graview 0.1.34 → 0.1.36

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 (132) hide show
  1. package/dist/preview/{chunk.3C4RJIJU.js → chunk.272ZJXQP.js} +1 -1
  2. package/dist/preview/{chunk.ETWVQ3A2.js → chunk.27TLAVRR.js} +1 -1
  3. package/dist/preview/{chunk.34CYK2DF.js → chunk.2A2DLMT3.js} +1 -1
  4. package/dist/preview/{chunk.FBY5IUGU.js → chunk.2B4WVCVV.js} +1 -1
  5. package/dist/preview/{chunk.ZE4CTZQ3.js → chunk.3PT55HXT.js} +1 -1
  6. package/dist/preview/{chunk.YJCT3DV2.js → chunk.3SM2CHKF.js} +1 -1
  7. package/dist/preview/{chunk.G64AREGA.js → chunk.3ZIOAPI5.js} +1 -1
  8. package/dist/preview/{chunk.HCDKSDIS.js → chunk.42WJ6VJZ.js} +1 -1
  9. package/dist/preview/{chunk.RIW7SQH4.js → chunk.4B73P2WA.js} +1 -1
  10. package/dist/preview/{chunk.CPW465TM.js → chunk.4GXXD4NG.js} +1 -1
  11. package/dist/preview/chunk.4Q56V7GS.js +1 -0
  12. package/dist/preview/{chunk.T2L4NPSB.js → chunk.4STIUIT6.js} +1 -1
  13. package/dist/preview/chunk.53IKY7UP.js +1 -0
  14. package/dist/preview/chunk.56BPXB6E.js +1 -0
  15. package/dist/preview/{chunk.7HPPJVIV.js → chunk.5PU3RWYY.js} +2 -2
  16. package/dist/preview/chunk.64MJ5FRL.js +1 -0
  17. package/dist/preview/chunk.6II4BONS.js +25 -0
  18. package/dist/preview/{chunk.VMGWYCXU.js → chunk.6KMXLUOS.js} +1 -1
  19. package/dist/preview/{chunk.MWJUZG3C.js → chunk.6QDFBCV4.js} +2 -2
  20. package/dist/preview/{chunk.IHFNLKXV.js → chunk.6W7J76TK.js} +1 -1
  21. package/dist/preview/{chunk.ZTFW7RKP.js → chunk.6ZZZBDEG.js} +1 -1
  22. package/dist/preview/{chunk.VOFUIWAX.js → chunk.7CO7S6QM.js} +1 -1
  23. package/dist/preview/chunk.7G3B5QPH.js +1 -0
  24. package/dist/preview/chunk.7TBSVQSH.js +1 -0
  25. package/dist/preview/{chunk.QVKKXMNK.js → chunk.7YQYWOZR.js} +1 -1
  26. package/dist/preview/{chunk.4K5QCJFH.js → chunk.AAZFVCSP.js} +1 -1
  27. package/dist/preview/{chunk.ZSW74NVJ.js → chunk.ACEYGWMO.js} +1 -1
  28. package/dist/preview/{chunk.HJ56Q6WB.js → chunk.ACXA55GW.js} +1 -1
  29. package/dist/preview/{chunk.PNVR3CXR.js → chunk.BZ5VLPKB.js} +2 -2
  30. package/dist/preview/chunk.CE3NOADH.js +1 -0
  31. package/dist/preview/chunk.CNJENUPC.js +1 -0
  32. package/dist/preview/{chunk.DMNXYMLC.js → chunk.CRPT3ZT3.js} +1 -1
  33. package/dist/preview/{chunk.XXMYKBLT.js → chunk.CUCNT7MG.js} +1 -1
  34. package/dist/preview/{chunk.U5ACEYAN.js → chunk.D6RDTUX3.js} +1 -1
  35. package/dist/preview/{chunk.UHQD3NTK.js → chunk.DANDYIB5.js} +1 -1
  36. package/dist/preview/{chunk.UCIQIPBQ.js → chunk.DSP62QYK.js} +1 -1
  37. package/dist/preview/chunk.E77K6KBX.js +1 -0
  38. package/dist/preview/{chunk.HPD5ZDZH.js → chunk.EBLKEQ7O.js} +1 -1
  39. package/dist/preview/{chunk.VSOB2QEK.js → chunk.EDSPYKR4.js} +1 -1
  40. package/dist/preview/chunk.EQIGKXIG.js +1 -0
  41. package/dist/preview/{chunk.HWITWOP3.js → chunk.ER5ILWKY.js} +2 -2
  42. package/dist/preview/{chunk.7VUPKOKC.js → chunk.ET76FISZ.js} +1 -1
  43. package/dist/preview/{chunk.X7W27IRI.js → chunk.F5BCCGFK.js} +5 -5
  44. package/dist/preview/{chunk.7X2ZO5BD.js → chunk.FERBNBDE.js} +1 -1
  45. package/dist/preview/{chunk.FUQVNXLB.js → chunk.FQKH67BP.js} +1 -1
  46. package/dist/preview/{chunk.577PGFUT.js → chunk.FUR4IHWG.js} +1 -1
  47. package/dist/preview/chunk.FWBQVPMI.js +1 -0
  48. package/dist/preview/{chunk.FRS3S7DN.js → chunk.GOCUBIRW.js} +1 -1
  49. package/dist/preview/{chunk.CNMITOKP.js → chunk.GUDKPK42.js} +1 -1
  50. package/dist/preview/{chunk.QVUL2FSI.js → chunk.GXLAZGYT.js} +1 -1
  51. package/dist/preview/{chunk.Z7ZCR4LN.js → chunk.GZLYTPE7.js} +1 -1
  52. package/dist/preview/{chunk.35KI7XYV.js → chunk.H4T56OXM.js} +1 -1
  53. package/dist/preview/{chunk.JQDYGI6G.js → chunk.HPX3F7XX.js} +1 -1
  54. package/dist/preview/{chunk.WYEYYCBH.js → chunk.HZPTBPJY.js} +1 -1
  55. package/dist/preview/{chunk.PW7YH6JV.js → chunk.IB32NOV5.js} +1 -1
  56. package/dist/preview/{chunk.FSAHO3LV.js → chunk.IMRCAU4T.js} +1 -1
  57. package/dist/preview/{chunk.6A62UVAE.js → chunk.ITXIFDQ7.js} +1 -1
  58. package/dist/preview/{chunk.2YCFK5HU.js → chunk.J3TEJBI5.js} +1 -1
  59. package/dist/preview/{chunk.7WHWD5YJ.js → chunk.JLXQ6ZLI.js} +1 -1
  60. package/dist/preview/{chunk.6FBQP336.js → chunk.JZMA2AV7.js} +1 -1
  61. package/dist/preview/{chunk.B6VI576I.js → chunk.K5NJTE3F.js} +1 -1
  62. package/dist/preview/{chunk.FCRFQ7ZW.js → chunk.KBJG5SI2.js} +1 -1
  63. package/dist/preview/{chunk.3H4NVUWV.js → chunk.KU6NIMQX.js} +1 -1
  64. package/dist/preview/{chunk.LAF6GTBN.js → chunk.LA7535VO.js} +1 -1
  65. package/dist/preview/{chunk.RN3EZVV4.js → chunk.LMVCWYYG.js} +1 -1
  66. package/dist/preview/{chunk.2YGQVI6T.js → chunk.LNNFNJKN.js} +1 -1
  67. package/dist/preview/{chunk.RH45AW2W.js → chunk.M4FQ7SSM.js} +1 -1
  68. package/dist/preview/{chunk.UA5UYINM.js → chunk.MXJS67W4.js} +1 -1
  69. package/dist/preview/{chunk.LIIC25G6.js → chunk.NJ62C2GU.js} +1 -1
  70. package/dist/preview/{chunk.VZHV25JE.js → chunk.NNCTJSD3.js} +1 -1
  71. package/dist/preview/{chunk.LCFDM7XY.js → chunk.NWYOLGQ3.js} +1 -1
  72. package/dist/preview/{chunk.DNDHDDM6.js → chunk.O3OALXCI.js} +2 -2
  73. package/dist/preview/{chunk.ZJX6ZKKM.js → chunk.O6ROFVFD.js} +1 -1
  74. package/dist/preview/{chunk.KSXB4LDF.js → chunk.OF34OZ4V.js} +1 -1
  75. package/dist/preview/{chunk.RYEAMM73.js → chunk.OFJH7LDC.js} +1 -1
  76. package/dist/preview/{chunk.Q7TP4RFE.js → chunk.OH5BBE2B.js} +1 -1
  77. package/dist/preview/{chunk.CZRX2FDI.js → chunk.OREMUXB5.js} +1 -1
  78. package/dist/preview/{chunk.AHCI7ZDO.js → chunk.OXZRGP53.js} +1 -1
  79. package/dist/preview/chunk.OZR5NI4J.js +1 -0
  80. package/dist/preview/{chunk.PPUAPAWR.js → chunk.P75TPZWT.js} +1 -1
  81. package/dist/preview/{chunk.WLBXBNNH.js → chunk.PWOVXARZ.js} +1 -1
  82. package/dist/preview/chunk.Q63RPNUS.js +1 -0
  83. package/dist/preview/{chunk.XK4FVT2X.js → chunk.QDHUDLJB.js} +1 -1
  84. package/dist/preview/{chunk.HP3ZEDCD.js → chunk.QEALNWWL.js} +3 -3
  85. package/dist/preview/{chunk.APNN6BKF.js → chunk.QLMUGC7R.js} +1 -1
  86. package/dist/preview/{chunk.6VRJII5M.js → chunk.QTITRX5Q.js} +1 -1
  87. package/dist/preview/{chunk.GMOTRAKJ.js → chunk.R45BF6JV.js} +1 -1
  88. package/dist/preview/{chunk.F6WYSDSI.js → chunk.R7LRJS6B.js} +2 -2
  89. package/dist/preview/{chunk.3MWBWSYF.js → chunk.RKHEZ6KZ.js} +1 -1
  90. package/dist/preview/{chunk.XZYJRNRY.js → chunk.S6GJGTJE.js} +1 -1
  91. package/dist/preview/{chunk.7MTX33WD.js → chunk.SG23JC6D.js} +1 -1
  92. package/dist/preview/chunk.SSRP5SBR.js +1 -0
  93. package/dist/preview/{chunk.T3M4FALL.js → chunk.T2CN7UTZ.js} +2 -2
  94. package/dist/preview/{chunk.B2WRXGFI.js → chunk.T47DLH5Z.js} +1 -1
  95. package/dist/preview/{chunk.BU2DSZ2L.js → chunk.TGEF6TMM.js} +1 -1
  96. package/dist/preview/{chunk.7JNDZWD6.js → chunk.UJR3Y7MP.js} +1 -1
  97. package/dist/preview/{chunk.52QAIGCD.js → chunk.VHWUGSFW.js} +1 -1
  98. package/dist/preview/{chunk.6K2HASOH.js → chunk.W42P7NOL.js} +1 -1
  99. package/dist/preview/{chunk.2UPGH6FT.js → chunk.WGI5G6NM.js} +1 -1
  100. package/dist/preview/{chunk.VKH3ZPPQ.js → chunk.WHTQHU3M.js} +1 -1
  101. package/dist/preview/{chunk.6XO4PECH.js → chunk.WJ2TWU2I.js} +1 -1
  102. package/dist/preview/chunk.WQBDTLPZ.js +1 -0
  103. package/dist/preview/{chunk.TCSZZAYB.js → chunk.XBTZXWJX.js} +1 -1
  104. package/dist/preview/{chunk.OMMKD2NU.js → chunk.XRCGADKC.js} +1 -1
  105. package/dist/preview/{chunk.SIH6RCAI.js → chunk.Y3IJDWNS.js} +1 -1
  106. package/dist/preview/{chunk.HUKAVTMX.js → chunk.YNE5QR7Q.js} +1 -1
  107. package/dist/preview/{chunk.5EAQDBBE.js → chunk.ZDNJK2SX.js} +1 -1
  108. package/dist/preview/{chunk.QU356VB2.js → chunk.ZEW2OOZ5.js} +1 -1
  109. package/dist/preview/chunk.ZNS3LYJU.js +1 -0
  110. package/dist/preview/{chunk.YT2CYCVT.js → chunk.ZSSOTIFL.js} +1 -1
  111. package/dist/preview/{chunk.WAB6ZS2V.js → chunk.ZVMIHXVK.js} +1 -1
  112. package/dist/preview/{chunk.DUUARGPE.js → chunk.ZWZ5SEXT.js} +1 -1
  113. package/dist/preview/index.html +42 -42
  114. package/dist/preview/page.js +2 -2
  115. package/package.json +6 -6
  116. package/dist/preview/chunk.6P7P2AW7.js +0 -1
  117. package/dist/preview/chunk.E7EQ2VTE.js +0 -1
  118. package/dist/preview/chunk.GNSAKLP2.js +0 -1
  119. package/dist/preview/chunk.HH6P4BLT.js +0 -1
  120. package/dist/preview/chunk.HPEGQN6E.js +0 -1
  121. package/dist/preview/chunk.JZBBGY4B.js +0 -1
  122. package/dist/preview/chunk.KA3KI4UA.js +0 -1
  123. package/dist/preview/chunk.M5HADQPP.js +0 -1
  124. package/dist/preview/chunk.QPAUQJON.js +0 -1
  125. package/dist/preview/chunk.SHPXD6FC.js +0 -1
  126. package/dist/preview/chunk.TPX6AVJL.js +0 -1
  127. package/dist/preview/chunk.WPCGHGDA.js +0 -1
  128. package/dist/preview/chunk.YCIX53AR.js +0 -1
  129. package/dist/preview/chunk.YEYY273R.js +0 -1
  130. package/dist/preview/chunk.ZFWV4JAJ.js +0 -1
  131. package/dist/preview/chunk.ZPQKAJRI.js +0 -1
  132. package/dist/preview/chunk.ZTD2CNC3.js +0 -25
