graview 0.1.68 → 0.1.69
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.ODYJEDIW.js → chunk.26RYER7Y.js} +1 -1
- package/dist/preview/{chunk.TRNJKHIA.js → chunk.2AL26ZPJ.js} +1 -1
- package/dist/preview/chunk.2WFOKJB4.js +1 -0
- package/dist/preview/chunk.3D37E2G5.js +1 -0
- package/dist/preview/chunk.3PT3BU6K.js +1 -0
- package/dist/preview/{chunk.7ZTGB4O7.js → chunk.3TKIZGC7.js} +1 -1
- package/dist/preview/{chunk.AQ2PI6MR.js → chunk.3VNOTHA5.js} +1 -1
- package/dist/preview/{chunk.QWLK3GKG.js → chunk.3XTIYX6M.js} +1 -1
- package/dist/preview/{chunk.GF3ZCX46.js → chunk.447RWLS7.js} +2 -2
- package/dist/preview/{chunk.E423JCOS.js → chunk.47VEV4BX.js} +1 -1
- package/dist/preview/{chunk.NRCWMYLH.js → chunk.4FJ4OPSJ.js} +1 -1
- package/dist/preview/{chunk.XFH6GHBQ.js → chunk.4O7WYLCK.js} +1 -1
- package/dist/preview/{chunk.MSUZAJ2K.js → chunk.4R7H3GIL.js} +2 -2
- package/dist/preview/{chunk.EB7PZJEO.js → chunk.4RPKCW4J.js} +1 -1
- package/dist/preview/{chunk.YM6SWEUI.js → chunk.523EFGHU.js} +1 -1
- package/dist/preview/chunk.5DU6FA5R.js +1 -0
- package/dist/preview/{chunk.LFFJB6D3.js → chunk.5MOXQUZH.js} +1 -1
- package/dist/preview/chunk.5TWRTGP6.js +1 -0
- package/dist/preview/{chunk.AWV57UBJ.js → chunk.66TRDXYR.js} +1 -1
- package/dist/preview/{chunk.AYZL3LCR.js → chunk.6BNSDPZE.js} +3 -3
- package/dist/preview/chunk.6BR2SUAE.js +1 -0
- package/dist/preview/{chunk.32JE2WS7.js → chunk.6TDVNWFU.js} +1 -1
- package/dist/preview/{chunk.UAMPR4MD.js → chunk.6XBQDXT6.js} +1 -1
- package/dist/preview/{chunk.TVWK3SGD.js → chunk.6ZFYFT5A.js} +1 -1
- package/dist/preview/{chunk.N5Z34V7U.js → chunk.7L3I776Z.js} +1 -1
- package/dist/preview/chunk.7OLKVOS6.js +1 -0
- package/dist/preview/{chunk.MKL4THIV.js → chunk.7T2P42VW.js} +1 -1
- package/dist/preview/{chunk.QM54TGU6.js → chunk.AG7WJYM5.js} +2 -2
- package/dist/preview/{chunk.ECNGVD25.js → chunk.AHYMIVBX.js} +1 -1
- package/dist/preview/chunk.AMAOZVEO.js +1 -0
- package/dist/preview/chunk.AMV2ILR6.js +1 -0
- package/dist/preview/{chunk.RQG672MJ.js → chunk.AUNQNTKY.js} +1 -1
- package/dist/preview/{chunk.HXTKBISQ.js → chunk.AZRICZKT.js} +1 -1
- package/dist/preview/{chunk.L7XKYGV7.js → chunk.B422DSYN.js} +1 -1
- package/dist/preview/{chunk.XDZDNZ7B.js → chunk.B5EFNTDA.js} +1 -1
- package/dist/preview/{chunk.F5GNNVSQ.js → chunk.BO32A3W5.js} +1 -1
- package/dist/preview/{chunk.ZLEBOR5T.js → chunk.BQORHDAH.js} +1 -1
- package/dist/preview/{chunk.4GVKKBQL.js → chunk.BSQI3KM2.js} +1 -1
- package/dist/preview/{chunk.BPNW5KCP.js → chunk.C6CT6F4C.js} +1 -1
- package/dist/preview/{chunk.JV432T4Q.js → chunk.CA2SYEYE.js} +1 -1
- package/dist/preview/{chunk.64LCHHZB.js → chunk.CCCONK73.js} +1 -1
- package/dist/preview/{chunk.GONZB3J3.js → chunk.CDSHUWSK.js} +1 -1
- package/dist/preview/{chunk.NFTPJAMJ.js → chunk.CKSRW3LA.js} +1 -1
- package/dist/preview/{chunk.LOKGUALC.js → chunk.CLIC2QBA.js} +1 -1
- package/dist/preview/{chunk.PLIV3IQK.js → chunk.CLZYNFFH.js} +1 -1
- package/dist/preview/{chunk.GKTQ5CZA.js → chunk.CSVDBDRZ.js} +2 -2
- package/dist/preview/{chunk.GJTEV6CK.js → chunk.CUEIGKFG.js} +1 -1
- package/dist/preview/{chunk.IPGLITWA.js → chunk.CYEPHT7V.js} +1 -1
- package/dist/preview/{chunk.BQAFFEOA.js → chunk.D3SWJ7OS.js} +1 -1
- package/dist/preview/{chunk.ACNOP2IU.js → chunk.D5JZQZ74.js} +1 -1
- package/dist/preview/{chunk.6AANHELP.js → chunk.DHPXRDT5.js} +5 -5
- package/dist/preview/{chunk.R3GE37OI.js → chunk.DKUEZPGR.js} +1 -1
- package/dist/preview/{chunk.2TUEBU7X.js → chunk.DO3FQM6R.js} +1 -1
- package/dist/preview/{chunk.G2BDEWJC.js → chunk.DRAPVGQZ.js} +1 -1
- package/dist/preview/{chunk.6WB2TYK7.js → chunk.DU76ASS4.js} +1 -1
- package/dist/preview/{chunk.AENP662H.js → chunk.EEUCRZA3.js} +1 -1
- package/dist/preview/{chunk.WC5WE34A.js → chunk.EK3JXEZL.js} +1 -1
- package/dist/preview/{chunk.2BMZPALF.js → chunk.EL7XXGQY.js} +1 -1
- package/dist/preview/{chunk.2KCDLCB2.js → chunk.EP7YT7LT.js} +1 -1
- package/dist/preview/{chunk.SS6KL5NT.js → chunk.EQZPEOIW.js} +1 -1
- package/dist/preview/{chunk.VW632VNJ.js → chunk.F4CDJBDS.js} +1 -1
- package/dist/preview/{chunk.O5FTWXA2.js → chunk.FE3SINPK.js} +1 -1
- package/dist/preview/{chunk.JULD4XFB.js → chunk.FIY4RUK5.js} +1 -1
- package/dist/preview/{chunk.3VEZ5MOC.js → chunk.FWXW4T4I.js} +1 -1
- package/dist/preview/{chunk.FSW535EA.js → chunk.G43YUGNW.js} +1 -1
- package/dist/preview/{chunk.QYPU444Y.js → chunk.GF5CZPZ7.js} +1 -1
- package/dist/preview/{chunk.4TT3ZHSJ.js → chunk.GPBHUIZQ.js} +1 -1
- package/dist/preview/{chunk.YL2RBZFE.js → chunk.GTF6EMVE.js} +1 -1
- package/dist/preview/chunk.GVFGS2HY.js +1 -0
- package/dist/preview/{chunk.EGSOHTZZ.js → chunk.HCX6KPRF.js} +1 -1
- package/dist/preview/{chunk.4YAO3A5Q.js → chunk.HGH27XZG.js} +3 -3
- package/dist/preview/{chunk.7WPVLEX2.js → chunk.HMJXB6KC.js} +2 -2
- package/dist/preview/chunk.HTEQCRVP.js +1 -0
- package/dist/preview/{chunk.VTDOWXCP.js → chunk.HU3KEWFO.js} +1 -1
- package/dist/preview/{chunk.DZ6UDZOB.js → chunk.I4H2GS4O.js} +2 -2
- package/dist/preview/{chunk.UD7VLXPM.js → chunk.I7KN732Z.js} +1 -1
- package/dist/preview/{chunk.YBQ5GVAX.js → chunk.I7OFRF6N.js} +2 -2
- package/dist/preview/{chunk.ZKXIZBCN.js → chunk.IAVIYJTL.js} +1 -1
- package/dist/preview/{chunk.CNN32262.js → chunk.IO5VFTXC.js} +1 -1
- package/dist/preview/{chunk.PIMAG4WT.js → chunk.IPKESOIU.js} +2 -2
- package/dist/preview/{chunk.42KHFGN6.js → chunk.IRNEWNUB.js} +1 -1
- package/dist/preview/{chunk.XRE7SHLD.js → chunk.ISZFRLNJ.js} +1 -1
- package/dist/preview/{chunk.GRTBEA7O.js → chunk.IY3DV52G.js} +1 -1
- package/dist/preview/{chunk.VES4XMZX.js → chunk.IYHY4VEC.js} +1 -1
- package/dist/preview/{chunk.HWFJQ42Y.js → chunk.J2N7EKMX.js} +1 -1
- package/dist/preview/{chunk.IT5DVKXY.js → chunk.J7O23NKZ.js} +2 -2
- package/dist/preview/chunk.JDUA5PH2.js +1 -0
- package/dist/preview/{chunk.DCLF4WWZ.js → chunk.JHAMSDAI.js} +1 -1
- package/dist/preview/{chunk.IKKKHHRN.js → chunk.JN3WZGJY.js} +1 -1
- package/dist/preview/{chunk.H4VNIAHN.js → chunk.JPAE6K4E.js} +1 -1
- package/dist/preview/{chunk.DGDW54KE.js → chunk.JQEXH23N.js} +1 -1
- package/dist/preview/{chunk.MPWLDQOG.js → chunk.KEGL6NBD.js} +1 -1
- package/dist/preview/{chunk.EGVM24ND.js → chunk.KHKCTVHD.js} +1 -1
- package/dist/preview/{chunk.VV5JAM5W.js → chunk.KKFKSJUN.js} +1 -1
- package/dist/preview/{chunk.Q6H5HESF.js → chunk.KLEKC4ZX.js} +1 -1
- package/dist/preview/chunk.KVQYOFDV.js +1 -0
- package/dist/preview/{chunk.ZLNUZ6LR.js → chunk.KW7PHJYX.js} +1 -1
- package/dist/preview/{chunk.PPCDPYYU.js → chunk.LAVLPYSC.js} +1 -1
- package/dist/preview/{chunk.FZELUSK5.js → chunk.LGNGFG5V.js} +1 -1
- package/dist/preview/{chunk.SADR3MQI.js → chunk.LKM2R5UF.js} +1 -1
- package/dist/preview/{chunk.42C3FIKK.js → chunk.LMZ2WMGH.js} +1 -1
- package/dist/preview/{chunk.KAM73WVF.js → chunk.MATUPDZ3.js} +1 -1
- package/dist/preview/{chunk.Z2X7BFCB.js → chunk.MD3N26BC.js} +2 -2
- package/dist/preview/{chunk.TFJA4QV4.js → chunk.MH3AQO2R.js} +1 -1
- package/dist/preview/chunk.MHHNO3O2.js +1 -0
- package/dist/preview/{chunk.DMZRFXH7.js → chunk.MKN7ADJB.js} +1 -1
- package/dist/preview/{chunk.ND3DEDWB.js → chunk.ML5EHDZG.js} +1 -1
- package/dist/preview/{chunk.Q4VFLLUT.js → chunk.MUWI54IP.js} +1 -1
- package/dist/preview/{chunk.PZQ5P6WK.js → chunk.MV27WMNW.js} +1 -1
- package/dist/preview/{chunk.6DMCEBSO.js → chunk.N7A3T5QU.js} +1 -1
- package/dist/preview/{chunk.H3IGXHZR.js → chunk.NLZHNPDU.js} +2 -2
- package/dist/preview/{chunk.4DXPPM6T.js → chunk.NRECR3NQ.js} +1 -1
- package/dist/preview/{chunk.LZ6MSQ5O.js → chunk.NSAGOOJW.js} +1 -1
- package/dist/preview/{chunk.LMTG5NPG.js → chunk.O7NYSO6F.js} +1 -1
- package/dist/preview/{chunk.2ME4DVBI.js → chunk.OD5QZHRC.js} +1 -1
- package/dist/preview/{chunk.QUETLFBJ.js → chunk.P26ATAAI.js} +1 -1
- package/dist/preview/{chunk.3JMQKANL.js → chunk.PJL3I2IW.js} +1 -1
- package/dist/preview/{chunk.6IR5LBJU.js → chunk.POKGLN4T.js} +1 -1
- package/dist/preview/{chunk.IXMIU4D4.js → chunk.PZ3KM3TY.js} +1 -1
- package/dist/preview/{chunk.MIOLBZBS.js → chunk.QEBD7SC4.js} +1 -1
- package/dist/preview/{chunk.DPHH5ZVL.js → chunk.QK7EUIPL.js} +1 -1
- package/dist/preview/{chunk.7TDML5YU.js → chunk.QNC2OKLF.js} +1 -1
- package/dist/preview/{chunk.QOQ26NXM.js → chunk.QRNKGPAD.js} +1 -1
- package/dist/preview/{chunk.QZP3ARLH.js → chunk.QVCKTDG3.js} +1 -1
- package/dist/preview/{chunk.2U6HB4XU.js → chunk.R7POSVUK.js} +1 -1
- package/dist/preview/{chunk.UFURYU4R.js → chunk.RNAL35ID.js} +1 -1
- package/dist/preview/{chunk.KUCBNMIY.js → chunk.ROYCJXPE.js} +1 -1
- package/dist/preview/chunk.RZ73YG5K.js +1 -0
- package/dist/preview/{chunk.JLDJZET2.js → chunk.S2NQRD6W.js} +1 -1
- package/dist/preview/{chunk.O32F6LGK.js → chunk.SAWASNDO.js} +1 -1
- package/dist/preview/{chunk.CFE3MHWZ.js → chunk.SCVKHGO3.js} +1 -1
- package/dist/preview/chunk.SM37MNS2.js +1 -0
- package/dist/preview/{chunk.DLSS56EU.js → chunk.T2BZBR7S.js} +1 -1
- package/dist/preview/{chunk.OQ4ZO3YY.js → chunk.T3PELB6I.js} +1 -1
- package/dist/preview/{chunk.TR4YFVZN.js → chunk.TAJBXG5U.js} +1 -1
- package/dist/preview/{chunk.3DEWQDP7.js → chunk.TLPCYKLW.js} +1 -1
- package/dist/preview/{chunk.7K2V5FUB.js → chunk.TQQDUJLX.js} +1 -1
- package/dist/preview/{chunk.CGBOPPNL.js → chunk.TQRC5VAM.js} +1 -1
- package/dist/preview/chunk.U563J5IM.js +1 -0
- package/dist/preview/{chunk.GRBWXTST.js → chunk.UAEOCWSG.js} +1 -1
- package/dist/preview/{chunk.Y7OGJOPA.js → chunk.UHJSZ2XZ.js} +1 -1
- package/dist/preview/{chunk.JGRSUTPJ.js → chunk.UPOYRCKI.js} +1 -1
- package/dist/preview/{chunk.I63462I3.js → chunk.VBBH5R5T.js} +1 -1
- package/dist/preview/chunk.VBYJBW32.js +1 -0
- package/dist/preview/{chunk.HH4D3JEI.js → chunk.VEQIH7HR.js} +1 -1
- package/dist/preview/chunk.VHLL6VC6.js +1 -0
- package/dist/preview/{chunk.VLXLBGMY.js → chunk.VQDL4EEP.js} +1 -1
- package/dist/preview/{chunk.UODTUBQ7.js → chunk.VQOYFBEV.js} +1 -1
- package/dist/preview/{chunk.H3W5C3XQ.js → chunk.VR553M6J.js} +1 -1
- package/dist/preview/{chunk.ENLIIZF2.js → chunk.VXPEXUQF.js} +1 -1
- package/dist/preview/{chunk.Z67LBSQO.js → chunk.W3WXI5B3.js} +1 -1
- package/dist/preview/{chunk.5JKUT2OM.js → chunk.W43XWQRC.js} +1 -1
- package/dist/preview/{chunk.BHJRT57H.js → chunk.WFJCC6G3.js} +1 -1
- package/dist/preview/{chunk.I34BWUB4.js → chunk.WJHLE73Y.js} +1 -1
- package/dist/preview/{chunk.MK5RPEB2.js → chunk.WQ7K5O2I.js} +1 -1
- package/dist/preview/{chunk.EP5JS7ZH.js → chunk.WV6SP6IJ.js} +1 -1
- package/dist/preview/{chunk.XXCHO2A5.js → chunk.YJ4PFOPC.js} +1 -1
- package/dist/preview/{chunk.JCETQQ7J.js → chunk.YZKHTBTC.js} +1 -1
- package/dist/preview/{chunk.CE3NKAF7.js → chunk.ZE5RSKXF.js} +1 -1
- package/dist/preview/{chunk.WV45KLXC.js → chunk.ZQYHNFRZ.js} +1 -1
- package/dist/preview/{chunk.TOUSIUJF.js → chunk.ZT3ZG52B.js} +1 -1
- package/dist/preview/{chunk.O2VXTYUJ.js → chunk.ZU3RPI34.js} +1 -1
- package/dist/preview/index.html +55 -55
- package/dist/preview/page.js +2 -2
- package/package.json +6 -6
- package/dist/preview/chunk.3WPCS6KP.js +0 -1
- package/dist/preview/chunk.5L4ADKTW.js +0 -1
- package/dist/preview/chunk.6ZENHSTQ.js +0 -1
- package/dist/preview/chunk.7OL6H4LF.js +0 -1
- package/dist/preview/chunk.ARS4HJD2.js +0 -1
- package/dist/preview/chunk.C2QKA6XY.js +0 -1
- package/dist/preview/chunk.FHQ25SWY.js +0 -1
- package/dist/preview/chunk.MBTEOF4R.js +0 -1
- package/dist/preview/chunk.N64RVSH3.js +0 -1
- package/dist/preview/chunk.PI4RFOBU.js +0 -1
- package/dist/preview/chunk.Q42R2KW4.js +0 -1
- package/dist/preview/chunk.R66ZVMWB.js +0 -1
- package/dist/preview/chunk.RYA7A4NA.js +0 -1
- package/dist/preview/chunk.SUG6LIOX.js +0 -1
- package/dist/preview/chunk.U7PAFLUM.js +0 -1
- package/dist/preview/chunk.WN7SAAH6.js +0 -1
- package/dist/preview/chunk.ZMADWPJO.js +0 -1
- package/dist/preview/chunk.ZO6VMEPP.js +0 -1
- package/dist/preview/chunk.ZUG7U7AT.js +0 -1
|
@@ -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 y}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 y}from"./chunk.5MOXQUZH.js";import{m as g}from"./chunk.NLZHNPDU.js";import{G as R,La as m,W as c}from"./chunk.FWXW4T4I.js";import{a as f}from"./chunk.SDO3U72B.js";import{ua as p}from"./chunk.DHPXRDT5.js";import{b as u}from"./chunk.AJZBJBMO.js";var o=u(R(),1);var r=u(c(),1),S,h=()=>S??=m(f(()=>(__graviewPreload(import.meta.url,["./chunk.HCX6KPRF.js","./chunk.EP7YT7LT.js","./chunk.I7KN732Z.js","./chunk.TLPCYKLW.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.AHYMIVBX.js"))));function L(e){let[n,t]=(0,o.useState)(()=>h().current);return(0,o.useEffect)(()=>{if(!e||n)return;let i=!0;return h().load().then(a=>i&&t(a),()=>{}),()=>{i=!1}},[e,n]),n}function D(e,n){let t=L(n.length>0);return(0,o.useMemo)(()=>t?t.withLines(e,n):n,[t,e,n])}function I(e,n){let t=L(n.some(i=>i.shape));return(0,o.useMemo)(()=>{let i=new Map;if(!t)return i;for(let a of n){let l=t.ruleLine(a,e);l&&i.set(a.name,l)}return i},[t,e,n])}function M(e){let n=e.line;if(!(!n||e.message.endsWith(` \u2014 ${n.text}`)||e.message===b(e)))return e.message}function b(e){let n=e.line;return n?n.record!==void 0?`${n.record} \u2014 ${n.text}`:n.text:e.message}var P={name:{},op:{color:"var(--graview-ink-muted)",fontWeight:500},value:{fontWeight:600,fontVariantNumeric:"tabular-nums"},word:{color:"var(--graview-ink-muted)"},open:{color:"var(--graview-ink-faint)"},close:{color:"var(--graview-ink-faint)"}};function w({parts:e}){return(0,r.jsx)(r.Fragment,{children:e.map((n,t)=>(0,r.jsxs)("span",{children:[n.space?" ":"",(0,r.jsx)("span",{"data-graview-rule-part":n.as,style:P[n.as],children:n.text})]},t))})}function x(e,n){let t=p(e?.tryDefinition(n),n);return t.charAt(0).toUpperCase()+t.slice(1)}function C({line:e,schema:n,brand:t,lead:i=e.record===void 0?"kind":"record",stacked:a=!1,style:l}){let d=e.kind,s=i==="kind"?d?x(n,d):void 0:i==="record"?e.record:void 0,k=i==="kind"&&s?`${s}: ${e.said}`:i==="record"&&s?`${s} \u2014 ${e.said}`:e.said;return(0,r.jsxs)("span",{"data-graview-rule-line":"",style:{overflowWrap:"anywhere",...l},children:[(0,r.jsx)("span",{style:g,children:k}),(0,r.jsxs)("span",{"aria-hidden":"true",children:[i!=="none"&&d?(0,r.jsx)("span",{style:{display:"inline-flex",verticalAlign:"-0.1em",marginRight:"0.4em"},children:(0,r.jsx)(y,{kind:d,...n?{schema:n}:{},...t?{brand:t}:{},size:13})}):null,s?(0,r.jsxs)("span",{"data-graview-rule-head":"",style:{fontWeight:600,marginRight:i==="record"||a?0:"0.6em"},children:[s,i==="record"&&!a?(0,r.jsx)("span",{style:{color:"var(--graview-ink-faint)",fontWeight:400},children:" \u2014 "}):null]}):null,a&&s?(0,r.jsx)("br",{}):null,(0,r.jsx)(w,{parts:e.parts}),e.when&&e.when.length>0?(0,r.jsxs)("span",{"data-graview-rule-when":"",style:{color:"var(--graview-ink-faint)"},children:[", when ",(0,r.jsx)(w,{parts:e.when})]}):null]})]})}function z(e){return e.line?e.label&&e.label.trim().length>0?e.label:void 0:e.label&&e.label!==e.message&&!e.message.startsWith(e.label)?e.label:void 0}export{D as a,I as b,M as c,C as d,z as e};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as r,b as m,d as k,e as y}from"./chunk.Q355UPFG.js";import"./chunk.
|
|
1
|
+
import{a as r,b as m,d as k,e as y}from"./chunk.Q355UPFG.js";import"./chunk.NLZHNPDU.js";import"./chunk.QNC2OKLF.js";import"./chunk.FWXW4T4I.js";import"./chunk.SDO3U72B.js";import"./chunk.DHPXRDT5.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var i="way-back",b='[data-testid="notices-toasts"]';function g(t){let o=document.activeElement;o!==null&&o!==document.body&&!o.closest(b)||(t??document).querySelector('[data-graview-app-bar] [data-testid="app-home"]')?.focus({preventScroll:!0})}function E(t,o,a,d,h){if(t.past)return a?.dismiss(i),()=>{};let c=h?.closest("[data-graview-embed]"),s,f=e=>{if(e!==void 0&&r(t,o)?.batch!==e)return!1;try{let n=k(t,o);return n&&a?.notify({kind:"toast",id:i,sentence:`Took back \u201C${n.intent}\u201D`}),n!==void 0}catch(n){return a?.notify({kind:"toast",id:i,tone:"warn",sentence:n instanceof Error?n.message:String(n)}),!0}},u=()=>{let e=m(t,o,d);if(d=t.batches().length,e){let n=s=e.batch;a?.notify({kind:"toast",id:i,sentence:e.intent,timeout:1e4,action:{label:"Take back",keys:"Meta+Z Control+Z",onSelect:()=>(g(c),f(n))}})}else s&&r(t,o)?.batch!==s&&(s=void 0,a?.dismiss(i))},l=e=>{y(e)&&(!c||c.contains(e.target))&&f()&&e.preventDefault()};u();let p=t.subscribe(u);return document.addEventListener("keydown",l),(e=!1)=>{p(),document.removeEventListener("keydown",l),e&&s&&a?.dismiss(i)}}export{E as sceneWay};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b,c,d,e,f,g,h,i,j,k}from"./chunk.CCCONK73.js";import"./chunk.IO5VFTXC.js";import"./chunk.WV6SP6IJ.js";import"./chunk.B422DSYN.js";import"./chunk.ZE5RSKXF.js";import"./chunk.DKUEZPGR.js";import"./chunk.EP7YT7LT.js";import"./chunk.I7KN732Z.js";import"./chunk.TLPCYKLW.js";import"./chunk.P26ATAAI.js";import"./chunk.FIY4RUK5.js";import"./chunk.IY3DV52G.js";import"./chunk.DHPXRDT5.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{g as columnActs,d as columnChoices,c as columnMoves,b as columnOf,e as columnReach,f as columnSteps,j as describePlace,k as placeText,h as resolveFor,i as shadowedPageSlots,a as statusColumns};
|
|
@@ -0,0 +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{G as k,La as o,W as n}from"./chunk.FWXW4T4I.js";import{a as t}from"./chunk.SDO3U72B.js";import{b as p}from"./chunk.AJZBJBMO.js";var f=o(t(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.B422DSYN.js","./chunk.ZE5RSKXF.js","./chunk.DKUEZPGR.js","./chunk.EP7YT7LT.js","./chunk.I7KN732Z.js","./chunk.TLPCYKLW.js","./chunk.MIE4TJRW.js","./chunk.SCVKHGO3.js","./chunk.RD2FSSLV.js","./chunk.AZRICZKT.js","./chunk.MH3AQO2R.js","./chunk.J2N7EKMX.js","./chunk.P26ATAAI.js","./chunk.FIY4RUK5.js","./chunk.IY3DV52G.js","./chunk.NLZHNPDU.js","./chunk.QNC2OKLF.js","./chunk.FWXW4T4I.js","./chunk.SDO3U72B.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.QRNKGPAD.js")))),y=f.part((e,r)=>e.drawFiles(r),{quiet:!0});var d=o(t(()=>(__graviewPreload(import.meta.url,["./chunk.MIE4TJRW.js","./chunk.SCVKHGO3.js","./chunk.RD2FSSLV.js","./chunk.AZRICZKT.js","./chunk.MH3AQO2R.js","./chunk.J2N7EKMX.js","./chunk.P26ATAAI.js","./chunk.FIY4RUK5.js","./chunk.IY3DV52G.js","./chunk.NLZHNPDU.js","./chunk.QNC2OKLF.js","./chunk.FWXW4T4I.js","./chunk.SDO3U72B.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.D5JZQZ74.js")))),I=d.part((e,r)=>e.drawLinkedRecord(r),{quiet:!0}),w=d.part((e,r)=>e.drawLinkedPicker(r),{what:"Picking a linked record"});var s=p(n(),1),m=o(t(()=>(__graviewPreload(import.meta.url,["./chunk.MIE4TJRW.js","./chunk.SCVKHGO3.js","./chunk.RD2FSSLV.js","./chunk.AZRICZKT.js","./chunk.MH3AQO2R.js","./chunk.J2N7EKMX.js","./chunk.P26ATAAI.js","./chunk.FIY4RUK5.js","./chunk.IY3DV52G.js","./chunk.NLZHNPDU.js","./chunk.QNC2OKLF.js","./chunk.FWXW4T4I.js","./chunk.SDO3U72B.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.QK7EUIPL.js")))),g=m.part((e,r)=>(0,s.jsx)(e.RepeatPicker,{...r}),{quiet:!0}),E=m.part((e,r)=>(0,s.jsx)(e.RepeatEditor,{...r}),{quiet:!0});var a=p(k(),1),i=p(n(),1),c=o(t(()=>(__graviewPreload(import.meta.url,["./chunk.MH3AQO2R.js","./chunk.J2N7EKMX.js","./chunk.P26ATAAI.js","./chunk.FIY4RUK5.js","./chunk.IY3DV52G.js","./chunk.NLZHNPDU.js","./chunk.QNC2OKLF.js","./chunk.FWXW4T4I.js","./chunk.SDO3U72B.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.TAJBXG5U.js")))),l=c.part((e,r)=>(0,i.jsx)(e.WhenInput,{...r}),{quiet:!0});function M(e){return(0,i.jsx)(a.Suspense,{fallback:(0,i.jsx)("span",{"data-graview-when-arriving":"",style:{display:"inline-block",minHeight:24}}),children:(0,i.jsx)(l,{...e})})}var N=()=>c.load().then(()=>{},()=>{});export{y as a,I as b,w as c,g as d,E as e,M as f,N as g};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk.WVUJXDXZ.js";import{k as m,m as i}from"./chunk.B422DSYN.js";import"./chunk.ZE5RSKXF.js";import"./chunk.DKUEZPGR.js";import"./chunk.EP7YT7LT.js";import"./chunk.I7KN732Z.js";import"./chunk.TLPCYKLW.js";import"./chunk.FIY4RUK5.js";import"./chunk.IY3DV52G.js";import"./chunk.DHPXRDT5.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";function a(t){let r=new Map;return(s,o)=>{let e=o.kind,n=r.get(e);return n===void 0&&r.set(e,n=i(t,e).length),n===0?{}:m(t,s,o).values}}export{a as computedOn};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{c as M}from"./chunk.O32F6LGK.js";import{ga as b}from"./chunk.6AANHELP.js";var k=["owners","status","schedule","budget","places","sources","stock","votes","private","history","publishing","roster","routines","comparison"],y={owners:"people who own things",status:"a status that moves",schedule:"dates it is due by, or a schedule",budget:"money against a budget",places:"places",sources:"sources behind claims",stock:"counts in stock",votes:"votes or picks",private:"private to its owner",history:"a history, a record book",publishing:"content to publish",roster:"a roster of people",routines:"repeating routines",comparison:"a comparison to pick one from"},J={owners:"a person kind (or the people the app has), an owner link, Give it to someone, a rule that every one has somebody on it, and Who has what",status:"a status with named steps (or the one the app has), an act for each step, and a board",schedule:"a due date, Set the date, the on-time rule, and a calendar",budget:"a cost beside the money the app keeps, a budget on the kind it is grouped under, Set the budget, and the over-budget rule",places:"a place kind, a link to one, and a map of where things are",sources:"a source kind, a link from each claim to its source, and the rule that a claim names one",stock:"what is on hand and the reorder level, Count the stock, and the running-low rule",votes:"a vote on each, Vote for it, and a tally",private:"a sight that keeps each person's own records to them",history:"the record book: an era or season each belongs to, and a timeline",publishing:"a published status, Publish it, and what the public sees",roster:"a person kind with the fields a roster keeps, and the list of who is here",routines:"how often each repeats and when it was last done, Mark it done, and the overdue rule",comparison:"a side-by-side of the candidates, one chosen, and Choose it"},U=new Set(["person","people","member","user","player","guest","candidate","participant","traveler","volunteer","interviewer","interviewee","contact","trade","staff","student","employee","teammate","crew","attendee","friend","customer","client","driver","speaker","host","teacher","parent","kid","child","coach","patient","tenant","resident","neighbor","applicant","recruit","contributor","assignee","worker","collaborator","runner"]),K=new Set(["place","venue","location","room","site","building","store","warehouse","city","country","region","address","hall","stadium","office","shelf"]),z=new Set(["source","reference","citation","evidence"]),H=new Set(["season","era","period","epoch","edition","generation","age","campaign","tournament"]),ae=/owner|owned|assign|^lead$|responsible|^by$|^by-|done-?by|interviewer|reviewer|maker|author|keeper|givenby|^for-?person$/i,oe=/due|deadline|until|needed|needby|target|expires|^ends?(on|at)?$|^by$/i,de=/^(date|day|when|at|start|starts|startsat|startson|startdate|scheduled|scheduledfor|scheduledon|happens|happenson|held|heldon|from|time|exchangedate|.*date|.*day)$/i,le=/released|fixed|published|applied|checked|created|added|done|last|first|updated|seen|born|birth|founded|finished|completed|closed/i,X=/status|stage|state|phase|progress/i,W=/budget|limit|cap$|allowance/i,ce=/budget|cost|price|quote|amount|salary|fee|spend|total|paid|owed/i,pe=/^(place|location|venue|address|where|city|town)$/i,B=/reorder|onhand|instock|^stock|quantity|^qty/i,he=/^votes?$|votecount|upvotes|^score$|^points$/i,fe=/^(votes?|votesfor|votedby|voters|picks?|chooses|choices|favorites|likes)$/i,ue=/often|frequency|cadence|^every$|repeat|interval/i,ge=/^last/i,Q=/^(published|live|public)$/i,ye=/count\(.*\bwhere\b.*\)\s*<=\s*1\b/,u=e=>e.toLowerCase(),w=(e,t)=>u(e.kinds[t]?.noun??b(t)),$=(e,t)=>u(e.kinds[t]?.plural??`${w(e,t)}s`),me=e=>e.charAt(0).toUpperCase()+e.slice(1),p=(e,t)=>me($(e,t)),we=e=>/^[aeiou]/i.test(e)?"an":"a",x=(e,t="and")=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} ${t} ${e[e.length-1]}`,N=e=>new Set((e??"").split(/[^A-Za-z0-9_-]+/).filter(Boolean)),v=e=>Object.entries(e.kinds),m=(e,t)=>Object.entries(e.acts??{}).filter(([,s])=>[s.on??[]].flat().includes(t)),_=e=>Array.isArray(e.lenses)?e.lenses:[],I=e=>typeof e.title=="string"?e.title:void 0,A=e=>e.bindings&&typeof e.bindings=="object"?e.bindings:{},R=(e,t)=>Array.isArray(t)&&t.length===1&&typeof t[0]=="string"&&e.kinds[t[0]]?t[0]:void 0;function V(e,t){let s=e.kinds[t];if(!s)return!1;let r=n=>u(n).replace(/ll/g,"l");return s.people===!0||U.has(r(t))||U.has(r(w(e,t)))}var Y=(e,t)=>K.has(u(t))||K.has(w(e,t)),ke=(e,t)=>z.has(u(t))||z.has(w(e,t)),be=(e,t)=>H.has(u(t))||H.has(w(e,t)),$e=(e,t)=>(t.type==="number"||t.type==="integer")&&(t.format==="money"||ce.test(e)),j=e=>e.type==="date"||e.type==="datetime";function P(e,t,s,r,n){return _(e).filter(d=>d.name===t&&A(d)[s]?.[r]===n).map(I).filter(d=>d!==void 0)}function D(e,t,s,r){return _(e).filter(n=>n.name==="coverage"&&A(n)[s]?.kind===t&&(r===void 0||A(n).link?.edge===r)).map(I).filter(n=>n!==void 0)}function f(e,t,s){let r=new Set(t);return Object.entries(e.rules??{}).filter(([,n])=>(s===void 0||n.over==="graph"||s.includes(n.over))&&[...N(`${n.when??""} ${n.require??""} ${n.says??""}`)].some(d=>r.has(d))).map(([n])=>n)}var G=class{kinds=new Set;fields=new Set;relations=new Set;rules=new Set;lenses=new Set;acts=new Set;said;add=(t,...s)=>{for(let r of s)this[t].add(r)};say=t=>{this.said??=t};any=()=>this.kinds.size+this.fields.size+this.relations.size+this.rules.size+this.lenses.size+this.acts.size>0;asTrait=t=>({trait:t,words:y[t],said:this.said??y[t],kinds:[...this.kinds],fields:[...this.fields],relations:[...this.relations],rules:[...this.rules],lenses:[...this.lenses],acts:[...this.acts]})};function ve(e){let t;for(let[s,r]of v(e)){let n=Object.keys(r.fields).length+Object.keys(r.edges??{}).length;(!t||n>t.fields)&&(t={kind:s,fields:n})}return t?.kind}function g(e){let t=ve(e);return v(e).sort(([s],[r])=>+(r===t)-+(s===t))}function Z(e,t){let s=e.kinds[t];if(!s)return[];let r=[];for(let[n,d]of Object.entries(s.fields)){if(d.type!=="enum"||!Array.isArray(d.options)||d.options.length<2)continue;let i=m(e,t).filter(([,a])=>typeof a.sets?.[n]=="string"&&d.options.includes(a.sets[n])).map(([a])=>a);((X.test(n)||s.lifecycle?.field===n)&&i.length>=1||i.length>=2)&&r.push({field:n,options:d.options,steps:i})}return r}var ee={owners(e,t){for(let[s,r]of g(e))for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);d.cardinality!=="one"||!i||!V(e,i)||!ae.test(n)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n],[s,i])),t.add("lenses",...D(e,s,"rows",n)),t.add("acts",...m(e,s).filter(([,o])=>o.connects===n||o.severs===n).map(([o])=>o)),t.say(`Each ${w(e,s)} has one of the ${$(e,i)} on it (${n}).`))}},status(e,t){for(let[s]of g(e))for(let{field:r,options:n,steps:d}of Z(e,s))t.add("kinds",s),t.add("fields",`${s}.${r}`),t.add("acts",...d),t.add("rules",...f(e,[r],[s])),t.add("lenses",...P(e,"columns",s,"column",r)),t.say(`${p(e,s)} move through ${x(n.map(u))}.`)},schedule(e,t){for(let[s,r]of g(e))for(let[n,d]of Object.entries(r.fields)){if(!j(d)||le.test(n))continue;let i=P(e,"calendar",s,"start",n),o=oe.test(n);if(!o&&!de.test(n)&&i.length===0)continue;t.add("kinds",s),t.add("fields",`${s}.${n}`),t.add("lenses",...i),t.add("rules",...f(e,[n],[s])),t.add("acts",...m(e,s).filter(([,l])=>(l.writes??[]).includes(n)||l.sets?.[n]!==void 0).map(([l])=>l));let a=/date|day|when|time/i.test(n)?u(b(n)):`date (${n})`;t.say(o?`${p(e,s)} are due by a date (${n}).`:`${p(e,s)} have ${we(a)} ${a}${i.length>0?", on a calendar":""}.`)}},budget(e,t){let s=v(e).flatMap(([o,a])=>Object.entries(a.fields).filter(([l,h])=>(h.type==="number"||h.type==="integer")&&W.test(l)).map(([l])=>({kind:o,name:l})));if(s.length===0)return;let r=g(e).flatMap(([o,a])=>Object.entries(a.fields).filter(([l,h])=>$e(l,h)&&!W.test(l)).map(([l])=>({kind:o,name:l})));if(r.length===0)return;let n=[...s,...r].map(o=>o.name);for(let o of[...s,...r])t.add("kinds",o.kind),t.add("fields",`${o.kind}.${o.name}`),t.add("acts",...m(e,o.kind).filter(([,a])=>(a.writes??[]).includes(o.name)||a.sets?.[o.name]!==void 0).map(([a])=>a));t.add("rules",...f(e,n).filter(o=>s.some(a=>N(e.rules[o].require??"").has(a.name))));let d=r[0],i=s.find(o=>o.kind===d.kind)??s[0];t.say(`${p(e,d.kind)}' ${u(b(d.name))} against ${i.kind===d.kind?"each one's":`each ${w(e,i.kind)}'s`} ${u(b(i.name))}.`)},places(e,t){for(let[s,r]of g(e)){Y(e,s)&&(t.add("kinds",s),t.add("lenses",...D(e,s,"columns")));for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);!i||!Y(e,i)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n],[s,i])),t.say(`${p(e,s)} are at ${$(e,i)} (${n}).`))}for(let[n,d]of Object.entries(r.fields))d.type!=="place"&&!(d.type==="string"&&pe.test(n))||(t.add("kinds",s),t.add("fields",`${s}.${n}`),t.say(`${p(e,s)} say where (${n}).`))}t.any()&&!t.said&&t.say(`${x([...t.kinds].map(s=>p(e,s)))} are places.`)},sources(e,t){for(let[s,r]of g(e)){for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);!i||!ke(e,i)&&!/^cite/i.test(n)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n,i],[s,i])),t.add("acts",...m(e,s).filter(([,o])=>o.connects===n||o.severs===n).map(([o])=>o)),t.say(`${p(e,s)} cite ${$(e,i)} (${n}).`))}for(let[n,d]of Object.entries(r.fields))d.type!=="url"||!/^source/i.test(n)||(t.add("kinds",s),t.add("fields",`${s}.${n}`),t.add("rules",...f(e,[n],[s])),t.say(`${p(e,s)} link to their source (${n}).`))}},stock(e,t){for(let[s,r]of g(e)){let n=Object.entries(r.fields).filter(([a,l])=>(l.type==="number"||l.type==="integer")&&B.test(a)).map(([a])=>a),d=Object.keys(r.computed??{}).filter(a=>B.test(a)),i=n.some(a=>/reorder/i.test(a)),o=v(e).some(([,a])=>Object.entries(a.fields).some(([l,h])=>/^(change|delta|moved)$/i.test(l)&&(h.type==="number"||h.type==="integer")));!i&&!(d.length+n.length>0&&o)||(t.add("kinds",s),t.add("fields",...n.map(a=>`${s}.${a}`),...d.map(a=>`${s}.${a}`)),t.add("rules",...f(e,[...n,...d],[s])),t.add("acts",...m(e,s).filter(([,a])=>n.some(l=>(a.writes??[]).includes(l)||a.sets?.[l]!==void 0)).map(([a])=>a)),t.say(`${p(e,s)} have a count in stock${i?" and a reorder point":""}.`))}},votes(e,t){for(let[s,r]of g(e)){for(let[n,d]of Object.entries(r.fields)){if(d.type!=="number"&&d.type!=="integer"||!he.test(n))continue;let i=m(e,s).filter(([,o])=>o.sets?.[n]!==void 0).map(([o])=>o);i.length!==0&&(t.add("kinds",s),t.add("fields",`${s}.${n}`),t.add("acts",...i),t.add("rules",...f(e,[n],[s])),t.say(`${p(e,s)} collect votes (${n}).`))}for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);!i||!fe.test(n)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n],[s,i])),t.add("acts",...m(e,s).filter(([,o])=>o.connects===n||o.severs===n).map(([o])=>o)),t.say(`${p(e,s)} pick ${$(e,i)} (${n}).`))}}},private(e,t){let s=[];for(let r of e.policy?.sees??[])if(!(!r.own&&!r.via)){for(let n of r.kinds)if(e.kinds[n]&&(t.add("kinds",n),s.includes(n)||s.push(n),r.via))for(let[d,i]of v(e))i.edges?.[r.via]&&t.add("relations",`${d}.${r.via}`)}s.length>0&&t.say(`${x(s.map(r=>p(e,r)))} are seen only by whose they are.`)},history(e,t){for(let[s,r]of g(e))for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);d.cardinality!=="one"||!i||!be(e,i)||!Object.entries(r.fields).some(([a,l])=>j(l)||/year|result|outcome|score|finish/i.test(a))||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n,i],[s,i])),t.add("lenses",...D(e,s,"rows",n),..._(e).filter(a=>a.name==="timeline"&&A(a)[s]!==void 0).map(I).filter(a=>a!==void 0)),t.say(`${p(e,s)} grouped into ${$(e,i)}, a record book.`))}},publishing(e,t){for(let[s,r]of g(e)){let n=Object.entries(r.fields).filter(([,i])=>i.type==="text").map(([i])=>i);if(n.length===0)continue;let d=Z(e,s).map(i=>i.field);for(let[i,o]of Object.entries(r.fields)){if(o.type!=="enum"||!(X.test(i)||d.includes(i))||!(o.options??[]).some(l=>Q.test(l)))continue;let a=(o.options??[]).find(l=>Q.test(l));t.add("kinds",s),t.add("fields",`${s}.${i}`,...n.map(l=>`${s}.${l}`)),t.add("acts",...m(e,s).filter(([,l])=>l.sets?.[i]===a).map(([l])=>l)),t.add("rules",...f(e,[i,...n],[s]).filter(l=>N(`${e.rules[l].when??""} ${e.rules[l].require??""}`).has(a)||n.some(h=>N(e.rules[l].require??"").has(h)))),t.say(`${p(e,s)} go from ${u(o.options[0])} to ${u(a)}, with their words.`)}}},roster(e,t){for(let[s,r]of g(e)){if(!V(e,s))continue;let n=Object.keys(r.fields);n.length<2||(t.add("kinds",s),t.add("fields",...n.map(d=>`${s}.${d}`)),t.add("lenses",...D(e,s,"columns"),...D(e,s,"rows")),t.say(`${p(e,s)}, with ${x(n.slice(1).map(d=>u(b(d))))}.`))}},routines(e,t){for(let[s,r]of g(e)){let n=Object.entries(r.fields).filter(([,a])=>j(a)&&a.repeats===!0).map(([a])=>a),d=Object.entries(r.fields).filter(([a,l])=>(l.type==="enum"||l.type==="string"||l.type==="integer"||l.type==="number")&&ue.test(a)).map(([a])=>a),i=Object.entries(r.fields).filter(([a,l])=>j(l)&&ge.test(a)).map(([a])=>a);if(n.length===0&&!(d.length>0&&i.length>0))continue;let o=[...n,...d,...i];t.add("kinds",s),t.add("fields",...o.map(a=>`${s}.${a}`)),t.add("rules",...f(e,o,[s])),t.add("lenses",...o.flatMap(a=>P(e,"calendar",s,"start",a))),t.add("acts",...m(e,s).filter(([,a])=>o.some(l=>(a.writes??[]).includes(l)||a.sets?.[l]!==void 0)).map(([a])=>a)),t.say(n.length>0?`${p(e,s)} repeat (${n[0]}).`:`${p(e,s)} come round again, each with when it was last done.`)}},comparison(e,t){for(let[s,r]of Object.entries(e.rules??{})){if(!r.require||!ye.test(r.require))continue;let n=r.over==="graph"?void 0:r.over,d=/in\('([^']+)'\)/.exec(r.require)?.[1],i=/all\('([^']+)'/.exec(r.require)?.[1],o=n?d?v(e).find(([,l])=>l.edges?.[d])?.[0]:void 0:i&&e.kinds[i]?i:void 0;if(!o&&!n)continue;let a=/==\s*'([^']+)'/.exec(r.require)?.[1];t.add("kinds",...o?[o]:[],...n?[n]:[]),t.add("rules",s),o&&a&&t.add("acts",...m(e,o).filter(([,l])=>Object.values(l.sets??{}).includes(a)).map(([l])=>l)),t.say(o&&n?`${p(e,o)} compared within each ${w(e,n)}, one ${a??"chosen"}.`:o?`${p(e,o)} compared, one ${a??"chosen"}.`:`One ${a??"chosen"} per ${w(e,n)}.`)}}};function E(e){let t=[];for(let s of k){let r=new G;ee[s](e,r),r.any()&&t.push(r.asTrait(s))}return t}function L(e,t){let s=new G;return ee[t](e,s),s.any()}var Oe=e=>Math.round(Math.max(0,Math.min(1,e))*100)/100;function q(e){return e?.type==="noul"&&Number.isFinite(e.noul)?Oe(e.noul):void 0}var Re={add:.7,drop:.7},Fe="propose_change";function Me(e){return M(e)}var De=e=>e.toLowerCase(),Te=e=>e.charAt(0).toUpperCase()+e.slice(1),O=(e,t="and")=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} ${t} ${e[e.length-1]}`,Se=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").toLowerCase(),T=(e,t)=>{let s=e.kinds[t];return De(s?.plural??(s?.noun?`${s.noun}s`:`${Se(t)}s`))},xe=e=>k.includes(e),se=(e,t)=>k.indexOf(e)-k.indexOf(t);function je(e){let t=E(e),s=new Set(t.map(r=>r.trait));return{name:e.name,keeps:Object.keys(e.kinds).map(r=>T(e,r)),"made of":t.map(r=>r.said),lacks:k.filter(r=>!s.has(r)).map(r=>y[r])}}function Ne(e,t){let s=new Set(E(t).map(n=>n.trait)),r={};for(let n of k)s.has(n)||(r[`need:${n}`]={type:"noul",instructions:`Does what they asked for need ${y[n]}, which ${t.name} has no part for yet?`,criteria:{true:`It needs ${y[n]}: they asked for it, or what they asked for cannot be kept without it.`,false:"Not asked for, and not needed to keep what they asked for."}});for(let n of Object.keys(t.kinds)){let d=T(t,n);r[`drop:kind:${n}`]={type:"noul",instructions:`Did they ask ${t.name} to stop keeping ${d}?`,criteria:{true:`They said the ${d} go: to drop them, remove them or stop tracking them.`,false:`${Te(d)} stay: nothing they said asks for them to go.`}}}for(let n of k)s.has(n)&&(r[`drop:trait:${n}`]={type:"noul",instructions:`Did they ask ${t.name} to stop having ${y[n]}?`,criteria:{true:`They said it goes: to drop or stop ${y[n]}.`,false:"It stays: nothing they said asks for it to go."}});return{state:{said:e,app:je(t)},questions:r}}var te=/^drop:(kind|trait):(.+)$/s;function Ae(e,t={}){let s={...Re,...t},r=Object.keys(e);if(r.length===0)throw new Error("readReshape was handed no answers.");let n=r.filter(o=>!/^need:/.test(o)&&!te.test(o));if(n.length>0)throw new Error(`readReshape does not know the question ${n.map(o=>`"${o}"`).join(", ")}: it reads need:<trait>, drop:kind:<name> and drop:trait:<name>.`);let d={},i={};for(let[o,a]of Object.entries(e)){let l=te.exec(o);if(l){i[`${l[1]}:${l[2]}`]=q(a)??0;continue}let h=o.slice(5);xe(h)&&(d[h]=q(a)??0)}return{add:Object.keys(d).filter(o=>d[o]>=s.add).sort(se),drop:Object.entries(i).filter(([,o])=>o>=s.drop).map(([o])=>o.slice(o.indexOf(":")+1)),needs:d,drops:i}}function Ge(e){let{said:t,document:s}=e,r=[...new Set(e.add)].sort(se),n=[...new Set(e.drop)],d=E(s),i=r.filter(c=>!L(s,c)).map(c=>({what:"trait",name:c,words:y[c],brings:J[c]})),o=r.filter(c=>L(s,c)),a=Object.keys(s.kinds).filter(c=>n.includes(c)),l=d.filter(c=>n.includes(c.trait)&&!Object.hasOwn(s.kinds,c.trait)),h=[...a.map(c=>({what:"kind",name:c,words:T(s,c)})),...l.map(c=>({what:"trait",name:c.trait,words:y[c.trait]}))],C=Object.keys(s.kinds).filter(c=>!a.includes(c)).map(c=>({what:"kind",name:c,words:T(s,c)})),ne=[...a.map(c=>`All ${T(s,c)} records go, with their links.`),...l.flatMap(c=>{let F=[...c.fields,...c.relations];return F.length>0?[`What carries ${y[c.trait]} goes: ${O(F)}, with its values and links.`]:[]})],S=[];i.length>0&&S.push(`adds ${O(i.map(c=>c.words))}`),h.length>0&&S.push(`drops ${O(h.map(c=>c.words))}`),C.length>0&&S.push(`keeps ${O(C.map(c=>c.words))}`);let re=i.length+h.length===0?`Nothing in ${s.name} changes for that.`:`This ${O(S)}.`,ie=o.length>0?` ${s.name} already has ${O(o.map(c=>y[c]))}.`:"";return{said:t,add:i.map(c=>c.name),drop:h.map(c=>c.name),card:{said:`${re}${ie}`,adds:i,keeps:C,drops:h,breaking:ne}}}async function Ue(e){let{state:t,questions:s}=Ne(e.said,e.document),{answers:r,usage:n}=await e.decide(t,s),d=Ae(r,e.thresholds??{}),i=d.add.length+d.drop.length===0?null:Ge({said:e.said,document:e.document,add:d.add,drop:d.drop});return{proposal:i&&i.add.length+i.drop.length===0?null:i,reading:d,answers:r,usage:n}}export{Fe as a,Me as b,Ne as c,Ae as d,Ge as e,Ue as f};
|
|
1
|
+
import{c as M}from"./chunk.SAWASNDO.js";import{ga as b}from"./chunk.DHPXRDT5.js";var k=["owners","status","schedule","budget","places","sources","stock","votes","private","history","publishing","roster","routines","comparison"],y={owners:"people who own things",status:"a status that moves",schedule:"dates it is due by, or a schedule",budget:"money against a budget",places:"places",sources:"sources behind claims",stock:"counts in stock",votes:"votes or picks",private:"private to its owner",history:"a history, a record book",publishing:"content to publish",roster:"a roster of people",routines:"repeating routines",comparison:"a comparison to pick one from"},J={owners:"a person kind (or the people the app has), an owner link, Give it to someone, a rule that every one has somebody on it, and Who has what",status:"a status with named steps (or the one the app has), an act for each step, and a board",schedule:"a due date, Set the date, the on-time rule, and a calendar",budget:"a cost beside the money the app keeps, a budget on the kind it is grouped under, Set the budget, and the over-budget rule",places:"a place kind, a link to one, and a map of where things are",sources:"a source kind, a link from each claim to its source, and the rule that a claim names one",stock:"what is on hand and the reorder level, Count the stock, and the running-low rule",votes:"a vote on each, Vote for it, and a tally",private:"a sight that keeps each person's own records to them",history:"the record book: an era or season each belongs to, and a timeline",publishing:"a published status, Publish it, and what the public sees",roster:"a person kind with the fields a roster keeps, and the list of who is here",routines:"how often each repeats and when it was last done, Mark it done, and the overdue rule",comparison:"a side-by-side of the candidates, one chosen, and Choose it"},U=new Set(["person","people","member","user","player","guest","candidate","participant","traveler","volunteer","interviewer","interviewee","contact","trade","staff","student","employee","teammate","crew","attendee","friend","customer","client","driver","speaker","host","teacher","parent","kid","child","coach","patient","tenant","resident","neighbor","applicant","recruit","contributor","assignee","worker","collaborator","runner"]),K=new Set(["place","venue","location","room","site","building","store","warehouse","city","country","region","address","hall","stadium","office","shelf"]),z=new Set(["source","reference","citation","evidence"]),H=new Set(["season","era","period","epoch","edition","generation","age","campaign","tournament"]),ae=/owner|owned|assign|^lead$|responsible|^by$|^by-|done-?by|interviewer|reviewer|maker|author|keeper|givenby|^for-?person$/i,oe=/due|deadline|until|needed|needby|target|expires|^ends?(on|at)?$|^by$/i,de=/^(date|day|when|at|start|starts|startsat|startson|startdate|scheduled|scheduledfor|scheduledon|happens|happenson|held|heldon|from|time|exchangedate|.*date|.*day)$/i,le=/released|fixed|published|applied|checked|created|added|done|last|first|updated|seen|born|birth|founded|finished|completed|closed/i,X=/status|stage|state|phase|progress/i,W=/budget|limit|cap$|allowance/i,ce=/budget|cost|price|quote|amount|salary|fee|spend|total|paid|owed/i,pe=/^(place|location|venue|address|where|city|town)$/i,B=/reorder|onhand|instock|^stock|quantity|^qty/i,he=/^votes?$|votecount|upvotes|^score$|^points$/i,fe=/^(votes?|votesfor|votedby|voters|picks?|chooses|choices|favorites|likes)$/i,ue=/often|frequency|cadence|^every$|repeat|interval/i,ge=/^last/i,Q=/^(published|live|public)$/i,ye=/count\(.*\bwhere\b.*\)\s*<=\s*1\b/,u=e=>e.toLowerCase(),w=(e,t)=>u(e.kinds[t]?.noun??b(t)),$=(e,t)=>u(e.kinds[t]?.plural??`${w(e,t)}s`),me=e=>e.charAt(0).toUpperCase()+e.slice(1),p=(e,t)=>me($(e,t)),we=e=>/^[aeiou]/i.test(e)?"an":"a",x=(e,t="and")=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} ${t} ${e[e.length-1]}`,N=e=>new Set((e??"").split(/[^A-Za-z0-9_-]+/).filter(Boolean)),v=e=>Object.entries(e.kinds),m=(e,t)=>Object.entries(e.acts??{}).filter(([,s])=>[s.on??[]].flat().includes(t)),_=e=>Array.isArray(e.lenses)?e.lenses:[],I=e=>typeof e.title=="string"?e.title:void 0,A=e=>e.bindings&&typeof e.bindings=="object"?e.bindings:{},R=(e,t)=>Array.isArray(t)&&t.length===1&&typeof t[0]=="string"&&e.kinds[t[0]]?t[0]:void 0;function V(e,t){let s=e.kinds[t];if(!s)return!1;let r=n=>u(n).replace(/ll/g,"l");return s.people===!0||U.has(r(t))||U.has(r(w(e,t)))}var Y=(e,t)=>K.has(u(t))||K.has(w(e,t)),ke=(e,t)=>z.has(u(t))||z.has(w(e,t)),be=(e,t)=>H.has(u(t))||H.has(w(e,t)),$e=(e,t)=>(t.type==="number"||t.type==="integer")&&(t.format==="money"||ce.test(e)),j=e=>e.type==="date"||e.type==="datetime";function P(e,t,s,r,n){return _(e).filter(d=>d.name===t&&A(d)[s]?.[r]===n).map(I).filter(d=>d!==void 0)}function D(e,t,s,r){return _(e).filter(n=>n.name==="coverage"&&A(n)[s]?.kind===t&&(r===void 0||A(n).link?.edge===r)).map(I).filter(n=>n!==void 0)}function f(e,t,s){let r=new Set(t);return Object.entries(e.rules??{}).filter(([,n])=>(s===void 0||n.over==="graph"||s.includes(n.over))&&[...N(`${n.when??""} ${n.require??""} ${n.says??""}`)].some(d=>r.has(d))).map(([n])=>n)}var G=class{kinds=new Set;fields=new Set;relations=new Set;rules=new Set;lenses=new Set;acts=new Set;said;add=(t,...s)=>{for(let r of s)this[t].add(r)};say=t=>{this.said??=t};any=()=>this.kinds.size+this.fields.size+this.relations.size+this.rules.size+this.lenses.size+this.acts.size>0;asTrait=t=>({trait:t,words:y[t],said:this.said??y[t],kinds:[...this.kinds],fields:[...this.fields],relations:[...this.relations],rules:[...this.rules],lenses:[...this.lenses],acts:[...this.acts]})};function ve(e){let t;for(let[s,r]of v(e)){let n=Object.keys(r.fields).length+Object.keys(r.edges??{}).length;(!t||n>t.fields)&&(t={kind:s,fields:n})}return t?.kind}function g(e){let t=ve(e);return v(e).sort(([s],[r])=>+(r===t)-+(s===t))}function Z(e,t){let s=e.kinds[t];if(!s)return[];let r=[];for(let[n,d]of Object.entries(s.fields)){if(d.type!=="enum"||!Array.isArray(d.options)||d.options.length<2)continue;let i=m(e,t).filter(([,a])=>typeof a.sets?.[n]=="string"&&d.options.includes(a.sets[n])).map(([a])=>a);((X.test(n)||s.lifecycle?.field===n)&&i.length>=1||i.length>=2)&&r.push({field:n,options:d.options,steps:i})}return r}var ee={owners(e,t){for(let[s,r]of g(e))for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);d.cardinality!=="one"||!i||!V(e,i)||!ae.test(n)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n],[s,i])),t.add("lenses",...D(e,s,"rows",n)),t.add("acts",...m(e,s).filter(([,o])=>o.connects===n||o.severs===n).map(([o])=>o)),t.say(`Each ${w(e,s)} has one of the ${$(e,i)} on it (${n}).`))}},status(e,t){for(let[s]of g(e))for(let{field:r,options:n,steps:d}of Z(e,s))t.add("kinds",s),t.add("fields",`${s}.${r}`),t.add("acts",...d),t.add("rules",...f(e,[r],[s])),t.add("lenses",...P(e,"columns",s,"column",r)),t.say(`${p(e,s)} move through ${x(n.map(u))}.`)},schedule(e,t){for(let[s,r]of g(e))for(let[n,d]of Object.entries(r.fields)){if(!j(d)||le.test(n))continue;let i=P(e,"calendar",s,"start",n),o=oe.test(n);if(!o&&!de.test(n)&&i.length===0)continue;t.add("kinds",s),t.add("fields",`${s}.${n}`),t.add("lenses",...i),t.add("rules",...f(e,[n],[s])),t.add("acts",...m(e,s).filter(([,l])=>(l.writes??[]).includes(n)||l.sets?.[n]!==void 0).map(([l])=>l));let a=/date|day|when|time/i.test(n)?u(b(n)):`date (${n})`;t.say(o?`${p(e,s)} are due by a date (${n}).`:`${p(e,s)} have ${we(a)} ${a}${i.length>0?", on a calendar":""}.`)}},budget(e,t){let s=v(e).flatMap(([o,a])=>Object.entries(a.fields).filter(([l,h])=>(h.type==="number"||h.type==="integer")&&W.test(l)).map(([l])=>({kind:o,name:l})));if(s.length===0)return;let r=g(e).flatMap(([o,a])=>Object.entries(a.fields).filter(([l,h])=>$e(l,h)&&!W.test(l)).map(([l])=>({kind:o,name:l})));if(r.length===0)return;let n=[...s,...r].map(o=>o.name);for(let o of[...s,...r])t.add("kinds",o.kind),t.add("fields",`${o.kind}.${o.name}`),t.add("acts",...m(e,o.kind).filter(([,a])=>(a.writes??[]).includes(o.name)||a.sets?.[o.name]!==void 0).map(([a])=>a));t.add("rules",...f(e,n).filter(o=>s.some(a=>N(e.rules[o].require??"").has(a.name))));let d=r[0],i=s.find(o=>o.kind===d.kind)??s[0];t.say(`${p(e,d.kind)}' ${u(b(d.name))} against ${i.kind===d.kind?"each one's":`each ${w(e,i.kind)}'s`} ${u(b(i.name))}.`)},places(e,t){for(let[s,r]of g(e)){Y(e,s)&&(t.add("kinds",s),t.add("lenses",...D(e,s,"columns")));for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);!i||!Y(e,i)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n],[s,i])),t.say(`${p(e,s)} are at ${$(e,i)} (${n}).`))}for(let[n,d]of Object.entries(r.fields))d.type!=="place"&&!(d.type==="string"&&pe.test(n))||(t.add("kinds",s),t.add("fields",`${s}.${n}`),t.say(`${p(e,s)} say where (${n}).`))}t.any()&&!t.said&&t.say(`${x([...t.kinds].map(s=>p(e,s)))} are places.`)},sources(e,t){for(let[s,r]of g(e)){for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);!i||!ke(e,i)&&!/^cite/i.test(n)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n,i],[s,i])),t.add("acts",...m(e,s).filter(([,o])=>o.connects===n||o.severs===n).map(([o])=>o)),t.say(`${p(e,s)} cite ${$(e,i)} (${n}).`))}for(let[n,d]of Object.entries(r.fields))d.type!=="url"||!/^source/i.test(n)||(t.add("kinds",s),t.add("fields",`${s}.${n}`),t.add("rules",...f(e,[n],[s])),t.say(`${p(e,s)} link to their source (${n}).`))}},stock(e,t){for(let[s,r]of g(e)){let n=Object.entries(r.fields).filter(([a,l])=>(l.type==="number"||l.type==="integer")&&B.test(a)).map(([a])=>a),d=Object.keys(r.computed??{}).filter(a=>B.test(a)),i=n.some(a=>/reorder/i.test(a)),o=v(e).some(([,a])=>Object.entries(a.fields).some(([l,h])=>/^(change|delta|moved)$/i.test(l)&&(h.type==="number"||h.type==="integer")));!i&&!(d.length+n.length>0&&o)||(t.add("kinds",s),t.add("fields",...n.map(a=>`${s}.${a}`),...d.map(a=>`${s}.${a}`)),t.add("rules",...f(e,[...n,...d],[s])),t.add("acts",...m(e,s).filter(([,a])=>n.some(l=>(a.writes??[]).includes(l)||a.sets?.[l]!==void 0)).map(([a])=>a)),t.say(`${p(e,s)} have a count in stock${i?" and a reorder point":""}.`))}},votes(e,t){for(let[s,r]of g(e)){for(let[n,d]of Object.entries(r.fields)){if(d.type!=="number"&&d.type!=="integer"||!he.test(n))continue;let i=m(e,s).filter(([,o])=>o.sets?.[n]!==void 0).map(([o])=>o);i.length!==0&&(t.add("kinds",s),t.add("fields",`${s}.${n}`),t.add("acts",...i),t.add("rules",...f(e,[n],[s])),t.say(`${p(e,s)} collect votes (${n}).`))}for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);!i||!fe.test(n)||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n],[s,i])),t.add("acts",...m(e,s).filter(([,o])=>o.connects===n||o.severs===n).map(([o])=>o)),t.say(`${p(e,s)} pick ${$(e,i)} (${n}).`))}}},private(e,t){let s=[];for(let r of e.policy?.sees??[])if(!(!r.own&&!r.via)){for(let n of r.kinds)if(e.kinds[n]&&(t.add("kinds",n),s.includes(n)||s.push(n),r.via))for(let[d,i]of v(e))i.edges?.[r.via]&&t.add("relations",`${d}.${r.via}`)}s.length>0&&t.say(`${x(s.map(r=>p(e,r)))} are seen only by whose they are.`)},history(e,t){for(let[s,r]of g(e))for(let[n,d]of Object.entries(r.edges??{})){let i=R(e,d.to);d.cardinality!=="one"||!i||!be(e,i)||!Object.entries(r.fields).some(([a,l])=>j(l)||/year|result|outcome|score|finish/i.test(a))||(t.add("kinds",s,i),t.add("relations",`${s}.${n}`),t.add("rules",...f(e,[n,i],[s,i])),t.add("lenses",...D(e,s,"rows",n),..._(e).filter(a=>a.name==="timeline"&&A(a)[s]!==void 0).map(I).filter(a=>a!==void 0)),t.say(`${p(e,s)} grouped into ${$(e,i)}, a record book.`))}},publishing(e,t){for(let[s,r]of g(e)){let n=Object.entries(r.fields).filter(([,i])=>i.type==="text").map(([i])=>i);if(n.length===0)continue;let d=Z(e,s).map(i=>i.field);for(let[i,o]of Object.entries(r.fields)){if(o.type!=="enum"||!(X.test(i)||d.includes(i))||!(o.options??[]).some(l=>Q.test(l)))continue;let a=(o.options??[]).find(l=>Q.test(l));t.add("kinds",s),t.add("fields",`${s}.${i}`,...n.map(l=>`${s}.${l}`)),t.add("acts",...m(e,s).filter(([,l])=>l.sets?.[i]===a).map(([l])=>l)),t.add("rules",...f(e,[i,...n],[s]).filter(l=>N(`${e.rules[l].when??""} ${e.rules[l].require??""}`).has(a)||n.some(h=>N(e.rules[l].require??"").has(h)))),t.say(`${p(e,s)} go from ${u(o.options[0])} to ${u(a)}, with their words.`)}}},roster(e,t){for(let[s,r]of g(e)){if(!V(e,s))continue;let n=Object.keys(r.fields);n.length<2||(t.add("kinds",s),t.add("fields",...n.map(d=>`${s}.${d}`)),t.add("lenses",...D(e,s,"columns"),...D(e,s,"rows")),t.say(`${p(e,s)}, with ${x(n.slice(1).map(d=>u(b(d))))}.`))}},routines(e,t){for(let[s,r]of g(e)){let n=Object.entries(r.fields).filter(([,a])=>j(a)&&a.repeats===!0).map(([a])=>a),d=Object.entries(r.fields).filter(([a,l])=>(l.type==="enum"||l.type==="string"||l.type==="integer"||l.type==="number")&&ue.test(a)).map(([a])=>a),i=Object.entries(r.fields).filter(([a,l])=>j(l)&&ge.test(a)).map(([a])=>a);if(n.length===0&&!(d.length>0&&i.length>0))continue;let o=[...n,...d,...i];t.add("kinds",s),t.add("fields",...o.map(a=>`${s}.${a}`)),t.add("rules",...f(e,o,[s])),t.add("lenses",...o.flatMap(a=>P(e,"calendar",s,"start",a))),t.add("acts",...m(e,s).filter(([,a])=>o.some(l=>(a.writes??[]).includes(l)||a.sets?.[l]!==void 0)).map(([a])=>a)),t.say(n.length>0?`${p(e,s)} repeat (${n[0]}).`:`${p(e,s)} come round again, each with when it was last done.`)}},comparison(e,t){for(let[s,r]of Object.entries(e.rules??{})){if(!r.require||!ye.test(r.require))continue;let n=r.over==="graph"?void 0:r.over,d=/in\('([^']+)'\)/.exec(r.require)?.[1],i=/all\('([^']+)'/.exec(r.require)?.[1],o=n?d?v(e).find(([,l])=>l.edges?.[d])?.[0]:void 0:i&&e.kinds[i]?i:void 0;if(!o&&!n)continue;let a=/==\s*'([^']+)'/.exec(r.require)?.[1];t.add("kinds",...o?[o]:[],...n?[n]:[]),t.add("rules",s),o&&a&&t.add("acts",...m(e,o).filter(([,l])=>Object.values(l.sets??{}).includes(a)).map(([l])=>l)),t.say(o&&n?`${p(e,o)} compared within each ${w(e,n)}, one ${a??"chosen"}.`:o?`${p(e,o)} compared, one ${a??"chosen"}.`:`One ${a??"chosen"} per ${w(e,n)}.`)}}};function E(e){let t=[];for(let s of k){let r=new G;ee[s](e,r),r.any()&&t.push(r.asTrait(s))}return t}function L(e,t){let s=new G;return ee[t](e,s),s.any()}var Oe=e=>Math.round(Math.max(0,Math.min(1,e))*100)/100;function q(e){return e?.type==="noul"&&Number.isFinite(e.noul)?Oe(e.noul):void 0}var Re={add:.7,drop:.7},Fe="propose_change";function Me(e){return M(e)}var De=e=>e.toLowerCase(),Te=e=>e.charAt(0).toUpperCase()+e.slice(1),O=(e,t="and")=>e.length<2?e.join(""):`${e.slice(0,-1).join(", ")} ${t} ${e[e.length-1]}`,Se=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[-_]+/g," ").toLowerCase(),T=(e,t)=>{let s=e.kinds[t];return De(s?.plural??(s?.noun?`${s.noun}s`:`${Se(t)}s`))},xe=e=>k.includes(e),se=(e,t)=>k.indexOf(e)-k.indexOf(t);function je(e){let t=E(e),s=new Set(t.map(r=>r.trait));return{name:e.name,keeps:Object.keys(e.kinds).map(r=>T(e,r)),"made of":t.map(r=>r.said),lacks:k.filter(r=>!s.has(r)).map(r=>y[r])}}function Ne(e,t){let s=new Set(E(t).map(n=>n.trait)),r={};for(let n of k)s.has(n)||(r[`need:${n}`]={type:"noul",instructions:`Does what they asked for need ${y[n]}, which ${t.name} has no part for yet?`,criteria:{true:`It needs ${y[n]}: they asked for it, or what they asked for cannot be kept without it.`,false:"Not asked for, and not needed to keep what they asked for."}});for(let n of Object.keys(t.kinds)){let d=T(t,n);r[`drop:kind:${n}`]={type:"noul",instructions:`Did they ask ${t.name} to stop keeping ${d}?`,criteria:{true:`They said the ${d} go: to drop them, remove them or stop tracking them.`,false:`${Te(d)} stay: nothing they said asks for them to go.`}}}for(let n of k)s.has(n)&&(r[`drop:trait:${n}`]={type:"noul",instructions:`Did they ask ${t.name} to stop having ${y[n]}?`,criteria:{true:`They said it goes: to drop or stop ${y[n]}.`,false:"It stays: nothing they said asks for it to go."}});return{state:{said:e,app:je(t)},questions:r}}var te=/^drop:(kind|trait):(.+)$/s;function Ae(e,t={}){let s={...Re,...t},r=Object.keys(e);if(r.length===0)throw new Error("readReshape was handed no answers.");let n=r.filter(o=>!/^need:/.test(o)&&!te.test(o));if(n.length>0)throw new Error(`readReshape does not know the question ${n.map(o=>`"${o}"`).join(", ")}: it reads need:<trait>, drop:kind:<name> and drop:trait:<name>.`);let d={},i={};for(let[o,a]of Object.entries(e)){let l=te.exec(o);if(l){i[`${l[1]}:${l[2]}`]=q(a)??0;continue}let h=o.slice(5);xe(h)&&(d[h]=q(a)??0)}return{add:Object.keys(d).filter(o=>d[o]>=s.add).sort(se),drop:Object.entries(i).filter(([,o])=>o>=s.drop).map(([o])=>o.slice(o.indexOf(":")+1)),needs:d,drops:i}}function Ge(e){let{said:t,document:s}=e,r=[...new Set(e.add)].sort(se),n=[...new Set(e.drop)],d=E(s),i=r.filter(c=>!L(s,c)).map(c=>({what:"trait",name:c,words:y[c],brings:J[c]})),o=r.filter(c=>L(s,c)),a=Object.keys(s.kinds).filter(c=>n.includes(c)),l=d.filter(c=>n.includes(c.trait)&&!Object.hasOwn(s.kinds,c.trait)),h=[...a.map(c=>({what:"kind",name:c,words:T(s,c)})),...l.map(c=>({what:"trait",name:c.trait,words:y[c.trait]}))],C=Object.keys(s.kinds).filter(c=>!a.includes(c)).map(c=>({what:"kind",name:c,words:T(s,c)})),ne=[...a.map(c=>`All ${T(s,c)} records go, with their links.`),...l.flatMap(c=>{let F=[...c.fields,...c.relations];return F.length>0?[`What carries ${y[c.trait]} goes: ${O(F)}, with its values and links.`]:[]})],S=[];i.length>0&&S.push(`adds ${O(i.map(c=>c.words))}`),h.length>0&&S.push(`drops ${O(h.map(c=>c.words))}`),C.length>0&&S.push(`keeps ${O(C.map(c=>c.words))}`);let re=i.length+h.length===0?`Nothing in ${s.name} changes for that.`:`This ${O(S)}.`,ie=o.length>0?` ${s.name} already has ${O(o.map(c=>y[c]))}.`:"";return{said:t,add:i.map(c=>c.name),drop:h.map(c=>c.name),card:{said:`${re}${ie}`,adds:i,keeps:C,drops:h,breaking:ne}}}async function Ue(e){let{state:t,questions:s}=Ne(e.said,e.document),{answers:r,usage:n}=await e.decide(t,s),d=Ae(r,e.thresholds??{}),i=d.add.length+d.drop.length===0?null:Ge({said:e.said,document:e.document,add:d.add,drop:d.drop});return{proposal:i&&i.add.length+i.drop.length===0?null:i,reading:d,answers:r,usage:n}}export{Fe as a,Me as b,Ne as c,Ae as d,Ge as e,Ue as f};
|
|
@@ -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{c as ae,d as se,f as oe,i as re,j as le,k as de,m as ce,n as ue,o as pe,p as ge,q as fe}from"./chunk.H3W5C3XQ.js";import{b as Z,c as ee,d as te,e as ne}from"./chunk.6WB2TYK7.js";import{a as ie}from"./chunk.N5Z34V7U.js";import{a as Y}from"./chunk.YL2RBZFE.js";import{a as X,e as O}from"./chunk.H3IGXHZR.js";import{E as K,G as Ie,J as Q,S as V,W as _,ea as j}from"./chunk.3VEZ5MOC.js";import{td as J}from"./chunk.6AANHELP.js";import{b as N}from"./chunk.AJZBJBMO.js";var c=N(Ie(),1);var o=N(_(),1);function he(e,a,t){let i=a.on==="selection"?a.ids:a.on==="record"||a.on==="field"?[a.id]:[],l=i.length>0?ie(e.store,i,{principal:e.principal,...i.length===1?{focus:i[0]}:{}}).affordances.map(s=>({mutation:s.mutation,label:s.label,args:s.args,open:s.open,why:s.why,...s.destructive?{destructive:!0}:{}})):void 0;return{store:e.store,target:a,principal:e.principal,interaction:se(),places:e.places,selection:e.selection,...l?{acts:l}:{},...e.place?{place:e.place}:{},...t?{said:t}:{},...e.app.purpose?{purpose:e.app.purpose}:{}}}async function be(e,a,t){let i=await (__graviewPreload(import.meta.url,["./chunk.VTDOWXCP.js","./chunk.G4JJXA63.js","./chunk.TBY5IR7C.js","./chunk.BHJRT57H.js","./chunk.BIDL7GQD.js","./chunk.CNN32262.js","./chunk.JGRSUTPJ.js","./chunk.XOZU4OFA.js","./chunk.EP5JS7ZH.js","./chunk.Q5WEOX3Q.js","./chunk.KAM73WVF.js","./chunk.O32F6LGK.js","./chunk.EGSOHTZZ.js","./chunk.WVUJXDXZ.js","./chunk.L7XKYGV7.js","./chunk.CE3NKAF7.js","./chunk.R3GE37OI.js","./chunk.2KCDLCB2.js","./chunk.UD7VLXPM.js","./chunk.3DEWQDP7.js","./chunk.TFJA4QV4.js","./chunk.HWFJQ42Y.js","./chunk.QUETLFBJ.js","./chunk.JULD4XFB.js","./chunk.GRTBEA7O.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.5L4ADKTW.js")),l=i.recipeDraft(a.recipe,{app:e.app,sight:i.draftSight(e.app,e.principal)});if(i.isDraftFailure(l))return l.failed;t?.(),e.seatTalk.setDraft(l,null),e.goTo.draft?.(),ke()}function ke(e=180){if(typeof document>"u")return;let a=document.querySelector('[data-testid="draft-keep"]'),t=document.activeElement,i=!t||t===document.body||t.closest?.("[inert]")!==null;if(a){i&&a.focus();return}e>0&&requestAnimationFrame(()=>ke(e-1))}async function T(e,a,t,i,l){let s=he(e,t,i),d=a==="suggest"?await oe(e.ai,s):a==="fill"?await re(e.ai,s):a==="record"?await le(e.ai,s):await de(e.ai,s);if(d.interaction.outcome==="failed")return a!=="suggest"&&e.desk.record(d.interaction),d;let u=g=>{let p={...d.interaction,outcome:"failed",failed:g};return e.desk.record(p),{...d,interaction:p}};if(a==="fill"||a==="record"){if(!d.ghost||d.ghost.proposals.length===0)return u("Nothing here could be filled in.");l?.(),e.desk.setGhost({ghost:d.ghost}),e.desk.record(d.interaction)}if(a==="panel"&&d.panel){let g=await be(e,d.panel,l);if(g)return u(g);e.desk.record(d.interaction)}return d}var W=new WeakMap,Te=64,me=new WeakMap;function Ee(e){let a=me.get(e);if(!a){let t=a={n:0};me.set(e,t),e.subscribe(()=>void(t.n+=1))}return a.n}var Se=(e,a)=>{let t=ee(a);return t.length>0?t.map(i=>e.graph.getNode(i)):[Ee(e)]},we=(e,a,t)=>JSON.stringify({target:a,seat:e.principal,by:t}),Ae=(e,a,t)=>{let i=Se(e.store,a);return t.schema===e.store.schema&&t.ai===e.ai&&i.length===t.depends.length&&i.every((l,s)=>l===t.depends[s])};function Me(e,a,t="menu"){let i=W.get(e.store)?.get(we(e,a,t));return i?.result!==void 0&&Ae(e,a,i)?i.result:void 0}function Ce(e,a,t){let i=W.get(e.store);i||W.set(e.store,i=new Map);let l=we(e,a,t?.by??"menu"),s=i.get(l);if(s&&Ae(e,a,s))return s.result?Promise.resolve(s.result):s.asked;let d=t?t.ask():T(e,"suggest",a),u={schema:e.store.schema,ai:e.ai,depends:Se(e.store,a),asked:d};i.delete(l),i.set(l,u),i.size>Te&&i.delete(i.keys().next().value);let g=i;return d.then(p=>{p.interaction.outcome!=="failed"?u.result=p:g.get(l)===u&&g.delete(l)}),d}async function Oe(e,a,t,i,l={}){let s=a.interaction,d=ue(t);if(d){let u=s.usage?.at(-1)?.model,g=s.offered.find(h=>h.id===t.id)?.confidence,p=ce(e.store,{interaction:s.id,target:s.target,basis:`${s.ask.said}: ${t.label}`,...u?{model:u}:{},proposals:[{...d,...g!==void 0?{confidence:g}:{}}]},e.principal);if(p.proposals.length===0){let h="That can't be done now.";return e.desk.record({...s,outcome:"failed",failed:h}),h}l.onCard?e.desk.setGhost({ghost:p,onCard:!0}):(i?.(),e.desk.setGhost({ghost:p})),e.desk.record(s);return}if(t.type==="panel"){let u=t.label,g={title:u,recipe:{...t.panel,title:u}},p=await be(e,g,i);return e.desk.record(p?{...s,outcome:"failed",failed:p}:{...s,outcome:"drawn",accepted:[t.id],panel:g}),p}i?.(),t.type==="place"?e.goTo.place(t.place):t.type==="record"&&e.goTo.record(t.record),e.desk.record({...s,outcome:"accepted",accepted:[t.id]})}async function qe(e,a){if(a.ask.kind==="ask")return O(e.desk,{target:a.target,asked:a.ask.said}),null;let t=a.ask.kind==="panel"||a.ask.kind==="record"?a.ask.kind:"fill";return T(e,t,a.target,a.ask.said)}var k={padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},ye=(0,o.jsx)("button",{type:"button",tabIndex:-1,disabled:!0,"aria-hidden":"true",style:{...k,visibility:"hidden"},children:"\xA0"}),P={margin:0,padding:"4px 10px",fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function ze({target:e,close:a}){let t=Y(),i=(0,c.useMemo)(()=>Z(e,n=>t.store.graph.has(n)),[e,t.store]),l=(0,c.useMemo)(()=>{let n=he(t,i);return te(t.store,i,{principal:t.principal,places:t.places,...n.acts?{acts:n.acts}:{}})},[t,i]),s=l.candidates.some(n=>n.type==="fill"),d=l.candidates.some(n=>n.type==="panel"),u=(0,c.useMemo)(()=>d?ne(t.store,i,{principal:t.principal,places:t.places,most:1}):[],[d,t,i]),g=(0,c.useMemo)(()=>new Set(t.store.allMutations().filter(n=>(n.creates??[]).length>0).map(n=>n.name)),[t.store]),p=ae(t.ai)!==void 0&&l.candidates.some(n=>n.type==="act"&&n.asks.length>0&&g.has(n.mutation)),h=K(t.ai),S=Me(t,i),f=JSON.stringify(i),[m,I]=(0,c.useState)(!1),[A,R]=(0,c.useState)(null),[H,E]=(0,c.useState)(h&&S===void 0);(0,c.useEffect)(()=>{if(S!==void 0||!(h||m))return;let n=!0;return E(!0),Ce(t,i).then(y=>{n&&(R(y),E(!1))}),()=>{n=!1}},[f,m]);let r=S??A,w=(r?.offers??[]).filter(n=>!(n.type==="place"&&u.some(y=>y.place===n.place))).slice(0,Math.max(0,3-u.length)),b=r?.interaction.outcome==="failed"?r.interaction.failed??"The AI could not suggest anything here.":null,D=(0,c.useRef)(!1),F=(0,c.useRef)(null);(0,c.useLayoutEffect)(()=>{r===null||!D.current||(D.current=!1,F.current?.querySelector("button")?.focus())},[r]);let L=(0,c.useRef)(!0);(0,c.useEffect)(()=>()=>{L.current=!1},[]);let[U,G]=(0,c.useState)(!1),[B,$]=(0,c.useState)(null),M=n=>{if(U)return;G(!0),$(null);let y=!1;n(()=>{y=!0,a()}).then(x=>{L.current&&(G(!1),x?$(x):y||a())},x=>{L.current&&(G(!1),$(x instanceof Error?x.message:String(x)))})},q=n=>n.interaction.outcome==="failed"?n.interaction.failed??"The AI could not do that here.":void 0,C=H&&!m?(0,o.jsx)("p",{role:"status","data-testid":"inline-ai-thinking",style:P,children:"Thinking\u2026"}):U?(0,o.jsx)("p",{role:"status","data-testid":"inline-ai-asking",style:P,children:"Asking\u2026"}):B?(0,o.jsx)("p",{role:"alert","data-testid":"inline-ai-failed",style:{...P,color:"var(--graview-warn)"},children:B}):b?(0,o.jsx)("p",{role:"status",style:P,children:b}):null,z=(0,c.useRef)(0);z.current=Math.max(z.current,h&&S===void 0?Math.max(1,3-u.length):0,w.length+(C?1:0));let xe=Math.max(0,z.current-w.length-(C?1:0));return(0,o.jsxs)("div",{ref:F,"data-testid":"inline-ai",style:{display:"grid",gap:2},children:[(0,o.jsxs)("ul",{"data-testid":"inline-ai-room",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[C?(0,o.jsxs)("li",{style:{position:"relative"},children:[ye,(0,o.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center"},children:C})]}):null,w.map(n=>(0,o.jsx)("li",{children:(0,o.jsxs)("button",{type:"button","data-menu-item":`ai-offer:${n.id}`,"data-ai-offer":n.id,"data-ai-offer-type":n.type,title:n.label,onClick:()=>M(y=>Oe(t,r,n,y)),style:{...k,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[n.label,(0,o.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",n.type==="panel"?"a panel":n.type==="place"?"go there":n.type==="record"?"open it":"suggested"]})]})},n.id)),Array.from({length:xe},(n,y)=>(0,o.jsx)("li",{"data-inline-ai-room":"",children:ye},`room-${y}`))]}),(0,o.jsxs)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[!h&&r===null?(0,o.jsx)("li",{children:(0,o.jsx)("button",{type:"button","data-menu-item":"ai-suggest","aria-disabled":m||void 0,onClick:n=>{m||(D.current=document.activeElement===n.currentTarget,I(!0))},style:k,children:m?"Thinking\u2026":"Suggest\u2026"})}):null,s?(0,o.jsx)("li",{children:(0,o.jsx)("button",{type:"button","data-menu-item":"ai-fill",onClick:()=>M(async n=>q(await T(t,"fill",i,"Fill in",n))),style:k,children:"Fill in with AI"})}):null,p?(0,o.jsx)("li",{children:(0,o.jsx)("button",{type:"button","data-menu-item":"ai-record",onClick:()=>M(async n=>q(await T(t,"record",i,"Add one",n))),style:k,children:"Add one with AI"})}):null,u.map(n=>(0,o.jsx)("li",{children:(0,o.jsx)("button",{type:"button","data-menu-item":`ai-open:${n.place}`,"data-ai-existing":n.fit,onClick:()=>{a(),t.goTo.place(n.place),n.fit==="partial"&&O(t.desk,{target:{on:"lens",place:n.place,...n.kind?{kind:n.kind}:{}}})},style:k,children:n.fit==="full"?`Open ${n.title}`:`Open and adjust ${n.title}`})},n.place)),d?(0,o.jsx)("li",{children:(0,o.jsx)("button",{type:"button","data-menu-item":"ai-panel",onClick:()=>M(async n=>q(await T(t,"panel",i,"Draw a panel",n))),style:k,children:u.length>0?"Draw a new view":"Draw a panel"})}):null,(0,o.jsx)("li",{children:(0,o.jsx)("button",{type:"button","data-menu-item":"ai-ask",onClick:()=>{let n=document.activeElement,y=X(n instanceof Element?n.closest('[data-testid="context-menu"]'):null);a(),O(t.desk,{target:i,returnTo:n instanceof HTMLElement&&n!==document.body?n:null,...y?{from:y}:{}})},style:k,children:"Tell Graview\u2026"})})]})]})}var v={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 10px",fontSize:"0.8125rem",borderRadius:8};function Ne({placement:e="picture"}){let{store:a,principal:t,aiDesk:i}=j(),l=V(a,t),{ghost:s,entries:d}=Q(i),[u,g]=(0,c.useState)(new Set);(0,c.useEffect)(()=>g(new Set),[s?.ghost.interaction]);let p=(0,c.useRef)(null),h=(0,c.useRef)(null),S=s?.batch;if((0,c.useEffect)(()=>{S!==void 0&&h.current?.focus()},[S]),!s)return null;let{ghost:f}=s,m=d.find(r=>r.id===f.interaction),I=()=>{let r=f.target.on==="record"||f.target.on==="field"?f.target.id:void 0,w=p.current?.closest("[data-graview-face], main")?.parentElement??document,b=(r?w.querySelector(`[data-graview-view="${CSS.escape(r)}"][tabindex]`):null)??document.querySelector("[data-graview-page-title]")??p.current?.closest("main")??document.querySelector("main");b&&!b.hasAttribute("tabindex")&&b.setAttribute("tabindex","-1"),b?.focus({preventScroll:!0}),i.setGhost(null)},A=f.proposals.filter(r=>!u.has(r.id)).map(r=>r.id),R=()=>{let r=pe(l,f,{author:t,ids:A});if(!r.ok){i.setGhost({...s,refused:r.refused});return}m&&i.record(ge(m,r.accepted,r.batch)),i.setGhost({ghost:f,batch:r.batch,took:r.accepted.length,...s.onCard?{onCard:!0}:{}})},H=()=>{m&&s.batch===void 0&&i.record(fe(m)),I()},E=()=>{if(s.batch!==void 0)try{l.undo(s.batch,{author:t}),m&&i.record({...m,undone:!0}),I()}catch(r){i.setGhost({...s,refused:r instanceof Error?r.message:String(r)})}};return(0,o.jsxs)("section",{ref:p,"data-testid":"ai-ghost","data-interaction":f.interaction,"aria-label":"Proposed by AI",style:{...e==="card"?{position:"static"}:{position:e==="page"?"fixed":"absolute",insetInline:"max(12px, calc(50% - 220px))",bottom:"calc(var(--graview-foot-room, 0px) + 72px)",zIndex:J("toast"),boxShadow:"var(--graview-lift-high)"},display:"grid",gap:8,padding:12,borderRadius:12,border:"1px dashed var(--graview-accent)",background:"var(--graview-float)",fontSize:"0.875rem"},children:[(0,o.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:s.batch!==void 0?`Done: ${s.took===1?"one change":`${s.took} changes`}, as one.`:`Proposed by AI \xB7 ${f.basis}`}),s.batch===void 0?(0,o.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:f.proposals.map(r=>(0,o.jsx)("li",{"data-ghost-proposal":r.id,children:(0,o.jsxs)("label",{style:{display:"flex",alignItems:"baseline",gap:8,cursor:"pointer"},children:[(0,o.jsx)("input",{type:"checkbox",checked:!u.has(r.id),onChange:w=>{let b=new Set(u);w.target.checked?b.delete(r.id):b.add(r.id),g(b)}}),(0,o.jsx)("span",{style:{fontStyle:"italic",color:"var(--graview-ink)"},children:r.said}),r.confidence!==void 0?(0,o.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[Math.round(r.confidence*100),"% sure"]}):null]})},r.id))}):null,s.refused?(0,o.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-warn)"},children:s.refused}):null,(0,o.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:s.batch===void 0?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button","data-testid":"ghost-accept",disabled:A.length===0,onClick:R,style:v,children:A.length===f.proposals.length?"Accept":`Accept ${A.length} of ${f.proposals.length}`}),(0,o.jsx)("button",{type:"button","data-testid":"ghost-dismiss",onClick:H,style:v,children:"Dismiss"})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button",ref:h,"data-testid":"ghost-undo",onClick:E,style:v,children:"Undo"}),(0,o.jsx)("button",{type:"button","data-testid":"ghost-close",onClick:I,style:v,children:"Close"})]})})]})}export{he as a,be as b,T as c,Me as d,Ce as e,Oe as f,qe as g,ze as h,Ne as i};
|
|
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{c as ae,d as se,f as oe,i as re,j as le,k as de,m as ce,n as ue,o as pe,p as ge,q as fe}from"./chunk.VR553M6J.js";import{b as Z,c as ee,d as te,e as ne}from"./chunk.DU76ASS4.js";import{a as ie}from"./chunk.7L3I776Z.js";import{a as Y}from"./chunk.GTF6EMVE.js";import{a as X,e as O}from"./chunk.NLZHNPDU.js";import{E as K,G as Ie,J as Q,S as V,W as _,ea as j}from"./chunk.FWXW4T4I.js";import{td as J}from"./chunk.DHPXRDT5.js";import{b as N}from"./chunk.AJZBJBMO.js";var c=N(Ie(),1);var o=N(_(),1);function he(e,a,t){let i=a.on==="selection"?a.ids:a.on==="record"||a.on==="field"?[a.id]:[],l=i.length>0?ie(e.store,i,{principal:e.principal,...i.length===1?{focus:i[0]}:{}}).affordances.map(s=>({mutation:s.mutation,label:s.label,args:s.args,open:s.open,why:s.why,...s.destructive?{destructive:!0}:{}})):void 0;return{store:e.store,target:a,principal:e.principal,interaction:se(),places:e.places,selection:e.selection,...l?{acts:l}:{},...e.place?{place:e.place}:{},...t?{said:t}:{},...e.app.purpose?{purpose:e.app.purpose}:{}}}async function be(e,a,t){let i=await (__graviewPreload(import.meta.url,["./chunk.HU3KEWFO.js","./chunk.G4JJXA63.js","./chunk.TBY5IR7C.js","./chunk.WFJCC6G3.js","./chunk.BIDL7GQD.js","./chunk.IO5VFTXC.js","./chunk.UPOYRCKI.js","./chunk.XOZU4OFA.js","./chunk.WV6SP6IJ.js","./chunk.Q5WEOX3Q.js","./chunk.MATUPDZ3.js","./chunk.SAWASNDO.js","./chunk.HCX6KPRF.js","./chunk.WVUJXDXZ.js","./chunk.B422DSYN.js","./chunk.ZE5RSKXF.js","./chunk.DKUEZPGR.js","./chunk.EP7YT7LT.js","./chunk.I7KN732Z.js","./chunk.TLPCYKLW.js","./chunk.MH3AQO2R.js","./chunk.J2N7EKMX.js","./chunk.P26ATAAI.js","./chunk.FIY4RUK5.js","./chunk.IY3DV52G.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.AMV2ILR6.js")),l=i.recipeDraft(a.recipe,{app:e.app,sight:i.draftSight(e.app,e.principal)});if(i.isDraftFailure(l))return l.failed;t?.(),e.seatTalk.setDraft(l,null),e.goTo.draft?.(),ke()}function ke(e=180){if(typeof document>"u")return;let a=document.querySelector('[data-testid="draft-keep"]'),t=document.activeElement,i=!t||t===document.body||t.closest?.("[inert]")!==null;if(a){i&&a.focus();return}e>0&&requestAnimationFrame(()=>ke(e-1))}async function T(e,a,t,i,l){let s=he(e,t,i),d=a==="suggest"?await oe(e.ai,s):a==="fill"?await re(e.ai,s):a==="record"?await le(e.ai,s):await de(e.ai,s);if(d.interaction.outcome==="failed")return a!=="suggest"&&e.desk.record(d.interaction),d;let u=g=>{let p={...d.interaction,outcome:"failed",failed:g};return e.desk.record(p),{...d,interaction:p}};if(a==="fill"||a==="record"){if(!d.ghost||d.ghost.proposals.length===0)return u("Nothing here could be filled in.");l?.(),e.desk.setGhost({ghost:d.ghost}),e.desk.record(d.interaction)}if(a==="panel"&&d.panel){let g=await be(e,d.panel,l);if(g)return u(g);e.desk.record(d.interaction)}return d}var W=new WeakMap,Te=64,me=new WeakMap;function Ee(e){let a=me.get(e);if(!a){let t=a={n:0};me.set(e,t),e.subscribe(()=>void(t.n+=1))}return a.n}var Se=(e,a)=>{let t=ee(a);return t.length>0?t.map(i=>e.graph.getNode(i)):[Ee(e)]},we=(e,a,t)=>JSON.stringify({target:a,seat:e.principal,by:t}),Ae=(e,a,t)=>{let i=Se(e.store,a);return t.schema===e.store.schema&&t.ai===e.ai&&i.length===t.depends.length&&i.every((l,s)=>l===t.depends[s])};function Me(e,a,t="menu"){let i=W.get(e.store)?.get(we(e,a,t));return i?.result!==void 0&&Ae(e,a,i)?i.result:void 0}function Ce(e,a,t){let i=W.get(e.store);i||W.set(e.store,i=new Map);let l=we(e,a,t?.by??"menu"),s=i.get(l);if(s&&Ae(e,a,s))return s.result?Promise.resolve(s.result):s.asked;let d=t?t.ask():T(e,"suggest",a),u={schema:e.store.schema,ai:e.ai,depends:Se(e.store,a),asked:d};i.delete(l),i.set(l,u),i.size>Te&&i.delete(i.keys().next().value);let g=i;return d.then(p=>{p.interaction.outcome!=="failed"?u.result=p:g.get(l)===u&&g.delete(l)}),d}async function Oe(e,a,t,i,l={}){let s=a.interaction,d=ue(t);if(d){let u=s.usage?.at(-1)?.model,g=s.offered.find(h=>h.id===t.id)?.confidence,p=ce(e.store,{interaction:s.id,target:s.target,basis:`${s.ask.said}: ${t.label}`,...u?{model:u}:{},proposals:[{...d,...g!==void 0?{confidence:g}:{}}]},e.principal);if(p.proposals.length===0){let h="That can't be done now.";return e.desk.record({...s,outcome:"failed",failed:h}),h}l.onCard?e.desk.setGhost({ghost:p,onCard:!0}):(i?.(),e.desk.setGhost({ghost:p})),e.desk.record(s);return}if(t.type==="panel"){let u=t.label,g={title:u,recipe:{...t.panel,title:u}},p=await be(e,g,i);return e.desk.record(p?{...s,outcome:"failed",failed:p}:{...s,outcome:"drawn",accepted:[t.id],panel:g}),p}i?.(),t.type==="place"?e.goTo.place(t.place):t.type==="record"&&e.goTo.record(t.record),e.desk.record({...s,outcome:"accepted",accepted:[t.id]})}async function qe(e,a){if(a.ask.kind==="ask")return O(e.desk,{target:a.target,asked:a.ask.said}),null;let t=a.ask.kind==="panel"||a.ask.kind==="record"?a.ask.kind:"fill";return T(e,t,a.target,a.ask.said)}var k={padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},ye=(0,o.jsx)("button",{type:"button",tabIndex:-1,disabled:!0,"aria-hidden":"true",style:{...k,visibility:"hidden"},children:"\xA0"}),P={margin:0,padding:"4px 10px",fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function ze({target:e,close:a}){let t=Y(),i=(0,c.useMemo)(()=>Z(e,n=>t.store.graph.has(n)),[e,t.store]),l=(0,c.useMemo)(()=>{let n=he(t,i);return te(t.store,i,{principal:t.principal,places:t.places,...n.acts?{acts:n.acts}:{}})},[t,i]),s=l.candidates.some(n=>n.type==="fill"),d=l.candidates.some(n=>n.type==="panel"),u=(0,c.useMemo)(()=>d?ne(t.store,i,{principal:t.principal,places:t.places,most:1}):[],[d,t,i]),g=(0,c.useMemo)(()=>new Set(t.store.allMutations().filter(n=>(n.creates??[]).length>0).map(n=>n.name)),[t.store]),p=ae(t.ai)!==void 0&&l.candidates.some(n=>n.type==="act"&&n.asks.length>0&&g.has(n.mutation)),h=K(t.ai),S=Me(t,i),f=JSON.stringify(i),[m,I]=(0,c.useState)(!1),[A,R]=(0,c.useState)(null),[H,E]=(0,c.useState)(h&&S===void 0);(0,c.useEffect)(()=>{if(S!==void 0||!(h||m))return;let n=!0;return E(!0),Ce(t,i).then(y=>{n&&(R(y),E(!1))}),()=>{n=!1}},[f,m]);let r=S??A,w=(r?.offers??[]).filter(n=>!(n.type==="place"&&u.some(y=>y.place===n.place))).slice(0,Math.max(0,3-u.length)),b=r?.interaction.outcome==="failed"?r.interaction.failed??"The AI could not suggest anything here.":null,D=(0,c.useRef)(!1),F=(0,c.useRef)(null);(0,c.useLayoutEffect)(()=>{r===null||!D.current||(D.current=!1,F.current?.querySelector("button")?.focus())},[r]);let L=(0,c.useRef)(!0);(0,c.useEffect)(()=>()=>{L.current=!1},[]);let[U,G]=(0,c.useState)(!1),[B,$]=(0,c.useState)(null),M=n=>{if(U)return;G(!0),$(null);let y=!1;n(()=>{y=!0,a()}).then(x=>{L.current&&(G(!1),x?$(x):y||a())},x=>{L.current&&(G(!1),$(x instanceof Error?x.message:String(x)))})},q=n=>n.interaction.outcome==="failed"?n.interaction.failed??"The AI could not do that here.":void 0,C=H&&!m?(0,o.jsx)("p",{role:"status","data-testid":"inline-ai-thinking",style:P,children:"Thinking\u2026"}):U?(0,o.jsx)("p",{role:"status","data-testid":"inline-ai-asking",style:P,children:"Asking\u2026"}):B?(0,o.jsx)("p",{role:"alert","data-testid":"inline-ai-failed",style:{...P,color:"var(--graview-warn)"},children:B}):b?(0,o.jsx)("p",{role:"status",style:P,children:b}):null,z=(0,c.useRef)(0);z.current=Math.max(z.current,h&&S===void 0?Math.max(1,3-u.length):0,w.length+(C?1:0));let xe=Math.max(0,z.current-w.length-(C?1:0));return(0,o.jsxs)("div",{ref:F,"data-testid":"inline-ai",style:{display:"grid",gap:2},children:[(0,o.jsxs)("ul",{"data-testid":"inline-ai-room",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[C?(0,o.jsxs)("li",{style:{position:"relative"},children:[ye,(0,o.jsx)("div",{style:{position:"absolute",inset:0,display:"flex",alignItems:"center"},children:C})]}):null,w.map(n=>(0,o.jsx)("li",{children:(0,o.jsxs)("button",{type:"button","data-menu-item":`ai-offer:${n.id}`,"data-ai-offer":n.id,"data-ai-offer-type":n.type,title:n.label,onClick:()=>M(y=>Oe(t,r,n,y)),style:{...k,whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:[n.label,(0,o.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",n.type==="panel"?"a panel":n.type==="place"?"go there":n.type==="record"?"open it":"suggested"]})]})},n.id)),Array.from({length:xe},(n,y)=>(0,o.jsx)("li",{"data-inline-ai-room":"",children:ye},`room-${y}`))]}),(0,o.jsxs)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[!h&&r===null?(0,o.jsx)("li",{children:(0,o.jsx)("button",{type:"button","data-menu-item":"ai-suggest","aria-disabled":m||void 0,onClick:n=>{m||(D.current=document.activeElement===n.currentTarget,I(!0))},style:k,children:m?"Thinking\u2026":"Suggest\u2026"})}):null,s?(0,o.jsx)("li",{children:(0,o.jsx)("button",{type:"button","data-menu-item":"ai-fill",onClick:()=>M(async n=>q(await T(t,"fill",i,"Fill in",n))),style:k,children:"Fill in with AI"})}):null,p?(0,o.jsx)("li",{children:(0,o.jsx)("button",{type:"button","data-menu-item":"ai-record",onClick:()=>M(async n=>q(await T(t,"record",i,"Add one",n))),style:k,children:"Add one with AI"})}):null,u.map(n=>(0,o.jsx)("li",{children:(0,o.jsx)("button",{type:"button","data-menu-item":`ai-open:${n.place}`,"data-ai-existing":n.fit,onClick:()=>{a(),t.goTo.place(n.place),n.fit==="partial"&&O(t.desk,{target:{on:"lens",place:n.place,...n.kind?{kind:n.kind}:{}}})},style:k,children:n.fit==="full"?`Open ${n.title}`:`Open and adjust ${n.title}`})},n.place)),d?(0,o.jsx)("li",{children:(0,o.jsx)("button",{type:"button","data-menu-item":"ai-panel",onClick:()=>M(async n=>q(await T(t,"panel",i,"Draw a panel",n))),style:k,children:u.length>0?"Draw a new view":"Draw a panel"})}):null,(0,o.jsx)("li",{children:(0,o.jsx)("button",{type:"button","data-menu-item":"ai-ask",onClick:()=>{let n=document.activeElement,y=X(n instanceof Element?n.closest('[data-testid="context-menu"]'):null);a(),O(t.desk,{target:i,returnTo:n instanceof HTMLElement&&n!==document.body?n:null,...y?{from:y}:{}})},style:k,children:"Tell Graview\u2026"})})]})]})}var v={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 10px",fontSize:"0.8125rem",borderRadius:8};function Ne({placement:e="picture"}){let{store:a,principal:t,aiDesk:i}=j(),l=V(a,t),{ghost:s,entries:d}=Q(i),[u,g]=(0,c.useState)(new Set);(0,c.useEffect)(()=>g(new Set),[s?.ghost.interaction]);let p=(0,c.useRef)(null),h=(0,c.useRef)(null),S=s?.batch;if((0,c.useEffect)(()=>{S!==void 0&&h.current?.focus()},[S]),!s)return null;let{ghost:f}=s,m=d.find(r=>r.id===f.interaction),I=()=>{let r=f.target.on==="record"||f.target.on==="field"?f.target.id:void 0,w=p.current?.closest("[data-graview-face], main")?.parentElement??document,b=(r?w.querySelector(`[data-graview-view="${CSS.escape(r)}"][tabindex]`):null)??document.querySelector("[data-graview-page-title]")??p.current?.closest("main")??document.querySelector("main");b&&!b.hasAttribute("tabindex")&&b.setAttribute("tabindex","-1"),b?.focus({preventScroll:!0}),i.setGhost(null)},A=f.proposals.filter(r=>!u.has(r.id)).map(r=>r.id),R=()=>{let r=pe(l,f,{author:t,ids:A});if(!r.ok){i.setGhost({...s,refused:r.refused});return}m&&i.record(ge(m,r.accepted,r.batch)),i.setGhost({ghost:f,batch:r.batch,took:r.accepted.length,...s.onCard?{onCard:!0}:{}})},H=()=>{m&&s.batch===void 0&&i.record(fe(m)),I()},E=()=>{if(s.batch!==void 0)try{l.undo(s.batch,{author:t}),m&&i.record({...m,undone:!0}),I()}catch(r){i.setGhost({...s,refused:r instanceof Error?r.message:String(r)})}};return(0,o.jsxs)("section",{ref:p,"data-testid":"ai-ghost","data-interaction":f.interaction,"aria-label":"Proposed by AI",style:{...e==="card"?{position:"static"}:{position:e==="page"?"fixed":"absolute",insetInline:"max(12px, calc(50% - 220px))",bottom:"calc(var(--graview-foot-room, 0px) + 72px)",zIndex:J("toast"),boxShadow:"var(--graview-lift-high)"},display:"grid",gap:8,padding:12,borderRadius:12,border:"1px dashed var(--graview-accent)",background:"var(--graview-float)",fontSize:"0.875rem"},children:[(0,o.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:s.batch!==void 0?`Done: ${s.took===1?"one change":`${s.took} changes`}, as one.`:`Proposed by AI \xB7 ${f.basis}`}),s.batch===void 0?(0,o.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:f.proposals.map(r=>(0,o.jsx)("li",{"data-ghost-proposal":r.id,children:(0,o.jsxs)("label",{style:{display:"flex",alignItems:"baseline",gap:8,cursor:"pointer"},children:[(0,o.jsx)("input",{type:"checkbox",checked:!u.has(r.id),onChange:w=>{let b=new Set(u);w.target.checked?b.delete(r.id):b.add(r.id),g(b)}}),(0,o.jsx)("span",{style:{fontStyle:"italic",color:"var(--graview-ink)"},children:r.said}),r.confidence!==void 0?(0,o.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[Math.round(r.confidence*100),"% sure"]}):null]})},r.id))}):null,s.refused?(0,o.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-warn)"},children:s.refused}):null,(0,o.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:s.batch===void 0?(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button","data-testid":"ghost-accept",disabled:A.length===0,onClick:R,style:v,children:A.length===f.proposals.length?"Accept":`Accept ${A.length} of ${f.proposals.length}`}),(0,o.jsx)("button",{type:"button","data-testid":"ghost-dismiss",onClick:H,style:v,children:"Dismiss"})]}):(0,o.jsxs)(o.Fragment,{children:[(0,o.jsx)("button",{type:"button",ref:h,"data-testid":"ghost-undo",onClick:E,style:v,children:"Undo"}),(0,o.jsx)("button",{type:"button","data-testid":"ghost-close",onClick:I,style:v,children:"Close"})]})})]})}export{he as a,be as b,T as c,Me as d,Ce as e,Oe as f,qe as g,ze as h,Ne as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{G as A,Ua as H,W as F,Wa as M}from"./chunk.
|
|
1
|
+
import{G as A,Ua as H,W as F,Wa as M}from"./chunk.FWXW4T4I.js";import"./chunk.SDO3U72B.js";import"./chunk.DHPXRDT5.js";import"./chunk.FQLNBIQ5.js";import{b as x}from"./chunk.AJZBJBMO.js";var t=x(A(),1),f=x(F(),1),q={faces:'[data-testid="app-menu-open"][data-scene]',problems:'[data-testid="standing"], [data-testid="standing-link"]',activity:'[data-testid="inbox-button"]',ask:'[data-testid="app-find"], [data-testid="app-find-open"]',find:'[data-testid="app-find"], [data-testid="app-find-open"]',profile:'[data-testid="profile-button"]',home:'[data-testid="app-home"]'};function D(e){if(!e.isConnected||e.closest("[hidden], [inert], [aria-hidden='true']"))return!1;if(typeof e.checkVisibility!="function")return!0;if(!e.checkVisibility({visibilityProperty:!0}))return!1;let a=e.getBoundingClientRect();return a.width>1&&a.height>1}function E(e,a){if(!e||a==="ask"&&!e.querySelector("[data-graview-quick-ask]"))return null;for(let c of e.querySelectorAll(q[a]))if(D(c))return c;return null}function W(e){let a=(u,h,d)=>e.querySelector(u)?.getAttribute(h)?.trim()||d,c=a('[data-testid="app-menu-open"]',"data-scene","Scene"),n=a('[data-testid="app-menu-open"]',"data-pages","Pages");return[{anchor:"faces",title:`${c} or ${n}`,words:`One app, two ways to see it, in the app menu: ${c} draws every record as one picture, ${n} as lists and pages to read and change.`},{anchor:"problems",title:"Whether all is in order",words:"The dot is green while every rule holds. When one is broken it counts what is wrong, and pressing it shows each one and where."},{anchor:"activity",title:"Inbox",words:"What waits for you, what has happened here and who did it \u2014 each change with its way back \u2014 and what you asked."},{anchor:"ask",title:"Tell Graview",words:"Press \u2318K (Ctrl+K) to tell Graview what to do about what you have selected, or right-click it and type. The answer stands beside it, and a change it proposes waits for you to accept it."}]}var R=300,O=1200,$=15e3;function _({root:e,steps:a,onEnd:c}){let[n,u]=(0,t.useState)(null),h=(0,t.useRef)(null),d=(0,t.useRef)(!1),p=(0,t.useRef)(c);p.current=c,(0,t.useEffect)(()=>{let r=Date.now(),o=Date.now(),s=null,i,k=new MutationObserver(()=>o=Date.now());k.observe(document.body,{childList:!0,subtree:!0});let v=()=>{let L=e(),S=Date.now();if(L?.querySelector('[data-testid="app-bar"]')){if(s??=S,S-o>=R||S-s>=O){let T=[...W(L),...a].filter(C=>E(L,C.anchor)!==null);if(T.length===0){d.current=!0,p.current(null);return}h.current=document.activeElement,u({list:T,at:0});return}}else if(S-r>=$){d.current=!0,p.current(null);return}i=setTimeout(v,100)};return i=setTimeout(v,100),()=>{clearTimeout(i),k.disconnect()}},[]);let y=(0,t.useCallback)(()=>{let r=h.current;(r instanceof HTMLElement&&r!==document.body&&r.isConnected?r:e()?.querySelector('[data-testid="app-home"]'))?.focus({preventScroll:!0})},[e]),m=(0,t.useCallback)((r,o)=>{if(d.current)return;d.current=!0;let s=document.querySelector("[data-testid='first-look']"),i=document.activeElement,k=i===null||i===document.body||s!==null&&s.contains(i);u(null),p.current(r),!(!o&&!k)&&(y(),requestAnimationFrame(()=>{let v=document.activeElement;(v===null||v===document.body)&&y()}))},[y]),w=(0,t.useCallback)((r,o)=>{let s=e();for(let i=o;i<r.length;i++)if(E(s,r[i].anchor))return i;return-1},[e]),b=(0,t.useCallback)(()=>{if(!n)return;let r=w(n.list,n.at+1);r<0?m("finished",!0):u({list:n.list,at:r})},[n,w,m]);if((0,t.useEffect)(()=>{if(!n)return;let r=e();if(!r)return;let o=0,s=()=>{cancelAnimationFrame(o),o=requestAnimationFrame(()=>{E(e(),n.list[n.at].anchor)||b()})},i=new MutationObserver(s);return i.observe(r,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["hidden","class"]}),()=>{cancelAnimationFrame(o),i.disconnect()}},[n,e,b]),!n)return null;let g=n.list[n.at],l=w(n.list,n.at+1)<0;return(0,f.jsx)(N,{root:e,step:g,position:n.at+1,total:n.list.length,last:l,onNext:b,onEnd:m},n.at)}var I={...H,width:"min(320px, calc(100vw - 24px))",maxHeight:"min(70vh, 420px)",overflow:"auto",padding:"12px 14px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)",color:"var(--graview-ink)",fontFamily:"var(--graview-font-body, system-ui)",fontSize:"0.875rem",lineHeight:1.45,overflowWrap:"anywhere"},P={minHeight:32,padding:"0 12px",borderRadius:8,font:"inherit",fontWeight:600,cursor:"pointer"};function N({root:e,step:a,position:c,total:n,last:u,onNext:h,onEnd:d}){let p=(0,t.useRef)(null),y=(0,t.useRef)(null),m=(0,t.useId)().replace(/:/g,""),w=(0,t.useMemo)(()=>({get current(){return E(e(),a.anchor)}}),[e,a.anchor]),[b]=(0,t.useState)(()=>{let l=w.current?.getBoundingClientRect(),r=typeof document>"u"?0:document.documentElement.clientWidth||innerWidth;return l&&l.left+l.width/2<r/2?"start":"end"});M(p,!0,w,{align:b}),(0,t.useLayoutEffect)(()=>{y.current?.focus({preventScroll:!0})},[]);let g=(0,t.useRef)(d);return g.current=d,(0,t.useEffect)(()=>{let l=o=>{o.target instanceof Node&&p.current?.contains(o.target)||g.current("dismissed",!1)},r=o=>{if(o.key!=="Escape"||o.defaultPrevented)return;let s=o.target;s instanceof Node&&p.current?.contains(s)||s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement||[...document.querySelectorAll("[data-graview-overlay]:not([hidden])")].some(i=>i!==p.current)||g.current("dismissed",!0)};return document.addEventListener("pointerdown",l,!0),document.addEventListener("keydown",r),()=>{document.removeEventListener("pointerdown",l,!0),document.removeEventListener("keydown",r)}},[]),(0,f.jsxs)("div",{ref:p,popover:"manual",role:"dialog","aria-modal":"false","aria-labelledby":`${m}-title`,"aria-describedby":`${m}-words`,tabIndex:-1,"data-testid":"first-look","data-first-look-anchor":a.anchor,"data-graview-overlay":"",onKeyDown:l=>{l.key==="Escape"&&(l.preventDefault(),l.stopPropagation(),d("dismissed",!0))},style:I,children:[(0,f.jsxs)("p",{style:{margin:0,fontSize:"0.75rem",color:"var(--graview-ink-muted)"},"data-testid":"first-look-count",children:[c," of ",n]}),(0,f.jsx)("p",{id:`${m}-title`,style:{margin:"2px 0 4px",fontWeight:600,fontSize:"0.9375rem"},"data-testid":"first-look-title",children:a.title}),(0,f.jsx)("p",{id:`${m}-words`,style:{margin:0},"data-testid":"first-look-words",children:a.words}),(0,f.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",justifyContent:"flex-end",gap:8,marginTop:12},children:[u?null:(0,f.jsx)("button",{type:"button","data-testid":"first-look-skip",onClick:()=>d("dismissed",!0),style:{...P,fontWeight:500,border:"1px solid transparent",background:"none",color:"var(--graview-ink-muted)"},children:"Skip"}),(0,f.jsx)("button",{ref:y,type:"button","data-testid":u?"first-look-done":"first-look-next",onClick:()=>u?d("finished",!0):h(),style:{...P,border:"1px solid var(--graview-accent)",background:"var(--graview-accent)",color:"var(--graview-accent-ink)"},children:u?"Done":"Next"})]})]})}export{_ as FirstLookHints,E as firstLookAnchor};
|
|
@@ -1,2 +1,2 @@
|
|
|
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 Q,b as Ge,c as Ve,f as ue,i as Ke}from"./chunk.
|
|
2
|
-
`)}function ut(n,r){let{store:o}=n,i=c=>Object.fromEntries(Object.entries(c).filter(([,l])=>l!==void 0&&typeof l!="object").map(([l,s])=>[l,typeof s=="string"?s.slice(0,80):s]));return{kinds:(r.kind?[r.kind]:o.schema.kinds.slice(0,6)).map(c=>{let l=o.graph.nodesOfKind(c),s=o.schema.tryDefinition(c);return{kind:c,count:l.length,fields:Object.keys(s?.fields?.shape??{}),relations:Object.keys(s?.edges??{}),some:(r.record?l.filter(u=>u.id===r.record):l.slice(0,3)).map(i)}})}}function ft(n,r){let o=n.store.schema,i=new Set,d=new Set;for(let c of o.definitions)for(let[l,s]of Object.entries(c.edges??{})){let u=Array.isArray(s?.to)?s.to:[];if(r.kind===void 0||c.kind===r.kind||u.includes(r.kind)){d.add(l);for(let P of[c.kind,...u])P!==r.kind&&o.tryDefinition(P)&&i.add(P)}}if(r.kind===void 0)for(let c of o.kinds)i.add(c);return{kinds:[...i],edges:[...d]}}var Ue={manifest:"The view could not start: what it reads is not this app's.",source:"The script is too long: make it shorter.",start:"The script did not start: it must be one plain script, with no syntax errors, that calls graview.onProps and graview.render.",error:"The script threw while drawing: read only what props gives (props.nodes for a list, props.node for one record), guard each value that may be missing, and call no function that does not exist."};async function We(n,r,o=15e3){let i=Date.now()+o;for(;Date.now()<i;){for(let c of document.querySelectorAll("[data-worker-view-place]")){let l=xe(c),s=l?.name===n?l.drawing().root:void 0;if(l&&c.isConnected&&s?.isConnected&&s.childElementCount>0&&(r===void 0||await l.source()===r))return{element:c,handle:l}}let d=document.querySelector(`[data-worker-view-fell-back="${CSS.escape(n)}"]`);if(d)return{failed:Ue[d.getAttribute("data-worker-view-failed")??""]??Ue.error};await dt(80)}return{failed:"The view did not draw in time: keep it simple and quick to draw."}}var pe=new Map,pt=(n,r)=>{let o=pe.get(n);return o||pe.set(n,o={phase:r(),steps:[],before:!1,putBack:null,began:!1,original:null,markup:null,talk:[],events:[],since:Date.now(),stop:null,covering:!1,pointed:null,about:null,kept:null,pressed:null,version:0,heard:new Set}),o};function he(n,r){return r.record?[n.graph.getNode(r.record)].filter(o=>o!==void 0):r.kind?n.graph.nodesOfKind(r.kind):n.schema.kinds.flatMap(o=>n.graph.nodesOfKind(o))}var Y=(n,r)=>r?Re(n.schema.tryDefinition(r.kind),r):"";function gt(n,r,o){let i=T(o).toLowerCase();return he(n,r).map(d=>Y(n,d)).filter(d=>d.length>1&&i.includes(T(d).toLowerCase())).slice(0,40)}function ze(n,r){let o=r.kind?[r.kind]:n.schema.kinds,i=[...new Set(o.flatMap(c=>Object.keys(n.schema.tryDefinition(c)?.fields?.shape??{})))],d={};for(let c of he(n,r).slice(0,400))for(let l of i){let s=c[l];if(s==null||typeof s=="object")continue;let u=d[l]??=[];u.length<60&&!u.includes(s)&&u.push(s)}return{fields:i,values:d}}function $t({ask:n,close:r}){let o=$e(),{ai:i,aiDesk:d,aiHere:c,session:l,principal:s,keptViews:u,store:D,onProposeChange:P,composeChange:w,onDraftChange:O,app:q}=o,a=n.part,e=(0,g.useMemo)(()=>pt(n.at,()=>n.mode==="highlight"?{at:"highlighting"}:{at:"open"}),[n]),H=(0,g.useCallback)(t=>(e.heard.add(t),()=>void e.heard.delete(t)),[e]),S=(0,g.useSyncExternalStore)(H,()=>e.phase,()=>e.phase),Ye=(0,g.useSyncExternalStore)(H,()=>e.version,()=>e.version),A=(0,g.useCallback)(()=>{e.version+=1,e.heard.forEach(t=>t())},[e]),k=(0,g.useCallback)(t=>{e.phase=t,A()},[e,A]),C=(0,g.useCallback)(async()=>{let t=e.putBack;e.putBack=null,t&&await t()},[e]),Z=(0,g.useCallback)(()=>{e.stop?.abort(),e.stop=null,C(),pe.delete(n.at),r()},[C,n.at,r,e]),b=(0,g.useCallback)(()=>a.main?.isConnected?a.main:yt(),[a]),G={name:a.name,slot:a.slot,...a.kind?{kind:a.kind}:{},...a.group?{group:a.group}:{}},me=a.place??(a.kind?`${a.kind}-${a.slot}`:"home"),Ze=n.fromScene?`From the scene: Better UI changes how \u201C${a.name}\u201D looks on its page here, for everyone in this app.`:`This changes how ${a.name} looks for everyone in this app.`,M=(0,g.useCallback)((t,f,p,h={})=>({id:De(),at:new Date().toISOString(),by:s,target:{on:"place",place:me},targetLabel:a.name,ask:{kind:"section",said:t},offered:[],outcome:f,stages:p.map(m=>({stage:m.stage,ms:m.ms,model:m.model})),usage:p.flatMap(m=>m.usage?[{tier:m.stage==="light"?"fast":"thinking",model:m.model,inputTokens:m.usage.inputTokens,outputTokens:m.usage.outputTokens}]:[]),...h}),[s,me,a.name]),we=P!==void 0&&w!==void 0&&Ee(D,s),B=(0,g.useMemo)(()=>kt(o,a),[o,a]),$=Le(G,ft(o,a),B.map(t=>t.act)),ke=$!==void 0&&typeof u?.fork=="function"&&typeof u.draftFork=="function"&&u.current().may.views===!0,ye=a.slot==="record"?{page:"record",kind:a.kind}:a.slot==="home"?{page:"home"}:{page:"list",kind:a.kind??""},V=(0,g.useCallback)(t=>({manifest:$,source:t,from:ye,said:""}),[$,ye]),ve=S.at==="working";(0,g.useEffect)(()=>{if(!ve)return;let t=a.record??(a.kind?`kind:${a.kind}`:null);return c({participant:`agent:graview-for-${s.id??"anyone"}:${l}`,kind:"agent",name:"Graview",...s.id?{onBehalfOf:s.id}:{},over:t,robot:{at:t,mode:"thinking"}}),()=>c(null)},[ve]);let x=(0,g.useCallback)(()=>{if(e.original)return e.original;let t=b(),f=t?.innerText??"";return e.original=Q(X(t),gt(o.store,a,f||(t?.textContent??""))),e.original},[e,b,o,a]),I=(0,g.useCallback)(()=>Q(X(b()),x().records.map(t=>t.label)),[b,x]),K=(0,g.useCallback)(async t=>{if(await C(),t.kind==="spec"){let f=await O(Je(t.edits,t.said,i.name));e.putBack=f.undo}else u.draftFork(V(t.source)),e.putBack=()=>u.draftFork(null)},[C,O,e,u,V,i.name]),L=(0,g.useCallback)(async()=>{let t=e.steps.at(-1);e.before=!1,t?await K(t):await C()},[e,K,C]),v=(0,g.useCallback)((t,f)=>{e.talk.push({who:t,said:f}),A()},[e,A]),F=(0,g.useCallback)(t=>{e.events.at(-1)?.kind==="streaming"&&e.events.pop(),e.events.push(t),A()},[e,A]),U=()=>e.talk.filter(t=>t.who==="person").map(t=>t.said).join(" "),be=(0,g.useCallback)(async t=>{if(!we||!O)return!1;let p=(await (__graviewPreload(import.meta.url,["./chunk.7ZTGB4O7.js","./chunk.TBY5IR7C.js","./chunk.BIDL7GQD.js","./chunk.Q5WEOX3Q.js","./chunk.KAM73WVF.js","./chunk.O32F6LGK.js","./chunk.R3GE37OI.js","./chunk.2KCDLCB2.js","./chunk.UD7VLXPM.js","./chunk.3DEWQDP7.js","./chunk.6AANHELP.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.ZMADWPJO.js"))).documentOfApp(q??{});if(!p)return!1;let h=e.steps.at(-1);if(h&&h.kind!=="spec")return!1;let m=h?.edits??[],y=m.length>0?w({document:p,edits:m}):void 0,j=y?.ok?y.document:p;if(!(t.mode==="just"?{can:!0}:await Ne(i,t.words,G)).can)return!1;F({kind:"look",text:`Looking at how ${a.name} is set up`});let E=[],ne=await Ie({ai:i,document:j,part:G,mode:t.mode==="choose"?"just":t.mode,...t.words?{words:t.words}:{},...t.pointed?{highlighted:[t.pointed.name,...t.pointed.lines]}:{},shows:lt(b(),30),judge:async W=>{let _=w({document:p,edits:[...m,...W]});return _.ok?(E=_.said,[]):[_.refused]}});if(!ne.ok)return!1;let at=[...m,...ne.edits],Oe=M(`Make \u201C${a.name}\u201D better: ${t.words}`,"offered",ne.stages),oe=_e(b()),re={kind:"spec",edits:at,said:E[E.length-1]??E[0]??`${a.name} changed.`,entry:Oe};e.covering=!0,A();try{await K(re);let W=oe;for(let st=Date.now()+1500;Date.now()<st&&W===oe;)await fe(),W=_e(b());let _=W===oe?["nothing changed"]:se(x(),I(),{...ze(o.store,a),asked:U()});if(_.length>0)return await L(),d.record({...Oe,outcome:"failed",failed:_.join(" ")}),!1}catch{return await L(),!1}finally{e.covering=!1,A()}return e.steps.push(re),e.before=!1,F({kind:"passed",text:"Changed its settings \u2014 it's on the page"}),v("graview",`Done: ${re.said.replace(/\.$/,"")}.`),!0},[i,d,q,w,M,e,o,b,O,x,I,a,G,K,L,we,F,v,A]),Se=(0,g.useCallback)(async t=>{if(!$||!u?.draftFork)return{findings:["This page cannot be drawn anew here."],drew:void 0};let f=x();e.covering=!0,A();try{u.draftFork(V(t)),e.putBack=()=>u.draftFork(null);let p=await We($.name,t),h;if("failed"in p)h=[p.failed];else{let y=[...await p.handle.check(t),...p.handle.refused().filter(j=>!/^Refused a rule of the stylesheet\b/.test(j))];if(y.length>0)h=y;else{await fe(),await fe();let j=p.element.closest("[data-graview-page-main], main")??X(b());h=se(f,Q(j,f.records.map(E=>E.label)),{...ze(o.store,a),asked:U()});let R=p.handle.presses?await p.handle.presses(t).catch(()=>{}):void 0;R&&(e.pressed=R,h=[...h,...ie(R,Xe(f,ge(o,a,f)),B.filter(E=>E.toggle).map(E=>E.act),z(a))])}}let m=le(I());if(h.length===0){let y=M(`Draw \u201C${a.name}\u201D anew: ${U()}`,"offered",[]);e.steps.push({kind:"view",source:t,said:Be(a.name,f,I())??`${a.name} has a new design. Compare Before and After.`,entry:y}),e.before=!1}else await L();return{findings:h,drew:m}}finally{e.covering=!1,A()}},[$,u,x,e,A,V,I,o,a,M,L]),Pe=(0,g.useCallback)(async(t=[])=>{if(!$||!ke){v("graview","Its settings can't do that, and a new design can't be drawn for it here.");return}let f=new AbortController;e.stop=f,e.markup??=Qe(b());let p=e.steps.length,h=[...e.steps].reverse().find(y=>y.kind==="view"),m=await He({ai:i,part:G,manifest:$,talk:e.talk,keep:ht(x(),b(),a.name,o,a),...e.markup?{markup:e.markup}:{},...h?{current:h.source}:e.kept?{current:e.kept}:{},host:{look:()=>le(I()),read:()=>ut(o,a),draft:Se},onEvent:y=>F(y),...e.about?{about:e.about}:{},acts:B,...t.length>0?{pressed:t}:{},noun:z(a),signal:f.signal});if(e.stop===f){if(e.stop=null,e.events.at(-1)?.kind==="streaming"&&e.events.pop(),d.record(M(`Draw \u201C${a.name}\u201D anew: ${U()}`,e.steps.length>p?"offered":"failed",m.stages,e.steps.length>p?{}:{failed:m.last?.findings.join(" ")??m.said})),m.passed){let y=e.pressed?de(e.pressed,B,z(a)):void 0,j=Fe.test(m.said)?void 0:m.said;v("graview",[j??(y?void 0:"Here it is on the page."),y].filter(Boolean).join(" "))}else v("graview",m.said);m.ended==="stuck"&&k({at:"stuck",...m.keepable&&m.last?{source:m.last.source}:{}})}},[i,d,B,I,M,ke,e,o,Se,b,$,x,a,G,v,k,F]),Ae=(0,g.useCallback)(async()=>{let f=[...e.steps].reverse().find(R=>R.kind==="view")?.source??e.kept;if(!f||!$)return[];F({kind:"look",text:"Pressing every control on the page"});let p=await We($.name);if("failed"in p||!p.handle.presses)return[];let h=await p.handle.presses(f).catch(()=>{});if(!h)return[];e.pressed=h;let m=x(),y=ie(h,Xe(m,ge(o,a,m)),B.filter(R=>R.toggle).map(R=>R.act),z(a)),j=y.length>0?y:h.controls.slice(0,8).map(R=>`${R.control}: ${R.says}`);return F(y.length>0?{kind:"check",text:`Check: ${y.length} ${y.length===1?"control doesn't":"controls don't"} work \u2014 fixing`}:{kind:"passed",text:"Check: every control works"}),v("graview",y.length>0?`I pressed every control: ${y.join(" ")}`:`I pressed every control. ${de(h,B,z(a))??"Each one did what it says."}`),j},[B,e,o,$,x,a,v,F]),J=(0,g.useCallback)(async(t,f="describe")=>{if(e.phase.at==="working")return;let p=e.pointed;e.pointed=null;let h={mode:f,words:t,...p?{pointed:p}:{}};e.about=p??e.about,v("person",t),e.events=[],e.since=Date.now(),k({at:"working"}),x(),e.markup??=Qe(b());let m=ce.test(t)?await Ae().catch(()=>[]):[];!ce.test(t)&&await be(h).catch(()=>!1)||await Pe(m),e.phase.at==="working"&&k(e.steps.length>0?{at:"draft"}:{at:"open"})},[Pe,be,e,b,x,Ae,v,k]),ee=(0,g.useCallback)(()=>{if(e.phase.at!=="working")return;let t=e.stop;e.stop=null,t?.abort(),e.covering=!1,e.steps=e.steps.filter(f=>f.entry.at<new Date(e.since).toISOString()),L(),v("graview","Stopped. The page is as it was."),k(e.steps.length>0?{at:"draft"}:{at:"open"})},[e,v,k,L]),et=(0,g.useCallback)(async t=>{let f=e.steps.at(-1);!f||t===e.before||(e.before=t,A(),t?await C():await K(f))},[e,C,K,A]),te=(0,g.useCallback)(async()=>{let t=e.steps.at(-1);if(!(!t||e.phase.at!=="draft")){k({at:"keeping"});try{let f,p;if(t.kind==="spec"){await C();let h=await P(Je(t.edits,t.said,i.name));if(h==="declined")return v("graview","It wasn't kept."),k({at:"draft"});typeof h=="object"&&([f,p]=[h.undo,h.note])}else{let h=await u.fork(V(t.source));e.putBack=null,u.draftFork?.(null),e.kept=t.source,h&&([f,p]=[h.undo,h.note])}d.record({...t.entry,outcome:"accepted"}),e.steps=[],e.before=!1,k({at:"kept",...f?{undo:f}:{},...p?{note:p}:{}})}catch{v("graview","It couldn't be kept."),k({at:"draft"})}}},[e,k,C,P,i.name,u,V,d,v]),tt=(0,g.useCallback)(async t=>{if(e.phase.at!=="stuck")return;let f={kind:"view",source:t,said:`${a.name} kept as it was last drafted.`,entry:M(`Draw \u201C${a.name}\u201D anew: ${U()}`,"offered",[])};e.steps.push(f),e.phase={at:"draft"},await te(),e.steps.at(-1)===f&&(e.steps.pop(),k(e.steps.length>0?{at:"draft"}:{at:"open"}))},[e,a.name,M,te,k]),nt=(0,g.useCallback)(()=>{v("graview","Stopped. The page is as it was."),k(e.steps.length>0?{at:"draft"}:{at:"open"})},[e,v,k]),ot=(0,g.useCallback)(()=>{let t=e.steps.at(-1);t&&d.record({...t.entry,outcome:"dismissed"}),e.steps=[],e.before=!1,C(),v("graview","Put back as it was."),k({at:"open"})},[e,d,C,v,k]),rt=(0,g.useCallback)(async()=>{if(!(e.phase.at!=="kept"||!e.phase.undo))try{await e.phase.undo(),e.kept=null,v("graview","Undone. The page is as it was."),k({at:"undone"})}catch{v("graview","It couldn't be put back.")}},[e,v,k]);if((0,g.useEffect)(()=>{e.began||!(n.mode==="just"||n.mode==="describe"&&n.words)||(e.began=!0,J(n.mode==="just"?"Make it easier to read at a glance":n.words,n.mode))},[e,n.mode,n.words,J]),(0,g.useEffect)(()=>{let t=f=>{if(f.key!=="Escape"||e.phase.at==="highlighting")return;if(f.preventDefault(),e.phase.at==="working")return ee();Z();let p=n.returnTo?.isConnected?n.returnTo:document.querySelector("[data-graview-page-title], main h1");p&&!p.hasAttribute("tabindex")&&!p.matches("a[href], button, input, select, textarea")&&p.setAttribute("tabindex","-1"),p?.focus?.()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,Z,ee,n.returnTo]),S.at==="highlighting")return(0,N.jsx)(Ke,{box:b(),root:b(),whole:a.elements,wholeSaid:"The whole page",cancel:()=>k({at:"open"}),chose:t=>{e.pointed={name:Me(t)??je(t.map(ue)),lines:qe(t.map(ue))},k({at:"open"})}});let Te=e.steps.at(-1);return(0,N.jsxs)(N.Fragment,{children:[e.covering?(0,N.jsx)(Ge,{over:b(),name:a.name,said:`Graview is drafting \u201C${a.name}\u201D\u2026`}):null,(0,N.jsx)(Ve,{name:a.name,scope:Ze,phase:S.at,talk:e.talk,steps:e.events,since:e.since,working:S.at==="working"||S.at==="keeping",...Te&&S.at==="draft"?{draft:{said:Te.said,before:e.before}}:{},...S.at==="kept"?{kept:{...S.note?{note:S.note}:{},...S.undo?{undo:()=>void rt()}:{}}}:{},...S.at==="stuck"?{stuck:{...S.source!==void 0?{keepAnyway:()=>void tt(S.source)}:{},stop:nt}}:{},about:(e.pointed??e.about)?.name??a.name,ask:t=>void J(t),just:()=>void J("Make it easier to read at a glance","just"),point:()=>k({at:"highlighting"}),stop:ee,compare:t=>void et(t),keep:()=>void te(),discard:ot,close:Z})]})}function Je(n,r,o){return{said:r,add:[],drop:[],card:{said:r,adds:[],keeps:[],drops:[],breaking:[]},edits:n,via:`ai:${o??"model"}`}}function ht(n,r,o,i,d){let c=X(r),l=d.slot==="home"?[...r?.querySelectorAll("h1")??[]].find(w=>c!==r&&!c?.contains(w)):void 0,s=T(l?.textContent)||T(c?.querySelector("[data-graview-page-title]")?.textContent)||(d.slot==="home"?"":T(c?.querySelector("h1")?.textContent))||(d.record?T(Y(i.store,i.store.graph.getNode(d.record))):"")||o,u=ge(i,d,n),D=Object.fromEntries(n.records.flatMap(w=>w.facts?.length||w.under&&w.under!==s?[[w.label,{...u[w.label]?{id:u[w.label]}:{},...w.facts?.length?{shows:w.facts}:{},...w.under&&w.under!==s?{under:w.under}:{}}]]:[])),P=wt(i,n,u,s);return{title:s,headings:n.headings.filter(w=>w!==s),records:n.records.map(w=>w.label),...Object.keys(D).length>0?{says:D}:{},...P?{grouping:P}:{}}}function mt(n,r,o){let i=he(n,r),d={};for(let c of o.records){let l=i.find(s=>T(Y(n,s))===T(c.label));l&&(d[c.label]=l.id)}return d}var ge=(n,r,o)=>mt(n.store,r,o);function wt(n,r,o,i){let{store:d}=n,c=r.records.filter(O=>O.under&&O.under!==i&&o[O.label]);if(c.length<2)return;let l=d.graph.allEdges(),s=new Map;for(let O of c){let q=o[O.label];for(let a of l){let e=a.from===q?a.to:a.to===q?a.from:void 0,H=e!==void 0?d.graph.getNode(e):void 0;if(!H||T(Y(d,H))!==T(O.under))continue;let S=`${a.kind}\0${H.kind}\0${a.from===q?"from":"to"}`;s.set(S,(s.get(S)??0)+1)}}let u=[...s].sort((O,q)=>q[1]-O[1])[0];if(!u||u[1]<c.length/2)return;let[D,P,w]=u[0].split("\0");return{edge:D,kind:P,record:w}}var X=n=>n?.querySelector("main")??n;function Qe(n){if(!n?.isConnected)return null;let r=(n.querySelector("main")??n).cloneNode(!0);for(let i of r.querySelectorAll("[data-graview-listed], [data-graview-record]")){let d=i.querySelector("a[href]");d&&d.setAttribute("data-record",i.getAttribute("data-graview-listed")??i.getAttribute("data-graview-record")??"")}for(let i of r.querySelectorAll("a[aria-label]"))T(i.textContent)||(i.textContent=i.getAttribute("aria-label"));for(let i of r.querySelectorAll("script, style, svg, button, input, select, textarea, [hidden], [aria-hidden='true'], [data-graview-popover]"))i.remove();for(let i of[r,...r.querySelectorAll("*")])for(let d of[...i.getAttributeNames()])d==="data-record"&&i.localName==="a"||i.removeAttribute(d);let o=r.outerHTML.replace(/\s+/g," ").replace(/<(div|span)>\s*<\/\1>/g,"").trim();return o.length>6e3?o.slice(0,6e3):o}var z=n=>n.slot==="list"||n.slot==="group"?n.name.toLowerCase():n.slot==="record"?"parts":"records";function Xe(n,r){return n.records.flatMap(o=>r[o.label]?[{label:o.label,id:r[o.label],...o.presses?{presses:!0}:{},...o.opens?{opens:!0}:{}}]:[])}function kt(n,r){let{store:o}=n,i=r.kind?[r.kind]:o.schema.kinds,d=l=>o.schema.tryDefinition(l)?.fields?.shape??{},c=l=>{let s=l?._zod?.def;for(let u=0;u<6&&s&&s.type!=="boolean"&&s.innerType!==void 0;u++)s=s.innerType._zod?.def;return s?.type==="boolean"};return o.allMutations().flatMap(l=>{let s=l.subject;if(!s||l.creates?.length)return[];let u=i.find(w=>s.kinds==="*"||s.kinds.includes(w));if(!u)return[];let D=l.writes??[],P=D.length===1&&c(d(u)[D[0]])?D[0]:void 0;return[{act:l.name,title:String(l.title??l.name),record:s.arg,...P?{toggle:P}:{}}]}).slice(0,24)}function yt(){return document.querySelector("[data-graview-page-main], main")??document.querySelector("[data-graview-face]")}export{$t as PageCard,_e as drawnSignature,ze as fieldsShownOf,gt as labelsShown,Qe as markupOf,lt as outlineOf,mt as recordIdsOf};
|
|
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 Q,b as Ge,c as Ve,f as ue,i as Ke}from"./chunk.AG7WJYM5.js";import"./chunk.KHKCTVHD.js";import{b as je,c as qe,d as Me,f as se,g as Be,h as ie,i as de,j as Fe,k as ce,m as Ne,n as Ie,o as Le,p as He,q as le}from"./chunk.DO3FQM6R.js";import"./chunk.NYLKG25K.js";import{a as Ee}from"./chunk.TBY5IR7C.js";import{d as De}from"./chunk.VR553M6J.js";import"./chunk.DU76ASS4.js";import"./chunk.BJUUSIQY.js";import"./chunk.UPOYRCKI.js";import"./chunk.XOZU4OFA.js";import"./chunk.WV6SP6IJ.js";import"./chunk.ZE5RSKXF.js";import"./chunk.MIE4TJRW.js";import{x as xe}from"./chunk.SCVKHGO3.js";import"./chunk.RD2FSSLV.js";import"./chunk.AZRICZKT.js";import"./chunk.MH3AQO2R.js";import"./chunk.J2N7EKMX.js";import"./chunk.P26ATAAI.js";import"./chunk.FIY4RUK5.js";import"./chunk.IY3DV52G.js";import"./chunk.NLZHNPDU.js";import"./chunk.QNC2OKLF.js";import{G as it,W as Ce,ea as $e}from"./chunk.FWXW4T4I.js";import"./chunk.SDO3U72B.js";import{la as Re}from"./chunk.DHPXRDT5.js";import"./chunk.FQLNBIQ5.js";import{b as ae}from"./chunk.AJZBJBMO.js";var g=ae(it(),1);var N=ae(Ce(),1),T=n=>(n??"").replace(/\s+/g," ").trim(),fe=()=>new Promise(n=>requestAnimationFrame(()=>n())),dt=n=>new Promise(r=>setTimeout(r,n));function ct(n){let r=n.cloneNode(!0);for(let o of r.querySelectorAll("span"))o.remove();return T(r.textContent).replace(/^[▸▾]\s*/,"")}function _e(n){if(!n||!n.isConnected)return"";let r=n.innerText??n.textContent??"";return`${n.querySelectorAll("*").length}|${T(r)}`}function lt(n,r=80){if(!n)return"";let o=[],i=new Set,d="li, tr, article, [data-graview-listed], [data-graview-record], [data-graview-field]";for(let c of n.querySelectorAll(`h1, h2, h3, h4, ${d}`)){if(o.length>=r)break;if([...i].some(u=>u.contains(c))||c.closest("[data-graview-popover], [hidden], nav, [aria-hidden='true']"))continue;let l=/^h([1-4])$/i.exec(c.localName),s=(l?ct(c):T(c.innerText??c.textContent)).slice(0,140);if(s)if(l)o.push(`${"#".repeat(Number(l[1]))} ${s}`);else{let u=c.getAttribute("data-graview-field");o.push(u?`${u}: ${s}`:`- ${s}`),i.add(c)}}return o.join(`
|
|
2
|
+
`)}function ut(n,r){let{store:o}=n,i=c=>Object.fromEntries(Object.entries(c).filter(([,l])=>l!==void 0&&typeof l!="object").map(([l,s])=>[l,typeof s=="string"?s.slice(0,80):s]));return{kinds:(r.kind?[r.kind]:o.schema.kinds.slice(0,6)).map(c=>{let l=o.graph.nodesOfKind(c),s=o.schema.tryDefinition(c);return{kind:c,count:l.length,fields:Object.keys(s?.fields?.shape??{}),relations:Object.keys(s?.edges??{}),some:(r.record?l.filter(u=>u.id===r.record):l.slice(0,3)).map(i)}})}}function ft(n,r){let o=n.store.schema,i=new Set,d=new Set;for(let c of o.definitions)for(let[l,s]of Object.entries(c.edges??{})){let u=Array.isArray(s?.to)?s.to:[];if(r.kind===void 0||c.kind===r.kind||u.includes(r.kind)){d.add(l);for(let P of[c.kind,...u])P!==r.kind&&o.tryDefinition(P)&&i.add(P)}}if(r.kind===void 0)for(let c of o.kinds)i.add(c);return{kinds:[...i],edges:[...d]}}var Ue={manifest:"The view could not start: what it reads is not this app's.",source:"The script is too long: make it shorter.",start:"The script did not start: it must be one plain script, with no syntax errors, that calls graview.onProps and graview.render.",error:"The script threw while drawing: read only what props gives (props.nodes for a list, props.node for one record), guard each value that may be missing, and call no function that does not exist."};async function We(n,r,o=15e3){let i=Date.now()+o;for(;Date.now()<i;){for(let c of document.querySelectorAll("[data-worker-view-place]")){let l=xe(c),s=l?.name===n?l.drawing().root:void 0;if(l&&c.isConnected&&s?.isConnected&&s.childElementCount>0&&(r===void 0||await l.source()===r))return{element:c,handle:l}}let d=document.querySelector(`[data-worker-view-fell-back="${CSS.escape(n)}"]`);if(d)return{failed:Ue[d.getAttribute("data-worker-view-failed")??""]??Ue.error};await dt(80)}return{failed:"The view did not draw in time: keep it simple and quick to draw."}}var pe=new Map,pt=(n,r)=>{let o=pe.get(n);return o||pe.set(n,o={phase:r(),steps:[],before:!1,putBack:null,began:!1,original:null,markup:null,talk:[],events:[],since:Date.now(),stop:null,covering:!1,pointed:null,about:null,kept:null,pressed:null,version:0,heard:new Set}),o};function he(n,r){return r.record?[n.graph.getNode(r.record)].filter(o=>o!==void 0):r.kind?n.graph.nodesOfKind(r.kind):n.schema.kinds.flatMap(o=>n.graph.nodesOfKind(o))}var Y=(n,r)=>r?Re(n.schema.tryDefinition(r.kind),r):"";function gt(n,r,o){let i=T(o).toLowerCase();return he(n,r).map(d=>Y(n,d)).filter(d=>d.length>1&&i.includes(T(d).toLowerCase())).slice(0,40)}function ze(n,r){let o=r.kind?[r.kind]:n.schema.kinds,i=[...new Set(o.flatMap(c=>Object.keys(n.schema.tryDefinition(c)?.fields?.shape??{})))],d={};for(let c of he(n,r).slice(0,400))for(let l of i){let s=c[l];if(s==null||typeof s=="object")continue;let u=d[l]??=[];u.length<60&&!u.includes(s)&&u.push(s)}return{fields:i,values:d}}function $t({ask:n,close:r}){let o=$e(),{ai:i,aiDesk:d,aiHere:c,session:l,principal:s,keptViews:u,store:D,onProposeChange:P,composeChange:w,onDraftChange:O,app:q}=o,a=n.part,e=(0,g.useMemo)(()=>pt(n.at,()=>n.mode==="highlight"?{at:"highlighting"}:{at:"open"}),[n]),H=(0,g.useCallback)(t=>(e.heard.add(t),()=>void e.heard.delete(t)),[e]),S=(0,g.useSyncExternalStore)(H,()=>e.phase,()=>e.phase),Ye=(0,g.useSyncExternalStore)(H,()=>e.version,()=>e.version),A=(0,g.useCallback)(()=>{e.version+=1,e.heard.forEach(t=>t())},[e]),k=(0,g.useCallback)(t=>{e.phase=t,A()},[e,A]),C=(0,g.useCallback)(async()=>{let t=e.putBack;e.putBack=null,t&&await t()},[e]),Z=(0,g.useCallback)(()=>{e.stop?.abort(),e.stop=null,C(),pe.delete(n.at),r()},[C,n.at,r,e]),b=(0,g.useCallback)(()=>a.main?.isConnected?a.main:yt(),[a]),G={name:a.name,slot:a.slot,...a.kind?{kind:a.kind}:{},...a.group?{group:a.group}:{}},me=a.place??(a.kind?`${a.kind}-${a.slot}`:"home"),Ze=n.fromScene?`From the scene: Better UI changes how \u201C${a.name}\u201D looks on its page here, for everyone in this app.`:`This changes how ${a.name} looks for everyone in this app.`,M=(0,g.useCallback)((t,f,p,h={})=>({id:De(),at:new Date().toISOString(),by:s,target:{on:"place",place:me},targetLabel:a.name,ask:{kind:"section",said:t},offered:[],outcome:f,stages:p.map(m=>({stage:m.stage,ms:m.ms,model:m.model})),usage:p.flatMap(m=>m.usage?[{tier:m.stage==="light"?"fast":"thinking",model:m.model,inputTokens:m.usage.inputTokens,outputTokens:m.usage.outputTokens}]:[]),...h}),[s,me,a.name]),we=P!==void 0&&w!==void 0&&Ee(D,s),B=(0,g.useMemo)(()=>kt(o,a),[o,a]),$=Le(G,ft(o,a),B.map(t=>t.act)),ke=$!==void 0&&typeof u?.fork=="function"&&typeof u.draftFork=="function"&&u.current().may.views===!0,ye=a.slot==="record"?{page:"record",kind:a.kind}:a.slot==="home"?{page:"home"}:{page:"list",kind:a.kind??""},V=(0,g.useCallback)(t=>({manifest:$,source:t,from:ye,said:""}),[$,ye]),ve=S.at==="working";(0,g.useEffect)(()=>{if(!ve)return;let t=a.record??(a.kind?`kind:${a.kind}`:null);return c({participant:`agent:graview-for-${s.id??"anyone"}:${l}`,kind:"agent",name:"Graview",...s.id?{onBehalfOf:s.id}:{},over:t,robot:{at:t,mode:"thinking"}}),()=>c(null)},[ve]);let x=(0,g.useCallback)(()=>{if(e.original)return e.original;let t=b(),f=t?.innerText??"";return e.original=Q(X(t),gt(o.store,a,f||(t?.textContent??""))),e.original},[e,b,o,a]),I=(0,g.useCallback)(()=>Q(X(b()),x().records.map(t=>t.label)),[b,x]),K=(0,g.useCallback)(async t=>{if(await C(),t.kind==="spec"){let f=await O(Je(t.edits,t.said,i.name));e.putBack=f.undo}else u.draftFork(V(t.source)),e.putBack=()=>u.draftFork(null)},[C,O,e,u,V,i.name]),L=(0,g.useCallback)(async()=>{let t=e.steps.at(-1);e.before=!1,t?await K(t):await C()},[e,K,C]),v=(0,g.useCallback)((t,f)=>{e.talk.push({who:t,said:f}),A()},[e,A]),F=(0,g.useCallback)(t=>{e.events.at(-1)?.kind==="streaming"&&e.events.pop(),e.events.push(t),A()},[e,A]),U=()=>e.talk.filter(t=>t.who==="person").map(t=>t.said).join(" "),be=(0,g.useCallback)(async t=>{if(!we||!O)return!1;let p=(await (__graviewPreload(import.meta.url,["./chunk.3TKIZGC7.js","./chunk.TBY5IR7C.js","./chunk.BIDL7GQD.js","./chunk.Q5WEOX3Q.js","./chunk.MATUPDZ3.js","./chunk.SAWASNDO.js","./chunk.DKUEZPGR.js","./chunk.EP7YT7LT.js","./chunk.I7KN732Z.js","./chunk.TLPCYKLW.js","./chunk.DHPXRDT5.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.VBYJBW32.js"))).documentOfApp(q??{});if(!p)return!1;let h=e.steps.at(-1);if(h&&h.kind!=="spec")return!1;let m=h?.edits??[],y=m.length>0?w({document:p,edits:m}):void 0,j=y?.ok?y.document:p;if(!(t.mode==="just"?{can:!0}:await Ne(i,t.words,G)).can)return!1;F({kind:"look",text:`Looking at how ${a.name} is set up`});let E=[],ne=await Ie({ai:i,document:j,part:G,mode:t.mode==="choose"?"just":t.mode,...t.words?{words:t.words}:{},...t.pointed?{highlighted:[t.pointed.name,...t.pointed.lines]}:{},shows:lt(b(),30),judge:async W=>{let _=w({document:p,edits:[...m,...W]});return _.ok?(E=_.said,[]):[_.refused]}});if(!ne.ok)return!1;let at=[...m,...ne.edits],Oe=M(`Make \u201C${a.name}\u201D better: ${t.words}`,"offered",ne.stages),oe=_e(b()),re={kind:"spec",edits:at,said:E[E.length-1]??E[0]??`${a.name} changed.`,entry:Oe};e.covering=!0,A();try{await K(re);let W=oe;for(let st=Date.now()+1500;Date.now()<st&&W===oe;)await fe(),W=_e(b());let _=W===oe?["nothing changed"]:se(x(),I(),{...ze(o.store,a),asked:U()});if(_.length>0)return await L(),d.record({...Oe,outcome:"failed",failed:_.join(" ")}),!1}catch{return await L(),!1}finally{e.covering=!1,A()}return e.steps.push(re),e.before=!1,F({kind:"passed",text:"Changed its settings \u2014 it's on the page"}),v("graview",`Done: ${re.said.replace(/\.$/,"")}.`),!0},[i,d,q,w,M,e,o,b,O,x,I,a,G,K,L,we,F,v,A]),Se=(0,g.useCallback)(async t=>{if(!$||!u?.draftFork)return{findings:["This page cannot be drawn anew here."],drew:void 0};let f=x();e.covering=!0,A();try{u.draftFork(V(t)),e.putBack=()=>u.draftFork(null);let p=await We($.name,t),h;if("failed"in p)h=[p.failed];else{let y=[...await p.handle.check(t),...p.handle.refused().filter(j=>!/^Refused a rule of the stylesheet\b/.test(j))];if(y.length>0)h=y;else{await fe(),await fe();let j=p.element.closest("[data-graview-page-main], main")??X(b());h=se(f,Q(j,f.records.map(E=>E.label)),{...ze(o.store,a),asked:U()});let R=p.handle.presses?await p.handle.presses(t).catch(()=>{}):void 0;R&&(e.pressed=R,h=[...h,...ie(R,Xe(f,ge(o,a,f)),B.filter(E=>E.toggle).map(E=>E.act),z(a))])}}let m=le(I());if(h.length===0){let y=M(`Draw \u201C${a.name}\u201D anew: ${U()}`,"offered",[]);e.steps.push({kind:"view",source:t,said:Be(a.name,f,I())??`${a.name} has a new design. Compare Before and After.`,entry:y}),e.before=!1}else await L();return{findings:h,drew:m}}finally{e.covering=!1,A()}},[$,u,x,e,A,V,I,o,a,M,L]),Pe=(0,g.useCallback)(async(t=[])=>{if(!$||!ke){v("graview","Its settings can't do that, and a new design can't be drawn for it here.");return}let f=new AbortController;e.stop=f,e.markup??=Qe(b());let p=e.steps.length,h=[...e.steps].reverse().find(y=>y.kind==="view"),m=await He({ai:i,part:G,manifest:$,talk:e.talk,keep:ht(x(),b(),a.name,o,a),...e.markup?{markup:e.markup}:{},...h?{current:h.source}:e.kept?{current:e.kept}:{},host:{look:()=>le(I()),read:()=>ut(o,a),draft:Se},onEvent:y=>F(y),...e.about?{about:e.about}:{},acts:B,...t.length>0?{pressed:t}:{},noun:z(a),signal:f.signal});if(e.stop===f){if(e.stop=null,e.events.at(-1)?.kind==="streaming"&&e.events.pop(),d.record(M(`Draw \u201C${a.name}\u201D anew: ${U()}`,e.steps.length>p?"offered":"failed",m.stages,e.steps.length>p?{}:{failed:m.last?.findings.join(" ")??m.said})),m.passed){let y=e.pressed?de(e.pressed,B,z(a)):void 0,j=Fe.test(m.said)?void 0:m.said;v("graview",[j??(y?void 0:"Here it is on the page."),y].filter(Boolean).join(" "))}else v("graview",m.said);m.ended==="stuck"&&k({at:"stuck",...m.keepable&&m.last?{source:m.last.source}:{}})}},[i,d,B,I,M,ke,e,o,Se,b,$,x,a,G,v,k,F]),Ae=(0,g.useCallback)(async()=>{let f=[...e.steps].reverse().find(R=>R.kind==="view")?.source??e.kept;if(!f||!$)return[];F({kind:"look",text:"Pressing every control on the page"});let p=await We($.name);if("failed"in p||!p.handle.presses)return[];let h=await p.handle.presses(f).catch(()=>{});if(!h)return[];e.pressed=h;let m=x(),y=ie(h,Xe(m,ge(o,a,m)),B.filter(R=>R.toggle).map(R=>R.act),z(a)),j=y.length>0?y:h.controls.slice(0,8).map(R=>`${R.control}: ${R.says}`);return F(y.length>0?{kind:"check",text:`Check: ${y.length} ${y.length===1?"control doesn't":"controls don't"} work \u2014 fixing`}:{kind:"passed",text:"Check: every control works"}),v("graview",y.length>0?`I pressed every control: ${y.join(" ")}`:`I pressed every control. ${de(h,B,z(a))??"Each one did what it says."}`),j},[B,e,o,$,x,a,v,F]),J=(0,g.useCallback)(async(t,f="describe")=>{if(e.phase.at==="working")return;let p=e.pointed;e.pointed=null;let h={mode:f,words:t,...p?{pointed:p}:{}};e.about=p??e.about,v("person",t),e.events=[],e.since=Date.now(),k({at:"working"}),x(),e.markup??=Qe(b());let m=ce.test(t)?await Ae().catch(()=>[]):[];!ce.test(t)&&await be(h).catch(()=>!1)||await Pe(m),e.phase.at==="working"&&k(e.steps.length>0?{at:"draft"}:{at:"open"})},[Pe,be,e,b,x,Ae,v,k]),ee=(0,g.useCallback)(()=>{if(e.phase.at!=="working")return;let t=e.stop;e.stop=null,t?.abort(),e.covering=!1,e.steps=e.steps.filter(f=>f.entry.at<new Date(e.since).toISOString()),L(),v("graview","Stopped. The page is as it was."),k(e.steps.length>0?{at:"draft"}:{at:"open"})},[e,v,k,L]),et=(0,g.useCallback)(async t=>{let f=e.steps.at(-1);!f||t===e.before||(e.before=t,A(),t?await C():await K(f))},[e,C,K,A]),te=(0,g.useCallback)(async()=>{let t=e.steps.at(-1);if(!(!t||e.phase.at!=="draft")){k({at:"keeping"});try{let f,p;if(t.kind==="spec"){await C();let h=await P(Je(t.edits,t.said,i.name));if(h==="declined")return v("graview","It wasn't kept."),k({at:"draft"});typeof h=="object"&&([f,p]=[h.undo,h.note])}else{let h=await u.fork(V(t.source));e.putBack=null,u.draftFork?.(null),e.kept=t.source,h&&([f,p]=[h.undo,h.note])}d.record({...t.entry,outcome:"accepted"}),e.steps=[],e.before=!1,k({at:"kept",...f?{undo:f}:{},...p?{note:p}:{}})}catch{v("graview","It couldn't be kept."),k({at:"draft"})}}},[e,k,C,P,i.name,u,V,d,v]),tt=(0,g.useCallback)(async t=>{if(e.phase.at!=="stuck")return;let f={kind:"view",source:t,said:`${a.name} kept as it was last drafted.`,entry:M(`Draw \u201C${a.name}\u201D anew: ${U()}`,"offered",[])};e.steps.push(f),e.phase={at:"draft"},await te(),e.steps.at(-1)===f&&(e.steps.pop(),k(e.steps.length>0?{at:"draft"}:{at:"open"}))},[e,a.name,M,te,k]),nt=(0,g.useCallback)(()=>{v("graview","Stopped. The page is as it was."),k(e.steps.length>0?{at:"draft"}:{at:"open"})},[e,v,k]),ot=(0,g.useCallback)(()=>{let t=e.steps.at(-1);t&&d.record({...t.entry,outcome:"dismissed"}),e.steps=[],e.before=!1,C(),v("graview","Put back as it was."),k({at:"open"})},[e,d,C,v,k]),rt=(0,g.useCallback)(async()=>{if(!(e.phase.at!=="kept"||!e.phase.undo))try{await e.phase.undo(),e.kept=null,v("graview","Undone. The page is as it was."),k({at:"undone"})}catch{v("graview","It couldn't be put back.")}},[e,v,k]);if((0,g.useEffect)(()=>{e.began||!(n.mode==="just"||n.mode==="describe"&&n.words)||(e.began=!0,J(n.mode==="just"?"Make it easier to read at a glance":n.words,n.mode))},[e,n.mode,n.words,J]),(0,g.useEffect)(()=>{let t=f=>{if(f.key!=="Escape"||e.phase.at==="highlighting")return;if(f.preventDefault(),e.phase.at==="working")return ee();Z();let p=n.returnTo?.isConnected?n.returnTo:document.querySelector("[data-graview-page-title], main h1");p&&!p.hasAttribute("tabindex")&&!p.matches("a[href], button, input, select, textarea")&&p.setAttribute("tabindex","-1"),p?.focus?.()};return document.addEventListener("keydown",t),()=>document.removeEventListener("keydown",t)},[e,Z,ee,n.returnTo]),S.at==="highlighting")return(0,N.jsx)(Ke,{box:b(),root:b(),whole:a.elements,wholeSaid:"The whole page",cancel:()=>k({at:"open"}),chose:t=>{e.pointed={name:Me(t)??je(t.map(ue)),lines:qe(t.map(ue))},k({at:"open"})}});let Te=e.steps.at(-1);return(0,N.jsxs)(N.Fragment,{children:[e.covering?(0,N.jsx)(Ge,{over:b(),name:a.name,said:`Graview is drafting \u201C${a.name}\u201D\u2026`}):null,(0,N.jsx)(Ve,{name:a.name,scope:Ze,phase:S.at,talk:e.talk,steps:e.events,since:e.since,working:S.at==="working"||S.at==="keeping",...Te&&S.at==="draft"?{draft:{said:Te.said,before:e.before}}:{},...S.at==="kept"?{kept:{...S.note?{note:S.note}:{},...S.undo?{undo:()=>void rt()}:{}}}:{},...S.at==="stuck"?{stuck:{...S.source!==void 0?{keepAnyway:()=>void tt(S.source)}:{},stop:nt}}:{},about:(e.pointed??e.about)?.name??a.name,ask:t=>void J(t),just:()=>void J("Make it easier to read at a glance","just"),point:()=>k({at:"highlighting"}),stop:ee,compare:t=>void et(t),keep:()=>void te(),discard:ot,close:Z})]})}function Je(n,r,o){return{said:r,add:[],drop:[],card:{said:r,adds:[],keeps:[],drops:[],breaking:[]},edits:n,via:`ai:${o??"model"}`}}function ht(n,r,o,i,d){let c=X(r),l=d.slot==="home"?[...r?.querySelectorAll("h1")??[]].find(w=>c!==r&&!c?.contains(w)):void 0,s=T(l?.textContent)||T(c?.querySelector("[data-graview-page-title]")?.textContent)||(d.slot==="home"?"":T(c?.querySelector("h1")?.textContent))||(d.record?T(Y(i.store,i.store.graph.getNode(d.record))):"")||o,u=ge(i,d,n),D=Object.fromEntries(n.records.flatMap(w=>w.facts?.length||w.under&&w.under!==s?[[w.label,{...u[w.label]?{id:u[w.label]}:{},...w.facts?.length?{shows:w.facts}:{},...w.under&&w.under!==s?{under:w.under}:{}}]]:[])),P=wt(i,n,u,s);return{title:s,headings:n.headings.filter(w=>w!==s),records:n.records.map(w=>w.label),...Object.keys(D).length>0?{says:D}:{},...P?{grouping:P}:{}}}function mt(n,r,o){let i=he(n,r),d={};for(let c of o.records){let l=i.find(s=>T(Y(n,s))===T(c.label));l&&(d[c.label]=l.id)}return d}var ge=(n,r,o)=>mt(n.store,r,o);function wt(n,r,o,i){let{store:d}=n,c=r.records.filter(O=>O.under&&O.under!==i&&o[O.label]);if(c.length<2)return;let l=d.graph.allEdges(),s=new Map;for(let O of c){let q=o[O.label];for(let a of l){let e=a.from===q?a.to:a.to===q?a.from:void 0,H=e!==void 0?d.graph.getNode(e):void 0;if(!H||T(Y(d,H))!==T(O.under))continue;let S=`${a.kind}\0${H.kind}\0${a.from===q?"from":"to"}`;s.set(S,(s.get(S)??0)+1)}}let u=[...s].sort((O,q)=>q[1]-O[1])[0];if(!u||u[1]<c.length/2)return;let[D,P,w]=u[0].split("\0");return{edge:D,kind:P,record:w}}var X=n=>n?.querySelector("main")??n;function Qe(n){if(!n?.isConnected)return null;let r=(n.querySelector("main")??n).cloneNode(!0);for(let i of r.querySelectorAll("[data-graview-listed], [data-graview-record]")){let d=i.querySelector("a[href]");d&&d.setAttribute("data-record",i.getAttribute("data-graview-listed")??i.getAttribute("data-graview-record")??"")}for(let i of r.querySelectorAll("a[aria-label]"))T(i.textContent)||(i.textContent=i.getAttribute("aria-label"));for(let i of r.querySelectorAll("script, style, svg, button, input, select, textarea, [hidden], [aria-hidden='true'], [data-graview-popover]"))i.remove();for(let i of[r,...r.querySelectorAll("*")])for(let d of[...i.getAttributeNames()])d==="data-record"&&i.localName==="a"||i.removeAttribute(d);let o=r.outerHTML.replace(/\s+/g," ").replace(/<(div|span)>\s*<\/\1>/g,"").trim();return o.length>6e3?o.slice(0,6e3):o}var z=n=>n.slot==="list"||n.slot==="group"?n.name.toLowerCase():n.slot==="record"?"parts":"records";function Xe(n,r){return n.records.flatMap(o=>r[o.label]?[{label:o.label,id:r[o.label],...o.presses?{presses:!0}:{},...o.opens?{opens:!0}:{}}]:[])}function kt(n,r){let{store:o}=n,i=r.kind?[r.kind]:o.schema.kinds,d=l=>o.schema.tryDefinition(l)?.fields?.shape??{},c=l=>{let s=l?._zod?.def;for(let u=0;u<6&&s&&s.type!=="boolean"&&s.innerType!==void 0;u++)s=s.innerType._zod?.def;return s?.type==="boolean"};return o.allMutations().flatMap(l=>{let s=l.subject;if(!s||l.creates?.length)return[];let u=i.find(w=>s.kinds==="*"||s.kinds.includes(w));if(!u)return[];let D=l.writes??[],P=D.length===1&&c(d(u)[D[0]])?D[0]:void 0;return[{act:l.name,title:String(l.title??l.name),record:s.arg,...P?{toggle:P}:{}}]}).slice(0,24)}function yt(){return document.querySelector("[data-graview-page-main], main")??document.querySelector("[data-graview-face]")}export{$t as PageCard,_e as drawnSignature,ze as fieldsShownOf,gt as labelsShown,Qe as markupOf,lt as outlineOf,mt as recordIdsOf};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as B,b as ve}from"./chunk.
|
|
1
|
+
import{a as B,b as ve}from"./chunk.FE3SINPK.js";import{a as ye,c as he,d as be,f as we}from"./chunk.3D37E2G5.js";import{b as S,c as fe,d as me}from"./chunk.MH3AQO2R.js";import{k as ce,l as ge}from"./chunk.J2N7EKMX.js";import{b as pe,k as q}from"./chunk.P26ATAAI.js";import{b as de,e as ue}from"./chunk.FIY4RUK5.js";import{G as Re,W as se,fa as le,h as ae,u as ie}from"./chunk.FWXW4T4I.js";import{Na as te,Ya as re,Za as oe,ga as Z,la as ee,ua as ne}from"./chunk.DHPXRDT5.js";import{b as W}from"./chunk.AJZBJBMO.js";var l=W(Re(),1);var i=W(se(),1);function qe({affordance:n,onApply:a,onCancel:u,store:w}){let y=le(),s=w??y?.store,[x,_]=(0,l.useState)({}),[p,D]=(0,l.useState)(""),[I,F]=(0,l.useState)(G),[J,V]=(0,l.useState)(void 0),U=(0,l.useId)(),L=(0,l.useRef)(null),A=n.open.filter(e=>!(e.name in x)),o=A[0],v=s.allMutations().find(e=>e.name===n.mutation),P=(0,l.useMemo)(()=>De(v,s,n.args??{}),[v,s,n.args]),d=o?P[o.name]:void 0,E=ge(n.open.filter(e=>e.shape?.type==="date").map(e=>e.name)),Se=(()=>{if(!E||o?.name!==E.end||o.shape?.type!=="date")return;let e=x[E.start];if(typeof e!="string")return;let r=P[E.start];return ce(typeof r=="string"?r:void 0,e,typeof d=="string"?d:void 0,{time:o.shape.time===!0,instant:o.shape.instant===!0})})();(0,l.useEffect)(()=>{D(Se??ke(d,o?.shape)),F(Array.isArray(d)?d:G),V(d)},[o?.name]),(0,l.useEffect)(()=>{L.current?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[o?.name]),(0,l.useLayoutEffect)(()=>{let e=L.current,r=typeof document>"u"?null:document.activeElement,f=r instanceof HTMLElement&&r.getAttribute("data-affordance")===n.id;if(!e||r&&r!==document.body&&!e.contains(r)&&!f)return;let b=e.querySelector('[data-testid="ask-filter"], form input, [role=group] button:not([disabled])');b&&b!==r&&b.focus()},[o?.name]);let Y=ve({flow:"both",letters:!0});if(!o)return null;let h=e=>{let r=d!==void 0&&JSON.stringify(e)===JSON.stringify(d)?void 0:e,f={...x,[o.name]:r};if(n.open.filter(R=>!(R.name in f)).length===0){let R=a(Object.fromEntries(Object.entries(f).filter(([,M])=>M!==void 0)));R&&R.length>0&&_(Object.fromEntries(Object.entries(f).filter(([M])=>!R.includes(M))))}else _(f)},O=o.optional?(0,i.jsx)("button",{type:"button",onClick:()=>h(void 0),style:{fontSize:"0.8125rem"},children:"Skip"}):null,t=o.shape??{type:"unknown"},c=t.type==="number"?t.amount:void 0,g=Ee(o,t),m=q(s.schema,v,o.name),Q=te((v?.input?.shape??{})[o.name]),xe=oe((v?.input?.shape??{})[o.name]),N=re(o.name),Ae=typeof d=="boolean"?d?"yes":"no":d,[T,Oe]=(0,l.useState)(""),X=(0,l.useMemo)(()=>{let e=g.map(r=>s.graph.getNode(r)).filter(r=>r!==void 0);return pe(e,r=>s.schema.tryDefinition(r))},[g,s]),j=e=>{let r=Ce(s,t,e),f=t.type==="choice"||t.type==="several"&&t.of.type==="choice"?m.option(e):r,b=X.get(e);return b?`${f} \xB7 ${b}`:f},$=(0,l.useMemo)(()=>{let e=T.trim().toLowerCase();return e===""?g:g.filter(r=>j(r).toLowerCase().includes(e))},[g,T,s,t,X]),k=t.type==="several",H=t.type==="file"?t:t.type==="several"&&t.of.type==="file"?t.of:void 0,K=k&&g.length===0,C=o.kinds&&o.kinds.length>0&&!o.kinds.includes("*")?o.kinds.map(e=>Z(ne(s.schema.tryDefinition(e),e))).join(" or "):m.label,Ne=n.open.length>1?`${C} \xB7 ${n.open.length-A.length+1} of ${n.open.length}`:C;return(0,i.jsxs)("div",{ref:L,"data-graview-asking":n.id,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:4,padding:"5px 0 2px"},children:[n.open.length>1||g.length>0?(0,i.jsx)("span",{id:U,style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:Ne}):null,g.length>z?(0,i.jsx)("input",{type:"search",value:T,onChange:e=>Oe(e.target.value),placeholder:`Filter ${g.length}\u2026`,"aria-label":`Filter ${C}`,"data-testid":"ask-filter",onKeyDown:e=>{if(e.key!=="ArrowDown"||e.metaKey||e.ctrlKey||e.altKey)return;let r=Y.ref.current?.querySelector(`[${B}][tabindex="0"]`);r&&(e.preventDefault(),r.focus())},style:{font:"inherit",fontSize:"0.8125rem",minWidth:0,padding:"3px 7px"}}):null,xe?(0,i.jsxs)("form",{style:{display:"grid",gap:4},onSubmit:e=>{e.preventDefault(),h(J??(d===void 0?void 0:null))},children:[(0,i.jsx)(be,{value:J,onChange:V,start:N?x[N]??P[N]:void 0,label:`${N?q(s.schema,v,N).label:m.label} repeats`,name:o.name}),(0,i.jsxs)("span",{style:{display:"flex",gap:4},children:[(0,i.jsx)("button",{type:"submit",style:{fontSize:"0.8125rem"},children:A.length>1?"Next":"Apply"}),O]})]}):Q?(0,i.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,i.jsx)(he,{relation:Q,value:d,onChange:h,label:m.label}),O]}):H?(0,i.jsxs)("div",{style:{display:"grid",gap:4},children:[(0,i.jsx)(ye,{as:"control",value:d,onChange:h,several:k,image:H.image===!0,video:H.video===!0,label:m.label}),O]}):g.length>0?(0,i.jsxs)("div",{...Y,role:"group","aria-labelledby":U,style:{display:"flex",flexWrap:"wrap",gap:4},children:[$.slice(0,z).map(e=>{let r=k?I.includes(e):e===Ae;return(0,i.jsx)("button",{type:"button",[B]:"","aria-label":`${C}: ${j(e)}`,...k?{"aria-pressed":r}:r?{"aria-current":!0}:{},style:{padding:"3px 9px",fontSize:"0.8125rem",...r?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},onClick:()=>k?F(f=>f.includes(e)?f.filter(b=>b!==e):[...f,e]):h(t.type==="boolean"?e==="yes":e),children:j(e)},e)}),$.length>z?(0,i.jsxs)("span",{"data-testid":"ask-more",style:{alignSelf:"center",fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:[$.length-z," more \u2014 type to narrow"]}):null,$.length===0?(0,i.jsxs)("span",{"data-testid":"ask-none",style:{alignSelf:"center",fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:["None of the ",g.length," match that."]}):null,k?(0,i.jsx)("button",{type:"button",disabled:I.length===0,style:{fontSize:"0.8125rem"},onClick:()=>{let e=I;F(G),h(e)},children:A.length>1?"Next":"Apply"}):null,O]}):(0,i.jsxs)("form",{style:{display:"flex",flexWrap:"wrap",gap:4},onSubmit:e=>{if(e.preventDefault(),d!==void 0&&p===ke(d,t)){h(void 0);return}if(K){h(p.split(/[,\n]/).map(r=>r.trim()).filter(Boolean));return}if(p.trim().length!==0){if(c){let r=me(p,c);r!==void 0&&h(r);return}h(t.type==="number"?t.duration?ue(p)??p:Number(p):p)}},children:[t.type==="text"&&t.long?(0,i.jsx)("textarea",{autoFocus:!0,name:o.name,"aria-label":m.label,placeholder:m.label,value:p,rows:4,onChange:e=>D(e.target.value),onKeyDown:e=>{e.key==="Escape"?u():e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},style:{flex:"1 1 100%",minWidth:0,font:"inherit",fontSize:"0.875rem",lineHeight:1.45,padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)",resize:"vertical",fieldSizing:"content",minHeight:"5.5em",maxHeight:"40vh"}}):t.type==="date"?(0,i.jsx)(we,{autoFocus:!0,name:o.name,label:m.label,value:p===""?void 0:p,time:t.time===!0,instant:t.instant===!0,partial:t.partial===!0,onChange:e=>D(e??""),onCancel:u,boxStyle:{fontSize:"0.875rem",padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}):(0,i.jsx)("input",{autoFocus:!0,type:t.type==="number"&&!t.duration&&!c?"number":t.type==="text"&&t.holds==="phone"?"tel":"text",...c?{inputMode:"decimal","data-graview-amount":c.format??"unit"}:{},name:o.name,"aria-label":m.label,placeholder:K?`${m.label}, separated by commas`:c?`${m.label}, ${S(c).hint} \u2014 ${S(c).prefix??""}${S(c).placeholder}${S(c).suffix?` ${S(c).suffix}`:""}`:m.label,value:p,...t.type==="number"&&t.min!==void 0?{min:t.min}:{},...t.type==="number"&&t.max!==void 0?{max:t.max}:{},...t.type==="number"&&t.step!==void 0?{step:t.step}:{},onChange:e=>D(e.target.value),onKeyDown:e=>{e.key==="Escape"&&u()},style:{flex:1,minWidth:0,font:"inherit",fontSize:"0.875rem",padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}),(0,i.jsx)("button",{type:"submit",disabled:!K&&p.trim().length===0,style:{fontSize:"0.8125rem"},children:A.length>1?"Next":"Apply"}),O]})]})}var G=[];function De(n,a,u){let w=n?.derived?.act==="edit"&&n.subject?u[n.subject.arg]:void 0,y=typeof w=="string"?a.graph.getNode(w):void 0;return y?Object.fromEntries((n.writes??[]).filter(s=>y[s]!==void 0&&y[s]!==null).map(s=>[s,y[s]])):{}}function ke(n,a){return typeof n=="number"?a?.type==="number"&&a.amount?fe(n,a.amount):String(n):Array.isArray(n)?n.every(u=>typeof u=="string")?n.join(", "):"":typeof n!="string"?"":n}var z=10;function Ee(n,a){return n.candidates&&n.candidates.length>0?n.candidates:a.type==="choice"?a.options:a.type==="several"&&a.of.type==="choice"?a.of.options:a.type==="boolean"?$e:[]}var $e=["yes","no"];function Ce(n,a,u){return a.type==="boolean"||a.type==="choice"||a.type==="several"&&a.of.type==="choice"?u:ze(n,u)}function ze(n,a){let u=ae(a);if(u){let s=de(n.schema,n.graph.getNode(u.from)?.kind??"",u.kind,"out");return s.charAt(0).toUpperCase()+s.slice(1)}let w=ie(a);if(w.length>0)return w.map(s=>n.schema.tryDefinition(s)?.plural??`${s}s`).join(" + ");let y=n.graph.getNode(a);return y?ee(n.schema.tryDefinition(y.kind),y):a}export{qe as a,ze as b};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk.WVUJXDXZ.js";import{k as x}from"./chunk.
|
|
1
|
+
import"./chunk.WVUJXDXZ.js";import{k as x}from"./chunk.B422DSYN.js";import"./chunk.ZE5RSKXF.js";import"./chunk.DKUEZPGR.js";import"./chunk.EP7YT7LT.js";import"./chunk.I7KN732Z.js";import"./chunk.TLPCYKLW.js";import"./chunk.FIY4RUK5.js";import"./chunk.IY3DV52G.js";import{gb as f,ib as N,la as S}from"./chunk.DHPXRDT5.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var k=(n,r,t)=>({untrusted:!0,authoredBy:t.say(r),text:n});function O(n,r){let t;for(let[a,e]of Object.entries(n)){if(typeof e!="string"||a==="id"||a==="kind")continue;let o=r.fieldBy(n.id,a);o&&(t??={...n},t[a]=k(e,o,r))}return t??n}function L(n,r,t){let a=e=>{if(Array.isArray(e))return e.map(a);if(e!==null&&typeof e=="object"&&"id"in e&&"label"in e){let o=e,i=t.recordBy(o.id);return i?{...o,label:k(o.label,i,t)}:o}if(typeof e=="string"){let o=t.recordBy(n);return o?k(e,o,t):e}return e};return Object.fromEntries(Object.entries(r).map(([e,o])=>[e,a(o)]))}function $(n,r){return n.map(t=>{let a=r.recordBy(t.id);return a?{...t,label:k(t.label,a,r)}:t})}function D(n,r){return{...n,nodes:n.nodes.map(t=>O(t,r))}}var E=n=>(JSON.stringify(n)??"null").length,R=n=>typeof n=="number"&&Number.isFinite(n)&&n>0?Math.floor(n):0;function w(n,r,t,a,e,o=""){let i=n-r-t;return i>0?`and ${i} more ${e}: call ${a} with ${o}offset ${r+t} for the next page.`:void 0}var j=({line:n,...r})=>r;function T(n){let r;for(let[t,a]of Object.entries(n))typeof a!="string"||a.length<=600||(r??={...n},r[t]=`${a.slice(0,600)}\u2026 (cut at ${600} of ${a.length} characters)`);return r??n}function B(n,r,t,a){let e=Math.min(t,Math.max(0,n.length-r)),o=n.slice(r,r+e),i=a(o);for(;e>1&&E(i)>8e3;)e=Math.max(1,Math.floor(e*.75)),o=n.slice(r,r+e),i=a(o);return{page:o,answer:i}}function C(n,r){let t=JSON.stringify(r)??"null";if(t.length<=8e3)return r;let a=`This answer was ${t.length} characters, more than the ${8e3} one read answers, so it is cut. Ask ${n} for less, or use search_graph and get_node to read one thing.`;for(let e=8e3-a.length-40;;){let o={cut:a,partial:t.slice(0,e)},i=E(o)-8e3;if(i<=0)return o;e=Math.max(0,e-i-8)}}function I(n,r){let{matched:t,later:a,...e}=r,o=n.hits.filter(i=>i.about==="node").length;return n.total>o?{...e,more:`and ${n.total-o} more records match: narrow the words, or add kind:<kind>.`}:e}function P(n,r,t){let a=N(t.archived),e={nodes:n.graph.allNodes({archived:a}),edges:n.graph.allEdges({archived:"all"})},o=R(t.offset),i=e.nodes.length,{page:h,answer:u}=B(e.nodes,o,25,d=>{let g=new Set(d.map(s=>s.id)),l=new Set(d.map(s=>s.id)),c=w(i,o,d.length,"get_graph","nodes"),p=s=>l.has(s)||(a==="all"?n.graph.has(s):n.graph.has(s)&&f(n.graph.getNode(s))===a);return{...D({nodes:d.map(T),edges:e.edges.filter(s=>g.has(s.from)&&p(s.to))},r),total:i,...c?{more:c}:{}}});return{data:u,reads:h.map(d=>d.id)}}function U(n,r,t,a){let e=n.graph.getNode(t),o=R(a.offset),i=n.graph.outEdges(t),h=n.graph.inEdges(t),u=i.slice(o,o+20),d=h.slice(o,o+20),g=(s,A)=>{let m=n.graph.getNode(A);return{kind:s,id:A,label:m?S(n.schema.tryDefinition(m.kind),m):A,...f(m)?{archived:!0}:{}}},l=x(n.schema,n.graph,e),c=n.violations().filter(s=>s.nodeIds.includes(t)),p=[w(i.length,o,u.length,"get_node","links out",`id "${t}" and `),w(h.length,o,d.length,"get_node","links in",`id "${t}" and `),c.length>20?`and ${c.length-20} more problems: get_violations lists them.`:void 0].filter(Boolean);return{data:{node:O(T(e),r),...f(e)?{archived:!0}:{},...Object.keys(l.values).length>0?{computed:L(t,l.values,r)}:{},...Object.keys(l.refused).length>0?{uncomputed:l.refused}:{},out:$(u.map(s=>g(s.kind,s.to)),r),in:$(d.map(s=>g(s.kind,s.from)),r),violations:c.slice(0,20).map(j),...p.length>0?{more:p.join(" ")}:{}},reads:[t,...u.map(s=>s.to),...d.map(s=>s.from)]}}function F(n,r){let t=R(r.offset),{page:a,answer:e}=B(n,t,20,o=>{let i=w(n.length,t,o.length,"get_violations","problems");return{violations:o.map(j),total:n.length,...i?{more:i}:{}}});return{data:e,reads:[...new Set(a.flatMap(o=>o.nodeIds))]}}export{P as graphRead,U as nodeRead,I as searchRead,F as violationsRead,C as withinReadChars};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as X}from"./chunk.
|
|
1
|
+
import{b as X}from"./chunk.I4H2GS4O.js";import"./chunk.NLZHNPDU.js";import"./chunk.QNC2OKLF.js";import{G as ce,W as Y,ea as N,ha as _}from"./chunk.FWXW4T4I.js";import"./chunk.SDO3U72B.js";import{Fb as R,ye as U}from"./chunk.DHPXRDT5.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};
|