graview 0.1.66 → 0.1.67
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.
- package/dist/preview/{chunk.LSN2IPAI.js → chunk.25QFDTCU.js} +1 -1
- package/dist/preview/{chunk.BFAFCVL4.js → chunk.264PB572.js} +1 -1
- package/dist/preview/chunk.2FHIINXG.js +2 -0
- package/dist/preview/{chunk.HSSIMVVM.js → chunk.2VUX54XH.js} +1 -1
- package/dist/preview/{chunk.CTASTRQN.js → chunk.35KMZHB7.js} +1 -1
- package/dist/preview/{chunk.OWFS2YDQ.js → chunk.37RFCHSS.js} +1 -1
- package/dist/preview/chunk.3ENPWZBG.js +1 -0
- package/dist/preview/{chunk.XMQG2PSM.js → chunk.3GNT5MKP.js} +1 -1
- package/dist/preview/{chunk.BXBEGMPO.js → chunk.3NSV3WKM.js} +2 -2
- package/dist/preview/chunk.3ZODN6BW.js +1 -0
- package/dist/preview/{chunk.OPTYYIGC.js → chunk.47XEJZ3O.js} +1 -1
- package/dist/preview/{chunk.5FNFRVTL.js → chunk.4EMKCKDB.js} +1 -1
- package/dist/preview/{chunk.B6JRTW3A.js → chunk.4UUJHLHR.js} +1 -1
- package/dist/preview/{chunk.FBILPNGH.js → chunk.4W57E7AX.js} +1 -1
- package/dist/preview/chunk.55G4IPOO.js +1 -0
- package/dist/preview/{chunk.72XP2ARZ.js → chunk.5AKZROMR.js} +1 -1
- package/dist/preview/chunk.5J6DVR7S.js +1 -0
- package/dist/preview/{chunk.FXT5CN32.js → chunk.5R744JGZ.js} +1 -1
- package/dist/preview/{chunk.NJRLJEJY.js → chunk.6KJGRM7A.js} +1 -1
- package/dist/preview/{chunk.4AC2QM7T.js → chunk.6N4PE3U5.js} +1 -1
- package/dist/preview/{chunk.LGRVEHXT.js → chunk.6NG76MDA.js} +2 -2
- package/dist/preview/{chunk.4FCFNAA4.js → chunk.6SJEZWH3.js} +1 -1
- package/dist/preview/{chunk.7VADSNPZ.js → chunk.6UQFV53C.js} +1 -1
- package/dist/preview/{chunk.WAB3L3ZI.js → chunk.6W6XMLSF.js} +1 -1
- package/dist/preview/{chunk.4JULYKGD.js → chunk.77C556NM.js} +1 -1
- package/dist/preview/{chunk.IGK7EZCX.js → chunk.7ARRVNUR.js} +1 -1
- package/dist/preview/{chunk.CBXS23YH.js → chunk.7BJRHPE3.js} +2 -2
- package/dist/preview/{chunk.ZQR2SN65.js → chunk.7S6ZRMW4.js} +1 -1
- package/dist/preview/{chunk.IAEHUSQQ.js → chunk.7UHPHEH5.js} +1 -1
- package/dist/preview/chunk.7WHQWLL6.js +1 -0
- package/dist/preview/{chunk.KACSYPEV.js → chunk.A4EZAGG7.js} +1 -1
- package/dist/preview/chunk.A5PSEU3W.js +25 -0
- package/dist/preview/{chunk.VKZIEZ5C.js → chunk.A7GVTE5Y.js} +2 -2
- package/dist/preview/{chunk.45JP6VGJ.js → chunk.AJMVRFYX.js} +2 -2
- package/dist/preview/{chunk.6P6NGZ6D.js → chunk.AKJS2NUM.js} +1 -1
- package/dist/preview/{chunk.CU2WCYMK.js → chunk.ARWO4WOV.js} +1 -1
- package/dist/preview/chunk.B5SJMCTT.js +7 -0
- package/dist/preview/{chunk.JXNVNFV4.js → chunk.B7KZBT27.js} +1 -1
- package/dist/preview/{chunk.E3UL4MCD.js → chunk.BDNQMKDG.js} +1 -1
- package/dist/preview/{chunk.YNEHJWJV.js → chunk.BKYZSV2Y.js} +1 -1
- package/dist/preview/{chunk.5BX66FBP.js → chunk.CKDCTFLU.js} +1 -1
- package/dist/preview/chunk.CTUJZ3IV.js +1 -0
- package/dist/preview/chunk.CY7FFKEZ.js +1 -0
- package/dist/preview/{chunk.3PBTN7RO.js → chunk.D4WJ7OM5.js} +1 -1
- package/dist/preview/{chunk.C2C3AXGI.js → chunk.D7NWMXSX.js} +3 -3
- package/dist/preview/chunk.DEKRFTRN.js +4 -0
- package/dist/preview/{chunk.E7EWNWAN.js → chunk.DKEIEH2D.js} +1 -1
- package/dist/preview/{chunk.I2737CPF.js → chunk.DWM7AR5Y.js} +1 -1
- package/dist/preview/{chunk.ANS2IEEV.js → chunk.DZMIYEHQ.js} +1 -1
- package/dist/preview/{chunk.BMENTGDC.js → chunk.E5PYNAYT.js} +2 -2
- package/dist/preview/chunk.EBKH3ILT.js +1 -0
- package/dist/preview/{chunk.DTCAUPLC.js → chunk.EFVSZKB5.js} +1 -1
- package/dist/preview/{chunk.QOS5T46W.js → chunk.EGPCVMDU.js} +1 -1
- package/dist/preview/{chunk.7ZKBYXUM.js → chunk.EJ2EZL2G.js} +1 -1
- package/dist/preview/{chunk.7VP6Y6D2.js → chunk.EP6Q32WT.js} +1 -1
- package/dist/preview/{chunk.OOSIKCOS.js → chunk.F464JKHZ.js} +1 -1
- package/dist/preview/{chunk.VGHO3VCB.js → chunk.FLJXYESX.js} +1 -1
- package/dist/preview/chunk.FOUBDGL3.js +1 -0
- package/dist/preview/chunk.FPHRAO3R.js +1 -0
- package/dist/preview/{chunk.4FDVINRJ.js → chunk.FRQSLWP4.js} +1 -1
- package/dist/preview/{chunk.2MHNPBHC.js → chunk.FVQKSN33.js} +1 -1
- package/dist/preview/{chunk.PDDIQ6PK.js → chunk.G3GFDVO2.js} +1 -1
- package/dist/preview/{chunk.ZD7T234N.js → chunk.G5GVT6JY.js} +1 -1
- package/dist/preview/{chunk.3L4JMM3P.js → chunk.GFLH7RCI.js} +1 -1
- package/dist/preview/{chunk.OO2OP76C.js → chunk.GMLONS5L.js} +1 -1
- package/dist/preview/{chunk.FK722SHI.js → chunk.GRFD42WM.js} +1 -1
- package/dist/preview/{chunk.2VR7YEJ6.js → chunk.GVT4UUQA.js} +1 -1
- package/dist/preview/{chunk.GME63ZHI.js → chunk.H3EGBDW2.js} +1 -1
- package/dist/preview/{chunk.DQFHIJFN.js → chunk.H6KIEDZN.js} +1 -1
- package/dist/preview/{chunk.5B5SRTUK.js → chunk.HAOB6O72.js} +1 -1
- package/dist/preview/chunk.HB5NWHFP.js +3 -0
- package/dist/preview/{chunk.6EHHMWPP.js → chunk.HJUZMOW2.js} +1 -1
- package/dist/preview/{chunk.6MQ5NT7S.js → chunk.HN4ZJ4B4.js} +1 -1
- package/dist/preview/chunk.HVBKI5ZO.js +1 -0
- package/dist/preview/chunk.I3SDKMQS.js +1 -0
- package/dist/preview/{chunk.QQAZQDRW.js → chunk.IAEGJDF3.js} +1 -1
- package/dist/preview/{chunk.QWNSHISU.js → chunk.IDALEKIW.js} +1 -1
- package/dist/preview/{chunk.QFHWG4LN.js → chunk.ILJDLBPJ.js} +1 -1
- package/dist/preview/{chunk.ZR2TP3BF.js → chunk.J2OPIS3H.js} +1 -1
- package/dist/preview/chunk.J5OLYVZ4.js +1 -0
- package/dist/preview/{chunk.LETAQTLJ.js → chunk.J6HF7IRQ.js} +1 -1
- package/dist/preview/{chunk.RWIN3POV.js → chunk.JEC5FDKX.js} +1 -1
- package/dist/preview/chunk.JKFVNQY7.js +1 -0
- package/dist/preview/{chunk.LLIURXFP.js → chunk.JQ2WNKDW.js} +1 -1
- package/dist/preview/{chunk.Z7Y3R3YR.js → chunk.JQ63N4MZ.js} +1 -1
- package/dist/preview/{chunk.DZFM6GSY.js → chunk.JU6UFWS3.js} +1 -1
- package/dist/preview/{chunk.INHS3KTK.js → chunk.JVB5KDSG.js} +1 -1
- package/dist/preview/{chunk.4U4D7WOI.js → chunk.KFT7JIEH.js} +1 -1
- package/dist/preview/chunk.KGMSSXZL.js +1 -0
- package/dist/preview/{chunk.5CXIEYHY.js → chunk.KX5ZBHMA.js} +2 -2
- package/dist/preview/{chunk.V7W5AQKL.js → chunk.LP2ZMAT2.js} +1 -1
- package/dist/preview/{chunk.BUVTUAB5.js → chunk.LRNFE3UK.js} +1 -1
- package/dist/preview/{chunk.PAGEGBUD.js → chunk.LVOTLGJB.js} +1 -1
- package/dist/preview/{chunk.QHMHUL6B.js → chunk.LYEGRY77.js} +1 -1
- package/dist/preview/{chunk.PPSYUOH7.js → chunk.M7KXQGQL.js} +1 -1
- package/dist/preview/{chunk.7BIPZTJB.js → chunk.MAKCZ6B6.js} +1 -1
- package/dist/preview/{chunk.EQ4OODGO.js → chunk.MJY4SLWA.js} +1 -1
- package/dist/preview/{chunk.EMFOMSMI.js → chunk.MSAYU25L.js} +1 -1
- package/dist/preview/{chunk.F4VB6Q2W.js → chunk.MUSMNKE4.js} +1 -1
- package/dist/preview/{chunk.BGAC3B7X.js → chunk.MW7R5G3C.js} +1 -1
- package/dist/preview/{chunk.AK7NGFEX.js → chunk.N4ZKZ4GM.js} +1 -1
- package/dist/preview/{chunk.TXHYGFIZ.js → chunk.NAXOXBOF.js} +1 -1
- package/dist/preview/{chunk.IWYMKGZZ.js → chunk.NKLPL7QD.js} +1 -1
- package/dist/preview/{chunk.QU52E5RG.js → chunk.NKYWIGC7.js} +1 -1
- package/dist/preview/{chunk.KSIEO5W7.js → chunk.NRURQGXV.js} +1 -1
- package/dist/preview/{chunk.FV72U33M.js → chunk.NSOPYIT4.js} +1 -1
- package/dist/preview/chunk.NXZL5CA2.js +1 -0
- package/dist/preview/{chunk.WVLEGCRI.js → chunk.O2OL6RQQ.js} +1 -1
- package/dist/preview/{chunk.TGEL6EUA.js → chunk.O5VFKVZS.js} +1 -1
- package/dist/preview/{chunk.CEVGND3Y.js → chunk.OCXY5DCD.js} +3 -3
- package/dist/preview/chunk.OHAO6KKH.js +1 -0
- package/dist/preview/{chunk.DSYP43NN.js → chunk.P2EKKKK2.js} +1 -1
- package/dist/preview/chunk.PSNMZBVS.js +1 -0
- package/dist/preview/{chunk.W53YNBSM.js → chunk.PZ7KY6XH.js} +1 -1
- package/dist/preview/{chunk.WSO7JOW5.js → chunk.QAM76AXV.js} +1 -1
- package/dist/preview/{chunk.PSQYDCVM.js → chunk.QF5QB5YR.js} +1 -1
- package/dist/preview/chunk.QNP5OR3P.js +93 -0
- package/dist/preview/{chunk.5LJVOLKR.js → chunk.QRQ5WPZI.js} +1 -1
- package/dist/preview/chunk.QWGWOEBZ.js +90 -0
- package/dist/preview/{chunk.OMT4QUZY.js → chunk.QXLJGHMC.js} +4 -4
- package/dist/preview/{chunk.J2MM6BUW.js → chunk.QZQCQWQG.js} +1 -1
- package/dist/preview/{chunk.6FQW6FNL.js → chunk.R6JBA7UK.js} +1 -1
- package/dist/preview/chunk.R7CRBRD4.js +1 -0
- package/dist/preview/chunk.RD2FSSLV.js +1 -0
- package/dist/preview/{chunk.OEIWIZCP.js → chunk.RG5G6YQD.js} +1 -1
- package/dist/preview/{chunk.PFQBCHQA.js → chunk.RJY7VJBH.js} +1 -1
- package/dist/preview/chunk.RR25BGWP.js +1 -0
- package/dist/preview/{chunk.BZ7QWHAE.js → chunk.RSQ432QN.js} +1 -1
- package/dist/preview/{chunk.MWGZKZD6.js → chunk.SFBHPYRD.js} +1 -1
- package/dist/preview/{chunk.FFOD5B4B.js → chunk.SJQPTDAT.js} +1 -1
- package/dist/preview/{chunk.OTV5XTBB.js → chunk.SNHKYH72.js} +1 -1
- package/dist/preview/{chunk.WSDJPXJD.js → chunk.SO6NT5K7.js} +1 -1
- package/dist/preview/{chunk.FDZE5LTJ.js → chunk.STPA7HBK.js} +2 -2
- package/dist/preview/{chunk.ONYBW45K.js → chunk.SY5ID44D.js} +1 -1
- package/dist/preview/chunk.T27QKVKP.js +1 -0
- package/dist/preview/{chunk.U6TEW6YD.js → chunk.T2OUHRAA.js} +1 -1
- package/dist/preview/chunk.T3WCRS6M.js +1 -0
- package/dist/preview/{chunk.QGIM2WAY.js → chunk.TI5FR2QQ.js} +1 -1
- package/dist/preview/{chunk.HOCD7KIR.js → chunk.TTSGCNPT.js} +1 -1
- package/dist/preview/{chunk.ES63XSIM.js → chunk.TXZQEJ5T.js} +1 -1
- package/dist/preview/{chunk.6LXIEM6B.js → chunk.UDHPMVC4.js} +1 -1
- package/dist/preview/{chunk.KBPJ7X7W.js → chunk.UGQYMN4J.js} +1 -1
- package/dist/preview/{chunk.M6ZN2KUO.js → chunk.UQIPEMJ5.js} +1 -1
- package/dist/preview/{chunk.FIFUMX5X.js → chunk.URQTF5SY.js} +1 -1
- package/dist/preview/{chunk.J7W2OFHY.js → chunk.UW52CMGJ.js} +1 -1
- package/dist/preview/{chunk.LINSO5PN.js → chunk.UWS4RMM3.js} +1 -1
- package/dist/preview/{chunk.QPF4KSAW.js → chunk.V7H4BUEB.js} +1 -1
- package/dist/preview/{chunk.KHRS2SKB.js → chunk.VBHV4TLG.js} +1 -1
- package/dist/preview/{chunk.U3ED7W2U.js → chunk.VBLQJVQ5.js} +1 -1
- package/dist/preview/{chunk.CVPMSPCH.js → chunk.WALVW3KJ.js} +1 -1
- package/dist/preview/{chunk.2KFZHUAC.js → chunk.WEMUKZKH.js} +1 -1
- package/dist/preview/{chunk.YIPXZUTT.js → chunk.X226YATK.js} +1 -1
- package/dist/preview/{chunk.GNEOSHQ6.js → chunk.XFLGSUYO.js} +1 -1
- package/dist/preview/{chunk.W4YDPHCQ.js → chunk.XSWSBTUO.js} +1 -1
- package/dist/preview/{chunk.OJY7VJ7D.js → chunk.YCD4JSXD.js} +1 -1
- package/dist/preview/{chunk.72ZCLEQC.js → chunk.YZPESGCP.js} +1 -1
- package/dist/preview/{chunk.XOE4KNP2.js → chunk.Z27NSSYL.js} +2 -2
- package/dist/preview/{chunk.DEHIR4EG.js → chunk.Z2XUVJAL.js} +1 -1
- package/dist/preview/{chunk.YXEO3Y65.js → chunk.Z3O2VZAJ.js} +1 -1
- package/dist/preview/{chunk.M2JCFNHJ.js → chunk.Z4TY44CD.js} +1 -1
- package/dist/preview/{chunk.EXYCN4WI.js → chunk.ZAPS4J6G.js} +1 -1
- package/dist/preview/{chunk.6TLXFMX2.js → chunk.ZAQ4IDX6.js} +1 -1
- package/dist/preview/{chunk.6HY6ZGEE.js → chunk.ZEZUKRC6.js} +1 -1
- package/dist/preview/{chunk.GEFXU4VO.js → chunk.ZG5VGP5U.js} +1 -1
- package/dist/preview/index.html +56 -56
- package/dist/preview/page.js +2 -2
- package/package.json +6 -6
- package/dist/preview/chunk.4WGYUYWU.js +0 -2
- package/dist/preview/chunk.5EMIWORS.js +0 -1
- package/dist/preview/chunk.6EVMXBNB.js +0 -1
- package/dist/preview/chunk.BCQWAFGD.js +0 -1
- package/dist/preview/chunk.BOCVLC7X.js +0 -1
- package/dist/preview/chunk.DPJNGFEZ.js +0 -4
- package/dist/preview/chunk.E4VRRWFP.js +0 -1
- package/dist/preview/chunk.EUAO4QNV.js +0 -1
- package/dist/preview/chunk.F7672TKJ.js +0 -1
- package/dist/preview/chunk.FA42HCPW.js +0 -1
- package/dist/preview/chunk.FBJAQPZ6.js +0 -1
- package/dist/preview/chunk.GAFMWOME.js +0 -1
- package/dist/preview/chunk.I4Z7HVRT.js +0 -1
- package/dist/preview/chunk.JMXXA4YG.js +0 -1
- package/dist/preview/chunk.JMYUQNXN.js +0 -6
- package/dist/preview/chunk.K6DFXDPZ.js +0 -1
- package/dist/preview/chunk.KF27ME27.js +0 -1
- package/dist/preview/chunk.L25DCT5S.js +0 -1
- package/dist/preview/chunk.MODLZJD4.js +0 -25
- package/dist/preview/chunk.OJGHDWI6.js +0 -1
- package/dist/preview/chunk.SSF47GUY.js +0 -1
- package/dist/preview/chunk.T6DPWW2K.js +0 -3
- package/dist/preview/chunk.TA36WBHK.js +0 -1
- package/dist/preview/chunk.TTGKX7LT.js +0 -1
- package/dist/preview/chunk.U3HERHAI.js +0 -88
- package/dist/preview/chunk.V5I4GZEY.js +0 -1
- package/dist/preview/chunk.VT2YGDK2.js +0 -1
- package/dist/preview/chunk.XK65Y2KX.js +0 -1
- package/dist/preview/chunk.Z274CL7J.js +0 -1
- package/dist/preview/chunk.ZBVYD4OX.js +0 -90
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as X}from"./chunk.
|
|
1
|
+
import{b as X}from"./chunk.Z27NSSYL.js";import"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{G as ce,W as Y,ea as N,ha as _}from"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import{Fb as R,ye as U}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as O}from"./chunk.AJZBJBMO.js";var u=O(ce(),1);function M(e,t,s=!1){if(e<t.at||e===t.at&&s)return e;let i=t.at+t.removed.length;return e>=i?e+t.inserted.length-t.removed.length:s?t.at:t.at+t.inserted.length}var G=e=>e>=55296&&e<=56319,V=e=>e>=56320&&e<=57343;function q(e,t,s){let i=Math.min(e.length,t.length),n=0,l=Math.max(0,Math.min(i,t.length-s));for(;n<l&&e.charCodeAt(e.length-1-n)===t.charCodeAt(t.length-1-n);)n++;let r=0;for(;r<i-n&&e.charCodeAt(r)===t.charCodeAt(r);)r++;return r>0&&G(e.charCodeAt(r-1))&&r--,n>0&&V(e.charCodeAt(e.length-n))&&n--,{at:r,removed:e.slice(r,e.length-n),inserted:t.slice(r,t.length-n)}}function B(e,t){let s=Math.min(e.length,t.length),i=0;for(;i<s&&e.charCodeAt(i)===t.charCodeAt(i);)i++;i>0&&G(e.charCodeAt(i-1))&&i--;let n=0;for(;n<s-i&&e.charCodeAt(e.length-1-n)===t.charCodeAt(t.length-1-n);)n++;return n>0&&V(e.charCodeAt(e.length-n))&&n--,{at:i,removed:e.slice(i,e.length-n),inserted:t.slice(i,t.length-n)}}function Z(e,t){let s=c=>c.at+c.removed.length;if(s(e)<t.at)return e;if(e.at>s(t))return{...e,at:e.at+t.inserted.length-t.removed.length};let i=Math.min(e.at,t.at),n=s(e)-s(t),l=e.removed.slice(0,t.at-i)+t.inserted+(n>0?e.removed.slice(e.removed.length-n):""),r=t.at<=e.at?t.inserted+e.inserted:e.inserted+t.inserted,d=B(l,r);return{...d,at:i+d.at}}function I(e,t){let s=M(e.start,t,!0),i=e.end===e.start?s:M(e.end,t);return{start:s,end:Math.max(s,i)}}function le(e,t){let{kind:s,id:i,session:n}=e.author,l=`${s}:${i??""}:`;return t.startsWith(l)&&(!n||t.slice(l.length)===n)}function J(e,t,s,i){let n=e.anchor,l=e.head;for(let d of s)if(!(d.seq<e.rev||le(d,t)))for(let c of d.primitives)c.op!=="splice-text"||c.id!==e.node||c.field!==e.field||(n=M(n,c),l=M(l,c));let r=d=>Math.max(0,Math.min(i,d));return{start:r(n),end:r(l)}}var W=(e,t,s)=>e.ops.length>0&&e.ops.every(i=>{let n=i.mutation?.args;return i.mutation?.name===R&&n?.node===t&&n.field===s}),de=(e,t,s,i)=>t.ops.length>0&&t.ops.every(n=>n.undoes!==void 0)&&e.batches().some(n=>t.ops.some(l=>l.undoes===n.id||l.undoes===n.ops[0]?.id)&&W(n,s,i)),Q=(e,t)=>e.author.kind==="human"&&(t?.id===void 0||e.author.id===void 0||e.author.id===t.id);function j(e,t,s,i){let n=e.batches();for(let l=n.length-1;l>=0;l--){let r=n[l];if(!(!Q(r,t)||r.undone||!W(r,s,i))&&e.canUndo(r.id).ok)return r.id}}function ee(e,t,s,i){let n=e.batches();for(let l=n.length-1;l>=0;l--){let r=n[l];if(Q(r,t)){if(W(r,s,i))return;if(de(e,r,s,i))return r.undone?void 0:r.id}}}var p=O(Y(),1);function ue(e){let{store:t}=N(),{live:s,nodeId:i,field:n}=e,[l,r]=(0,u.useState)(null);return(0,u.useEffect)(()=>{let d=!0;return s.typing(i,n).then(c=>d&&r(c)),()=>{d=!1}},[i,n]),l&&!t.collaborative(i,n)?(0,p.jsx)(p.Fragment,{children:e.writtenWhole}):(0,p.jsx)(pe,{...e,typing:l})}function pe({nodeId:e,field:t,label:s,markdown:i,live:n,onDone:l,typing:r}){let{store:d,principal:c}=N(),m=_(e),f=ne(m?.[t]),[T,ie]=(0,u.useState)(!1),v=(0,u.useRef)(null),D=(0,u.useRef)(f),E=(0,u.useRef)(!1),H=(0,u.useRef)(n);H.current=n;let K=()=>ne(d.graph.getNode(e)?.[t]),b=!r||d.permits({name:R,args:{node:e,field:t,at:0,remove:0,insert:""}},c).ok;(0,u.useEffect)(()=>v.current?.focus(),[T,r]);let C=(0,u.useRef)(void 0),k=()=>{C.current===void 0&&(C.current=setTimeout(()=>{C.current=void 0;let o=v.current;if(!o||o.ownerDocument.activeElement!==o)return;let a=o.selectionDirection==="backward";H.current.sayCaret({node:e,field:t,anchor:a?o.selectionEnd:o.selectionStart,head:a?o.selectionStart:o.selectionEnd,rev:d.log.length})},ge))};(0,u.useEffect)(()=>()=>{clearTimeout(C.current),H.current.sayCaret(null)},[]);let F=o=>{let a=v.current;if(a){if(a.value!==o){let h=I({start:a.selectionStart,end:a.selectionEnd},B(a.value,o)),g=a.selectionDirection??"none";a.value=o,a.setSelectionRange(h.start,h.end,g)}D.current=o}},$=()=>{let o=v.current;if(!o||!r||!b||E.current)return;let a=D.current,h=K(),g=q(a,o.value,o.selectionEnd);if(g.removed===""&&g.inserted==="")return F(h);let y=a===h?g:Z(g,B(a,h));try{r.splice(y.at,y.removed.length,y.inserted)}catch{}let w=K();if(o.value!==w){o.value=w;let S=Math.min(w.length,y.at+y.inserted.length);o.setSelectionRange(S,S)}D.current=w,k()};(0,u.useLayoutEffect)(()=>{E.current||F(f)},[f]);let ae=async o=>{if(!r)return;r.flush();for(let h=0;r.waiting()>0&&h<100;h++)await new Promise(g=>setTimeout(g,30));let a=o?ee(d,c,e,t):j(d,c,e,t);if(a)try{o?d.redo(a,{author:c}):d.undo(a,{author:c})}catch{}},x=o=>{r?.flush(),n.sayCaret(null),l(o)},A=(0,u.useRef)(void 0);(0,u.useEffect)(()=>()=>A.current?.(),[]);let se=o=>{A.current?.();let a=o.ownerDocument,h=v.current?.closest("[data-graview-live]"),g=P=>{let L=P.target;if(L instanceof Node&&h?.contains(L))return S();L instanceof Element&&L.closest(te)||(S(),x(!0))},y=()=>{let P=a.activeElement;P!==null&&P!==a.body||o.isConnected&&fe(o)||(S(),v.current?.focus({preventScroll:!0}))},w=new MutationObserver(y);w.observe(a.body,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["open","hidden"]}),a.addEventListener("focusin",g),a.addEventListener("toggle",y,!0);let S=()=>{A.current=void 0,w.disconnect(),a.removeEventListener("focusin",g),a.removeEventListener("toggle",y,!0)};A.current=S},z=[...n.who.values()].filter(o=>o.caret?.node===e&&o.caret.field===t);return(0,p.jsxs)("div",{style:{display:"grid",gap:8,minWidth:0},"data-graview-live":t,children:[T?(0,p.jsx)("div",{"data-graview-preview":t,"aria-label":`${s}, as it will read`,role:"region",style:ye,children:(0,p.jsx)(X,{text:f,markdown:!0})}):(0,p.jsxs)("div",{style:{position:"relative",minWidth:0},children:[(0,p.jsx)("textarea",{ref:v,"aria-label":s,"data-graview-field":t,defaultValue:f,readOnly:!r||!b,rows:3,onInput:$,onCompositionStart:()=>{E.current=!0},onCompositionEnd:()=>{E.current=!1,$()},onSelect:k,onFocus:k,onPointerDown:()=>r?.flush(),onKeyDown:o=>{let a=o.key;a==="Escape"?(o.preventDefault(),x(!1)):(o.metaKey||o.ctrlKey)&&!o.altKey&&a.toLowerCase()==="z"?(o.preventDefault(),ae(o.shiftKey)):(o.metaKey||o.ctrlKey)&&a==="Enter"?(o.preventDefault(),x(!1)):(a==="Enter"||me.has(a))&&r?.flush()},onKeyUp:k,onBlur:o=>{r?.flush(),n.sayCaret(null);let a=o.relatedTarget;if(a instanceof Node&&o.currentTarget.closest("[data-graview-live]")?.contains(a))return;let h=a instanceof Element?a.closest(te):null;if(h)return se(h);x(!0)},style:ve}),z.length>0?(0,p.jsx)(he,{text:f,others:z,area:v,log:d.log.all()}):null]}),(0,p.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",alignItems:"center",gap:8},children:[(0,p.jsx)("button",{type:"button",onClick:()=>x(!1),style:re,children:"Done"}),i?(0,p.jsx)("button",{type:"button","aria-pressed":T,onClick:()=>ie(!T),style:re,children:T?"Write":"Preview"}):null,(0,p.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},...b?{}:{"data-graview-readonly":""},children:b?"Saved as you type \xB7 Ctrl or \u2318 Z takes back your typing":`Read only: the ${s.toLowerCase()} can't be changed here now`})]})]})}function he({text:e,others:t,area:s,log:i}){let n=(0,u.useRef)(null);(0,u.useLayoutEffect)(()=>{let c=s.current,m=n.current;if(!c||!m)return;let f=()=>{m.scrollTop=c.scrollTop};return f(),c.addEventListener("scroll",f),()=>c.removeEventListener("scroll",f)});let l=t.map(c=>({one:c,at:J(c.caret,c.participant,i,e.length).end})).sort((c,m)=>c.at-m.at),r=[],d=0;for(let{one:c,at:m}of l){r.push(e.slice(d,m)),d=m;let f=U(c)||"Somebody";r.push((0,p.jsx)("span",{"data-graview-caret":c.participant,title:`${f} is typing here`,style:{borderLeft:`2px solid hsl(${Math.round(c.hue)} 55% 52%)`,marginLeft:-1,marginRight:-1,pointerEvents:"auto"}},c.participant))}return r.push(`${e.slice(d)}\u200B`),(0,p.jsx)("div",{ref:n,"aria-hidden":"true",style:we,children:r})}var te='[data-graview-overlay], dialog, [role="dialog"], [role="alertdialog"], [popover]',fe=e=>{if(e.hasAttribute("hidden")||e instanceof HTMLDialogElement&&!e.open)return!1;if(e.hasAttribute("popover"))try{return e.matches(":popover-open")}catch{}return!0},ge=120,ne=e=>typeof e=="string"?e:"",me=new Set(["ArrowLeft","ArrowRight","ArrowUp","ArrowDown","Home","End","PageUp","PageDown"]),ye={minHeight:"7.5em",padding:"8px 10px",border:"1px dashed var(--graview-edge-bright)",borderRadius:6,lineHeight:1.6,minWidth:0},re={font:"inherit",fontSize:"0.8125rem",minHeight:28,padding:"2px 12px"},oe={font:"inherit",lineHeight:1.5,width:"100%",boxSizing:"border-box",minHeight:"7.5em",padding:"8px 10px",borderRadius:6},ve={...oe,resize:"vertical",fieldSizing:"content",color:"var(--graview-ink)",background:"var(--graview-panel, transparent)",border:"1px solid var(--graview-edge-bright)"},we={...oe,position:"absolute",inset:0,height:"100%",border:"1px solid transparent",color:"transparent",whiteSpace:"pre-wrap",overflowWrap:"break-word",overflow:"hidden",pointerEvents:"none"};export{ue as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as m}from"./chunk.
|
|
1
|
+
import{c as m}from"./chunk.UGQYMN4J.js";import{ga as c,la as u,ma as p,oa as f,ta as h,ua as l}from"./chunk.ZEZUKRC6.js";function M(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 d(t,e){let n=t.graph?.getNode(e);return n?u(t.schema.tryDefinition(n.kind),n):e}function g(t,e){let n=t.allMutations?.().find(r=>r.name===e);return n?p(n):c(e)}function v(t,e){let{when:n}=e,r=e.alsoMine?"anyone":"someone else",o=s=>l(t.schema.tryDefinition(s),s),i=s=>{let a=o(s);return`${/^[aeiou]/i.test(a)?"an":"a"} ${a}`};switch(n.on){case"act":{let s=n.act!==void 0?`\u201C${g(t,n.act)}\u201D`:"an act";return`When ${r} runs ${s}${n.record!==void 0?` on \u201C${d(t,n.record)}\u201D`:""}`}case"created":return`When ${r} adds ${i(n.kind)}`;case"changed":return n.record!==void 0?`When ${r} changes \u201C${d(t,n.record)}\u201D`:`When ${r} changes any of the ${f(t.schema,n.kind)}`;case"reaches":return`When ${n.record!==void 0?`\u201C${d(t,n.record)}\u201D`:i(n.kind)} reaches ${n.condition}${e.alsoMine?"":" (by someone else)"}`}}export{M as a,v as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as cn,c as un}from"./chunk.QOS5T46W.js";import{j as x}from"./chunk.FFOD5B4B.js";import{b as Z}from"./chunk.Z7Y3R3YR.js";import{Bc as Q,Hd as dn,Lc as U,ec as on,fc as E,ga as H,gb as V,la as T,ma as K,na as en,nc as rn,oa as tn,oc as an,sa as sn,ta as J,ua as G}from"./chunk.6HY6ZGEE.js";function fn(){return{name:"insight",derive({store:n,nodes:d,kindSelection:t}){let f=[],v=l=>T(n.schema.tryDefinition(l.kind),l);for(let l of d){if([...n.schema.edgeKinds].reduce((c,w)=>c+n.graph.out(l.id,w).length+n.graph.in(l.id,w).length,0)===0){f.push({id:`insight:island:${l.id}`,text:`${v(l)} is connected to nothing yet`,nodeIds:[l.id]});continue}for(let c of n.schema.edgeKinds){let w=n.graph.in(l.id,c).length;if(w<3)continue;let s=[...n.graph.allEdges()].filter(a=>a.kind===c),e=s.length;e>=4&&w/e>.6&&f.push({id:`insight:load:${l.id}:${c}`,text:`${v(l)} ${vn(n,s,c,w)}`,nodeIds:[l.id]})}}for(let l of t){if(n.graph.nodesOfKind(l).length>0)continue;let A=n.schema.definitions.filter(c=>c.kind!==l).filter(c=>Object.values(c.edges).some(w=>w.to!=="*"&&w.to.includes(l))).map(c=>c.plural??`${c.kind}s`);A.length>0&&f.push({id:`insight:gap:${l}`,text:`Nothing here yet, though ${A.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:f}}}}function vn(n,d,t,f){let v=new Set(d.map(s=>n.graph.getNode(s.from)?.kind).filter(s=>s!==void 0)),l=v.size===1?[...v][0]:void 0,A=d.length,c=Z(n.schema,l??[...v][0]??"",t,"in"),w=s=>l?en(n.schema,l,s):String(s);return f===A?`${c}: all ${w(f)}`:`${c}: ${f} of the ${w(A)}`}function ln(n){let d=new Map;if(n.length===0)return d;let t=n.slice(-512),f=new Set;for(let l of t)l.undoes&&f.add(l.undoes);let v=n[n.length-1].seq;for(let l of t){if(!l.mutation||f.has(l.id))continue;let A=Math.pow(.5,(v-l.seq)/64);d.set(l.mutation.name,(d.get(l.mutation.name)??0)+A)}return d}function hn(n){return 8*(n/(n+1))}var bn=100;function gn(){return{name:"invariant",derive({store:n,selection:d,nodes:t,violations:f}){let v=s=>T(n.schema.tryDefinition(s.kind),s),l=new Set(d),A=f.filter(s=>s.nodeIds.some(e=>l.has(e))||s.subjectId!==void 0&&l.has(s.subjectId)),c=[],w=[];A.forEach((s,e)=>{w.push({id:`violation:${s.invariant}:${e}`,text:s.message,nodeIds:s.nodeIds}),s.repairs.forEach((a,h)=>{c.push({id:`invariant:${s.invariant}:${e}:${h}`,label:a.label,provider:"invariant",mutation:a.mutation,args:a.args??{},open:(a.missing??[]).map(m=>{let r=n.allMutations().find(g=>g.name===a.mutation);if(!r)return{name:m};let o=E(r.input).find(g=>g.name===m),k=o?o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id)):void 0;return{name:m,shape:x(r.input,m),...o?{kinds:o.kinds}:{},...k?{candidates:k}:{}}}),score:bn-h-(a.missing?.length??0),why:s.message,nodeIds:s.nodeIds,...s.subjectId===void 0?{}:{subjectId:s.subjectId}})})});for(let s of t){let e=n.allInvariants().filter(a=>{if(a.scope==="graph")return!1;let h=a.scope;return h.kind!==s.kind?!1:h.match?h.match(s):!0});e.length!==0&&(A.some(a=>a.subjectId===s.id||a.nodeIds.includes(s.id))||w.push({id:`holds:${s.id}`,text:`${v(s)} holds \u2014 nothing currently breaks ${e.length===1?"it":`any of its ${e.length} rules`}`,nodeIds:[s.id]}))}return{affordances:c,observations:w}}}}var X=40;function pn(){return{name:"schema",derive({store:n,selection:d,nodes:t,kindSelection:f,edgeSelection:v,principal:l}){let A=(e,a)=>l!==void 0&&!n.permits({name:e,args:a},l).ok,c=[];if(t.length===0&&v.length>0){for(let e of v){let a=n.graph.getNode(e.from),h=n.graph.getNode(e.to);if(!a||!h)continue;let m=un(n,e);m?.provisional&&c.push({id:`schema:edge:${Q}:${e.kind}:${e.from}:${e.to}`,label:"Keep this link",provider:"schema",mutation:Q,args:{kind:e.kind,from:e.from,to:e.to},open:[],score:64,why:cn(m),nodeIds:[e.from,e.to]});for(let r of n.allMutations()){let o=(r.connects??[]).includes(e.kind),k=(r.severs??[]).includes(e.kind);if(!o&&!k||r.derived?.relation!==void 0&&r.derived.kind!==a.kind)continue;let g={},$=[],j=E(r.input);for(let p of j){let S=p.kinds.includes("*")||p.kinds.includes(a.kind),P=p.kinds.includes("*")||p.kinds.includes(h.kind),y=S&&!j.some(I=>I!==p&&(I.kinds.includes(a.kind)||I.kinds.includes("*")));S&&!P?g[p.name]=e.from:P&&!S?g[p.name]=e.to:S&&P&&y?g[p.name]=e.from:$.push({name:p.name,kinds:p.kinds,candidates:[e.from,e.to],shape:x(r.input,p.name)})}for(let p of q(r.input,""))p in g||$.some(S=>S.name===p)||$.push({name:p,shape:x(r.input,p)});$.every(p=>p.optional===!0?!0:p.kinds!==void 0?(p.candidates?.length??0)>0:(p.candidates?.length??0)>0||p.shape!==void 0&&p.shape.type!=="unknown")&&(o&&!k&&$.length===0||c.push({id:`schema:edge:${r.name}:${e.kind}:${e.from}:${e.to}`,label:K(r),provider:"schema",mutation:r.name,args:g,open:$,...r.destructive?{destructive:!0}:{},score:(k?62:58)-$.length,why:`this line is "${Z(n.schema,n.graph.getNode(e.from)?.kind??"",e.kind,"out")}"`,nodeIds:[e.from,e.to]}))}}return{affordances:c}}if(t.length===0&&f.length>0){let e=new Set(f),a=[];for(let h of n.allMutations()){if(!(h.creates??[]).some(o=>e.has(o)))continue;let m=[];for(let o of E(h.input)){let k=o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id));m.push({name:o.name,kinds:o.kinds,candidates:k,shape:x(h.input,o.name),...o.optional?{optional:!0}:{}})}for(let o of q(h.input,""))m.some(k=>k.name===o)||m.push({name:o,shape:x(h.input,o)});if(!m.every(o=>o.optional===!0?!0:o.kinds!==void 0?(o.candidates?.length??0)>0:(o.candidates?.length??0)>0||o.shape!==void 0&&o.shape.type!=="unknown")&&!A(h.name,{})){let o=m.filter(k=>k.optional!==!0&&k.kinds!==void 0&&!k.kinds.includes("*")&&(k.candidates?.length??0)===0);if(o.length>0){let k=[...new Set(o.flatMap(g=>g.kinds??[]))].map(g=>J(G(n.schema.tryDefinition(g),g)));a.push({id:`schema:waits:${h.name}`,text:`"${h.title??h.name}" cannot begin until there is ${k.length===1?k[0]:`${k.slice(0,-1).join(", ")} and ${k[k.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${h.name}`,label:K(h),provider:"schema",mutation:h.name,args:{},open:m,score:X-m.length,why:`this makes ${(h.creates??[]).filter(o=>e.has(o)).map(o=>J(G(n.schema.tryDefinition(o),o))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:a}}if(t.length===0)return{};let w=new Set(t.map(e=>e.kind)),s=(e,a,h)=>{let m=[];for(let r of n.graph.allEdges()){if(!a.includes(r.kind))continue;let o=r.from===e?r.to:r.to===e?r.from:null;if(!o)continue;let k=n.graph.getNode(o);k&&(!h.includes("*")&&!h.includes(k.kind)||m.includes(o)||m.push(o))}return m};for(let e of n.allMutations()){let a=e.subject;if(!a||!(a.kinds==="*"?!0:[...w].every(u=>a.kinds.includes(u))))continue;let m=e.derived?.act;if((m==="archive"||m==="merge")&&t.some(u=>V(u))||m==="unarchive"&&!t.some(u=>V(u))||m==="leave-alone"&&t.every(u=>U(n,u.id))||m==="allow-tidying"&&!t.some(u=>U(n,u.id)))continue;let r=t.length===1?t[0].id:null,o=e.severs??[],k=e.connects??[];if(r&&o.length>0&&k.length===0&&s(r,o,["*"]).length===0)continue;let g=[];for(let u of E(e.input)){if(u.name===a.arg)continue;let p=u.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):u.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(P=>P.id));if(r&&k.length>0){let S=new Set(s(r,k,u.kinds));p=p.filter(P=>!S.has(P))}else r&&o.length>0&&(p=s(r,o,u.kinds));g.push({name:u.name,kinds:u.kinds,candidates:p.filter(S=>!d.includes(S)),shape:x(e.input,u.name),...u.optional?{optional:!0}:{}})}for(let u of q(e.input,a.arg))g.some(p=>p.name===u)||g.push({name:u,shape:x(e.input,u)});if(g.length===0&&r){let u=Sn(e.input,a.arg);if(u.length>0&&!wn(n,e.name,{[a.arg]:r}))for(let p of u){let S=E(e.input).find(P=>P.name===p);g.push({name:p,optional:!0,...S?{kinds:S.kinds}:{},shape:x(e.input,p)})}}if(!g.every(u=>u.optional===!0?!0:u.kinds!==void 0?(u.candidates?.length??0)>0:(u.candidates?.length??0)>0||u.shape!==void 0&&u.shape.type!=="unknown")&&!A(e.name,r?{[a.arg]:r}:{}))continue;let j=t.map(u=>({[a.arg]:u.id}));g.length===0&&!j.some(u=>n.wouldChange({name:e.name,args:u}))||c.push({id:`schema:${e.name}`,label:t.length>1?`${K(e)} (${t.length})`:K(e),provider:"schema",mutation:e.name,args:j[0]??{},open:g,...e.destructive?{destructive:!0}:{},...e.derived?.act==="archive"||e.derived?.act==="merge"||e.derived?.act==="leave-alone"||e.derived?.act==="allow-tidying"?{setsAside:!0}:{},...o.length>0||k.length>0?{ties:!0}:{},...t.length>1?{batch:j}:{},score:X-g.length,why:t.length>1?`all ${t.length} selected nodes are ${[...w].map(u=>tn(n.schema,u).toLowerCase()).join(" or ")}`:`this is ${J(G(n.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(u=>u.id)})}if(t.length===1){let e=t[0];for(let a of n.allMutations()){let h=a.subject,m=a.severs??[],r=a.connects??[];if(!h||m.length===0&&r.length===0)continue;let o=h.kinds==="*"?"*":h.kinds;if(o==="*"||o.includes(e.kind))continue;let k=E(a.input),g=k.find(y=>y.name!==h.arg&&(y.kinds.includes("*")||y.kinds.includes(e.kind)));if(!g)continue;let $=o,j=$.includes("*")?n.graph.allNodes().map(y=>y.id):$.flatMap(y=>n.graph.nodesOfKind(y).map(I=>I.id)),u=new Set(s(e.id,r.length>0?r:m,$)),p=r.length>0?j.filter(y=>!u.has(y)):j.filter(y=>u.has(y));if(p.length===0)continue;let S=[{name:h.arg,kinds:$,candidates:p,shape:x(a.input,h.arg)}];for(let y of k){if(y.name===g.name||y.name===h.arg)continue;let I=y.kinds.includes("*")?n.graph.allNodes().map(L=>L.id):y.kinds.flatMap(L=>n.graph.nodesOfKind(L).map(O=>O.id));S.push({name:y.name,kinds:y.kinds,candidates:I,shape:x(a.input,y.name),...y.optional?{optional:!0}:{}})}for(let y of q(a.input,g.name))y===h.arg||S.some(I=>I.name===y)||S.push({name:y,shape:x(a.input,y)});S.every(y=>y.optional===!0?!0:y.kinds!==void 0?(y.candidates?.length??0)>0:(y.candidates?.length??0)>0||y.shape!==void 0&&y.shape.type!=="unknown")&&c.push({id:`schema:tie:${a.name}:${e.id}`,label:a.fromTheOtherEnd??K(a),provider:"schema",mutation:a.name,args:{[g.name]:e.id},open:S,ties:!0,...a.destructive?{destructive:!0}:{},score:X-S.length+2,why:`${m.length>0?"this one is on":"this one could join"} ${S[0].candidates.length===1?"it":"one of these"}`,nodeIds:[e.id]})}}return{affordances:c}}}}function Sn(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&v.safeParse(void 0).success).map(([f])=>f):[]}function wn(n,d,t){try{return n.preview({name:d,args:t}),!0}catch{return!1}}function q(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&!v.safeParse(void 0).success).map(([f])=>f):[]}var An=70,$n=80,On=new Set(["id","kind"]);function mn(){return{name:"structure",derive({store:n,nodes:d}){let t=c=>T(n.schema.tryDefinition(c.kind),c);if(d.length<2)return{};let f=[],v=[],l=d.map(c=>c.id);for(let c of n.schema.edgeKinds){let w=In(d.map(e=>new Set([...n.graph.out(e.id,c).map(a=>a.id),...n.graph.in(e.id,c).map(a=>a.id)])));for(let e of w){let a=n.graph.getNode(e);a&&f.push({id:`shared:${c}:${e}`,text:`all ${d.length} share "${t(a)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]})}let s=new Map;for(let e of d)for(let a of[...n.graph.out(e.id,c),...n.graph.in(e.id,c)])s.set(a.id,(s.get(a.id)??0)+1);for(let[e,a]of s){if(a!==d.length-1||d.length<3||l.includes(e))continue;let h=n.graph.getNode(e);if(!h)continue;let m=d.find(r=>![...n.graph.out(r.id,c),...n.graph.in(r.id,c)].some(o=>o.id===e));if(m&&(f.push({id:`near-shared:${c}:${e}`,text:`all but "${t(m)}" share "${t(h)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]}),!(!n.schema.edgeAllowed(c,m.kind,h.kind)&&!n.schema.edgeAllowed(c,h.kind,m.kind))))for(let r of n.allMutations()){let o=r.subject;if(!o||o.kinds!=="*"&&!o.kinds.includes(m.kind)||(r.connects!==void 0||r.severs!==void 0)&&!(r.connects??[]).includes(c))continue;let g=Pn(r.input,h.kind);g&&v.push({id:`structure:join:${r.name}:${m.id}:${e}`,label:`${K(r)}: bring "${t(m)}" in line with the others`,provider:"structure",mutation:r.name,args:{[o.arg]:m.id,[g]:e},open:[],score:An,why:`every other selected node is connected to "${t(h)}"`,nodeIds:[m.id,e]})}}}let A=new Map;for(let c of d)A.set(c.kind,[...A.get(c.kind)??[],c]);for(let[c,w]of A){if(w.length<2)continue;let s=w,e=w.map(r=>r.id),a=A.size>1?`${c}:`:"",h=new Set;for(let r of s)for(let o of Object.keys(r))On.has(o)||h.add(o);let m=r=>n.schema.definitions.find(o=>o.kind===r);for(let r of[...h].sort()){let o=m(s[0].kind),k=sn(o,r),g=o?.display?.format?.[r],$=O=>{if(!g)return O;try{return String(g(JSON.parse(O)))}catch{return O}},j=s.map(O=>O[r]),u=new Map;if(j.forEach((O,R)=>{let D=JSON.stringify(O??null),M=u.get(D);M?M.push(s[R]):u.set(D,[s[R]])}),u.size===1){let O=[...u.keys()][0];if(O==="null")continue;f.push({id:`agree:${a}${r}`,text:`all ${s.length} share the ${k} ${$(O)}`,nodeIds:e});continue}if(s.length<3||u.size!==2)continue;let p=[...u.entries()].sort((O,R)=>R[1].length-O[1].length),[S,P]=p[0],[,y]=p[1];if(y.length!==1||S==="null")continue;let I=y[0],L=JSON.parse(S);f.push({id:`odd-one-out:${a}${r}`,text:`${P.length} share the ${k} ${$(S)}; "${t(I)}" does not`,nodeIds:e});for(let O of n.allMutations()){let R=O.subject;if(!R||R.kinds!=="*"&&!R.kinds.includes(I.kind))continue;let D=kn(O.input);if(!D||!(r in D))continue;let M={[R.arg]:I.id,[r]:L},C=!0;for(let[W,z]of Object.entries(D)){if(W in M||z.safeParse(void 0).success)continue;let B=I[W];if(B===void 0){C=!1;break}M[W]=B}!C||!O.input.safeParse(M).success||v.push({id:`structure:align:${O.name}:${r}:${I.id}`,label:`Align the ${k} of "${t(I)}" with the other ${P.length}`,provider:"structure",mutation:O.name,args:M,open:[],score:$n,why:`${P.length} of ${s.length} share the ${k} ${$(S)}`,nodeIds:e})}}}return{affordances:v,observations:f}}}}function In(n){if(n.length===0)return[];let[d,...t]=n;return[...d].filter(f=>t.every(v=>v.has(f))).sort()}function kn(n){return n.shape??null}function Pn(n,d){let t=kn(n);if(!t)return null;for(let[f]of Object.entries(t)){let v=on(t[f]);if(v&&(v.includes("*")||v.includes(d)))return f}return null}function jn(){return[gn(),mn(),pn(),fn()]}function Xn(n,d,t={}){let f=yn(),v=t.providers??jn(),l=d.map(i=>n.graph.getNode(i)).filter(i=>i!==void 0),A={store:n,selection:d,nodes:l,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:n.violations(t.context),context:t.context??{},principal:t.principal??{kind:"human"}},c=[],w=[];for(let i of v){let b=i.derive(A);c.push(...b.affordances??[]),w.push(...b.observations??[])}let s=new Map(n.allMutations().map(i=>[i.name,i]));c.forEach((i,b)=>{let N=i.open.length>1?s.get(i.mutation):void 0;N&&(c[b]={...i,open:an(i.open,rn(n.schema,N))})});let e=new Set(n.allMutations().filter(i=>i.pinned).map(i=>i.name)),a=new Set(t.pins?.pinned??[]),h=new Set(t.pins?.unpinned??[]),m=i=>a.has(i.mutation)?"user":e.has(i.mutation)&&!h.has(i.mutation)?"declared":void 0,r=i=>{let b=m(i);return b?{...i,pinned:b}:i},o=new Map;for(let[i,b]of ln(n.log.all()))o.set(i,hn(b));let k=i=>i.pinned==="user"?0:i.pinned==="declared"?1:2,g=i=>i.score+(o.get(i.mutation)??0),$=new Map(n.allMutations().map(i=>[i.name,i])),j=new Map,u=i=>{let b=$.get(i.mutation);if(!b)return[];let N=j.get(i.mutation);N||(N=E(b.input).map(F=>F.name),j.set(i.mutation,N));let _=[];for(let F of i.batch??[i.args])for(let Y of N){let nn=F[Y]??i.args[Y];typeof nn=="string"&&_.push(nn)}return _},p=t.focus,S=4,P=i=>i.open.length>0?1:0,y=i=>{if(p===void 0)return S;let b=u(i);return b.length>0?b.includes(p)?I(i,0):S:i.nodeIds.includes(p)||i.subjectId===p?I(i,1):S},I=(i,b)=>i.provider==="invariant"?b:2+P(i),L=i=>i.setsAside?1:0,O=Nn(c).map(r),R=new Map(O.map((i,b)=>[i,b])),D=O.sort((i,b)=>{let N=Number(i.destructive??!1)-Number(b.destructive??!1);if(N!==0)return N;let _=L(i)-L(b);if(_!==0)return _;let F=y(i)-y(b);return F!==0?F:y(i)<2?R.get(i)-R.get(b):+(b.provider==="invariant")-+(i.provider==="invariant")||k(i)-k(b)||g(b)-g(i)||i.id.localeCompare(b.id)}),M=t.principal??{kind:"human"},C=[],W=[];for(let i of D){let b=n.permits({name:i.mutation,args:{...i.args,...i.batch?.[0]??{}}},M);if(b.ok)C.push(i);else{let N=Rn(n,i,M);if(N==="done")continue;N?C.push(N):W.push({...i,refusal:b.refusal})}}let z=C.map((i,b)=>({...i,rank:b})),B=W.map((i,b)=>({...i,rank:C.length+b}));return{affordances:t.limit===void 0?z:z.slice(0,t.limit),withheld:B,observations:xn(w),ms:yn()-f}}function Nn(n){let d=new Map;for(let t of n){let f=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),v=d.get(f);(!v||t.score>v.score)&&d.set(f,t)}return[...d.values()]}function xn(n){let d=new Map;for(let t of n)d.set(t.text,t);return[...d.values()]}function yn(){return typeof performance<"u"?performance.now():Date.now()}function Yn(n,d,t={},f={}){let v=(d.batch??[d.args]).map(A=>({name:d.mutation,args:{...d.args,...A,...t}})),l=n.allMutations().find(A=>A.name===d.mutation);return n.applyAll(v,{...l?.describe?{}:{intent:d.label},...f.author?{author:f.author}:{}})}function ne(n,d,t={},f={}){try{return n.preview({name:d.mutation,args:{...d.args,...t}})}catch(v){throw f.pressed&&dn(v,f.pressed.author?.id),v}}function Rn(n,d,t){let f=n.allMutations().find(s=>s.name===d.mutation)?.subject,v=f!==void 0&&d.args[f.arg]===void 0,l=v?d.open.find(s=>s.name===f.arg):d.open.find(s=>s.name!==f?.arg&&s.candidates);if(!l?.candidates)return;let A=s=>n.permits({name:d.mutation,args:{...d.args,...d.batch?.[0]??{},[l.name]:s}},t).ok,c=l.candidates.filter(A),w=t.id===void 0?void 0:n.graph.getNode(t.id);if(c.length===0){let s=v?f.kinds:"*";return w!==void 0&&(s==="*"||s.includes(w.kind))&&A(w.id)?"done":void 0}return c.length===1&&c[0]===t.id?{...d,args:{...d.args,[l.name]:t.id},open:d.open.filter(s=>s!==l)}:{...d,open:d.open.map(s=>s===l?{...s,candidates:c}:s)}}export{Xn as a,Yn as b,ne as c};
|
|
1
|
+
import{b as cn,c as un}from"./chunk.EGPCVMDU.js";import{j as x}from"./chunk.SJQPTDAT.js";import{b as Z}from"./chunk.JQ63N4MZ.js";import{Bc as Q,Hd as dn,Lc as U,ec as on,fc as E,ga as H,gb as V,la as T,ma as K,na as en,nc as rn,oa as tn,oc as an,sa as sn,ta as J,ua as G}from"./chunk.ZEZUKRC6.js";function fn(){return{name:"insight",derive({store:n,nodes:d,kindSelection:t}){let f=[],v=l=>T(n.schema.tryDefinition(l.kind),l);for(let l of d){if([...n.schema.edgeKinds].reduce((c,w)=>c+n.graph.out(l.id,w).length+n.graph.in(l.id,w).length,0)===0){f.push({id:`insight:island:${l.id}`,text:`${v(l)} is connected to nothing yet`,nodeIds:[l.id]});continue}for(let c of n.schema.edgeKinds){let w=n.graph.in(l.id,c).length;if(w<3)continue;let s=[...n.graph.allEdges()].filter(a=>a.kind===c),e=s.length;e>=4&&w/e>.6&&f.push({id:`insight:load:${l.id}:${c}`,text:`${v(l)} ${vn(n,s,c,w)}`,nodeIds:[l.id]})}}for(let l of t){if(n.graph.nodesOfKind(l).length>0)continue;let A=n.schema.definitions.filter(c=>c.kind!==l).filter(c=>Object.values(c.edges).some(w=>w.to!=="*"&&w.to.includes(l))).map(c=>c.plural??`${c.kind}s`);A.length>0&&f.push({id:`insight:gap:${l}`,text:`Nothing here yet, though ${A.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:f}}}}function vn(n,d,t,f){let v=new Set(d.map(s=>n.graph.getNode(s.from)?.kind).filter(s=>s!==void 0)),l=v.size===1?[...v][0]:void 0,A=d.length,c=Z(n.schema,l??[...v][0]??"",t,"in"),w=s=>l?en(n.schema,l,s):String(s);return f===A?`${c}: all ${w(f)}`:`${c}: ${f} of the ${w(A)}`}function ln(n){let d=new Map;if(n.length===0)return d;let t=n.slice(-512),f=new Set;for(let l of t)l.undoes&&f.add(l.undoes);let v=n[n.length-1].seq;for(let l of t){if(!l.mutation||f.has(l.id))continue;let A=Math.pow(.5,(v-l.seq)/64);d.set(l.mutation.name,(d.get(l.mutation.name)??0)+A)}return d}function hn(n){return 8*(n/(n+1))}var bn=100;function gn(){return{name:"invariant",derive({store:n,selection:d,nodes:t,violations:f}){let v=s=>T(n.schema.tryDefinition(s.kind),s),l=new Set(d),A=f.filter(s=>s.nodeIds.some(e=>l.has(e))||s.subjectId!==void 0&&l.has(s.subjectId)),c=[],w=[];A.forEach((s,e)=>{w.push({id:`violation:${s.invariant}:${e}`,text:s.message,nodeIds:s.nodeIds}),s.repairs.forEach((a,h)=>{c.push({id:`invariant:${s.invariant}:${e}:${h}`,label:a.label,provider:"invariant",mutation:a.mutation,args:a.args??{},open:(a.missing??[]).map(m=>{let r=n.allMutations().find(g=>g.name===a.mutation);if(!r)return{name:m};let o=E(r.input).find(g=>g.name===m),k=o?o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id)):void 0;return{name:m,shape:x(r.input,m),...o?{kinds:o.kinds}:{},...k?{candidates:k}:{}}}),score:bn-h-(a.missing?.length??0),why:s.message,nodeIds:s.nodeIds,...s.subjectId===void 0?{}:{subjectId:s.subjectId}})})});for(let s of t){let e=n.allInvariants().filter(a=>{if(a.scope==="graph")return!1;let h=a.scope;return h.kind!==s.kind?!1:h.match?h.match(s):!0});e.length!==0&&(A.some(a=>a.subjectId===s.id||a.nodeIds.includes(s.id))||w.push({id:`holds:${s.id}`,text:`${v(s)} holds \u2014 nothing currently breaks ${e.length===1?"it":`any of its ${e.length} rules`}`,nodeIds:[s.id]}))}return{affordances:c,observations:w}}}}var X=40;function pn(){return{name:"schema",derive({store:n,selection:d,nodes:t,kindSelection:f,edgeSelection:v,principal:l}){let A=(e,a)=>l!==void 0&&!n.permits({name:e,args:a},l).ok,c=[];if(t.length===0&&v.length>0){for(let e of v){let a=n.graph.getNode(e.from),h=n.graph.getNode(e.to);if(!a||!h)continue;let m=un(n,e);m?.provisional&&c.push({id:`schema:edge:${Q}:${e.kind}:${e.from}:${e.to}`,label:"Keep this link",provider:"schema",mutation:Q,args:{kind:e.kind,from:e.from,to:e.to},open:[],score:64,why:cn(m),nodeIds:[e.from,e.to]});for(let r of n.allMutations()){let o=(r.connects??[]).includes(e.kind),k=(r.severs??[]).includes(e.kind);if(!o&&!k||r.derived?.relation!==void 0&&r.derived.kind!==a.kind)continue;let g={},$=[],j=E(r.input);for(let p of j){let S=p.kinds.includes("*")||p.kinds.includes(a.kind),P=p.kinds.includes("*")||p.kinds.includes(h.kind),y=S&&!j.some(I=>I!==p&&(I.kinds.includes(a.kind)||I.kinds.includes("*")));S&&!P?g[p.name]=e.from:P&&!S?g[p.name]=e.to:S&&P&&y?g[p.name]=e.from:$.push({name:p.name,kinds:p.kinds,candidates:[e.from,e.to],shape:x(r.input,p.name)})}for(let p of q(r.input,""))p in g||$.some(S=>S.name===p)||$.push({name:p,shape:x(r.input,p)});$.every(p=>p.optional===!0?!0:p.kinds!==void 0?(p.candidates?.length??0)>0:(p.candidates?.length??0)>0||p.shape!==void 0&&p.shape.type!=="unknown")&&(o&&!k&&$.length===0||c.push({id:`schema:edge:${r.name}:${e.kind}:${e.from}:${e.to}`,label:K(r),provider:"schema",mutation:r.name,args:g,open:$,...r.destructive?{destructive:!0}:{},score:(k?62:58)-$.length,why:`this line is "${Z(n.schema,n.graph.getNode(e.from)?.kind??"",e.kind,"out")}"`,nodeIds:[e.from,e.to]}))}}return{affordances:c}}if(t.length===0&&f.length>0){let e=new Set(f),a=[];for(let h of n.allMutations()){if(!(h.creates??[]).some(o=>e.has(o)))continue;let m=[];for(let o of E(h.input)){let k=o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id));m.push({name:o.name,kinds:o.kinds,candidates:k,shape:x(h.input,o.name),...o.optional?{optional:!0}:{}})}for(let o of q(h.input,""))m.some(k=>k.name===o)||m.push({name:o,shape:x(h.input,o)});if(!m.every(o=>o.optional===!0?!0:o.kinds!==void 0?(o.candidates?.length??0)>0:(o.candidates?.length??0)>0||o.shape!==void 0&&o.shape.type!=="unknown")&&!A(h.name,{})){let o=m.filter(k=>k.optional!==!0&&k.kinds!==void 0&&!k.kinds.includes("*")&&(k.candidates?.length??0)===0);if(o.length>0){let k=[...new Set(o.flatMap(g=>g.kinds??[]))].map(g=>J(G(n.schema.tryDefinition(g),g)));a.push({id:`schema:waits:${h.name}`,text:`"${h.title??h.name}" cannot begin until there is ${k.length===1?k[0]:`${k.slice(0,-1).join(", ")} and ${k[k.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${h.name}`,label:K(h),provider:"schema",mutation:h.name,args:{},open:m,score:X-m.length,why:`this makes ${(h.creates??[]).filter(o=>e.has(o)).map(o=>J(G(n.schema.tryDefinition(o),o))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:a}}if(t.length===0)return{};let w=new Set(t.map(e=>e.kind)),s=(e,a,h)=>{let m=[];for(let r of n.graph.allEdges()){if(!a.includes(r.kind))continue;let o=r.from===e?r.to:r.to===e?r.from:null;if(!o)continue;let k=n.graph.getNode(o);k&&(!h.includes("*")&&!h.includes(k.kind)||m.includes(o)||m.push(o))}return m};for(let e of n.allMutations()){let a=e.subject;if(!a||!(a.kinds==="*"?!0:[...w].every(u=>a.kinds.includes(u))))continue;let m=e.derived?.act;if((m==="archive"||m==="merge")&&t.some(u=>V(u))||m==="unarchive"&&!t.some(u=>V(u))||m==="leave-alone"&&t.every(u=>U(n,u.id))||m==="allow-tidying"&&!t.some(u=>U(n,u.id)))continue;let r=t.length===1?t[0].id:null,o=e.severs??[],k=e.connects??[];if(r&&o.length>0&&k.length===0&&s(r,o,["*"]).length===0)continue;let g=[];for(let u of E(e.input)){if(u.name===a.arg)continue;let p=u.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):u.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(P=>P.id));if(r&&k.length>0){let S=new Set(s(r,k,u.kinds));p=p.filter(P=>!S.has(P))}else r&&o.length>0&&(p=s(r,o,u.kinds));g.push({name:u.name,kinds:u.kinds,candidates:p.filter(S=>!d.includes(S)),shape:x(e.input,u.name),...u.optional?{optional:!0}:{}})}for(let u of q(e.input,a.arg))g.some(p=>p.name===u)||g.push({name:u,shape:x(e.input,u)});if(g.length===0&&r){let u=Sn(e.input,a.arg);if(u.length>0&&!wn(n,e.name,{[a.arg]:r}))for(let p of u){let S=E(e.input).find(P=>P.name===p);g.push({name:p,optional:!0,...S?{kinds:S.kinds}:{},shape:x(e.input,p)})}}if(!g.every(u=>u.optional===!0?!0:u.kinds!==void 0?(u.candidates?.length??0)>0:(u.candidates?.length??0)>0||u.shape!==void 0&&u.shape.type!=="unknown")&&!A(e.name,r?{[a.arg]:r}:{}))continue;let j=t.map(u=>({[a.arg]:u.id}));g.length===0&&!j.some(u=>n.wouldChange({name:e.name,args:u}))||c.push({id:`schema:${e.name}`,label:t.length>1?`${K(e)} (${t.length})`:K(e),provider:"schema",mutation:e.name,args:j[0]??{},open:g,...e.destructive?{destructive:!0}:{},...e.derived?.act==="archive"||e.derived?.act==="merge"||e.derived?.act==="leave-alone"||e.derived?.act==="allow-tidying"?{setsAside:!0}:{},...o.length>0||k.length>0?{ties:!0}:{},...t.length>1?{batch:j}:{},score:X-g.length,why:t.length>1?`all ${t.length} selected nodes are ${[...w].map(u=>tn(n.schema,u).toLowerCase()).join(" or ")}`:`this is ${J(G(n.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(u=>u.id)})}if(t.length===1){let e=t[0];for(let a of n.allMutations()){let h=a.subject,m=a.severs??[],r=a.connects??[];if(!h||m.length===0&&r.length===0)continue;let o=h.kinds==="*"?"*":h.kinds;if(o==="*"||o.includes(e.kind))continue;let k=E(a.input),g=k.find(y=>y.name!==h.arg&&(y.kinds.includes("*")||y.kinds.includes(e.kind)));if(!g)continue;let $=o,j=$.includes("*")?n.graph.allNodes().map(y=>y.id):$.flatMap(y=>n.graph.nodesOfKind(y).map(I=>I.id)),u=new Set(s(e.id,r.length>0?r:m,$)),p=r.length>0?j.filter(y=>!u.has(y)):j.filter(y=>u.has(y));if(p.length===0)continue;let S=[{name:h.arg,kinds:$,candidates:p,shape:x(a.input,h.arg)}];for(let y of k){if(y.name===g.name||y.name===h.arg)continue;let I=y.kinds.includes("*")?n.graph.allNodes().map(L=>L.id):y.kinds.flatMap(L=>n.graph.nodesOfKind(L).map(O=>O.id));S.push({name:y.name,kinds:y.kinds,candidates:I,shape:x(a.input,y.name),...y.optional?{optional:!0}:{}})}for(let y of q(a.input,g.name))y===h.arg||S.some(I=>I.name===y)||S.push({name:y,shape:x(a.input,y)});S.every(y=>y.optional===!0?!0:y.kinds!==void 0?(y.candidates?.length??0)>0:(y.candidates?.length??0)>0||y.shape!==void 0&&y.shape.type!=="unknown")&&c.push({id:`schema:tie:${a.name}:${e.id}`,label:a.fromTheOtherEnd??K(a),provider:"schema",mutation:a.name,args:{[g.name]:e.id},open:S,ties:!0,...a.destructive?{destructive:!0}:{},score:X-S.length+2,why:`${m.length>0?"this one is on":"this one could join"} ${S[0].candidates.length===1?"it":"one of these"}`,nodeIds:[e.id]})}}return{affordances:c}}}}function Sn(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&v.safeParse(void 0).success).map(([f])=>f):[]}function wn(n,d,t){try{return n.preview({name:d,args:t}),!0}catch{return!1}}function q(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&!v.safeParse(void 0).success).map(([f])=>f):[]}var An=70,$n=80,On=new Set(["id","kind"]);function mn(){return{name:"structure",derive({store:n,nodes:d}){let t=c=>T(n.schema.tryDefinition(c.kind),c);if(d.length<2)return{};let f=[],v=[],l=d.map(c=>c.id);for(let c of n.schema.edgeKinds){let w=In(d.map(e=>new Set([...n.graph.out(e.id,c).map(a=>a.id),...n.graph.in(e.id,c).map(a=>a.id)])));for(let e of w){let a=n.graph.getNode(e);a&&f.push({id:`shared:${c}:${e}`,text:`all ${d.length} share "${t(a)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]})}let s=new Map;for(let e of d)for(let a of[...n.graph.out(e.id,c),...n.graph.in(e.id,c)])s.set(a.id,(s.get(a.id)??0)+1);for(let[e,a]of s){if(a!==d.length-1||d.length<3||l.includes(e))continue;let h=n.graph.getNode(e);if(!h)continue;let m=d.find(r=>![...n.graph.out(r.id,c),...n.graph.in(r.id,c)].some(o=>o.id===e));if(m&&(f.push({id:`near-shared:${c}:${e}`,text:`all but "${t(m)}" share "${t(h)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]}),!(!n.schema.edgeAllowed(c,m.kind,h.kind)&&!n.schema.edgeAllowed(c,h.kind,m.kind))))for(let r of n.allMutations()){let o=r.subject;if(!o||o.kinds!=="*"&&!o.kinds.includes(m.kind)||(r.connects!==void 0||r.severs!==void 0)&&!(r.connects??[]).includes(c))continue;let g=Pn(r.input,h.kind);g&&v.push({id:`structure:join:${r.name}:${m.id}:${e}`,label:`${K(r)}: bring "${t(m)}" in line with the others`,provider:"structure",mutation:r.name,args:{[o.arg]:m.id,[g]:e},open:[],score:An,why:`every other selected node is connected to "${t(h)}"`,nodeIds:[m.id,e]})}}}let A=new Map;for(let c of d)A.set(c.kind,[...A.get(c.kind)??[],c]);for(let[c,w]of A){if(w.length<2)continue;let s=w,e=w.map(r=>r.id),a=A.size>1?`${c}:`:"",h=new Set;for(let r of s)for(let o of Object.keys(r))On.has(o)||h.add(o);let m=r=>n.schema.definitions.find(o=>o.kind===r);for(let r of[...h].sort()){let o=m(s[0].kind),k=sn(o,r),g=o?.display?.format?.[r],$=O=>{if(!g)return O;try{return String(g(JSON.parse(O)))}catch{return O}},j=s.map(O=>O[r]),u=new Map;if(j.forEach((O,R)=>{let D=JSON.stringify(O??null),M=u.get(D);M?M.push(s[R]):u.set(D,[s[R]])}),u.size===1){let O=[...u.keys()][0];if(O==="null")continue;f.push({id:`agree:${a}${r}`,text:`all ${s.length} share the ${k} ${$(O)}`,nodeIds:e});continue}if(s.length<3||u.size!==2)continue;let p=[...u.entries()].sort((O,R)=>R[1].length-O[1].length),[S,P]=p[0],[,y]=p[1];if(y.length!==1||S==="null")continue;let I=y[0],L=JSON.parse(S);f.push({id:`odd-one-out:${a}${r}`,text:`${P.length} share the ${k} ${$(S)}; "${t(I)}" does not`,nodeIds:e});for(let O of n.allMutations()){let R=O.subject;if(!R||R.kinds!=="*"&&!R.kinds.includes(I.kind))continue;let D=kn(O.input);if(!D||!(r in D))continue;let M={[R.arg]:I.id,[r]:L},C=!0;for(let[W,z]of Object.entries(D)){if(W in M||z.safeParse(void 0).success)continue;let B=I[W];if(B===void 0){C=!1;break}M[W]=B}!C||!O.input.safeParse(M).success||v.push({id:`structure:align:${O.name}:${r}:${I.id}`,label:`Align the ${k} of "${t(I)}" with the other ${P.length}`,provider:"structure",mutation:O.name,args:M,open:[],score:$n,why:`${P.length} of ${s.length} share the ${k} ${$(S)}`,nodeIds:e})}}}return{affordances:v,observations:f}}}}function In(n){if(n.length===0)return[];let[d,...t]=n;return[...d].filter(f=>t.every(v=>v.has(f))).sort()}function kn(n){return n.shape??null}function Pn(n,d){let t=kn(n);if(!t)return null;for(let[f]of Object.entries(t)){let v=on(t[f]);if(v&&(v.includes("*")||v.includes(d)))return f}return null}function jn(){return[gn(),mn(),pn(),fn()]}function Xn(n,d,t={}){let f=yn(),v=t.providers??jn(),l=d.map(i=>n.graph.getNode(i)).filter(i=>i!==void 0),A={store:n,selection:d,nodes:l,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:n.violations(t.context),context:t.context??{},principal:t.principal??{kind:"human"}},c=[],w=[];for(let i of v){let b=i.derive(A);c.push(...b.affordances??[]),w.push(...b.observations??[])}let s=new Map(n.allMutations().map(i=>[i.name,i]));c.forEach((i,b)=>{let N=i.open.length>1?s.get(i.mutation):void 0;N&&(c[b]={...i,open:an(i.open,rn(n.schema,N))})});let e=new Set(n.allMutations().filter(i=>i.pinned).map(i=>i.name)),a=new Set(t.pins?.pinned??[]),h=new Set(t.pins?.unpinned??[]),m=i=>a.has(i.mutation)?"user":e.has(i.mutation)&&!h.has(i.mutation)?"declared":void 0,r=i=>{let b=m(i);return b?{...i,pinned:b}:i},o=new Map;for(let[i,b]of ln(n.log.all()))o.set(i,hn(b));let k=i=>i.pinned==="user"?0:i.pinned==="declared"?1:2,g=i=>i.score+(o.get(i.mutation)??0),$=new Map(n.allMutations().map(i=>[i.name,i])),j=new Map,u=i=>{let b=$.get(i.mutation);if(!b)return[];let N=j.get(i.mutation);N||(N=E(b.input).map(F=>F.name),j.set(i.mutation,N));let _=[];for(let F of i.batch??[i.args])for(let Y of N){let nn=F[Y]??i.args[Y];typeof nn=="string"&&_.push(nn)}return _},p=t.focus,S=4,P=i=>i.open.length>0?1:0,y=i=>{if(p===void 0)return S;let b=u(i);return b.length>0?b.includes(p)?I(i,0):S:i.nodeIds.includes(p)||i.subjectId===p?I(i,1):S},I=(i,b)=>i.provider==="invariant"?b:2+P(i),L=i=>i.setsAside?1:0,O=Nn(c).map(r),R=new Map(O.map((i,b)=>[i,b])),D=O.sort((i,b)=>{let N=Number(i.destructive??!1)-Number(b.destructive??!1);if(N!==0)return N;let _=L(i)-L(b);if(_!==0)return _;let F=y(i)-y(b);return F!==0?F:y(i)<2?R.get(i)-R.get(b):+(b.provider==="invariant")-+(i.provider==="invariant")||k(i)-k(b)||g(b)-g(i)||i.id.localeCompare(b.id)}),M=t.principal??{kind:"human"},C=[],W=[];for(let i of D){let b=n.permits({name:i.mutation,args:{...i.args,...i.batch?.[0]??{}}},M);if(b.ok)C.push(i);else{let N=Rn(n,i,M);if(N==="done")continue;N?C.push(N):W.push({...i,refusal:b.refusal})}}let z=C.map((i,b)=>({...i,rank:b})),B=W.map((i,b)=>({...i,rank:C.length+b}));return{affordances:t.limit===void 0?z:z.slice(0,t.limit),withheld:B,observations:xn(w),ms:yn()-f}}function Nn(n){let d=new Map;for(let t of n){let f=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),v=d.get(f);(!v||t.score>v.score)&&d.set(f,t)}return[...d.values()]}function xn(n){let d=new Map;for(let t of n)d.set(t.text,t);return[...d.values()]}function yn(){return typeof performance<"u"?performance.now():Date.now()}function Yn(n,d,t={},f={}){let v=(d.batch??[d.args]).map(A=>({name:d.mutation,args:{...d.args,...A,...t}})),l=n.allMutations().find(A=>A.name===d.mutation);return n.applyAll(v,{...l?.describe?{}:{intent:d.label},...f.author?{author:f.author}:{}})}function ne(n,d,t={},f={}){try{return n.preview({name:d.mutation,args:{...d.args,...t}})}catch(v){throw f.pressed&&dn(v,f.pressed.author?.id),v}}function Rn(n,d,t){let f=n.allMutations().find(s=>s.name===d.mutation)?.subject,v=f!==void 0&&d.args[f.arg]===void 0,l=v?d.open.find(s=>s.name===f.arg):d.open.find(s=>s.name!==f?.arg&&s.candidates);if(!l?.candidates)return;let A=s=>n.permits({name:d.mutation,args:{...d.args,...d.batch?.[0]??{},[l.name]:s}},t).ok,c=l.candidates.filter(A),w=t.id===void 0?void 0:n.graph.getNode(t.id);if(c.length===0){let s=v?f.kinds:"*";return w!==void 0&&(s==="*"||s.includes(w.kind))&&A(w.id)?"done":void 0}return c.length===1&&c[0]===t.id?{...d,args:{...d.args,[l.name]:t.id},open:d.open.filter(s=>s!==l)}:{...d,open:d.open.map(s=>s===l?{...s,candidates:c}:s)}}export{Xn as a,Yn as b,ne as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{E as b,R as c,S as T,U as p,V as D}from"./chunk.
|
|
1
|
+
import{E as b,R as c,S as T,U as p,V as D}from"./chunk.ZEZUKRC6.js";var S=864e5,N=/^(\d{4})-(\d{2})-(\d{2})/,s=n=>String(n).padStart(2,"0"),g=n=>new Date(n).toISOString().slice(0,10),m=n=>Date.UTC(+n.slice(0,4),+n.slice(5,7)-1,+n.slice(8,10)),W=(n,e)=>g(m(n)+e*S),M=n=>new Date(m(n)).getUTCDay();function A(n,e,t){if(!(e>=1&&e<=12&&t>=1&&t<=31))return;let r=`${String(n).padStart(4,"0")}-${s(e)}-${s(t)}`;return g(m(r))===r?r:void 0}function O(n=new Date){let e=c();return e?p(n.getTime(),e):{day:`${n.getFullYear()}-${s(n.getMonth()+1)}-${s(n.getDate())}`,minutes:n.getHours()*60+n.getMinutes()}}var $=n=>/T\d\d:\d\d(:[\d.]+)?(Z|[+-]\d\d:?\d\d)$/.test(n);function f(n){if(typeof n!="string")return;if($(n)){let r=new Date(n);return Number.isNaN(r.getTime())?void 0:O(r)}let e=/^(\d{4})-(\d{2})-(\d{2})(?:[T ](\d{2}):(\d{2}))?/.exec(n);if(!e||!A(Number(e[1]),Number(e[2]),Number(e[3])))return;let t=n.slice(0,10);return e[4]===void 0?{day:t}:{day:t,minutes:Number(e[4])*60+Number(e[5])}}function x(n,e){if(!e.time)return n.day;let t=n.minutes??9*60;if(!e.instant)return`${n.day}T${s(Math.floor(t/60))}:${s(t%60)}`;let r=c(),[,i,a,d]=N.exec(n.day);return(r?new Date(D(n.day,t,r)):new Date(Number(i),Number(a)-1,Number(d),Math.floor(t/60),t%60)).toISOString().replace(/\.\d{3}Z$/,"Z")}function Z(n,e=new Date){let t=T(),r=t;try{r=new Intl.DateTimeFormat(n??b,{timeZoneName:"short",timeZone:t}).formatToParts(e).find(i=>i.type==="timeZoneName")?.value??t}catch{r=t}return{zone:t,short:r}}function z(n,e,t,r){let i=f(e);if(!i)return t;let a=n===void 0?void 0:f(n),d=t===void 0?void 0:f(t),o=u=>m(u.day)+(u.minutes??0)*6e4,l=(u,h)=>{let y=o(u)+h;return{day:g(y),...r.time?{minutes:Math.round(y%S/6e4)}:{}}};return a&&d?x(l(d,o(i)-o(a)),r):d&&o(d)>=o(i)?t:r.time?x(l(i,36e5),r):t}var _=/^(start|starts|startsAt|startsOn|startAt|begins|from|opens|checkIn)$/i,w=/^(end|ends|endsAt|endsOn|endAt|until|to|finish|finishes|closes|through|checkOut)$/i;function F(n,e={}){let t=(e.start&&n.includes(e.start)?e.start:void 0)??n.find(i=>_.test(i)),r=(e.end&&n.includes(e.end)?e.end:void 0)??n.find(i=>i!==t&&w.test(i));return t&&r?{start:t,end:r}:void 0}export{S as a,m as b,W as c,M as d,A as e,O as f,$ as g,f as h,x as i,Z as j,z as k,F as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as U,b as V,d as b,e as B,f as C,g as W}from"./chunk.
|
|
1
|
+
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as U,b as V,d as b,e as B,f as C,g as W}from"./chunk.NRURQGXV.js";import{a as p,b as T,c as S,e as _}from"./chunk.BBLIT7S7.js";import{a as J,b as h,e as A}from"./chunk.AKJS2NUM.js";import{b as z}from"./chunk.5AKZROMR.js";import{a as R}from"./chunk.SDO3U72B.js";import"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var Q=R(()=>(__graviewPreload(import.meta.url,["./chunk.RSMCTI2N.js","./chunk.AJZBJBMO.js"]),import("./chunk.UJPX3BUV.js")));function te(d,e){let f=d.ownerDocument,u=f.defaultView,t=f.createElement("iframe");t.setAttribute("sandbox",T),t.setAttribute("referrerpolicy","no-referrer"),t.setAttribute("allow",""),t.setAttribute("title",e.title??e.view),t.setAttribute("data-guest-view",e.view),t.setAttribute("aria-busy","true"),t.style.border="0",t.style.width="100%",t.style.display="block",t.src=e.url;let a={applied:0,refused:0,dropped:0},P=h(e.limits),i,y,o={applied:0,refused:0,dropped:0},v=()=>{if(!i)return;let r=i.stats;a.applied+=r.applied-o.applied,a.refused+=r.refused-o.refused,a.dropped+=r.dropped-o.dropped,o={...r}},O=W(u,()=>l(),"data"),g=()=>C(()=>e.theme?.()??b(d),e.brand,O),L="",l=()=>{i&&(L=JSON.stringify(g()),i.push())},k=B(f,()=>{i&&JSON.stringify(g())!==L&&l()}),n,w=!1,D=e.pictures?z(Q,({createGuestPictures:r})=>{n=r(u,{as:"data",view:`"${e.title??e.view}"`,pictures:e.pictures,...e.limits?{limits:e.limits}:{},...e.file?{file:e.file}:{},moved:()=>{i?.push(),G&&E()}}),w&&x()}):()=>{},G=!1,c,N=()=>{!G||n?.waiting()||(clearTimeout(c),t.removeAttribute("data-guest-view-failed"),t.removeAttribute("aria-busy"),t.setAttribute("data-guest-view-drawn",""))},E=()=>{clearTimeout(c),c=setTimeout(N,250)},F=setTimeout(()=>{i||(t.removeAttribute("aria-busy"),t.setAttribute("data-guest-view-failed","silent"))},e.limits?.readyMs??8e3),H=()=>{v(),i?.dispose(),y?.close(),i=void 0,y=void 0,o={applied:0,refused:0,dropped:0}},M=r=>{if(!(r.source===null||r.source!==t.contentWindow)){if(r.origin!==S||!P.message()){a.dropped+=1;return}if(!_(r.data)||r.data.protocol!==1){a.dropped+=1;return}if(e.pictures&&!n){w=!0;return}x()}},x=()=>{w=!1,H();let r=U(),m=new MessageChannel;y=m.port1;let I=A({store:e.store,principal:e.principal,view:e.view,nonce:r,send:s=>m.port1.postMessage(s),...e.input?{input:e.input}:{},...e.reads?{reads:e.reads}:{},...n?{hand:n.hand}:{},theme:g,...e.places?{places:()=>[...new Set(e.places().map(s=>s.as))],placesShown:e.places}:{},...e.onNavigatePlace?{onNavigatePlace:e.onNavigatePlace}:{},...e.onNavigate?{onNavigate:e.onNavigate}:{},...e.onArrive?{onArrive:e.onArrive}:e.goTo?{onArrive:s=>V(e.goTo(),s)}:{},...e.onLost?{onLost:e.onLost}:{},onSize:s=>{e.onSize?e.onSize(s):t.style.height=`${s}px`,N()},...e.limits?{limits:e.limits}:{},limiter:P});i=I,m.port1.onmessage=s=>{I.receive(s.data),v()};let j={graview:"host-hello",protocol:1,nonce:r,view:e.view};t.contentWindow.postMessage(j,"*",[m.port2]),l(),G=!0,E()};return u.addEventListener("message",M),d.appendChild(t),d.removeAttribute("aria-busy"),{iframe:t,update:l,get stats(){return v(),a},dispose(){H(),clearTimeout(F),clearTimeout(c),k(),O.dispose(),D(),n?.dispose(),u.removeEventListener("message",M),t.remove()}}}export{p as GUEST_PROTOCOL,T as GUEST_SANDBOX,S as OPAQUE_ORIGIN,A as createGuestHost,h as createGuestLimiter,te as mountGuestView,J as readAcross,b as readTheme};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{i as z,j as D,k as H}from"./chunk.
|
|
1
|
+
import{i as z,j as D,k as H}from"./chunk.AJMVRFYX.js";import{a as P,b as A,c as p,d as W}from"./chunk.Q355UPFG.js";import"./chunk.GMLONS5L.js";import"./chunk.6NG76MDA.js";import"./chunk.35KMZHB7.js";import"./chunk.IAEGJDF3.js";import"./chunk.YZPESGCP.js";import"./chunk.SY5ID44D.js";import"./chunk.GVT4UUQA.js";import"./chunk.5R744JGZ.js";import"./chunk.O2OL6RQQ.js";import"./chunk.J6HF7IRQ.js";import"./chunk.LRNFE3UK.js";import{a as C,b as O}from"./chunk.MB7LKKUD.js";import"./chunk.T2OUHRAA.js";import"./chunk.GRFD42WM.js";import"./chunk.EP6Q32WT.js";import"./chunk.QAM76AXV.js";import"./chunk.Z27NSSYL.js";import"./chunk.PZ7KY6XH.js";import"./chunk.WEMUKZKH.js";import"./chunk.T27QKVKP.js";import"./chunk.WVUJXDXZ.js";import"./chunk.DWM7AR5Y.js";import"./chunk.6KJGRM7A.js";import"./chunk.WALVW3KJ.js";import"./chunk.SNHKYH72.js";import"./chunk.UGQYMN4J.js";import"./chunk.RG5G6YQD.js";import"./chunk.MIE4TJRW.js";import"./chunk.QRQ5WPZI.js";import"./chunk.RD2FSSLV.js";import"./chunk.37RFCHSS.js";import"./chunk.SO6NT5K7.js";import"./chunk.MUSMNKE4.js";import"./chunk.SJQPTDAT.js";import"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{G as B,Va as k,W as L}from"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import{td as R}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as E}from"./chunk.AJZBJBMO.js";var r=E(B(),1);var s=E(L(),1);function M(c){let e=document.activeElement;if(e!==null&&e!==document.body&&e!==document.documentElement&&e.isConnected)return;let n=c??document,o=n.querySelector("main")??n.querySelector("[data-graview-page]")??null,t=n.querySelector("[data-graview-page-title]")??o?.querySelector("h1, h2")??o;t instanceof HTMLElement&&(t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1"),t.focus({preventScroll:!0}))}var I=1500;function N(c,e,n){let{store:o,principal:t}=c,l=z(o),g=(0,r.useMemo)(()=>P(o,t),[o,t,l]),w=(0,r.useRef)(n),[b,d]=(0,r.useState)(),[y,u]=(0,r.useState)("");(0,r.useEffect)(()=>{let a=A(o,t,w.current);w.current=o.batches().length,a&&(d({batch:a.batch,at:e,when:Date.now()}),u(""))},[o,t,l]),(0,r.useEffect)(()=>{d(a=>!a||a.at===e?a:Date.now()-a.when<I?{...a,at:e}:void 0)},[e]);let[x,i]=(0,r.useState)(null),v=(0,r.useCallback)(()=>{d(void 0),i(null)},[]),f=(0,r.useCallback)(()=>{i(null);try{let a=W(o,t);a&&u(`Took back \u201C${a.intent}\u201D`)}catch(a){i(a instanceof Error?a.message:String(a))}},[o,t]),S=g&&b?.batch===g.batch&&b.at===e?g:void 0;return{change:g,offered:S,close:v,takeBack:f,refused:x,said:y}}function ee({context:c,docked:e,at:n,since:o,compact:t=!1,className:l,size:g}){let{change:w,offered:b,close:d,takeBack:y,refused:u,said:x}=N(c,n,o),i=e?b:w,v=(0,r.useRef)(null),f=e&&(i!==void 0||u!==null);j(v,f),(0,r.useEffect)(()=>{if(!f)return;let m,h=()=>m=setTimeout(()=>v.current?.matches(":hover, :focus-within")?h():d(),1e4);return h(),()=>clearTimeout(m)},[f,i?.batch,u,d]);let S=x||(e&&i?p(i):""),a=e?{position:"fixed",inset:"auto",margin:0,padding:0,border:"none",background:"none",overflow:"visible",zIndex:R("toast"),width:"max-content",height:"auto",bottom:"calc(16px + env(safe-area-inset-bottom, 0px))",left:16,justifyItems:"start",color:"var(--graview-ink)",...f?{}:{display:"none"}}:{},T=i?(0,s.jsxs)("button",{type:"button","data-testid":"page-undo",title:`${p(i)} \u2014 \u2318Z or Ctrl+Z`,"aria-keyshortcuts":"Meta+Z Control+Z",onClick:m=>{let h=m.currentTarget.closest("[data-graview-face]");y(),requestAnimationFrame(()=>M(h))},...e?{style:U}:{className:H("graview-undo",l),...D(g),...t?{"data-compact":"","aria-label":p(i)}:{}},children:[(0,s.jsx)("span",{"aria-hidden":"true",children:"\u21B6"}),e?(0,s.jsx)("span",{style:K,children:p(i)}):(0,s.jsx)("span",{className:"graview-undo-words",children:t?"Undo":p(i)})]}):null;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{role:"status","aria-live":"polite",style:V,children:S}),(0,s.jsxs)("div",{ref:v,...e?{popover:"manual","data-graview-foot":"","data-graview-offstage":""}:{},"data-testid":e?"face-undo-dock":"page-undo-place",...e?{style:{...F,...a}}:{className:"graview-undo-place"},children:[e?null:(0,s.jsx)("style",{children:q}),e&&i?(0,s.jsxs)("div",{"data-testid":"page-undo-notice",style:Z,children:[T,(0,s.jsx)("button",{type:"button","data-testid":"page-undo-dismiss","aria-label":`Dismiss: ${p(i)}`,title:"Dismiss",onClick:m=>{let h=m.currentTarget.closest("[data-graview-face]");d(),requestAnimationFrame(()=>M(h))},style:$,children:"\xD7"})]}):T,u?(0,s.jsx)("span",{"data-testid":"page-undo-refused",role:"alert",className:"graview-undo-refused",...e?{style:{fontSize:"0.8125rem",lineHeight:1.4,color:"var(--graview-warn)",borderRadius:6,background:"var(--graview-float)",padding:"4px 8px"}}:{},children:u}):null]})]})}function j(c,e){(0,r.useLayoutEffect)(()=>{let n=c.current;if(!n||!e)return;if(typeof n.showPopover=="function"&&!k(n))try{n.showPopover()}catch{}let o=()=>n.parentElement?.closest("[data-embed-content]")??null,t=()=>{O(n,o()),dispatchEvent(new Event(C))};t(),addEventListener("resize",t),addEventListener("scroll",t,!0);let l=typeof ResizeObserver=="function"?new ResizeObserver(t):null;return l?.observe(n),()=>{if(l?.disconnect(),removeEventListener("resize",t),removeEventListener("scroll",t,!0),n.isConnected&&k(n))try{n.hidePopover()}catch{}dispatchEvent(new Event(C))}},[c,e])}var q=`:where(.graview-undo-place){display:grid;justify-items:end;gap:4px;max-width:100%;min-width:0}
|
|
2
2
|
:where(.graview-undo){box-sizing:border-box;display:inline-flex;align-items:center;gap:6px;min-height:var(--graview-control-height,36px);max-width:min(100%,var(--graview-undo-widest,18rem));min-width:0;padding:0 14px;border-radius:999px;border:1px solid var(--graview-edge);background:var(--graview-float);color:var(--graview-ink);font:inherit;font-size:.875rem;cursor:pointer}
|
|
3
3
|
:where(.graview-undo[data-size=sm]){--graview-control-height:30px}
|
|
4
4
|
:where(.graview-undo[data-compact]){padding:0 10px}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{$ as z,Ac as ne,Cb as H,Cc as te,Db as U,Dc as oe,Eb as X,Ec as I,Fb as Z,Fc as R,Gc as E,Jc as P,Kd as ie,L,Mc as N,R as G,U as F,Y as T,jc as Q,ob as Y,pb as v,ra as J,wc as O,yb as q,zc as ee}from"./chunk.6HY6ZGEE.js";import{j as y}from"./chunk.FQLNBIQ5.js";var re=e=>q(e).id??e.session;function j(e,i={}){let n=O(e),o=new Map,t=i.advisory===!0;for(let s of e){if(s.vote===void 0||s.withheld||n.has(s.id)||s.vote.advisory===!0!==t)continue;let a=t?s.vote.voter:re(s.author);if(a===void 0)continue;let r=o.get(s.vote.suggestion);r||o.set(s.vote.suggestion,r=new Map),s.vote.vote===null?r.delete(a):r.set(a,s.vote.vote)}return o}function se(e){let i=0,n=0;for(let o of e?.values()??[])o==="for"?i++:n++;return{for:i,against:n}}function he(e,i,n){let o=I(i)?R(i):void 0,t=i&&(o===void 0?re(i):void 0),s=o!==void 0?n?.get(o):t!==void 0?e?.get(t):void 0,a=se(n);return{...se(e),...s!==void 0?{mine:s}:{},...a.for+a.against>0?{advisory:a}:{}}}var V=(e,i)=>e.expiresAt!==void 0&&Date.parse(e.expiresAt)<=Date.parse(i),Se=(e,i,n)=>(e??[]).some(o=>o.suggestion===i&&(o.until===void 0||Date.parse(o.until)>Date.parse(n)));function ae(e,i=()=>!0,n={}){let o=O(e),t=Ae(e),s=n.now??new Date().toISOString(),a,r;return e.filter(d=>d.suggests&&!d.withheld&&!o.has(d.id)&&t.get(d.id)!=="all"&&!V(d,s)&&!Se(n.dismissed,d.id,s)).flatMap(({id:d,batch:u,suggests:l,suggestsSaid:c,intent:g,batchIntent:p,author:S,lineage:w,at:f,expiresAt:me})=>{let B=t.get(d),M=ve(l,c,g).filter(h=>!B?.has(h.at));if(M.length===0)return[];let _=M.map(h=>h.call),W=new Set;return JSON.stringify(_.map(h=>h.args),(h,D)=>(typeof D=="string"&&i(D)&&W.add(D),D)),[{id:d,batch:u,calls:_,intent:B?M.map(h=>h.intent).join("; "):g,...p!==void 0?{headline:p}:{},items:M,author:S,...w?{lineage:w}:{},at:f,expiresAt:me,about:[...W],tally:he((a??=j(e)).get(d),n.voter,(r??=j(e,{advisory:!0})).get(d))}]})}function ve(e,i,n){let o=i&&i.length===e.length?i:void 0;return e.map((t,s)=>({at:s,call:t,intent:o?.[s]??(e.length===1?n:t.name)}))}function Ae(e){let i=new Map;for(let o of e){let t=o.lineage?.suggestion;if(t===void 0)continue;let s=o.lineage.items,a=i.get(t);if(a!=="all")if(s===void 0)i.set(t,"all");else{let r=a??new Set;for(let d of s)r.add(d);i.set(t,r)}}let n=new Map(e.filter(o=>o.suggests&&i.has(o.id)).map(o=>[o.id,o.suggests.length]));for(let[o,t]of i)t!=="all"&&n.has(o)&&t.size>=n.get(o)&&i.set(o,"all");return i}var le=e=>JSON.stringify(e,(i,n)=>n&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).sort()):n);var we=/^(archive|unarchive|remove|leave-alone|allow-tidying)$/;function xe(e,i){let n=ie(e.name),o=i?.act(e.name),t=e.args??{},s=o?o.derived:Q(n),{id:a}=t;if(s&&typeof a=="string"){if(we.test(s.act))return[s.act,a];if(s.act==="merge")return["merge",...[a,t.into].sort()];if(s.relation)return[s.act,s.relation,a,t.to]}let r=o?.subject?.arg??"id",[d,u]=Object.keys(t).filter(l=>l!==r);return o?.connects?.length===1&&d&&!u&&i.has(t[r])&&i.has(t[d])?["connect",o.connects[0],t[r],t[d]]:[n,o?.creates?.length&&typeof a=="string"&&!i.has(a)?{...t,id:0}:t]}var A=(e,i)=>`\u2248${le(e.map(n=>xe(n,i)))}`,de=e=>`\u2248${le([["connect",e.kind,e.from,e.to]])}`;function ue(e,i,n,o){let t=C(e,n,o);return[i,...i.map(s=>[s])].map(s=>t.get(A(s,n))).find(Boolean)}function C(e,i,n){let o=O(e),t=new Map(e.map(r=>[r.id,r])),s=new Map;for(let[r,d]of Object.entries(n??{}))o.has(d.id)||s.set(r,d);let a=new Map;for(let r of e)r.lineage?.suggestion!==void 0&&r.lineage.items&&a.set(r.lineage.suggestion,[...a.get(r.lineage.suggestion)??[],...r.lineage.items]);for(let r of e){let d=!o.has(r.id)&&!r.withheld,u=r.author.kind==="human",l=r.undoes!==void 0&&d?t.get(r.undoes):void 0;if(l?.suggests&&l.author.kind===r.author.kind&&l.author.id===r.author.id)continue;let c=l?.mutation&&l.undoes===void 0&&(l.lineage||r.undoneLineage||u),g=l?.suggests?l.suggests.filter((p,S)=>!a.get(l.id)?.includes(S)):c?[l.mutation]:[];if(g.length>0)for(let p of[g,...g.map(S=>[S])])s.set(A(p,i),r);if(!(!d||!u||r.undoes!==void 0))for(let p of r.primitives)p.op==="remove-edge"?s.set(de(p.edge),r):p.op==="add-edge"&&s.delete(de(p.edge))}return s}function ge(e){return Object.fromEntries([...e].map(([i,n])=>[i,{id:n.id,at:n.at,author:n.author,...n.undoes!==void 0&&{undoes:n.undoes}}]))}function ce(e,i){return e.ops.length>0&&e.ops.every(n=>n.suggests!==void 0||n.undoes!==void 0&&i(n.undoes)?.suggests!==void 0)}var K=e=>[...e].length;function Oe(e){let i,n=0,o=0;for(let t of e.ops){let s=t.mutation?.name===Z&&t.withheld!==!0&&t.undoes===void 0?t.mutation.args:void 0;if(typeof s?.node!="string"||typeof s.field!="string"||i&&(i.node!==s.node||i.field!==s.field))return;i={node:s.node,field:s.field};for(let a of t.primitives)a.op==="splice-text"?(n+=K(a.inserted),o+=K(a.removed)):a.op==="patch-node"&&typeof a.after[s.field]=="string"&&(n+=K(a.after[s.field]))}return i&&{...i,inserted:n,removed:o}}function be(e,i,n){let o=n.getNode(e.node)?.kind,t=[...e.inserted>0||e.removed===0?[`+${e.inserted}`]:[],...e.removed>0?[`\u2212${e.removed}`]:[]];return`Wrote in ${J(o?i.tryDefinition(o):void 0,e.field)} (${t.join(" ")})`}var b=e=>JSON.stringify([e.kind,e.id??"",e.name??""]),ke=e=>e.ops.find(i=>i.lineage?.run!==void 0)?.lineage?.run;function Me(e,i=()=>{}){let n=[];for(let o of e){if(ce(o,i))continue;if(!P(o.author)){let l=Oe(o),c=n.at(-1),g=l&&c&&"batch"in c&&b(c.batch.author)===b(o.author)&&c.typed?.node===l.node&&c.typed.field===l.field?c.typed:void 0;g?n[n.length-1]={batch:o,typed:{...g,batches:[...g.batches,o],inserted:g.inserted+l.inserted,removed:g.removed+l.removed}}:n.push(l?{batch:o,typed:{batches:[o],...l}}:{batch:o});continue}let t=ke(o),s=b(o.author),a=t!==void 0?n.findIndex(l=>"digest"in l&&l.digest.run===t&&b(l.digest.author)===s):n.length-1,r=n[a],d=r!==void 0&&"digest"in r&&b(r.digest.author)===s&&r.digest.run===t?r.digest:void 0,u=[...d?.batches??[],o];d&&n.splice(a,1),n.push({digest:{author:o.author,batches:u,things:De(u),at:o.at,...t!==void 0?{run:t}:{}}})}return n}var De=e=>e.reduce((i,n)=>i+(n.undone?0:n.ops.length),0),Ie=e=>{let i=Date.parse(e);if(Number.isNaN(i))return!1;let{minutes:n}=F(i,G());return n<6*60||n>=21*60};function Re(e,i=T(new Date().toISOString())??L()){let n=T(e.at)??e.at.slice(0,10),t=e.run!==void 0&&n===i&&[e.at,...(e.batches??[]).map(a=>a.at)].every(Ie)?"overnight":n===i?"today":`on ${z(n)}`,s=e.things===1?"one thing":`${e.things} things`;return e.author?.id?.startsWith("workflow:")&&e.author.name?`${e.author.name}: ${s} ${t}`:`Tidied ${s} ${t}`}N.declined=ue;N.kept=(e,i,n)=>ge(C(e,i,n));var m=e=>e,x=(e,i)=>i===void 0?{}:{[e]:i};function tn(e,i,n){let o=y(e)?.store??e,t=m(o),s=ne(n.lineage);if(s===void 0)throw new v("A suggestion says what it is based on: { basis, confidence? }");let a=n.author??t.by;if(n.expiresAt!==void 0&&Number.isNaN(Date.parse(n.expiresAt)))throw new v(`A suggestion expires at a time: "${n.expiresAt}" is not one (an ISO time, like 2026-10-23T06:00:00Z).`);let r=t.actMeanings(),d=A(i,r),u=$(o).find(f=>A(f.calls,r)===d);if(u)return o.log.get(u.id);t.refuseDeclined(i,a);let l=t.rehearsal();l.suggesting=!0;let c=l.applying(i,{author:a,lineage:s,...x("via",n.via)});if(c.ops.length===0)return;let g=[...new Set(c.ops.flatMap(f=>f.described??[]))],p=c.ops.filter(f=>f.mutation!==null&&f.author===a),S=i.length>1&&p.length===i.length?p.map(f=>f.intent):void 0,w={id:t.nextId(),seq:o.log.length,batch:t.mintBatch("batch"),author:a,intent:c.ops.map(f=>f.intent).join("; "),...x("batchIntent",n.intent),mutation:null,primitives:[],reads:[],writes:[],...g.length>0?{described:g}:{},at:t.now(),...x("via",n.via),lineage:s,suggests:i,...x("suggestsSaid",S),...x("expiresAt",n.expiresAt)};return o.log.append(w),o.notify(Y,[w]),w}function $(e,i,n={}){let o=y(e),t=o?.store??e,s=i??o?.principal,a=(s!==void 0?t.seenBy(s):t).log.all();return ae(a,r=>t.graph.has(r),{now:m(t).now(),dismissed:n.dismissed,voter:s})}function pe(e,i,n){let o=y(e),t=o?.store??e,s=n??o?.principal??m(t).by;return i.calls.every(a=>t.permits(a,s).ok)}function fe(e,i,n,o={}){let t=y(e)?.store??e,s=o.author??m(t).by;k(t,i,s);let a=t.applyAll([{name:oe,args:{suggestion:i,vote:n}}],{...o,author:s});return n===null?a:{...a,voted:n}}function k(e,i,n){let o=$(e,n).find(s=>s.id===i),t=o?void 0:e.log.get(i);if(t?.suggests&&V(t,m(e).now()))throw new v(`That suggestion expired on ${t.expiresAt.slice(0,10)}.`);if(!o)throw new v("That suggestion is no longer waiting: it was accepted or declined, or it is not one you can see.");return o}function on(e,i,n={}){let o=y(e)?.store??e,{items:t,...s}=n,a=s.author??m(o).by,r=k(o,i,a),d=t===void 0?r.items:r.items.filter(g=>t.includes(g.at));if(t!==void 0&&(t.length===0||d.length!==new Set(t).size))throw new v("Name the changes to accept by their place among those still waiting in the suggestion.");let u={...r,calls:d.map(g=>g.call)};if(!pe(o,u,a))return fe(o,i,"for",{...s,author:a});let l=o.log.get(i)?.suggests?.length??d.length,c=d.length<l?{items:d.map(g=>g.at)}:{};return o.applyAll(u.calls,{...s,author:a,lineage:{...r.lineage,suggestion:i,...c}})}function sn(e,i,n={}){let o=y(e)?.store??e,t=n.author??m(o).by,s=k(o,i,t);if(!pe(o,s,t))return fe(o,i,"against",{...n,author:t});let a=ye(s)&&n.intent===void 0?{intent:`Declined ${$e(je(s))} proposal: ${s.intent}`}:{};return o.undo(s.batch,{...n,...a,author:t})}function rn(e,i,n={}){let o=y(e)?.store??e,t=n.author??m(o).by,s=k(o,i,t);if(s.author.kind!==t.kind||s.author.id!==t.id)throw new v("Only who made a suggestion withdraws it: a person declines it (declineSuggestion).");return o.undo(s.batch,{...n,author:t})}var Pe={kind:"system",id:"tidying",name:"Graview, tidying",automated:!0};E.op=(e,i,n,o,t,s)=>{let a=e,{suggestion:r,vote:d}=n.args,u=k(a,r,t),l=I(t)?R(t):void 0,c=d==="for"?`For: ${u.intent}`:d==="against"?`Against: ${u.intent}`:`Withdraws a vote on: ${u.intent}`;return{id:i.id,seq:a.log.length,batch:o,author:t,intent:c,mutation:n,primitives:[],reads:[],writes:[],...u.about.length>0?{described:u.about}:{},at:i.at,...s.via!==void 0?{via:s.via}:{},vote:{suggestion:r,vote:d,...l!==void 0?{advisory:!0,voter:l}:{}}}};E.accepting=(e,i)=>{let n=e,o=n.tidying?.autoAcceptAt;if(o===void 0||i.vote?.vote!=="for")return;let t=i.vote.suggestion,s=$(n).find(u=>u.id===t);if(!s)return;let r=[...j(n.log.all()).get(t)??[]].filter(([,u])=>u==="for").map(([u])=>u);if(r.length<o)return;let d=P(s.author)?s.author:Pe;return{calls:s.calls,author:d,lineage:{...s.lineage,suggestion:t,voters:r.slice(0,ee)}}};var ye=e=>e.lineage?.proposedBy!==void 0,je=e=>e.author.name??e.author.id??"Somebody",$e=e=>/s$/i.test(e)?`${e}'`:`${e}'s`;function an(e,i,n,o){let t=y(e)?.store??e,s=m(t).actMeanings(),a=A(n,s),r=$(t,i).find(u=>ye(u)&&A(u.calls,s)===a);if(r)return t.log.get(r.id);let d={calls:n.map(({name:u,args:l})=>({name:u,args:l})),...x("intent",o)};return t.applyAll([{name:te,args:d}],{author:i}).ops.find(u=>u.suggests!==void 0)}function dn(e,i,n){if(!e||!e.grants.some(t=>t.propose!==void 0))return[];let o=new Set(H(e,i,n));return n.filter(t=>!o.has(t)&&U(t).some(s=>X(e,i,t.name,s)))}export{be as a,Me as b,Re as c,tn as d,$ as e,pe as f,fe as g,on as h,sn as i,rn as j,ye as k,an as l,dn as m};
|
|
1
|
+
import{$ as z,Ac as ne,Cb as H,Cc as te,Db as U,Dc as oe,Eb as X,Ec as I,Fb as Z,Fc as R,Gc as E,Jc as P,Kd as ie,L,Mc as N,R as G,U as F,Y as T,jc as Q,ob as Y,pb as v,ra as J,wc as O,yb as q,zc as ee}from"./chunk.ZEZUKRC6.js";import{j as y}from"./chunk.FQLNBIQ5.js";var re=e=>q(e).id??e.session;function j(e,i={}){let n=O(e),o=new Map,t=i.advisory===!0;for(let s of e){if(s.vote===void 0||s.withheld||n.has(s.id)||s.vote.advisory===!0!==t)continue;let a=t?s.vote.voter:re(s.author);if(a===void 0)continue;let r=o.get(s.vote.suggestion);r||o.set(s.vote.suggestion,r=new Map),s.vote.vote===null?r.delete(a):r.set(a,s.vote.vote)}return o}function se(e){let i=0,n=0;for(let o of e?.values()??[])o==="for"?i++:n++;return{for:i,against:n}}function he(e,i,n){let o=I(i)?R(i):void 0,t=i&&(o===void 0?re(i):void 0),s=o!==void 0?n?.get(o):t!==void 0?e?.get(t):void 0,a=se(n);return{...se(e),...s!==void 0?{mine:s}:{},...a.for+a.against>0?{advisory:a}:{}}}var V=(e,i)=>e.expiresAt!==void 0&&Date.parse(e.expiresAt)<=Date.parse(i),Se=(e,i,n)=>(e??[]).some(o=>o.suggestion===i&&(o.until===void 0||Date.parse(o.until)>Date.parse(n)));function ae(e,i=()=>!0,n={}){let o=O(e),t=Ae(e),s=n.now??new Date().toISOString(),a,r;return e.filter(d=>d.suggests&&!d.withheld&&!o.has(d.id)&&t.get(d.id)!=="all"&&!V(d,s)&&!Se(n.dismissed,d.id,s)).flatMap(({id:d,batch:u,suggests:l,suggestsSaid:c,intent:g,batchIntent:p,author:S,lineage:w,at:f,expiresAt:me})=>{let B=t.get(d),M=ve(l,c,g).filter(h=>!B?.has(h.at));if(M.length===0)return[];let _=M.map(h=>h.call),W=new Set;return JSON.stringify(_.map(h=>h.args),(h,D)=>(typeof D=="string"&&i(D)&&W.add(D),D)),[{id:d,batch:u,calls:_,intent:B?M.map(h=>h.intent).join("; "):g,...p!==void 0?{headline:p}:{},items:M,author:S,...w?{lineage:w}:{},at:f,expiresAt:me,about:[...W],tally:he((a??=j(e)).get(d),n.voter,(r??=j(e,{advisory:!0})).get(d))}]})}function ve(e,i,n){let o=i&&i.length===e.length?i:void 0;return e.map((t,s)=>({at:s,call:t,intent:o?.[s]??(e.length===1?n:t.name)}))}function Ae(e){let i=new Map;for(let o of e){let t=o.lineage?.suggestion;if(t===void 0)continue;let s=o.lineage.items,a=i.get(t);if(a!=="all")if(s===void 0)i.set(t,"all");else{let r=a??new Set;for(let d of s)r.add(d);i.set(t,r)}}let n=new Map(e.filter(o=>o.suggests&&i.has(o.id)).map(o=>[o.id,o.suggests.length]));for(let[o,t]of i)t!=="all"&&n.has(o)&&t.size>=n.get(o)&&i.set(o,"all");return i}var le=e=>JSON.stringify(e,(i,n)=>n&&typeof n=="object"&&!Array.isArray(n)?Object.fromEntries(Object.entries(n).sort()):n);var we=/^(archive|unarchive|remove|leave-alone|allow-tidying)$/;function xe(e,i){let n=ie(e.name),o=i?.act(e.name),t=e.args??{},s=o?o.derived:Q(n),{id:a}=t;if(s&&typeof a=="string"){if(we.test(s.act))return[s.act,a];if(s.act==="merge")return["merge",...[a,t.into].sort()];if(s.relation)return[s.act,s.relation,a,t.to]}let r=o?.subject?.arg??"id",[d,u]=Object.keys(t).filter(l=>l!==r);return o?.connects?.length===1&&d&&!u&&i.has(t[r])&&i.has(t[d])?["connect",o.connects[0],t[r],t[d]]:[n,o?.creates?.length&&typeof a=="string"&&!i.has(a)?{...t,id:0}:t]}var A=(e,i)=>`\u2248${le(e.map(n=>xe(n,i)))}`,de=e=>`\u2248${le([["connect",e.kind,e.from,e.to]])}`;function ue(e,i,n,o){let t=C(e,n,o);return[i,...i.map(s=>[s])].map(s=>t.get(A(s,n))).find(Boolean)}function C(e,i,n){let o=O(e),t=new Map(e.map(r=>[r.id,r])),s=new Map;for(let[r,d]of Object.entries(n??{}))o.has(d.id)||s.set(r,d);let a=new Map;for(let r of e)r.lineage?.suggestion!==void 0&&r.lineage.items&&a.set(r.lineage.suggestion,[...a.get(r.lineage.suggestion)??[],...r.lineage.items]);for(let r of e){let d=!o.has(r.id)&&!r.withheld,u=r.author.kind==="human",l=r.undoes!==void 0&&d?t.get(r.undoes):void 0;if(l?.suggests&&l.author.kind===r.author.kind&&l.author.id===r.author.id)continue;let c=l?.mutation&&l.undoes===void 0&&(l.lineage||r.undoneLineage||u),g=l?.suggests?l.suggests.filter((p,S)=>!a.get(l.id)?.includes(S)):c?[l.mutation]:[];if(g.length>0)for(let p of[g,...g.map(S=>[S])])s.set(A(p,i),r);if(!(!d||!u||r.undoes!==void 0))for(let p of r.primitives)p.op==="remove-edge"?s.set(de(p.edge),r):p.op==="add-edge"&&s.delete(de(p.edge))}return s}function ge(e){return Object.fromEntries([...e].map(([i,n])=>[i,{id:n.id,at:n.at,author:n.author,...n.undoes!==void 0&&{undoes:n.undoes}}]))}function ce(e,i){return e.ops.length>0&&e.ops.every(n=>n.suggests!==void 0||n.undoes!==void 0&&i(n.undoes)?.suggests!==void 0)}var K=e=>[...e].length;function Oe(e){let i,n=0,o=0;for(let t of e.ops){let s=t.mutation?.name===Z&&t.withheld!==!0&&t.undoes===void 0?t.mutation.args:void 0;if(typeof s?.node!="string"||typeof s.field!="string"||i&&(i.node!==s.node||i.field!==s.field))return;i={node:s.node,field:s.field};for(let a of t.primitives)a.op==="splice-text"?(n+=K(a.inserted),o+=K(a.removed)):a.op==="patch-node"&&typeof a.after[s.field]=="string"&&(n+=K(a.after[s.field]))}return i&&{...i,inserted:n,removed:o}}function be(e,i,n){let o=n.getNode(e.node)?.kind,t=[...e.inserted>0||e.removed===0?[`+${e.inserted}`]:[],...e.removed>0?[`\u2212${e.removed}`]:[]];return`Wrote in ${J(o?i.tryDefinition(o):void 0,e.field)} (${t.join(" ")})`}var b=e=>JSON.stringify([e.kind,e.id??"",e.name??""]),ke=e=>e.ops.find(i=>i.lineage?.run!==void 0)?.lineage?.run;function Me(e,i=()=>{}){let n=[];for(let o of e){if(ce(o,i))continue;if(!P(o.author)){let l=Oe(o),c=n.at(-1),g=l&&c&&"batch"in c&&b(c.batch.author)===b(o.author)&&c.typed?.node===l.node&&c.typed.field===l.field?c.typed:void 0;g?n[n.length-1]={batch:o,typed:{...g,batches:[...g.batches,o],inserted:g.inserted+l.inserted,removed:g.removed+l.removed}}:n.push(l?{batch:o,typed:{batches:[o],...l}}:{batch:o});continue}let t=ke(o),s=b(o.author),a=t!==void 0?n.findIndex(l=>"digest"in l&&l.digest.run===t&&b(l.digest.author)===s):n.length-1,r=n[a],d=r!==void 0&&"digest"in r&&b(r.digest.author)===s&&r.digest.run===t?r.digest:void 0,u=[...d?.batches??[],o];d&&n.splice(a,1),n.push({digest:{author:o.author,batches:u,things:De(u),at:o.at,...t!==void 0?{run:t}:{}}})}return n}var De=e=>e.reduce((i,n)=>i+(n.undone?0:n.ops.length),0),Ie=e=>{let i=Date.parse(e);if(Number.isNaN(i))return!1;let{minutes:n}=F(i,G());return n<6*60||n>=21*60};function Re(e,i=T(new Date().toISOString())??L()){let n=T(e.at)??e.at.slice(0,10),t=e.run!==void 0&&n===i&&[e.at,...(e.batches??[]).map(a=>a.at)].every(Ie)?"overnight":n===i?"today":`on ${z(n)}`,s=e.things===1?"one thing":`${e.things} things`;return e.author?.id?.startsWith("workflow:")&&e.author.name?`${e.author.name}: ${s} ${t}`:`Tidied ${s} ${t}`}N.declined=ue;N.kept=(e,i,n)=>ge(C(e,i,n));var m=e=>e,x=(e,i)=>i===void 0?{}:{[e]:i};function tn(e,i,n){let o=y(e)?.store??e,t=m(o),s=ne(n.lineage);if(s===void 0)throw new v("A suggestion says what it is based on: { basis, confidence? }");let a=n.author??t.by;if(n.expiresAt!==void 0&&Number.isNaN(Date.parse(n.expiresAt)))throw new v(`A suggestion expires at a time: "${n.expiresAt}" is not one (an ISO time, like 2026-10-23T06:00:00Z).`);let r=t.actMeanings(),d=A(i,r),u=$(o).find(f=>A(f.calls,r)===d);if(u)return o.log.get(u.id);t.refuseDeclined(i,a);let l=t.rehearsal();l.suggesting=!0;let c=l.applying(i,{author:a,lineage:s,...x("via",n.via)});if(c.ops.length===0)return;let g=[...new Set(c.ops.flatMap(f=>f.described??[]))],p=c.ops.filter(f=>f.mutation!==null&&f.author===a),S=i.length>1&&p.length===i.length?p.map(f=>f.intent):void 0,w={id:t.nextId(),seq:o.log.length,batch:t.mintBatch("batch"),author:a,intent:c.ops.map(f=>f.intent).join("; "),...x("batchIntent",n.intent),mutation:null,primitives:[],reads:[],writes:[],...g.length>0?{described:g}:{},at:t.now(),...x("via",n.via),lineage:s,suggests:i,...x("suggestsSaid",S),...x("expiresAt",n.expiresAt)};return o.log.append(w),o.notify(Y,[w]),w}function $(e,i,n={}){let o=y(e),t=o?.store??e,s=i??o?.principal,a=(s!==void 0?t.seenBy(s):t).log.all();return ae(a,r=>t.graph.has(r),{now:m(t).now(),dismissed:n.dismissed,voter:s})}function pe(e,i,n){let o=y(e),t=o?.store??e,s=n??o?.principal??m(t).by;return i.calls.every(a=>t.permits(a,s).ok)}function fe(e,i,n,o={}){let t=y(e)?.store??e,s=o.author??m(t).by;k(t,i,s);let a=t.applyAll([{name:oe,args:{suggestion:i,vote:n}}],{...o,author:s});return n===null?a:{...a,voted:n}}function k(e,i,n){let o=$(e,n).find(s=>s.id===i),t=o?void 0:e.log.get(i);if(t?.suggests&&V(t,m(e).now()))throw new v(`That suggestion expired on ${t.expiresAt.slice(0,10)}.`);if(!o)throw new v("That suggestion is no longer waiting: it was accepted or declined, or it is not one you can see.");return o}function on(e,i,n={}){let o=y(e)?.store??e,{items:t,...s}=n,a=s.author??m(o).by,r=k(o,i,a),d=t===void 0?r.items:r.items.filter(g=>t.includes(g.at));if(t!==void 0&&(t.length===0||d.length!==new Set(t).size))throw new v("Name the changes to accept by their place among those still waiting in the suggestion.");let u={...r,calls:d.map(g=>g.call)};if(!pe(o,u,a))return fe(o,i,"for",{...s,author:a});let l=o.log.get(i)?.suggests?.length??d.length,c=d.length<l?{items:d.map(g=>g.at)}:{};return o.applyAll(u.calls,{...s,author:a,lineage:{...r.lineage,suggestion:i,...c}})}function sn(e,i,n={}){let o=y(e)?.store??e,t=n.author??m(o).by,s=k(o,i,t);if(!pe(o,s,t))return fe(o,i,"against",{...n,author:t});let a=ye(s)&&n.intent===void 0?{intent:`Declined ${$e(je(s))} proposal: ${s.intent}`}:{};return o.undo(s.batch,{...n,...a,author:t})}function rn(e,i,n={}){let o=y(e)?.store??e,t=n.author??m(o).by,s=k(o,i,t);if(s.author.kind!==t.kind||s.author.id!==t.id)throw new v("Only who made a suggestion withdraws it: a person declines it (declineSuggestion).");return o.undo(s.batch,{...n,author:t})}var Pe={kind:"system",id:"tidying",name:"Graview, tidying",automated:!0};E.op=(e,i,n,o,t,s)=>{let a=e,{suggestion:r,vote:d}=n.args,u=k(a,r,t),l=I(t)?R(t):void 0,c=d==="for"?`For: ${u.intent}`:d==="against"?`Against: ${u.intent}`:`Withdraws a vote on: ${u.intent}`;return{id:i.id,seq:a.log.length,batch:o,author:t,intent:c,mutation:n,primitives:[],reads:[],writes:[],...u.about.length>0?{described:u.about}:{},at:i.at,...s.via!==void 0?{via:s.via}:{},vote:{suggestion:r,vote:d,...l!==void 0?{advisory:!0,voter:l}:{}}}};E.accepting=(e,i)=>{let n=e,o=n.tidying?.autoAcceptAt;if(o===void 0||i.vote?.vote!=="for")return;let t=i.vote.suggestion,s=$(n).find(u=>u.id===t);if(!s)return;let r=[...j(n.log.all()).get(t)??[]].filter(([,u])=>u==="for").map(([u])=>u);if(r.length<o)return;let d=P(s.author)?s.author:Pe;return{calls:s.calls,author:d,lineage:{...s.lineage,suggestion:t,voters:r.slice(0,ee)}}};var ye=e=>e.lineage?.proposedBy!==void 0,je=e=>e.author.name??e.author.id??"Somebody",$e=e=>/s$/i.test(e)?`${e}'`:`${e}'s`;function an(e,i,n,o){let t=y(e)?.store??e,s=m(t).actMeanings(),a=A(n,s),r=$(t,i).find(u=>ye(u)&&A(u.calls,s)===a);if(r)return t.log.get(r.id);let d={calls:n.map(({name:u,args:l})=>({name:u,args:l})),...x("intent",o)};return t.applyAll([{name:te,args:d}],{author:i}).ops.find(u=>u.suggests!==void 0)}function dn(e,i,n){if(!e||!e.grants.some(t=>t.propose!==void 0))return[];let o=new Set(H(e,i,n));return n.filter(t=>!o.has(t)&&U(t).some(s=>X(e,i,t.name,s)))}export{be as a,Me as b,Re as c,tn as d,$ as e,pe as f,fe as g,on as h,sn as i,rn as j,ye as k,an as l,dn as m};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as I,c as x}from"./chunk.
|
|
1
|
+
import{a as I,c as x}from"./chunk.UDHPMVC4.js";import"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{b,c as A,j as v,q as w,s as O,v as G}from"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import{Zd as k,oe as E,ve as S,we as W}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var F=(e,i)=>k(e,i).slice(1);function j(e,i){let l=e.split("/").filter(Boolean);return l.length===i.length&&l.every((s,h)=>s.startsWith(":")||s==="*"||s===i[h])}var $=["problems","search","map","places"];function R(e,i,l,s,h=[]){let{schema:r}=i,o=r.kinds,f=t=>{if(t.startsWith(w))return(t.slice(w.length).split("|")[0]??"").split("+").every(V=>o.includes(V));let y=O(t);return y!==null?o.includes(y):t.startsWith("edge:")||l.graph.getNode(t)!==void 0},[p="/",u]=e.path.split("?"),n=p.split("/").filter(Boolean),m=u?`?${u}`:"",d=n.length>0&&!$.includes(n[0])?o.find(t=>F(r,t)===n[0]):void 0,c=e.path;if(n[0]==="places"&&n.length===2)`/places/${n[1]}`!==E&&!s.some(t=>t.as===decodeURIComponent(n[1]))&&(c="/");else if(d){let t=n[1]===void 0?void 0:decodeURIComponent(n[1]);c=`/${F(r,d)}${t!==void 0&&l.graph.getNode(t)?.kind===d?`/${n[1]}`:""}${m}`}else n.length>0&&n.length<=2&&!$.includes(n[0])&&!h.some(t=>j(t.path,n))&&(c="/");let g=A(e.stop),P=g.within?.view,U=P!==void 0&&!s.some(t=>t.as===P),a=g;if(U){let{view:t,...y}=g.within??{};a={...a,within:y}}if(g.focusId&&!f(g.focusId)){let t=e.kind&&o.includes(e.kind)?G(e.kind):null;a={...v(a,t),zoom:!1}}return a={...a,relation:a.relation&&(o.includes(a.relation)||r.edgeKinds.includes(a.relation))?a.relation:null,expanded:a.expanded.filter(f),pins:Object.fromEntries(Object.entries(a.pins).filter(([t])=>f(t))),...a.selection?{selection:a.selection.filter(f)}:{}},{face:e.face,path:c,stop:b(a),...e.kind?{kind:e.kind}:{}}}function B(e,i,l){let s=e.at,h=e.pages?.routes()??[];if(e.routing!=="address"||typeof window>"u")return R(s,e.app,i,l,h);let{pathname:r,search:o,hash:f}=window.location,p=W(r,e.basePath),u=I({routing:"address",...e.basePath===void 0?{}:{basePath:e.basePath},face:s.face}),n=u==="pages",m={...s,face:u,...p===null?{}:n?{path:p+o}:{stop:x(e.basePath)??s.stop}},d=R(m,e.app,i,l,h),c=n?d.path===m.path?null:S(d.path,e.basePath===void 0?{}:{basePath:e.basePath}):d.stop===b(A(m.stop))?null:r+o+d.stop;return p!==null&&c!==null&&c!==r+o+f&&window.history.replaceState(window.history.state,"",c),d}export{R as settle,B as settleAt};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as j,e as B}from"./chunk.
|
|
1
|
+
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{a as j,e as B}from"./chunk.6UQFV53C.js";import{t as I}from"./chunk.QNP5OR3P.js";import{G as J,La as M,Ua as R,W as b,Ya as $,ea as A,ga as H}from"./chunk.A5PSEU3W.js";import{a as L}from"./chunk.SDO3U72B.js";import{b as c}from"./chunk.AJZBJBMO.js";var t=c(J(),1);var S=c(b(),1),E=M(L(()=>(__graviewPreload(import.meta.url,["./chunk.25VJPUDH.js","./chunk.HJUZMOW2.js","./chunk.NAXOXBOF.js","./chunk.6W6XMLSF.js","./chunk.PZ7KY6XH.js","./chunk.WEMUKZKH.js","./chunk.T27QKVKP.js","./chunk.SO6NT5K7.js","./chunk.MUSMNKE4.js","./chunk.SJQPTDAT.js","./chunk.JQ63N4MZ.js","./chunk.Z3O2VZAJ.js","./chunk.QNP5OR3P.js","./chunk.4W57E7AX.js","./chunk.A5PSEU3W.js","./chunk.SDO3U72B.js","./chunk.ZEZUKRC6.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.CY7FFKEZ.js")))),W=E.part((a,n)=>(0,S.jsx)(a.SuggestedCount,{...n}),{quiet:!0}),ro=E.part((a,n)=>(0,S.jsx)(a.SuggestedList,{...n}),{quiet:!0,as:"div"});var o=c(b(),1),K=I.part((a,n)=>(0,o.jsx)(a.InboxPane,{...n}),{what:"The inbox"}),Q=[],U=[],oo=a=>a>99?"99+":String(a);function to(a,n){let d=[a>0?`${a} waiting for you`:"",n>0?`${n===1?"1 change":`${n} changes`}`:""].filter(Boolean);return d.length>0?`Inbox \u2014 ${d.join(", ")}`:"Inbox"}function po({calls:a=Q,seat:n,remembers:d=!1}){let{store:C,principal:f,whileAway:V,notifications:m=U,onNotificationsSeen:y,ai:Y}=A(),_=H(),r=B({calls:a,seat:n,remembers:d}),N=j(),q=Y.off!==!0,p=(0,t.useMemo)(()=>f.id===void 0?[]:N.filter(e=>e.by.id===f.id||e.by.onBehalfOf?.id===f.id),[N,f.id]),F=(0,t.useMemo)(()=>C.log.all().some(e=>e.suggests!==void 0&&!e.withheld),[C,_]),h=(V?.tidied??0)>0,v=F||h,[G,z]=(0,t.useState)(0),g=m.filter(e=>!e.read),u=G+g.length,x=u+r.recent,i=$("inbox"),s=i.open,[l,P]=(0,t.useState)("activity"),w=(0,t.useRef)(!1);if(s&&!w.current){w.current=!0;let e=u>0||h?"for-you":r.has?"activity":p.length>0?"asks":"for-you";e!==l&&P(e)}s||(w.current=!1);let T=(0,t.useRef)("");(0,t.useEffect)(()=>{if(!s||l!=="for-you"||g.length===0||!y)return;let e=g.map(Z=>Z.id);T.current!==e.join(`
|
|
2
2
|
`)&&(T.current=e.join(`
|
|
3
3
|
`),y(e))},[s,l,g,y]);let D=(0,t.useCallback)(()=>i.setOpen(!1),[i]),X=(0,t.useCallback)(e=>z(e),[]);if(!(r.has||v||m.length>0||p.length>0))return null;let k=to(u,r.recent),O=()=>I.prefetch();return(0,o.jsxs)("div",{className:"graview-bar-inbox",style:{position:"relative"},children:[v?(0,o.jsx)(t.Suspense,{fallback:null,children:(0,o.jsx)(W,{onCount:X})}):null,(0,o.jsxs)("button",{type:"button",className:"graview-bar-tool","data-testid":"inbox-button","data-count":x,...i.trigger,onClick:i.toggle,onPointerEnter:O,onFocus:O,"aria-label":r.running?`${k} \u2014 an agent is working`:k,title:r.running?"Inbox \u2014 an agent is working":k,...r.running?{"data-running":""}:{},children:[(0,o.jsx)(eo,{}),x>0?(0,o.jsx)("span",{className:"graview-bar-badge","data-testid":"inbox-count","aria-hidden":"true",children:oo(x)}):r.running?(0,o.jsx)("span",{className:"graview-bar-badge","data-dot":"","aria-hidden":"true"}):null]}),(!s||l!=="activity")&&n!==void 0?(0,o.jsx)("div",{hidden:!0,"data-testid":"agent-seat-seated",children:n}):null,s?(0,o.jsx)("section",{...i.pane,"aria-label":"Inbox","data-testid":"inbox","data-graview-offstage":"","data-tab":l,tabIndex:-1,style:{...R,width:"min(360px, calc(100vw - 16px))",maxHeight:"min(70vh, 520px)",overflowX:"hidden",overflowY:"auto",display:"flex",flexDirection:"column",padding:0,borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",outline:"none"},children:(0,o.jsx)(t.Suspense,{fallback:null,children:(0,o.jsx)(K,{tab:l,choose:P,asksOn:q,counts:{"for-you":u,activity:r.recent,asks:p.length},notifications:m,asks:p,tray:v,waits:u>0||h,activityHas:r.has,calls:a,remembers:d,close:D,...n!==void 0?{seat:n}:{}})})}):null]})}function eo(){return(0,o.jsxs)("svg",{width:16,height:16,viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",style:{flex:"0 0 auto"},children:[(0,o.jsx)("path",{d:"M4 11.25 V7.25 a4 4 0 0 1 8 0 V11.25 L13.25 12.5 H2.75 Z",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinejoin:"round"}),(0,o.jsx)("path",{d:"M6.5 14 h3",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round"})]})}export{ro as a,po as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{Zc as g}from"./chunk.
|
|
1
|
+
import{Zc as g}from"./chunk.ZEZUKRC6.js";function b(){let t=new Uint8Array(16);return globalThis.crypto.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,"0")).join("")}function k(t,e){if(!t)return;let i={..."filter"in e&&e.filter?{filter:e.filter}:{},...e.section?{section:e.section}:{}};"record"in e?t.record(e.record,i):"list"in e?t.list(e.list,i):t.place(e.place,i)}function w(t,e){if(!t?.href)return;let i={..."filter"in e&&e.filter?{filter:e.filter}:{},...e.section?{section:e.section}:{}};return t.href("record"in e?{record:e.record}:"list"in e?{list:e.list}:{place:e.place},i)}var v=[["accent","--graview-accent"],["ground","--graview-ground"],["panel","--graview-panel"],["ink","--graview-ink"],["inkMuted","--graview-ink-muted"],["edge","--graview-edge"],["fontBody","--graview-font-body"],["fontDisplay","--graview-font-display"],["fontMono","--graview-font-mono"],["radius","--graview-radius"]];function B(t){let e=t.ownerDocument.defaultView,i=e.getComputedStyle(t),s=t.closest("[data-graview-scheme]")?.getAttribute("data-graview-scheme"),d={scheme:s==="dark"||s==="light"?s:/\bdark\b/.test(i.colorScheme??"")?"dark":/\blight\b/.test(i.colorScheme??"")?"light":e.matchMedia?.("(prefers-color-scheme: dark)").matches?"dark":"light"};for(let[l,u]of v)d[l]=i.getPropertyValue(u).trim();return d}function R(t,e){let i=t.defaultView;if(!i||typeof i.MutationObserver!="function")return()=>{};let s=new i.MutationObserver(e);s.observe(t.documentElement,{attributes:!0,subtree:!0,attributeFilter:["data-graview-scheme","data-theme"]});let o=i.matchMedia?.("(prefers-color-scheme: dark)");return o?.addEventListener?.("change",e),()=>{s.disconnect(),o?.removeEventListener?.("change",e)}}function T(t,e,i){let s=e?.(),o=t(),d=s?.logo,l=i.url(typeof d=="string"||d===void 0?d:o.scheme==="dark"&&d.dark?d.dark:d.light);return{...o,...s?.name?{name:s.name}:{},...l?{logo:l}:{}}}function x(t,e,i){let s,o,d=n=>{n?.startsWith("blob:")&&t.URL.revokeObjectURL(n)},l=async n=>{if(n.startsWith("<"))return g(n)===null?new t.Blob([n],{type:"image/svg+xml"}):void 0;if(/\\|%2e/i.test(n)||n.split(/[?#]/)[0].split("/").some(m=>m==="."||m===".."))return;let r=new t.URL(n,t.document.baseURI);if(r.origin!==t.location.origin||!/^https?:$/.test(r.protocol))return;let a=await t.fetch(r.href,{credentials:"same-origin"}),c=(a.headers.get("content-type")??"").split(";")[0].trim();return a.ok&&c.startsWith("image/")?new t.Blob([await a.arrayBuffer()],{type:c}):void 0},u=n=>new Promise(r=>{let a=new t.Image;a.onload=()=>r(!0),a.onerror=()=>r(!1),t.setTimeout(()=>r(!1),2e3),a.src=n}),p=n=>new Promise((r,a)=>{let c=new t.FileReader;c.onload=()=>r(String(c.result)),c.onerror=a,c.readAsDataURL(n)}),h=async n=>{if(/^data:image\//i.test(n))return n;let r=await l(n);if(!(!r||s!==n)){if(i==="blob"){let a=t.URL.createObjectURL(r);if(await u(a))return a;t.URL.revokeObjectURL(a)}return p(r)}},f=(n,r)=>{if(s!==n)return d(r);r!==o&&(d(o),o=r,e())};return{url(n){let r=n?.trim()||void 0;return r!==s&&(s=r,r?h(r).then(a=>f(r,a),()=>f(r,void 0)):(d(o),o=void 0)),o},dispose(){s=void 0,d(o),o=void 0}}}export{b as a,k as b,w as c,B as d,R as e,T as f,x as g};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{r as We}from"./chunk.BUVTUAB5.js";import{a as ae,b as Oe,f as Ne,i as ze}from"./chunk.MWGZKZD6.js";import{a as Le,e as Re,l as De}from"./chunk.QFHWG4LN.js";import{b as $e,c as O,d as qe,e as Ee}from"./chunk.YIPXZUTT.js";import"./chunk.BJUUSIQY.js";import{a as He,b as Ie,c as Pe}from"./chunk.EMFOMSMI.js";import{a as Me}from"./chunk.PSQYDCVM.js";import"./chunk.QOS5T46W.js";import"./chunk.PPSYUOH7.js";import"./chunk.XOZU4OFA.js";import"./chunk.GME63ZHI.js";import"./chunk.NJRLJEJY.js";import"./chunk.WSDJPXJD.js";import"./chunk.F4VB6Q2W.js";import"./chunk.FFOD5B4B.js";import"./chunk.Z7Y3R3YR.js";import"./chunk.YXEO3Y65.js";import{e as Te,m as Ce}from"./chunk.U3HERHAI.js";import"./chunk.FBILPNGH.js";import{G as Je,J as be,La as xe,W as Se,ea as Ae}from"./chunk.MODLZJD4.js";import{a as ve}from"./chunk.SDO3U72B.js";import{eb as ke,oa as ye,td as we}from"./chunk.6HY6ZGEE.js";import"./chunk.FQLNBIQ5.js";import{b as ie}from"./chunk.AJZBJBMO.js";var s=ie(Je(),1);var r=ie(Se(),1),N=xe(ve(()=>(__graviewPreload(import.meta.url,["./chunk.YIPXZUTT.js","./chunk.BJUUSIQY.js","./chunk.NJRLJEJY.js","./chunk.YXEO3Y65.js","./chunk.U3HERHAI.js","./chunk.FBILPNGH.js","./chunk.MODLZJD4.js","./chunk.SDO3U72B.js","./chunk.6HY6ZGEE.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.5BX66FBP.js")))),Xe=N.part((a,i)=>(0,r.jsx)(a.RateTelling,{...i}),{quiet:!0}),Ze=a=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>setTimeout(a,0)):setTimeout(a,0)},et=()=>`tl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,tt=/^(yes|yep|yeah|sure|ok(ay)?|do it|go ahead|please do)\b/i,nt=/^(no|nope|don'?t|not now|never ?mind)\b/i;function it(a,i,o){let t=i.on==="list"||i.on==="lens"?i.kind:void 0;if(i.on==="selection")return i.ids;if(i.on!=="list"&&i.on!=="lens")return[];if(o==="pages"&&typeof document<"u"){let y=new Set;for(let u of document.querySelectorAll("main [data-graview-listed], main [data-graview-record], main [data-graview-pick]")){let m=u.getAttribute("data-graview-listed")??u.getAttribute("data-graview-record")??u.getAttribute("data-graview-pick"),b=m?a.graph.getNode(m):void 0;m&&b&&(t===void 0||b.kind===t)&&y.add(m)}if(y.size>0)return[...y]}return t?a.graph.allNodes().filter(y=>y.kind===t).map(y=>y.id):[]}var at=new Set(["show","go","to","open","the","a","an","me"]),Fe=a=>a.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,""),oe=(a,i)=>{let o=Fe(a);return i.every(t=>o.includes(t))},Ge=a=>a&&!/^.\p{Lu}/u.test(a)?`${a[0].toLowerCase()}${a.slice(1)}`:a,X={act:4,show:3,place:3,record:4},Ke=360,f=12;function $t({face:a,opening:i,close:o}){let t=Me(),{setMenuAt:y,aiHere:u,session:m,people:b,seats:E,onProposeChange:C,composeChange:$}=Ae(),[g,q]=(0,s.useState)({state:"offered"}),l=(0,s.useMemo)(()=>i.target??$e(i.pointed??{about:[]},e=>t.store.graph.has(e)),[i,t.store]),z=(0,s.useMemo)(()=>Re(t.store,l,t.places),[t.store,l,t.places]),[A,Q]=(0,s.useState)(""),[B,F]=(0,s.useState)(-1),[p,re]=(0,s.useState)(null),[se,ee]=(0,s.useState)(null),K=(0,s.useRef)(null),le=(0,s.useRef)(null),Y=(0,s.useRef)(null),j=(0,s.useId)(),I=(0,s.useRef)(!0),{ghost:de}=be(t.desk),[te,Qe]=(0,s.useState)(null),P=(0,s.useRef)(null),H=(0,s.useCallback)(e=>{let n=P.current;!n||!t.ai.told||(n.kept&&N.current?N.current.changeTelling(t.ai.told,n.id,e):n.queued={...n.queued,...e})},[t.ai.told]);(0,s.useEffect)(()=>{let e=t.ai.told;if(!e)return;let n=globalThis,d=()=>void N.load().then(w=>w.toldListed(e),()=>{});if(n.requestIdleCallback){let w=n.requestIdleCallback(d,{timeout:1500});return()=>n.cancelIdleCallback?.(w)}let T=setTimeout(d,200);return()=>clearTimeout(T)},[t.ai.told]),(0,s.useEffect)(()=>()=>{I.current=!1;let e=P.current,n=t.desk.get().ghost;e&&!(n&&n.ghost.interaction===e.interaction&&n.batch===void 0)&&H({outcome:"abandoned"});let d=t.desk.get().ghost;d?.onCard&&t.desk.setGhost({...d,onCard:!1})},[t.desk]);let ce=p!==null;(0,s.useEffect)(()=>{if(!ce)return;let e=O(l)[0]??(l.on==="list"?`kind:${l.kind}`:l.on==="lens"&&l.kind?`kind:${l.kind}`:null),n=t.principal,d=n.id?ke(n,{graph:t.store.graph,schema:t.store.schema,...E?{seats:E}:{},...b?{people:b}:{}}):void 0;return u({participant:`agent:graview-for-${n.id??"anyone"}:${m}`,kind:"agent",name:"Graview",...n.id?{onBehalfOf:n.id,...d?{onBehalfOfName:d}:{}}:{},over:e,robot:{at:e,mode:"thinking"}}),()=>u(null)},[ce]);let U=(0,s.useMemo)(()=>{let e=ae(t,l);return qe(t.store,l,{principal:t.principal,places:t.places,...e.acts?{acts:e.acts}:{}})},[t,l]),ue=(0,s.useMemo)(()=>{let e=O(l);if(e.length===0)return[];let n=new Set(U.candidates.flatMap(d=>d.type==="act"?[d.mutation]:[]));return He(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,l,U]),V=(0,s.useCallback)(()=>{let e=i.returnTo,n=Be(K.current,l,a);o(),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})})},[i.returnTo,l,a,o]),pe=(0,s.useCallback)(e=>{if(e.open.length>0){let n=K.current?.getBoundingClientRect();o(),y({x:n?.left??0,y:n?.top??0,on:e.args.id??O(l)[0],about:O(l)});return}try{Pe(t.store,e,{},{pressed:t.principal?{author:t.principal}:{}}),Ie(t.store,e,{},{author:t.principal}),V()}catch(n){ee(n instanceof Error?n.message:String(n))}},[t.store,t.principal,o,V,y,l]),_=(0,s.useCallback)(async e=>{let n=e.trim();if(!n)return;let d=p?.result?.answer?{said:p.said,answer:p.result.answer,...p.result.reading?{reading:p.result.reading.which}:{}}:void 0,T=l.on==="lens"?t.places.find(M=>M.as===l.place)?.title:(l.on==="list",void 0);Q(""),F(-1),ee(null),re({said:n,result:null}),q({state:"offered"});let w=it(t.store,l,a),S=P.current;S&&H({outcome:"abandoned"});let c=Date.now(),k=t.ai.told?N.current??await Promise.race([N.load().catch(()=>{}),new Promise(M=>setTimeout(M,50))]):void 0,R=t.ai.told&&k?k.examplesHere(t.ai.told,t.store,t.principal,n,l):{examples:[],ids:[]},Ve=[...new Set([...S?[]:i.suggested?[i.suggested]:[],...R.ids])],v=await De(t.ai,{...ae(t,l,n),said:n,...d?{follows:d}:{},...w.length>0?{members:w}:{},...T?{where:T}:{},...R.examples.length>0?{examples:R.examples}:{}});t.desk.record(v.interaction),v.ghost&&v.ghost.proposals.length>0&&t.desk.setGhost({ghost:v.ghost,onCard:!0});let W;if(v.missing)try{let{planFor:M}=await (__graviewPreload(import.meta.url,["./chunk.YIPXZUTT.js","./chunk.BJUUSIQY.js","./chunk.NJRLJEJY.js","./chunk.YXEO3Y65.js","./chunk.6HY6ZGEE.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.IGK7EZCX.js")),G=Date.now(),me=T??(v.reading&&v.reading.which==="held"&&l.on==="record"?v.reading.words.replace(/^the \d+ \S+ in /,""):void 0);W=await M(t,{said:n,missing:v.missing,members:v.reading?.records??w,host:C!==void 0,...$?{compose:$}:{},...me?{where:me}:{}}),t.desk.record({...v.interaction,stages:[...v.interaction.stages??[],{stage:"compose",ms:Date.now()-G}]})}catch{W={refused:`${v.missing.said} That change could not be made here.`}}I.current&&re({said:n,result:v,...W?{plan:W}:{}});let J=t.ai.told;if(!J)return;let _e=Date.now()-c;P.current?.stop?.();let ne={id:et(),conversation:S?.conversation??"",interaction:v.interaction.id};P.current={...ne,conversation:ne.conversation||ne.id};let D=P.current;Ze(()=>void N.load().then(M=>{let G=M.keepTelling(J,{...M.tellingDraftOf(t.store,{words:n,target:l,result:v,...W?{plan:W}:{},ms:_e,...S?{conversation:S.conversation,follows:S.id}:{},examples:Ve}),id:D.id,conversation:D.conversation},t.principal);G&&(D.kept=!0,D.queued&&M.changeTelling(J,G.id,D.queued),D.stop=M.watchTelling(t.desk,J,G),I.current&&P.current===D&&Qe(G))},()=>{}))},[p,t,l,a,C,$,i.suggested,H]),L=p?.plan&&"question"in p.plan?p.plan:void 0,ge=(0,s.useCallback)(async()=>{let e=L?.proposal;if(!(!e||!C||g.state!=="offered")){q({state:"applying"});try{let n=await C(e);if(!I.current)return;H({outcome:n==="declined"?"declined":"accepted"}),q(n==="declined"?{state:"declined",said:"The host declined this change to the app."}:{state:"applied",...typeof n=="object"?{undo:n.undo,...n.note?{note:n.note}:{}}:{}})}catch(n){I.current&&q({state:"declined",said:n instanceof Error?n.message:String(n)})}}},[L,C,g,H]),fe=(0,s.useCallback)(()=>{H({outcome:"declined"}),q({state:"declined",said:"Left as it is."})},[H]),Ye=(0,s.useCallback)(async()=>{g.state!=="applied"||!g.undo||(await g.undo(),H({outcome:"undone"}),I.current&&q({state:"undone"}))},[g,H]),he=(0,s.useRef)(i.asked);(0,s.useEffect)(()=>{let e=he.current;he.current=void 0,e&&_(e)},[]);let x=(0,s.useMemo)(()=>{let e=A.trim();if(!e&&p)return[];let n=Fe(e).split(/\s+/).filter(c=>c&&!at.has(c)),d=/^show\b/i.test(e),T=/^(go|open)\b/i.test(e),w=[];if(!d&&!T)for(let c of ue.filter(k=>oe(k.label,n)).slice(0,X.act))w.push({id:`act:${c.id}`,kind:"act",label:c.label,hint:c.open.length>0?"asks more":"do it",take:()=>pe(c)});let S=e&&!/\?\s*$/.test(e)?Ee(t.store,l,{principal:t.principal,places:t.places,said:e}):[];for(let c of S)w.push({id:`place:${c.place}`,kind:"place",label:c.fit==="full"?`Open ${c.title}`:`Open and adjust ${c.title}`,hint:c.fit==="full"?"a view you have":"adjust it",take:()=>{o(),t.goTo.place(c.place),c.fit==="partial"&&Te(t.desk,{target:{on:"lens",place:c.place,...c.kind?{kind:c.kind}:{}},asked:e})}});if(!T){let c=U.candidates.filter(k=>k.type==="panel");for(let k of c.filter(R=>oe(`show ${R.label}`,n)).slice(0,X.show))w.push({id:k.id,kind:"show",label:`Show ${Ge(k.label)}`,hint:"a panel",take:()=>{o(),Oe(t,{title:k.label,recipe:{...k.panel,title:k.label}})}})}if(!d){for(let c of t.places.filter(k=>oe(k.title,n)&&!S.some(R=>R.place===k.as)).slice(0,X.place))w.push({id:`place:${c.as}`,kind:"place",label:`Go to ${c.title}`,take:()=>(o(),t.goTo.place(c.as))});if(n.length>0){let c=We(t.store,e.replace(/^(go to|open)\s+/i,""),{principal:t.principal,from:O(l),limit:X.record}).hits;for(let k of c)k.about==="node"&&w.push({id:`record:${k.id}`,kind:"record",label:k.label,hint:ye(t.store.schema,k.kind),take:()=>(o(),t.goTo.record(k.id))})}}return e&&w.push({id:"ask",kind:"ask",label:e,take:()=>void _(e)}),w},[A,ue,U,t,l,pe,_,o,p]);(0,s.useEffect)(()=>F(A.trim()?0:-1),[A]),(0,s.useLayoutEffect)(()=>{let e=K.current;if(!e)return;if(typeof e.showPopover=="function")try{e.showPopover()}catch{}le.current?.focus({preventScroll:!0});let n=0,d=null,T=i.from;T&&rt(e,T);let w=()=>{let S=Be(e,l,a);T?st(e,S):ot(e,S);let c=Y.current?S:null;d!==c&&(d?.removeAttribute("data-graview-ai-thinking"),c?.setAttribute("data-graview-ai-thinking",""),d=c),Y.current&<(Y.current,c),n=requestAnimationFrame(w)};return w(),()=>{cancelAnimationFrame(n),d?.removeAttribute("data-graview-ai-thinking")}},[l,a,i.from]),(0,s.useEffect)(()=>{if(p)return;let e=n=>{n.target instanceof Node&&K.current?.contains(n.target)||o()};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[p,o]);let je=e=>{if(e.key==="ArrowDown"&&x.length>0)e.preventDefault(),F(n=>Math.min(x.length-1,n+1));else if(e.key==="ArrowUp"&&x.length>0)e.preventDefault(),F(n=>Math.max(0,n-1));else if(e.key==="Enter"){e.preventDefault();let n=x[B];n?n.take():L?.proposal&&g.state==="offered"&&tt.test(A.trim())?(Q(""),ge()):L&&g.state==="offered"&&nt.test(A.trim())?(Q(""),fe()):A.trim()&&_(A)}},h=p?.result??null,Ue=x[B];return(0,r.jsxs)("section",{ref:K,popover:"manual",role:"region","aria-label":p?`Answer about ${z}`:`Tell Graview about ${z}`,"data-testid":"quick-ask","data-quick-ask":p?"answer":"bar","data-quick-ask-face":a,"data-graview-offstage":"","data-graview-overlay":"",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),V())},onMouseDown:e=>e.stopPropagation(),style:pt,children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[(0,r.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 ",z]}),(0,r.jsx)("button",{type:"button","data-testid":"quick-ask-close","aria-label":"Close",title:"Close",onClick:V,style:gt,children:(0,r.jsx)("span",{"aria-hidden":"true",children:"\u2715"})})]}),p?(0,r.jsxs)("div",{"data-testid":"quick-answer",style:{display:"grid",gap:8},children:[(0,r.jsxs)("p",{"data-testid":"quick-answer-asked",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",fontStyle:"italic",overflowWrap:"anywhere"},children:["\u201C",p.said,"\u201D"]}),(0,r.jsx)("p",{"data-testid":"quick-answer-text","aria-live":"polite",style:{margin:0,fontSize:"0.9375rem",lineHeight:1.45,color:h?.interaction.outcome==="failed"?"var(--graview-warn)":"var(--graview-ink)",overflowWrap:"anywhere"},children:h===null?"Thinking\u2026":h.interaction.outcome==="failed"?h.interaction.failed??"The AI could not answer that here.":Le(p.plan?"question"in p.plan?p.plan.question:p.plan.refused:h.answer,h.ghost&&h.ghost.proposals.length>0?"Here is what I would change.":h.offers.length>0?"These may help.":void 0)}),h?.taken?(0,r.jsxs)("p",{"data-testid":"quick-ask-taken",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:["Taking \u201C",h.taken.said,"\u201D as ",h.taken.as,"."]}):null,h?.reading?.close?(0,r.jsxs)("p",{"data-testid":"quick-ask-reading",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:["Taking this as ",h.reading.words,"."]}):null,L?(0,r.jsxs)("section",{"data-testid":"quick-ask-plan","data-plan-state":g.state,"aria-label":"What I would do",style:ut,children:[(0,r.jsx)("ol",{style:{margin:0,paddingInlineStart:18,display:"grid",gap:2},children:L.parts.map((e,n)=>(0,r.jsx)("li",{"data-plan-part":e.part,style:{fontStyle:g.state==="applied"?"normal":"italic"},children:e.said},n))}),L.proposal&&C?g.state==="offered"||g.state==="applying"?(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("button",{type:"button","data-testid":"quick-ask-plan-yes",disabled:g.state==="applying",onClick:()=>void ge(),style:Z,children:"Yes"}),(0,r.jsx)("button",{type:"button","data-testid":"quick-ask-plan-no",disabled:g.state==="applying",onClick:fe,style:Z,children:"No"})]}):g.state==="applied"?(0,r.jsxs)("div",{role:"status",style:{display:"flex",gap:6,alignItems:"center"},children:[(0,r.jsxs)("span",{"data-testid":"quick-ask-plan-done",children:["Done, as one change.",g.note?` ${g.note}`:""]}),g.undo?(0,r.jsx)("button",{type:"button","data-testid":"quick-ask-plan-undo",onClick:()=>void Ye(),style:Z,children:"Undo"}):null]}):(0,r.jsx)("p",{role:"status",style:{margin:0,color:"var(--graview-ink-muted)"},children:g.state==="undone"?"Taken back.":g.said}):null]}):null,h&&h.offers.length>0?(0,r.jsx)("ul",{"aria-label":"What acts on it",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:6},children:h.offers.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)("button",{type:"button","data-testid":"quick-answer-offer","data-ai-offer":e.id,"data-ai-offer-type":e.type,onClick:()=>{Ne(t,h,e,o,{onCard:e.type==="act"||e.type==="fill"}).then(n=>{n&&I.current&&ee(n)})},style:Z,children:e.type==="panel"?`Show ${Ge(e.label)}`:e.type==="place"?`Go to ${e.label}`:e.type==="act"||e.type==="fill"?`${e.label.replace(/[.?]$/,"")}?`:e.label})},e.id))}):null,de?.onCard&&de.ghost.interaction===h?.interaction.id?(0,r.jsx)(ze,{placement:"card"}):null,h&&te&&t.ai.told&&te.interaction===h.interaction.id?(0,r.jsx)(Xe,{told:t.ai.told,telling:te}):null]}):null,(0,r.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,r.jsx)("input",{ref:le,type:"text",role:"combobox","data-testid":"quick-ask-input","aria-label":p?`Reply about ${z}`:`Tell Graview about ${z}, or go somewhere`,"aria-expanded":x.length>0,"aria-controls":j,"aria-autocomplete":"list",...Ue?{"aria-activedescendant":`${j}-${B}`}:{},autoComplete:"off",enterKeyHint:"go",placeholder:p?"Reply\u2026":"Tell Graview, or go to\u2026",value:A,readOnly:p!==null&&h===null,"aria-busy":p!==null&&h===null,onChange:e=>Q(e.target.value),onKeyDown:je,style:ft}),(0,r.jsx)("div",{id:j,role:"listbox","aria-label":A.trim()?`What \u201C${A.trim()}\u201D finds here`:"What can be done here",hidden:x.length===0,style:{display:x.length===0?"none":"grid",gap:1,maxHeight:280,overflowY:"auto"},children:x.map((e,n)=>(0,r.jsx)("div",{id:`${j}-${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:()=>F(n),onMouseDown:d=>d.preventDefault(),onClick:e.take,style:{...ht,background:n===B?"var(--graview-panel-muted)":"transparent",...e.kind==="ask"?{borderTop:"1px solid var(--graview-edge)",marginTop:2}:{}},children:e.kind==="ask"?(0,r.jsxs)("span",{children:["Tell Graview: ",(0,r.jsxs)("span",{style:{fontWeight:600},children:["\u2018",e.label,"\u2019"]})]}):(0,r.jsxs)("span",{children:[e.label,e.hint?(0,r.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",e.hint]}):null]})},e.id))})]}),se?(0,r.jsx)("p",{role:"alert","data-testid":"quick-ask-refused",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-warn)"},children:se}):null,(0,r.jsx)("span",{style:Ce,"aria-live":"polite",children:x.length>0&&A.trim()?`${x.length} ${x.length===1?"way":"ways"} to go on`:""}),p!==null&&h===null?(0,r.jsxs)("span",{ref:Y,role:"status","data-testid":"ai-thinking-mark",style:dt,children:[(0,r.jsx)("style",{children:"@keyframes graview-thinking{from{opacity:.35}to{opacity:1}}@media (prefers-reduced-motion:reduce){[data-testid=ai-thinking-mark]>span{animation:none!important}}"}),(0,r.jsx)("span",{"aria-hidden":"true",style:ct}),(0,r.jsxs)("span",{children:["Thinking about ",z,"\u2026"]})]}):null]})}function Be(a,i,o){let t=a?.closest("[data-graview-embed]")??document,y=i.on==="list"?[`aggregate:${i.kind}`,`kind:${i.kind}`]:i.on==="lens"&&i.kind?[`aggregate:${i.kind}`]:O(i);for(let u of y)for(let m of t.querySelectorAll(`[data-graview-view="${CSS.escape(u)}"], [data-graview-pick="${CSS.escape(u)}"], [data-graview-record="${CSS.escape(u)}"], [data-graview-listed="${CSS.escape(u)}"]`)){if(a?.contains(m))continue;let b=m.getBoundingClientRect();if(b.width>0&&b.height>0)return m}return o==="pages"?t.querySelector("main [data-graview-page-title]")??t.querySelector("main h1"):null}function ot(a,i){let o={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},t=Math.min(Ke,o.width-2*f),y=a.getBoundingClientRect().height,u=i?.getBoundingClientRect(),m,b,E,C=l=>Math.max(f,Math.min(l,o.height-y-f));if(u&&u.width>0&&u.bottom>0&&u.top<o.height)if(u.right+f+t<=o.width-f)m=u.right+f,b=C(u.top),E="right";else if(u.left-f-t>=f)m=u.left-f-t,b=C(u.top),E="left";else{m=Math.max(f,Math.min(u.left,o.width-t-f));let l=u.bottom+f;b=l+y<=o.height-f?l:C(u.top-f-y),E=l+y<=o.height-f?"below":"above"}else m=(o.width-t)/2,b=C(72),E="top";let $=a.style,g={left:`${Math.round(m)}px`,top:`${Math.round(b)}px`,width:`${Math.round(t)}px`};$.left!==g.left&&($.left=g.left),$.top!==g.top&&($.top=g.top),$.width!==g.width&&($.width=g.width);let q=i?.getAttribute("data-graview-view")??i?.getAttribute("data-graview-pick")??i?.getAttribute("data-graview-record")??i?.getAttribute("data-graview-listed")??(i?"page":"");a.getAttribute("data-quick-ask-beside")!==q&&a.setAttribute("data-quick-ask-beside",q),a.getAttribute("data-quick-ask-side")!==E&&a.setAttribute("data-quick-ask-side",E)}function rt(a,i){let o={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},t=Math.min(Ke,o.width-2*f),y=i.left+t>o.width-f?Math.max(f,o.width-f-t):Math.max(f,i.left),u=240,m=i.top+u>o.height-f?Math.max(f,o.height-f-u):Math.max(f,i.top);a.style.left=`${Math.round(y)}px`,a.style.top=`${Math.round(m)}px`,a.style.width=`${Math.round(t)}px`,a.style.maxHeight=`${Math.round(o.height-m-f)}px`,a.setAttribute("data-quick-ask-side","where-the-menu-stood"),a.setAttribute("data-quick-ask-from",`${Math.round(i.left)},${Math.round(i.top)}`)}function st(a,i){let o=i?.getAttribute("data-graview-view")??i?.getAttribute("data-graview-pick")??i?.getAttribute("data-graview-record")??i?.getAttribute("data-graview-listed")??(i?"page":"");a.getAttribute("data-quick-ask-beside")!==o&&a.setAttribute("data-quick-ask-beside",o)}function lt(a,i){let o=i?.getBoundingClientRect(),t=i?.getAttribute("data-graview-view")??i?.getAttribute("data-graview-pick")??i?.getAttribute("data-graview-record")??i?.getAttribute("data-graview-listed")??(i?"page":"");if(a.getAttribute("data-thinking-on")!==t&&a.setAttribute("data-thinking-on",t),!o||o.width===0){a.style.visibility!=="hidden"&&(a.style.visibility="hidden");return}let y=a.getBoundingClientRect().width,u=`${Math.round(Math.max(f/2,o.right-y-6))}px`,m=`${Math.round(Math.max(f/2,o.top-10))}px`;a.style.left!==u&&(a.style.left=u),a.style.top!==m&&(a.style.top=m),a.style.visibility!=="visible"&&(a.style.visibility="visible")}var dt={position:"fixed",visibility:"hidden",display:"inline-flex",alignItems:"center",gap:6,padding:"2px 8px",borderRadius:999,fontSize:"0.75rem",lineHeight:1.4,whiteSpace:"nowrap",color:"var(--graview-ink)",background:"var(--graview-float)",border:"1px dashed var(--graview-accent)",boxShadow:"var(--graview-lift-low)",pointerEvents:"none"},ct={width:7,height:7,borderRadius:999,background:"var(--graview-accent)",animation:"graview-thinking 1s ease-in-out infinite alternate"},ut={display:"grid",gap:8,padding:10,borderRadius:10,border:"1px dashed var(--graview-accent)",fontSize:"0.875rem"},pt={position:"fixed",inset:"auto",height:"auto",margin:0,zIndex:we("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"},gt={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"},ft={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},ht={display:"flex",alignItems:"center",minHeight:30,padding:"4px 8px",borderRadius:6,cursor:"pointer",overflowWrap:"anywhere"},Z={display:"inline-flex",alignItems:"center",minHeight:30,padding:"2px 10px",font:"inherit",fontSize:"0.8125rem",borderRadius:8};export{$t as QuickAskCard};
|
|
1
|
+
var __graviewPreload=(base,files)=>{if(typeof document>"u")return;const asked=globalThis.__graviewPreloaded??=new Set;for(const file of files){const href=new URL(file,base).href;if(asked.has(href))continue;asked.add(href);const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};import{r as We}from"./chunk.LRNFE3UK.js";import{a as ae,b as Oe,f as Ne,i as ze}from"./chunk.SFBHPYRD.js";import{a as Le,e as Re,l as De}from"./chunk.ILJDLBPJ.js";import{b as $e,c as O,d as qe,e as Ee}from"./chunk.X226YATK.js";import"./chunk.BJUUSIQY.js";import{a as He,b as Ie,c as Pe}from"./chunk.MSAYU25L.js";import{a as Me}from"./chunk.QF5QB5YR.js";import"./chunk.EGPCVMDU.js";import"./chunk.M7KXQGQL.js";import"./chunk.XOZU4OFA.js";import"./chunk.H3EGBDW2.js";import"./chunk.6KJGRM7A.js";import"./chunk.SO6NT5K7.js";import"./chunk.MUSMNKE4.js";import"./chunk.SJQPTDAT.js";import"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import{e as Te,m as Ce}from"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import{G as Je,J as be,La as xe,W as Se,ea as Ae}from"./chunk.A5PSEU3W.js";import{a as ve}from"./chunk.SDO3U72B.js";import{eb as ke,oa as ye,td as we}from"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import{b as ie}from"./chunk.AJZBJBMO.js";var s=ie(Je(),1);var r=ie(Se(),1),N=xe(ve(()=>(__graviewPreload(import.meta.url,["./chunk.X226YATK.js","./chunk.BJUUSIQY.js","./chunk.6KJGRM7A.js","./chunk.Z3O2VZAJ.js","./chunk.QNP5OR3P.js","./chunk.4W57E7AX.js","./chunk.A5PSEU3W.js","./chunk.SDO3U72B.js","./chunk.ZEZUKRC6.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.CKDCTFLU.js")))),Xe=N.part((a,i)=>(0,r.jsx)(a.RateTelling,{...i}),{quiet:!0}),Ze=a=>{typeof requestAnimationFrame=="function"?requestAnimationFrame(()=>setTimeout(a,0)):setTimeout(a,0)},et=()=>`tl-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`,tt=/^(yes|yep|yeah|sure|ok(ay)?|do it|go ahead|please do)\b/i,nt=/^(no|nope|don'?t|not now|never ?mind)\b/i;function it(a,i,o){let t=i.on==="list"||i.on==="lens"?i.kind:void 0;if(i.on==="selection")return i.ids;if(i.on!=="list"&&i.on!=="lens")return[];if(o==="pages"&&typeof document<"u"){let y=new Set;for(let u of document.querySelectorAll("main [data-graview-listed], main [data-graview-record], main [data-graview-pick]")){let m=u.getAttribute("data-graview-listed")??u.getAttribute("data-graview-record")??u.getAttribute("data-graview-pick"),b=m?a.graph.getNode(m):void 0;m&&b&&(t===void 0||b.kind===t)&&y.add(m)}if(y.size>0)return[...y]}return t?a.graph.allNodes().filter(y=>y.kind===t).map(y=>y.id):[]}var at=new Set(["show","go","to","open","the","a","an","me"]),Fe=a=>a.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,""),oe=(a,i)=>{let o=Fe(a);return i.every(t=>o.includes(t))},Ge=a=>a&&!/^.\p{Lu}/u.test(a)?`${a[0].toLowerCase()}${a.slice(1)}`:a,X={act:4,show:3,place:3,record:4},Ke=360,f=12;function $t({face:a,opening:i,close:o}){let t=Me(),{setMenuAt:y,aiHere:u,session:m,people:b,seats:E,onProposeChange:C,composeChange:$}=Ae(),[g,q]=(0,s.useState)({state:"offered"}),l=(0,s.useMemo)(()=>i.target??$e(i.pointed??{about:[]},e=>t.store.graph.has(e)),[i,t.store]),z=(0,s.useMemo)(()=>Re(t.store,l,t.places),[t.store,l,t.places]),[A,Q]=(0,s.useState)(""),[B,F]=(0,s.useState)(-1),[p,re]=(0,s.useState)(null),[se,ee]=(0,s.useState)(null),K=(0,s.useRef)(null),le=(0,s.useRef)(null),Y=(0,s.useRef)(null),j=(0,s.useId)(),I=(0,s.useRef)(!0),{ghost:de}=be(t.desk),[te,Qe]=(0,s.useState)(null),P=(0,s.useRef)(null),H=(0,s.useCallback)(e=>{let n=P.current;!n||!t.ai.told||(n.kept&&N.current?N.current.changeTelling(t.ai.told,n.id,e):n.queued={...n.queued,...e})},[t.ai.told]);(0,s.useEffect)(()=>{let e=t.ai.told;if(!e)return;let n=globalThis,d=()=>void N.load().then(w=>w.toldListed(e),()=>{});if(n.requestIdleCallback){let w=n.requestIdleCallback(d,{timeout:1500});return()=>n.cancelIdleCallback?.(w)}let T=setTimeout(d,200);return()=>clearTimeout(T)},[t.ai.told]),(0,s.useEffect)(()=>()=>{I.current=!1;let e=P.current,n=t.desk.get().ghost;e&&!(n&&n.ghost.interaction===e.interaction&&n.batch===void 0)&&H({outcome:"abandoned"});let d=t.desk.get().ghost;d?.onCard&&t.desk.setGhost({...d,onCard:!1})},[t.desk]);let ce=p!==null;(0,s.useEffect)(()=>{if(!ce)return;let e=O(l)[0]??(l.on==="list"?`kind:${l.kind}`:l.on==="lens"&&l.kind?`kind:${l.kind}`:null),n=t.principal,d=n.id?ke(n,{graph:t.store.graph,schema:t.store.schema,...E?{seats:E}:{},...b?{people:b}:{}}):void 0;return u({participant:`agent:graview-for-${n.id??"anyone"}:${m}`,kind:"agent",name:"Graview",...n.id?{onBehalfOf:n.id,...d?{onBehalfOfName:d}:{}}:{},over:e,robot:{at:e,mode:"thinking"}}),()=>u(null)},[ce]);let U=(0,s.useMemo)(()=>{let e=ae(t,l);return qe(t.store,l,{principal:t.principal,places:t.places,...e.acts?{acts:e.acts}:{}})},[t,l]),ue=(0,s.useMemo)(()=>{let e=O(l);if(e.length===0)return[];let n=new Set(U.candidates.flatMap(d=>d.type==="act"?[d.mutation]:[]));return He(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,l,U]),V=(0,s.useCallback)(()=>{let e=i.returnTo,n=Be(K.current,l,a);o(),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})})},[i.returnTo,l,a,o]),pe=(0,s.useCallback)(e=>{if(e.open.length>0){let n=K.current?.getBoundingClientRect();o(),y({x:n?.left??0,y:n?.top??0,on:e.args.id??O(l)[0],about:O(l)});return}try{Pe(t.store,e,{},{pressed:t.principal?{author:t.principal}:{}}),Ie(t.store,e,{},{author:t.principal}),V()}catch(n){ee(n instanceof Error?n.message:String(n))}},[t.store,t.principal,o,V,y,l]),_=(0,s.useCallback)(async e=>{let n=e.trim();if(!n)return;let d=p?.result?.answer?{said:p.said,answer:p.result.answer,...p.result.reading?{reading:p.result.reading.which}:{}}:void 0,T=l.on==="lens"?t.places.find(M=>M.as===l.place)?.title:(l.on==="list",void 0);Q(""),F(-1),ee(null),re({said:n,result:null}),q({state:"offered"});let w=it(t.store,l,a),S=P.current;S&&H({outcome:"abandoned"});let c=Date.now(),k=t.ai.told?N.current??await Promise.race([N.load().catch(()=>{}),new Promise(M=>setTimeout(M,50))]):void 0,R=t.ai.told&&k?k.examplesHere(t.ai.told,t.store,t.principal,n,l):{examples:[],ids:[]},Ve=[...new Set([...S?[]:i.suggested?[i.suggested]:[],...R.ids])],v=await De(t.ai,{...ae(t,l,n),said:n,...d?{follows:d}:{},...w.length>0?{members:w}:{},...T?{where:T}:{},...R.examples.length>0?{examples:R.examples}:{}});t.desk.record(v.interaction),v.ghost&&v.ghost.proposals.length>0&&t.desk.setGhost({ghost:v.ghost,onCard:!0});let W;if(v.missing)try{let{planFor:M}=await (__graviewPreload(import.meta.url,["./chunk.X226YATK.js","./chunk.BJUUSIQY.js","./chunk.6KJGRM7A.js","./chunk.Z3O2VZAJ.js","./chunk.ZEZUKRC6.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.7ARRVNUR.js")),G=Date.now(),me=T??(v.reading&&v.reading.which==="held"&&l.on==="record"?v.reading.words.replace(/^the \d+ \S+ in /,""):void 0);W=await M(t,{said:n,missing:v.missing,members:v.reading?.records??w,host:C!==void 0,...$?{compose:$}:{},...me?{where:me}:{}}),t.desk.record({...v.interaction,stages:[...v.interaction.stages??[],{stage:"compose",ms:Date.now()-G}]})}catch{W={refused:`${v.missing.said} That change could not be made here.`}}I.current&&re({said:n,result:v,...W?{plan:W}:{}});let J=t.ai.told;if(!J)return;let _e=Date.now()-c;P.current?.stop?.();let ne={id:et(),conversation:S?.conversation??"",interaction:v.interaction.id};P.current={...ne,conversation:ne.conversation||ne.id};let D=P.current;Ze(()=>void N.load().then(M=>{let G=M.keepTelling(J,{...M.tellingDraftOf(t.store,{words:n,target:l,result:v,...W?{plan:W}:{},ms:_e,...S?{conversation:S.conversation,follows:S.id}:{},examples:Ve}),id:D.id,conversation:D.conversation},t.principal);G&&(D.kept=!0,D.queued&&M.changeTelling(J,G.id,D.queued),D.stop=M.watchTelling(t.desk,J,G),I.current&&P.current===D&&Qe(G))},()=>{}))},[p,t,l,a,C,$,i.suggested,H]),L=p?.plan&&"question"in p.plan?p.plan:void 0,ge=(0,s.useCallback)(async()=>{let e=L?.proposal;if(!(!e||!C||g.state!=="offered")){q({state:"applying"});try{let n=await C(e);if(!I.current)return;H({outcome:n==="declined"?"declined":"accepted"}),q(n==="declined"?{state:"declined",said:"The host declined this change to the app."}:{state:"applied",...typeof n=="object"?{undo:n.undo,...n.note?{note:n.note}:{}}:{}})}catch(n){I.current&&q({state:"declined",said:n instanceof Error?n.message:String(n)})}}},[L,C,g,H]),fe=(0,s.useCallback)(()=>{H({outcome:"declined"}),q({state:"declined",said:"Left as it is."})},[H]),Ye=(0,s.useCallback)(async()=>{g.state!=="applied"||!g.undo||(await g.undo(),H({outcome:"undone"}),I.current&&q({state:"undone"}))},[g,H]),he=(0,s.useRef)(i.asked);(0,s.useEffect)(()=>{let e=he.current;he.current=void 0,e&&_(e)},[]);let x=(0,s.useMemo)(()=>{let e=A.trim();if(!e&&p)return[];let n=Fe(e).split(/\s+/).filter(c=>c&&!at.has(c)),d=/^show\b/i.test(e),T=/^(go|open)\b/i.test(e),w=[];if(!d&&!T)for(let c of ue.filter(k=>oe(k.label,n)).slice(0,X.act))w.push({id:`act:${c.id}`,kind:"act",label:c.label,hint:c.open.length>0?"asks more":"do it",take:()=>pe(c)});let S=e&&!/\?\s*$/.test(e)?Ee(t.store,l,{principal:t.principal,places:t.places,said:e}):[];for(let c of S)w.push({id:`place:${c.place}`,kind:"place",label:c.fit==="full"?`Open ${c.title}`:`Open and adjust ${c.title}`,hint:c.fit==="full"?"a view you have":"adjust it",take:()=>{o(),t.goTo.place(c.place),c.fit==="partial"&&Te(t.desk,{target:{on:"lens",place:c.place,...c.kind?{kind:c.kind}:{}},asked:e})}});if(!T){let c=U.candidates.filter(k=>k.type==="panel");for(let k of c.filter(R=>oe(`show ${R.label}`,n)).slice(0,X.show))w.push({id:k.id,kind:"show",label:`Show ${Ge(k.label)}`,hint:"a panel",take:()=>{o(),Oe(t,{title:k.label,recipe:{...k.panel,title:k.label}})}})}if(!d){for(let c of t.places.filter(k=>oe(k.title,n)&&!S.some(R=>R.place===k.as)).slice(0,X.place))w.push({id:`place:${c.as}`,kind:"place",label:`Go to ${c.title}`,take:()=>(o(),t.goTo.place(c.as))});if(n.length>0){let c=We(t.store,e.replace(/^(go to|open)\s+/i,""),{principal:t.principal,from:O(l),limit:X.record}).hits;for(let k of c)k.about==="node"&&w.push({id:`record:${k.id}`,kind:"record",label:k.label,hint:ye(t.store.schema,k.kind),take:()=>(o(),t.goTo.record(k.id))})}}return e&&w.push({id:"ask",kind:"ask",label:e,take:()=>void _(e)}),w},[A,ue,U,t,l,pe,_,o,p]);(0,s.useEffect)(()=>F(A.trim()?0:-1),[A]),(0,s.useLayoutEffect)(()=>{let e=K.current;if(!e)return;if(typeof e.showPopover=="function")try{e.showPopover()}catch{}le.current?.focus({preventScroll:!0});let n=0,d=null,T=i.from;T&&rt(e,T);let w=()=>{let S=Be(e,l,a);T?st(e,S):ot(e,S);let c=Y.current?S:null;d!==c&&(d?.removeAttribute("data-graview-ai-thinking"),c?.setAttribute("data-graview-ai-thinking",""),d=c),Y.current&<(Y.current,c),n=requestAnimationFrame(w)};return w(),()=>{cancelAnimationFrame(n),d?.removeAttribute("data-graview-ai-thinking")}},[l,a,i.from]),(0,s.useEffect)(()=>{if(p)return;let e=n=>{n.target instanceof Node&&K.current?.contains(n.target)||o()};return document.addEventListener("pointerdown",e,!0),()=>document.removeEventListener("pointerdown",e,!0)},[p,o]);let je=e=>{if(e.key==="ArrowDown"&&x.length>0)e.preventDefault(),F(n=>Math.min(x.length-1,n+1));else if(e.key==="ArrowUp"&&x.length>0)e.preventDefault(),F(n=>Math.max(0,n-1));else if(e.key==="Enter"){e.preventDefault();let n=x[B];n?n.take():L?.proposal&&g.state==="offered"&&tt.test(A.trim())?(Q(""),ge()):L&&g.state==="offered"&&nt.test(A.trim())?(Q(""),fe()):A.trim()&&_(A)}},h=p?.result??null,Ue=x[B];return(0,r.jsxs)("section",{ref:K,popover:"manual",role:"region","aria-label":p?`Answer about ${z}`:`Tell Graview about ${z}`,"data-testid":"quick-ask","data-quick-ask":p?"answer":"bar","data-quick-ask-face":a,"data-graview-offstage":"","data-graview-overlay":"",onKeyDown:e=>{e.key==="Escape"&&(e.preventDefault(),e.stopPropagation(),V())},onMouseDown:e=>e.stopPropagation(),style:pt,children:[(0,r.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:8},children:[(0,r.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 ",z]}),(0,r.jsx)("button",{type:"button","data-testid":"quick-ask-close","aria-label":"Close",title:"Close",onClick:V,style:gt,children:(0,r.jsx)("span",{"aria-hidden":"true",children:"\u2715"})})]}),p?(0,r.jsxs)("div",{"data-testid":"quick-answer",style:{display:"grid",gap:8},children:[(0,r.jsxs)("p",{"data-testid":"quick-answer-asked",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",fontStyle:"italic",overflowWrap:"anywhere"},children:["\u201C",p.said,"\u201D"]}),(0,r.jsx)("p",{"data-testid":"quick-answer-text","aria-live":"polite",style:{margin:0,fontSize:"0.9375rem",lineHeight:1.45,color:h?.interaction.outcome==="failed"?"var(--graview-warn)":"var(--graview-ink)",overflowWrap:"anywhere"},children:h===null?"Thinking\u2026":h.interaction.outcome==="failed"?h.interaction.failed??"The AI could not answer that here.":Le(p.plan?"question"in p.plan?p.plan.question:p.plan.refused:h.answer,h.ghost&&h.ghost.proposals.length>0?"Here is what I would change.":h.offers.length>0?"These may help.":void 0)}),h?.taken?(0,r.jsxs)("p",{"data-testid":"quick-ask-taken",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:["Taking \u201C",h.taken.said,"\u201D as ",h.taken.as,"."]}):null,h?.reading?.close?(0,r.jsxs)("p",{"data-testid":"quick-ask-reading",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:["Taking this as ",h.reading.words,"."]}):null,L?(0,r.jsxs)("section",{"data-testid":"quick-ask-plan","data-plan-state":g.state,"aria-label":"What I would do",style:ut,children:[(0,r.jsx)("ol",{style:{margin:0,paddingInlineStart:18,display:"grid",gap:2},children:L.parts.map((e,n)=>(0,r.jsx)("li",{"data-plan-part":e.part,style:{fontStyle:g.state==="applied"?"normal":"italic"},children:e.said},n))}),L.proposal&&C?g.state==="offered"||g.state==="applying"?(0,r.jsxs)("div",{style:{display:"flex",gap:6},children:[(0,r.jsx)("button",{type:"button","data-testid":"quick-ask-plan-yes",disabled:g.state==="applying",onClick:()=>void ge(),style:Z,children:"Yes"}),(0,r.jsx)("button",{type:"button","data-testid":"quick-ask-plan-no",disabled:g.state==="applying",onClick:fe,style:Z,children:"No"})]}):g.state==="applied"?(0,r.jsxs)("div",{role:"status",style:{display:"flex",gap:6,alignItems:"center"},children:[(0,r.jsxs)("span",{"data-testid":"quick-ask-plan-done",children:["Done, as one change.",g.note?` ${g.note}`:""]}),g.undo?(0,r.jsx)("button",{type:"button","data-testid":"quick-ask-plan-undo",onClick:()=>void Ye(),style:Z,children:"Undo"}):null]}):(0,r.jsx)("p",{role:"status",style:{margin:0,color:"var(--graview-ink-muted)"},children:g.state==="undone"?"Taken back.":g.said}):null]}):null,h&&h.offers.length>0?(0,r.jsx)("ul",{"aria-label":"What acts on it",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:6},children:h.offers.map(e=>(0,r.jsx)("li",{children:(0,r.jsx)("button",{type:"button","data-testid":"quick-answer-offer","data-ai-offer":e.id,"data-ai-offer-type":e.type,onClick:()=>{Ne(t,h,e,o,{onCard:e.type==="act"||e.type==="fill"}).then(n=>{n&&I.current&&ee(n)})},style:Z,children:e.type==="panel"?`Show ${Ge(e.label)}`:e.type==="place"?`Go to ${e.label}`:e.type==="act"||e.type==="fill"?`${e.label.replace(/[.?]$/,"")}?`:e.label})},e.id))}):null,de?.onCard&&de.ghost.interaction===h?.interaction.id?(0,r.jsx)(ze,{placement:"card"}):null,h&&te&&t.ai.told&&te.interaction===h.interaction.id?(0,r.jsx)(Xe,{told:t.ai.told,telling:te}):null]}):null,(0,r.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,r.jsx)("input",{ref:le,type:"text",role:"combobox","data-testid":"quick-ask-input","aria-label":p?`Reply about ${z}`:`Tell Graview about ${z}, or go somewhere`,"aria-expanded":x.length>0,"aria-controls":j,"aria-autocomplete":"list",...Ue?{"aria-activedescendant":`${j}-${B}`}:{},autoComplete:"off",enterKeyHint:"go",placeholder:p?"Reply\u2026":"Tell Graview, or go to\u2026",value:A,readOnly:p!==null&&h===null,"aria-busy":p!==null&&h===null,onChange:e=>Q(e.target.value),onKeyDown:je,style:ft}),(0,r.jsx)("div",{id:j,role:"listbox","aria-label":A.trim()?`What \u201C${A.trim()}\u201D finds here`:"What can be done here",hidden:x.length===0,style:{display:x.length===0?"none":"grid",gap:1,maxHeight:280,overflowY:"auto"},children:x.map((e,n)=>(0,r.jsx)("div",{id:`${j}-${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:()=>F(n),onMouseDown:d=>d.preventDefault(),onClick:e.take,style:{...ht,background:n===B?"var(--graview-panel-muted)":"transparent",...e.kind==="ask"?{borderTop:"1px solid var(--graview-edge)",marginTop:2}:{}},children:e.kind==="ask"?(0,r.jsxs)("span",{children:["Tell Graview: ",(0,r.jsxs)("span",{style:{fontWeight:600},children:["\u2018",e.label,"\u2019"]})]}):(0,r.jsxs)("span",{children:[e.label,e.hint?(0,r.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",e.hint]}):null]})},e.id))})]}),se?(0,r.jsx)("p",{role:"alert","data-testid":"quick-ask-refused",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-warn)"},children:se}):null,(0,r.jsx)("span",{style:Ce,"aria-live":"polite",children:x.length>0&&A.trim()?`${x.length} ${x.length===1?"way":"ways"} to go on`:""}),p!==null&&h===null?(0,r.jsxs)("span",{ref:Y,role:"status","data-testid":"ai-thinking-mark",style:dt,children:[(0,r.jsx)("style",{children:"@keyframes graview-thinking{from{opacity:.35}to{opacity:1}}@media (prefers-reduced-motion:reduce){[data-testid=ai-thinking-mark]>span{animation:none!important}}"}),(0,r.jsx)("span",{"aria-hidden":"true",style:ct}),(0,r.jsxs)("span",{children:["Thinking about ",z,"\u2026"]})]}):null]})}function Be(a,i,o){let t=a?.closest("[data-graview-embed]")??document,y=i.on==="list"?[`aggregate:${i.kind}`,`kind:${i.kind}`]:i.on==="lens"&&i.kind?[`aggregate:${i.kind}`]:O(i);for(let u of y)for(let m of t.querySelectorAll(`[data-graview-view="${CSS.escape(u)}"], [data-graview-pick="${CSS.escape(u)}"], [data-graview-record="${CSS.escape(u)}"], [data-graview-listed="${CSS.escape(u)}"]`)){if(a?.contains(m))continue;let b=m.getBoundingClientRect();if(b.width>0&&b.height>0)return m}return o==="pages"?t.querySelector("main [data-graview-page-title]")??t.querySelector("main h1"):null}function ot(a,i){let o={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},t=Math.min(Ke,o.width-2*f),y=a.getBoundingClientRect().height,u=i?.getBoundingClientRect(),m,b,E,C=l=>Math.max(f,Math.min(l,o.height-y-f));if(u&&u.width>0&&u.bottom>0&&u.top<o.height)if(u.right+f+t<=o.width-f)m=u.right+f,b=C(u.top),E="right";else if(u.left-f-t>=f)m=u.left-f-t,b=C(u.top),E="left";else{m=Math.max(f,Math.min(u.left,o.width-t-f));let l=u.bottom+f;b=l+y<=o.height-f?l:C(u.top-f-y),E=l+y<=o.height-f?"below":"above"}else m=(o.width-t)/2,b=C(72),E="top";let $=a.style,g={left:`${Math.round(m)}px`,top:`${Math.round(b)}px`,width:`${Math.round(t)}px`};$.left!==g.left&&($.left=g.left),$.top!==g.top&&($.top=g.top),$.width!==g.width&&($.width=g.width);let q=i?.getAttribute("data-graview-view")??i?.getAttribute("data-graview-pick")??i?.getAttribute("data-graview-record")??i?.getAttribute("data-graview-listed")??(i?"page":"");a.getAttribute("data-quick-ask-beside")!==q&&a.setAttribute("data-quick-ask-beside",q),a.getAttribute("data-quick-ask-side")!==E&&a.setAttribute("data-quick-ask-side",E)}function rt(a,i){let o={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},t=Math.min(Ke,o.width-2*f),y=i.left+t>o.width-f?Math.max(f,o.width-f-t):Math.max(f,i.left),u=240,m=i.top+u>o.height-f?Math.max(f,o.height-f-u):Math.max(f,i.top);a.style.left=`${Math.round(y)}px`,a.style.top=`${Math.round(m)}px`,a.style.width=`${Math.round(t)}px`,a.style.maxHeight=`${Math.round(o.height-m-f)}px`,a.setAttribute("data-quick-ask-side","where-the-menu-stood"),a.setAttribute("data-quick-ask-from",`${Math.round(i.left)},${Math.round(i.top)}`)}function st(a,i){let o=i?.getAttribute("data-graview-view")??i?.getAttribute("data-graview-pick")??i?.getAttribute("data-graview-record")??i?.getAttribute("data-graview-listed")??(i?"page":"");a.getAttribute("data-quick-ask-beside")!==o&&a.setAttribute("data-quick-ask-beside",o)}function lt(a,i){let o=i?.getBoundingClientRect(),t=i?.getAttribute("data-graview-view")??i?.getAttribute("data-graview-pick")??i?.getAttribute("data-graview-record")??i?.getAttribute("data-graview-listed")??(i?"page":"");if(a.getAttribute("data-thinking-on")!==t&&a.setAttribute("data-thinking-on",t),!o||o.width===0){a.style.visibility!=="hidden"&&(a.style.visibility="hidden");return}let y=a.getBoundingClientRect().width,u=`${Math.round(Math.max(f/2,o.right-y-6))}px`,m=`${Math.round(Math.max(f/2,o.top-10))}px`;a.style.left!==u&&(a.style.left=u),a.style.top!==m&&(a.style.top=m),a.style.visibility!=="visible"&&(a.style.visibility="visible")}var dt={position:"fixed",visibility:"hidden",display:"inline-flex",alignItems:"center",gap:6,padding:"2px 8px",borderRadius:999,fontSize:"0.75rem",lineHeight:1.4,whiteSpace:"nowrap",color:"var(--graview-ink)",background:"var(--graview-float)",border:"1px dashed var(--graview-accent)",boxShadow:"var(--graview-lift-low)",pointerEvents:"none"},ct={width:7,height:7,borderRadius:999,background:"var(--graview-accent)",animation:"graview-thinking 1s ease-in-out infinite alternate"},ut={display:"grid",gap:8,padding:10,borderRadius:10,border:"1px dashed var(--graview-accent)",fontSize:"0.875rem"},pt={position:"fixed",inset:"auto",height:"auto",margin:0,zIndex:we("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"},gt={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"},ft={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},ht={display:"flex",alignItems:"center",minHeight:30,padding:"4px 8px",borderRadius:6,cursor:"pointer",overflowWrap:"anywhere"},Z={display:"inline-flex",alignItems:"center",minHeight:30,padding:"2px 10px",font:"inherit",fontSize:"0.8125rem",borderRadius:8};export{$t as QuickAskCard};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk.STPA7HBK.js";import"./chunk.6NG76MDA.js";import"./chunk.35KMZHB7.js";import"./chunk.DEKRFTRN.js";import"./chunk.BKYZSV2Y.js";import"./chunk.IAEGJDF3.js";import"./chunk.YZPESGCP.js";import"./chunk.SY5ID44D.js";import"./chunk.GVT4UUQA.js";import"./chunk.5R744JGZ.js";import"./chunk.O2OL6RQQ.js";import"./chunk.J6HF7IRQ.js";import"./chunk.LRNFE3UK.js";import"./chunk.HJCQ6I3S.js";import"./chunk.YCD4JSXD.js";import"./chunk.ZG5VGP5U.js";import"./chunk.EP6Q32WT.js";import"./chunk.QAM76AXV.js";import"./chunk.Z27NSSYL.js";import"./chunk.WEMUKZKH.js";import"./chunk.T27QKVKP.js";import"./chunk.URQTF5SY.js";import"./chunk.BIDL7GQD.js";import"./chunk.LP2ZMAT2.js";import"./chunk.MSAYU25L.js";import"./chunk.EGPCVMDU.js";import"./chunk.H3EGBDW2.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.6SJEZWH3.js";import"./chunk.6N4PE3U5.js";import"./chunk.B7KZBT27.js";import"./chunk.WVUJXDXZ.js";import"./chunk.DWM7AR5Y.js";import"./chunk.6KJGRM7A.js";import"./chunk.WALVW3KJ.js";import"./chunk.SNHKYH72.js";import"./chunk.UGQYMN4J.js";import"./chunk.RG5G6YQD.js";import"./chunk.MIE4TJRW.js";import"./chunk.QRQ5WPZI.js";import"./chunk.RD2FSSLV.js";import"./chunk.37RFCHSS.js";import"./chunk.SO6NT5K7.js";import"./chunk.MUSMNKE4.js";import"./chunk.SJQPTDAT.js";import"./chunk.JQ63N4MZ.js";import"./chunk.Z3O2VZAJ.js";import"./chunk.QNP5OR3P.js";import"./chunk.4W57E7AX.js";import"./chunk.A5PSEU3W.js";import"./chunk.SDO3U72B.js";import"./chunk.ZEZUKRC6.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{b as declaredLensView,a as formatFor};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as a}from"./chunk.
|
|
1
|
+
import{e as a}from"./chunk.J6HF7IRQ.js";import{l as i}from"./chunk.A5PSEU3W.js";import{de as o}from"./chunk.ZEZUKRC6.js";function p(t){let r=t.within??{};return o({...r.sort?{sort:r.sort}:{},...r.filter?{filter:r.filter}:{},...r.group?{group:r.group}:{},...r.q?{q:r.q}:{},...r.archived?{archived:r.archived}:{}})}function c(t,r){let m=a(r),e=t;for(let n of["sort","filter","group","q","archived"])e=i(e,n,m[n]??null);return e}export{p as a,c as b};
|