@@ -1 +1 @@
1
- import"./chunk.GZHZLJBF.js";import{n as D}from"./chunk.WLBXBNNH.js";import"./chunk.7MTX33WD.js";import"./chunk.OJGHDWI6.js";import"./chunk.Z7ZCR4LN.js";import{a as $}from"./chunk.RIW7SQH4.js";import"./chunk.FSAHO3LV.js";import"./chunk.PNVR3CXR.js";import{F as P,Q as C}from"./chunk.ZTD2CNC3.js";import{Ba as w,Da as R,Ha as c,R as S}from"./chunk.X7W27IRI.js";import{b as k}from"./chunk.AJZBJBMO.js";var m=k(P(),1);var e=k(C(),1),W=[["","Does not repeat"],["day","Daily"],["week","Weekly"],["month","Monthly"],["year","Yearly"]],E=r=>`${r}${r%100>=11&&r%100<=13?"th":["th","st","nd","rd"][r%10]??"th"}`,v={display:"flex",flexWrap:"wrap",gap:"6px 12px",alignItems:"center"};function N({value:r,onChange:d,start:p,label:s,name:l="repeat"}){let f=(0,m.useId)(),a=c(r)?r:void 0,i=typeof p=="string"&&/^\d{4}-\d{2}-\d{2}/.test(p)?p:void 0,u=i?w[new Date(`${i.slice(0,10)}T00:00:00Z`).getUTCDay()]:void 0,o=t=>{let n={...a??{every:"week"},...t};for(let b of Object.keys(n))n[b]===void 0&&delete n[b];d(n)},y=a?.every??"week",g=a?.on??(u?[u]:[]);return(0,e.jsxs)("fieldset",{"data-graview-part":"field","data-graview-field":"repeat","data-graview-repeat":l,style:{display:"grid",gap:8,border:"1px solid var(--graview-edge)",borderRadius:8,padding:"8px 12px",margin:0,minWidth:0},children:[(0,e.jsx)("legend",{"data-graview-part":"label",style:{padding:"0 4px"},children:s}),(0,e.jsxs)("div",{style:v,children:[(0,e.jsx)("label",{htmlFor:`${f}-every`,children:"Repeats"}),(0,e.jsx)("select",{id:`${f}-every`,name:`${l}.every`,value:a?.every??"",onChange:t=>{let n=t.target.value;d(n===""?void 0:{...a?.interval?{interval:a.interval}:{},...a?.until?{until:a.until}:{},every:n})},"data-graview-part":"control",children:W.map(([t,n])=>(0,e.jsx)("option",{value:t,children:n},t))}),a?(0,e.jsxs)("label",{style:v,children:["every",(0,e.jsx)("input",{type:"number",min:1,max:99,name:`${l}.interval`,"aria-label":`Every how many ${y}s`,value:a.interval??1,onChange:t=>o({interval:Number(t.target.value)>1?Math.min(99,Math.round(Number(t.target.value))):void 0}),style:{width:"4.5em"},"data-graview-part":"control"}),y,(a.interval??1)>1?"s":""]}):null]}),a?.every==="week"?(0,e.jsxs)("div",{role:"group","aria-label":"On",style:v,children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"On"}),w.map((t,n)=>(0,e.jsxs)("label",{style:{display:"inline-flex",gap:4,alignItems:"center",minHeight:24},children:[(0,e.jsx)("input",{type:"checkbox",name:`${l}.on`,value:t,checked:g.includes(t),onChange:b=>{let h=w.filter(x=>x===t?b.target.checked:g.includes(x));o({on:h.length===0||h.length===1&&h[0]===u?void 0:h})}}),S(n,"short")]},t))]}):null,a?.every==="month"?(0,e.jsxs)("label",{style:v,children:["On",(0,e.jsxs)("select",{name:`${l}.on`,value:a.on?.[0]===-1?"last":"",onChange:t=>o({on:t.target.value==="last"?[-1]:void 0}),"data-graview-part":"control",children:[(0,e.jsx)("option",{value:"",children:i?`the ${E(Number(i.slice(8,10)))}`:"the same day"}),(0,e.jsx)("option",{value:"last",children:"the last day"})]})]}):null,a?(0,e.jsxs)("label",{style:v,children:["Until",(0,e.jsx)("input",{type:"date",name:`${l}.until`,value:a.until??"",onChange:t=>o({until:t.target.value||void 0}),"data-graview-part":"control"})]}):null,(0,e.jsx)("p",{"aria-live":"polite","data-graview-repeat-said":"",style:{margin:0,color:"var(--graview-ink-dim)",fontSize:"0.8125rem"},children:a?$(i??"",a):"Does not repeat"})]})}function M({nodeId:r,field:d,start:p,value:s,label:l}){let{fields:f,commit:a}=D(r),i=f.find(t=>t.field===R(d)&&t.takesValue&&t.open.length===0),[u,o]=(0,m.useState)(!1),[y,g]=(0,m.useState)(c(s)?s:void 0);return i?u?(0,e.jsxs)("form",{onSubmit:t=>{t.preventDefault(),o(!1),a(i,y??null)},style:{display:"grid",gap:6,marginTop:6},children:[(0,e.jsx)(N,{value:y,onChange:g,start:p,label:l,name:R(d)}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("button",{type:"submit","data-graview-repeat-keep":d,children:"Keep"}),(0,e.jsx)("button",{type:"button",onClick:()=>o(!1),children:"Cancel"})]})]}):(0,e.jsx)("button",{type:"button","data-graview-repeat-open":d,onClick:()=>(g(c(s)?s:void 0),o(!0)),style:{marginInlineStart:8,fontSize:"0.75rem",padding:"1px 8px",borderRadius:999,minHeight:24},children:c(s)?"Change how it repeats":"Repeat\u2026"}):null}export{M as RepeatEditor,N as RepeatPicker};
1
+ import"./chunk.GZHZLJBF.js";import{n as D}from"./chunk.PWOVXARZ.js";import"./chunk.SG23JC6D.js";import"./chunk.OJGHDWI6.js";import"./chunk.GZLYTPE7.js";import{a as $}from"./chunk.4B73P2WA.js";import"./chunk.IMRCAU4T.js";import"./chunk.BZ5VLPKB.js";import{F as P,Q as C}from"./chunk.6II4BONS.js";import{Ca as w,Ea as R,Ia as c,R as S}from"./chunk.F5BCCGFK.js";import{b as k}from"./chunk.AJZBJBMO.js";var m=k(P(),1);var e=k(C(),1),W=[["","Does not repeat"],["day","Daily"],["week","Weekly"],["month","Monthly"],["year","Yearly"]],E=r=>`${r}${r%100>=11&&r%100<=13?"th":["th","st","nd","rd"][r%10]??"th"}`,v={display:"flex",flexWrap:"wrap",gap:"6px 12px",alignItems:"center"};function N({value:r,onChange:d,start:p,label:s,name:l="repeat"}){let f=(0,m.useId)(),a=c(r)?r:void 0,i=typeof p=="string"&&/^\d{4}-\d{2}-\d{2}/.test(p)?p:void 0,u=i?w[new Date(`${i.slice(0,10)}T00:00:00Z`).getUTCDay()]:void 0,o=t=>{let n={...a??{every:"week"},...t};for(let b of Object.keys(n))n[b]===void 0&&delete n[b];d(n)},y=a?.every??"week",g=a?.on??(u?[u]:[]);return(0,e.jsxs)("fieldset",{"data-graview-part":"field","data-graview-field":"repeat","data-graview-repeat":l,style:{display:"grid",gap:8,border:"1px solid var(--graview-edge)",borderRadius:8,padding:"8px 12px",margin:0,minWidth:0},children:[(0,e.jsx)("legend",{"data-graview-part":"label",style:{padding:"0 4px"},children:s}),(0,e.jsxs)("div",{style:v,children:[(0,e.jsx)("label",{htmlFor:`${f}-every`,children:"Repeats"}),(0,e.jsx)("select",{id:`${f}-every`,name:`${l}.every`,value:a?.every??"",onChange:t=>{let n=t.target.value;d(n===""?void 0:{...a?.interval?{interval:a.interval}:{},...a?.until?{until:a.until}:{},every:n})},"data-graview-part":"control",children:W.map(([t,n])=>(0,e.jsx)("option",{value:t,children:n},t))}),a?(0,e.jsxs)("label",{style:v,children:["every",(0,e.jsx)("input",{type:"number",min:1,max:99,name:`${l}.interval`,"aria-label":`Every how many ${y}s`,value:a.interval??1,onChange:t=>o({interval:Number(t.target.value)>1?Math.min(99,Math.round(Number(t.target.value))):void 0}),style:{width:"4.5em"},"data-graview-part":"control"}),y,(a.interval??1)>1?"s":""]}):null]}),a?.every==="week"?(0,e.jsxs)("div",{role:"group","aria-label":"On",style:v,children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"On"}),w.map((t,n)=>(0,e.jsxs)("label",{style:{display:"inline-flex",gap:4,alignItems:"center",minHeight:24},children:[(0,e.jsx)("input",{type:"checkbox",name:`${l}.on`,value:t,checked:g.includes(t),onChange:b=>{let h=w.filter(x=>x===t?b.target.checked:g.includes(x));o({on:h.length===0||h.length===1&&h[0]===u?void 0:h})}}),S(n,"short")]},t))]}):null,a?.every==="month"?(0,e.jsxs)("label",{style:v,children:["On",(0,e.jsxs)("select",{name:`${l}.on`,value:a.on?.[0]===-1?"last":"",onChange:t=>o({on:t.target.value==="last"?[-1]:void 0}),"data-graview-part":"control",children:[(0,e.jsx)("option",{value:"",children:i?`the ${E(Number(i.slice(8,10)))}`:"the same day"}),(0,e.jsx)("option",{value:"last",children:"the last day"})]})]}):null,a?(0,e.jsxs)("label",{style:v,children:["Until",(0,e.jsx)("input",{type:"date",name:`${l}.until`,value:a.until??"",onChange:t=>o({until:t.target.value||void 0}),"data-graview-part":"control"})]}):null,(0,e.jsx)("p",{"aria-live":"polite","data-graview-repeat-said":"",style:{margin:0,color:"var(--graview-ink-dim)",fontSize:"0.8125rem"},children:a?$(i??"",a):"Does not repeat"})]})}function M({nodeId:r,field:d,start:p,value:s,label:l}){let{fields:f,commit:a}=D(r),i=f.find(t=>t.field===R(d)&&t.takesValue&&t.open.length===0),[u,o]=(0,m.useState)(!1),[y,g]=(0,m.useState)(c(s)?s:void 0);return i?u?(0,e.jsxs)("form",{onSubmit:t=>{t.preventDefault(),o(!1),a(i,y??null)},style:{display:"grid",gap:6,marginTop:6},children:[(0,e.jsx)(N,{value:y,onChange:g,start:p,label:l,name:R(d)}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("button",{type:"submit","data-graview-repeat-keep":d,children:"Keep"}),(0,e.jsx)("button",{type:"button",onClick:()=>o(!1),children:"Cancel"})]})]}):(0,e.jsx)("button",{type:"button","data-graview-repeat-open":d,onClick:()=>(g(c(s)?s:void 0),o(!0)),style:{marginInlineStart:8,fontSize:"0.75rem",padding:"1px 8px",borderRadius:999,minHeight:24},children:c(s)?"Change how it repeats":"Repeat\u2026"}):null}export{M as RepeatEditor,N as RepeatPicker};
@@ -1,4 +1,4 @@
1
- import"./chunk.PNVR3CXR.js";import{Q as T}from"./chunk.ZTD2CNC3.js";import"./chunk.X7W27IRI.js";import{b as A}from"./chunk.AJZBJBMO.js";var F=/^ {0,3}(`{3,}|~{3,})[ \t]*([^`\s]*)/,D=/^ {0,3}(#{1,6})(?:[ \t]+|$)/,R=/^ {0,3}(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/,v=/^ {0,3}>[ \t]?/,_=/^([ \t]*)([-*+]|(\d{1,9})[.)])(?:[ \t]+|$)/,K=/^\|?\s*:?-+:?\s*(?:\|\s*:?-+:?\s*)+\|?$|^\|\s*:?-+:?\s*\|$/,w=/^[ \t]*$/;function O(t){let n=F.exec(t);if(!(!n||n[1][0]==="`"&&t.indexOf("`",n[0].length)>=0))return{mark:n[1],lang:n[2]}}function U(t,n){let r=t.trim().slice(n).trim(),e=r.length;for(;e>0&&r[e-1]==="#";)e--;return(e===0||r[e-1]===" "||r[e-1]===" ")&&(r=r.slice(0,e).trim()),r}var $=t=>O(t)!==void 0||D.test(t)||R.test(t)||v.test(t)||_.test(t),b=t=>[...t].reduce((n,r)=>r===" "?n+4-n%4:n+1,0);function E(t){let n=t.trim().replace(/^\|/,"").replace(/(?<!\\)\|$/,""),r=[],e="",l=!1;for(let c=0;c<n.length;c++){let h=n[c];h==="\\"&&n[c+1]==="|"?(e+="|",c++):h==="`"?(l=!l,e+=h):h==="|"&&!l?(r.push(e.trim()),e=""):e+=h}return r.push(e.trim()),r}function W(t){return B(t.replace(/\r\n?/g,`
1
+ import"./chunk.BZ5VLPKB.js";import{Q as T}from"./chunk.6II4BONS.js";import"./chunk.F5BCCGFK.js";import{b as A}from"./chunk.AJZBJBMO.js";var F=/^ {0,3}(`{3,}|~{3,})[ \t]*([^`\s]*)/,D=/^ {0,3}(#{1,6})(?:[ \t]+|$)/,R=/^ {0,3}(?:(?:-[ \t]*){3,}|(?:\*[ \t]*){3,}|(?:_[ \t]*){3,})$/,v=/^ {0,3}>[ \t]?/,_=/^([ \t]*)([-*+]|(\d{1,9})[.)])(?:[ \t]+|$)/,K=/^\|?\s*:?-+:?\s*(?:\|\s*:?-+:?\s*)+\|?$|^\|\s*:?-+:?\s*\|$/,w=/^[ \t]*$/;function O(t){let n=F.exec(t);if(!(!n||n[1][0]==="`"&&t.indexOf("`",n[0].length)>=0))return{mark:n[1],lang:n[2]}}function U(t,n){let r=t.trim().slice(n).trim(),e=r.length;for(;e>0&&r[e-1]==="#";)e--;return(e===0||r[e-1]===" "||r[e-1]===" ")&&(r=r.slice(0,e).trim()),r}var $=t=>O(t)!==void 0||D.test(t)||R.test(t)||v.test(t)||_.test(t),b=t=>[...t].reduce((n,r)=>r===" "?n+4-n%4:n+1,0);function E(t){let n=t.trim().replace(/^\|/,"").replace(/(?<!\\)\|$/,""),r=[],e="",l=!1;for(let c=0;c<n.length;c++){let h=n[c];h==="\\"&&n[c+1]==="|"?(e+="|",c++):h==="`"?(l=!l,e+=h):h==="|"&&!l?(r.push(e.trim()),e=""):e+=h}return r.push(e.trim()),r}function W(t){return B(t.replace(/\r\n?/g,`
2
2
  `).replace(/\0/g,"\uFFFD").split(`
3
3
  `),0)}function B(t,n){let r=[],e=0;for(;e<t.length;){let l=t[e];if(w.test(l)){e++;continue}let c=O(l);if(c){let o=new RegExp(`^ {0,3}${c.mark[0]==="`"?"`":"~"}{${c.mark.length},}[ \\t]*$`),a=[];for(e++;e<t.length&&!o.test(t[e]);)a.push(t[e++]);e++,r.push({t:"code",text:a.join(`
4
4
  `),...c.lang?{lang:c.lang}:{}});continue}let h=D.exec(l);if(h){r.push({t:"heading",level:h[1].length,children:k(U(l,h[1].length),0)}),e++;continue}if(R.test(l)){r.push({t:"rule"}),e++;continue}if(v.test(l)){let o=[];for(;e<t.length&&(v.test(t[e])||o.length>0&&!w.test(t[e])&&!$(t[e])&&!w.test(o[o.length-1]));)o.push(t[e++].replace(v,""));r.push(n<8?{t:"quote",blocks:B(o,n+1)}:{t:"p",children:k(o.join(`
@@ -1 +1 @@
1
- import{C as Q,E as X,I as Y,K as Z,N as ee,a as N,i as K,l as z,o as D,p as W,t as _,u as j,w as U,z as J}from"./chunk.PNVR3CXR.js";import{F as se,Q as T,Y as $,_ as G,ka as V,ra as q}from"./chunk.ZTD2CNC3.js";import{Mb as M,Vb as P,Xb as O,xc as I}from"./chunk.X7W27IRI.js";import{b as k}from"./chunk.AJZBJBMO.js";var o=k(se(),1);function ie(e){let t=[e?.typography?.body,e?.typography?.display,e?.typography?.mono],n=[];for(let a of t){let r=a?.split(",")[0]?.trim().replace(/^["']|["']$/g,"");!r||O(r)||r.toLowerCase()!==M.toLowerCase()&&(n.includes(r)||n.push(r))}return n}function ne(e){let t=ie(e);return t.length===0?null:`https://fonts.googleapis.com/css2?${t.map(a=>`family=${encodeURIComponent(a).replace(/%20/g,"+")}:wght@400;500;600;700`).join("&")}&display=swap`}var l=k(T(),1);function be({rootRef:e,firstLook:t,app:n}){let a=(0,o.useCallback)(()=>e.current,[e]);return t?(0,l.jsx)(ee,{firstLook:t,root:a,app:n}):null}function Se(e,t){let{app:n}=e;return(0,o.useMemo)(()=>{let a=Y(t(n.schema,n.viewSpecs),n),r=e.views?V(a,e.views(n.schema,a)):a;return Z(r,n.schema,Q(e.brand??n.brand,n.schema)),r},[e.views,n.schema,n.viewSpecs,n.lenses,n.pages,n.home])}function ce(e,t){return new I({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.intelligence?{intelligence:e.intelligence}:{}})}function te(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 de(e,t){let[n,a]=(0,o.useState)(()=>te(t));return(0,o.useEffect)(()=>{if(!e||typeof document>"u")return;let r=()=>a(te(t));r();let i=new MutationObserver(r);i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let d=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return d?.addEventListener?.("change",r),()=>{i.disconnect(),d?.removeEventListener?.("change",r)}},[e,t]),n}var A=e=>e?e.getBoundingClientRect().height:0;function ve(e,t,n){let a=(0,o.useRef)(n);a.current=n;let r=n!==void 0;(0,o.useLayoutEffect)(()=>{let i=e.current;if(!i||!r)return;let d=()=>{let u=[...i.children],b=u.find(S=>S.hasAttribute("data-graview-app-bar")),y=u.find(S=>S.hasAttribute("data-embed-content")),h=y?.querySelector("[data-embed-measure]")??null,c=u.find(S=>S.hasAttribute("data-graview-place-line"));return{strip:b,line:c,content:y,measure:h}},s=-1,f=()=>{let{strip:u,line:b,content:y,measure:h}=d(),c=Math.ceil(A(u)+A(b)+A(h||y));c!==s&&(s=c,a.current?.(c))};if(f(),typeof ResizeObserver>"u")return;let m=new ResizeObserver(f),E=()=>{m.disconnect();let{strip:u,line:b,content:y,measure:h}=d();for(let c of[i,u,b,y,h])c&&m.observe(c)};E();let g=new MutationObserver(()=>{E(),f()});return g.observe(i,{childList:!0}),()=>{m.disconnect(),g.disconnect()}},[e,t,r])}var we=480,le=0;function Ee(e){let{app:t,seed:n,scheme:a="auto",brand:r=t.brand,fonts:i=!0,height:d="100%",label:s}=e,f=(0,o.useRef)(null);q(f);let m=d==="viewport"?"100dvh":d,E=z(typeof m=="string"&&/vh\b/.test(m)),g=(0,o.useMemo)(()=>`graview-embed-${++le}`,[]),u=(0,o.useMemo)(()=>e.store??e.remote?.store??ce(t,n),[e.store,e.remote,t,n]),b=e.presence??e.remote?.presence,y=e.hostContext?.theme,h=de(a==="auto"&&y===void 0,r?.scheme),c=a==="auto"?y??h:a,S=(0,o.useMemo)(()=>N(c,r,{scope:`.${g}`}),[c,r,g]);K(e.favicon?P(r):void 0),(0,o.useEffect)(()=>{if(!i||typeof document>"u")return;let w=ne(r);if(!w||document.querySelector(`link[href="${w}"]`))return;let p=document.createElement("link");p.rel="stylesheet",p.href=w,document.head.appendChild(p)},[r,i]);let L=(0,o.useRef)(void 0);(0,o.useLayoutEffect)(()=>{let w=f.current,p=L.current;if(L.current=s,!w||!s)return;let ae=v=>{let R=v.getAttribute("aria-label")??"",x=p&&p!==s?R.startsWith(`${p} \xB7 `)?R.slice(p.length+3):R===p?"":R:R;x===s&&(v.getAttribute("role")==="region"||v.tagName==="SECTION"&&!v.hasAttribute("role"))&&v.setAttribute("role","group");let B=x.startsWith(`${s} \xB7 `)||x===s?x:x?`${s} \xB7 ${x}`:s;B!==R&&v.setAttribute("aria-label",B)},H=()=>w.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(v=>{v.hasAttribute("data-graview-named-by-lens")||ae(v)});H();let C=new MutationObserver(H);return C.observe(w,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>C.disconnect()},[s]);let oe=E?`${m}`.replace(/([\d.]+)[sdl]?vh\b/g,(w,p)=>`${+p*E/100}px`):m;return{rootRef:f,scope:g,css:S,scheme:c,store:u,presence:b,brand:r,auto:d==="auto",height:oe}}function Re({rootRef:e,board:t}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,l.jsx)(J,{board:t,anchor:n})}function xe(e,t,n){return{brand:n,locale:e.locale,principal:e.principal,seats:e.seats,presence:t,people:e.people,memory:e.memory,presenceTtlMs:e.presenceTtlMs,onKeepLens:e.onKeepLens,ai:e.ai,files:e.files,resolveApp:e.resolveApp,history:e.history,linkedRecords:e.linkedRecords,subscriptions:e.subscriptions,signIn:e.signIn,menuSections:e.menuSections,app:e.app}}function Ae({name:e,heading:t,faces:n,at:a,without:r,home:i,reach:d,standing:s,hostActions:f,keeping:m,onFind:E,switch:g}){let{brand:u,store:b,principal:y,views:h}=$();G();let c=r?.has("places")?[]:D({store:b,principal:y,views:h}),S=U();return(0,l.jsx)(_,{brand:u,name:e,description:u?.subtitle,heading:t,faces:n,home:i,places:c,current:a===null?null:W(c,a),reach:d,onFind:E,...g?{switch:g}:{},...n?{scenePlaces:S}:{},tools:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(X,{clean:s}),(0,l.jsx)(j,{...f?{hostActions:f}:{},...m?{keeping:m}:{}})]})})}var ke=e=>e===!1?2:Math.min(e+1,6);function Fe(e){let[t,n]=(0,o.useState)(e),a=(0,o.useRef)(void 0),r=(0,o.useRef)(void 0),i=(0,o.useMemo)(()=>({go:a,at:n,pending:r}),[]),d=(0,o.useCallback)(s=>{if(a.current){a.current(s);return}r.current=s,n(s)},[]);return{at:t,setAt:n,steering:i,steer:d}}function ue(e){let t=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof t=="string"&&t.length>0?t:typeof e=="object"?"Error":typeof e}}var F=()=>typeof performance<"u"?performance.now():Date.now();function Le(e,t){let n=(0,o.useRef)({onError:e,face:t});return n.current={onError:e,face:t},(0,o.useCallback)((a,r)=>n.current.onError?.(ue(a),{module:r.module,face:n.current.face}),[])}function He(e,t){let n=(0,o.useRef)(null);n.current===null&&(n.current=F());let a=(0,o.useRef)({onReady:e,face:t});a.current={onReady:e,face:t};let r=(0,o.useRef)(!1);return(0,o.useCallback)(i=>{r.current||(r.current=!0,a.current.onReady?.({ms:Math.max(0,F()-(n.current??F())),face:i}))},[])}var re=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t,n){console.error(`[graview] ${this.props.module} threw while rendering`,t,n.componentStack),this.props.report(t,{module:this.props.module})}render(){return this.state.failed?(0,l.jsxs)("div",{role:"alert","data-graview-face-error":this.props.module,...this.props.content?{"data-embed-content":""}:{},style:this.props.content?{flex:"1 1 auto",display:"grid",alignContent:"center",justifyItems:"center",gap:8,padding:24,background:"var(--graview-ground)",color:"var(--graview-ink)",fontSize:"0.9375rem"}:{display:"inline-flex",alignItems:"center",gap:6,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,l.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,l.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{be as a,Se as b,ce as c,ve as d,we as e,Ee as f,Re as g,xe as h,Ae as i,ke as j,Fe as k,Le as l,He as m,re as n};
1
+ import{C as Q,E as X,I as Y,K as Z,N as ee,a as N,i as K,l as z,o as D,p as W,t as _,u as j,w as U,z as J}from"./chunk.BZ5VLPKB.js";import{F as se,Q as T,Y as $,_ as G,ka as V,ra as q}from"./chunk.6II4BONS.js";import{Nb as M,Wb as P,Yb as O,yc as I}from"./chunk.F5BCCGFK.js";import{b as k}from"./chunk.AJZBJBMO.js";var o=k(se(),1);function ie(e){let t=[e?.typography?.body,e?.typography?.display,e?.typography?.mono],n=[];for(let a of t){let r=a?.split(",")[0]?.trim().replace(/^["']|["']$/g,"");!r||O(r)||r.toLowerCase()!==M.toLowerCase()&&(n.includes(r)||n.push(r))}return n}function ne(e){let t=ie(e);return t.length===0?null:`https://fonts.googleapis.com/css2?${t.map(a=>`family=${encodeURIComponent(a).replace(/%20/g,"+")}:wght@400;500;600;700`).join("&")}&display=swap`}var l=k(T(),1);function be({rootRef:e,firstLook:t,app:n}){let a=(0,o.useCallback)(()=>e.current,[e]);return t?(0,l.jsx)(ee,{firstLook:t,root:a,app:n}):null}function Se(e,t){let{app:n}=e;return(0,o.useMemo)(()=>{let a=Y(t(n.schema,n.viewSpecs),n),r=e.views?V(a,e.views(n.schema,a)):a;return Z(r,n.schema,Q(e.brand??n.brand,n.schema)),r},[e.views,n.schema,n.viewSpecs,n.lenses,n.pages,n.home])}function ce(e,t){return new I({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.intelligence?{intelligence:e.intelligence}:{}})}function te(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 de(e,t){let[n,a]=(0,o.useState)(()=>te(t));return(0,o.useEffect)(()=>{if(!e||typeof document>"u")return;let r=()=>a(te(t));r();let i=new MutationObserver(r);i.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let d=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return d?.addEventListener?.("change",r),()=>{i.disconnect(),d?.removeEventListener?.("change",r)}},[e,t]),n}var A=e=>e?e.getBoundingClientRect().height:0;function ve(e,t,n){let a=(0,o.useRef)(n);a.current=n;let r=n!==void 0;(0,o.useLayoutEffect)(()=>{let i=e.current;if(!i||!r)return;let d=()=>{let u=[...i.children],b=u.find(S=>S.hasAttribute("data-graview-app-bar")),y=u.find(S=>S.hasAttribute("data-embed-content")),h=y?.querySelector("[data-embed-measure]")??null,c=u.find(S=>S.hasAttribute("data-graview-place-line"));return{strip:b,line:c,content:y,measure:h}},s=-1,f=()=>{let{strip:u,line:b,content:y,measure:h}=d(),c=Math.ceil(A(u)+A(b)+A(h||y));c!==s&&(s=c,a.current?.(c))};if(f(),typeof ResizeObserver>"u")return;let m=new ResizeObserver(f),E=()=>{m.disconnect();let{strip:u,line:b,content:y,measure:h}=d();for(let c of[i,u,b,y,h])c&&m.observe(c)};E();let g=new MutationObserver(()=>{E(),f()});return g.observe(i,{childList:!0}),()=>{m.disconnect(),g.disconnect()}},[e,t,r])}var we=480,le=0;function Ee(e){let{app:t,seed:n,scheme:a="auto",brand:r=t.brand,fonts:i=!0,height:d="100%",label:s}=e,f=(0,o.useRef)(null);q(f);let m=d==="viewport"?"100dvh":d,E=z(typeof m=="string"&&/vh\b/.test(m)),g=(0,o.useMemo)(()=>`graview-embed-${++le}`,[]),u=(0,o.useMemo)(()=>e.store??e.remote?.store??ce(t,n),[e.store,e.remote,t,n]),b=e.presence??e.remote?.presence,y=e.hostContext?.theme,h=de(a==="auto"&&y===void 0,r?.scheme),c=a==="auto"?y??h:a,S=(0,o.useMemo)(()=>N(c,r,{scope:`.${g}`}),[c,r,g]);K(e.favicon?P(r):void 0),(0,o.useEffect)(()=>{if(!i||typeof document>"u")return;let w=ne(r);if(!w||document.querySelector(`link[href="${w}"]`))return;let p=document.createElement("link");p.rel="stylesheet",p.href=w,document.head.appendChild(p)},[r,i]);let L=(0,o.useRef)(void 0);(0,o.useLayoutEffect)(()=>{let w=f.current,p=L.current;if(L.current=s,!w||!s)return;let ae=v=>{let R=v.getAttribute("aria-label")??"",x=p&&p!==s?R.startsWith(`${p} \xB7 `)?R.slice(p.length+3):R===p?"":R:R;x===s&&(v.getAttribute("role")==="region"||v.tagName==="SECTION"&&!v.hasAttribute("role"))&&v.setAttribute("role","group");let B=x.startsWith(`${s} \xB7 `)||x===s?x:x?`${s} \xB7 ${x}`:s;B!==R&&v.setAttribute("aria-label",B)},H=()=>w.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(v=>{v.hasAttribute("data-graview-named-by-lens")||ae(v)});H();let C=new MutationObserver(H);return C.observe(w,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>C.disconnect()},[s]);let oe=E?`${m}`.replace(/([\d.]+)[sdl]?vh\b/g,(w,p)=>`${+p*E/100}px`):m;return{rootRef:f,scope:g,css:S,scheme:c,store:u,presence:b,brand:r,auto:d==="auto",height:oe}}function Re({rootRef:e,board:t}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,l.jsx)(J,{board:t,anchor:n})}function xe(e,t,n){return{brand:n,locale:e.locale,principal:e.principal,seats:e.seats,presence:t,people:e.people,memory:e.memory,presenceTtlMs:e.presenceTtlMs,onKeepLens:e.onKeepLens,ai:e.ai,files:e.files,resolveApp:e.resolveApp,history:e.history,linkedRecords:e.linkedRecords,subscriptions:e.subscriptions,signIn:e.signIn,menuSections:e.menuSections,app:e.app}}function Ae({name:e,heading:t,faces:n,at:a,without:r,home:i,reach:d,standing:s,hostActions:f,keeping:m,onFind:E,switch:g}){let{brand:u,store:b,principal:y,views:h}=$();G();let c=r?.has("places")?[]:D({store:b,principal:y,views:h}),S=U();return(0,l.jsx)(_,{brand:u,name:e,description:u?.subtitle,heading:t,faces:n,home:i,places:c,current:a===null?null:W(c,a),reach:d,onFind:E,...g?{switch:g}:{},...n?{scenePlaces:S}:{},tools:(0,l.jsxs)(l.Fragment,{children:[(0,l.jsx)(X,{clean:s}),(0,l.jsx)(j,{...f?{hostActions:f}:{},...m?{keeping:m}:{}})]})})}var ke=e=>e===!1?2:Math.min(e+1,6);function Fe(e){let[t,n]=(0,o.useState)(e),a=(0,o.useRef)(void 0),r=(0,o.useRef)(void 0),i=(0,o.useMemo)(()=>({go:a,at:n,pending:r}),[]),d=(0,o.useCallback)(s=>{if(a.current){a.current(s);return}r.current=s,n(s)},[]);return{at:t,setAt:n,steering:i,steer:d}}function ue(e){let t=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof t=="string"&&t.length>0?t:typeof e=="object"?"Error":typeof e}}var F=()=>typeof performance<"u"?performance.now():Date.now();function Le(e,t){let n=(0,o.useRef)({onError:e,face:t});return n.current={onError:e,face:t},(0,o.useCallback)((a,r)=>n.current.onError?.(ue(a),{module:r.module,face:n.current.face}),[])}function He(e,t){let n=(0,o.useRef)(null);n.current===null&&(n.current=F());let a=(0,o.useRef)({onReady:e,face:t});a.current={onReady:e,face:t};let r=(0,o.useRef)(!1);return(0,o.useCallback)(i=>{r.current||(r.current=!0,a.current.onReady?.({ms:Math.max(0,F()-(n.current??F())),face:i}))},[])}var re=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t,n){console.error(`[graview] ${this.props.module} threw while rendering`,t,n.componentStack),this.props.report(t,{module:this.props.module})}render(){return this.state.failed?(0,l.jsxs)("div",{role:"alert","data-graview-face-error":this.props.module,...this.props.content?{"data-embed-content":""}:{},style:this.props.content?{flex:"1 1 auto",display:"grid",alignContent:"center",justifyItems:"center",gap:8,padding:24,background:"var(--graview-ground)",color:"var(--graview-ink)",fontSize:"0.9375rem"}:{display:"inline-flex",alignItems:"center",gap:6,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,l.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,l.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{be as a,Se as b,ce as c,ve as d,we as e,Ee as f,Re as g,xe as h,Ae as i,ke as j,Fe as k,Le as l,He as m,re as n};
@@ -1 +1 @@
1
- import{H as W}from"./chunk.PNVR3CXR.js";import{F as H,b as A,c as T,d as v,e as f,f as x,k as I,n as b,pa as k,w as R}from"./chunk.ZTD2CNC3.js";import{Qc as s,Wc as y,Xc as r}from"./chunk.X7W27IRI.js";import{b as B}from"./chunk.AJZBJBMO.js";var u=B(H(),1),L=e=>typeof e=="object"&&e!==null&&"idx"in e;function E(e){let n=r(window.location.pathname,e);return n===null?null:n!==s&&n!=="/"?"pages":n===s||window.location.href.includes("#")?f(window.location.hash).overview?"graview":"scene":L(window.history.state)?"pages":null}function J(e){let n=e.face??(e.stop&&v(e.stop).overview?"graview":"scene");return e.routing!=="address"||typeof window>"u"?n:E(e.basePath)??n}function K(e){return e.routing!=="address"||typeof window>"u"?!1:r(window.location.pathname,e.basePath)==="/"&&E(e.basePath)===null}function Q(e){if(typeof window>"u")return;let n=r(window.location.pathname,e);return n===s||n==="/"&&window.location.href.includes("#")?T(f(window.location.hash)):void 0}function X({basePath:e,pagesWere:n,shown:t,onFace:i,toggle:l,kinds:U,places:w,opens:$}){let{view:F,go:p}=k(),g=(0,u.useRef)({shown:t,view:F,onFace:i});g.current={shown:t,view:F,onFace:i};let S=(0,u.useRef)(n??"/"),M=()=>{S.current=`${r(window.location.pathname,e)??"/"}${window.location.search}`};return l.current=(o,c,a)=>{let{shown:d,view:N,onFace:V}=g.current;if(o==="pages"&&d!=="pages")window.history.pushState(null,"",y(c??S.current,{basePath:e}));else if(o!=="pages"&&d==="pages"){M();let m=a===void 0?N:j(v(a),w),h=Y(m)?q($):m,O=h!==m&&h.overview?"graview":o,P=_(O,h,U);p(P),window.history.pushState(null,"",`${y(s,{basePath:e})}${x(P)}`),V?.(O);return}V?.(o)},(0,u.useEffect)(()=>{let o=()=>{if(r(window.location.pathname,e)===null)return;let c=E(e)??"pages",{shown:a,onFace:d}=g.current;if(c==="pages"){a!=="pages"&&d?.("pages");return}a==="pages"&&(p(j(f(window.location.hash),w)),d?.(c))};return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[e,p,w]),null}function j(e,n){let t=e.within?.view,i=t!==void 0&&!e.focusId?n.find(l=>l.as===t):void 0;return i?{...e,focusId:R(i.kind)}:e}function _(e,n,t){return e==="graview"?b(n,!0):n.overview?I(b(n,!1),W(n,t)):n}function Y(e){return e.focusId===null&&e.overview!==!0}function q(e){return e??{...A,overview:!0}}export{J as a,K as b,Q as c,X as d,j as e,_ as f,Y as g,q as h};
1
+ import{H as W}from"./chunk.BZ5VLPKB.js";import{F as H,b as A,c as T,d as v,e as f,f as x,k as I,n as b,pa as k,w as R}from"./chunk.6II4BONS.js";import{Rc as s,Xc as y,Yc as r}from"./chunk.F5BCCGFK.js";import{b as B}from"./chunk.AJZBJBMO.js";var u=B(H(),1),L=e=>typeof e=="object"&&e!==null&&"idx"in e;function E(e){let n=r(window.location.pathname,e);return n===null?null:n!==s&&n!=="/"?"pages":n===s||window.location.href.includes("#")?f(window.location.hash).overview?"graview":"scene":L(window.history.state)?"pages":null}function J(e){let n=e.face??(e.stop&&v(e.stop).overview?"graview":"scene");return e.routing!=="address"||typeof window>"u"?n:E(e.basePath)??n}function K(e){return e.routing!=="address"||typeof window>"u"?!1:r(window.location.pathname,e.basePath)==="/"&&E(e.basePath)===null}function Q(e){if(typeof window>"u")return;let n=r(window.location.pathname,e);return n===s||n==="/"&&window.location.href.includes("#")?T(f(window.location.hash)):void 0}function X({basePath:e,pagesWere:n,shown:t,onFace:i,toggle:l,kinds:U,places:w,opens:$}){let{view:F,go:p}=k(),g=(0,u.useRef)({shown:t,view:F,onFace:i});g.current={shown:t,view:F,onFace:i};let S=(0,u.useRef)(n??"/"),M=()=>{S.current=`${r(window.location.pathname,e)??"/"}${window.location.search}`};return l.current=(o,c,a)=>{let{shown:d,view:N,onFace:V}=g.current;if(o==="pages"&&d!=="pages")window.history.pushState(null,"",y(c??S.current,{basePath:e}));else if(o!=="pages"&&d==="pages"){M();let m=a===void 0?N:j(v(a),w),h=Y(m)?q($):m,O=h!==m&&h.overview?"graview":o,P=_(O,h,U);p(P),window.history.pushState(null,"",`${y(s,{basePath:e})}${x(P)}`),V?.(O);return}V?.(o)},(0,u.useEffect)(()=>{let o=()=>{if(r(window.location.pathname,e)===null)return;let c=E(e)??"pages",{shown:a,onFace:d}=g.current;if(c==="pages"){a!=="pages"&&d?.("pages");return}a==="pages"&&(p(j(f(window.location.hash),w)),d?.(c))};return window.addEventListener("popstate",o),()=>window.removeEventListener("popstate",o)},[e,p,w]),null}function j(e,n){let t=e.within?.view,i=t!==void 0&&!e.focusId?n.find(l=>l.as===t):void 0;return i?{...e,focusId:R(i.kind)}:e}function _(e,n,t){return e==="graview"?b(n,!0):n.overview?I(b(n,!1),W(n,t)):n}function Y(e){return e.focusId===null&&e.overview!==!0}function q(e){return e??{...A,overview:!0}}export{J as a,K as b,Q as c,X as d,j as e,_ as f,Y as g,q as h};
@@ -1,4 +1,4 @@
1
- import{a as I,j as M,k as O}from"./chunk.ETWVQ3A2.js";import"./chunk.CZRX2FDI.js";import{g as P}from"./chunk.5EAQDBBE.js";import{l as D}from"./chunk.YT2CYCVT.js";import"./chunk.Z7ZCR4LN.js";import"./chunk.RIW7SQH4.js";import{b as C}from"./chunk.FSAHO3LV.js";import"./chunk.PNVR3CXR.js";import{F as q,Q as F}from"./chunk.ZTD2CNC3.js";import{X as L,ec as E}from"./chunk.X7W27IRI.js";import{b as N}from"./chunk.AJZBJBMO.js";var f=N(q(),1);var n=N(F(),1),R=40,B=60;function T(l,o,s){return l.allNodes().filter(i=>i.kind===o).map(i=>i[s])}function Y(l){if(l.length<2)return[];let o=[...l].sort((a,d)=>a-d),s=o[o.length-1]-o[0];if(s<=0)return[];let i=Math.max(1,10**Math.floor(Math.log10(s/4))),e=s/4>=i*5?i*5:i,t=a=>Math.round(a/e)*e;return[...new Set([.2,.4,.6,.8].map(a=>t(o[Math.floor(a*(o.length-1))])))].filter(a=>a>0)}function _(l,o,s){let i=new Set(s.far??[]),e=new Map;for(let t of o.allNodes())i.has(t.kind)&&e.set(t.id,L(l.tryDefinition(t.kind),t));return[...e.entries()].map(([t,a])=>({id:t,label:a}))}function K(l,o,s){let i=_(l,o,s);return(i.length<=R?i:i.map(t=>({end:t,ties:o.out(t.id).length+o.in(t.id).length})).sort((t,a)=>a.ties-t.ties||t.end.label.localeCompare(a.end.label)).slice(0,R).map(t=>t.end)).sort((t,a)=>t.label.localeCompare(a.label))}function U(l,o,s){let i=[];for(let e of s.filters){let t=i.length;if(e.about==="is")for(let a of e.options??[])i.push({value:`is:${a}`,label:a,group:e.label,condition:{key:"is",value:a}});else if(e.about==="edge"){i.push({value:`${e.key}:*`,label:"anything",group:e.label,condition:{key:e.key,value:"*"}}),i.push({value:`${e.key}:none`,label:"nothing",group:e.label,condition:{key:e.key,value:"none"}});for(let a of K(l,o,e))i.push({value:`${e.key}:${a.id}`,label:a.label,group:e.label,condition:{key:e.key,value:a.id}})}else if(e.type==="date")for(let a of["before","after","on"])i.push({value:`${e.key}:${a}`,label:`${a}\u2026`,group:e.label,ask:{key:e.key,op:a,label:e.label}});else if(e.type==="number"){let a=l.tryDefinition(s.kind),d=Y(T(o,s.kind,e.key).filter(p=>typeof p=="number"));for(let p of["at-most","at-least"])for(let v of p==="at-most"?d:[...d].reverse())i.push({value:`${e.key}:${p}:${v}`,label:`${p==="at-most"?"at most":"at least"} ${C(a,e.key,v)}`,group:e.label,condition:{key:e.key,value:`${p}:${v}`}})}else if(e.type==="text"){let a=[...new Set(T(o,s.kind,e.key).filter(d=>typeof d=="string"&&d.length>0&&!d.includes(",")))].sort((d,p)=>d.localeCompare(p));if(a.length>=2&&a.length<=B)for(let d of a)i.push({value:`${e.key}:${d}`,label:d,group:e.label,condition:{key:e.key,value:d}})}else if(e.type==="boolean")i.push({value:`${e.key}:true`,label:"yes",group:e.label,condition:{key:e.key,value:"true"}}),i.push({value:`${e.key}:false`,label:"no",group:e.label,condition:{key:e.key,value:"false"}});else if(e.about==="via"){let a=l.tryDefinition(e.far?.[0]??"");for(let d of e.options??[])i.push({value:`${e.key}:${d}`,label:C(a,e.key.split(".")[1],d),group:e.label,condition:{key:e.key,value:d}})}else for(let a of e.options??[])i.push({value:`${e.key}:${a}`,label:C(l.tryDefinition(s.kind),e.key,a),group:e.label,condition:{key:e.key,value:a}});for(let a=t;a<i.length;a++)i[a]={...i[a],key:e.key}}return i}function V(l,o,s,i){let e=l.tryDefinition(o);return["at-most","at-least"].map(t=>({value:`${s.key}:${t}:${i}`,label:`${t==="at-most"?"at most":"at least"} ${C(e,s.key,i)}`,group:s.label,key:s.key,condition:{key:s.key,value:`${t}:${i}`}}))}function G(l){let o=l.trim().replace(/(?<=\d),(?=\d{3}\b)/g,"");return/^-?\d+(\.\d+)?$/.test(o)?Number(o):null}function j(l,o,s){let i=U(l,o,s);return s.filters.flatMap(e=>{let t=i.filter(d=>d.key===e.key);if(e.type==="number"&&e.about!=="edge")return[{key:e.key,label:e.label,entries:t,atNumber:d=>V(l,s.kind,e,d)}];if(t.length===0)return[];if(e.about!=="edge")return[{key:e.key,label:e.label,entries:t}];let a=_(l,o,e);return a.length<I?[{key:e.key,label:e.label,entries:t}]:[{key:e.key,label:e.label,entries:t.filter(d=>d.value===`${e.key}:*`||d.value===`${e.key}:none`),typed:[...a].sort((d,p)=>d.label.localeCompare(p.label))}]})}var z=8;function H(l,o){let s=o.trim().toLocaleLowerCase();if(!s)return{shown:[],more:0};let e=[...l.filter(t=>t.label.toLocaleLowerCase().includes(s))].sort((t,a)=>+!t.label.toLocaleLowerCase().startsWith(s)-+!a.label.toLocaleLowerCase().startsWith(s));return{shown:e.slice(0,z),more:Math.max(0,e.length-z)}}var J=["day","week","month","year","decade"];function le(l){let{which:o,schema:s,graph:i,offers:e,arrangement:t,set:a,toggle:d,has:p,done:v}=l,m=l.testId,A=(0,f.useRef)(null);(0,f.useEffect)(()=>{let u=A.current?.closest("[data-graview-popover]");!u||document.activeElement!==u||(u.querySelector('[aria-pressed="true"]')??u.querySelector("button, input"))?.focus({preventScroll:!0})},[]);let y=t.sort?e.sorts.find(u=>u.key===t.sort.by):void 0,S=t.group?e.groups.find(u=>u.key===t.group.by):void 0,b=O(y),r=e.natural?e.sorts.find(u=>u.key===e.natural.by):void 0,k=o==="filter"||o==="all"&&l.parts?.filter?j(s,i,e):[],w=u=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:"Sort by"}),(0,n.jsx)($,{testId:`${m}-sort-default`,value:"",on:!t.sort,onPress:()=>(a({sort:void 0}),u()),children:r?`As declared (${M(r.label)})`:"As they were added"}),e.sorts.map(g=>(0,n.jsx)($,{value:g.key,on:t.sort?.by===g.key,onPress:()=>(a({sort:{by:g.key,direction:t.sort?.direction??"asc"}}),u()),children:g.label},g.key)),t.sort?(0,n.jsxs)("div",{role:"group","aria-label":"Order","data-testid":`${m}-direction`,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:"Order"}),["asc","desc"].map(g=>(0,n.jsx)($,{testId:`${m}-direction-${g}`,value:g,on:t.sort.direction===g,onPress:()=>(a({sort:{by:t.sort.by,direction:g}}),u()),children:b[g]},g))]}):null]}),c=u=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:"Group by"}),(0,n.jsx)($,{testId:`${m}-group-none`,value:"",on:!t.group,onPress:()=>(a({group:void 0}),u()),children:"Not grouped"}),e.groups.map(g=>(0,n.jsx)($,{value:g.key,on:t.group?.by===g.key,onPress:()=>(a({group:{by:g.key}}),u()),children:g.label},g.key)),t.group&&S?.buckets?(0,n.jsxs)("div",{role:"group","aria-label":"How wide a group is","data-testid":`${m}-bucket`,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:"Each group"}),J.map(g=>(0,n.jsx)($,{testId:`${m}-bucket-${g}`,value:g,on:(t.group.bucket??"day")===g,onPress:()=>(a({group:{by:t.group.by,bucket:g}}),u()),children:`A ${g}`},g))]}):null]}),x=u=>(0,n.jsx)(Q,{sections:k,has:p,testId:m,onToggle:g=>(d(g),u())}),h=l.parts??{sort:!0,group:!0,filter:!0};return(0,n.jsxs)("div",{ref:A,style:{display:"contents"},children:[(0,n.jsx)("style",{children:Z}),o==="sort"?w(v):o==="group"?c(v):o==="filter"?x(v):(0,n.jsxs)(n.Fragment,{children:[h.sort?(0,n.jsx)("div",{role:"group","aria-label":"Sort",children:w(v)}):null,h.group?(0,n.jsx)("div",{role:"group","aria-label":"Group",children:c(v)}):null,h.filter?(0,n.jsx)("div",{role:"group","aria-label":"Filter",children:x(v)}):null]})]})}function $({value:l,on:o,onPress:s,testId:i,children:e}){return(0,n.jsx)("button",{type:"button",className:"graview-arrange-item",value:l,"data-value":l,"aria-pressed":o,onClick:s,...i?{"data-testid":i}:{},children:e})}function Q({sections:l,has:o,testId:s,onToggle:i}){let[e,t]=(0,f.useState)(null),[a,d]=(0,f.useState)(""),[p,v]=(0,f.useState)(()=>new Set(l.length===1?[l[0].key]:[])),[m,A]=(0,f.useState)({});if(e)return(0,n.jsx)(X,{ask:e,testId:s,onDay:r=>i({key:e.key,value:`${e.op}:${r}`}),onCancel:()=>t(null)});let y=r=>(0,n.jsx)($,{value:r.value,on:r.condition?o(r.condition):!1,onPress:()=>r.condition?i(r.condition):t(r.ask),children:r.label},r.value),S=(r,k)=>{let w=(r.typed??[]).filter(h=>o({key:r.key,value:h.id})),c=H(r.typed??[],k),x=[...w,...c.shown.filter(h=>!w.includes(h))];return(0,n.jsxs)(n.Fragment,{children:[x.map(h=>y({value:`${r.key}:${h.id}`,label:h.label,group:r.label,key:r.key,condition:{key:r.key,value:h.id}})),k.trim()&&c.shown.length===0?(0,n.jsx)("span",{className:"graview-arrange-none",children:"None is called that."}):null,c.more>0?(0,n.jsx)("span",{className:"graview-arrange-none",children:`${c.more} more \u2014 type more of the name`}):null]})},b=a.trim().toLocaleLowerCase();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"graview-arrange-find",children:[(0,n.jsx)("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:"Find a filter"}),(0,n.jsx)("input",{type:"search","data-testid":`${s}-filter-find`,value:a,placeholder:"Find a filter, a name or a number\u2026",onChange:r=>d(r.target.value)})]}),l.map(r=>{let k=r.entries.filter(c=>c.condition&&o(c.condition)).length+(r.typed??[]).filter(c=>o({key:r.key,value:c.id})).length;if(b){let c=r.label.toLocaleLowerCase().includes(b),x=r.atNumber&&G(b)!==null?r.atNumber(G(b)):[],h=[...x,...c?r.entries:r.entries.filter(g=>g.label.toLocaleLowerCase().includes(b)&&!x.some(W=>W.value===g.value))],u=r.typed?H(r.typed,b):{shown:[],more:0};return h.length===0&&u.shown.length===0?null:(0,n.jsxs)("div",{role:"group","aria-label":r.label,"data-section":r.key,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:r.label}),h.map(y),r.typed?S(r,b):null]},r.key)}if(r.entries.length===0&&!r.typed)return null;let w=p.has(r.key);return(0,n.jsxs)("div",{role:"group","aria-label":r.label,"data-section":r.key,children:[(0,n.jsxs)("button",{type:"button",className:"graview-arrange-section","data-testid":`${s}-section`,"data-key":r.key,"aria-expanded":w,onClick:()=>v(c=>c.has(r.key)?new Set([...c].filter(x=>x!==r.key)):new Set([...c,r.key])),children:[(0,n.jsx)("span",{children:r.label}),k>0?(0,n.jsx)("span",{className:"graview-arrange-on",children:`${k} on`}):null]}),w?(0,n.jsxs)(n.Fragment,{children:[r.typed?(0,n.jsx)("input",{type:"search",className:"graview-arrange-far","data-testid":`${s}-far-find`,"data-key":r.key,"aria-label":`${r.label}: type a name`,placeholder:`Type a name (${r.typed.length})\u2026`,autoFocus:!0,value:m[r.key]??"",onChange:c=>A({...m,[r.key]:c.target.value})}):null,r.entries.map(y),r.typed?S(r,m[r.key]??""):null]}):null]},r.key)})]})}function X({ask:l,testId:o,onDay:s,onCancel:i}){let[e,t]=(0,f.useState)(""),a=/^\d{4}-\d{2}-\d{2}$/.test(e)&&Number(e.slice(0,4))>=1e3,d=()=>{a&&s(e)};return(0,n.jsxs)("div",{role:"group","aria-label":`${l.label} ${l.op} which day`,"data-testid":`${o}-ask-day`,className:"graview-arrange-ask",children:[(0,n.jsx)("p",{"aria-hidden":"true",children:`${l.label} ${l.op}`}),(0,n.jsx)("input",{type:"date","data-testid":`${o}-day`,"aria-label":`${l.label} ${l.op} which day`,autoFocus:!0,value:e,onChange:p=>t(p.target.value),onKeyDown:p=>{p.key==="Enter"?(p.preventDefault(),d()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),p.nativeEvent.stopImmediatePropagation(),i())}}),(0,n.jsxs)("span",{children:[(0,n.jsx)("button",{type:"button","data-testid":`${o}-day-add`,disabled:!a,onClick:d,children:"Add"}),(0,n.jsx)("button",{type:"button",onClick:i,children:"Never mind"})]})]})}var Z=`
1
+ import{a as I,j as M,k as O}from"./chunk.27TLAVRR.js";import"./chunk.OREMUXB5.js";import{g as P}from"./chunk.ZDNJK2SX.js";import{l as D}from"./chunk.ZSSOTIFL.js";import"./chunk.GZLYTPE7.js";import"./chunk.4B73P2WA.js";import{b as C}from"./chunk.IMRCAU4T.js";import"./chunk.BZ5VLPKB.js";import{F as q,Q as F}from"./chunk.6II4BONS.js";import{X as L,fc as E}from"./chunk.F5BCCGFK.js";import{b as N}from"./chunk.AJZBJBMO.js";var f=N(q(),1);var n=N(F(),1),R=40,B=60;function T(l,o,s){return l.allNodes().filter(i=>i.kind===o).map(i=>i[s])}function Y(l){if(l.length<2)return[];let o=[...l].sort((a,d)=>a-d),s=o[o.length-1]-o[0];if(s<=0)return[];let i=Math.max(1,10**Math.floor(Math.log10(s/4))),e=s/4>=i*5?i*5:i,t=a=>Math.round(a/e)*e;return[...new Set([.2,.4,.6,.8].map(a=>t(o[Math.floor(a*(o.length-1))])))].filter(a=>a>0)}function _(l,o,s){let i=new Set(s.far??[]),e=new Map;for(let t of o.allNodes())i.has(t.kind)&&e.set(t.id,L(l.tryDefinition(t.kind),t));return[...e.entries()].map(([t,a])=>({id:t,label:a}))}function K(l,o,s){let i=_(l,o,s);return(i.length<=R?i:i.map(t=>({end:t,ties:o.out(t.id).length+o.in(t.id).length})).sort((t,a)=>a.ties-t.ties||t.end.label.localeCompare(a.end.label)).slice(0,R).map(t=>t.end)).sort((t,a)=>t.label.localeCompare(a.label))}function U(l,o,s){let i=[];for(let e of s.filters){let t=i.length;if(e.about==="is")for(let a of e.options??[])i.push({value:`is:${a}`,label:a,group:e.label,condition:{key:"is",value:a}});else if(e.about==="edge"){i.push({value:`${e.key}:*`,label:"anything",group:e.label,condition:{key:e.key,value:"*"}}),i.push({value:`${e.key}:none`,label:"nothing",group:e.label,condition:{key:e.key,value:"none"}});for(let a of K(l,o,e))i.push({value:`${e.key}:${a.id}`,label:a.label,group:e.label,condition:{key:e.key,value:a.id}})}else if(e.type==="date")for(let a of["before","after","on"])i.push({value:`${e.key}:${a}`,label:`${a}\u2026`,group:e.label,ask:{key:e.key,op:a,label:e.label}});else if(e.type==="number"){let a=l.tryDefinition(s.kind),d=Y(T(o,s.kind,e.key).filter(p=>typeof p=="number"));for(let p of["at-most","at-least"])for(let v of p==="at-most"?d:[...d].reverse())i.push({value:`${e.key}:${p}:${v}`,label:`${p==="at-most"?"at most":"at least"} ${C(a,e.key,v)}`,group:e.label,condition:{key:e.key,value:`${p}:${v}`}})}else if(e.type==="text"){let a=[...new Set(T(o,s.kind,e.key).filter(d=>typeof d=="string"&&d.length>0&&!d.includes(",")))].sort((d,p)=>d.localeCompare(p));if(a.length>=2&&a.length<=B)for(let d of a)i.push({value:`${e.key}:${d}`,label:d,group:e.label,condition:{key:e.key,value:d}})}else if(e.type==="boolean")i.push({value:`${e.key}:true`,label:"yes",group:e.label,condition:{key:e.key,value:"true"}}),i.push({value:`${e.key}:false`,label:"no",group:e.label,condition:{key:e.key,value:"false"}});else if(e.about==="via"){let a=l.tryDefinition(e.far?.[0]??"");for(let d of e.options??[])i.push({value:`${e.key}:${d}`,label:C(a,e.key.split(".")[1],d),group:e.label,condition:{key:e.key,value:d}})}else for(let a of e.options??[])i.push({value:`${e.key}:${a}`,label:C(l.tryDefinition(s.kind),e.key,a),group:e.label,condition:{key:e.key,value:a}});for(let a=t;a<i.length;a++)i[a]={...i[a],key:e.key}}return i}function V(l,o,s,i){let e=l.tryDefinition(o);return["at-most","at-least"].map(t=>({value:`${s.key}:${t}:${i}`,label:`${t==="at-most"?"at most":"at least"} ${C(e,s.key,i)}`,group:s.label,key:s.key,condition:{key:s.key,value:`${t}:${i}`}}))}function G(l){let o=l.trim().replace(/(?<=\d),(?=\d{3}\b)/g,"");return/^-?\d+(\.\d+)?$/.test(o)?Number(o):null}function j(l,o,s){let i=U(l,o,s);return s.filters.flatMap(e=>{let t=i.filter(d=>d.key===e.key);if(e.type==="number"&&e.about!=="edge")return[{key:e.key,label:e.label,entries:t,atNumber:d=>V(l,s.kind,e,d)}];if(t.length===0)return[];if(e.about!=="edge")return[{key:e.key,label:e.label,entries:t}];let a=_(l,o,e);return a.length<I?[{key:e.key,label:e.label,entries:t}]:[{key:e.key,label:e.label,entries:t.filter(d=>d.value===`${e.key}:*`||d.value===`${e.key}:none`),typed:[...a].sort((d,p)=>d.label.localeCompare(p.label))}]})}var z=8;function H(l,o){let s=o.trim().toLocaleLowerCase();if(!s)return{shown:[],more:0};let e=[...l.filter(t=>t.label.toLocaleLowerCase().includes(s))].sort((t,a)=>+!t.label.toLocaleLowerCase().startsWith(s)-+!a.label.toLocaleLowerCase().startsWith(s));return{shown:e.slice(0,z),more:Math.max(0,e.length-z)}}var J=["day","week","month","year","decade"];function le(l){let{which:o,schema:s,graph:i,offers:e,arrangement:t,set:a,toggle:d,has:p,done:v}=l,m=l.testId,A=(0,f.useRef)(null);(0,f.useEffect)(()=>{let u=A.current?.closest("[data-graview-popover]");!u||document.activeElement!==u||(u.querySelector('[aria-pressed="true"]')??u.querySelector("button, input"))?.focus({preventScroll:!0})},[]);let y=t.sort?e.sorts.find(u=>u.key===t.sort.by):void 0,S=t.group?e.groups.find(u=>u.key===t.group.by):void 0,b=O(y),r=e.natural?e.sorts.find(u=>u.key===e.natural.by):void 0,k=o==="filter"||o==="all"&&l.parts?.filter?j(s,i,e):[],w=u=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:"Sort by"}),(0,n.jsx)($,{testId:`${m}-sort-default`,value:"",on:!t.sort,onPress:()=>(a({sort:void 0}),u()),children:r?`As declared (${M(r.label)})`:"As they were added"}),e.sorts.map(g=>(0,n.jsx)($,{value:g.key,on:t.sort?.by===g.key,onPress:()=>(a({sort:{by:g.key,direction:t.sort?.direction??"asc"}}),u()),children:g.label},g.key)),t.sort?(0,n.jsxs)("div",{role:"group","aria-label":"Order","data-testid":`${m}-direction`,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:"Order"}),["asc","desc"].map(g=>(0,n.jsx)($,{testId:`${m}-direction-${g}`,value:g,on:t.sort.direction===g,onPress:()=>(a({sort:{by:t.sort.by,direction:g}}),u()),children:b[g]},g))]}):null]}),c=u=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:"Group by"}),(0,n.jsx)($,{testId:`${m}-group-none`,value:"",on:!t.group,onPress:()=>(a({group:void 0}),u()),children:"Not grouped"}),e.groups.map(g=>(0,n.jsx)($,{value:g.key,on:t.group?.by===g.key,onPress:()=>(a({group:{by:g.key}}),u()),children:g.label},g.key)),t.group&&S?.buckets?(0,n.jsxs)("div",{role:"group","aria-label":"How wide a group is","data-testid":`${m}-bucket`,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:"Each group"}),J.map(g=>(0,n.jsx)($,{testId:`${m}-bucket-${g}`,value:g,on:(t.group.bucket??"day")===g,onPress:()=>(a({group:{by:t.group.by,bucket:g}}),u()),children:`A ${g}`},g))]}):null]}),x=u=>(0,n.jsx)(Q,{sections:k,has:p,testId:m,onToggle:g=>(d(g),u())}),h=l.parts??{sort:!0,group:!0,filter:!0};return(0,n.jsxs)("div",{ref:A,style:{display:"contents"},children:[(0,n.jsx)("style",{children:Z}),o==="sort"?w(v):o==="group"?c(v):o==="filter"?x(v):(0,n.jsxs)(n.Fragment,{children:[h.sort?(0,n.jsx)("div",{role:"group","aria-label":"Sort",children:w(v)}):null,h.group?(0,n.jsx)("div",{role:"group","aria-label":"Group",children:c(v)}):null,h.filter?(0,n.jsx)("div",{role:"group","aria-label":"Filter",children:x(v)}):null]})]})}function $({value:l,on:o,onPress:s,testId:i,children:e}){return(0,n.jsx)("button",{type:"button",className:"graview-arrange-item",value:l,"data-value":l,"aria-pressed":o,onClick:s,...i?{"data-testid":i}:{},children:e})}function Q({sections:l,has:o,testId:s,onToggle:i}){let[e,t]=(0,f.useState)(null),[a,d]=(0,f.useState)(""),[p,v]=(0,f.useState)(()=>new Set(l.length===1?[l[0].key]:[])),[m,A]=(0,f.useState)({});if(e)return(0,n.jsx)(X,{ask:e,testId:s,onDay:r=>i({key:e.key,value:`${e.op}:${r}`}),onCancel:()=>t(null)});let y=r=>(0,n.jsx)($,{value:r.value,on:r.condition?o(r.condition):!1,onPress:()=>r.condition?i(r.condition):t(r.ask),children:r.label},r.value),S=(r,k)=>{let w=(r.typed??[]).filter(h=>o({key:r.key,value:h.id})),c=H(r.typed??[],k),x=[...w,...c.shown.filter(h=>!w.includes(h))];return(0,n.jsxs)(n.Fragment,{children:[x.map(h=>y({value:`${r.key}:${h.id}`,label:h.label,group:r.label,key:r.key,condition:{key:r.key,value:h.id}})),k.trim()&&c.shown.length===0?(0,n.jsx)("span",{className:"graview-arrange-none",children:"None is called that."}):null,c.more>0?(0,n.jsx)("span",{className:"graview-arrange-none",children:`${c.more} more \u2014 type more of the name`}):null]})},b=a.trim().toLocaleLowerCase();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"graview-arrange-find",children:[(0,n.jsx)("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:"Find a filter"}),(0,n.jsx)("input",{type:"search","data-testid":`${s}-filter-find`,value:a,placeholder:"Find a filter, a name or a number\u2026",onChange:r=>d(r.target.value)})]}),l.map(r=>{let k=r.entries.filter(c=>c.condition&&o(c.condition)).length+(r.typed??[]).filter(c=>o({key:r.key,value:c.id})).length;if(b){let c=r.label.toLocaleLowerCase().includes(b),x=r.atNumber&&G(b)!==null?r.atNumber(G(b)):[],h=[...x,...c?r.entries:r.entries.filter(g=>g.label.toLocaleLowerCase().includes(b)&&!x.some(W=>W.value===g.value))],u=r.typed?H(r.typed,b):{shown:[],more:0};return h.length===0&&u.shown.length===0?null:(0,n.jsxs)("div",{role:"group","aria-label":r.label,"data-section":r.key,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:r.label}),h.map(y),r.typed?S(r,b):null]},r.key)}if(r.entries.length===0&&!r.typed)return null;let w=p.has(r.key);return(0,n.jsxs)("div",{role:"group","aria-label":r.label,"data-section":r.key,children:[(0,n.jsxs)("button",{type:"button",className:"graview-arrange-section","data-testid":`${s}-section`,"data-key":r.key,"aria-expanded":w,onClick:()=>v(c=>c.has(r.key)?new Set([...c].filter(x=>x!==r.key)):new Set([...c,r.key])),children:[(0,n.jsx)("span",{children:r.label}),k>0?(0,n.jsx)("span",{className:"graview-arrange-on",children:`${k} on`}):null]}),w?(0,n.jsxs)(n.Fragment,{children:[r.typed?(0,n.jsx)("input",{type:"search",className:"graview-arrange-far","data-testid":`${s}-far-find`,"data-key":r.key,"aria-label":`${r.label}: type a name`,placeholder:`Type a name (${r.typed.length})\u2026`,autoFocus:!0,value:m[r.key]??"",onChange:c=>A({...m,[r.key]:c.target.value})}):null,r.entries.map(y),r.typed?S(r,m[r.key]??""):null]}):null]},r.key)})]})}function X({ask:l,testId:o,onDay:s,onCancel:i}){let[e,t]=(0,f.useState)(""),a=/^\d{4}-\d{2}-\d{2}$/.test(e)&&Number(e.slice(0,4))>=1e3,d=()=>{a&&s(e)};return(0,n.jsxs)("div",{role:"group","aria-label":`${l.label} ${l.op} which day`,"data-testid":`${o}-ask-day`,className:"graview-arrange-ask",children:[(0,n.jsx)("p",{"aria-hidden":"true",children:`${l.label} ${l.op}`}),(0,n.jsx)("input",{type:"date","data-testid":`${o}-day`,"aria-label":`${l.label} ${l.op} which day`,autoFocus:!0,value:e,onChange:p=>t(p.target.value),onKeyDown:p=>{p.key==="Enter"?(p.preventDefault(),d()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),p.nativeEvent.stopImmediatePropagation(),i())}}),(0,n.jsxs)("span",{children:[(0,n.jsx)("button",{type:"button","data-testid":`${o}-day-add`,disabled:!a,onClick:d,children:"Add"}),(0,n.jsx)("button",{type:"button",onClick:i,children:"Never mind"})]})]})}var Z=`
2
2
  .graview-arrange-list{display:grid;align-content:start;width:min(300px,calc(100vw - 24px));height:auto;max-height:min(70vh,520px);overflow:auto;overscroll-behavior:contain;margin:0;padding:0 6px 6px;border-radius:10px;border:1px solid var(--graview-edge);background:linear-gradient(var(--graview-float),var(--graview-float)),var(--graview-panel);box-shadow:var(--graview-lift-high);color:var(--graview-ink);font-size:.875rem;line-height:1.3}
3
3
  .graview-arrange-list>*:first-child:not(.graview-arrange-find){margin-top:6px}
4
4
  @media (max-width:519px){.graview-arrange-list{left:0!important;right:0!important;top:auto!important;bottom:0!important;width:100%!important;max-height:min(80dvh,560px)!important;border-radius:14px 14px 0 0;padding-bottom:calc(10px + env(safe-area-inset-bottom))}}
@@ -1,3 +1,3 @@
1
- import{b as ee}from"./chunk.FUQVNXLB.js";import"./chunk.Z7ZCR4LN.js";import"./chunk.RIW7SQH4.js";import{c as Z}from"./chunk.FSAHO3LV.js";import{F as ce,Q as X}from"./chunk.ZTD2CNC3.js";import{X as J,_ as U,dc as j}from"./chunk.X7W27IRI.js";import{b as _}from"./chunk.AJZBJBMO.js";var B=_(ce(),1);var ue=6;function ne(v,b,h,f,L){let t=new Set(v),o=new Map;for(let r of b)for(let[u,a,S]of[[r.from,r.to,"out"],[r.to,r.from,"in"]]){if(!t.has(u)||t.has(a))continue;let p=h(a);if(p===void 0)continue;let m=`${u}|${r.kind}|${S}|${p}`,k=o.get(m);k?k.others.includes(a)||k.others.push(a):o.set(m,{self:u,edge:r.kind,direction:S,kind:p,others:[a]})}let d=[];for(let r of o.values()){let u=h(r.self)??"",a=Z(L,r.direction==="out"?u:r.kind,r.edge,r.direction),S=r.others.filter(f),p=r.others.filter(m=>!f(m));if(r.others.length>ue){d.push({...r,others:r.others,lands:"district",words:a});continue}for(let m of S)d.push({...r,others:[m],lands:"record",words:a});p.length>0&&d.push({...r,others:p,lands:"district",words:a})}return d}function te(v,b=[]){let h=[...b],f=new Map,L=t=>h.some(o=>t.x<o.x+o.width&&o.x<t.x+t.width&&t.y<o.y+o.height&&o.y<t.y+t.height);for(let t of[...v].sort((o,d)=>o.y-d.y||o.x-d.x)){let o={x:t.x-t.width/2,y:t.y-t.height,width:t.width,height:t.height};for(let d=0;d<12&&L(o);d++)o.y+=t.height+2;h.push(o),f.set(t.key,{x:o.x,y:o.y})}return f}var s=_(X(),1),ge=4;function we({frame:v,width:b,height:h,stageRef:f,tick:L,store:t,graphVersion:o,selection:d,view:r,rulers:{visibleRect:u,clipQuadratic:a,unsureOf:S,unsureDash:p,unsureOpacity:m}}){let k=n=>t.graph.getNode(n)?.kind,C=ee(d,r,k),$=C.lens===null&&C.records.length<=ge?C.records:[],re=$.join(`
1
+ import{b as ee}from"./chunk.FQKH67BP.js";import"./chunk.GZLYTPE7.js";import"./chunk.4B73P2WA.js";import{c as Z}from"./chunk.IMRCAU4T.js";import{F as ce,Q as X}from"./chunk.6II4BONS.js";import{X as J,_ as U,ec as j}from"./chunk.F5BCCGFK.js";import{b as _}from"./chunk.AJZBJBMO.js";var B=_(ce(),1);var ue=6;function ne(v,b,h,f,L){let t=new Set(v),o=new Map;for(let r of b)for(let[u,a,S]of[[r.from,r.to,"out"],[r.to,r.from,"in"]]){if(!t.has(u)||t.has(a))continue;let p=h(a);if(p===void 0)continue;let m=`${u}|${r.kind}|${S}|${p}`,k=o.get(m);k?k.others.includes(a)||k.others.push(a):o.set(m,{self:u,edge:r.kind,direction:S,kind:p,others:[a]})}let d=[];for(let r of o.values()){let u=h(r.self)??"",a=Z(L,r.direction==="out"?u:r.kind,r.edge,r.direction),S=r.others.filter(f),p=r.others.filter(m=>!f(m));if(r.others.length>ue){d.push({...r,others:r.others,lands:"district",words:a});continue}for(let m of S)d.push({...r,others:[m],lands:"record",words:a});p.length>0&&d.push({...r,others:p,lands:"district",words:a})}return d}function te(v,b=[]){let h=[...b],f=new Map,L=t=>h.some(o=>t.x<o.x+o.width&&o.x<t.x+t.width&&t.y<o.y+o.height&&o.y<t.y+t.height);for(let t of[...v].sort((o,d)=>o.y-d.y||o.x-d.x)){let o={x:t.x-t.width/2,y:t.y-t.height,width:t.width,height:t.height};for(let d=0;d<12&&L(o);d++)o.y+=t.height+2;h.push(o),f.set(t.key,{x:o.x,y:o.y})}return f}var s=_(X(),1),ge=4;function we({frame:v,width:b,height:h,stageRef:f,tick:L,store:t,graphVersion:o,selection:d,view:r,rulers:{visibleRect:u,clipQuadratic:a,unsureOf:S,unsureDash:p,unsureOpacity:m}}){let k=n=>t.graph.getNode(n)?.kind,C=ee(d,r,k),$=C.lens===null&&C.records.length<=ge?C.records:[],re=$.join(`
2
2
  `),[c,q]=(0,B.useState)(null);(0,B.useLayoutEffect)(()=>{let n=f.current;if(!r.overview||$.length===0||!n||typeof document>"u"||v.t<1){q(null);return}let g=n.getBoundingClientRect(),R=e=>({x:e.left-g.left,y:e.top-g.top,width:e.width,height:e.height}),N=new Map,oe=$.map(e=>`[data-graview-view="${CSS.escape(e)}"]`).join(","),D=e=>{if(N.has(e))return N.get(e);let i=null;for(let y of n.querySelectorAll(`[data-graview-pick="${CSS.escape(e)}"], [data-graview-view="${CSS.escape(e)}"]`))if(!y.closest("[data-graview-offstage], [data-graview-screen]")&&!(!$.includes(e)&&y.closest(oe))&&(i=u(y,n),i))break;if(!i){let y=n.querySelector(`[data-graview-building="${CSS.escape(e)}"]`);y&&(i=R(y.getBoundingClientRect()))}return N.set(e,i),i},T=e=>{let i=n.querySelector(`[data-graview-plot="kind:${CSS.escape(e)}"] .graview-plot-tile`);return i?R(i.getBoundingClientRect()):null},ie=ne($,t.graph.allEdges(),k,e=>D(e)!==null,t.schema),K=[];for(let e of n.querySelectorAll('[data-graview-view^="kind:"] .graview-kind-face')){let i=u(e,n);i&&K.push(i)}let H=e=>({x:e.x+e.width/2,y:e.y+e.height/2}),E=[],W=new Set($),A=new Set;for(let e of ie){let i=k(e.self),y=D(e.self)??(i?T(i):null),Q=e.lands==="record"?D(e.others[0]):T(e.kind);if(!y||!Q)continue;for(let l of e.others)W.add(l);A.add(e.kind),i&&A.add(i);let x=H(y),w=H(Q),O=Math.hypot(w.x-x.x,w.y-x.y);if(O<6)continue;let V=Math.min(40,O*.12)*(E.length%2===0?1:-1),de={x:(x.x+w.x)/2-(w.y-x.y)/O*V,y:(x.y+w.y)/2+(w.x-x.x)/O*V},Y=a({p0:x,c:de,p1:w},K);if(Y.length===0)continue;let ae=Y.map(l=>`M ${l.p0.x.toFixed(1)} ${l.p0.y.toFixed(1)} Q ${l.c.x.toFixed(1)} ${l.c.y.toFixed(1)} ${l.p1.x.toFixed(1)} ${l.p1.y.toFixed(1)}`).join(" "),le=l=>{let F=t.graph.getNode(l);return F?J(t.schema.tryDefinition(F.kind),F):l},G=e.lands==="record"?`${e.words}: ${le(e.others[0])}`:`${e.words}: ${U(t.schema,e.kind,e.others.length)}`,P=e.others[0],I=e.lands==="record"?S?.(e.edge,e.direction==="out"?e.self:P,e.direction==="out"?P:e.self):void 0;E.push({key:`${e.self}|${e.edge}|${e.direction}|${e.lands}|${P}`,link:e,d:ae,end:w,said:I!==void 0?`${G} \xB7 unsure`:G,...I!==void 0?{unsure:I}:{}})}let z=[];for(let e of n.querySelectorAll(".graview-kind-face[data-graview-nameplate]")){let i=u(e,n);i&&z.push(i)}let se=te(E.map(e=>({key:e.key,x:e.end.x,y:e.end.y-6,width:Math.min(260,14+e.said.length*6.6),height:20})),z);q({lines:E,labels:se,reached:[...W],districts:[...A]})},[re,r.overview,v,o,L,b,h,f,t]);let M=(0,B.useMemo)(()=>{if(!c)return"";let n=c.reached.map(R=>`[data-graview-building="${CSS.escape(R)}"]`).join(","),g=c.districts.map(R=>`[data-graview-plot="kind:${CSS.escape(R)}"]`).join(",");return[".graview-ground[data-graview-altitude] .graview-building { opacity: 0.22; }",n?`.graview-ground[data-graview-altitude] .graview-building:is(${n}) { opacity: 1; }`:"",g?`.graview-ground[data-graview-altitude] .graview-plot:not(:is(${g})) .graview-plot-tile { opacity: 0.4; }`:""].join(`
3
3
  `)},[c]);return!c||c.lines.length===0?M?(0,s.jsx)("style",{children:M}):null:(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("style",{children:M}),(0,s.jsx)("svg",{className:"graview-record-links","data-graview-world":"","data-graview-record-links":c.lines.length,"aria-hidden":"true",width:b,height:h,style:{position:"absolute",left:0,top:0,pointerEvents:"none",zIndex:j.lines},children:c.lines.map(n=>(0,s.jsxs)("g",{className:"graview-record-link","data-graview-link":n.link.edge,"data-graview-lands":n.link.lands,"data-graview-direction":n.link.direction,"data-graview-provisional":n.unsure!==void 0||void 0,children:[(0,s.jsx)("path",{className:"graview-record-link-line",d:n.d,...n.unsure!==void 0?{strokeDasharray:p,strokeOpacity:m}:{}}),n.link.lands==="record"?(0,s.jsx)("circle",{className:"graview-record-link-end",cx:n.end.x,cy:n.end.y,r:3}):null]},n.key))}),(0,s.jsx)("div",{"aria-hidden":"true","data-graview-world":"",style:{position:"absolute",inset:0,pointerEvents:"none",zIndex:j.tieLabels},children:c.lines.map(n=>{let g=c.labels.get(n.key);return g?(0,s.jsx)("span",{className:"graview-record-link-said","data-graview-link-said":n.link.edge,"data-graview-lands":n.link.lands,...n.unsure!==void 0?{title:n.unsure}:{},style:{position:"absolute",left:g.x,top:g.y,...n.unsure!==void 0?{pointerEvents:"auto"}:{}},children:n.said},n.key):null})})]})}export{we as RecordLinks};
@@ -1,4 +1,4 @@
1
- import{ec as e}from"./chunk.X7W27IRI.js";var a=`
1
+ import{fc as e}from"./chunk.F5BCCGFK.js";var a=`
2
2
  .graview-spec{display:flex;flex-direction:column;gap:6px;min-width:0;color:var(--graview-ink)}
3
3
 
4
4
  .graview-spec-row{flex-direction:row;flex-wrap:wrap;align-items:center;gap:4px 10px;box-sizing:border-box;max-width:100%;padding:5px 10px;border:1px solid var(--graview-edge);border-radius:var(--graview-radius-sm,8px);background:var(--graview-panel);font-size:.875rem}
@@ -1 +1 @@
1
- import{Cb as S,wb as w}from"./chunk.X7W27IRI.js";function B(s){return[...s.mutations??[],...S(s.schema,s.mutations??[])]}function b(s){let i=[...s.schema.kinds],a=B(s),d=new Map,c=new Map;for(let n of a){c.set(n.name,n.creates??[]);let e=w(n.input).filter(t=>!t.optional&&!t.kinds.includes("*")).flatMap(t=>t.kinds);d.set(n.name,[...new Set(e)])}let g=new Map;for(let n of i)g.set(n,[]);for(let n of a)for(let e of c.get(n.name)??[])g.get(e)?.push(n.name);let p=new Map,l=new Set;for(let n=0;;n+=1){let e=[];for(let t of a)if((d.get(t.name)??[]).every(o=>l.has(o)))for(let o of c.get(t.name)??[])l.has(o)||e.push(o);if(e.length===0)break;for(let t of e)l.add(t),p.set(t,n)}let h=n=>{let e=g.get(n)??[];if(e.length===0)return[];let t=e.map(r=>d.get(r)??[]).sort((r,o)=>r.length-o.length)[0];return[...new Set(t)].filter(r=>r!==n)},y=new Map,u=n=>{let e=y.get(n);if(e)return e;let t=new Set;y.set(n,t);for(let r of h(n)){t.add(r);for(let o of u(r))t.add(o)}return t.delete(n),t},f=new Map(i.map(n=>[n,0]));for(let n of i)for(let e of u(n))f.set(e,(f.get(e)??0)+1);let m=i.map(n=>({kind:n,madeBy:[...g.get(n)??[]].sort(),needs:[...h(n)].sort(),depth:p.get(n)??null})).sort((n,e)=>(n.depth??Number.MAX_SAFE_INTEGER)-(e.depth??Number.MAX_SAFE_INTEGER)||(f.get(e.kind)??0)-(f.get(n.kind)??0)||n.kind.localeCompare(e.kind)),k=m.filter(n=>n.depth===0).map(n=>n.kind),A=[...new Set(a.filter(n=>(d.get(n.name)??[]).length===0).filter(n=>(c.get(n.name)??[]).length>0).map(n=>n.name))].sort(),M=m.filter(n=>n.depth===null).map(n=>({kind:n.kind,why:n.madeBy.length===0?"no act declares that it creates this kind":`every act that makes it needs ${n.needs.map(e=>`"${e}"`).join(", ")}, which nothing can make first`}));return{order:m,roots:k,doors:A,unreachable:M}}export{b as a};
1
+ import{Db as S,xb as w}from"./chunk.F5BCCGFK.js";function B(s){return[...s.mutations??[],...S(s.schema,s.mutations??[])]}function b(s){let i=[...s.schema.kinds],a=B(s),d=new Map,c=new Map;for(let n of a){c.set(n.name,n.creates??[]);let e=w(n.input).filter(t=>!t.optional&&!t.kinds.includes("*")).flatMap(t=>t.kinds);d.set(n.name,[...new Set(e)])}let g=new Map;for(let n of i)g.set(n,[]);for(let n of a)for(let e of c.get(n.name)??[])g.get(e)?.push(n.name);let p=new Map,l=new Set;for(let n=0;;n+=1){let e=[];for(let t of a)if((d.get(t.name)??[]).every(o=>l.has(o)))for(let o of c.get(t.name)??[])l.has(o)||e.push(o);if(e.length===0)break;for(let t of e)l.add(t),p.set(t,n)}let h=n=>{let e=g.get(n)??[];if(e.length===0)return[];let t=e.map(r=>d.get(r)??[]).sort((r,o)=>r.length-o.length)[0];return[...new Set(t)].filter(r=>r!==n)},y=new Map,u=n=>{let e=y.get(n);if(e)return e;let t=new Set;y.set(n,t);for(let r of h(n)){t.add(r);for(let o of u(r))t.add(o)}return t.delete(n),t},f=new Map(i.map(n=>[n,0]));for(let n of i)for(let e of u(n))f.set(e,(f.get(e)??0)+1);let m=i.map(n=>({kind:n,madeBy:[...g.get(n)??[]].sort(),needs:[...h(n)].sort(),depth:p.get(n)??null})).sort((n,e)=>(n.depth??Number.MAX_SAFE_INTEGER)-(e.depth??Number.MAX_SAFE_INTEGER)||(f.get(e.kind)??0)-(f.get(n.kind)??0)||n.kind.localeCompare(e.kind)),k=m.filter(n=>n.depth===0).map(n=>n.kind),A=[...new Set(a.filter(n=>(d.get(n.name)??[]).length===0).filter(n=>(c.get(n.name)??[]).length>0).map(n=>n.name))].sort(),M=m.filter(n=>n.depth===null).map(n=>({kind:n.kind,why:n.madeBy.length===0?"no act declares that it creates this kind":`every act that makes it needs ${n.needs.map(e=>`"${e}"`).join(", ")}, which nothing can make first`}));return{order:m,roots:k,doors:A,unreachable:M}}export{b as a};
@@ -1 +1 @@
1
- import{a as P,b}from"./chunk.LIIC25G6.js";import"./chunk.577PGFUT.js";import"./chunk.FBY5IUGU.js";import"./chunk.4K5QCJFH.js";import"./chunk.PNVR3CXR.js";import{F as G,Q as O,Y as S}from"./chunk.ZTD2CNC3.js";import{pc as E}from"./chunk.X7W27IRI.js";import{b as v}from"./chunk.AJZBJBMO.js";var o=v(G(),1);var t=v(O(),1);function I(i){for(let d of i)for(let[r,s]of Object.entries(d))if(s===!1)return`${r} == true`;return""}var w={margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function j({ask:i,close:d}){let{store:r,principal:s,subscriptions:m,app:f}=S(),c=(0,o.useRef)(null),p=(0,o.useId)(),[n,u]=(0,o.useState)(0),[l,y]=(0,o.useState)(!0),[h,M]=(0,o.useState)(()=>{let e=i.choices.find(g=>g.on==="reaches");if(!e)return"";let a=e.record!==void 0?r.graph.getNode(e.record):void 0;return I(a?[a]:r.graph.nodesOfKind(e.kind).slice(0,5))}),[C,k]=(0,o.useState)(null),[W,x]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=c.current;e&&!e.open&&e.showModal()},[]);let N=()=>{let e=i.returnTo;d(),requestAnimationFrame(()=>{e?.isConnected?e.focus():document.querySelector("[data-graview-page-title], main h1, [data-testid='activity-button']")?.focus()})},T=e=>e.on==="reaches"?{...e,condition:h}:e,A=e=>b(r,{when:T(e),alsoMine:!l}),z=async()=>{let e=T(i.choices[n]),a=P(r,e);if(a){k(a);return}x(!0);try{await m.add({who:E(s),app:f?.name??"app",when:e,...l?{}:{alsoMine:!0}}),N()}catch(g){x(!1),k(g instanceof Error?g.message:String(g))}};return(0,t.jsx)("dialog",{ref:c,"aria-labelledby":p,"data-testid":"notify-sheet",onClose:N,onClick:e=>{e.target===e.currentTarget&&e.currentTarget.close()},style:{width:"min(92vw, 420px)",padding:0,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)"},children:(0,t.jsxs)("form",{method:"dialog",onSubmit:e=>{e.preventDefault(),z()},style:{display:"grid",gap:12,padding:18},children:[(0,t.jsx)("h2",{id:p,style:{margin:0,fontSize:"1.0625rem"},children:"Notify me"}),(0,t.jsxs)("fieldset",{style:{margin:0,padding:0,border:0,display:"grid",gap:6},children:[(0,t.jsx)("legend",{style:{...w,marginBottom:6},children:"Tell me"}),i.choices.map((e,a)=>(0,t.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"baseline",cursor:"pointer"},children:[(0,t.jsx)("input",{type:"radio",name:`${p}-when`,checked:n===a,onChange:()=>u(a),"data-notify-choice":e.on}),(0,t.jsx)("span",{children:e.on==="reaches"?`When ${e.record!==void 0?"it":"one"} reaches a condition`:A(e)})]},a))]}),i.choices[n]?.on==="reaches"?(0,t.jsxs)("label",{style:{display:"grid",gap:4},children:[(0,t.jsx)("span",{style:w,children:"The condition, in the app's own words (done == true, amount > 100)"}),(0,t.jsx)("input",{value:h,onChange:e=>M(e.target.value),"data-testid":"notify-condition",autoComplete:"off",spellCheck:!1})]}):null,(0,t.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,t.jsx)("input",{type:"checkbox",checked:l,onChange:e=>y(e.target.checked),"data-testid":"notify-others-only"}),"Only when someone else does it"]}),(0,t.jsxs)("p",{style:w,"data-testid":"notify-said",children:[A(i.choices[n]),"."]}),C?(0,t.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-danger, var(--graview-ink))"},children:C}):null,(0,t.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[(0,t.jsx)("button",{type:"button",onClick:()=>c.current?.close(),children:"Cancel"}),(0,t.jsx)("button",{type:"submit",autoFocus:!0,disabled:W,"data-testid":"notify-keep",style:{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"},children:"Notify me"})]})]})})}function B({style:i}){let{store:d,principal:r,subscriptions:s,app:m}=S(),f=(r.onBehalfOf??r).id,[c,p]=(0,o.useState)([]);return(0,o.useEffect)(()=>{if(f===void 0)return;let n=!0,u=()=>void Promise.resolve(s.list(f)).then(y=>n&&p(y.filter(h=>h.app===(m?.name??"app"))),()=>n&&p([]));u();let l=s.onChange?.(u);return()=>{n=!1,l?.()}},[s,f,m]),c.length===0?null:(0,t.jsxs)("section",{"aria-label":"What you are told of","data-testid":"notified",style:{display:"grid",gap:6,...i},children:[(0,t.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"You are told"}),(0,t.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:c.map(n=>(0,t.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"baseline",justifyContent:"space-between"},"data-subscription":n.id,children:[(0,t.jsx)("span",{style:{fontSize:"0.8125rem"},children:b(d,n)}),(0,t.jsx)("button",{type:"button","data-testid":"notify-stop","aria-label":`Stop: ${b(d,n)}`,onClick:u=>{let l=u.currentTarget.closest("li"),y=(l?.nextElementSibling??l?.previousElementSibling)?.querySelector("button");Promise.resolve(s.remove(n.id)).then(()=>(y??document.querySelector("[data-testid='activity-button']"))?.focus())},style:{padding:"1px 8px",fontSize:"0.8125rem"},children:"Stop"})]},n.id))})]})}export{B as NotifiedList,j as NotifySheet};
1
+ import{a as P,b}from"./chunk.NJ62C2GU.js";import"./chunk.FUR4IHWG.js";import"./chunk.2B4WVCVV.js";import"./chunk.AAZFVCSP.js";import"./chunk.BZ5VLPKB.js";import{F as G,Q as O,Y as S}from"./chunk.6II4BONS.js";import{qc as E}from"./chunk.F5BCCGFK.js";import{b as v}from"./chunk.AJZBJBMO.js";var o=v(G(),1);var t=v(O(),1);function I(i){for(let d of i)for(let[r,s]of Object.entries(d))if(s===!1)return`${r} == true`;return""}var w={margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function j({ask:i,close:d}){let{store:r,principal:s,subscriptions:m,app:f}=S(),c=(0,o.useRef)(null),p=(0,o.useId)(),[n,u]=(0,o.useState)(0),[l,y]=(0,o.useState)(!0),[h,M]=(0,o.useState)(()=>{let e=i.choices.find(g=>g.on==="reaches");if(!e)return"";let a=e.record!==void 0?r.graph.getNode(e.record):void 0;return I(a?[a]:r.graph.nodesOfKind(e.kind).slice(0,5))}),[C,k]=(0,o.useState)(null),[W,x]=(0,o.useState)(!1);(0,o.useEffect)(()=>{let e=c.current;e&&!e.open&&e.showModal()},[]);let N=()=>{let e=i.returnTo;d(),requestAnimationFrame(()=>{e?.isConnected?e.focus():document.querySelector("[data-graview-page-title], main h1, [data-testid='activity-button']")?.focus()})},T=e=>e.on==="reaches"?{...e,condition:h}:e,A=e=>b(r,{when:T(e),alsoMine:!l}),z=async()=>{let e=T(i.choices[n]),a=P(r,e);if(a){k(a);return}x(!0);try{await m.add({who:E(s),app:f?.name??"app",when:e,...l?{}:{alsoMine:!0}}),N()}catch(g){x(!1),k(g instanceof Error?g.message:String(g))}};return(0,t.jsx)("dialog",{ref:c,"aria-labelledby":p,"data-testid":"notify-sheet",onClose:N,onClick:e=>{e.target===e.currentTarget&&e.currentTarget.close()},style:{width:"min(92vw, 420px)",padding:0,border:"1px solid var(--graview-edge)",borderRadius:"var(--graview-radius, 12px)",background:"var(--graview-panel)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)"},children:(0,t.jsxs)("form",{method:"dialog",onSubmit:e=>{e.preventDefault(),z()},style:{display:"grid",gap:12,padding:18},children:[(0,t.jsx)("h2",{id:p,style:{margin:0,fontSize:"1.0625rem"},children:"Notify me"}),(0,t.jsxs)("fieldset",{style:{margin:0,padding:0,border:0,display:"grid",gap:6},children:[(0,t.jsx)("legend",{style:{...w,marginBottom:6},children:"Tell me"}),i.choices.map((e,a)=>(0,t.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"baseline",cursor:"pointer"},children:[(0,t.jsx)("input",{type:"radio",name:`${p}-when`,checked:n===a,onChange:()=>u(a),"data-notify-choice":e.on}),(0,t.jsx)("span",{children:e.on==="reaches"?`When ${e.record!==void 0?"it":"one"} reaches a condition`:A(e)})]},a))]}),i.choices[n]?.on==="reaches"?(0,t.jsxs)("label",{style:{display:"grid",gap:4},children:[(0,t.jsx)("span",{style:w,children:"The condition, in the app's own words (done == true, amount > 100)"}),(0,t.jsx)("input",{value:h,onChange:e=>M(e.target.value),"data-testid":"notify-condition",autoComplete:"off",spellCheck:!1})]}):null,(0,t.jsxs)("label",{style:{display:"flex",gap:8,alignItems:"center"},children:[(0,t.jsx)("input",{type:"checkbox",checked:l,onChange:e=>y(e.target.checked),"data-testid":"notify-others-only"}),"Only when someone else does it"]}),(0,t.jsxs)("p",{style:w,"data-testid":"notify-said",children:[A(i.choices[n]),"."]}),C?(0,t.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-danger, var(--graview-ink))"},children:C}):null,(0,t.jsxs)("div",{style:{display:"flex",gap:8,justifyContent:"flex-end"},children:[(0,t.jsx)("button",{type:"button",onClick:()=>c.current?.close(),children:"Cancel"}),(0,t.jsx)("button",{type:"submit",autoFocus:!0,disabled:W,"data-testid":"notify-keep",style:{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"},children:"Notify me"})]})]})})}function B({style:i}){let{store:d,principal:r,subscriptions:s,app:m}=S(),f=(r.onBehalfOf??r).id,[c,p]=(0,o.useState)([]);return(0,o.useEffect)(()=>{if(f===void 0)return;let n=!0,u=()=>void Promise.resolve(s.list(f)).then(y=>n&&p(y.filter(h=>h.app===(m?.name??"app"))),()=>n&&p([]));u();let l=s.onChange?.(u);return()=>{n=!1,l?.()}},[s,f,m]),c.length===0?null:(0,t.jsxs)("section",{"aria-label":"What you are told of","data-testid":"notified",style:{display:"grid",gap:6,...i},children:[(0,t.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"You are told"}),(0,t.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:c.map(n=>(0,t.jsxs)("li",{style:{display:"flex",gap:8,alignItems:"baseline",justifyContent:"space-between"},"data-subscription":n.id,children:[(0,t.jsx)("span",{style:{fontSize:"0.8125rem"},children:b(d,n)}),(0,t.jsx)("button",{type:"button","data-testid":"notify-stop","aria-label":`Stop: ${b(d,n)}`,onClick:u=>{let l=u.currentTarget.closest("li"),y=(l?.nextElementSibling??l?.previousElementSibling)?.querySelector("button");Promise.resolve(s.remove(n.id)).then(()=>(y??document.querySelector("[data-testid='activity-button']"))?.focus())},style:{padding:"1px 8px",fontSize:"0.8125rem"},children:"Stop"})]},n.id))})]})}export{B as NotifiedList,j as NotifySheet};
@@ -1 +1 @@
1
- import{b as rn,c as on,d as te,e as an,f as re,h as Oe,i as sn,n as dn,q as oe}from"./chunk.4K5QCJFH.js";import{A as pe,B as me,Da as _e,E as ke,G as Ne,Ga as He,H as Ce,Ob as en,Qa as Ue,Ra as We,V as Ke,Va as xe,Wa as Je,Yb as nn,Z as Ve,Zb as tn,b as je,c as De,d as $e,da as Ie,e as K,g as de,h as L,i as Te,ib as U,j as Ge,k as ce,ka as we,l as Me,lb as Ye,m as Pe,na as Ze,o as Le,p as le,pb as Qe,q as he,qa as qe,sa as Be,ub as Xe,v as Fe,wa as be,x as ne,xa as ve,y as fe}from"./chunk.X7W27IRI.js";function Dn(e,a){let n=e.brand??{},t=n.accent?tn(n.accent):void 0;t&&!t.ok&&a.push(sn("brand","brand.accent",`that accent cannot make a readable brand, so the app keeps Graview's colors: ${t.why}`,"pick a color further from orange-red, or a darker one"));let l=typeof n.logo=="string"?{src:n.logo}:n.logo,c=n.name??e.name,x=n.typography?Object.fromEntries(Object.entries(n.typography).filter(([,S])=>typeof S=="string"&&!/url\(|@import|[;{}<>\\]/i.test(S)).map(([S,I])=>[S,nn(I)])):void 0;return{name:c,schemes:t?.ok?t.schemes:en,...n.currency?{currency:n.currency}:{},...n.locale?{locale:n.locale}:{},...l?{logo:l.src,logoAlt:l.alt??c}:{},...n.favicon?{favicon:n.favicon}:{},...e.description?{subtitle:e.description}:{},...x?{typography:x}:{},...n.shape?{shape:n.shape}:{},...n.accents?{accents:n.accents}:{},...n.scheme?{scheme:n.scheme}:{}}}function cn(e){let{currency:a,locale:n}=e.brand??{};return{...a?{currency:a}:{},...n?{locale:n}:{}}}var kn=Symbol.for("@graview/core:typed-field"),ln=(e,a)=>(/^(phone|place|duration)$/.test(a)&&(me(e)[kn]=a),e),fn=/^(?=(?:\D*\d){3})\+?[\d ()./-]+(?: *(?:ext\.?|x|#) *\d+)?$/i;function pn(e){let a=L().check(K(300),fe(t=>qe(t,e)!==void 0,`a record of ${e.kinds.join(" or ")} in ${e.address}, as "<kind>:<id>"`)),n=e.cardinality==="one"?a:le(a).check(K(200));return Be(e.description?n.check(pe(e.description)):n,e)}var bn=new WeakMap;function mn(e,a){bn.set(e,a)}var vn=[{where:"settings[]",was:"honoured",now:"honored",since:"0.1.16"},{where:"pages",was:"overview",now:"scene",since:"0.1.17"}],V=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function un(e,a=vn){if(!V(e))return{document:e,respelled:[]};let n=[],t=e;for(let l of a)t=Re(t,l.where.split("."),l,"",n);return{document:t,respelled:n}}function Re(e,a,n,t,l){if(a.length===0){if(!V(e)||!Object.hasOwn(e,n.was))return e;l.push(`${t}${n.was}`);let{[n.was]:B,...F}=e;return Object.hasOwn(e,n.now)?F:{...F,[n.now]:B}}if(!V(e))return e;let[c,...x]=a,S=c.endsWith("[]"),I=S?c.slice(0,-2):c,$=e[I],T=$;if(!S)T=Re($,x,n,`${t}${I}.`,l);else if(Array.isArray($)){let B=$.map((F,W)=>Re(F,x,n,`${t}${I}.${W}.`,l));T=B.some((F,W)=>F!==$[W])?B:$}return T===$?e:{...e,[I]:T}}var yn="graview-compiled@1";function xn(e,a){return e.find(([n,t])=>n!==q&&"ref"in t&&(t.ref==="*"||t.ref.includes(a)))?.[0]}var q="id",ue=e=>typeof e=="string"&&/^\$[A-Za-z][A-Za-z0-9]*$/.test(e)?e.slice(1):void 0;function gn(e){let a=Object.entries(e.fields),n=t=>["name","title","label"].find(l=>t.some(([c])=>c===l))??t[0]?.[0];return n(a.filter(([,t])=>t.required&&(t.type==="string"||t.type==="text")))??n(a.filter(([,t])=>t.type==="string"))}function hn(e,a,n){let t;switch(e.type){case"string":case"place":t=L().check(K(500));break;case"phone":t=L().check(K(40),de(fn,"a phone number"));break;case"text":t=L().check(K(2e4)),e.format&&(me(t)[Symbol.for("@graview/core:markdown")]=1);break;case"number":case"integer":case"duration":{let c=e.min??(e.type==="duration"?0:void 0),x=[...e.type==="number"?[]:[Me()],...c===void 0?[]:[De(c)],...e.max===void 0?[]:[je(e.max)],...e.step===void 0?[]:[$e(e.step)]];t=x.length>0?ce().check(...x):ce();break}case"boolean":t=Pe();break;case"date":t=L().check(de(ke,"a date like 2026-10-02"));break;case"datetime":t=L().check(fe(Ne,"a date and time like 2026-10-02T14:30:00Z"));break;case"enum":t=Fe(e.options);break;case"list":t=le(e.of==="number"?ce():e.of==="date"?L().check(de(ke)):e.of==="image"||e.of==="file"?we(e.of):L().check(K(500))).check(K(200));break;case"image":case"file":t=we(e.type);break;case"app-link":t=Ze();break;case"url":t=Ge();break;case"email":t=Te();break}let l=e.type==="number"||e.type==="integer";return ln(t,l&&e.format==="duration"?"duration":e.type),e.description&&(t=t.check(pe(e.description))),l&&(e.format==="money"||e.format==="percent"||!e.format&&e.unit)&&Qe(t,{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{}}),a?ne(t):t}var ie=e=>{throw new U(`there is no record "${e}"`,"invalid")},On=(e,a)=>"field"in e?hn(e.field,e.optional,a):"ref"in e?Xe(e.ref):ne(Le()),Rn=new WeakMap;var Ae=(e,a)=>V(a)&&Object.keys(e??{}).length===Object.keys(a).length&&Object.keys(e??{}).every(n=>Object.hasOwn(a,n));function nt(e,a={}){let n=V(e)?e.format:void 0;if(n!==yn)return{ok:!1,findings:[Oe("compiled-format","format",n===void 0?"this is not a compiled Graview app":`this compiled app is ${JSON.stringify(n)}, and this build reads ${yn}`,"compile the document instead")]};let t=e,l=un(t.document).document,c=l===t.document?t:{...t,document:l},x=V(l)&&typeof l.name=="string"&&V(l.kinds)&&Ae(l.kinds,c.kinds)&&Ae(l.acts,c.acts)&&Ae(l.rules,c.rules)&&Array.isArray(c.edges)&&Array.isArray(c.findings),S={ok:!1,findings:[Oe("compiled-shape","","this compiled app's parts do not match its document","compile the document instead")]};if(!x)return S;try{return An(c,a)}catch{return S}}function An(e,a={}){let{document:n}=e,t=a.today??Ce,l=new Map(e.edges.map(([g,r])=>[g,r])),c=new Map;for(let[g,r]of Object.entries(n.kinds)){let R=e.kinds[g]?.computed,O=ve(r.edges);c.set(g,{fields:new Set([...Object.keys(r.fields),...O.keys()]),edges:new Map(Object.entries(be(r.edges)).map(([j,G])=>[j,G.cardinality??"many"])),...R?{computed:new Map(R)}:{},...O.size>0?{linked:O}:{}})}e.facts&&c.set(on,{computed:new Map(e.facts)});let x=cn(n),S=new Map,I=Object.entries(n.kinds).map(([g,r])=>{let R={};for(let[o,u]of Object.entries(r.fields))R[o]=hn(u,!u.required,x),u.repeats&&(R[_e(o)]=ne(He()));for(let[o,u]of ve(r.edges))R[o]=ne(pn(u));let{label:O,describe:j,durations:G}=e.kinds[g]??{},M=Object.entries(r.computed??{}).map(([o,u])=>[o,typeof u=="string"?{expr:u}:u]),J=Object.hasOwn(r.fields,"label")&&!r.fields.label.label&&!/\{\s*label\b/.test(r.label??`{${gn(r)??""}}`),_=Object.fromEntries([...J?[["label","Label"]]:[],...Object.entries(r.fields).filter(([,o])=>o.label).map(([o,u])=>[o,u.label]),...M.filter(([,o])=>o.label).map(([o,u])=>[o,u.label])]),A=Object.keys(_).length>0,f=Object.fromEntries(Object.entries(r.fields).filter(([,o])=>o.default!==void 0).map(([o,u])=>[o,u.default]));S.set(g,f);let D=Object.fromEntries(Object.entries(be(r.edges)).map(([o,{renamedFrom:u,...Z}])=>[o,Z])),z=o=>r[o]?{[o]:r[o]}:{};return Ke(g,{fields:he(R),edges:D,...z("plural"),...z("noun"),...z("description"),...O?{label:o=>oe(O,{node:o,kinds:c,today:t(),money:x})||o.id}:{},...j?{describe:o=>oe(j,{node:o,kinds:c,today:t(),money:x})}:{},...z("lifecycle"),...z("figure"),...z("fieldRoles"),...z("people"),archives:r.archives,...r.tidying?{tidying:r.tidying}:{},...M.length>0?{computed:Object.fromEntries(M.map(([o,u])=>[o,G?.includes(o)?{...u,as:"duration"}:r.computed[o]]))}:{},...A||r.glance||r.page?{display:{...A?{labels:_}:{},...r.glance?{glance:[...r.glance]}:{},...r.page?{page:r.page}:{}}}:{},...Object.keys(f).length>0?{defaults:f}:{}})}),$=Ue(I,n.computed);function T(g){return $.tryDefinition(g.kind)?.label?.(g)??g.id}let B=g=>({id:"",kind:g,...S.get(g)}),F=[];for(let[g,r]of Object.entries(n.acts??{})){let R=e.acts[g],{title:O,effects:j,guard:G,refusal:M,destructive:J,idempotent:_,creates:A,connects:f,severs:D,writes:z,writesOther:o,sets:u}=R,Z=new Map(R.args),ae={};for(let[s,b]of Z)ae[s]=On(b,x);let k=[r.on??[]].flat(),N=new Map(R.exprs),P=j.find(s=>"create"in s),Y=(s,b,p,w=null)=>{if(V(s)&&"expr"in s)return re(N.get(s.expr),{graph:p,subject:w,kinds:c,bindings:b,today:t()});let h=ue(s);return h===void 0?typeof s=="string"&&s.startsWith("$$")?s.slice(1):s:h==="now"?new Date().toISOString():h==="today"?t():b[h]},Se=(s,b)=>{if(!P)return"";let p=n.kinds[P.create].fields,w=B(P.create),h=[];for(let[v,ee]of Object.entries(P.set??{})){try{w[v]=Y(ee,s,b)??w[v]}catch{}let Q=ue(ee);Q&&s[Q]!==void 0&&h.push(v)}let C=T(w).trim(),H=h.filter(v=>w[v]!==!1&&p[v].type!=="text"&&!(/[^]{41}/.test(w[v])||/ .*[.!?]$/.test(w[v])&&!/[ .][A-Z]\w{0,3}\.$/.test(w[v]))&&T({...w,[v]:void 0}).trim()===C).map(v=>w[v]===!0?p[v].label??Ve(v):dn(w[v],p[v].format,t(),[],x));return C&&H.length>0?`${C} (${H.join(", ")})`:C};F.push(Ye(g,{input:he(ae),title:O,...r.description?{description:r.description}:{},...r.fromTheOtherEnd?{fromTheOtherEnd:r.fromTheOtherEnd}:{},...Z.has(q)?{subject:{kinds:k.length>0?k:"*",arg:q}}:{},...J?{destructive:!0}:{},..._?{idempotent:!0}:{},...A.length>0?{creates:A}:{},...f.length>0?{connects:f}:{},...D.length>0?{severs:D}:{},writes:z,...Object.keys(o).length>0?{writesOther:o}:{},...Object.keys(u).length>0?{sets:u}:{},describe:(s,b)=>{let p=typeof s[q]=="string"?b.getNode(s[q]):void 0,w=p?T(p):Se(s,b);return w?`${O}: ${w}`:O},apply(s,b){let p=s.graph,w=typeof b[q]=="string"?b[q]:void 0,h=w?p.getNode(w):void 0;if(w&&!h&&ie(w),h&&k.length>0&&!k.includes(h.kind))throw new U(`"${O}" acts on ${k.join(" or ")}, not on ${Ie(h.kind)}`,"invalid");let C={};for(let[i,d]of Object.entries(b))d!==void 0&&(C[i]=d);if(G&&h){let i;try{i=re(G,{graph:p,subject:h,kinds:c,bindings:C,today:t()})}catch(d){throw d instanceof te?new U(`"${O}" could not be judged: ${d.sentence}`):d}if(i!==!0)throw new U(M?oe(M,{node:h,kinds:c,graph:p,bindings:C,today:t(),money:x}):`"${O}" is not allowed for ${T(h)} right now`)}let H=new Map,v=i=>p.has(i)||[...H.values()].includes(i),ee=new Set,Q=i=>{let d=We(i);ee.has(d)||(ee.add(d),s.removeEdge(i))},X=(i,d)=>{let m=ue(i);if(m==="subject")return w;if(m==="me"){let y=s.me;if(y&&n.kinds[p.getNode(y)?.kind]?.people)return y;throw new U(`"${O}" is done as you, and you have no record here`)}if(H.has(m))return H.get(m);try{return Y(i,C,p,d??h??null)}catch(y){throw y instanceof te?new U(`"${O}" could not work out a value: ${y.sentence}`):y}};for(let i of j)if("create"in i){let d=n.kinds[i.create],m=B(i.create);for(let[ge,se]of Object.entries(i.set??{})){let Ee=X(se,void 0);Ee!==void 0&&(m[ge]=Ee)}let y=gn(d),E=s.freshId(String((y&&m[y])??i.create),i.create);s.addNode({...m,id:E}),i.as&&H.set(i.as,E)}else if("connect"in i||"sever"in i){let d="connect"in i?i.connect:i.sever,m=String(X(i.from,void 0)??""),y=String(X(i.to,void 0)??"");if(v(m)||ie(m),v(y)||ie(y),"connect"in i){if(l.get(d)?.cardinality==="one")for(let E of p.out(m,d))E.id!==y&&Q({kind:d,from:m,to:E.id});p.out(m,d).some(E=>E.id===y)||s.addEdge({kind:d,from:m,to:y})}else Q({kind:d,from:m,to:y})}else if("set"in i){let d=String(X(i.target??"$subject",void 0)??""),m=p.getNode(d);!m&&!v(d)&&ie(d);let y={};for(let[E,ge]of Object.entries(i.set)){let se=X(ge,m);se!==void 0&&(y[E]=se)}Object.keys(y).length>0&&s.patchNode(d,y)}else if("remove"in i){let d=String(X(i.remove,void 0)??"");p.has(d)||ie(d),s.removeNode(d)}else if("replace"in i&&h){let d=b.to;for(let m of i.replace){let y=l.get(m)?.from.includes(h.kind)??!0;for(let E of y?p.out(h.id,m):p.in(h.id,m))m===i.keep&&E.id===d||Q(y?{kind:m,from:h.id,to:E.id}:{kind:m,from:E.id,to:h.id})}}}}))}let W=[];for(let[g,r]of Object.entries(n.rules??{})){let{title:R,require:O,when:j,says:G}=e.rules[g],M=r.repairs??[],J=(A,f,D=t(),z)=>{let o=[],u={graph:A,subject:f,kinds:c,today:D,...z?{linked:z}:{},onUnread:k=>o.push(k)},Z;try{if(j&&re(j,u)!==!0)return[];if(Z=re(O,u)===!0,!Z&&o.length>0)throw new te(`it reads ${rn(o[0])}`,0)}catch(k){throw k instanceof an?new Je(k.sentence):k instanceof te?new Error(k.sentence):k}if(Z)return[];let ae=M.flatMap(k=>{let N=n.acts?.[k.act],P={},Y=f&&N?.on&&N.fromTheOtherEnd&&![N.on].flat().includes(f.kind)?xn(e.acts[k.act].args,f.kind):void 0;Y?P[Y]=f.id:f&&(N?.on||/^(edit|remove|archive|unarchive|merge|skip|detach|split)-/.test(k.act))&&(P[q]=f.id);for(let[b,p]of Object.entries(k.args??{}))P[b]=ue(p)==="subject"?f?.id:p;let s=(N?e.acts[k.act].args:[]).filter(([b,p])=>p.required&&P[b]===void 0).map(([b])=>b);return[{mutation:k.act,label:k.label??(Y?N.fromTheOtherEnd:N?.title)??k.act.replace(/-/g," "),args:P,...s.length>0?{missing:s}:{}}]});return[{invariant:g,...f?{subjectId:f.id}:{},label:R,message:G?oe(G,{node:f,kinds:c,graph:A,today:D,money:x}):f?`${T(f)}: ${R}`:R,nodeIds:f?[f.id]:[],repairs:ae}]},_={label:R,shape:{over:r.over,require:O,when:j,says:G,declared:n.kinds,money:x,kinds:c,today:t},judgment:{require:r.require,...r.when?{when:r.when}:{},...r.says?{says:r.says}:{}},...r.description?{description:r.description}:{},...M.length>0?{repairs:M.map(A=>A.act)}:{}};W.push(r.over==="graph"?xe(g,{scope:"graph",..._,evaluate:({graph:A,today:f,context:D})=>J(A,null,f,D?.linked)}):xe(g,{scope:{kind:r.over},..._,evaluate:({graph:A,subject:f,today:D,context:z})=>J(A,f,D,z?.linked)}))}let ze=n.policy&&{...n.policy,...n.roles?{roles:n.roles}:{}},ye={name:n.name,schema:$,mutations:F,invariants:W,...ze?{policy:ze}:{},...e.brand?{brand:e.brand}:{},...n.modules?{modules:n.modules}:{},...n.lenses?{lenses:n.lenses}:{},...n.pages?{pages:n.pages}:{},...n.settings?{settings:n.settings}:{},...n.connections?{connections:n.connections}:{},...e.viewSpecs?{viewSpecs:e.viewSpecs}:{},...e.home?{home:e.home}:{},version:n.version??1};return mn(ye,n),Rn.set(ye,e),{ok:!0,app:ye,document:n,findings:e.findings,sights:n.policy?.sees,kinds:c}}export{un as a,Dn as b,yn as c,q as d,ue as e,gn as f,nt as g,An as h};
1
+ import{b as rn,c as on,d as te,e as an,f as re,h as Oe,i as sn,n as dn,q as oe}from"./chunk.AAZFVCSP.js";import{A as pe,B as me,E as ke,Ea as _e,G as Ne,H as Ce,Ha as He,Pb as en,Ra as Ue,Sa as We,V as Ke,Wa as xe,Xa as Je,Z as Ve,Zb as nn,_b as tn,b as je,c as De,d as $e,da as Ie,e as K,g as de,h as L,i as Te,j as Ge,jb as U,k as ce,l as Me,la as we,m as Pe,mb as Ye,o as Le,oa as Ze,p as le,q as he,qb as Qe,ra as qe,ta as Be,v as Fe,vb as Xe,x as ne,xa as be,y as fe,ya as ve}from"./chunk.F5BCCGFK.js";function Dn(e,a){let n=e.brand??{},t=n.accent?tn(n.accent):void 0;t&&!t.ok&&a.push(sn("brand","brand.accent",`that accent cannot make a readable brand, so the app keeps Graview's colors: ${t.why}`,"pick a color further from orange-red, or a darker one"));let l=typeof n.logo=="string"?{src:n.logo}:n.logo,c=n.name??e.name,x=n.typography?Object.fromEntries(Object.entries(n.typography).filter(([,S])=>typeof S=="string"&&!/url\(|@import|[;{}<>\\]/i.test(S)).map(([S,I])=>[S,nn(I)])):void 0;return{name:c,schemes:t?.ok?t.schemes:en,...n.currency?{currency:n.currency}:{},...n.locale?{locale:n.locale}:{},...l?{logo:l.src,logoAlt:l.alt??c}:{},...n.favicon?{favicon:n.favicon}:{},...e.description?{subtitle:e.description}:{},...x?{typography:x}:{},...n.shape?{shape:n.shape}:{},...n.accents?{accents:n.accents}:{},...n.scheme?{scheme:n.scheme}:{}}}function cn(e){let{currency:a,locale:n}=e.brand??{};return{...a?{currency:a}:{},...n?{locale:n}:{}}}var kn=Symbol.for("@graview/core:typed-field"),ln=(e,a)=>(/^(phone|place|duration)$/.test(a)&&(me(e)[kn]=a),e),fn=/^(?=(?:\D*\d){3})\+?[\d ()./-]+(?: *(?:ext\.?|x|#) *\d+)?$/i;function pn(e){let a=L().check(K(300),fe(t=>qe(t,e)!==void 0,`a record of ${e.kinds.join(" or ")} in ${e.address}, as "<kind>:<id>"`)),n=e.cardinality==="one"?a:le(a).check(K(200));return Be(e.description?n.check(pe(e.description)):n,e)}var bn=new WeakMap;function mn(e,a){bn.set(e,a)}var vn=[{where:"settings[]",was:"honoured",now:"honored",since:"0.1.16"},{where:"pages",was:"overview",now:"scene",since:"0.1.17"}],V=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function un(e,a=vn){if(!V(e))return{document:e,respelled:[]};let n=[],t=e;for(let l of a)t=Re(t,l.where.split("."),l,"",n);return{document:t,respelled:n}}function Re(e,a,n,t,l){if(a.length===0){if(!V(e)||!Object.hasOwn(e,n.was))return e;l.push(`${t}${n.was}`);let{[n.was]:B,...F}=e;return Object.hasOwn(e,n.now)?F:{...F,[n.now]:B}}if(!V(e))return e;let[c,...x]=a,S=c.endsWith("[]"),I=S?c.slice(0,-2):c,$=e[I],T=$;if(!S)T=Re($,x,n,`${t}${I}.`,l);else if(Array.isArray($)){let B=$.map((F,W)=>Re(F,x,n,`${t}${I}.${W}.`,l));T=B.some((F,W)=>F!==$[W])?B:$}return T===$?e:{...e,[I]:T}}var yn="graview-compiled@1";function xn(e,a){return e.find(([n,t])=>n!==q&&"ref"in t&&(t.ref==="*"||t.ref.includes(a)))?.[0]}var q="id",ue=e=>typeof e=="string"&&/^\$[A-Za-z][A-Za-z0-9]*$/.test(e)?e.slice(1):void 0;function gn(e){let a=Object.entries(e.fields),n=t=>["name","title","label"].find(l=>t.some(([c])=>c===l))??t[0]?.[0];return n(a.filter(([,t])=>t.required&&(t.type==="string"||t.type==="text")))??n(a.filter(([,t])=>t.type==="string"))}function hn(e,a,n){let t;switch(e.type){case"string":case"place":t=L().check(K(500));break;case"phone":t=L().check(K(40),de(fn,"a phone number"));break;case"text":t=L().check(K(2e4)),e.format&&(me(t)[Symbol.for("@graview/core:markdown")]=1);break;case"number":case"integer":case"duration":{let c=e.min??(e.type==="duration"?0:void 0),x=[...e.type==="number"?[]:[Me()],...c===void 0?[]:[De(c)],...e.max===void 0?[]:[je(e.max)],...e.step===void 0?[]:[$e(e.step)]];t=x.length>0?ce().check(...x):ce();break}case"boolean":t=Pe();break;case"date":t=L().check(de(ke,"a date like 2026-10-02"));break;case"datetime":t=L().check(fe(Ne,"a date and time like 2026-10-02T14:30:00Z"));break;case"enum":t=Fe(e.options);break;case"list":t=le(e.of==="number"?ce():e.of==="date"?L().check(de(ke)):e.of==="image"||e.of==="file"?we(e.of):L().check(K(500))).check(K(200));break;case"image":case"file":t=we(e.type);break;case"app-link":t=Ze();break;case"url":t=Ge();break;case"email":t=Te();break}let l=e.type==="number"||e.type==="integer";return ln(t,l&&e.format==="duration"?"duration":e.type),e.description&&(t=t.check(pe(e.description))),l&&(e.format==="money"||e.format==="percent"||!e.format&&e.unit)&&Qe(t,{...n,...e.format?{format:e.format}:{},...e.unit?{unit:e.unit}:{}}),a?ne(t):t}var ie=e=>{throw new U(`there is no record "${e}"`,"invalid")},On=(e,a)=>"field"in e?hn(e.field,e.optional,a):"ref"in e?Xe(e.ref):ne(Le()),Rn=new WeakMap;var Ae=(e,a)=>V(a)&&Object.keys(e??{}).length===Object.keys(a).length&&Object.keys(e??{}).every(n=>Object.hasOwn(a,n));function nt(e,a={}){let n=V(e)?e.format:void 0;if(n!==yn)return{ok:!1,findings:[Oe("compiled-format","format",n===void 0?"this is not a compiled Graview app":`this compiled app is ${JSON.stringify(n)}, and this build reads ${yn}`,"compile the document instead")]};let t=e,l=un(t.document).document,c=l===t.document?t:{...t,document:l},x=V(l)&&typeof l.name=="string"&&V(l.kinds)&&Ae(l.kinds,c.kinds)&&Ae(l.acts,c.acts)&&Ae(l.rules,c.rules)&&Array.isArray(c.edges)&&Array.isArray(c.findings),S={ok:!1,findings:[Oe("compiled-shape","","this compiled app's parts do not match its document","compile the document instead")]};if(!x)return S;try{return An(c,a)}catch{return S}}function An(e,a={}){let{document:n}=e,t=a.today??Ce,l=new Map(e.edges.map(([g,r])=>[g,r])),c=new Map;for(let[g,r]of Object.entries(n.kinds)){let R=e.kinds[g]?.computed,O=ve(r.edges);c.set(g,{fields:new Set([...Object.keys(r.fields),...O.keys()]),edges:new Map(Object.entries(be(r.edges)).map(([j,G])=>[j,G.cardinality??"many"])),...R?{computed:new Map(R)}:{},...O.size>0?{linked:O}:{}})}e.facts&&c.set(on,{computed:new Map(e.facts)});let x=cn(n),S=new Map,I=Object.entries(n.kinds).map(([g,r])=>{let R={};for(let[o,u]of Object.entries(r.fields))R[o]=hn(u,!u.required,x),u.repeats&&(R[_e(o)]=ne(He()));for(let[o,u]of ve(r.edges))R[o]=ne(pn(u));let{label:O,describe:j,durations:G}=e.kinds[g]??{},M=Object.entries(r.computed??{}).map(([o,u])=>[o,typeof u=="string"?{expr:u}:u]),J=Object.hasOwn(r.fields,"label")&&!r.fields.label.label&&!/\{\s*label\b/.test(r.label??`{${gn(r)??""}}`),_=Object.fromEntries([...J?[["label","Label"]]:[],...Object.entries(r.fields).filter(([,o])=>o.label).map(([o,u])=>[o,u.label]),...M.filter(([,o])=>o.label).map(([o,u])=>[o,u.label])]),A=Object.keys(_).length>0,f=Object.fromEntries(Object.entries(r.fields).filter(([,o])=>o.default!==void 0).map(([o,u])=>[o,u.default]));S.set(g,f);let D=Object.fromEntries(Object.entries(be(r.edges)).map(([o,{renamedFrom:u,...Z}])=>[o,Z])),z=o=>r[o]?{[o]:r[o]}:{};return Ke(g,{fields:he(R),edges:D,...z("plural"),...z("noun"),...z("description"),...O?{label:o=>oe(O,{node:o,kinds:c,today:t(),money:x})||o.id}:{},...j?{describe:o=>oe(j,{node:o,kinds:c,today:t(),money:x})}:{},...z("lifecycle"),...z("figure"),...z("fieldRoles"),...z("people"),archives:r.archives,...r.tidying?{tidying:r.tidying}:{},...M.length>0?{computed:Object.fromEntries(M.map(([o,u])=>[o,G?.includes(o)?{...u,as:"duration"}:r.computed[o]]))}:{},...A||r.glance||r.page?{display:{...A?{labels:_}:{},...r.glance?{glance:[...r.glance]}:{},...r.page?{page:r.page}:{}}}:{},...Object.keys(f).length>0?{defaults:f}:{}})}),$=Ue(I,n.computed);function T(g){return $.tryDefinition(g.kind)?.label?.(g)??g.id}let B=g=>({id:"",kind:g,...S.get(g)}),F=[];for(let[g,r]of Object.entries(n.acts??{})){let R=e.acts[g],{title:O,effects:j,guard:G,refusal:M,destructive:J,idempotent:_,creates:A,connects:f,severs:D,writes:z,writesOther:o,sets:u}=R,Z=new Map(R.args),ae={};for(let[s,b]of Z)ae[s]=On(b,x);let k=[r.on??[]].flat(),N=new Map(R.exprs),P=j.find(s=>"create"in s),Y=(s,b,p,w=null)=>{if(V(s)&&"expr"in s)return re(N.get(s.expr),{graph:p,subject:w,kinds:c,bindings:b,today:t()});let h=ue(s);return h===void 0?typeof s=="string"&&s.startsWith("$$")?s.slice(1):s:h==="now"?new Date().toISOString():h==="today"?t():b[h]},Se=(s,b)=>{if(!P)return"";let p=n.kinds[P.create].fields,w=B(P.create),h=[];for(let[v,ee]of Object.entries(P.set??{})){try{w[v]=Y(ee,s,b)??w[v]}catch{}let Q=ue(ee);Q&&s[Q]!==void 0&&h.push(v)}let C=T(w).trim(),H=h.filter(v=>w[v]!==!1&&p[v].type!=="text"&&!(/[^]{41}/.test(w[v])||/ .*[.!?]$/.test(w[v])&&!/[ .][A-Z]\w{0,3}\.$/.test(w[v]))&&T({...w,[v]:void 0}).trim()===C).map(v=>w[v]===!0?p[v].label??Ve(v):dn(w[v],p[v].format,t(),[],x));return C&&H.length>0?`${C} (${H.join(", ")})`:C};F.push(Ye(g,{input:he(ae),title:O,...r.description?{description:r.description}:{},...r.fromTheOtherEnd?{fromTheOtherEnd:r.fromTheOtherEnd}:{},...Z.has(q)?{subject:{kinds:k.length>0?k:"*",arg:q}}:{},...J?{destructive:!0}:{},..._?{idempotent:!0}:{},...A.length>0?{creates:A}:{},...f.length>0?{connects:f}:{},...D.length>0?{severs:D}:{},writes:z,...Object.keys(o).length>0?{writesOther:o}:{},...Object.keys(u).length>0?{sets:u}:{},describe:(s,b)=>{let p=typeof s[q]=="string"?b.getNode(s[q]):void 0,w=p?T(p):Se(s,b);return w?`${O}: ${w}`:O},apply(s,b){let p=s.graph,w=typeof b[q]=="string"?b[q]:void 0,h=w?p.getNode(w):void 0;if(w&&!h&&ie(w),h&&k.length>0&&!k.includes(h.kind))throw new U(`"${O}" acts on ${k.join(" or ")}, not on ${Ie(h.kind)}`,"invalid");let C={};for(let[i,d]of Object.entries(b))d!==void 0&&(C[i]=d);if(G&&h){let i;try{i=re(G,{graph:p,subject:h,kinds:c,bindings:C,today:t()})}catch(d){throw d instanceof te?new U(`"${O}" could not be judged: ${d.sentence}`):d}if(i!==!0)throw new U(M?oe(M,{node:h,kinds:c,graph:p,bindings:C,today:t(),money:x}):`"${O}" is not allowed for ${T(h)} right now`)}let H=new Map,v=i=>p.has(i)||[...H.values()].includes(i),ee=new Set,Q=i=>{let d=We(i);ee.has(d)||(ee.add(d),s.removeEdge(i))},X=(i,d)=>{let m=ue(i);if(m==="subject")return w;if(m==="me"){let y=s.me;if(y&&n.kinds[p.getNode(y)?.kind]?.people)return y;throw new U(`"${O}" is done as you, and you have no record here`)}if(H.has(m))return H.get(m);try{return Y(i,C,p,d??h??null)}catch(y){throw y instanceof te?new U(`"${O}" could not work out a value: ${y.sentence}`):y}};for(let i of j)if("create"in i){let d=n.kinds[i.create],m=B(i.create);for(let[ge,se]of Object.entries(i.set??{})){let Ee=X(se,void 0);Ee!==void 0&&(m[ge]=Ee)}let y=gn(d),E=s.freshId(String((y&&m[y])??i.create),i.create);s.addNode({...m,id:E}),i.as&&H.set(i.as,E)}else if("connect"in i||"sever"in i){let d="connect"in i?i.connect:i.sever,m=String(X(i.from,void 0)??""),y=String(X(i.to,void 0)??"");if(v(m)||ie(m),v(y)||ie(y),"connect"in i){if(l.get(d)?.cardinality==="one")for(let E of p.out(m,d))E.id!==y&&Q({kind:d,from:m,to:E.id});p.out(m,d).some(E=>E.id===y)||s.addEdge({kind:d,from:m,to:y})}else Q({kind:d,from:m,to:y})}else if("set"in i){let d=String(X(i.target??"$subject",void 0)??""),m=p.getNode(d);!m&&!v(d)&&ie(d);let y={};for(let[E,ge]of Object.entries(i.set)){let se=X(ge,m);se!==void 0&&(y[E]=se)}Object.keys(y).length>0&&s.patchNode(d,y)}else if("remove"in i){let d=String(X(i.remove,void 0)??"");p.has(d)||ie(d),s.removeNode(d)}else if("replace"in i&&h){let d=b.to;for(let m of i.replace){let y=l.get(m)?.from.includes(h.kind)??!0;for(let E of y?p.out(h.id,m):p.in(h.id,m))m===i.keep&&E.id===d||Q(y?{kind:m,from:h.id,to:E.id}:{kind:m,from:E.id,to:h.id})}}}}))}let W=[];for(let[g,r]of Object.entries(n.rules??{})){let{title:R,require:O,when:j,says:G}=e.rules[g],M=r.repairs??[],J=(A,f,D=t(),z)=>{let o=[],u={graph:A,subject:f,kinds:c,today:D,...z?{linked:z}:{},onUnread:k=>o.push(k)},Z;try{if(j&&re(j,u)!==!0)return[];if(Z=re(O,u)===!0,!Z&&o.length>0)throw new te(`it reads ${rn(o[0])}`,0)}catch(k){throw k instanceof an?new Je(k.sentence):k instanceof te?new Error(k.sentence):k}if(Z)return[];let ae=M.flatMap(k=>{let N=n.acts?.[k.act],P={},Y=f&&N?.on&&N.fromTheOtherEnd&&![N.on].flat().includes(f.kind)?xn(e.acts[k.act].args,f.kind):void 0;Y?P[Y]=f.id:f&&(N?.on||/^(edit|remove|archive|unarchive|merge|skip|detach|split)-/.test(k.act))&&(P[q]=f.id);for(let[b,p]of Object.entries(k.args??{}))P[b]=ue(p)==="subject"?f?.id:p;let s=(N?e.acts[k.act].args:[]).filter(([b,p])=>p.required&&P[b]===void 0).map(([b])=>b);return[{mutation:k.act,label:k.label??(Y?N.fromTheOtherEnd:N?.title)??k.act.replace(/-/g," "),args:P,...s.length>0?{missing:s}:{}}]});return[{invariant:g,...f?{subjectId:f.id}:{},label:R,message:G?oe(G,{node:f,kinds:c,graph:A,today:D,money:x}):f?`${T(f)}: ${R}`:R,nodeIds:f?[f.id]:[],repairs:ae}]},_={label:R,shape:{over:r.over,require:O,when:j,says:G,declared:n.kinds,money:x,kinds:c,today:t},judgment:{require:r.require,...r.when?{when:r.when}:{},...r.says?{says:r.says}:{}},...r.description?{description:r.description}:{},...M.length>0?{repairs:M.map(A=>A.act)}:{}};W.push(r.over==="graph"?xe(g,{scope:"graph",..._,evaluate:({graph:A,today:f,context:D})=>J(A,null,f,D?.linked)}):xe(g,{scope:{kind:r.over},..._,evaluate:({graph:A,subject:f,today:D,context:z})=>J(A,f,D,z?.linked)}))}let ze=n.policy&&{...n.policy,...n.roles?{roles:n.roles}:{}},ye={name:n.name,schema:$,mutations:F,invariants:W,...ze?{policy:ze}:{},...e.brand?{brand:e.brand}:{},...n.modules?{modules:n.modules}:{},...n.lenses?{lenses:n.lenses}:{},...n.pages?{pages:n.pages}:{},...n.settings?{settings:n.settings}:{},...n.connections?{connections:n.connections}:{},...e.viewSpecs?{viewSpecs:e.viewSpecs}:{},...e.home?{home:e.home}:{},version:n.version??1};return mn(ye,n),Rn.set(ye,e),{ok:!0,app:ye,document:n,findings:e.findings,sights:n.policy?.sees,kinds:c}}export{un as a,Dn as b,yn as c,q as d,ue as e,gn as f,nt as g,An as h};
@@ -1 +1 @@
1
- import{q as re}from"./chunk.YT2CYCVT.js";import{a as j,b as C,c as J,d as te,e as ne,f as P,g as ie,k as ae,n as oe}from"./chunk.HWITWOP3.js";import{a as X,b as Z,c as ee}from"./chunk.QVKKXMNK.js";import"./chunk.ZSW74NVJ.js";import"./chunk.ZE4CTZQ3.js";import{a as _}from"./chunk.U5ACEYAN.js";import"./chunk.UT6642FC.js";import"./chunk.TI4OSTQV.js";import"./chunk.PPUAPAWR.js";import"./chunk.Z7ZCR4LN.js";import"./chunk.RIW7SQH4.js";import"./chunk.FSAHO3LV.js";import{m as V}from"./chunk.PNVR3CXR.js";import{F as ge,I as Q,Q as Y,Y as U}from"./chunk.ZTD2CNC3.js";import{$ as N,fc as B}from"./chunk.X7W27IRI.js";import{b as D}from"./chunk.AJZBJBMO.js";var a=D(ge(),1);var l=D(Y(),1),fe=new Set(["show","go","to","open","the","a","an","me"]),de=o=>o.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,""),O=(o,c)=>{let r=de(o);return c.every(t=>r.includes(t))},se=o=>o&&`${o[0].toLowerCase()}${o.slice(1)}`,I={act:4,show:3,place:3,record:4},he=360,h=12;function Ie({face:o,opening:c,close:r}){let t=_(),{setMenuAt:y}=U(),i=(0,a.useMemo)(()=>c.target??j(c.pointed??{about:[]},e=>t.store.graph.has(e)),[c,t.store]),g=(0,a.useMemo)(()=>te(t.store,i,t.places),[t.store,i,t.places]),[p,v]=(0,a.useState)(""),[b,m]=(0,a.useState)(-1),[s,E]=(0,a.useState)(null),[A,L]=(0,a.useState)(null),T=(0,a.useRef)(null),W=(0,a.useRef)(null),M=(0,a.useId)(),R=(0,a.useRef)(!0),{ghost:z}=Q(t.desk);(0,a.useEffect)(()=>()=>{R.current=!1;let e=t.desk.get().ghost;e?.onCard&&t.desk.setGhost({...e,onCard:!1})},[t.desk]);let $=(0,a.useMemo)(()=>{let e=P(t,i);return J(t.store,i,{principal:t.principal,places:t.places,...e.acts?{acts:e.acts}:{}})},[t,i]),G=(0,a.useMemo)(()=>{let e=C(i);if(e.length===0)return[];let n=new Set($.candidates.flatMap(d=>d.type==="act"?[d.mutation]:[]));return X(t.store,e,{principal:t.principal,...e.length===1?{focus:e[0]}:{}}).affordances.filter(d=>!d.destructive&&n.has(d.mutation))},[t.store,t.principal,i,$]),q=(0,a.useCallback)(()=>{let e=c.returnTo,n=le(T.current,i,o);r(),requestAnimationFrame(()=>{if(e?.isConnected&&!e.closest("[inert]"))return e.focus({preventScroll:!0});let d=(n&&n.tabIndex>=0?n:null)??document.querySelector("[data-graview-page-title]")??document.querySelector("main");d&&d.tabIndex<0&&!d.hasAttribute("tabindex")&&d.setAttribute("tabindex","-1"),d?.focus({preventScroll:!0})})},[c.returnTo,i,o,r]),K=(0,a.useCallback)(e=>{if(e.open.length>0){let n=T.current?.getBoundingClientRect();r(),y({x:n?.left??0,y:n?.top??0,on:e.args.id??C(i)[0],about:C(i)});return}try{ee(t.store,e,{}),Z(t.store,e,{},{author:t.principal}),q()}catch(n){L(n instanceof Error?n.message:String(n))}},[t.store,t.principal,r,q,y,i]),H=(0,a.useCallback)(async e=>{let n=e.trim();if(!n)return;let d=s?.result?.answer?{said:s.said,answer:s.result.answer}:void 0;v(""),m(-1),L(null),E({said:n,result:null});let S=await ne(t.ai,{...P(t,i,n),said:n,...d?{follows:d}:{}});t.desk.record(S.interaction),S.ghost&&S.ghost.proposals.length>0&&t.desk.setGhost({ghost:S.ghost,onCard:!0}),R.current&&E({said:n,result:S})},[s,t,i]),F=(0,a.useRef)(c.asked);(0,a.useEffect)(()=>{let e=F.current;F.current=void 0,e&&H(e)},[]);let k=(0,a.useMemo)(()=>{let e=p.trim();if(!e&&s)return[];let n=de(e).split(/\s+/).filter(f=>f&&!fe.has(f)),d=/^show\b/i.test(e),S=/^(go|open)\b/i.test(e),x=[];if(!d&&!S)for(let f of G.filter(u=>O(u.label,n)).slice(0,I.act))x.push({id:`act:${f.id}`,kind:"act",label:f.label,hint:f.open.length>0?"asks more":"do it",take:()=>K(f)});if(!S){let f=$.candidates.filter(u=>u.type==="panel");for(let u of f.filter(ue=>O(`show ${ue.label}`,n)).slice(0,I.show))x.push({id:u.id,kind:"show",label:`Show ${se(u.label)}`,hint:"a panel",take:()=>{r(),ie(t,{title:u.label,recipe:{...u.panel,title:u.label}})}})}if(!d){for(let f of t.places.filter(u=>O(u.title,n)).slice(0,I.place))x.push({id:`place:${f.as}`,kind:"place",label:`Go to ${f.title}`,take:()=>(r(),t.goTo.place(f.as))});if(n.length>0){let f=re(t.store,e.replace(/^(go to|open)\s+/i,""),{principal:t.principal,from:C(i),limit:I.record}).hits;for(let u of f)u.about==="node"&&x.push({id:`record:${u.id}`,kind:"record",label:u.label,hint:N(t.store.schema,u.kind),take:()=>(r(),t.goTo.record(u.id))})}}return e&&x.push({id:"ask",kind:"ask",label:e,take:()=>void H(e)}),x},[p,G,$,t,i,K,H,r,s]);(0,a.useEffect)(()=>m(p.trim()?0:-1),[p]),(0,a.useLayoutEffect)(()=>{let e=T.current;if(!e)return;if(typeof e.showPopover=="function")try{e.showPopover()}catch{}W.current?.focus({preventScroll:!0});let n=0,d=()=>{me(e,le(e,i,o)),n=requestAnimationFrame(d)};return d(),()=>cancelAnimationFrame(n)},[i,o]),(0,a.useEffect)(()=>{if(s)return;let e=n=>{n.target instanceof Node&&T.current?.contains(n.target)||r()};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[s,r]);let ce=e=>{if(e.key==="ArrowDown"&&k.length>0)e.preventDefault(),m(n=>Math.min(k.length-1,n+1));else if(e.key==="ArrowUp"&&k.length>0)e.preventDefault(),m(n=>Math.max(0,n-1));else if(e.key==="Enter"){e.preventDefault();let n=k[b];n?n.take():p.trim()&&H(p)}},w=s?.result??null,pe=k[b];return(0,l.jsxs)("section",{ref:T,popover:"manual",role:"region","aria-label":s?`Answer about ${g}`:`Ask about ${g}`,"data-testid":"quick-ask","data-quick-ask":s?"answer":"bar","data-quick-ask-face":o,"data-graview-offstage":"","data-graview-overlay":"",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),q())},onMouseDown:e=>e.stopPropagation(),style:ke,children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[(0,l.jsxs)("p",{"data-testid":"quick-ask-about",style:{margin:0,flex:"1 1 auto",minWidth:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)",overflowWrap:"anywhere"},children:["About ",g]}),(0,l.jsx)("button",{type:"button","data-testid":"quick-ask-close","aria-label":"Close",title:"Close",onClick:q,style:we,children:(0,l.jsx)("span",{"aria-hidden":"true",children:"\u2715"})})]}),s?(0,l.jsxs)("div",{"data-testid":"quick-answer",style:{display:"grid",gap:8},children:[(0,l.jsxs)("p",{"data-testid":"quick-answer-asked",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",fontStyle:"italic",overflowWrap:"anywhere"},children:["\u201C",s.said,"\u201D"]}),(0,l.jsx)("p",{"data-testid":"quick-answer-text","aria-live":"polite",style:{margin:0,fontSize:"0.9375rem",lineHeight:1.45,color:w?.interaction.outcome==="failed"?"var(--graview-warn)":"var(--graview-ink)",overflowWrap:"anywhere"},children:w===null?"Thinking\u2026":w.interaction.outcome==="failed"?w.interaction.failed??"The AI could not answer that here.":w.answer??""}),w&&w.offers.length>0?(0,l.jsx)("ul",{"aria-label":"What acts on it",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:6},children:w.offers.map(e=>(0,l.jsx)("li",{children:(0,l.jsx)("button",{type:"button","data-testid":"quick-answer-offer","data-ai-offer":e.id,"data-ai-offer-type":e.type,onClick:()=>{ae(t,w,e,r).then(n=>{n&&R.current&&L(n)})},style:ve,children:e.type==="panel"?`Show ${se(e.label)}`:e.type==="place"?`Go to ${e.label}`:e.label})},e.id))}):null,z?.onCard&&z.ghost.interaction===w?.interaction.id?(0,l.jsx)(oe,{placement:"card"}):null]}):null,(0,l.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,l.jsx)("input",{ref:W,type:"text",role:"combobox","data-testid":"quick-ask-input","aria-label":s?`Ask a follow-up about ${g}`:`Ask about ${g}, or go somewhere`,"aria-expanded":k.length>0,"aria-controls":M,"aria-autocomplete":"list",...pe?{"aria-activedescendant":`${M}-${b}`}:{},autoComplete:"off",enterKeyHint:"go",placeholder:s?"Ask a follow-up\u2026":"Ask, or go to\u2026",value:p,readOnly:s!==null&&w===null,"aria-busy":s!==null&&w===null,onChange:e=>v(e.target.value),onKeyDown:ce,style:be}),(0,l.jsx)("div",{id:M,role:"listbox","aria-label":p.trim()?`What \u201C${p.trim()}\u201D finds here`:"What can be done here",hidden:k.length===0,style:{display:k.length===0?"none":"grid",gap:1,maxHeight:280,overflowY:"auto"},children:k.map((e,n)=>(0,l.jsx)("div",{id:`${M}-${n}`,role:"option","aria-selected":n===b,"data-testid":"quick-ask-option","data-quick-ask-kind":e.kind,"data-quick-ask-row":e.id,onMouseEnter:()=>m(n),onMouseDown:d=>d.preventDefault(),onClick:e.take,style:{...ye,background:n===b?"var(--graview-panel-muted)":"transparent",...e.kind==="ask"?{borderTop:"1px solid var(--graview-edge)",marginTop:2}:{}},children:e.kind==="ask"?(0,l.jsxs)("span",{children:["Ask: ",(0,l.jsxs)("span",{style:{fontWeight:600},children:["\u2018",e.label,"\u2019"]})]}):(0,l.jsxs)("span",{children:[e.label,e.hint?(0,l.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",e.hint]}):null]})},e.id))})]}),A?(0,l.jsx)("p",{role:"alert","data-testid":"quick-ask-refused",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-warn)"},children:A}):null,(0,l.jsx)("span",{style:V,"aria-live":"polite",children:k.length>0&&p.trim()?`${k.length} ${k.length===1?"way":"ways"} to go on`:""})]})}function le(o,c,r){let t=o?.closest("[data-graview-embed]")??document,y=c.on==="list"?[`aggregate:${c.kind}`,`kind:${c.kind}`]:c.on==="lens"&&c.kind?[`aggregate:${c.kind}`]:C(c);for(let i of y)for(let g of t.querySelectorAll(`[data-graview-view="${CSS.escape(i)}"], [data-graview-pick="${CSS.escape(i)}"]`)){if(o?.contains(g))continue;let p=g.getBoundingClientRect();if(p.width>0&&p.height>0)return g}return r==="pages"?t.querySelector("main [data-graview-page-title]")??t.querySelector("main h1"):null}function me(o,c){let r={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},t=Math.min(he,r.width-2*h),y=o.getBoundingClientRect().height,i=c?.getBoundingClientRect(),g,p,v,b=A=>Math.max(h,Math.min(A,r.height-y-h));if(i&&i.width>0&&i.bottom>0&&i.top<r.height)if(i.right+h+t<=r.width-h)g=i.right+h,p=b(i.top),v="right";else if(i.left-h-t>=h)g=i.left-h-t,p=b(i.top),v="left";else{g=Math.max(h,Math.min(i.left,r.width-t-h));let A=i.bottom+h;p=A+y<=r.height-h?A:b(i.top-h-y),v=A+y<=r.height-h?"below":"above"}else g=(r.width-t)/2,p=b(72),v="top";let m=o.style,s={left:`${Math.round(g)}px`,top:`${Math.round(p)}px`,width:`${Math.round(t)}px`};m.left!==s.left&&(m.left=s.left),m.top!==s.top&&(m.top=s.top),m.width!==s.width&&(m.width=s.width);let E=c?.getAttribute("data-graview-view")??c?.getAttribute("data-graview-pick")??(c?"page":"");o.getAttribute("data-quick-ask-beside")!==E&&o.setAttribute("data-quick-ask-beside",E),o.getAttribute("data-quick-ask-side")!==v&&o.setAttribute("data-quick-ask-side",v)}var ke={position:"fixed",inset:"auto",margin:0,zIndex:B("popover"),boxSizing:"border-box",display:"grid",gap:10,padding:12,borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)",maxHeight:"calc(100dvh - 24px)",overflowY:"auto",fontSize:"0.875rem"},we={display:"inline-grid",placeItems:"center",width:28,height:28,padding:0,font:"inherit",fontSize:"0.875rem",lineHeight:1,color:"var(--graview-ink-muted)",background:"transparent",border:"1px solid transparent",borderRadius:6,boxShadow:"none",cursor:"pointer"},be={boxSizing:"border-box",width:"100%",height:36,padding:"0 10px",font:"inherit",fontSize:"max(1rem,16px)",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:8},ye={display:"flex",alignItems:"center",minHeight:30,padding:"4px 8px",borderRadius:6,cursor:"pointer",overflowWrap:"anywhere"},ve={display:"inline-flex",alignItems:"center",minHeight:30,padding:"2px 10px",font:"inherit",fontSize:"0.8125rem",borderRadius:8};export{Ie as QuickAskCard};
1
+ import{q as re}from"./chunk.ZSSOTIFL.js";import{a as j,b as C,c as J,d as te,e as ne,f as P,g as ie,k as ae,n as oe}from"./chunk.ER5ILWKY.js";import{a as X,b as Z,c as ee}from"./chunk.7YQYWOZR.js";import"./chunk.ACEYGWMO.js";import"./chunk.3PT55HXT.js";import{a as _}from"./chunk.D6RDTUX3.js";import"./chunk.UT6642FC.js";import"./chunk.TI4OSTQV.js";import"./chunk.P75TPZWT.js";import"./chunk.GZLYTPE7.js";import"./chunk.4B73P2WA.js";import"./chunk.IMRCAU4T.js";import{m as V}from"./chunk.BZ5VLPKB.js";import{F as ge,I as Q,Q as Y,Y as U}from"./chunk.6II4BONS.js";import{$ as N,gc as B}from"./chunk.F5BCCGFK.js";import{b as D}from"./chunk.AJZBJBMO.js";var a=D(ge(),1);var l=D(Y(),1),fe=new Set(["show","go","to","open","the","a","an","me"]),de=o=>o.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,""),O=(o,c)=>{let r=de(o);return c.every(t=>r.includes(t))},se=o=>o&&`${o[0].toLowerCase()}${o.slice(1)}`,I={act:4,show:3,place:3,record:4},he=360,h=12;function Ie({face:o,opening:c,close:r}){let t=_(),{setMenuAt:y}=U(),i=(0,a.useMemo)(()=>c.target??j(c.pointed??{about:[]},e=>t.store.graph.has(e)),[c,t.store]),g=(0,a.useMemo)(()=>te(t.store,i,t.places),[t.store,i,t.places]),[p,v]=(0,a.useState)(""),[b,m]=(0,a.useState)(-1),[s,E]=(0,a.useState)(null),[A,L]=(0,a.useState)(null),T=(0,a.useRef)(null),W=(0,a.useRef)(null),M=(0,a.useId)(),R=(0,a.useRef)(!0),{ghost:z}=Q(t.desk);(0,a.useEffect)(()=>()=>{R.current=!1;let e=t.desk.get().ghost;e?.onCard&&t.desk.setGhost({...e,onCard:!1})},[t.desk]);let $=(0,a.useMemo)(()=>{let e=P(t,i);return J(t.store,i,{principal:t.principal,places:t.places,...e.acts?{acts:e.acts}:{}})},[t,i]),G=(0,a.useMemo)(()=>{let e=C(i);if(e.length===0)return[];let n=new Set($.candidates.flatMap(d=>d.type==="act"?[d.mutation]:[]));return X(t.store,e,{principal:t.principal,...e.length===1?{focus:e[0]}:{}}).affordances.filter(d=>!d.destructive&&n.has(d.mutation))},[t.store,t.principal,i,$]),q=(0,a.useCallback)(()=>{let e=c.returnTo,n=le(T.current,i,o);r(),requestAnimationFrame(()=>{if(e?.isConnected&&!e.closest("[inert]"))return e.focus({preventScroll:!0});let d=(n&&n.tabIndex>=0?n:null)??document.querySelector("[data-graview-page-title]")??document.querySelector("main");d&&d.tabIndex<0&&!d.hasAttribute("tabindex")&&d.setAttribute("tabindex","-1"),d?.focus({preventScroll:!0})})},[c.returnTo,i,o,r]),K=(0,a.useCallback)(e=>{if(e.open.length>0){let n=T.current?.getBoundingClientRect();r(),y({x:n?.left??0,y:n?.top??0,on:e.args.id??C(i)[0],about:C(i)});return}try{ee(t.store,e,{}),Z(t.store,e,{},{author:t.principal}),q()}catch(n){L(n instanceof Error?n.message:String(n))}},[t.store,t.principal,r,q,y,i]),H=(0,a.useCallback)(async e=>{let n=e.trim();if(!n)return;let d=s?.result?.answer?{said:s.said,answer:s.result.answer}:void 0;v(""),m(-1),L(null),E({said:n,result:null});let S=await ne(t.ai,{...P(t,i,n),said:n,...d?{follows:d}:{}});t.desk.record(S.interaction),S.ghost&&S.ghost.proposals.length>0&&t.desk.setGhost({ghost:S.ghost,onCard:!0}),R.current&&E({said:n,result:S})},[s,t,i]),F=(0,a.useRef)(c.asked);(0,a.useEffect)(()=>{let e=F.current;F.current=void 0,e&&H(e)},[]);let k=(0,a.useMemo)(()=>{let e=p.trim();if(!e&&s)return[];let n=de(e).split(/\s+/).filter(f=>f&&!fe.has(f)),d=/^show\b/i.test(e),S=/^(go|open)\b/i.test(e),x=[];if(!d&&!S)for(let f of G.filter(u=>O(u.label,n)).slice(0,I.act))x.push({id:`act:${f.id}`,kind:"act",label:f.label,hint:f.open.length>0?"asks more":"do it",take:()=>K(f)});if(!S){let f=$.candidates.filter(u=>u.type==="panel");for(let u of f.filter(ue=>O(`show ${ue.label}`,n)).slice(0,I.show))x.push({id:u.id,kind:"show",label:`Show ${se(u.label)}`,hint:"a panel",take:()=>{r(),ie(t,{title:u.label,recipe:{...u.panel,title:u.label}})}})}if(!d){for(let f of t.places.filter(u=>O(u.title,n)).slice(0,I.place))x.push({id:`place:${f.as}`,kind:"place",label:`Go to ${f.title}`,take:()=>(r(),t.goTo.place(f.as))});if(n.length>0){let f=re(t.store,e.replace(/^(go to|open)\s+/i,""),{principal:t.principal,from:C(i),limit:I.record}).hits;for(let u of f)u.about==="node"&&x.push({id:`record:${u.id}`,kind:"record",label:u.label,hint:N(t.store.schema,u.kind),take:()=>(r(),t.goTo.record(u.id))})}}return e&&x.push({id:"ask",kind:"ask",label:e,take:()=>void H(e)}),x},[p,G,$,t,i,K,H,r,s]);(0,a.useEffect)(()=>m(p.trim()?0:-1),[p]),(0,a.useLayoutEffect)(()=>{let e=T.current;if(!e)return;if(typeof e.showPopover=="function")try{e.showPopover()}catch{}W.current?.focus({preventScroll:!0});let n=0,d=()=>{me(e,le(e,i,o)),n=requestAnimationFrame(d)};return d(),()=>cancelAnimationFrame(n)},[i,o]),(0,a.useEffect)(()=>{if(s)return;let e=n=>{n.target instanceof Node&&T.current?.contains(n.target)||r()};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[s,r]);let ce=e=>{if(e.key==="ArrowDown"&&k.length>0)e.preventDefault(),m(n=>Math.min(k.length-1,n+1));else if(e.key==="ArrowUp"&&k.length>0)e.preventDefault(),m(n=>Math.max(0,n-1));else if(e.key==="Enter"){e.preventDefault();let n=k[b];n?n.take():p.trim()&&H(p)}},w=s?.result??null,pe=k[b];return(0,l.jsxs)("section",{ref:T,popover:"manual",role:"region","aria-label":s?`Answer about ${g}`:`Ask about ${g}`,"data-testid":"quick-ask","data-quick-ask":s?"answer":"bar","data-quick-ask-face":o,"data-graview-offstage":"","data-graview-overlay":"",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),q())},onMouseDown:e=>e.stopPropagation(),style:ke,children:[(0,l.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[(0,l.jsxs)("p",{"data-testid":"quick-ask-about",style:{margin:0,flex:"1 1 auto",minWidth:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)",overflowWrap:"anywhere"},children:["About ",g]}),(0,l.jsx)("button",{type:"button","data-testid":"quick-ask-close","aria-label":"Close",title:"Close",onClick:q,style:we,children:(0,l.jsx)("span",{"aria-hidden":"true",children:"\u2715"})})]}),s?(0,l.jsxs)("div",{"data-testid":"quick-answer",style:{display:"grid",gap:8},children:[(0,l.jsxs)("p",{"data-testid":"quick-answer-asked",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",fontStyle:"italic",overflowWrap:"anywhere"},children:["\u201C",s.said,"\u201D"]}),(0,l.jsx)("p",{"data-testid":"quick-answer-text","aria-live":"polite",style:{margin:0,fontSize:"0.9375rem",lineHeight:1.45,color:w?.interaction.outcome==="failed"?"var(--graview-warn)":"var(--graview-ink)",overflowWrap:"anywhere"},children:w===null?"Thinking\u2026":w.interaction.outcome==="failed"?w.interaction.failed??"The AI could not answer that here.":w.answer??""}),w&&w.offers.length>0?(0,l.jsx)("ul",{"aria-label":"What acts on it",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:6},children:w.offers.map(e=>(0,l.jsx)("li",{children:(0,l.jsx)("button",{type:"button","data-testid":"quick-answer-offer","data-ai-offer":e.id,"data-ai-offer-type":e.type,onClick:()=>{ae(t,w,e,r).then(n=>{n&&R.current&&L(n)})},style:ve,children:e.type==="panel"?`Show ${se(e.label)}`:e.type==="place"?`Go to ${e.label}`:e.label})},e.id))}):null,z?.onCard&&z.ghost.interaction===w?.interaction.id?(0,l.jsx)(oe,{placement:"card"}):null]}):null,(0,l.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,l.jsx)("input",{ref:W,type:"text",role:"combobox","data-testid":"quick-ask-input","aria-label":s?`Ask a follow-up about ${g}`:`Ask about ${g}, or go somewhere`,"aria-expanded":k.length>0,"aria-controls":M,"aria-autocomplete":"list",...pe?{"aria-activedescendant":`${M}-${b}`}:{},autoComplete:"off",enterKeyHint:"go",placeholder:s?"Ask a follow-up\u2026":"Ask, or go to\u2026",value:p,readOnly:s!==null&&w===null,"aria-busy":s!==null&&w===null,onChange:e=>v(e.target.value),onKeyDown:ce,style:be}),(0,l.jsx)("div",{id:M,role:"listbox","aria-label":p.trim()?`What \u201C${p.trim()}\u201D finds here`:"What can be done here",hidden:k.length===0,style:{display:k.length===0?"none":"grid",gap:1,maxHeight:280,overflowY:"auto"},children:k.map((e,n)=>(0,l.jsx)("div",{id:`${M}-${n}`,role:"option","aria-selected":n===b,"data-testid":"quick-ask-option","data-quick-ask-kind":e.kind,"data-quick-ask-row":e.id,onMouseEnter:()=>m(n),onMouseDown:d=>d.preventDefault(),onClick:e.take,style:{...ye,background:n===b?"var(--graview-panel-muted)":"transparent",...e.kind==="ask"?{borderTop:"1px solid var(--graview-edge)",marginTop:2}:{}},children:e.kind==="ask"?(0,l.jsxs)("span",{children:["Ask: ",(0,l.jsxs)("span",{style:{fontWeight:600},children:["\u2018",e.label,"\u2019"]})]}):(0,l.jsxs)("span",{children:[e.label,e.hint?(0,l.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",e.hint]}):null]})},e.id))})]}),A?(0,l.jsx)("p",{role:"alert","data-testid":"quick-ask-refused",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-warn)"},children:A}):null,(0,l.jsx)("span",{style:V,"aria-live":"polite",children:k.length>0&&p.trim()?`${k.length} ${k.length===1?"way":"ways"} to go on`:""})]})}function le(o,c,r){let t=o?.closest("[data-graview-embed]")??document,y=c.on==="list"?[`aggregate:${c.kind}`,`kind:${c.kind}`]:c.on==="lens"&&c.kind?[`aggregate:${c.kind}`]:C(c);for(let i of y)for(let g of t.querySelectorAll(`[data-graview-view="${CSS.escape(i)}"], [data-graview-pick="${CSS.escape(i)}"]`)){if(o?.contains(g))continue;let p=g.getBoundingClientRect();if(p.width>0&&p.height>0)return g}return r==="pages"?t.querySelector("main [data-graview-page-title]")??t.querySelector("main h1"):null}function me(o,c){let r={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},t=Math.min(he,r.width-2*h),y=o.getBoundingClientRect().height,i=c?.getBoundingClientRect(),g,p,v,b=A=>Math.max(h,Math.min(A,r.height-y-h));if(i&&i.width>0&&i.bottom>0&&i.top<r.height)if(i.right+h+t<=r.width-h)g=i.right+h,p=b(i.top),v="right";else if(i.left-h-t>=h)g=i.left-h-t,p=b(i.top),v="left";else{g=Math.max(h,Math.min(i.left,r.width-t-h));let A=i.bottom+h;p=A+y<=r.height-h?A:b(i.top-h-y),v=A+y<=r.height-h?"below":"above"}else g=(r.width-t)/2,p=b(72),v="top";let m=o.style,s={left:`${Math.round(g)}px`,top:`${Math.round(p)}px`,width:`${Math.round(t)}px`};m.left!==s.left&&(m.left=s.left),m.top!==s.top&&(m.top=s.top),m.width!==s.width&&(m.width=s.width);let E=c?.getAttribute("data-graview-view")??c?.getAttribute("data-graview-pick")??(c?"page":"");o.getAttribute("data-quick-ask-beside")!==E&&o.setAttribute("data-quick-ask-beside",E),o.getAttribute("data-quick-ask-side")!==v&&o.setAttribute("data-quick-ask-side",v)}var ke={position:"fixed",inset:"auto",margin:0,zIndex:B("popover"),boxSizing:"border-box",display:"grid",gap:10,padding:12,borderRadius:12,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",color:"var(--graview-ink)",boxShadow:"var(--graview-lift-high)",maxHeight:"calc(100dvh - 24px)",overflowY:"auto",fontSize:"0.875rem"},we={display:"inline-grid",placeItems:"center",width:28,height:28,padding:0,font:"inherit",fontSize:"0.875rem",lineHeight:1,color:"var(--graview-ink-muted)",background:"transparent",border:"1px solid transparent",borderRadius:6,boxShadow:"none",cursor:"pointer"},be={boxSizing:"border-box",width:"100%",height:36,padding:"0 10px",font:"inherit",fontSize:"max(1rem,16px)",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:8},ye={display:"flex",alignItems:"center",minHeight:30,padding:"4px 8px",borderRadius:6,cursor:"pointer",overflowWrap:"anywhere"},ve={display:"inline-flex",alignItems:"center",minHeight:30,padding:"2px 10px",font:"inherit",fontSize:"0.8125rem",borderRadius:8};export{Ie as QuickAskCard};
@@ -1 +1 @@
1
- import{a as v,b as m,c as h}from"./chunk.MB7LKKUD.js";import"./chunk.PNVR3CXR.js";import{F as N,Q as u,ta as p,va as b}from"./chunk.ZTD2CNC3.js";import{fc as f}from"./chunk.X7W27IRI.js";import{b as c}from"./chunk.AJZBJBMO.js";var l=c(N(),1);var o=c(u(),1);function z({notices:r,anchor:n,board:a}){return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(w,{notices:r.filter(i=>i.kind==="banner"),at:"top",anchor:n,board:a}),(0,o.jsx)(w,{notices:r.filter(i=>i.kind==="toast"),at:"foot",anchor:n,board:a})]})}var y={info:"var(--graview-accent)",good:"var(--graview-good)",warn:"var(--graview-warn)",bad:"var(--graview-bad)"};function w({notices:r,at:n,anchor:a,board:i}){let s=(0,l.useRef)(null),t=r.length>0;return(0,l.useLayoutEffect)(()=>{let e=s.current;if(!t||!e)return;if(typeof e.showPopover=="function"&&!p(e))try{e.showPopover()}catch{}let d=()=>(n==="top"?h:m)(e,a());d(),n==="foot"&&i.hold?.(()=>e.matches(":hover, :focus-within"));let S=b(e);addEventListener("resize",d),addEventListener("scroll",d,!0),n==="foot"&&addEventListener(v,d);let g=typeof ResizeObserver=="function"?new ResizeObserver(d):null;return g?.observe(e),()=>{if(S(),g?.disconnect(),removeEventListener("resize",d),removeEventListener("scroll",d,!0),removeEventListener(v,d),e.isConnected&&p(e))try{e.hidePopover()}catch{}}},[t,n,a,i]),t?(0,o.jsx)("div",{ref:s,popover:"manual",role:"region","aria-label":n==="top"?"Notices":"Messages","data-testid":n==="top"?"notices-banners":"notices-toasts","data-graview-offstage":"",style:{position:"fixed",inset:"auto",margin:0,padding:0,border:"none",background:"none",overflow:"visible",zIndex:f("toast"),width:"max-content",height:"auto",maxWidth:"min(560px, calc(100vw - 32px))",display:"grid",gap:8,color:"var(--graview-ink)"},children:r.map(e=>(0,o.jsx)(T,{notice:e,board:i},e.id))}):null}function T({notice:r,board:n}){let a=r.tone??"info",i=[...r.action?[r.action]:[],...r.actions??[]],s=()=>n.dismiss(r.id);return(0,o.jsxs)("div",{"data-testid":"notice","data-kind":r.kind,"data-tone":a,style:{boxSizing:"border-box",display:"flex",flexWrap:"wrap",alignItems:"center",gap:"8px 12px",padding:r.kind==="banner"?"8px 10px 8px 14px":"10px 12px 10px 14px",borderRadius:"var(--graview-radius, 12px)",borderTop:"1px solid var(--graview-edge)",borderRight:"1px solid var(--graview-edge)",borderBottom:"1px solid var(--graview-edge)",borderLeft:`3px solid ${y[a]}`,background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",fontSize:"0.875rem",lineHeight:1.45},children:[(0,o.jsx)("span",{"aria-hidden":"true",style:{width:7,height:7,borderRadius:999,flex:"0 0 auto",background:y[a]}}),(0,o.jsx)("span",{style:{flex:"1 1 16rem",minWidth:0},children:r.sentence}),i.length>0?(0,o.jsx)("span",{style:{display:"flex",flexWrap:"wrap",gap:6},children:i.map((t,e)=>t.href!==void 0?(0,o.jsx)("a",{href:t.href,...t.target?{target:t.target,rel:"noopener"}:{},"data-testid":"notice-action",onClick:()=>{t.onSelect?.(),s()},style:{...x,...e===0?k:{}},children:t.label},t.label):(0,o.jsx)("button",{type:"button","data-testid":"notice-action",onClick:()=>{s(),t.onSelect?.()},style:{...x,...e===0?k:{}},children:t.label},t.label))}):null,(0,o.jsx)("button",{type:"button","data-testid":"notice-dismiss","aria-label":`Dismiss: ${r.sentence}`,title:"Dismiss",onClick:s,style:E,children:"\xD7"})]})}var x={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 12px",borderRadius:9,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)",font:"inherit",fontWeight:500,textDecoration:"none",cursor:"pointer"},k={background:"var(--graview-accent)",borderColor:"var(--graview-accent)",color:"var(--graview-accent-ink)"},E={minWidth:28,minHeight:28,padding:0,border:"none",background:"none",boxShadow:"none",color:"var(--graview-ink-muted)",fontSize:"1rem",cursor:"pointer"};export{z as NoticeStacks};
1
+ import{a as v,b as m,c as h}from"./chunk.MB7LKKUD.js";import"./chunk.BZ5VLPKB.js";import{F as N,Q as u,ta as p,va as b}from"./chunk.6II4BONS.js";import{gc as f}from"./chunk.F5BCCGFK.js";import{b as c}from"./chunk.AJZBJBMO.js";var l=c(N(),1);var o=c(u(),1);function z({notices:r,anchor:n,board:a}){return(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)(w,{notices:r.filter(i=>i.kind==="banner"),at:"top",anchor:n,board:a}),(0,o.jsx)(w,{notices:r.filter(i=>i.kind==="toast"),at:"foot",anchor:n,board:a})]})}var y={info:"var(--graview-accent)",good:"var(--graview-good)",warn:"var(--graview-warn)",bad:"var(--graview-bad)"};function w({notices:r,at:n,anchor:a,board:i}){let s=(0,l.useRef)(null),t=r.length>0;return(0,l.useLayoutEffect)(()=>{let e=s.current;if(!t||!e)return;if(typeof e.showPopover=="function"&&!p(e))try{e.showPopover()}catch{}let d=()=>(n==="top"?h:m)(e,a());d(),n==="foot"&&i.hold?.(()=>e.matches(":hover, :focus-within"));let S=b(e);addEventListener("resize",d),addEventListener("scroll",d,!0),n==="foot"&&addEventListener(v,d);let g=typeof ResizeObserver=="function"?new ResizeObserver(d):null;return g?.observe(e),()=>{if(S(),g?.disconnect(),removeEventListener("resize",d),removeEventListener("scroll",d,!0),removeEventListener(v,d),e.isConnected&&p(e))try{e.hidePopover()}catch{}}},[t,n,a,i]),t?(0,o.jsx)("div",{ref:s,popover:"manual",role:"region","aria-label":n==="top"?"Notices":"Messages","data-testid":n==="top"?"notices-banners":"notices-toasts","data-graview-offstage":"",style:{position:"fixed",inset:"auto",margin:0,padding:0,border:"none",background:"none",overflow:"visible",zIndex:f("toast"),width:"max-content",height:"auto",maxWidth:"min(560px, calc(100vw - 32px))",display:"grid",gap:8,color:"var(--graview-ink)"},children:r.map(e=>(0,o.jsx)(T,{notice:e,board:i},e.id))}):null}function T({notice:r,board:n}){let a=r.tone??"info",i=[...r.action?[r.action]:[],...r.actions??[]],s=()=>n.dismiss(r.id);return(0,o.jsxs)("div",{"data-testid":"notice","data-kind":r.kind,"data-tone":a,style:{boxSizing:"border-box",display:"flex",flexWrap:"wrap",alignItems:"center",gap:"8px 12px",padding:r.kind==="banner"?"8px 10px 8px 14px":"10px 12px 10px 14px",borderRadius:"var(--graview-radius, 12px)",borderTop:"1px solid var(--graview-edge)",borderRight:"1px solid var(--graview-edge)",borderBottom:"1px solid var(--graview-edge)",borderLeft:`3px solid ${y[a]}`,background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",fontSize:"0.875rem",lineHeight:1.45},children:[(0,o.jsx)("span",{"aria-hidden":"true",style:{width:7,height:7,borderRadius:999,flex:"0 0 auto",background:y[a]}}),(0,o.jsx)("span",{style:{flex:"1 1 16rem",minWidth:0},children:r.sentence}),i.length>0?(0,o.jsx)("span",{style:{display:"flex",flexWrap:"wrap",gap:6},children:i.map((t,e)=>t.href!==void 0?(0,o.jsx)("a",{href:t.href,...t.target?{target:t.target,rel:"noopener"}:{},"data-testid":"notice-action",onClick:()=>{t.onSelect?.(),s()},style:{...x,...e===0?k:{}},children:t.label},t.label):(0,o.jsx)("button",{type:"button","data-testid":"notice-action",onClick:()=>{s(),t.onSelect?.()},style:{...x,...e===0?k:{}},children:t.label},t.label))}):null,(0,o.jsx)("button",{type:"button","data-testid":"notice-dismiss","aria-label":`Dismiss: ${r.sentence}`,title:"Dismiss",onClick:s,style:E,children:"\xD7"})]})}var x={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 12px",borderRadius:9,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)",font:"inherit",fontWeight:500,textDecoration:"none",cursor:"pointer"},k={background:"var(--graview-accent)",borderColor:"var(--graview-accent)",color:"var(--graview-accent-ink)"},E={minWidth:28,minHeight:28,padding:0,border:"none",background:"none",boxShadow:"none",color:"var(--graview-ink-muted)",fontSize:"1rem",cursor:"pointer"};export{z as NoticeStacks};
@@ -1 +1 @@
1
- import{c as m}from"./chunk.FBY5IUGU.js";import{$ as p,X as c,Y as u,Z as f,da as h,ea as l}from"./chunk.X7W27IRI.js";function A(t,e){let n=t.schema.kinds,r="kind"in e?e.kind:void 0;if(r!==void 0&&!n.includes(r))return`There is no kind "${r}" in this app. Its kinds are: ${n.join(", ")}.`;if(e.on==="act"&&e.act!==void 0&&t.allMutations&&!t.allMutations().some(i=>i.name===e.act))return`There is no act "${e.act}" in this app.`;let o="record"in e?e.record:void 0;if(o!==void 0&&t.graph&&!t.graph.getNode(o))return`No record "${o}" is here to be told about.`;if(o!==void 0&&r!==void 0&&t.graph&&t.graph.getNode(o)?.kind!==r)return`\u201C${o}\u201D is not ${h(r)}.`;if(e.on==="changed"&&e.kind===void 0&&e.record===void 0)return"Say which kind, or which record, to be told about.";if(e.on==="reaches"){if(e.condition.trim()==="")return"Say what it should reach: a condition like done == true.";try{m(e.condition)}catch(i){return`The condition does not read: ${i instanceof Error?i.message:String(i)}.`}}}function a(t,e){let n=t.graph?.getNode(e);return n?c(t.schema.tryDefinition(n.kind),n):e}function g(t,e){let n=t.allMutations?.().find(r=>r.name===e);return n?u(n):f(e)}function M(t,e){let{when:n}=e,r=e.alsoMine?"anyone":"someone else",o=d=>l(t.schema.tryDefinition(d),d),i=d=>{let s=o(d);return`${/^[aeiou]/i.test(s)?"an":"a"} ${s}`};switch(n.on){case"act":{let d=n.act!==void 0?`\u201C${g(t,n.act)}\u201D`:"an act";return`When ${r} runs ${d}${n.record!==void 0?` on \u201C${a(t,n.record)}\u201D`:""}`}case"created":return`When ${r} adds ${i(n.kind)}`;case"changed":return n.record!==void 0?`When ${r} changes \u201C${a(t,n.record)}\u201D`:`When ${r} changes any of the ${p(t.schema,n.kind)}`;case"reaches":return`When ${n.record!==void 0?`\u201C${a(t,n.record)}\u201D`:i(n.kind)} reaches ${n.condition}${e.alsoMine?"":" (by someone else)"}`}}export{A as a,M as b};
1
+ import{c as m}from"./chunk.2B4WVCVV.js";import{$ as p,X as c,Y as u,Z as f,da as h,ea as l}from"./chunk.F5BCCGFK.js";function A(t,e){let n=t.schema.kinds,r="kind"in e?e.kind:void 0;if(r!==void 0&&!n.includes(r))return`There is no kind "${r}" in this app. Its kinds are: ${n.join(", ")}.`;if(e.on==="act"&&e.act!==void 0&&t.allMutations&&!t.allMutations().some(i=>i.name===e.act))return`There is no act "${e.act}" in this app.`;let o="record"in e?e.record:void 0;if(o!==void 0&&t.graph&&!t.graph.getNode(o))return`No record "${o}" is here to be told about.`;if(o!==void 0&&r!==void 0&&t.graph&&t.graph.getNode(o)?.kind!==r)return`\u201C${o}\u201D is not ${h(r)}.`;if(e.on==="changed"&&e.kind===void 0&&e.record===void 0)return"Say which kind, or which record, to be told about.";if(e.on==="reaches"){if(e.condition.trim()==="")return"Say what it should reach: a condition like done == true.";try{m(e.condition)}catch(i){return`The condition does not read: ${i instanceof Error?i.message:String(i)}.`}}}function a(t,e){let n=t.graph?.getNode(e);return n?c(t.schema.tryDefinition(n.kind),n):e}function g(t,e){let n=t.allMutations?.().find(r=>r.name===e);return n?u(n):f(e)}function M(t,e){let{when:n}=e,r=e.alsoMine?"anyone":"someone else",o=d=>l(t.schema.tryDefinition(d),d),i=d=>{let s=o(d);return`${/^[aeiou]/i.test(s)?"an":"a"} ${s}`};switch(n.on){case"act":{let d=n.act!==void 0?`\u201C${g(t,n.act)}\u201D`:"an act";return`When ${r} runs ${d}${n.record!==void 0?` on \u201C${a(t,n.record)}\u201D`:""}`}case"created":return`When ${r} adds ${i(n.kind)}`;case"changed":return n.record!==void 0?`When ${r} changes \u201C${a(t,n.record)}\u201D`:`When ${r} changes any of the ${p(t.schema,n.kind)}`;case"reaches":return`When ${n.record!==void 0?`\u201C${a(t,n.record)}\u201D`:i(n.kind)} reaches ${n.condition}${e.alsoMine?"":" (by someone else)"}`}}export{A as a,M as b};