graview 0.1.61 → 0.1.63
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/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +11 -7
- package/dist/index.js.map +1 -1
- package/dist/preview/{chunk.JEQO24GS.js → chunk.24HNOLUS.js} +1 -1
- package/dist/preview/chunk.25CQCCLN.js +1 -0
- package/dist/preview/{chunk.C634A6ZC.js → chunk.26H33GJC.js} +1 -1
- package/dist/preview/chunk.2F4AZZQR.js +1 -0
- package/dist/preview/chunk.2KIWGQXC.js +2 -0
- package/dist/preview/{chunk.IA5ZBMRD.js → chunk.2PJ6STKA.js} +1 -1
- package/dist/preview/{chunk.7LZ6JDJA.js → chunk.2RASWDMQ.js} +2 -2
- package/dist/preview/chunk.33XNYHI6.js +1 -0
- package/dist/preview/{chunk.SJALH7IX.js → chunk.34DRUCH2.js} +1 -1
- package/dist/preview/{chunk.SKQO467Y.js → chunk.36OE6RKG.js} +1 -1
- package/dist/preview/{chunk.3SMNWZ3M.js → chunk.37FLKAVZ.js} +1 -1
- package/dist/preview/chunk.3JCHJLH6.js +1 -0
- package/dist/preview/chunk.3L37FY3G.js +4 -0
- package/dist/preview/chunk.3OQ6S6H4.js +1 -0
- package/dist/preview/chunk.47QEWSSE.js +1 -0
- package/dist/preview/{chunk.W5TVQYAI.js → chunk.4DAKQXDG.js} +1 -1
- package/dist/preview/{chunk.BI6DS3PZ.js → chunk.4EXC26LI.js} +1 -1
- package/dist/preview/{chunk.ZKAZA6UJ.js → chunk.4MEQUUG4.js} +1 -1
- package/dist/preview/{chunk.LA2DMHZC.js → chunk.4TH3CGAZ.js} +1 -1
- package/dist/preview/{chunk.5POG3G2C.js → chunk.57YDGGJK.js} +1 -1
- package/dist/preview/chunk.5GC4VAHU.js +1 -0
- package/dist/preview/{chunk.XZWXDQ3N.js → chunk.5QXQ7PBI.js} +1 -1
- package/dist/preview/chunk.6CSHRMJC.js +1 -0
- package/dist/preview/chunk.6HKWAHPT.js +1 -0
- package/dist/preview/{chunk.ULHB3RYK.js → chunk.6XHPBJ5F.js} +1 -1
- package/dist/preview/chunk.6YK5E7ZQ.js +4 -0
- package/dist/preview/{chunk.UACSX64H.js → chunk.6Z2GHQQH.js} +3 -3
- package/dist/preview/chunk.72YXFJKC.js +2 -0
- package/dist/preview/{chunk.XFSGB6EU.js → chunk.735AFUP5.js} +1 -1
- package/dist/preview/chunk.75GENXGP.js +1 -0
- package/dist/preview/{chunk.SBLYBRDU.js → chunk.A2R53GWF.js} +1 -1
- package/dist/preview/{chunk.7R727IKU.js → chunk.AHPYNDVA.js} +2 -2
- package/dist/preview/chunk.ATDIDPKZ.js +1 -0
- package/dist/preview/{chunk.HQNE4I4M.js → chunk.AW26EETU.js} +1 -1
- package/dist/preview/chunk.AWUO3M5D.js +1 -0
- package/dist/preview/chunk.B46UZHGW.js +1 -0
- package/dist/preview/{chunk.WS7LAT4Z.js → chunk.B5PJCYBU.js} +1 -1
- package/dist/preview/chunk.BF3EZCG3.js +1 -0
- package/dist/preview/chunk.BIDL7GQD.js +0 -0
- package/dist/preview/chunk.BKQICGFW.js +1 -0
- package/dist/preview/{chunk.6HZY5NRX.js → chunk.BN7C5ZYX.js} +1 -1
- package/dist/preview/chunk.BQM3YAMR.js +35 -0
- package/dist/preview/chunk.C65EHQ7V.js +1 -0
- package/dist/preview/{chunk.3FUUYYR5.js → chunk.CAXILB7K.js} +1 -1
- package/dist/preview/{chunk.NUEPFPRA.js → chunk.CCQMDZHO.js} +1 -1
- package/dist/preview/{chunk.HOQMD6WQ.js → chunk.CGK2PY76.js} +14 -14
- package/dist/preview/chunk.CI4RZL4Z.js +1 -0
- package/dist/preview/chunk.CXDGE5ZS.js +1 -0
- package/dist/preview/chunk.CYTTZOYL.js +25 -0
- package/dist/preview/chunk.D5LOTCBU.js +3 -0
- package/dist/preview/chunk.DBFJVVWF.js +1 -0
- package/dist/preview/{chunk.A2ZQASQV.js → chunk.DDFRFSVN.js} +1 -1
- package/dist/preview/{chunk.UXOBUK3C.js → chunk.DIFIHNR3.js} +1 -1
- package/dist/preview/chunk.DVSTLVIH.js +15 -0
- package/dist/preview/chunk.DWK3GXRR.js +1 -0
- package/dist/preview/{chunk.2QFKNTAZ.js → chunk.DZSZUX34.js} +1 -1
- package/dist/preview/chunk.E3XJMO7Q.js +1 -0
- package/dist/preview/chunk.EJ2WE764.js +18 -0
- package/dist/preview/{chunk.SAYAFOF6.js → chunk.EJ4MSVX2.js} +1 -1
- package/dist/preview/chunk.ERPILTRY.js +1 -0
- package/dist/preview/chunk.FFXBDOKA.js +1 -0
- package/dist/preview/chunk.FGDGTES4.js +20 -0
- package/dist/preview/chunk.FNVGNISQ.js +3 -0
- package/dist/preview/chunk.FXCQJPN4.js +6 -0
- package/dist/preview/chunk.G2JAYG2Z.js +1 -0
- package/dist/preview/chunk.GHN62OMG.js +32 -0
- package/dist/preview/{chunk.F4VHCQNP.js → chunk.H5SN46VK.js} +1 -1
- package/dist/preview/{chunk.2XSIJH5J.js → chunk.H7AH3IW4.js} +1 -1
- package/dist/preview/{chunk.GI6XQF5X.js → chunk.HMMK7LCL.js} +1 -1
- package/dist/preview/{chunk.WICFQROI.js → chunk.HOFATBGD.js} +1 -1
- package/dist/preview/{chunk.PJ5AO7CK.js → chunk.HRNNRA2I.js} +1 -1
- package/dist/preview/{chunk.E7UDVC4V.js → chunk.HSMJHCR3.js} +1 -1
- package/dist/preview/{chunk.6SO64TUI.js → chunk.IEDCFSN5.js} +1 -1
- package/dist/preview/{chunk.VYFMUCBT.js → chunk.JIEDJEHK.js} +1 -1
- package/dist/preview/chunk.JNIDS66Z.js +1 -0
- package/dist/preview/{chunk.DHY7KOBV.js → chunk.JO3BBRSR.js} +1 -1
- package/dist/preview/chunk.JVDPRQ7J.js +1 -0
- package/dist/preview/chunk.K2HDEL7I.js +1 -0
- package/dist/preview/chunk.K7TK3KRB.js +7 -0
- package/dist/preview/{chunk.U2ISOUM2.js → chunk.KB5BCW23.js} +1 -1
- package/dist/preview/{chunk.EN2ABVIP.js → chunk.KL5H7KEV.js} +1 -1
- package/dist/preview/{chunk.ZC3FRCJQ.js → chunk.KPQLM4TM.js} +1 -1
- package/dist/preview/{chunk.R3N73BJO.js → chunk.KQPKYWDM.js} +1 -1
- package/dist/preview/{chunk.6DOOLVT4.js → chunk.KXFNRJ46.js} +1 -1
- package/dist/preview/chunk.KZUMXT5J.js +74 -0
- package/dist/preview/chunk.MAHNJO6U.js +1 -0
- package/dist/preview/{chunk.VN7I7XIO.js → chunk.MBB5A6BT.js} +1 -1
- package/dist/preview/chunk.MENLUNM5.js +1 -0
- package/dist/preview/{chunk.747OH3EE.js → chunk.MIE3ODQ2.js} +1 -1
- package/dist/preview/chunk.MT5DXJKN.js +1 -0
- package/dist/preview/chunk.MY5HJW2Z.js +1 -0
- package/dist/preview/{chunk.4LG34OC2.js → chunk.N3T2O6EW.js} +2 -2
- package/dist/preview/{chunk.E6RNMWFN.js → chunk.NEPQBMFT.js} +1 -1
- package/dist/preview/{chunk.ISRQQVS4.js → chunk.NIAM7OTV.js} +1 -1
- package/dist/preview/{chunk.5IEFTFKQ.js → chunk.NJSK3UO2.js} +1 -1
- package/dist/preview/chunk.NTC2H5ZX.js +1 -0
- package/dist/preview/chunk.NWWJNNEK.js +2 -0
- package/dist/preview/{chunk.6VLCMBRE.js → chunk.O3YIWIVQ.js} +1 -1
- package/dist/preview/chunk.O67JXUVG.js +1 -0
- package/dist/preview/{chunk.CRCJ3TAG.js → chunk.OIMGD7FR.js} +1 -1
- package/dist/preview/{chunk.ZJCM62GH.js → chunk.OM2NIQWA.js} +1 -1
- package/dist/preview/chunk.OMRQTLI5.js +1 -0
- package/dist/preview/{chunk.BDTT4ENI.js → chunk.OTSBF367.js} +2 -2
- package/dist/preview/{chunk.MU3XII7I.js → chunk.OXWOUE3W.js} +1 -1
- package/dist/preview/chunk.PDMX3GTL.js +1 -0
- package/dist/preview/{chunk.SIYBHZDD.js → chunk.PDS4HT46.js} +1 -1
- package/dist/preview/chunk.PWAP2GJS.js +1 -0
- package/dist/preview/chunk.Q2EGESEZ.js +1 -0
- package/dist/preview/{chunk.DHJI7LIW.js → chunk.Q4GJIJAU.js} +1 -1
- package/dist/preview/chunk.Q4MI53KK.js +5 -0
- package/dist/preview/chunk.Q5WEOX3Q.js +1 -0
- package/dist/preview/{chunk.2LNSENPV.js → chunk.QAMW5QDT.js} +1 -1
- package/dist/preview/{chunk.WD4VPMEE.js → chunk.QS32TO4N.js} +1 -1
- package/dist/preview/chunk.QSPLKCTX.js +1 -0
- package/dist/preview/chunk.R4HDKNT3.js +88 -0
- package/dist/preview/chunk.REUMBCSV.js +1 -0
- package/dist/preview/{chunk.CUTLO6DA.js → chunk.RUFYORIJ.js} +1 -1
- package/dist/preview/{chunk.PYVWGTQS.js → chunk.SGPXYDSG.js} +1 -1
- package/dist/preview/chunk.SJUXFPTI.js +1 -0
- package/dist/preview/{chunk.MBPOYZ3J.js → chunk.SME4HD5I.js} +1 -1
- package/dist/preview/{chunk.XZUHFXME.js → chunk.SMHP2CQH.js} +1 -1
- package/dist/preview/chunk.SSAETRHR.js +5 -0
- package/dist/preview/{chunk.PZXTSWDH.js → chunk.STDJ6XG5.js} +1 -1
- package/dist/preview/{chunk.66IKLMYX.js → chunk.T3JIZNE7.js} +2 -2
- package/dist/preview/chunk.T535ZLRM.js +1 -0
- package/dist/preview/chunk.T6PU3NKP.js +1 -0
- package/dist/preview/{chunk.U3JK2DNC.js → chunk.UAVK54Z6.js} +1 -1
- package/dist/preview/{chunk.EVEHSENK.js → chunk.V4HVFLFQ.js} +1 -1
- package/dist/preview/chunk.V6IL7CIZ.js +1 -0
- package/dist/preview/{chunk.ZVG3DR5G.js → chunk.VCTAFSZ5.js} +1 -1
- package/dist/preview/{chunk.GIW657OR.js → chunk.VZDHRY3U.js} +2 -1
- package/dist/preview/chunk.WBS7ND2C.js +1 -0
- package/dist/preview/chunk.WNS5LEO5.js +1 -0
- package/dist/preview/chunk.WUVXIUA7.js +1 -0
- package/dist/preview/{chunk.JHAFQNGC.js → chunk.WYPCLZL7.js} +1 -1
- package/dist/preview/{chunk.DLDP6OWD.js → chunk.XBYJCGPU.js} +1 -1
- package/dist/preview/{chunk.65KFZV3A.js → chunk.XCEZCOX4.js} +1 -1
- package/dist/preview/{chunk.KRFRREEW.js → chunk.XCWZFLIB.js} +1 -1
- package/dist/preview/chunk.XIW4SZHD.js +1 -0
- package/dist/preview/{chunk.MK72IRIY.js → chunk.XUO67YMT.js} +1 -1
- package/dist/preview/{chunk.FWUG7Y6C.js → chunk.XUXZW7DU.js} +1 -1
- package/dist/preview/chunk.XYGNS637.js +1 -0
- package/dist/preview/{chunk.FJIXSGYU.js → chunk.Y4ZM75WL.js} +1 -1
- package/dist/preview/{chunk.D5Q64GA4.js → chunk.YOUB3J3Y.js} +1 -1
- package/dist/preview/{chunk.3HFUO3DC.js → chunk.YXAKHXYB.js} +1 -1
- package/dist/preview/chunk.YZBJUAS6.js +1 -0
- package/dist/preview/chunk.Z2ZQJ3DD.js +1 -0
- package/dist/preview/chunk.ZELWW7UA.js +21 -0
- package/dist/preview/{chunk.YGIJDHAV.js → chunk.ZLTHWCKL.js} +2 -2
- package/dist/preview/chunk.ZP7JEVVU.js +1 -0
- package/dist/preview/chunk.ZRH5X3MR.js +1 -0
- package/dist/preview/{chunk.R5547CJ7.js → chunk.ZSGDVNVN.js} +1 -1
- package/dist/preview/chunk.ZVG4FXJK.js +1 -0
- package/dist/preview/chunk.ZY7US4Y7.js +6 -0
- package/dist/preview/{chunk.GQNSNJTJ.js → chunk.ZZAI57VI.js} +1 -1
- package/dist/preview/index.html +54 -51
- package/dist/preview/page.js +2 -2
- package/dist/preview/splash.js +58 -0
- package/package.json +6 -6
- package/dist/preview/chunk.2AWVQ5SW.js +0 -1
- package/dist/preview/chunk.2WZAFKJ2.js +0 -2
- package/dist/preview/chunk.3ICWPRRJ.js +0 -1
- package/dist/preview/chunk.3RW677X6.js +0 -1
- package/dist/preview/chunk.4G32374Q.js +0 -1
- package/dist/preview/chunk.4OEWFPH3.js +0 -1
- package/dist/preview/chunk.4STDIZVI.js +0 -2
- package/dist/preview/chunk.5S7IGASX.js +0 -28
- package/dist/preview/chunk.5T53SF2K.js +0 -1
- package/dist/preview/chunk.5X22RKB3.js +0 -1
- package/dist/preview/chunk.644FUGSX.js +0 -1
- package/dist/preview/chunk.7CETF4A6.js +0 -1
- package/dist/preview/chunk.AVFOTYZR.js +0 -74
- package/dist/preview/chunk.BFDJTWGX.js +0 -88
- package/dist/preview/chunk.BJI2C3IZ.js +0 -1
- package/dist/preview/chunk.D4TA5XDC.js +0 -4
- package/dist/preview/chunk.DKXVEVDG.js +0 -1
- package/dist/preview/chunk.DP5DUV6F.js +0 -6
- package/dist/preview/chunk.DXWTM4SH.js +0 -1
- package/dist/preview/chunk.F7IQ4B6A.js +0 -1
- package/dist/preview/chunk.F7PIW2EM.js +0 -5
- package/dist/preview/chunk.G4VMRYS4.js +0 -1
- package/dist/preview/chunk.GPWYWALF.js +0 -1
- package/dist/preview/chunk.HGVBGSRS.js +0 -6
- package/dist/preview/chunk.HZHNM2KI.js +0 -3
- package/dist/preview/chunk.ISXNAFRC.js +0 -20
- package/dist/preview/chunk.JU3BCCQM.js +0 -1
- package/dist/preview/chunk.K2AC536Q.js +0 -21
- package/dist/preview/chunk.K3UOXAZS.js +0 -1
- package/dist/preview/chunk.KNYLY7MH.js +0 -1
- package/dist/preview/chunk.LQAT7FA6.js +0 -3
- package/dist/preview/chunk.LTI5PKTS.js +0 -1
- package/dist/preview/chunk.MBP7VDYM.js +0 -1
- package/dist/preview/chunk.MBU7UH6J.js +0 -1
- package/dist/preview/chunk.MH6CCHEX.js +0 -1
- package/dist/preview/chunk.MNRTA2CB.js +0 -1
- package/dist/preview/chunk.MYVED5LU.js +0 -1
- package/dist/preview/chunk.N5WDQAIM.js +0 -5
- package/dist/preview/chunk.N7T7VB77.js +0 -25
- package/dist/preview/chunk.ODVRO2BJ.js +0 -1
- package/dist/preview/chunk.OVPFROL3.js +0 -1
- package/dist/preview/chunk.PGA5TUSN.js +0 -1
- package/dist/preview/chunk.PHC2MI4C.js +0 -1
- package/dist/preview/chunk.PXQVXBNG.js +0 -1
- package/dist/preview/chunk.Q5I5M3FR.js +0 -1
- package/dist/preview/chunk.QATUGE34.js +0 -1
- package/dist/preview/chunk.QL77K3D4.js +0 -1
- package/dist/preview/chunk.QUJS63OJ.js +0 -13
- package/dist/preview/chunk.REH6RXNH.js +0 -1
- package/dist/preview/chunk.RZ5PPQBV.js +0 -1
- package/dist/preview/chunk.SCGF4ZPP.js +0 -1
- package/dist/preview/chunk.SLAZFFCQ.js +0 -1
- package/dist/preview/chunk.SLPJWOKC.js +0 -1
- package/dist/preview/chunk.TKLYUVMR.js +0 -32
- package/dist/preview/chunk.TKUNRFDE.js +0 -1
- package/dist/preview/chunk.TMAZNDA6.js +0 -1
- package/dist/preview/chunk.UDCDK7XJ.js +0 -4
- package/dist/preview/chunk.UO544PZH.js +0 -1
- package/dist/preview/chunk.VKHAAH32.js +0 -1
- package/dist/preview/chunk.VOOOIECX.js +0 -1
- package/dist/preview/chunk.VS6NT5C4.js +0 -1
- package/dist/preview/chunk.VUAOCYG2.js +0 -1
- package/dist/preview/chunk.VX65S2FA.js +0 -1
- package/dist/preview/chunk.X2I3XH2E.js +0 -2
- package/dist/preview/chunk.XWWSW3ZV.js +0 -7
- package/dist/preview/chunk.Y7H5O2SL.js +0 -1
- package/dist/preview/chunk.YOT7ESDG.js +0 -18
- package/dist/preview/chunk.ZQHCNFJK.js +0 -1
- package/dist/preview/chunk.ZYNUMVEC.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ne,b as B,c as re}from"./chunk.PDMX3GTL.js";import{B as J,D as Q,H as X,J as Y,M as ee,g as G,i as W,o as q,r as z,s as j,w as Z,x as _,z as U}from"./chunk.KZUMXT5J.js";import{a as N}from"./chunk.CGK2PY76.js";import{G as ae,Ja as $,Qa as K,T as M,ba as T,da as I,wa as D}from"./chunk.CYTTZOYL.js";import{Zc as V}from"./chunk.Q4MI53KK.js";import{b as P}from"./chunk.AJZBJBMO.js";var o=P(ae(),1);var y=P(M(),1),fe=e=>typeof e=="object"?e:{};function he({rootRef:e,firstLook:r,app:n}){let t=(0,o.useCallback)(()=>e.current,[e]);return r?(0,y.jsx)(ee,{firstLook:r,root:t,app:n}):null}function ge(e,r,n){let{app:t}=e,a=(0,o.useMemo)(()=>{let i=X(r(t.schema,t.viewSpecs),t),d=n?ie(i,n):i,s=e.views?e.views(t.schema,d):i,c=s===d?i:D(i,s);return Y(c,t.schema,J(e.brand??t.brand,t.schema)),n?n.register(c):c},[e.views,t.schema,t.viewSpecs,t.lenses,t.pages,t.home,n]);return $(a,e.keptViews)}function ie(e,r){let n={...e,register(t,a,i,d){return d?.name!==r.name&&e.register(t,a,i,d),n},...e.home?{home:(t,a)=>(r.home||e.home(t,a),n)}:{}};return n}var k=e=>e?e.getBoundingClientRect().height:0;function be(e,r,n){let t=(0,o.useRef)(n);t.current=n;let a=n!==void 0;(0,o.useLayoutEffect)(()=>{let i=e.current;if(!i||!a)return;let d=()=>{let u=[...i.children],g=u.find(b=>b.hasAttribute("data-graview-app-bar")),p=u.find(b=>b.hasAttribute("data-embed-content")),h=p?.querySelector("[data-embed-measure]")??null,l=u.find(b=>b.hasAttribute("data-graview-place-line"));return{strip:g,line:l,content:p,measure:h}},s=-1,c=()=>{let{strip:u,line:g,content:p,measure:h}=d(),l=Math.ceil(k(u)+k(g)+k(h||p));l!==s&&(s=l,t.current?.(l))};if(c(),typeof ResizeObserver>"u")return;let m=new ResizeObserver(c),S=()=>{m.disconnect();let{strip:u,line:g,content:p,measure:h}=d();for(let l of[i,u,g,p,h])l&&m.observe(l)};S();let v=new MutationObserver(()=>{S(),c()});return v.observe(i,{childList:!0}),()=>{m.disconnect(),v.disconnect()}},[e,r,a])}var we=480,se=0;function Se(e){let{app:r,seed:n,scheme:t="auto",brand:a=r.brand,fonts:i=!0,height:d="100%",label:s}=e,c=(0,o.useRef)(null);K(c);let m=d==="viewport"?"100dvh":d,S=W(typeof m=="string"&&/vh\b/.test(m)),v=(0,o.useMemo)(()=>`graview-embed-${++se}`,[]),u=(0,o.useMemo)(()=>e.store??e.remote?.store??B(r,n),[e.store,e.remote,r,n]),g=e.presence??e.remote?.presence,p=e.hostContext?.theme,h=re(t==="auto"&&p===void 0,a?.scheme),l=t==="auto"?p??h:t,b=(0,o.useMemo)(()=>N(l,a,{scope:`.${v}`}),[l,a,v]);G(e.favicon?V(a):void 0),(0,o.useEffect)(()=>{if(!i||typeof document>"u")return;let R=ne(a);if(!R||document.querySelector(`link[href="${R}"]`))return;let f=document.createElement("link");f.rel="stylesheet",f.href=R,document.head.appendChild(f)},[a,i]);let A=(0,o.useRef)(void 0);(0,o.useLayoutEffect)(()=>{let R=c.current,f=A.current;if(A.current=s,!R||!s)return;let oe=w=>{let E=w.getAttribute("aria-label")??"",x=f&&f!==s?E.startsWith(`${f} \xB7 `)?E.slice(f.length+3):E===f?"":E:E;x===s&&(w.getAttribute("role")==="region"||w.tagName==="SECTION"&&!w.hasAttribute("role"))&&w.setAttribute("role","group");let O=x.startsWith(`${s} \xB7 `)||x===s?x:x?`${s} \xB7 ${x}`:s;O!==E&&w.setAttribute("aria-label",O)},C=()=>R.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(w=>{w.hasAttribute("data-graview-named-by-lens")||oe(w)});C();let L=new MutationObserver(C);return L.observe(R,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>L.disconnect()},[s]);let F=S?`${m}`.replace(/([\d.]+)[sdl]?vh\b/g,(R,f)=>`${+f*S/100}px`):m;return{rootRef:c,scope:v,css:b,scheme:l,store:u,presence:g,brand:a,auto:d==="auto",height:F}}function ve({rootRef:e,board:r,onReport:n,where:t}){let a=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]),i=(0,o.useRef)(t);i.current=t;let d=(0,o.useMemo)(()=>n?{tell:n,where:()=>i.current()}:void 0,[n]);return(0,y.jsx)(q,{board:r,anchor:a,report:d})}function Re(e){let r=e.split(/[?#]/)[0].split("/").filter(Boolean).map(n=>{try{return decodeURIComponent(n)}catch{return n}});return r.length===0?{place:"home"}:r[0]==="places"?{place:r[1]??"places"}:{place:r[0],...r[1]!==void 0?{record:r[1]}:{}}}function Ee(e,r,n){return{brand:n,locale:e.locale,timeZone:e.timeZone,principal:e.principal,seats:e.seats,presence:r,typing:e.remote?.typing,people:e.people,memory:e.memory,presenceTtlMs:e.presenceTtlMs,onKeepLens:e.onKeepLens,onProposeChange:e.onProposeChange,ai:e.ai,files:e.files,resolveApp:e.resolveApp,history:e.history,linkedRecords:e.linkedRecords,subscriptions:e.subscriptions,dismissals:e.dismissals,whileAway:e.whileAway,workflowRuns:e.workflowRuns,keptViews:e.keptViews,onExport:e.onExport,signIn:e.signIn,menuSections:e.menuSections,app:e.app}}function xe({name:e,heading:r,faces:n,at:t,without:a,home:i,reach:d,standing:s,hostActions:c,barActions:m,keeping:S,onFind:v,switch:u,named:g=!0}){let{brand:p,store:h,principal:l,views:b}=T();I();let A=a?.has("places")?[]:z({store:h,principal:l,views:b}),F=U();return(0,y.jsx)(Z,{brand:p,name:e,named:g,description:p?.subtitle,heading:r,faces:n,home:i,places:A,current:t===null?null:j(A,t),reach:d,onFind:v,...u?{switch:u}:{},...n||t===null?{scenePlaces:F}:{},...m?{actions:m}:{},tools:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(Q,{clean:s}),(0,y.jsx)(_,{...c?{hostActions:c}:{},...S?{keeping:S}:{}})]})})}var Ae=e=>e===!1?2:Math.min(e+1,6);function ke(e){let[r,n]=(0,o.useState)(e),t=(0,o.useRef)(void 0),a=(0,o.useRef)(void 0),i=(0,o.useMemo)(()=>({go:t,at:n,pending:a}),[]),d=(0,o.useCallback)(s=>{if(t.current){t.current(s);return}a.current=s,n(s)},[]);return{at:r,setAt:n,steering:i,steer:d}}function de(e){let r=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof r=="string"&&r.length>0?r:typeof e=="object"?"Error":typeof e}}var H=()=>typeof performance<"u"?performance.now():Date.now();function Fe(e,r){let n=(0,o.useRef)({onError:e,face:r});return n.current={onError:e,face:r},(0,o.useCallback)((t,a)=>n.current.onError?.(de(t),{module:a.module,face:n.current.face}),[])}function Pe(e,r){let n=(0,o.useRef)(null);n.current===null&&(n.current=H());let t=(0,o.useRef)({onReady:e,face:r});t.current={onReady:e,face:r};let a=(0,o.useRef)(!1);return(0,o.useCallback)(i=>{a.current||(a.current=!0,t.current.onReady?.({ms:Math.max(0,H()-(n.current??H())),face:i}))},[])}var te=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(r,n){console.error(`[graview] ${this.props.module} threw while rendering`,r,n.componentStack),this.props.report(r,{module:this.props.module})}render(){return this.state.failed?(0,y.jsxs)("div",{role:"alert","data-graview-face-error":this.props.module,...this.props.content?{"data-embed-content":""}:{},style:this.props.content?{flex:"1 1 auto",display:"grid",alignContent:"center",justifyItems:"center",gap:8,padding:24,background:"var(--graview-ground)",color:"var(--graview-ink)",fontSize:"0.9375rem"}:{display:"inline-flex",alignItems:"center",gap:6,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,y.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,y.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{fe as a,he as b,ge as c,be as d,we as e,Se as f,ve as g,Re as h,Ee as i,xe as j,Ae as k,ke as l,Fe as m,Pe as n,te as o};
|
|
@@ -0,0 +1,21 @@
|
|
|
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 gt,b as kt,c as xt,d as St,e as Tt,f as Mt,g as Et}from"./chunk.HMMK7LCL.js";import{a as ke,e as mt}from"./chunk.BBLIT7S7.js";import{a as bt,b as Te,c as Rt}from"./chunk.NJSK3UO2.js";import{a as ut,f as ct,g as pt,i as ft}from"./chunk.WBS7ND2C.js";import"./chunk.NTC2H5ZX.js";import{j as yt}from"./chunk.3L37FY3G.js";import{e as vt}from"./chunk.XUO67YMT.js";import"./chunk.B3WVCSW5.js";import{c as ht,f as wt,i as xe,j as Se}from"./chunk.Q4GJIJAU.js";import{b as ae,e as de}from"./chunk.MT5DXJKN.js";import"./chunk.JVDPRQ7J.js";import{a as U}from"./chunk.SDO3U72B.js";import"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var Kt=["good","warn","bad","neutral","accent"],Gt=["value","max","aria-label","placeholder","disabled"],At=["click","change"],Me=["_blank","_self"],Wt=["section","div","span","strong","p","hr","a","button","input","progress"],le={type:{oneOf:Kt}},Ee={"gv-card":{host:"section",properties:{tone:le},events:{},children:"any"},"gv-group":{host:"div",properties:{direction:{type:{oneOf:["row","column"]}}},events:{},children:"any"},"gv-title":{host:"strong",properties:{},events:{},children:"text"},"gv-text":{host:"p",properties:{tone:le},events:{},children:"text"},"gv-badge":{host:"span",properties:{tone:le},events:{},children:"text"},"gv-field":{host:"div",properties:{label:{type:"string"}},events:{},children:"text"},"gv-progress":{host:"progress",properties:{value:{type:"number",as:"value"},max:{type:"number",as:"max"},label:{type:"string",as:"aria-label"}},events:{},children:"none"},"gv-divider":{host:"hr",properties:{},events:{},children:"none"},"gv-link":{host:"a",properties:{href:{type:"url"}},events:{},children:"text"},"gv-button":{host:"button",properties:{tone:le,disabled:{type:"boolean",as:"disabled"}},events:{press:{from:"click"}},children:"text"},"gv-input":{host:"input",properties:{label:{type:"string",as:"aria-label"},value:{type:"string",as:"value"},placeholder:{type:"string",as:"placeholder"}},events:{change:{from:"change",detail:"value"}},children:"none"}},Re=1e4;var rr=0,nr=1,or=2,sr=3,Ot=1,ir=2,ar=3,dr=1,lr=3,ur=8,Ke="~",Ge=(r,e)=>Object.prototype.hasOwnProperty.call(r,e),Z=r=>typeof r=="object"&&r!==null&&!Array.isArray(r);function _t(r,e){return e.type==="url"?"href":e.as??`data-gv-${r.toLowerCase()}`}var cr=2e3;function Lt(r,e){if(e==null)return{ok:!0,value:null};let a=r.type;if(a==="boolean")return typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,reason:"value"};if(a==="number")return typeof e=="number"&&Number.isFinite(e)?{ok:!0,value:String(e)}:{ok:!1,reason:"value"};if(typeof e!="string"||e.length>cr)return{ok:!1,reason:a==="url"?"url":"value"};if(typeof a=="object")return a.oneOf.includes(e)?{ok:!0,value:e}:{ok:!1,reason:"value"};if(a==="url"){let p;try{p=new URL(e)}catch{return{ok:!1,reason:"url"}}return p.protocol!=="https:"||p.hostname===""||!/^https:\/\//i.test(e)?{ok:!1,reason:"url"}:{ok:!0,value:p.href}}return{ok:!0,value:e}}function pr(r){let e=r.host==="a";return Wt.includes(r.host)&&(r.target===void 0||e&&Me.includes(r.target))&&Object.values(r.properties).every(a=>a.type!=="url"||e)&&Object.values(r.properties).every(a=>a.as===void 0||a.type!=="url"&&Gt.includes(a.as))&&Object.values(r.events).every(a=>At.includes(a.from))}function Ae(r,e){let a=e.kit??Ee,p=e.maxNodes??2e3,o=r.ownerDocument,f=[],y=new Map,A={dom:r,name:Ke,component:{host:"div",properties:{},events:{},children:"any"},children:[],listeners:new Map,id:Ke};y.set(Ke,A);let W=e.links?new Set(e.links.origins.flatMap(n=>{try{let c=new URL(n);return c.protocol==="https:"&&c.hostname!==""?[c.origin]:[]}catch{return[]}})):void 0,P=0,M=0,D=!1,g=n=>{f.push(n),f.length>200&&f.shift()},x=()=>({dom:o.createComment(""),children:[],refused:!0,listeners:new Map}),L=(n,c,m)=>{let h=n.component;if(!Ge(h.properties,c))return g({reason:"property",element:n.name,name:c});let d=h.properties[c],i=Lt(d,m),w=i.ok&&d.type==="url"&&W&&typeof i.value=="string"&&!W.has(new URL(i.value).origin)?{ok:!1,reason:"url"}:i,E=n.dom,T=_t(c,d);if(!w.ok)return E.removeAttribute(T),g({reason:w.reason,element:n.name,name:c});let R=w.value;R===null||R===!1?E.removeAttribute(T):E.setAttribute(T,R===!0?"":R),T==="value"&&"value"in E&&(E.value=typeof R=="string"?R:""),T==="disabled"&&"disabled"in E&&(E.disabled=R!==null&&R!==!1)},b=(n,c,m)=>{let h=n.component;if(!Ge(h.events,c))return g({reason:"event",element:n.name,name:c});let d=n.listeners.get(c);if(d&&(d(),n.listeners.delete(c),M-=1),m==null)return;if(!Z(m)||typeof m.listener!="number")return g({reason:"value",element:n.name,name:c});let i=m.listener,w=h.events[c],E=n.dom,T=()=>e.onEvent(i,w.detail==="value"?String(E.value??""):void 0);E.addEventListener(w.from,T),n.listeners.set(c,()=>E.removeEventListener(w.from,T)),M+=1},S=n=>{if(!n.refused){P-=1,n.id!==void 0&&y.delete(n.id);for(let c of n.listeners.values())c();M-=n.listeners.size,n.listeners.clear();for(let c of n.children)S(c)}},k=(n,c)=>{if(!Z(n)||typeof n.id!="string"||y.has(n.id))return g({reason:"record"}),x();if(P>=p)return g({reason:"budget"}),D||(D=!0,e.onOverBudget?.()),x();let m=n.id,h=c.component.children;if(n.type===ur)return x();if(n.type===lr){if(h==="none")return g({reason:"child",element:c.name}),x();let T={dom:o.createTextNode(String(n.data??"").slice(0,Re)),children:[],text:!0,listeners:new Map,id:m};return y.set(m,T),P+=1,T}if(n.type!==dr)return g({reason:"record"}),x();let d=String(n.element);if(!Ge(a,d)||!pr(a[d]))return g({reason:"element",element:d}),x();if(h!=="any")return g({reason:"child",element:d}),x();let i=a[d],w=o.createElement(i.host);w.setAttribute("data-gv",d.replace(/^gv-/,"")),w.className=`graview-guest-${d.replace(/^gv-/,"")}`,i.host==="a"&&(w.setAttribute("rel","noopener noreferrer"),w.setAttribute("target",i.target??"_blank"),w.setAttribute("referrerpolicy","no-referrer")),i.host==="button"&&w.setAttribute("type","button");let E={dom:w,name:d,component:i,children:[],listeners:new Map,id:m};if(y.set(m,E),P+=1,Z(n.properties))for(let[T,R]of Object.entries(n.properties))L(E,T,R);if(Z(n.attributes))for(let T of Object.keys(n.attributes))g({reason:"attribute",element:d,name:T});if(Z(n.eventListeners))for(let[T,R]of Object.entries(n.eventListeners))b(E,T,R);if(Array.isArray(n.children))for(let T of n.children){let R=k(T,E);E.children.push(R),w.appendChild(R.dom)}return E},G=n=>{if(!Array.isArray(n))return g({reason:"record"});let[c,m]=n,h=typeof m=="string"?y.get(m):void 0;if(!h)return g({reason:"record"});switch(c){case rr:{if(h.text)return g({reason:"record"});let d=Number(n[3]),i=Number.isInteger(d)&&d>=0&&d<=h.children.length?d:h.children.length,w=k(n[2],h);h.dom.insertBefore(w.dom,h.children[i]?.dom??null),h.children.splice(i,0,w);return}case nr:{let d=Number(n[2]),i=h.children[d];if(!i)return g({reason:"record"});h.children.splice(d,1),i.dom.parentNode?.removeChild(i.dom),S(i);return}case or:if(!h.text)return g({reason:"record"});h.dom.data=String(n[2]??"").slice(0,Re);return;case sr:{if(h===A||h.text)return g({reason:"record"});let d=String(n[2]),i=n[4]??Ot;return i===Ot?L(h,d,n[3]):i===ar?b(h,d,n[3]):g(i===ir?{reason:"attribute",element:h.name,name:d}:{reason:"record"})}default:return g({reason:"record"})}};return{apply(n,c){if(!Array.isArray(n))return g({reason:"record"}),!0;for(let m=0;m<n.length;m+=1){if(c&&m%32===0&&c())return!1;G(n[m])}return!0},get refused(){return f},get size(){return P},get listening(){return M},dispose(){for(let n of A.children)S(n);A.children.length=0,r.replaceChildren()}}}var We=`
|
|
2
|
+
.graview-guest { display: flex; flex-direction: column; gap: 8px; min-width: 0; color: var(--graview-ink, inherit); font: inherit; }
|
|
3
|
+
.graview-guest-card { display: flex; flex-direction: column; gap: 6px; padding: 12px; border: 1px solid var(--graview-edge, #d0d0d0); border-radius: 10px; background: var(--graview-panel, transparent); }
|
|
4
|
+
.graview-guest-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
|
|
5
|
+
.graview-guest-group[data-gv-direction="row"] { flex-direction: row; flex-wrap: wrap; align-items: center; }
|
|
6
|
+
.graview-guest-title { font-weight: 600; font-size: 1rem; overflow-wrap: anywhere; }
|
|
7
|
+
.graview-guest-text { margin: 0; font-size: 0.875rem; line-height: 1.45; overflow-wrap: anywhere; }
|
|
8
|
+
.graview-guest-badge { align-self: flex-start; padding: 1px 8px; border: 1px solid currentColor; border-radius: 999px; font-size: 0.8125rem; font-weight: 600; }
|
|
9
|
+
.graview-guest-field { font-size: 0.875rem; overflow-wrap: anywhere; }
|
|
10
|
+
.graview-guest-field[data-gv-label]::before { content: attr(data-gv-label) " "; color: var(--graview-ink-muted, inherit); }
|
|
11
|
+
.graview-guest-progress { width: 100%; }
|
|
12
|
+
.graview-guest-divider { width: 100%; margin: 2px 0; border: 0; border-top: 1px solid var(--graview-edge, #d0d0d0); }
|
|
13
|
+
.graview-guest-link { color: var(--graview-accent, inherit); text-decoration: underline; }
|
|
14
|
+
.graview-guest-button { align-self: flex-start; font: inherit; padding: 4px 12px; border-radius: 8px; border: 1px solid var(--graview-edge, #d0d0d0); background: var(--graview-panel, transparent); color: inherit; cursor: pointer; }
|
|
15
|
+
.graview-guest-input { font: inherit; padding: 4px 8px; border-radius: 6px; border: 1px solid var(--graview-edge, #d0d0d0); }
|
|
16
|
+
.graview-guest [data-gv-tone="good"] { color: var(--graview-good, inherit); }
|
|
17
|
+
.graview-guest [data-gv-tone="bad"] { color: var(--graview-bad, inherit); }
|
|
18
|
+
.graview-guest [data-gv-tone="warn"] { color: var(--graview-warn, inherit); }
|
|
19
|
+
.graview-guest [data-gv-tone="accent"] { color: var(--graview-accent, inherit); }
|
|
20
|
+
.graview-guest [data-gv-tone="neutral"] { color: var(--graview-ink-muted, inherit); }
|
|
21
|
+
`;var It=new WeakSet;function fr(r,e){if(r.startsWith("blob:"))return"blob:";try{return new URL(r,e.location.href).origin}catch{return r}}function Pt(r,e,a){let p=fr(e,r),o=`this page's Content-Security-Policy${a?` (${a})`:""} does not allow a worker from ${p}: it needs worker-src ${p}`;return It.has(r)||(It.add(r),r.console?.warn?.(`Graview: worker views cannot start on this page, because ${o}. A host that will not allow ${p} serves each view's whole script from its own origin and passes worker: { url } (the @graview/guest README, "What the host page allows").`)),o}function mr(r,e){return r===""?!0:e.startsWith("blob:")?r.startsWith("blob"):e.startsWith(r)||r.startsWith(e)}function ue(r,e){let a="script"in e.source?r.URL.createObjectURL(new r.Blob([e.source.script],{type:"text/javascript"})):void 0,p="script"in e.source?a:e.source.url,o,f,y=!1,A=!1,W=0,P=0,M="",D=0,g=0,x=r.performance,L=x.now(),b,S=d=>{let i=d,w=String(i.effectiveDirective||i.violatedDirective||"").split(" ")[0];/^(worker-src|script-src|script-src-elem|child-src|default-src)$/.test(w)&&mr(String(i.blockedURI??""),p)&&(b=w)},k=r.document;k?.addEventListener("securitypolicyviolation",S);let G=()=>k?.removeEventListener("securitypolicyviolation",S),n=()=>{A||(A=!0,f?.close(),o?.terminate(),o=void 0,r.clearTimeout(W),r.clearInterval(P),G(),a&&r.URL.revokeObjectURL(a))},c=(d,i)=>{A||(n(),e.onStop(d,i))},m=()=>{r.clearTimeout(W),G(),M=gt();let d=new r.MessageChannel;f=d.port1;let i=Math.max(1,e.silentMs),w=Math.max(10,Math.min(1e3,Math.floor(i/4)));L=x.now();let E=L;P=r.setInterval(()=>{let R=x.now();if(R-E>w*2&&(L+=R-E-w),E=R,R-L>=i)return c("silent");D+=1,d.port1.postMessage({type:"heartbeat",beat:D})},w);let T={graview:"host-hello",protocol:1,nonce:M,view:e.name};o.postMessage(T,[d.port2]),e.onReady(M,d.port1,x.now()-h)},h=x.now();try{o=new r.Worker(p,{name:e.name})}catch(d){o=void 0;let i=d,w=i?.name==="SecurityError"?Pt(r,p,b):`the worker could not be made: ${String(i?.message??d)}`;queueMicrotask(()=>c("start",w))}return o&&(W=r.setTimeout(()=>c("start",`it never said it was ready in ${e.readyMs.toLocaleString("en-US")} ms`),e.readyMs),o.onerror=d=>{let i=typeof d.message=="string"&&d.message!==""?d.message:void 0;if(y)return void e.onError?.(i??"an error");r.clearTimeout(W),r.setTimeout(()=>!y&&c("start",b?Pt(r,p,b):i?`it failed before it said ready: ${i}`:"it failed before it said ready, and the engine gave no reason (a page policy that refuses it, or a script that does not load)"),0)},o.onmessage=d=>{if(!e.limiter.message()||y||!mt(d.data)||d.data.protocol!==1){e.onDropped();return}y=!0,m()}),{get worker(){return o},answer(d){let i=d;return typeof i!="object"||i===null||i.type!=="heartbeat"||i.nonce!==M?!1:(typeof i.beat=="number"&&i.beat>g&&i.beat<=D&&(g=i.beat,L=x.now()),!0)},stop:n}}function ce(r,e){let a=e(),p=0;return{draw(o){let f=e();f-a>=1e3&&(a=f,p=0);let y=r(),A=o(()=>p+(e()-f)>=y);return p+=e()-f,A&&p<y}}}var gr=Symbol.for("graview.view.clicked");function Nt(r,e){r[gr]=Object.freeze([...e])}function Vt(r){return!Number.isFinite(r)||r<=60?1:Math.min(4,Math.round(r/60*10)/10)}function Dt(r,e){return{...r,pushMs:Math.round(r.pushMs*e),drawMs:Math.round(r.drawMs*e)}}var Ct=new WeakMap;function Ht(r,e){let a=Ct.get(r);return a!==void 0?a:(Ct.set(r,e),e)}var yr=U(()=>(__graviewPreload(import.meta.url,["./chunk.3L37FY3G.js","./chunk.AJZBJBMO.js"]),import("./chunk.DVSTLVIH.js"))),hr=U(()=>(__graviewPreload(import.meta.url,["./chunk.XUO67YMT.js","./chunk.B3WVCSW5.js","./chunk.Q4GJIJAU.js","./chunk.MT5DXJKN.js","./chunk.Q4MI53KK.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.CAXILB7K.js"))),wr=U(()=>(__graviewPreload(import.meta.url,["./chunk.AJZBJBMO.js"]),import("./chunk.K2HDEL7I.js"))),vr=U(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.XYGNS637.js","./chunk.DZSZUX34.js","./chunk.4EXC26LI.js","./chunk.PWAP2GJS.js","./chunk.AHPYNDVA.js","./chunk.FNVGNISQ.js","./chunk.D5LOTCBU.js","./chunk.Q4MI53KK.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.ZRH5X3MR.js"))),br=U(()=>(__graviewPreload(import.meta.url,["./chunk.Q4GJIJAU.js","./chunk.MT5DXJKN.js","./chunk.Q4MI53KK.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.SGPXYDSG.js"))),kr=U(()=>(__graviewPreload(import.meta.url,["./chunk.BBLIT7S7.js","./chunk.AJZBJBMO.js"]),import("./chunk.RRCPEHM4.js"))),xr=U(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.XYGNS637.js","./chunk.DZSZUX34.js","./chunk.4EXC26LI.js","./chunk.PWAP2GJS.js","./chunk.AHPYNDVA.js","./chunk.FNVGNISQ.js","./chunk.D5LOTCBU.js","./chunk.Q4MI53KK.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.ATDIDPKZ.js")));function Sr(r,e,a){switch(r){case"manifest":return a??"Its manifest names something this app does not have.";case"source":return a??`Its code is longer than the ${e.maxSourceBytes.toLocaleString("en-US")} bytes a view may be.`;case"start":return`It could not start${a?`: ${a}.`:"."}`;case"error":return`It failed before it drew anything${a?`: ${a}`:"."}`;case"silent":return`It stopped answering for ${e.silentMs.toLocaleString("en-US")} ms.`;case"nodes":return`It drew more than the ${e.maxNodes.toLocaleString("en-US")} things a view may draw.`;case"flood":return`It sent more than ${e.messages} messages in ${e.messageWindowMs.toLocaleString("en-US")} ms.`;case"slow":return`It took longer than ${e.pushMs.toLocaleString("en-US")} ms to draw what it was shown.`}}function Tr(r,e){let a=r.ownerDocument,p=a.defaultView,{manifest:o}=e,f=a.createElement("div");f.className="graview-worker-view",f.setAttribute("role","region"),f.setAttribute("aria-label",o.title??o.name),f.setAttribute("data-worker-view",o.name),f.style.cssText="display:block;position:relative;contain:layout paint style;isolation:isolate;overflow:clip;min-width:0",r.appendChild(f);let y=f.attachShadow({mode:"open"}),A=e.author?a.createElement("p"):void 0;A&&(A.className="graview-worker-view-author",A.setAttribute("data-worker-view-author",o.name),A.style.cssText="margin:4px 0 0;font-size:0.75rem;color:var(--graview-ink-muted, inherit)",A.textContent=e.author,r.appendChild(A));let W={applied:0,refused:0,dropped:0},P=ae(e.limits),M={maxSourceBytes:e.limits?.maxSourceBytes??256e3,maxNodes:e.limits?.maxNodes??5e3,messages:e.limits?.messages??120,messageWindowMs:e.limits?.messageWindowMs??1e3,pushMs:e.limits?.pushMs??1e3,silentMs:e.limits?.silentMs??5e3,drawMs:e.limits?.drawMs??100},D={pushMs:M.pushMs,drawMs:M.drawMs},g,x,L,b,S,k,G=!1,n={applied:0,refused:0,dropped:0},c=[],m=()=>{if(!b)return;let t=b.stats;W.applied+=t.applied-n.applied,W.refused+=t.refused-n.refused,W.dropped+=t.dropped-n.dropped,n={...t}},h=()=>{},d,i,w=()=>{let t=y.querySelector("[data-graview-view-root]"),s=p.ResizeObserver;i||!t||typeof s!="function"||(i=new s(v=>{let K=v[v.length-1]?.borderBoxSize?.[0],_=Math.ceil(K?K.blockSize:t.offsetHeight);_!==d&&(d=_,f.setAttribute("data-graview-content-height",String(_)),e.onContentHeight?.(_))}),i.observe(t))},E=()=>{i&&(i.disconnect(),i=void 0,d=void 0,f.removeAttribute("data-graview-content-height"),e.onContentHeight?.(void 0))},T=0,R=()=>{},Oe=()=>{R(),R=()=>{},m(),b?.dispose(),b=void 0,S?.stop(),h(),p.clearInterval(T)},C=(t,s)=>{if(G)return;G=!0,Oe(),E(),k?.dispose();let v=Sr(t,M,s);f.removeAttribute("data-worker-view-drawn"),f.setAttribute("data-worker-view-failed",t),e.fallback!==!1&&(e.fallback??Bt)(f,t,v),e.onFailure?.(t,v)},Bt=(t,s,v)=>{let K=x??(()=>{try{return Se(e.store,e.principal,{manifest:o,...e.input?{input:e.input()}:{},...L?{computed:L}:{}})}catch{return}})(),_=a.createElement("div");_.setAttribute("data-graview-fallback",s),_.style.cssText="padding:12px;display:grid;gap:6px;color:var(--graview-ink, inherit);font-family:var(--graview-font-body, inherit)";let u=a.createElement("strong");u.textContent=o.title??o.name;let N=a.createElement("ul");N.style.cssText="margin:0;padding-left:1.2em";for(let H of[...K?.node?[K.node]:[],...K?.nodes??[]]){let se=a.createElement("li");se.textContent=H.label??H.id,N.appendChild(se)}let I=a.createElement("p");I.style.cssText="margin:0;font-size:0.8125rem;color:var(--graview-ink-muted, inherit)",I.textContent=`This view was stopped. ${v}`,_.append(u,N,I),y.replaceChildren(_)},_e=wt(o,e.store);if(_e.length>0)return queueMicrotask(()=>C("manifest",_e.join(" "))),he();let Le=t=>{if(("source"in t?new TextEncoder().encode(t.source).length:"script"in t?new TextEncoder().encode(t.script).length:0)>M.maxSourceBytes)return["source"];let v="source"in t?bt(t.source):[];return v.length>0?["source",v.join(" ")]:void 0},z=e.worker,Ie=typeof z=="function"?void 0:Le(z);if(Ie)return queueMicrotask(()=>C(...Ie)),he();let Pe=Et(p,()=>Ve(),"blob"),pe=()=>Mt(()=>e.theme?.()??St(f),e.brand,Pe),Ne=()=>{let t=e.brand?.()?.views;k?.theme(t?.css),k?.motion(t?.motion??"none")},Ce="",fe=()=>{Ce=JSON.stringify(pe()),Ne(),b?.push()},Ve=()=>{b&&JSON.stringify(pe())!==Ce&&fe()},Ut=Tt(a,Ve),F,Ft=xe(e.store,o)?xr().then(({computedOn:t})=>{L=t(e.store.schema)}):Promise.resolve(),$,$t=o.pictures?wr().then(({createGuestPictures:t})=>{G||(F=t(p,{as:"blob",view:`"${o.title??o.name}"`,pictures:o.pictures,...e.limits?{limits:e.limits}:{},...e.file?{file:e.file}:{},moved:()=>b?.push(),onLeft:s=>{B?.postMessage({type:"notice",text:s}),e.onProblem?.(s)}}))}):Promise.resolve();h=()=>{Ut(),Pe.dispose(),F?.dispose(),J?.dispose(),$?.dispose(),oe?.dispose()};let B,ee=t=>B?.postMessage(t),De=!1,He=!1,te=()=>f.toggleAttribute("data-worker-view-drawn",!G&&He&&k!==void 0&&c.length===0&&X.size===0&&!F?.waiting()&&!($?.waiting??0)),q=p.performance,X=new Map,re=q.now(),zt=()=>{if(T)return;let t=Math.max(10,Math.min(250,Math.floor(M.pushMs/4)));re=q.now(),T=p.setInterval(()=>{let s=q.now(),v=s-re>t*2?s-re-t:0;re=s;for(let[K,_]of X){let u=_+v;if(X.set(K,u),s-u>=M.pushMs)return C("slow")}},t)},qt=ce(()=>M.drawMs,()=>q.now()),je=()=>{},me=t=>{if(G)return;if(!k)return void c.push(t);let s=k;if(!qt.draw(K=>t[0]==="render"?s.apply(t[1],K):(s.style(t[1]),!0)))return C("slow");t[0]==="render"&&je()},Be=()=>new Set([...e.store.kindsKeptFrom(e.principal),...e.store.modules.disabledKinds]),Ue=()=>ct(e.store.schema,Be()),ge=()=>pt(e.store.schema,e.places?.()??[],{kept:Be(),...e.arrangement?{pages:e.arrangement()}:{}}),Y=ft({sees:t=>e.store.seenBy(e.principal).graph.has(t),places:ge,lists:Ue,schema:e.store.schema,...e.onNavigate?{onNavigate:e.onNavigate}:e.goTo?{onNavigate:t=>kt(e.goTo(),t)}:{},...e.hrefOf?{hrefOf:e.hrefOf}:!e.onNavigate&&e.goTo?{hrefOf:t=>xt(e.goTo(),t)}:{},onLost:t=>{B?.postMessage({type:"notice",text:t}),e.onProblem?.(t)}}),j=new Set,Fe=new Set,J,$e=!1,ze=()=>{$e||($e=!0,vr().then(({createGuestMedia:t})=>{G||(J=t(p,{view:`"${o.title??o.name}"`,pictures:o.pictures!==void 0,shown:()=>x,...e.file?{file:e.file}:{},onProblem:s=>{B?.postMessage({type:"notice",text:s}),e.onProblem?.(s)}}),J.refresh(y))},()=>e.onProblem?.(`The view "${o.title??o.name}" places a video or a full-screen viewer, and the host's player could not be loaded.`)))},qe=!1,Xe=!1,ne=new Map,Ye=()=>{qe||!o.accepts?.length||(qe=!0,br().then(({createGuestDrops:t})=>{G||($=t(p,{shadow:y,manifest:o,store:e.store,principal:e.principal,files:()=>e.files?.(),shown:()=>j,hears:()=>Xe,idOf:s=>k?.renderer.idOf(s),send:ee,change:(s,v)=>{if(!b)return{ok:!1,reason:"refused",message:"The view has gone."};let K=b.change(s,v);return m(),K},handed:(s,v)=>ne.set(s.href,{file:s,drop:v}),onProblem:s=>{B?.postMessage({type:"notice",text:s}),e.onProblem?.(s)},onBusy:()=>te()}),$.refresh())},()=>e.onProblem?.(`The view "${o.title??o.name}" takes files, and the host's drop could not be loaded.`)))},oe,Je=[],Qe=!1,Xt=t=>{Je=t,oe?.bind(t),!(Qe||t.length===0)&&(Qe=!0,kr().then(({createGuestGestures:s,unheardWords:v})=>{if(!G){if(o.gestures!==!0){let K=v(o.title??o.name);return B?.postMessage({type:"notice",text:K}),e.onProblem?.(K)}oe=s(y,{root:()=>y.querySelector("[data-graview-view-root]")??void 0,idOf:K=>k?.renderer.idOf(K),send:ee}),oe.bind(Je)}},()=>{}))},Yt=t=>{let s=e.store.seenBy(e.principal).graph;for(let v of j){let K=s.getNode(v);for(let _ of Object.values(K??{}))for(let u of ht(_))if(u.href===t)return u}},Ze=t=>{if(t.localName==="graview-video")return ze();t.hasAttribute("data-lightbox")&&(t.setAttribute("aria-haspopup","dialog"),ze())};Promise.all([yr(),hr()]).then(([{createOpenDrawing:t,handedLinks:s,judgeLink:v,linkRefusedWords:K},{createPressReader:_,createSaver:u,fillPrefills:N,judgePress:I,markPresses:H,prefillOf:se,quietPictures:Jt}])=>{if(G)return;let Q=_(),nt=(l,O)=>{let V=k?.renderer.idOf(l);V!==void 0&&ee({type:"dom-event",target:V,event:"acted",pressed:O})},we=u({reader:Q,save:(l,O)=>{if(!b)return;let V=b.pressed(I(e.store,o,j,l));m(),nt(O,{as:l.as,...V})}}),ot=()=>we.flush();p.addEventListener("pagehide",ot),R=()=>{p.removeEventListener("pagehide",ot),we.flush()};let Qt=new WeakSet;je=()=>{Y.refresh(y),H(y),Jt(y),N(y,Q,Qt,l=>se(e.store,e.principal,o,j,l)),J?.refresh(y),$?.refresh()};let st,it=new Set,Zt=()=>(st!==x&&([st,it]=[x,s(x)]),it),at=new Set;k=t(y,{origin:e.origin??p.location.origin,link:l=>v(l,{handed:Zt(),...e.links?{origins:e.links.origins}:{}}),...e.asset?{asset:e.asset}:{},...e.images?{imageOrigins:e.images.origins}:{},...o.pictures?{picture:l=>F?.drawn(l)}:{},onRefused:l=>{if(l.reason==="url"&&l.element==="a"&&l.address!==void 0&&!at.has(l.address)){at.add(l.address);let V=K(l.address,e.links?.origins);return B?.postMessage({type:"notice",text:V}),e.onProblem?.(V)}if(l.reason!=="url"||l.element!=="img"||l.address===void 0||Fe.has(l.address))return;Fe.add(l.address);let O=yt(l.address,{...e.images?{origins:e.images.origins}:{},assets:e.asset!==void 0},l.length);B?.postMessage({type:"notice",text:O}),e.onProblem?.(O)},...e.limits?.maxNodes!==void 0?{maxNodes:e.limits.maxNodes}:{},onOverBudget:()=>C("nodes"),send:ee,onFieldSet:l=>Q.filled(l),onAttribute:(l,O)=>{(O==="data-record"||O==="data-place")&&Y.link(l),O==="data-lightbox"&&Ze(l),O==="data-drop"&&Ye()},decorate:l=>{(l.hasAttribute("data-record")||l.hasAttribute("data-place"))&&Y.link(l),Ze(l),l.hasAttribute("data-drop")&&Ye()},before:(l,O,V)=>{Q.heard(l,O),we.heard(l,O,V),Y.pressed(l,O,V);let ve=O.closest("a[href]");ve&&V.contains(ve)&&!ve.hasAttribute("data-graview-link")&&l.type==="click"&&l.stopPropagation();let ie=O.closest("[data-lightbox]"),dt=l.type==="keydown"?l.key:void 0;if(ie&&V.contains(ie)&&l.isTrusted&&(l.type==="click"||(dt==="Enter"||dt===" ")&&ie.localName!=="button")&&(l.preventDefault(),l.stopPropagation(),J?.open(ie)),$?.before(l,O,V))return!1;let be=Q.press(l,O,V);if(!be||!b)return;l.stopPropagation(),l.type==="keydown"&&l.preventDefault();let er=b.pressed(I(e.store,o,j,be));m();let lt={as:be.as,...er},tr=O.closest("[data-act]");return queueMicrotask(()=>nt(tr,lt)),{pressed:lt}}}),Ne();for(let l of c.splice(0))me(l);w(),te()},()=>C("start","the view's drawing could not be loaded"));let ye=t=>S=ue(p,{source:t,name:o.name,limiter:P,readyMs:e.limits?.readyMs??5e3,silentMs:e.limits?.silentMs??5e3,onDropped:()=>W.dropped+=1,onStop:(s,v)=>C(s,v),onError:s=>{De||C("error",s)},onReady:(s,v,K)=>{B=v,g=Vt(Ht(p,K)),Object.assign(M,Dt(D,g)),zt();let _=de({store:e.store,principal:e.principal,view:o.name,nonce:s,send:u=>{u.type==="props"&&typeof u.push=="number"&&(X.set(u.push,q.now()),te()),v.postMessage(u)},props:()=>{let u=Se(e.store,e.principal,{manifest:o,...e.input?{input:e.input()}:{},theme:pe(),places:ut(ge()),...L?{computed:L}:{}}),N=j;return j=new Set([...u.node?[u.node.id]:[],...(u.nodes??[]).map(I=>I.id)]),x&&(N.size!==j.size||[...j].some(I=>!N.has(I)))&&k?.fade(),x=u,u},...F?{hand:F.hand}:{},judgeAct:(u,N)=>{let I=vt(e.store,o,u,N,{shown:j,file:H=>ne.get(H)?.file??Yt(H),dropped:H=>ne.get(H)?.drop});if(I.ok)for(let H of I.spent??[])ne.delete(H);return I},onHears:u=>{u.includes("drop")&&(Xe=!0)},onGestures:Xt,onClicks:u=>Nt(f,u),onRender:u=>{De=!0,me(["render",u])},onPushed:(u,N)=>{if(X.delete(u),N>=M.pushMs)return C("slow");He=!0,te()},onFlood:()=>C("flood"),onStyle:u=>me(["style",u]),places:()=>[...new Set([...ge().map(u=>u.as),...Ue().map(u=>u.slug)])],...e.limits?{limits:e.limits}:{},limiter:P});b=_,v.onmessage=({data:u})=>{if(!S?.answer(u)&&(_.receive(u),m(),!G&&u?.nonce===s&&u.type==="navigate")){let N={...u.where!==void 0?{where:u.where}:{},...u.section!==void 0?{section:u.section}:{}},I=typeof u.place=="string"?{place:u.place,...N}:typeof u.to=="string"&&{record:u.to,...N};I&&Y.go(I)}},fe()}}),et=o.pictures!==void 0||xe(e.store,o),tt=()=>Promise.all([$t.catch(()=>Promise.reject(new Error("the view's pictures could not be loaded"))),Ft.catch(()=>Promise.reject(new Error("the view's computed values could not be worked out")))]),rt=t=>{"source"in t?(et?Promise.all([Te(t.source),tt()]).then(([s])=>s):Te(t.source)).then(s=>{G||ye({script:s})},s=>C("start",s instanceof Error&&s.message.startsWith("the view's")?s.message:"the view's runtime could not be loaded")):et?tt().then(()=>{G||ye(t)},s=>C("start",s instanceof Error?s.message:"the view's pictures could not be loaded")):ye(t)};return typeof z=="function"?Rt(z).then(t=>{if(G)return;let s=Le(t);s?C(...s):rt(t)},t=>C("source",`Its code did not arrive${t instanceof Error&&t.message?`: ${t.message}`:""}.`)):rt(z),he();function he(){return{element:f,shadow:y,get worker(){return S?.worker},update:()=>{b&&fe()},get stats(){return m(),W},get refused(){return k?.refused??[]},get contentHeight(){return d},get pace(){return g},dispose(){G=!0,Oe(),i?.disconnect(),k?.dispose(),f.remove(),A?.remove()}}}}var jt="graview-guest-kit";function rn(r,e){let a=r.ownerDocument,p=a.defaultView;if(!a.getElementById(jt)){let S=a.createElement("style");S.id=jt,S.textContent=We,a.head.appendChild(S)}let o=a.createElement("div");o.className="graview-guest",o.setAttribute("role","group"),o.setAttribute("aria-label",e.title??e.view),o.setAttribute("data-guest-view",e.view),r.appendChild(o);let f={applied:0,refused:0,dropped:0},y=ae(e.limits),A=ce(()=>e.limits?.drawMs??100,()=>p.performance.now()),W,P,M,D=!1,g={applied:0,refused:0,dropped:0},x=()=>{if(!W)return;let S=W.stats;f.applied+=S.applied-g.applied,f.refused+=S.refused-g.refused,f.dropped+=S.dropped-g.dropped,g={...S}},L=()=>{x(),W?.dispose(),W=void 0,M?.stop()},b=(S,k)=>{D||(D=!0,L(),P?.dispose(),e.onFailure?.(S,k))};return M=ue(p,{source:e.worker,name:e.view,limiter:y,readyMs:e.limits?.readyMs??5e3,silentMs:e.limits?.silentMs??5e3,onDropped:()=>f.dropped+=1,onStop:(S,k)=>b(S,k),onReady:(S,k)=>{let G=Ae(o,{...e.kit?{kit:e.kit}:{},...e.links?{links:e.links}:{},onEvent:(c,m)=>k.postMessage({type:"event",listener:c,...m!==void 0?{detail:m}:{}}),...e.limits?.maxNodes!==void 0?{maxNodes:e.limits.maxNodes}:{},onOverBudget:()=>b("budget")});P=G;let n=de({store:e.store,principal:e.principal,view:e.view,nonce:S,send:c=>k.postMessage(c),onRender:c=>{A.draw(m=>G.apply(c,m))||b("slow")},...e.input?{input:e.input}:{},...e.onNavigate?{onNavigate:e.onNavigate}:{},onSize:e.onSize??(c=>o.style.minHeight=`${c}px`),...e.limits?{limits:e.limits}:{},limiter:y});W=n,k.onmessage=c=>{M?.answer(c.data)||(n.receive(c.data),x())},n.push()}}),{element:o,get worker(){return M?.worker},update:()=>W?.push(),get stats(){return x(),f},get refused(){return P?.refused??[]},dispose(){D=!0,L(),P?.dispose(),o.remove()}}}export{Ee as GUEST_KIT,We as GUEST_KIT_CSS,Me as KIT_LINK_TARGETS,Kt as KIT_TONES,Ae as createKitRenderer,_t as hostAttribute,Lt as kitValue,rn as mountGuestWorker,Tr as mountWorkerView};
|
|
@@ -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 Ge}from"./chunk.BJUUSIQY.js";import{a as Ke}from"./chunk.
|
|
2
|
-
`),unknownWords:r,questions:f,toolMistakes:d}}var Sn=e=>/^(?:aggregate|kind):([^,]+)$/.exec(e)?.[1];function Xe(e,n){let t=e.about??[];if(e.field!==void 0&&e.on!==void 0&&n(e.on))return{on:"field",id:e.on,field:e.field};let i=t.filter(n);if(i.length>1)return{on:"selection",ids:i};if(e.on!==void 0&&n(e.on))return{on:"record",id:e.on};if(i.length===1)return{on:"record",id:i[0]};let o=[e.on,...t].map(r=>r===void 0?void 0:Sn(r)).find(r=>r!==void 0);return e.place!==void 0?{on:"lens",place:e.place,...o?{kind:o}:{}}:o!==void 0?{on:"list",kind:o}:{on:"place",place:"home"}}var Q=e=>e.on==="record"||e.on==="field"?[e.id]:e.on==="selection"?e.ids:e.on==="act"&&e.id!==void 0?[e.id]:[],ye=(e,n)=>e.tryDefinition(n)?.fields?.shape??{},Y=(e,n)=>e.tryDefinition(n)?.edges??{},ge=(e,n)=>new Set(e.tryDefinition(n)?.display?.hide??[]),L=(e,n)=>ce(e.tryDefinition(n.kind),n),$e=(e,n,t)=>Ne(e.tryDefinition(n),t)||B(t),Ce=e=>typeof e=="boolean"?e?"yes":"no":String(e);function me(e,n){let t=e.kindsKeptFrom(n);return new Set(e.schema.kinds.filter(i=>!t.has(i)))}function Re(e,n,t,i){if(!e.permits(n,t).ok)return!1;if(!i)return!0;try{return e.previewAll([n],{author:t}).ops.length>0}catch{return!1}}function he(e,n,t){let i=e,{principal:o}=t,r=t.each??8,f=ee(i)?.store??i,d=f.seenBy(o),c=f.schema,a=me(f,o),s=l=>{let h=d.graph.getNode(l);return h&&a.has(h.kind)?h:void 0},u=f.allMutations(),g=new Map(u.map(l=>[l.name,l])),b=[],C=new Set,A=l=>{C.has(l.id)||(C.add(l.id),b.push(l))},m=l=>l.slice(0,r),x=Q(n).filter(l=>s(l)!==void 0);if(Q(n).length>0&&x.length===0)return{target:n,candidates:[]};let O=x.length===1?s(x[0]):void 0,k=O?.kind??(n.on==="list"?n.kind:n.on==="lens"?n.kind??t.places?.find(l=>l.as===n.place)?.kind:void 0)??(n.on==="selection"?s(x[0])?.kind:void 0);if(k!==void 0&&!a.has(k))return{target:n,candidates:[]};let p=(l,h)=>`act:${l}${Object.keys(h).length>0?`:${Object.values(h).map(R=>String(R)).join(",")}`:""}`,w=(l,h,R,E,$)=>{l.destructive||Object.values(h).some(y=>typeof y=="string"&&f.graph.has(y)&&s(y)===void 0)||Re(f,{name:l.name,args:{...h}},o,E.length===0)&&A({type:"act",id:p(l.name,h),label:R,description:$??l.description??R,mutation:l.name,args:h,asks:E})};if(n.on!=="place"||t.acts)if(t.acts)for(let l of t.acts){let h=g.get(l.mutation);!h||l.destructive||n.on==="act"&&l.mutation!==n.act||w(h,l.args,l.label,(l.open??[]).filter(R=>!R.optional).map(R=>R.name),l.why)}else{let l=O?[O]:[];for(let h of u){if(n.on==="act"&&h.name!==n.act)continue;let R=h.input.shape??{},E=$=>Object.entries(R).filter(([y,v])=>y!==$&&v.safeParse?.(void 0).success===!1).map(([y])=>y);if(h.subject)for(let $ of l)fe(c,h).includes($.kind)&&w(h,{[h.subject.arg]:$.id},`${h.title??B(h.name)}: ${L(c,$)}`,E(h.subject.arg));else k!==void 0&&(h.creates??[]).includes(k)&&w(h,{},h.title??B(h.name),E(void 0))}}let T=b.filter(l=>l.type==="act");b.splice(0,b.length,...m(T));let F=(l,h)=>{let R=Le(c,u).get(l.kind),E=ye(c,l.kind),$=ge(c,l.kind),y=[];for(let[v,D]of Object.entries(E)){if(h!==void 0?v!==h:$.has(v)||l[v]!==void 0)continue;let j=pe(D),J=j?.type==="enum"&&!j.multiple?j.options??[]:j?.type==="boolean"?[!0,!1]:[];if(J.length===0)continue;let _=(R?.get(v)??[]).map(N=>g.get(N)).find(N=>N?.subject!==void 0&&Re(f,{name:N.name,args:{[N.subject.arg]:l.id,[v]:J.find(Se=>Se!==l[v])??J[0]}},o,!0));if(_?.subject)for(let N of J)l[v]!==N&&y.push({type:"fill",id:`fill:${l.id}:${v}:${Ce(N)}`,label:`${$e(c,l.kind,v)}: ${Ce(N)}`,description:`Set ${$e(c,l.kind,v).toLowerCase()} of ${L(c,l)} to ${Ce(N)}`,record:l.id,field:v,value:N,call:{name:_.name,args:{[_.subject.arg]:l.id,[v]:N}}})}for(let[v,D]of Object.entries(Y(c,l.kind))){if(h!==void 0&&v!==h)continue;let j=D.to==="*"?[...a]:D.to.filter(I=>a.has(I)),J=new Set(d.graph.out(l.id,v).map(I=>I.id)),_=u.find(I=>(I.connects??[]).includes(v)&&I.subject!==void 0&&fe(c,I).includes(l.kind));if(!_?.subject)continue;let N=De(_.input).find(I=>I.name!==_.subject.arg);if(!N)continue;let Se=j.flatMap(I=>N.kinds.length===0||N.kinds.includes(I)?d.graph.nodesOfKind(I):[]).filter(I=>I.id!==l.id&&!J.has(I.id)&&s(I.id)!==void 0);for(let I of m(Se)){let Me={name:_.name,args:{[_.subject.arg]:l.id,[N.name]:I.id}};Re(f,Me,o,!0)&&y.push({type:"fill",id:`fill:${l.id}:${v}:${I.id}`,label:`${B(v)}: ${L(c,I)}`,description:`Link ${L(c,l)} to ${L(c,I)}${D.description?` as ${D.description}`:""}`,record:l.id,field:v,value:I.id,call:Me})}}return y};if(n.on==="field"&&O)for(let l of F(O,n.field))A(l);else if(O&&n.on==="record")for(let l of m(F(O)))A(l);let q=l=>{let h=W(c,l).toLowerCase(),R=[{type:"panel",id:`panel:${l}:list`,label:`A list of ${h}`,description:`Every ${G(c.tryDefinition(l),l).toLowerCase()} this viewer may see, as a list`,panel:{lens:"blocks",kind:l}}],E=ge(c,l);for(let[$,y]of Object.entries(ye(c,l))){if(E.has($))continue;let v=pe(y),D=$e(c,l,$).toLowerCase();if(v?.type==="enum")R.push({type:"panel",id:`panel:${l}:group:${$}`,label:`${V(h)} by ${D}`,description:`A list of ${h} grouped by ${D}`,panel:{lens:"blocks",kind:l,group:$}}),R.push({type:"panel",id:`panel:${l}:columns:${$}`,label:`Columns of ${h} by ${D}`,description:`${V(h)} in a column for each ${D}`,panel:{lens:"columns",kind:l,column:$}});else if(v?.type==="number"||v?.type==="integer"||v?.type==="date"||v?.type==="datetime"){let j=v.type==="date"||v.type==="datetime";R.push({type:"panel",id:`panel:${l}:sort:${$}`,label:`${V(h)} by ${D}`,description:`A list of ${h}, the ${j?"latest":"highest"} ${D} first`,panel:{lens:"blocks",kind:l,sort:{by:$,direction:"desc"}}}),j&&R.push({type:"panel",id:`panel:${l}:calendar:${$}`,label:`A calendar of ${h}`,description:`${V(h)} on a calendar by ${D}`,panel:{lens:"calendar",kind:l,start:$}})}}return R},H=n.on==="place"?[...a]:k!==void 0?[k]:[];for(let l of H)for(let h of m(q(l)))A(h);for(let l of m((t.places??[]).filter(h=>h.kind===void 0?n.on==="place":a.has(h.kind)&&(n.on==="place"||h.kind===k))))n.on==="lens"&&l.as===n.place||A({type:"place",id:`place:${l.as}`,label:l.title,description:`Go to ${l.title}`,place:l.as});if(O){let l=[];for(let[h,R]of Object.entries(Y(c,O.kind)))for(let E of d.graph.out(O.id,h))s(E.id)&&l.push({type:"record",id:`record:${E.id}`,label:L(c,E),description:`${V(R.description??B(h))}: ${L(c,E)}`,record:E.id,relation:h});for(let h of c.kinds)for(let[R,E]of Object.entries(Y(c,h)))if(!(E.to!=="*"&&!E.to.includes(O.kind)))for(let $ of d.graph.in(O.id,R))$.kind===h&&s($.id)&&l.push({type:"record",id:`record:${$.id}`,label:L(c,$),description:`${V(E.inverse??B(R))}: ${L(c,$)}`,record:$.id,relation:R});for(let h of m(l))A(h)}else if(n.on==="list"||n.on==="lens")for(let l of m(k!==void 0?d.graph.nodesOfKind(k):[]))s(l.id)&&A({type:"record",id:`record:${l.id}`,label:L(c,l),description:`Open ${L(c,l)}`,record:l.id});else if(n.on==="selection")for(let l of x){let h=s(l);A({type:"record",id:`record:${l}`,label:L(c,h),description:`Open ${L(c,h)}`,record:l})}return{target:n,candidates:b}}var V=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,xn={columns:["board","kanban","column","lane","pipeline","stage","funnel"],board:["board","map","floor","layout","seat","slot"],calendar:["calendar","schedule","date","due","month","week","agenda","deadline","day"],timeline:["timeline","gantt","schedule","roadmap","span"],coverage:["coverage","matrix","grid","gap"],plan:["plan","floor","map","region","area"],blocks:["list","table","summary","overview","dashboard","card"]},On=new Set(["a","an","the","of","for","my","our","me","us","to","with","and","in","on","by","that","which","i","we","want","need","show","open","go","draw","make","new","view","views","panel","panels","page","lens","please","all","every","some","see","can","could","would","like","one","what","is","are","do","does","here","there","how","it","this","these","those"]),te=e=>e.length>3&&e.endsWith("ies")?`${e.slice(0,-3)}y`:e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e,Te=e=>e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^a-z0-9]+/).filter(Boolean);function Ze(e,n,t){let i=e,o=ee(i)?.store??i,r=o.schema,f=me(o,t.principal),d=o.seenBy(t.principal),c=Q(n),a=new Set;for(let p of c){let w=d.graph.getNode(p)?.kind;w!==void 0&&f.has(w)&&a.add(w)}if(c.length>0&&a.size===0)return[];if(n.on==="list"&&a.add(n.kind),n.on==="lens"){let p=n.kind??t.places.find(w=>w.as===n.place)?.kind;p!==void 0&&a.add(p)}let s=new Map;for(let p of r.kinds){if(!f.has(p))continue;let w=r.tryDefinition(p);for(let T of[p,G(w,p),W(r,p)])for(let F of Te(T))s.set(te(F),p)}let u=Te(t.said??"").filter(p=>!On.has(p)),g=new Set,b=[];for(let p of u){let w=s.get(te(p));w!==void 0?g.add(w):b.push(te(p))}let C=g.size>0?g:a;if((t.said??"").trim()!==""&&u.length===0)return[];if(C.size===0&&u.length===0)return[];let A=[];t.places.forEach((p,w)=>{if(p.hidden||n.on==="lens"&&p.as===n.place)return;let T=p.over??(p.kind!==void 0?[p.kind]:[]);if(T.length>0&&!T.some(H=>f.has(H)))return;let F=T.some(H=>C.has(H)),q=!F&&(p.reads??[]).some(H=>C.has(H));C.size>0&&!F&&!q||A.push({place:p,own:F,reads:q,at:w})});let m=p=>new Set(Te(p.title).map(te)),x=new Set(b.filter(p=>A.some(({place:w})=>m(w).has(p)))),O=[];for(let{place:p,own:w,reads:T,at:F}of A){let q=m(p),H=new Set((xn[p.lens??""]??[]).map(te)),l=b.filter($=>q.has($)||H.has($)&&!x.has($)).length,h=b.length-l;if(b.length>0&&l===0)continue;let R=!T&&h===0?"full":"partial",E=(w?4:T?2:1)+l*2-h+(R==="full"?1:0);O.push({view:{place:p.as,title:p.title,...p.kind!==void 0?{kind:p.kind}:{},fit:R},score:E,at:F})}return O.filter((p,w)=>!O.slice(0,w).some(T=>T.view.place===p.view.place&&T.view.title===p.view.title)).sort((p,w)=>w.score-p.score||p.at-w.at).slice(0,t.most??3).map(p=>p.view)}var Ee=new WeakMap;function vn(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619)>>>0;return n.toString(36)}function $n(e,n){let t=e,i=ee(t)?.store??t,o=i.schema,r=me(i,n),d=i.allMutations().filter(A=>!A.destructive&&i.permits({name:A.name,args:{}},n).ok!==!1),c=`${[...r].join(",")}|${d.map(A=>A.name).join(",")}`,a=Ee.get(o)?.get(c);if(a)return a;let s=[...r].map(A=>{let m=ge(o,A),x={};for(let[w,T]of Object.entries(ye(o,A))){if(m.has(w))continue;let F=pe(T);F&&(x[w]=F.type==="enum"?`enum:${(F.options??[]).join("|")}`:F.type)}let O={};for(let[w,T]of Object.entries(Y(o,A)))O[w]=T.to==="*"?[...r]:T.to.filter(F=>r.has(F));let k=o.tryDefinition(A),p=Object.entries(k?.fieldAliases??{}).filter(([w,T])=>w in x&&T.length>0);return{kind:A,noun:G(o.tryDefinition(A),A),plural:W(o,A),fields:x,relations:O,...k?.aliases&&k.aliases.length>0?{aliases:k.aliases}:{},...p.length>0?{fieldAliases:Object.fromEntries(p)}:{}}}),u=d.map(A=>({name:A.name,title:A.title??B(A.name),...A.subject?{on:fe(o,A).filter(m=>r.has(m))}:{}})),g={kinds:s,acts:u},b={version:vn(JSON.stringify(g)),...g},C=Ee.get(o)??new Map;return C.set(c,b),Ee.set(o,C),b}var Cn=e=>e.name??e.id??e.kind;function en(e,n,t){let i=e,{principal:o}=t,r=ee(i)?.store??i,f=r.seenBy(o),d=r.schema,c=me(r,o),a=p=>{let w=f.graph.getNode(p);return w&&c.has(w.kind)?w:void 0},s=p=>({id:p.id,kind:p.kind,label:L(d,p)}),u=Q(n),g=u.length===1?a(u[0]):void 0,b=g?Object.fromEntries(Object.keys(ye(d,g.kind)).filter(p=>!ge(d,g.kind).has(p)&&g[p]!==void 0&&p!=="label").map(p=>[p,g[p]])):{},C={on:n.on,...g?{record:{...s(g),fields:b}}:{},...n.on==="field"&&g?{field:n.field}:{},...n.on==="list"&&c.has(n.kind)?{kind:n.kind}:{},...n.on==="lens"?{place:n.place,...n.kind&&c.has(n.kind)?{kind:n.kind}:{}}:{},...n.on==="place"?{place:n.place}:{},...n.on==="act"?{act:n.act}:{}},A=[...new Set([...n.on==="selection"?n.ids:[],...t.selection??[]])].flatMap(p=>{let w=a(p);return w?[s(w)]:[]}),m=[];if(g){for(let p of Object.keys(Y(d,g.kind)))for(let w of f.graph.out(g.id,p))a(w.id)&&m.push({...s(w),relation:p,direction:"out"});for(let p of d.kinds)for(let w of Object.keys(Y(d,p)))for(let T of f.graph.in(g.id,w))T.kind===p&&a(T.id)&&m.push({...s(T),relation:w,direction:"in"})}let x=f.batches().filter(p=>!p.ops.every(je)).slice(-(t.recent??6)).reverse().map(p=>({intent:p.intent,at:p.at,by:Cn(p.author)})),O=(t.purpose?.jobs??[]).filter(p=>Ge(p,o.roles)&&c.has(p.kind)).map(p=>({name:p.name,ask:p.ask,kind:p.kind})),k=t.purpose&&(t.purpose.for!==void 0||O.length>0)?{...t.purpose.for!==void 0?{for:t.purpose.for}:{},jobs:O}:void 0;return{...t.place!==void 0?{place:t.place}:{},target:C,selection:A,neighbors:m.slice(0,24),recent:x,schema:$n(r,o),...k?{purpose:k}:{},...t.friction?{friction:Qe(t.friction,d,{reader:o})}:{}}}function ie(e){if(!e.off)return e.fast??(e.decide?{model:e.name??"decide",decide:e.decide}:void 0)}function U(e){if(e.off)return;if(e.thinking)return e.thinking;let n=e.name??"model";if(e.complete){let t=e.complete;return{model:n,think:({system:i,prompt:o})=>t({prompt:o,system:i})}}if(e.turn){let t=e.turn;return{model:n,think:async({system:i,prompt:o})=>({text:await t({system:i,messages:[{role:"user",content:o}],tools:[],call:async()=>({error:"No tools here."})})})}}}var Pe=(e,n,t)=>e?n/1e6*(e.inputPerMillion??0)+t/1e6*(e.outputPerMillion??0):void 0,Ie=()=>`ai-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;function Rn(e,n,t=[]){let i=o=>{let r=e.graph.getNode(o);return r?ce(e.schema.tryDefinition(r.kind),r):"a record"};switch(n.on){case"record":return i(n.id);case"field":return`${i(n.id)} \xB7 ${n.field}`;case"selection":return`${n.ids.length} records`;case"list":return e.schema.tryDefinition(n.kind)?W(e.schema,n.kind):n.kind;case"lens":case"place":return t.find(o=>o.as===n.place)?.title??(n.place==="home"?"Home":n.place);case"act":return n.act}}var nn=e=>e.type!=="act"||e.asks.length===0,be=(e,n)=>({id:e.id,type:e.type,label:e.label,...n!==void 0?{confidence:n}:{}});function X(e,n){let t=n.interaction??Ie(),i=he(n.store,n.target,{principal:n.principal,...n.acts?{acts:n.acts}:{},...n.places?{places:n.places}:{}}),o=en(n.store,n.target,{principal:n.principal,...n.place?{place:n.place}:{},...n.selection?{selection:n.selection}:{},...n.purpose?{purpose:n.purpose}:{}}),r=[];return{id:t,catalog:i,state:o,entry:{id:t,at:new Date().toISOString(),by:n.by??n.principal,target:n.target,targetLabel:Rn(n.store,n.target,n.places)},usage:r,meter:f=>{r.push(f),e.meter?.({...f,interaction:t})}}}async function oe(e,n,t,i){let o=await e.decide(n,t),{inputTokens:r,outputTokens:f}=o.usage,d=Pe(e.price,r,f);return i({tier:"fast",model:e.model,inputTokens:r,outputTokens:f,...d!==void 0?{costUsd:d}:{}}),o.answers}async function re(e,n,t,i,o){let r=await e.think({system:n,prompt:t,state:i.state,catalog:i.catalog}),f=r.usage?.inputTokens,d=r.usage?.outputTokens,c=r.usage?.costUsd??(f!==void 0?Pe(e.price,f,d??0):void 0);return o({tier:"thinking",model:e.model,...f!==void 0?{inputTokens:f}:{},...d!==void 0?{outputTokens:d}:{},...c!==void 0?{costUsd:c}:{}}),Ve(r.text)}function se(e,n){let t=new Map(e.map((i,o)=>[`c${o+1}`,i]));return{question:{type:"choice",instructions:n,criteria:Object.fromEntries([...t].map(([i,o])=>[i,`${o.label} \u2014 ${o.description}`]))},of:i=>t.get(i)}}function ae(e,n,t){if(e?.type!=="choice")return[];let i=e,o=Object.entries(i.probabilities).sort((r,f)=>f[1]-r[1]);return o.some(([r])=>r===i.choice)||o.unshift([i.choice,i.confidence]),o.flatMap(([r,f])=>{let d=n(r);return d?[{candidate:d,confidence:f}]:[]}).slice(0,t)}var M=(e,n,t,i)=>({interaction:{...e.entry,ask:{kind:t,said:n??""},offered:[],outcome:"failed",failed:i,usage:[...e.usage]},offers:[]}),Z="AI isn't on here.";async function tn(e,n,t=3){let i=X(e,n),o=n.said??"Suggest",r=i.catalog.candidates.filter(nn).slice(0,24);if(r.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let f=ie(e),d=U(e),c=[];try{if(f){let{question:a,of:s}=se(r,"Which of these would the person most likely want to do next, here?"),u=await oe(f,{...i.state,candidates:r.map(g=>({id:g.id,type:g.type,says:g.description}))},{next:a},i.meter);c=ae(u.next,s,t)}else if(d){let a=await re(d,'You suggest what a person most likely wants to do next in an app. Answer only JSON: {"pick": [candidate ids, best first]}. Pick only ids from the candidates.',JSON.stringify({state:i.state,candidates:r.map(u=>({id:u.id,says:u.description}))}),i,i.meter);c=(Array.isArray(a?.pick)?a.pick.filter(u=>typeof u=="string"):[]).flatMap(u=>r.filter(g=>g.id===u)).slice(0,t).map(u=>({candidate:u}))}else return M(i,o,"suggest",Z)}catch(a){return M(i,o,"suggest",a instanceof Error?a.message:String(a))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:c.map(({candidate:a,confidence:s})=>be(a,s)),outcome:"offered",usage:[...i.usage]},offers:c.map(({candidate:a})=>a)}}var Tn=e=>`several:${e}`;async function it(e,n,t=2){let i=X(e,{...n,acts:[]}),o=n.said??"Suggest for the chosen",r=n.target.on==="selection"?n.target.ids.length:1,d=[...n.shared.map(s=>({type:"act",id:Tn(s.id),label:s.label,description:`${s.label}, for all ${r} chosen`,mutation:s.mutation,args:s.args,asks:[]})),...i.catalog.candidates.filter(s=>s.type==="panel"||s.type==="place")].slice(0,24),c=ie(e);if(!c)return M(i,o,"suggest",Z);if(d.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let a;try{let{question:s,of:u}=se(d,`Which of these would the person most likely want to do next with the ${r} records they chose together?`),g=await oe(c,{...i.state,candidates:d.map(b=>({id:b.id,type:b.type,says:b.description}))},{next:s},i.meter);a=ae(g.next,u,t).filter((b,C)=>C===0||b.confidence>=En)}catch(s){return M(i,o,"suggest",s instanceof Error?s.message:String(s))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:a.map(({candidate:s,confidence:u})=>be(s,u)),outcome:"offered",usage:[...i.usage]},offers:a.map(({candidate:s})=>s)}}var En=.25;async function on(e,n){let t=X(e,n),i=n.said??"Fill in",o=t.catalog.candidates.filter(u=>u.type==="fill"),r=new Map;for(let u of o)r.set(u.field,[...r.get(u.field)??[],u]);if(r.size===0)return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:[],outcome:"offered",usage:[]},offers:[]};let f=ie(e),d=U(e),c=[];try{if(f){let u=[...r].map(([b,C],A)=>({key:`f${A+1}`,field:b,...se(C,`Which value fits "${b}" best for this record?`)})),g=await oe(f,t.state,Object.fromEntries(u.map(b=>[b.key,b.question])),t.meter);for(let b of u){let C=!Pn(n.store,n.target,b.field)&&In(n.store,n.target,b.field)!=="one";c.push(...ae(g[b.key],b.of,C?3:1).filter((A,m)=>m===0||A.confidence>=.4))}}else if(d){let u=await re(d,`You fill in a record's fields in an app. Answer only JSON: {"fills": [candidate ids]}, at most one per field, only ids from the candidates.`,JSON.stringify({state:t.state,candidates:o.map(C=>({id:C.id,says:C.description}))}),t,t.meter),g=Array.isArray(u?.fills)?u.fills.filter(C=>typeof C=="string"):[],b=new Set;for(let C of g){let A=o.find(m=>m.id===C);A?.type==="fill"&&!b.has(A.field)&&(b.add(A.field),c.push({candidate:A}))}}else return M(t,i,"fill",Z)}catch(u){return M(t,i,"fill",u instanceof Error?u.message:String(u))}let a=t.usage.at(-1)?.model,s=de(n.store,{interaction:t.id,target:n.target,basis:i,...a?{model:a}:{},proposals:c.flatMap(({candidate:u,confidence:g})=>u.type==="fill"?[{id:u.id,label:u.label,said:u.description,call:u.call,record:u.record,field:u.field,...g!==void 0?{confidence:g}:{}}]:[])},n.principal);return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:s.proposals.map(u=>({id:u.id,type:"fill",label:u.label,...u.confidence!==void 0?{confidence:u.confidence}:{}})),outcome:"offered",usage:[...t.usage]},offers:[],...s.proposals.length>0?{ghost:s}:{}}}function Pn(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0,r=(o?e.schema.tryDefinition(o)?.fields?.shape:void 0)??{};return t in r}function In(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0;return o?e.schema.tryDefinition(o)?.edges?.[t]?.cardinality:void 0}async function rn(e,n){let t=X(e,n),i=n.said??"Add one",o=new Set(n.store.allMutations().filter(s=>(s.creates??[]).length>0).map(s=>s.name)),r=t.catalog.candidates.filter(s=>s.type==="act"&&s.asks.length>0&&o.has(s.mutation));if(r.length===0)return M(t,i,"record","Nothing here makes a record.");let f=U(e);if(!f)return M(t,i,"record",Z);let d;try{let s=await re(f,'You propose one new record for an app by filling in an act. Answer only JSON: {"act": a candidate id, "args": {argument: value}}. Use only the candidates, and fill every argument the act asks for with a value that fits the state.',JSON.stringify({ask:i,state:t.state,candidates:r.map(b=>({id:b.id,says:b.description,asks:b.asks}))}),t,t.meter),u=r.find(b=>b.id===s?.act),g=typeof s?.args=="object"&&s.args!==null?s.args:{};u&&(d={act:u,args:Object.fromEntries(Object.entries(g).filter(([b])=>u.asks.includes(b)))})}catch(s){return M(t,i,"record",s instanceof Error?s.message:String(s))}if(!d)return M(t,i,"record","The model named no act this app has here.");let c=t.usage.at(-1)?.model,a=de(n.store,{interaction:t.id,target:n.target,basis:i,...c?{model:c}:{},proposals:[{id:d.act.id,label:d.act.label,said:d.act.description,call:{name:d.act.mutation,args:{...d.act.args,...d.args}}}]},n.principal);return a.proposals.length===0?M(t,i,"record","What the model proposed could not be made here."):{interaction:{...t.entry,ask:{kind:"record",said:i},offered:a.proposals.map(s=>({id:s.id,type:"act",label:s.said})),outcome:"offered",usage:[...t.usage]},offers:[d.act],ghost:a}}async function sn(e,n){let t=X(e,n),i=n.said??"Make a panel",o=t.catalog.candidates.filter(s=>s.type==="panel");if(o.length===0)return M(t,i,"panel","Nothing here can be drawn as a panel.");let r=ie(e),f=U(e),d;try{if(f){let s=await re(f,'You choose a panel to draw in an app. Answer only JSON: {"panel": a candidate id, "title": a short title}. Choose only among the candidates.',JSON.stringify({ask:i,state:t.state,candidates:o.map(g=>({id:g.id,says:g.description}))}),t,t.meter),u=o.find(g=>g.id===s?.panel);u&&(d={panel:u,...typeof s?.title=="string"&&s.title.trim()?{title:s.title.trim().slice(0,60)}:{}})}else if(r){let{question:s,of:u}=se(o,`Which panel answers this best: ${i}`),g=ae((await oe(r,t.state,{panel:s},t.meter)).panel,u,1)[0];g?.candidate.type==="panel"&&(d={panel:g.candidate,confidence:g.confidence})}else return M(t,i,"panel",Z)}catch(s){return M(t,i,"panel",s instanceof Error?s.message:String(s))}if(!d)return M(t,i,"panel","The model named no panel this app can draw.");let c=d.title??d.panel.label,a={title:c,recipe:{...d.panel.panel,title:c}};return{interaction:{...t.entry,ask:{kind:"panel",said:i},offered:[be(d.panel,d.confidence)],outcome:"drawn",panel:a,usage:[...t.usage]},offers:[d.panel],panel:a}}function Fn(e){return e.off?void 0:e.answer}var Mn=`You answer a person's question about what they are looking at in an app, from the state given and nothing else. Answer only JSON: {"answer": one to three short sentences, "pick": [candidate ids that act on the answer, best first, at most three]}. Pick only ids from the candidates, and none when nothing fits. Never say an id to the person.`;async function ot(e,n){let t=X(e,n),i=n.said.trim(),o=t.catalog.candidates.filter(m=>nn(m)||m.type==="panel"||m.type==="place"||m.type==="record").slice(0,32),r=Fn(e),f=U(e),d=ie(e),c="",a=[],s=m=>m.flatMap(x=>o.filter(O=>O.id===x)).slice(0,3).map(x=>({candidate:x}));try{if(r){let m=await r.answer({said:i,target:n.target,targetLabel:t.entry.targetLabel,state:t.state,catalog:{target:t.catalog.target,candidates:o},...n.follows?{follows:n.follows}:{}}),x=m.usage?.inputTokens,O=m.usage?.outputTokens,k=m.usage?.costUsd??(x!==void 0?Pe(r.price,x,O??0):void 0);t.meter({tier:"thinking",model:r.model,...x!==void 0?{inputTokens:x}:{},...O!==void 0?{outputTokens:O}:{},...k!==void 0?{costUsd:k}:{}}),c=typeof m.text=="string"?m.text.trim():"",a=s(m.pick??[])}else if(f){let m=await re(f,Mn,JSON.stringify({ask:i,about:t.entry.targetLabel,...n.follows?{follows:n.follows}:{},state:t.state,candidates:o.map(x=>({id:x.id,says:x.description}))}),t,t.meter);c=typeof m?.answer=="string"?m.answer.trim():"",a=s(Array.isArray(m?.pick)?m.pick:[])}else if(d&&o.length>0){let{question:m,of:x}=se(o,`Which of these best answers, or acts on: ${i}`),O=await oe(d,{...t.state,asked:i,candidates:o.map(k=>({id:k.id,type:k.type,says:k.description}))},{answer:m},t.meter);a=ae(O.answer,x,3),c=a.length>0?`These fit \u201C${i}\u201D.`:""}else return M(t,i,"ask",Z)}catch(m){return M(t,i,"ask",m instanceof Error?m.message:String(m))}if(!c&&a.length===0){let m=n.target.on==="place"||n.target.on==="lens"?n.target.place:void 0,x=n.target.on==="list"||n.target.on==="lens"?n.target.kind:void 0;return Be(n.store,{type:"unanswered",question:i,...m?{place:m}:{},...x?{kind:x}:{}},n.principal),M(t,i,"ask","The AI had no answer to that here.")}let u=t.usage.at(-1)?.model,g=a.flatMap(({candidate:m,confidence:x})=>{let O=ke(m);return O?[{...O,...x!==void 0?{confidence:x}:{}}]:[]}),b=g.length>0?de(n.store,{interaction:t.id,target:n.target,basis:i,...u?{model:u}:{},proposals:g},n.principal):void 0,C=a.map(({candidate:m})=>m).filter(m=>ke(m)===void 0),A=[...C.map(m=>be(m,a.find(x=>x.candidate===m)?.confidence)),...(b?.proposals??[]).map(m=>({id:m.id,type:m.field!==void 0?"fill":"act",label:m.label,...m.confidence!==void 0?{confidence:m.confidence}:{}}))];return{interaction:{...t.entry,ask:{kind:"ask",said:i},offered:A,outcome:"offered",...c?{answer:c}:{},usage:[...t.usage]},offers:C,...b&&b.proposals.length>0?{ghost:b}:{},...c?{answer:c}:{}}}function de(e,n,t){let i=n.proposals.flatMap(o=>{try{let r=e.previewAll([o.call],{author:t}),f=r.ops.map(d=>d.intent).join("; ");return r.ops.length>0?[{...o,said:f||o.said}]:[]}catch{return[]}});return{...n,proposals:i}}function ke(e){if(e.type==="fill")return{id:e.id,label:e.label,said:e.description,call:e.call,record:e.record,field:e.field};if(e.type==="act"&&e.asks.length===0)return{id:e.id,label:e.label,said:e.description,call:{name:e.mutation,args:{...e.args}}}}function an(e,n,t){let i=n.proposals.filter(r=>t.ids===void 0||t.ids.includes(r.id));if(i.length===0)return{ok:!1,refused:"Nothing was chosen."};let o=i.flatMap(r=>r.confidence===void 0?[]:[r.confidence]);try{let f=e.applyAll(i.map(d=>d.call),{author:t.author,via:`ai:${n.interaction}`,intent:n.basis,lineage:{basis:`Asked \u201C${n.basis}\u201D`,...n.model?{model:n.model}:{},...o.length>0?{confidence:Math.min(...o)}:{},interaction:n.interaction}}).ops[0]?.batch;return f?{ok:!0,batch:f,accepted:i.map(d=>d.id)}:{ok:!1,refused:"That changes nothing now."}}catch(r){return{ok:!1,refused:r instanceof Error?r.message:String(r)}}}function dn(e,n,t){let i=e.ask.kind==="suggest"?n.length>0:e.offered.length>0&&e.offered.every(o=>n.includes(o.id));return{...e,outcome:i?"accepted":"partly",accepted:n,batches:[...e.batches??[],t]}}var ln=e=>({...e,outcome:"dismissed"});var P=xe(hn(),1);var S=xe(Ue(),1);function fn(e,n,t){let i=n.on==="selection"?n.ids:n.on==="record"||n.on==="field"?[n.id]:[],o=i.length>0?Ke(e.store,i,{principal:e.principal,...i.length===1?{focus:i[0]}:{}}).affordances.map(r=>({mutation:r.mutation,label:r.label,args:r.args,open:r.open,why:r.why,...r.destructive?{destructive:!0}:{}})):void 0;return{store:e.store,target:n,principal:e.principal,interaction:Ie(),places:e.places,selection:e.selection,...o?{acts:o}:{},...e.place?{place:e.place}:{},...t?{said:t}:{},...e.app.purpose?{purpose:e.app.purpose}:{}}}async function un(e,n,t){let i=await (__graviewPreload(import.meta.url,["./chunk.HGVBGSRS.js","./chunk.G4JJXA63.js","./chunk.WD4VPMEE.js","./chunk.VUAOCYG2.js","./chunk.ZVG3DR5G.js","./chunk.XOZU4OFA.js","./chunk.LA2DMHZC.js","./chunk.ISRQQVS4.js","./chunk.WVUJXDXZ.js","./chunk.MBU7UH6J.js","./chunk.2QFKNTAZ.js","./chunk.BI6DS3PZ.js","./chunk.PGA5TUSN.js","./chunk.7R727IKU.js","./chunk.LQAT7FA6.js","./chunk.UO544PZH.js","./chunk.4STDIZVI.js","./chunk.HZHNM2KI.js","./chunk.F7PIW2EM.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.ODVRO2BJ.js")),o=i.recipeDraft(n.recipe,{app:e.app,sight:i.draftSight(e.app,e.principal)});if(i.isDraftFailure(o))return o.failed;t?.(),e.seatTalk.setDraft(o,null),e.goTo.draft?.(),pn()}function pn(e=180){if(typeof document>"u")return;let n=document.querySelector('[data-testid="draft-keep"]'),t=document.activeElement,i=!t||t===document.body||t.closest?.("[inert]")!==null;if(n){i&&n.focus();return}e>0&&requestAnimationFrame(()=>pn(e-1))}async function le(e,n,t,i,o){let r=fn(e,t,i),f=n==="suggest"?await tn(e.ai,r):n==="fill"?await on(e.ai,r):n==="record"?await rn(e.ai,r):await sn(e.ai,r);if(f.interaction.outcome==="failed")return n!=="suggest"&&e.desk.record(f.interaction),f;let d=c=>{let a={...f.interaction,outcome:"failed",failed:c};return e.desk.record(a),{...f,interaction:a}};if(n==="fill"||n==="record"){if(!f.ghost||f.ghost.proposals.length===0)return d("Nothing here could be filled in.");o?.(),e.desk.setGhost({ghost:f.ghost}),e.desk.record(f.interaction)}if(n==="panel"&&f.panel){let c=await un(e,f.panel,o);if(c)return d(c);e.desk.record(f.interaction)}return f}var Fe=new WeakMap,Nn=64,cn=new WeakMap;function jn(e){let n=cn.get(e);if(!n){let t=n={n:0};cn.set(e,t),e.subscribe(()=>void(t.n+=1))}return n.n}var yn=(e,n)=>{let t=Q(n);return t.length>0?t.map(i=>e.graph.getNode(i)):[jn(e)]},gn=(e,n,t)=>JSON.stringify({target:n,seat:e.principal,by:t}),mn=(e,n,t)=>{let i=yn(e.store,n);return t.schema===e.store.schema&&t.ai===e.ai&&i.length===t.depends.length&&i.every((o,r)=>o===t.depends[r])};function Dn(e,n,t="menu"){let i=Fe.get(e.store)?.get(gn(e,n,t));return i?.result!==void 0&&mn(e,n,i)?i.result:void 0}function Ln(e,n,t){let i=Fe.get(e.store);i||Fe.set(e.store,i=new Map);let o=gn(e,n,t?.by??"menu"),r=i.get(o);if(r&&mn(e,n,r))return r.result?Promise.resolve(r.result):r.asked;let f=t?t.ask():le(e,"suggest",n),d={schema:e.store.schema,ai:e.ai,depends:yn(e.store,n),asked:f};i.delete(o),i.set(o,d),i.size>Nn&&i.delete(i.keys().next().value);let c=i;return f.then(a=>{a.interaction.outcome!=="failed"?d.result=a:c.get(o)===d&&c.delete(o)}),f}async function Hn(e,n,t,i){let o=n.interaction,r=ke(t);if(r){let f=o.usage?.at(-1)?.model,d=o.offered.find(a=>a.id===t.id)?.confidence,c=de(e.store,{interaction:o.id,target:o.target,basis:`${o.ask.said}: ${t.label}`,...f?{model:f}:{},proposals:[{...r,...d!==void 0?{confidence:d}:{}}]},e.principal);if(c.proposals.length===0){let a="That can't be done now.";return e.desk.record({...o,outcome:"failed",failed:a}),a}i?.(),e.desk.setGhost({ghost:c}),e.desk.record(o);return}if(t.type==="panel"){let f=t.label,d={title:f,recipe:{...t.panel,title:f}},c=await un(e,d,i);return e.desk.record(c?{...o,outcome:"failed",failed:c}:{...o,outcome:"drawn",accepted:[t.id],panel:d}),c}i?.(),t.type==="place"?e.goTo.place(t.place):t.type==="record"&&e.goTo.record(t.record),e.desk.record({...o,outcome:"accepted",accepted:[t.id]})}async function yt(e,n){if(n.ask.kind==="ask")return ue(e.desk,{target:n.target,asked:n.ask.said}),null;let t=n.ask.kind==="panel"||n.ask.kind==="record"?n.ask.kind:"fill";return le(e,t,n.target,n.ask.said)}var z={padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},we={margin:0,padding:"4px 10px",fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function gt({target:e,close:n}){let t=Je(),i=(0,P.useMemo)(()=>Xe(e,y=>t.store.graph.has(y)),[e,t.store]),o=(0,P.useMemo)(()=>{let y=fn(t,i);return he(t.store,i,{principal:t.principal,places:t.places,...y.acts?{acts:y.acts}:{}})},[t,i]),r=o.candidates.some(y=>y.type==="fill"),f=o.candidates.some(y=>y.type==="panel"),d=(0,P.useMemo)(()=>f?Ze(t.store,i,{principal:t.principal,places:t.places,most:1}):[],[f,t,i]),c=(0,P.useMemo)(()=>new Set(t.store.allMutations().filter(y=>(y.creates??[]).length>0).map(y=>y.name)),[t.store]),a=U(t.ai)!==void 0&&o.candidates.some(y=>y.type==="act"&&y.asks.length>0&&c.has(y.mutation)),s=Oe(t.ai),u=Dn(t,i),g=JSON.stringify(i),[b,C]=(0,P.useState)(!1),[A,m]=(0,P.useState)(null),[x,O]=(0,P.useState)(s&&u===void 0);(0,P.useEffect)(()=>{if(u!==void 0||!(s||b))return;let y=!0;return O(!0),Ln(t,i).then(v=>{y&&(m(v),O(!1))}),()=>{y=!1}},[g,b]);let k=u??A,p=(k?.offers??[]).filter(y=>!(y.type==="place"&&d.some(v=>v.place===y.place))).slice(0,Math.max(0,3-d.length)),w=k?.interaction.outcome==="failed"?k.interaction.failed??"The AI could not suggest anything here.":null,T=(0,P.useRef)(!1),F=(0,P.useRef)(null);(0,P.useLayoutEffect)(()=>{k===null||!T.current||(T.current=!1,F.current?.querySelector("button")?.focus())},[k]);let q=(0,P.useRef)(!0);(0,P.useEffect)(()=>()=>{q.current=!1},[]);let[H,l]=(0,P.useState)(!1),[h,R]=(0,P.useState)(null),E=y=>{if(H)return;l(!0),R(null);let v=!1;y(()=>{v=!0,n()}).then(j=>{q.current&&(l(!1),j?R(j):v||n())},j=>{q.current&&(l(!1),R(j instanceof Error?j.message:String(j)))})},$=y=>y.interaction.outcome==="failed"?y.interaction.failed??"The AI could not do that here.":void 0;return(0,S.jsxs)("div",{ref:F,"data-testid":"inline-ai",style:{display:"grid",gap:2},children:[x&&!b?(0,S.jsx)("p",{role:"status","data-testid":"inline-ai-thinking",style:we,children:"Thinking\u2026"}):H?(0,S.jsx)("p",{role:"status","data-testid":"inline-ai-asking",style:we,children:"Asking\u2026"}):h?(0,S.jsx)("p",{role:"alert","data-testid":"inline-ai-failed",style:{...we,color:"var(--graview-warn)"},children:h}):w?(0,S.jsx)("p",{role:"status",style:we,children:w}):null,(0,S.jsxs)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[p.map(y=>(0,S.jsx)("li",{children:(0,S.jsxs)("button",{type:"button","data-menu-item":`ai-offer:${y.id}`,"data-ai-offer":y.id,"data-ai-offer-type":y.type,onClick:()=>E(v=>Hn(t,k,y,v)),style:z,children:[y.label,(0,S.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",y.type==="panel"?"a panel":y.type==="place"?"go there":y.type==="record"?"open it":"suggested"]})]})},y.id)),!s&&k===null?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-suggest","aria-disabled":b||void 0,onClick:y=>{b||(T.current=document.activeElement===y.currentTarget,C(!0))},style:z,children:b?"Thinking\u2026":"Suggest\u2026"})}):null,r?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-fill",onClick:()=>E(async y=>$(await le(t,"fill",i,"Fill in",y))),style:z,children:"Fill in with AI"})}):null,a?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-record",onClick:()=>E(async y=>$(await le(t,"record",i,"Add one",y))),style:z,children:"Add one with AI"})}):null,d.map(y=>(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":`ai-open:${y.place}`,"data-ai-existing":y.fit,onClick:()=>{n(),t.goTo.place(y.place),y.fit==="partial"&&ue(t.desk,{target:{on:"lens",place:y.place,...y.kind?{kind:y.kind}:{}}})},style:z,children:y.fit==="full"?`Open ${y.title}`:`Open and adjust ${y.title}`})},y.place)),f?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-panel",onClick:()=>E(async y=>$(await le(t,"panel",i,"Draw a panel",y))),style:z,children:d.length>0?"Draw a new view":"Draw a panel"})}):null,(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-ask",onClick:()=>{let y=document.activeElement;n(),ue(t.desk,{target:i,returnTo:y instanceof HTMLElement&&y!==document.body?y:null})},style:z,children:"Ask about this\u2026"})})]})]})}var Ae={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 10px",fontSize:"0.8125rem",borderRadius:8};function mt({placement:e="picture"}){let{store:n,principal:t,aiDesk:i}=ze(),o=We(n,t),{ghost:r,entries:f}=_e(i),[d,c]=(0,P.useState)(new Set);(0,P.useEffect)(()=>c(new Set),[r?.ghost.interaction]);let a=(0,P.useRef)(null),s=(0,P.useRef)(null),u=r?.batch;if((0,P.useEffect)(()=>{u!==void 0&&s.current?.focus()},[u]),!r)return null;let{ghost:g}=r,b=f.find(k=>k.id===g.interaction),C=()=>{let k=g.target.on==="record"||g.target.on==="field"?g.target.id:void 0,p=a.current?.closest("[data-graview-face], main")?.parentElement??document,w=(k?p.querySelector(`[data-graview-view="${CSS.escape(k)}"][tabindex]`):null)??document.querySelector("[data-graview-page-title]")??a.current?.closest("main")??document.querySelector("main");w&&!w.hasAttribute("tabindex")&&w.setAttribute("tabindex","-1"),w?.focus({preventScroll:!0}),i.setGhost(null)},A=g.proposals.filter(k=>!d.has(k.id)).map(k=>k.id),m=()=>{let k=an(o,g,{author:t,ids:A});if(!k.ok){i.setGhost({...r,refused:k.refused});return}b&&i.record(dn(b,k.accepted,k.batch)),i.setGhost({ghost:g,batch:k.batch,took:k.accepted.length,...r.onCard?{onCard:!0}:{}})},x=()=>{b&&r.batch===void 0&&i.record(ln(b)),C()},O=()=>{if(r.batch!==void 0)try{o.undo(r.batch,{author:t}),C()}catch(k){i.setGhost({...r,refused:k instanceof Error?k.message:String(k)})}};return(0,S.jsxs)("section",{ref:a,"data-testid":"ai-ghost","data-interaction":g.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:He("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,S.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:r.batch!==void 0?`Done: ${r.took===1?"one change":`${r.took} changes`}, as one.`:`Proposed by AI \xB7 ${g.basis}`}),r.batch===void 0?(0,S.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:g.proposals.map(k=>(0,S.jsx)("li",{"data-ghost-proposal":k.id,children:(0,S.jsxs)("label",{style:{display:"flex",alignItems:"baseline",gap:8,cursor:"pointer"},children:[(0,S.jsx)("input",{type:"checkbox",checked:!d.has(k.id),onChange:p=>{let w=new Set(d);p.target.checked?w.delete(k.id):w.add(k.id),c(w)}}),(0,S.jsx)("span",{style:{fontStyle:"italic",color:"var(--graview-ink)"},children:k.said}),k.confidence!==void 0?(0,S.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[Math.round(k.confidence*100),"% sure"]}):null]})},k.id))}):null,r.refused?(0,S.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-warn)"},children:r.refused}):null,(0,S.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.batch===void 0?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("button",{type:"button","data-testid":"ghost-accept",disabled:A.length===0,onClick:m,style:Ae,children:A.length===g.proposals.length?"Accept":`Accept ${A.length} of ${g.proposals.length}`}),(0,S.jsx)("button",{type:"button","data-testid":"ghost-dismiss",onClick:x,style:Ae,children:"Dismiss"})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("button",{type:"button",ref:s,"data-testid":"ghost-undo",onClick:O,style:Ae,children:"Undo"}),(0,S.jsx)("button",{type:"button","data-testid":"ghost-close",onClick:C,style:Ae,children:"Close"})]})})]})}export{Xe as a,Q as b,he as c,Ze as d,ie as e,Ie as f,Rn as g,Tn as h,it as i,ot as j,fn as k,un as l,le as m,Dn as n,Ln as o,Hn as p,yt as q,gt as r,mt as s};
|
|
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 Ge}from"./chunk.BJUUSIQY.js";import{a as Ke}from"./chunk.57YDGGJK.js";import{a as Ve}from"./chunk.VCTAFSZ5.js";import{a as Je}from"./chunk.YOUB3J3Y.js";import{a as pe}from"./chunk.DZSZUX34.js";import{c as ue}from"./chunk.KZUMXT5J.js";import{E as Oe,G as hn,J as _e,P as We,T as Ue,ba as ze}from"./chunk.CYTTZOYL.js";import{Ad as qe,Cd as Be,Ib as je,ec as De,ga as B,la as ce,oa as W,oc as fe,qc as Le,qd as He,ra as Ne,ta as G}from"./chunk.Q4MI53KK.js";import{j as ee}from"./chunk.FQLNBIQ5.js";import{b as xe}from"./chunk.AJZBJBMO.js";var kn=["search-miss","unanswered","refused","tool-invalid"];var _n=new RegExp("[\\u0000-\\u001f\\u007f-\\u009f\\u200b-\\u200f\\u2028-\\u202e\\u2066-\\u2069]","g");var K=e=>e.onBehalfOf?K(e.onBehalfOf):e.id!==void 0?`${e.kind}:${e.id}`:`${e.kind}:?`,ve=e=>e.toLowerCase().replace(/\s+/g," ").replace(/^[\s\p{P}]+|[\s\p{P}]+$/gu,"");var bn=new Set("a an and are at be by can do does for from has have how i in is it me my of on or our the their there this to was we what when where which who why will with you your".split(" "));function ne(e,n,t,i,o){let r=new Map;for(let f of e){let d=n(f);if(d===void 0)continue;let c=r.get(d)??{first:f,people:new Set,times:0,last:f};c.people.add(K(f.by)),c.times+=1,c.last=f,r.set(d,c)}return[...r.entries()].filter(([,f])=>f.people.size>=i).sort(([f,d],[c,a])=>a.people.size-d.people.size||a.times-d.times||f.localeCompare(c)).slice(0,o).map(([f,d])=>({...t(d.last,f),people:d.people.size,times:d.times}))}function wn(e,n={}){let t=Math.max(1,n.minPeople??2),i=n.most??12,o=n.reader?K(n.reader):void 0,r=e.filter(a=>!qe(a.by)&&(o===void 0||K(a.by)!==o)),f=Object.fromEntries(kn.map(a=>{let s=r.filter(u=>u.type===a);return[a,{events:s.length,people:new Set(s.map(u=>K(u.by))).size}]})),d=[],c=new Map;for(let a of r){let s=a.type==="search-miss"?a.words:a.type==="unanswered"?a.question:void 0;if(s!==void 0)for(let u of new Set(ve(s).split(/[^\p{L}\p{N}]+/u))){if(u.length<3||bn.has(u))continue;let g={...a,id:`${a.id}:${u}`};d.push(g),c.set(g,u)}}return{events:r.length,people:new Set(r.map(a=>K(a.by))).size,byType:f,searches:ne(r,a=>a.type==="search-miss"&&ve(a.words)||void 0,(a,s)=>({words:s}),t,i),questions:ne(r,a=>a.type==="unanswered"&&ve(a.question)||void 0,(a,s)=>({question:s}),t,i),words:ne(d,a=>c.get(a),(a,s)=>({word:s}),t,i),refusals:ne(r,a=>a.type==="refused"?`${a.act}|${a.code}`:void 0,a=>({act:a.act,code:a.code}),t,i),tools:ne(r,a=>a.type==="tool-invalid"?`${a.tool}|${a.act??""}`:void 0,a=>{let s=a;return{tool:s.tool,...s.act?{act:s.act}:{},...s.then?{then:s.then}:{}}},1,i)}}var Ye=e=>e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e;function An(e){let n=new Set,t=i=>{for(let o of i.toLowerCase().split(/[^\p{L}\p{N}]+/u))o.length>0&&n.add(Ye(o))};for(let i of e.kinds){let o=e.tryDefinition(i);t(i),t(G(o,i)),t(W(e,i));for(let r of[...o?.aliases??[],...Object.values(o?.fieldAliases??{}).flat()])t(r);for(let r of Object.keys(o?.fields?.shape??{}))t(r),t(B(r))}return n}function Qe(e,n,t={}){let i=wn(e,{most:8,...t}),o=An(n),r=i.searches.filter(s=>!s.words.split(/[^\p{L}\p{N}]+/u).some(u=>u.length>0&&o.has(Ye(u)))).map(s=>({words:s.words,people:s.people})),f=i.questions.map(s=>({question:s.question,people:s.people})),d=i.tools.map(s=>({tool:s.tool,...s.act?{act:s.act}:{},...s.then?{then:s.then}:{},times:s.times})),c=s=>`${s} ${s===1?"person":"people"}`;return{said:[...r.length>0?[`Searched for, found nothing, and nothing here is called it: ${r.map(s=>`\u201C${s.words}\u201D (${c(s.people)})`).join(", ")}.`]:[],...f.length>0?[`Asked and not answered: ${f.map(s=>`\u201C${s.question}\u201D (${c(s.people)})`).join(", ")}.`]:[],...d.length>0?[`Tool calls refused as invalid: ${d.map(s=>`${s.tool}${s.act?` (${s.act})`:""} ${s.times===1?"once":`${s.times} times`}${s.then?`, then worked as ${s.then}`:""}`).join("; ")}.`]:[]].join(`
|
|
2
|
+
`),unknownWords:r,questions:f,toolMistakes:d}}var Sn=e=>/^(?:aggregate|kind):([^,]+)$/.exec(e)?.[1];function Xe(e,n){let t=e.about??[];if(e.field!==void 0&&e.on!==void 0&&n(e.on))return{on:"field",id:e.on,field:e.field};let i=t.filter(n);if(i.length>1)return{on:"selection",ids:i};if(e.on!==void 0&&n(e.on))return{on:"record",id:e.on};if(i.length===1)return{on:"record",id:i[0]};let o=[e.on,...t].map(r=>r===void 0?void 0:Sn(r)).find(r=>r!==void 0);return e.place!==void 0?{on:"lens",place:e.place,...o?{kind:o}:{}}:o!==void 0?{on:"list",kind:o}:{on:"place",place:"home"}}var Q=e=>e.on==="record"||e.on==="field"?[e.id]:e.on==="selection"?e.ids:e.on==="act"&&e.id!==void 0?[e.id]:[],ye=(e,n)=>e.tryDefinition(n)?.fields?.shape??{},Y=(e,n)=>e.tryDefinition(n)?.edges??{},ge=(e,n)=>new Set(e.tryDefinition(n)?.display?.hide??[]),L=(e,n)=>ce(e.tryDefinition(n.kind),n),$e=(e,n,t)=>Ne(e.tryDefinition(n),t)||B(t),Ce=e=>typeof e=="boolean"?e?"yes":"no":String(e);function me(e,n){let t=e.kindsKeptFrom(n);return new Set(e.schema.kinds.filter(i=>!t.has(i)))}function Re(e,n,t,i){if(!e.permits(n,t).ok)return!1;if(!i)return!0;try{return e.previewAll([n],{author:t}).ops.length>0}catch{return!1}}function he(e,n,t){let i=e,{principal:o}=t,r=t.each??8,f=ee(i)?.store??i,d=f.seenBy(o),c=f.schema,a=me(f,o),s=l=>{let h=d.graph.getNode(l);return h&&a.has(h.kind)?h:void 0},u=f.allMutations(),g=new Map(u.map(l=>[l.name,l])),b=[],C=new Set,A=l=>{C.has(l.id)||(C.add(l.id),b.push(l))},m=l=>l.slice(0,r),x=Q(n).filter(l=>s(l)!==void 0);if(Q(n).length>0&&x.length===0)return{target:n,candidates:[]};let O=x.length===1?s(x[0]):void 0,k=O?.kind??(n.on==="list"?n.kind:n.on==="lens"?n.kind??t.places?.find(l=>l.as===n.place)?.kind:void 0)??(n.on==="selection"?s(x[0])?.kind:void 0);if(k!==void 0&&!a.has(k))return{target:n,candidates:[]};let p=(l,h)=>`act:${l}${Object.keys(h).length>0?`:${Object.values(h).map(R=>String(R)).join(",")}`:""}`,w=(l,h,R,E,$)=>{l.destructive||Object.values(h).some(y=>typeof y=="string"&&f.graph.has(y)&&s(y)===void 0)||Re(f,{name:l.name,args:{...h}},o,E.length===0)&&A({type:"act",id:p(l.name,h),label:R,description:$??l.description??R,mutation:l.name,args:h,asks:E})};if(n.on!=="place"||t.acts)if(t.acts)for(let l of t.acts){let h=g.get(l.mutation);!h||l.destructive||n.on==="act"&&l.mutation!==n.act||w(h,l.args,l.label,(l.open??[]).filter(R=>!R.optional).map(R=>R.name),l.why)}else{let l=O?[O]:[];for(let h of u){if(n.on==="act"&&h.name!==n.act)continue;let R=h.input.shape??{},E=$=>Object.entries(R).filter(([y,v])=>y!==$&&v.safeParse?.(void 0).success===!1).map(([y])=>y);if(h.subject)for(let $ of l)fe(c,h).includes($.kind)&&w(h,{[h.subject.arg]:$.id},`${h.title??B(h.name)}: ${L(c,$)}`,E(h.subject.arg));else k!==void 0&&(h.creates??[]).includes(k)&&w(h,{},h.title??B(h.name),E(void 0))}}let T=b.filter(l=>l.type==="act");b.splice(0,b.length,...m(T));let F=(l,h)=>{let R=Le(c,u).get(l.kind),E=ye(c,l.kind),$=ge(c,l.kind),y=[];for(let[v,D]of Object.entries(E)){if(h!==void 0?v!==h:$.has(v)||l[v]!==void 0)continue;let j=pe(D),J=j?.type==="enum"&&!j.multiple?j.options??[]:j?.type==="boolean"?[!0,!1]:[];if(J.length===0)continue;let _=(R?.get(v)??[]).map(N=>g.get(N)).find(N=>N?.subject!==void 0&&Re(f,{name:N.name,args:{[N.subject.arg]:l.id,[v]:J.find(Se=>Se!==l[v])??J[0]}},o,!0));if(_?.subject)for(let N of J)l[v]!==N&&y.push({type:"fill",id:`fill:${l.id}:${v}:${Ce(N)}`,label:`${$e(c,l.kind,v)}: ${Ce(N)}`,description:`Set ${$e(c,l.kind,v).toLowerCase()} of ${L(c,l)} to ${Ce(N)}`,record:l.id,field:v,value:N,call:{name:_.name,args:{[_.subject.arg]:l.id,[v]:N}}})}for(let[v,D]of Object.entries(Y(c,l.kind))){if(h!==void 0&&v!==h)continue;let j=D.to==="*"?[...a]:D.to.filter(I=>a.has(I)),J=new Set(d.graph.out(l.id,v).map(I=>I.id)),_=u.find(I=>(I.connects??[]).includes(v)&&I.subject!==void 0&&fe(c,I).includes(l.kind));if(!_?.subject)continue;let N=De(_.input).find(I=>I.name!==_.subject.arg);if(!N)continue;let Se=j.flatMap(I=>N.kinds.length===0||N.kinds.includes(I)?d.graph.nodesOfKind(I):[]).filter(I=>I.id!==l.id&&!J.has(I.id)&&s(I.id)!==void 0);for(let I of m(Se)){let Me={name:_.name,args:{[_.subject.arg]:l.id,[N.name]:I.id}};Re(f,Me,o,!0)&&y.push({type:"fill",id:`fill:${l.id}:${v}:${I.id}`,label:`${B(v)}: ${L(c,I)}`,description:`Link ${L(c,l)} to ${L(c,I)}${D.description?` as ${D.description}`:""}`,record:l.id,field:v,value:I.id,call:Me})}}return y};if(n.on==="field"&&O)for(let l of F(O,n.field))A(l);else if(O&&n.on==="record")for(let l of m(F(O)))A(l);let q=l=>{let h=W(c,l).toLowerCase(),R=[{type:"panel",id:`panel:${l}:list`,label:`A list of ${h}`,description:`Every ${G(c.tryDefinition(l),l).toLowerCase()} this viewer may see, as a list`,panel:{lens:"blocks",kind:l}}],E=ge(c,l);for(let[$,y]of Object.entries(ye(c,l))){if(E.has($))continue;let v=pe(y),D=$e(c,l,$).toLowerCase();if(v?.type==="enum")R.push({type:"panel",id:`panel:${l}:group:${$}`,label:`${V(h)} by ${D}`,description:`A list of ${h} grouped by ${D}`,panel:{lens:"blocks",kind:l,group:$}}),R.push({type:"panel",id:`panel:${l}:columns:${$}`,label:`Columns of ${h} by ${D}`,description:`${V(h)} in a column for each ${D}`,panel:{lens:"columns",kind:l,column:$}});else if(v?.type==="number"||v?.type==="integer"||v?.type==="date"||v?.type==="datetime"){let j=v.type==="date"||v.type==="datetime";R.push({type:"panel",id:`panel:${l}:sort:${$}`,label:`${V(h)} by ${D}`,description:`A list of ${h}, the ${j?"latest":"highest"} ${D} first`,panel:{lens:"blocks",kind:l,sort:{by:$,direction:"desc"}}}),j&&R.push({type:"panel",id:`panel:${l}:calendar:${$}`,label:`A calendar of ${h}`,description:`${V(h)} on a calendar by ${D}`,panel:{lens:"calendar",kind:l,start:$}})}}return R},H=n.on==="place"?[...a]:k!==void 0?[k]:[];for(let l of H)for(let h of m(q(l)))A(h);for(let l of m((t.places??[]).filter(h=>h.kind===void 0?n.on==="place":a.has(h.kind)&&(n.on==="place"||h.kind===k))))n.on==="lens"&&l.as===n.place||A({type:"place",id:`place:${l.as}`,label:l.title,description:`Go to ${l.title}`,place:l.as});if(O){let l=[];for(let[h,R]of Object.entries(Y(c,O.kind)))for(let E of d.graph.out(O.id,h))s(E.id)&&l.push({type:"record",id:`record:${E.id}`,label:L(c,E),description:`${V(R.description??B(h))}: ${L(c,E)}`,record:E.id,relation:h});for(let h of c.kinds)for(let[R,E]of Object.entries(Y(c,h)))if(!(E.to!=="*"&&!E.to.includes(O.kind)))for(let $ of d.graph.in(O.id,R))$.kind===h&&s($.id)&&l.push({type:"record",id:`record:${$.id}`,label:L(c,$),description:`${V(E.inverse??B(R))}: ${L(c,$)}`,record:$.id,relation:R});for(let h of m(l))A(h)}else if(n.on==="list"||n.on==="lens")for(let l of m(k!==void 0?d.graph.nodesOfKind(k):[]))s(l.id)&&A({type:"record",id:`record:${l.id}`,label:L(c,l),description:`Open ${L(c,l)}`,record:l.id});else if(n.on==="selection")for(let l of x){let h=s(l);A({type:"record",id:`record:${l}`,label:L(c,h),description:`Open ${L(c,h)}`,record:l})}return{target:n,candidates:b}}var V=e=>e&&`${e[0].toUpperCase()}${e.slice(1)}`,xn={columns:["board","kanban","column","lane","pipeline","stage","funnel"],board:["board","map","floor","layout","seat","slot"],calendar:["calendar","schedule","date","due","month","week","agenda","deadline","day"],timeline:["timeline","gantt","schedule","roadmap","span"],coverage:["coverage","matrix","grid","gap"],plan:["plan","floor","map","region","area"],blocks:["list","table","summary","overview","dashboard","card"]},On=new Set(["a","an","the","of","for","my","our","me","us","to","with","and","in","on","by","that","which","i","we","want","need","show","open","go","draw","make","new","view","views","panel","panels","page","lens","please","all","every","some","see","can","could","would","like","one","what","is","are","do","does","here","there","how","it","this","these","those"]),te=e=>e.length>3&&e.endsWith("ies")?`${e.slice(0,-3)}y`:e.length>3&&e.endsWith("s")&&!e.endsWith("ss")?e.slice(0,-1):e,Te=e=>e.toLowerCase().normalize("NFKD").replace(/[̀-ͯ]/g,"").split(/[^a-z0-9]+/).filter(Boolean);function Ze(e,n,t){let i=e,o=ee(i)?.store??i,r=o.schema,f=me(o,t.principal),d=o.seenBy(t.principal),c=Q(n),a=new Set;for(let p of c){let w=d.graph.getNode(p)?.kind;w!==void 0&&f.has(w)&&a.add(w)}if(c.length>0&&a.size===0)return[];if(n.on==="list"&&a.add(n.kind),n.on==="lens"){let p=n.kind??t.places.find(w=>w.as===n.place)?.kind;p!==void 0&&a.add(p)}let s=new Map;for(let p of r.kinds){if(!f.has(p))continue;let w=r.tryDefinition(p);for(let T of[p,G(w,p),W(r,p)])for(let F of Te(T))s.set(te(F),p)}let u=Te(t.said??"").filter(p=>!On.has(p)),g=new Set,b=[];for(let p of u){let w=s.get(te(p));w!==void 0?g.add(w):b.push(te(p))}let C=g.size>0?g:a;if((t.said??"").trim()!==""&&u.length===0)return[];if(C.size===0&&u.length===0)return[];let A=[];t.places.forEach((p,w)=>{if(p.hidden||n.on==="lens"&&p.as===n.place)return;let T=p.over??(p.kind!==void 0?[p.kind]:[]);if(T.length>0&&!T.some(H=>f.has(H)))return;let F=T.some(H=>C.has(H)),q=!F&&(p.reads??[]).some(H=>C.has(H));C.size>0&&!F&&!q||A.push({place:p,own:F,reads:q,at:w})});let m=p=>new Set(Te(p.title).map(te)),x=new Set(b.filter(p=>A.some(({place:w})=>m(w).has(p)))),O=[];for(let{place:p,own:w,reads:T,at:F}of A){let q=m(p),H=new Set((xn[p.lens??""]??[]).map(te)),l=b.filter($=>q.has($)||H.has($)&&!x.has($)).length,h=b.length-l;if(b.length>0&&l===0)continue;let R=!T&&h===0?"full":"partial",E=(w?4:T?2:1)+l*2-h+(R==="full"?1:0);O.push({view:{place:p.as,title:p.title,...p.kind!==void 0?{kind:p.kind}:{},fit:R},score:E,at:F})}return O.filter((p,w)=>!O.slice(0,w).some(T=>T.view.place===p.view.place&&T.view.title===p.view.title)).sort((p,w)=>w.score-p.score||p.at-w.at).slice(0,t.most??3).map(p=>p.view)}var Ee=new WeakMap;function vn(e){let n=2166136261;for(let t=0;t<e.length;t++)n^=e.charCodeAt(t),n=Math.imul(n,16777619)>>>0;return n.toString(36)}function $n(e,n){let t=e,i=ee(t)?.store??t,o=i.schema,r=me(i,n),d=i.allMutations().filter(A=>!A.destructive&&i.permits({name:A.name,args:{}},n).ok!==!1),c=`${[...r].join(",")}|${d.map(A=>A.name).join(",")}`,a=Ee.get(o)?.get(c);if(a)return a;let s=[...r].map(A=>{let m=ge(o,A),x={};for(let[w,T]of Object.entries(ye(o,A))){if(m.has(w))continue;let F=pe(T);F&&(x[w]=F.type==="enum"?`enum:${(F.options??[]).join("|")}`:F.type)}let O={};for(let[w,T]of Object.entries(Y(o,A)))O[w]=T.to==="*"?[...r]:T.to.filter(F=>r.has(F));let k=o.tryDefinition(A),p=Object.entries(k?.fieldAliases??{}).filter(([w,T])=>w in x&&T.length>0);return{kind:A,noun:G(o.tryDefinition(A),A),plural:W(o,A),fields:x,relations:O,...k?.aliases&&k.aliases.length>0?{aliases:k.aliases}:{},...p.length>0?{fieldAliases:Object.fromEntries(p)}:{}}}),u=d.map(A=>({name:A.name,title:A.title??B(A.name),...A.subject?{on:fe(o,A).filter(m=>r.has(m))}:{}})),g={kinds:s,acts:u},b={version:vn(JSON.stringify(g)),...g},C=Ee.get(o)??new Map;return C.set(c,b),Ee.set(o,C),b}var Cn=e=>e.name??e.id??e.kind;function en(e,n,t){let i=e,{principal:o}=t,r=ee(i)?.store??i,f=r.seenBy(o),d=r.schema,c=me(r,o),a=p=>{let w=f.graph.getNode(p);return w&&c.has(w.kind)?w:void 0},s=p=>({id:p.id,kind:p.kind,label:L(d,p)}),u=Q(n),g=u.length===1?a(u[0]):void 0,b=g?Object.fromEntries(Object.keys(ye(d,g.kind)).filter(p=>!ge(d,g.kind).has(p)&&g[p]!==void 0&&p!=="label").map(p=>[p,g[p]])):{},C={on:n.on,...g?{record:{...s(g),fields:b}}:{},...n.on==="field"&&g?{field:n.field}:{},...n.on==="list"&&c.has(n.kind)?{kind:n.kind}:{},...n.on==="lens"?{place:n.place,...n.kind&&c.has(n.kind)?{kind:n.kind}:{}}:{},...n.on==="place"?{place:n.place}:{},...n.on==="act"?{act:n.act}:{}},A=[...new Set([...n.on==="selection"?n.ids:[],...t.selection??[]])].flatMap(p=>{let w=a(p);return w?[s(w)]:[]}),m=[];if(g){for(let p of Object.keys(Y(d,g.kind)))for(let w of f.graph.out(g.id,p))a(w.id)&&m.push({...s(w),relation:p,direction:"out"});for(let p of d.kinds)for(let w of Object.keys(Y(d,p)))for(let T of f.graph.in(g.id,w))T.kind===p&&a(T.id)&&m.push({...s(T),relation:w,direction:"in"})}let x=f.batches().filter(p=>!p.ops.every(je)).slice(-(t.recent??6)).reverse().map(p=>({intent:p.intent,at:p.at,by:Cn(p.author)})),O=(t.purpose?.jobs??[]).filter(p=>Ge(p,o.roles)&&c.has(p.kind)).map(p=>({name:p.name,ask:p.ask,kind:p.kind})),k=t.purpose&&(t.purpose.for!==void 0||O.length>0)?{...t.purpose.for!==void 0?{for:t.purpose.for}:{},jobs:O}:void 0;return{...t.place!==void 0?{place:t.place}:{},target:C,selection:A,neighbors:m.slice(0,24),recent:x,schema:$n(r,o),...k?{purpose:k}:{},...t.friction?{friction:Qe(t.friction,d,{reader:o})}:{}}}function ie(e){if(!e.off)return e.fast??(e.decide?{model:e.name??"decide",decide:e.decide}:void 0)}function U(e){if(e.off)return;if(e.thinking)return e.thinking;let n=e.name??"model";if(e.complete){let t=e.complete;return{model:n,think:({system:i,prompt:o})=>t({prompt:o,system:i})}}if(e.turn){let t=e.turn;return{model:n,think:async({system:i,prompt:o})=>({text:await t({system:i,messages:[{role:"user",content:o}],tools:[],call:async()=>({error:"No tools here."})})})}}}var Pe=(e,n,t)=>e?n/1e6*(e.inputPerMillion??0)+t/1e6*(e.outputPerMillion??0):void 0,Ie=()=>`ai-${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`;function Rn(e,n,t=[]){let i=o=>{let r=e.graph.getNode(o);return r?ce(e.schema.tryDefinition(r.kind),r):"a record"};switch(n.on){case"record":return i(n.id);case"field":return`${i(n.id)} \xB7 ${n.field}`;case"selection":return`${n.ids.length} records`;case"list":return e.schema.tryDefinition(n.kind)?W(e.schema,n.kind):n.kind;case"lens":case"place":return t.find(o=>o.as===n.place)?.title??(n.place==="home"?"Home":n.place);case"act":return n.act}}var nn=e=>e.type!=="act"||e.asks.length===0,be=(e,n)=>({id:e.id,type:e.type,label:e.label,...n!==void 0?{confidence:n}:{}});function X(e,n){let t=n.interaction??Ie(),i=he(n.store,n.target,{principal:n.principal,...n.acts?{acts:n.acts}:{},...n.places?{places:n.places}:{}}),o=en(n.store,n.target,{principal:n.principal,...n.place?{place:n.place}:{},...n.selection?{selection:n.selection}:{},...n.purpose?{purpose:n.purpose}:{}}),r=[];return{id:t,catalog:i,state:o,entry:{id:t,at:new Date().toISOString(),by:n.by??n.principal,target:n.target,targetLabel:Rn(n.store,n.target,n.places)},usage:r,meter:f=>{r.push(f),e.meter?.({...f,interaction:t})}}}async function oe(e,n,t,i){let o=await e.decide(n,t),{inputTokens:r,outputTokens:f}=o.usage,d=Pe(e.price,r,f);return i({tier:"fast",model:e.model,inputTokens:r,outputTokens:f,...d!==void 0?{costUsd:d}:{}}),o.answers}async function re(e,n,t,i,o){let r=await e.think({system:n,prompt:t,state:i.state,catalog:i.catalog}),f=r.usage?.inputTokens,d=r.usage?.outputTokens,c=r.usage?.costUsd??(f!==void 0?Pe(e.price,f,d??0):void 0);return o({tier:"thinking",model:e.model,...f!==void 0?{inputTokens:f}:{},...d!==void 0?{outputTokens:d}:{},...c!==void 0?{costUsd:c}:{}}),Ve(r.text)}function se(e,n){let t=new Map(e.map((i,o)=>[`c${o+1}`,i]));return{question:{type:"choice",instructions:n,criteria:Object.fromEntries([...t].map(([i,o])=>[i,`${o.label} \u2014 ${o.description}`]))},of:i=>t.get(i)}}function ae(e,n,t){if(e?.type!=="choice")return[];let i=e,o=Object.entries(i.probabilities).sort((r,f)=>f[1]-r[1]);return o.some(([r])=>r===i.choice)||o.unshift([i.choice,i.confidence]),o.flatMap(([r,f])=>{let d=n(r);return d?[{candidate:d,confidence:f}]:[]}).slice(0,t)}var M=(e,n,t,i)=>({interaction:{...e.entry,ask:{kind:t,said:n??""},offered:[],outcome:"failed",failed:i,usage:[...e.usage]},offers:[]}),Z="AI isn't on here.";async function tn(e,n,t=3){let i=X(e,n),o=n.said??"Suggest",r=i.catalog.candidates.filter(nn).slice(0,24);if(r.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let f=ie(e),d=U(e),c=[];try{if(f){let{question:a,of:s}=se(r,"Which of these would the person most likely want to do next, here?"),u=await oe(f,{...i.state,candidates:r.map(g=>({id:g.id,type:g.type,says:g.description}))},{next:a},i.meter);c=ae(u.next,s,t)}else if(d){let a=await re(d,'You suggest what a person most likely wants to do next in an app. Answer only JSON: {"pick": [candidate ids, best first]}. Pick only ids from the candidates.',JSON.stringify({state:i.state,candidates:r.map(u=>({id:u.id,says:u.description}))}),i,i.meter);c=(Array.isArray(a?.pick)?a.pick.filter(u=>typeof u=="string"):[]).flatMap(u=>r.filter(g=>g.id===u)).slice(0,t).map(u=>({candidate:u}))}else return M(i,o,"suggest",Z)}catch(a){return M(i,o,"suggest",a instanceof Error?a.message:String(a))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:c.map(({candidate:a,confidence:s})=>be(a,s)),outcome:"offered",usage:[...i.usage]},offers:c.map(({candidate:a})=>a)}}var Tn=e=>`several:${e}`;async function it(e,n,t=2){let i=X(e,{...n,acts:[]}),o=n.said??"Suggest for the chosen",r=n.target.on==="selection"?n.target.ids.length:1,d=[...n.shared.map(s=>({type:"act",id:Tn(s.id),label:s.label,description:`${s.label}, for all ${r} chosen`,mutation:s.mutation,args:s.args,asks:[]})),...i.catalog.candidates.filter(s=>s.type==="panel"||s.type==="place")].slice(0,24),c=ie(e);if(!c)return M(i,o,"suggest",Z);if(d.length===0)return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:[],outcome:"offered",usage:[]},offers:[]};let a;try{let{question:s,of:u}=se(d,`Which of these would the person most likely want to do next with the ${r} records they chose together?`),g=await oe(c,{...i.state,candidates:d.map(b=>({id:b.id,type:b.type,says:b.description}))},{next:s},i.meter);a=ae(g.next,u,t).filter((b,C)=>C===0||b.confidence>=En)}catch(s){return M(i,o,"suggest",s instanceof Error?s.message:String(s))}return{interaction:{...i.entry,ask:{kind:"suggest",said:o},offered:a.map(({candidate:s,confidence:u})=>be(s,u)),outcome:"offered",usage:[...i.usage]},offers:a.map(({candidate:s})=>s)}}var En=.25;async function on(e,n){let t=X(e,n),i=n.said??"Fill in",o=t.catalog.candidates.filter(u=>u.type==="fill"),r=new Map;for(let u of o)r.set(u.field,[...r.get(u.field)??[],u]);if(r.size===0)return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:[],outcome:"offered",usage:[]},offers:[]};let f=ie(e),d=U(e),c=[];try{if(f){let u=[...r].map(([b,C],A)=>({key:`f${A+1}`,field:b,...se(C,`Which value fits "${b}" best for this record?`)})),g=await oe(f,t.state,Object.fromEntries(u.map(b=>[b.key,b.question])),t.meter);for(let b of u){let C=!Pn(n.store,n.target,b.field)&&In(n.store,n.target,b.field)!=="one";c.push(...ae(g[b.key],b.of,C?3:1).filter((A,m)=>m===0||A.confidence>=.4))}}else if(d){let u=await re(d,`You fill in a record's fields in an app. Answer only JSON: {"fills": [candidate ids]}, at most one per field, only ids from the candidates.`,JSON.stringify({state:t.state,candidates:o.map(C=>({id:C.id,says:C.description}))}),t,t.meter),g=Array.isArray(u?.fills)?u.fills.filter(C=>typeof C=="string"):[],b=new Set;for(let C of g){let A=o.find(m=>m.id===C);A?.type==="fill"&&!b.has(A.field)&&(b.add(A.field),c.push({candidate:A}))}}else return M(t,i,"fill",Z)}catch(u){return M(t,i,"fill",u instanceof Error?u.message:String(u))}let a=t.usage.at(-1)?.model,s=de(n.store,{interaction:t.id,target:n.target,basis:i,...a?{model:a}:{},proposals:c.flatMap(({candidate:u,confidence:g})=>u.type==="fill"?[{id:u.id,label:u.label,said:u.description,call:u.call,record:u.record,field:u.field,...g!==void 0?{confidence:g}:{}}]:[])},n.principal);return{interaction:{...t.entry,ask:{kind:"fill",said:i},offered:s.proposals.map(u=>({id:u.id,type:"fill",label:u.label,...u.confidence!==void 0?{confidence:u.confidence}:{}})),outcome:"offered",usage:[...t.usage]},offers:[],...s.proposals.length>0?{ghost:s}:{}}}function Pn(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0,r=(o?e.schema.tryDefinition(o)?.fields?.shape:void 0)??{};return t in r}function In(e,n,t){let i=n.on==="record"||n.on==="field"?n.id:void 0,o=i?e.graph.getNode(i)?.kind:void 0;return o?e.schema.tryDefinition(o)?.edges?.[t]?.cardinality:void 0}async function rn(e,n){let t=X(e,n),i=n.said??"Add one",o=new Set(n.store.allMutations().filter(s=>(s.creates??[]).length>0).map(s=>s.name)),r=t.catalog.candidates.filter(s=>s.type==="act"&&s.asks.length>0&&o.has(s.mutation));if(r.length===0)return M(t,i,"record","Nothing here makes a record.");let f=U(e);if(!f)return M(t,i,"record",Z);let d;try{let s=await re(f,'You propose one new record for an app by filling in an act. Answer only JSON: {"act": a candidate id, "args": {argument: value}}. Use only the candidates, and fill every argument the act asks for with a value that fits the state.',JSON.stringify({ask:i,state:t.state,candidates:r.map(b=>({id:b.id,says:b.description,asks:b.asks}))}),t,t.meter),u=r.find(b=>b.id===s?.act),g=typeof s?.args=="object"&&s.args!==null?s.args:{};u&&(d={act:u,args:Object.fromEntries(Object.entries(g).filter(([b])=>u.asks.includes(b)))})}catch(s){return M(t,i,"record",s instanceof Error?s.message:String(s))}if(!d)return M(t,i,"record","The model named no act this app has here.");let c=t.usage.at(-1)?.model,a=de(n.store,{interaction:t.id,target:n.target,basis:i,...c?{model:c}:{},proposals:[{id:d.act.id,label:d.act.label,said:d.act.description,call:{name:d.act.mutation,args:{...d.act.args,...d.args}}}]},n.principal);return a.proposals.length===0?M(t,i,"record","What the model proposed could not be made here."):{interaction:{...t.entry,ask:{kind:"record",said:i},offered:a.proposals.map(s=>({id:s.id,type:"act",label:s.said})),outcome:"offered",usage:[...t.usage]},offers:[d.act],ghost:a}}async function sn(e,n){let t=X(e,n),i=n.said??"Make a panel",o=t.catalog.candidates.filter(s=>s.type==="panel");if(o.length===0)return M(t,i,"panel","Nothing here can be drawn as a panel.");let r=ie(e),f=U(e),d;try{if(f){let s=await re(f,'You choose a panel to draw in an app. Answer only JSON: {"panel": a candidate id, "title": a short title}. Choose only among the candidates.',JSON.stringify({ask:i,state:t.state,candidates:o.map(g=>({id:g.id,says:g.description}))}),t,t.meter),u=o.find(g=>g.id===s?.panel);u&&(d={panel:u,...typeof s?.title=="string"&&s.title.trim()?{title:s.title.trim().slice(0,60)}:{}})}else if(r){let{question:s,of:u}=se(o,`Which panel answers this best: ${i}`),g=ae((await oe(r,t.state,{panel:s},t.meter)).panel,u,1)[0];g?.candidate.type==="panel"&&(d={panel:g.candidate,confidence:g.confidence})}else return M(t,i,"panel",Z)}catch(s){return M(t,i,"panel",s instanceof Error?s.message:String(s))}if(!d)return M(t,i,"panel","The model named no panel this app can draw.");let c=d.title??d.panel.label,a={title:c,recipe:{...d.panel.panel,title:c}};return{interaction:{...t.entry,ask:{kind:"panel",said:i},offered:[be(d.panel,d.confidence)],outcome:"drawn",panel:a,usage:[...t.usage]},offers:[d.panel],panel:a}}function Fn(e){return e.off?void 0:e.answer}var Mn=`You answer a person's question about what they are looking at in an app, from the state given and nothing else. Answer only JSON: {"answer": one to three short sentences, "pick": [candidate ids that act on the answer, best first, at most three]}. Pick only ids from the candidates, and none when nothing fits. Never say an id to the person.`;async function ot(e,n){let t=X(e,n),i=n.said.trim(),o=t.catalog.candidates.filter(m=>nn(m)||m.type==="panel"||m.type==="place"||m.type==="record").slice(0,32),r=Fn(e),f=U(e),d=ie(e),c="",a=[],s=m=>m.flatMap(x=>o.filter(O=>O.id===x)).slice(0,3).map(x=>({candidate:x}));try{if(r){let m=await r.answer({said:i,target:n.target,targetLabel:t.entry.targetLabel,state:t.state,catalog:{target:t.catalog.target,candidates:o},...n.follows?{follows:n.follows}:{}}),x=m.usage?.inputTokens,O=m.usage?.outputTokens,k=m.usage?.costUsd??(x!==void 0?Pe(r.price,x,O??0):void 0);t.meter({tier:"thinking",model:r.model,...x!==void 0?{inputTokens:x}:{},...O!==void 0?{outputTokens:O}:{},...k!==void 0?{costUsd:k}:{}}),c=typeof m.text=="string"?m.text.trim():"",a=s(m.pick??[])}else if(f){let m=await re(f,Mn,JSON.stringify({ask:i,about:t.entry.targetLabel,...n.follows?{follows:n.follows}:{},state:t.state,candidates:o.map(x=>({id:x.id,says:x.description}))}),t,t.meter);c=typeof m?.answer=="string"?m.answer.trim():"",a=s(Array.isArray(m?.pick)?m.pick:[])}else if(d&&o.length>0){let{question:m,of:x}=se(o,`Which of these best answers, or acts on: ${i}`),O=await oe(d,{...t.state,asked:i,candidates:o.map(k=>({id:k.id,type:k.type,says:k.description}))},{answer:m},t.meter);a=ae(O.answer,x,3),c=a.length>0?`These fit \u201C${i}\u201D.`:""}else return M(t,i,"ask",Z)}catch(m){return M(t,i,"ask",m instanceof Error?m.message:String(m))}if(!c&&a.length===0){let m=n.target.on==="place"||n.target.on==="lens"?n.target.place:void 0,x=n.target.on==="list"||n.target.on==="lens"?n.target.kind:void 0;return Be(n.store,{type:"unanswered",question:i,...m?{place:m}:{},...x?{kind:x}:{}},n.principal),M(t,i,"ask","The AI had no answer to that here.")}let u=t.usage.at(-1)?.model,g=a.flatMap(({candidate:m,confidence:x})=>{let O=ke(m);return O?[{...O,...x!==void 0?{confidence:x}:{}}]:[]}),b=g.length>0?de(n.store,{interaction:t.id,target:n.target,basis:i,...u?{model:u}:{},proposals:g},n.principal):void 0,C=a.map(({candidate:m})=>m).filter(m=>ke(m)===void 0),A=[...C.map(m=>be(m,a.find(x=>x.candidate===m)?.confidence)),...(b?.proposals??[]).map(m=>({id:m.id,type:m.field!==void 0?"fill":"act",label:m.label,...m.confidence!==void 0?{confidence:m.confidence}:{}}))];return{interaction:{...t.entry,ask:{kind:"ask",said:i},offered:A,outcome:"offered",...c?{answer:c}:{},usage:[...t.usage]},offers:C,...b&&b.proposals.length>0?{ghost:b}:{},...c?{answer:c}:{}}}function de(e,n,t){let i=n.proposals.flatMap(o=>{try{let r=e.previewAll([o.call],{author:t}),f=r.ops.map(d=>d.intent).join("; ");return r.ops.length>0?[{...o,said:f||o.said}]:[]}catch{return[]}});return{...n,proposals:i}}function ke(e){if(e.type==="fill")return{id:e.id,label:e.label,said:e.description,call:e.call,record:e.record,field:e.field};if(e.type==="act"&&e.asks.length===0)return{id:e.id,label:e.label,said:e.description,call:{name:e.mutation,args:{...e.args}}}}function an(e,n,t){let i=n.proposals.filter(r=>t.ids===void 0||t.ids.includes(r.id));if(i.length===0)return{ok:!1,refused:"Nothing was chosen."};let o=i.flatMap(r=>r.confidence===void 0?[]:[r.confidence]);try{let f=e.applyAll(i.map(d=>d.call),{author:t.author,via:`ai:${n.interaction}`,intent:n.basis,lineage:{basis:`Asked \u201C${n.basis}\u201D`,...n.model?{model:n.model}:{},...o.length>0?{confidence:Math.min(...o)}:{},interaction:n.interaction}}).ops[0]?.batch;return f?{ok:!0,batch:f,accepted:i.map(d=>d.id)}:{ok:!1,refused:"That changes nothing now."}}catch(r){return{ok:!1,refused:r instanceof Error?r.message:String(r)}}}function dn(e,n,t){let i=e.ask.kind==="suggest"?n.length>0:e.offered.length>0&&e.offered.every(o=>n.includes(o.id));return{...e,outcome:i?"accepted":"partly",accepted:n,batches:[...e.batches??[],t]}}var ln=e=>({...e,outcome:"dismissed"});var P=xe(hn(),1);var S=xe(Ue(),1);function fn(e,n,t){let i=n.on==="selection"?n.ids:n.on==="record"||n.on==="field"?[n.id]:[],o=i.length>0?Ke(e.store,i,{principal:e.principal,...i.length===1?{focus:i[0]}:{}}).affordances.map(r=>({mutation:r.mutation,label:r.label,args:r.args,open:r.open,why:r.why,...r.destructive?{destructive:!0}:{}})):void 0;return{store:e.store,target:n,principal:e.principal,interaction:Ie(),places:e.places,selection:e.selection,...o?{acts:o}:{},...e.place?{place:e.place}:{},...t?{said:t}:{},...e.app.purpose?{purpose:e.app.purpose}:{}}}async function un(e,n,t){let i=await (__graviewPreload(import.meta.url,["./chunk.FXCQJPN4.js","./chunk.G4JJXA63.js","./chunk.BIDL7GQD.js","./chunk.QS32TO4N.js","./chunk.JVDPRQ7J.js","./chunk.VCTAFSZ5.js","./chunk.XOZU4OFA.js","./chunk.4TH3CGAZ.js","./chunk.Q5WEOX3Q.js","./chunk.MAHNJO6U.js","./chunk.75GENXGP.js","./chunk.NIAM7OTV.js","./chunk.WVUJXDXZ.js","./chunk.XYGNS637.js","./chunk.DZSZUX34.js","./chunk.4EXC26LI.js","./chunk.PWAP2GJS.js","./chunk.AHPYNDVA.js","./chunk.FNVGNISQ.js","./chunk.REUMBCSV.js","./chunk.2KIWGQXC.js","./chunk.D5LOTCBU.js","./chunk.Q4MI53KK.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.47QEWSSE.js")),o=i.recipeDraft(n.recipe,{app:e.app,sight:i.draftSight(e.app,e.principal)});if(i.isDraftFailure(o))return o.failed;t?.(),e.seatTalk.setDraft(o,null),e.goTo.draft?.(),pn()}function pn(e=180){if(typeof document>"u")return;let n=document.querySelector('[data-testid="draft-keep"]'),t=document.activeElement,i=!t||t===document.body||t.closest?.("[inert]")!==null;if(n){i&&n.focus();return}e>0&&requestAnimationFrame(()=>pn(e-1))}async function le(e,n,t,i,o){let r=fn(e,t,i),f=n==="suggest"?await tn(e.ai,r):n==="fill"?await on(e.ai,r):n==="record"?await rn(e.ai,r):await sn(e.ai,r);if(f.interaction.outcome==="failed")return n!=="suggest"&&e.desk.record(f.interaction),f;let d=c=>{let a={...f.interaction,outcome:"failed",failed:c};return e.desk.record(a),{...f,interaction:a}};if(n==="fill"||n==="record"){if(!f.ghost||f.ghost.proposals.length===0)return d("Nothing here could be filled in.");o?.(),e.desk.setGhost({ghost:f.ghost}),e.desk.record(f.interaction)}if(n==="panel"&&f.panel){let c=await un(e,f.panel,o);if(c)return d(c);e.desk.record(f.interaction)}return f}var Fe=new WeakMap,Nn=64,cn=new WeakMap;function jn(e){let n=cn.get(e);if(!n){let t=n={n:0};cn.set(e,t),e.subscribe(()=>void(t.n+=1))}return n.n}var yn=(e,n)=>{let t=Q(n);return t.length>0?t.map(i=>e.graph.getNode(i)):[jn(e)]},gn=(e,n,t)=>JSON.stringify({target:n,seat:e.principal,by:t}),mn=(e,n,t)=>{let i=yn(e.store,n);return t.schema===e.store.schema&&t.ai===e.ai&&i.length===t.depends.length&&i.every((o,r)=>o===t.depends[r])};function Dn(e,n,t="menu"){let i=Fe.get(e.store)?.get(gn(e,n,t));return i?.result!==void 0&&mn(e,n,i)?i.result:void 0}function Ln(e,n,t){let i=Fe.get(e.store);i||Fe.set(e.store,i=new Map);let o=gn(e,n,t?.by??"menu"),r=i.get(o);if(r&&mn(e,n,r))return r.result?Promise.resolve(r.result):r.asked;let f=t?t.ask():le(e,"suggest",n),d={schema:e.store.schema,ai:e.ai,depends:yn(e.store,n),asked:f};i.delete(o),i.set(o,d),i.size>Nn&&i.delete(i.keys().next().value);let c=i;return f.then(a=>{a.interaction.outcome!=="failed"?d.result=a:c.get(o)===d&&c.delete(o)}),f}async function Hn(e,n,t,i){let o=n.interaction,r=ke(t);if(r){let f=o.usage?.at(-1)?.model,d=o.offered.find(a=>a.id===t.id)?.confidence,c=de(e.store,{interaction:o.id,target:o.target,basis:`${o.ask.said}: ${t.label}`,...f?{model:f}:{},proposals:[{...r,...d!==void 0?{confidence:d}:{}}]},e.principal);if(c.proposals.length===0){let a="That can't be done now.";return e.desk.record({...o,outcome:"failed",failed:a}),a}i?.(),e.desk.setGhost({ghost:c}),e.desk.record(o);return}if(t.type==="panel"){let f=t.label,d={title:f,recipe:{...t.panel,title:f}},c=await un(e,d,i);return e.desk.record(c?{...o,outcome:"failed",failed:c}:{...o,outcome:"drawn",accepted:[t.id],panel:d}),c}i?.(),t.type==="place"?e.goTo.place(t.place):t.type==="record"&&e.goTo.record(t.record),e.desk.record({...o,outcome:"accepted",accepted:[t.id]})}async function yt(e,n){if(n.ask.kind==="ask")return ue(e.desk,{target:n.target,asked:n.ask.said}),null;let t=n.ask.kind==="panel"||n.ask.kind==="record"?n.ask.kind:"fill";return le(e,t,n.target,n.ask.said)}var z={padding:"5px 10px",fontSize:"0.875rem",borderRadius:8,width:"100%",textAlign:"left",borderWidth:1,borderStyle:"solid",borderColor:"transparent",background:"none",boxShadow:"none"},we={margin:0,padding:"4px 10px",fontSize:"0.8125rem",color:"var(--graview-ink-muted)"};function gt({target:e,close:n}){let t=Je(),i=(0,P.useMemo)(()=>Xe(e,y=>t.store.graph.has(y)),[e,t.store]),o=(0,P.useMemo)(()=>{let y=fn(t,i);return he(t.store,i,{principal:t.principal,places:t.places,...y.acts?{acts:y.acts}:{}})},[t,i]),r=o.candidates.some(y=>y.type==="fill"),f=o.candidates.some(y=>y.type==="panel"),d=(0,P.useMemo)(()=>f?Ze(t.store,i,{principal:t.principal,places:t.places,most:1}):[],[f,t,i]),c=(0,P.useMemo)(()=>new Set(t.store.allMutations().filter(y=>(y.creates??[]).length>0).map(y=>y.name)),[t.store]),a=U(t.ai)!==void 0&&o.candidates.some(y=>y.type==="act"&&y.asks.length>0&&c.has(y.mutation)),s=Oe(t.ai),u=Dn(t,i),g=JSON.stringify(i),[b,C]=(0,P.useState)(!1),[A,m]=(0,P.useState)(null),[x,O]=(0,P.useState)(s&&u===void 0);(0,P.useEffect)(()=>{if(u!==void 0||!(s||b))return;let y=!0;return O(!0),Ln(t,i).then(v=>{y&&(m(v),O(!1))}),()=>{y=!1}},[g,b]);let k=u??A,p=(k?.offers??[]).filter(y=>!(y.type==="place"&&d.some(v=>v.place===y.place))).slice(0,Math.max(0,3-d.length)),w=k?.interaction.outcome==="failed"?k.interaction.failed??"The AI could not suggest anything here.":null,T=(0,P.useRef)(!1),F=(0,P.useRef)(null);(0,P.useLayoutEffect)(()=>{k===null||!T.current||(T.current=!1,F.current?.querySelector("button")?.focus())},[k]);let q=(0,P.useRef)(!0);(0,P.useEffect)(()=>()=>{q.current=!1},[]);let[H,l]=(0,P.useState)(!1),[h,R]=(0,P.useState)(null),E=y=>{if(H)return;l(!0),R(null);let v=!1;y(()=>{v=!0,n()}).then(j=>{q.current&&(l(!1),j?R(j):v||n())},j=>{q.current&&(l(!1),R(j instanceof Error?j.message:String(j)))})},$=y=>y.interaction.outcome==="failed"?y.interaction.failed??"The AI could not do that here.":void 0;return(0,S.jsxs)("div",{ref:F,"data-testid":"inline-ai",style:{display:"grid",gap:2},children:[x&&!b?(0,S.jsx)("p",{role:"status","data-testid":"inline-ai-thinking",style:we,children:"Thinking\u2026"}):H?(0,S.jsx)("p",{role:"status","data-testid":"inline-ai-asking",style:we,children:"Asking\u2026"}):h?(0,S.jsx)("p",{role:"alert","data-testid":"inline-ai-failed",style:{...we,color:"var(--graview-warn)"},children:h}):w?(0,S.jsx)("p",{role:"status",style:we,children:w}):null,(0,S.jsxs)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"flex",flexDirection:"column",gap:2},children:[p.map(y=>(0,S.jsx)("li",{children:(0,S.jsxs)("button",{type:"button","data-menu-item":`ai-offer:${y.id}`,"data-ai-offer":y.id,"data-ai-offer-type":y.type,onClick:()=>E(v=>Hn(t,k,y,v)),style:z,children:[y.label,(0,S.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[" \xB7 ",y.type==="panel"?"a panel":y.type==="place"?"go there":y.type==="record"?"open it":"suggested"]})]})},y.id)),!s&&k===null?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-suggest","aria-disabled":b||void 0,onClick:y=>{b||(T.current=document.activeElement===y.currentTarget,C(!0))},style:z,children:b?"Thinking\u2026":"Suggest\u2026"})}):null,r?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-fill",onClick:()=>E(async y=>$(await le(t,"fill",i,"Fill in",y))),style:z,children:"Fill in with AI"})}):null,a?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-record",onClick:()=>E(async y=>$(await le(t,"record",i,"Add one",y))),style:z,children:"Add one with AI"})}):null,d.map(y=>(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":`ai-open:${y.place}`,"data-ai-existing":y.fit,onClick:()=>{n(),t.goTo.place(y.place),y.fit==="partial"&&ue(t.desk,{target:{on:"lens",place:y.place,...y.kind?{kind:y.kind}:{}}})},style:z,children:y.fit==="full"?`Open ${y.title}`:`Open and adjust ${y.title}`})},y.place)),f?(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-panel",onClick:()=>E(async y=>$(await le(t,"panel",i,"Draw a panel",y))),style:z,children:d.length>0?"Draw a new view":"Draw a panel"})}):null,(0,S.jsx)("li",{children:(0,S.jsx)("button",{type:"button","data-menu-item":"ai-ask",onClick:()=>{let y=document.activeElement;n(),ue(t.desk,{target:i,returnTo:y instanceof HTMLElement&&y!==document.body?y:null})},style:z,children:"Ask about this\u2026"})})]})]})}var Ae={display:"inline-flex",alignItems:"center",minHeight:28,padding:"2px 10px",fontSize:"0.8125rem",borderRadius:8};function mt({placement:e="picture"}){let{store:n,principal:t,aiDesk:i}=ze(),o=We(n,t),{ghost:r,entries:f}=_e(i),[d,c]=(0,P.useState)(new Set);(0,P.useEffect)(()=>c(new Set),[r?.ghost.interaction]);let a=(0,P.useRef)(null),s=(0,P.useRef)(null),u=r?.batch;if((0,P.useEffect)(()=>{u!==void 0&&s.current?.focus()},[u]),!r)return null;let{ghost:g}=r,b=f.find(k=>k.id===g.interaction),C=()=>{let k=g.target.on==="record"||g.target.on==="field"?g.target.id:void 0,p=a.current?.closest("[data-graview-face], main")?.parentElement??document,w=(k?p.querySelector(`[data-graview-view="${CSS.escape(k)}"][tabindex]`):null)??document.querySelector("[data-graview-page-title]")??a.current?.closest("main")??document.querySelector("main");w&&!w.hasAttribute("tabindex")&&w.setAttribute("tabindex","-1"),w?.focus({preventScroll:!0}),i.setGhost(null)},A=g.proposals.filter(k=>!d.has(k.id)).map(k=>k.id),m=()=>{let k=an(o,g,{author:t,ids:A});if(!k.ok){i.setGhost({...r,refused:k.refused});return}b&&i.record(dn(b,k.accepted,k.batch)),i.setGhost({ghost:g,batch:k.batch,took:k.accepted.length,...r.onCard?{onCard:!0}:{}})},x=()=>{b&&r.batch===void 0&&i.record(ln(b)),C()},O=()=>{if(r.batch!==void 0)try{o.undo(r.batch,{author:t}),C()}catch(k){i.setGhost({...r,refused:k instanceof Error?k.message:String(k)})}};return(0,S.jsxs)("section",{ref:a,"data-testid":"ai-ghost","data-interaction":g.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:He("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,S.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:r.batch!==void 0?`Done: ${r.took===1?"one change":`${r.took} changes`}, as one.`:`Proposed by AI \xB7 ${g.basis}`}),r.batch===void 0?(0,S.jsx)("ul",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:4},children:g.proposals.map(k=>(0,S.jsx)("li",{"data-ghost-proposal":k.id,children:(0,S.jsxs)("label",{style:{display:"flex",alignItems:"baseline",gap:8,cursor:"pointer"},children:[(0,S.jsx)("input",{type:"checkbox",checked:!d.has(k.id),onChange:p=>{let w=new Set(d);p.target.checked?w.delete(k.id):w.add(k.id),c(w)}}),(0,S.jsx)("span",{style:{fontStyle:"italic",color:"var(--graview-ink)"},children:k.said}),k.confidence!==void 0?(0,S.jsxs)("span",{style:{color:"var(--graview-ink-faint)"},children:[Math.round(k.confidence*100),"% sure"]}):null]})},k.id))}):null,r.refused?(0,S.jsx)("p",{role:"alert",style:{margin:0,color:"var(--graview-warn)"},children:r.refused}):null,(0,S.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:r.batch===void 0?(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("button",{type:"button","data-testid":"ghost-accept",disabled:A.length===0,onClick:m,style:Ae,children:A.length===g.proposals.length?"Accept":`Accept ${A.length} of ${g.proposals.length}`}),(0,S.jsx)("button",{type:"button","data-testid":"ghost-dismiss",onClick:x,style:Ae,children:"Dismiss"})]}):(0,S.jsxs)(S.Fragment,{children:[(0,S.jsx)("button",{type:"button",ref:s,"data-testid":"ghost-undo",onClick:O,style:Ae,children:"Undo"}),(0,S.jsx)("button",{type:"button","data-testid":"ghost-close",onClick:C,style:Ae,children:"Close"})]})})]})}export{Xe as a,Q as b,he as c,Ze as d,ie as e,Ie as f,Rn as g,Tn as h,it as i,ot as j,fn as k,un as l,le as m,Dn as n,Ln as o,Hn as p,yt as q,gt as r,mt as s};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk.DDFRFSVN.js";import"./chunk.U5P23GO7.js";import"./chunk.YOUB3J3Y.js";import"./chunk.KZUMXT5J.js";import"./chunk.CGK2PY76.js";import"./chunk.CYTTZOYL.js";import"./chunk.SDO3U72B.js";import"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{a as ActivityFilter,b as InteractionRow};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"./chunk.WVUJXDXZ.js";import{b as P}from"./chunk.XYGNS637.js";import"./chunk.DZSZUX34.js";import"./chunk.4EXC26LI.js";import"./chunk.PWAP2GJS.js";import"./chunk.AHPYNDVA.js";import"./chunk.FNVGNISQ.js";import"./chunk.D5LOTCBU.js";import{Aa as L,wa as M,ya as T,za as E}from"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";function G(r,l,i){let g=r.getAttribute("data-record")??"",m=r.getAttribute("data-field")??"",c=Number(r.getAttribute("data-index")??"0"),e=[...l?.node?[l.node]:[],...l?.nodes??[]].find(p=>p.id===g);if(!g||!e)return{why:g?`names a record it was not shown ("${g.slice(0,80)}")`:"names no record (data-record)"};let h=m&&Object.hasOwn(e,m)?e[m]:void 0,f=(Array.isArray(h)?h:[h]).filter(M),o=Number.isInteger(c)&&c>=0?f[c]:void 0,v=e.label?`"${e.label}"`:"a record";return m?o?(i==="video"?!E(o):!E(o)&&!T(o))?{why:`names "${o.name}" on ${v}, which is not ${i==="video"?"a video":"a picture or a video"}`}:{file:o,on:e}:{why:f.length===0?`names "${m}" on ${v}, which holds no file it was shown`:`names file ${r.getAttribute("data-index")} of "${m}" on ${v}, which holds ${f.length}`}:{why:`names no field of ${v} (data-field)`}}var C=r=>`${r.caption?.trim()||r.name}, ${L(r)}`;function N(r,l,i,g,m,c={}){let e=r.createElement("video");e.setAttribute("data-graview-video",""),e.setAttribute("playsinline",""),e.setAttribute("aria-label",C(i)),c.autoplay?(e.setAttribute("data-graview-video-autoplay",""),e.setAttribute("muted",""),e.muted=!0,e.setAttribute("loop",""),e.setAttribute("preload",c.still?"metadata":"auto"),c.still?e.setAttribute("data-graview-video-still",""):e.setAttribute("autoplay","")):(e.setAttribute("controls",""),e.setAttribute("preload","metadata"));let h=i.poster?g(i.poster):void 0;h&&e.setAttribute("poster",h),i.width&&i.height?(e.setAttribute("width",String(i.width)),e.setAttribute("height",String(i.height)),e.style.aspectRatio=`${i.width} / ${i.height}`):e.style.aspectRatio="16 / 9",c.cover?(e.setAttribute("data-graview-video-cover",""),e.style.cssText+=";display:block;width:100%;height:100%;max-height:none;aspect-ratio:auto;object-fit:cover;background:#000"):e.style.cssText+=";display:block;width:100%;height:auto;max-height:80vh;background:#000;border-radius:var(--graview-radius, 8px)";let f=i.captions?g(i.captions):void 0;if(f){let o=r.createElement("track");o.setAttribute("kind","captions"),o.setAttribute("src",f),o.setAttribute("srclang","en"),o.setAttribute("label","Captions"),o.setAttribute("default",""),e.appendChild(o)}return i.duration===void 0&&e.addEventListener("loadedmetadata",()=>Number.isFinite(e.duration)&&e.duration>0&&e.setAttribute("aria-label",C({...i,duration:e.duration}))),e.setAttribute("src",m),l.appendChild(e),e}function S(r,l){let i=r.document,g=new Set,m=t=>{g.has(t)||(g.add(t),l.onProblem?.(t))},c=t=>{let a=l.file?l.file(t):t;if(a!==void 0)try{let s=new r.URL(a,i.baseURI);return s.origin===r.location.origin&&/^https?:$/.test(s.protocol)?a:void 0}catch{return}},e=new WeakMap,h=typeof r.matchMedia=="function"?r.matchMedia("(prefers-reduced-motion: reduce)"):void 0,f=new Set,o=(t,a)=>{a?(t.removeAttribute("autoplay"),t.setAttribute("data-graview-video-still",""),t.pause()):(t.removeAttribute("data-graview-video-still"),t.setAttribute("autoplay",""),t.setAttribute("preload","auto"),t.play?.()?.catch?.(()=>{}))},v=()=>{for(let t of f)t.isConnected?o(t,h?.matches===!0):f.delete(t)};h?.addEventListener?.("change",v);let p,k=t=>{if(typeof t.close=="function")return t.close();t.removeAttribute("open"),t.dispatchEvent(new r.Event("close"))},w=(t,a)=>m(`The ${t} in the view ${l.view} was not drawn: it ${a}.`);return{refresh(t){let a=l.shown();for(let s of Array.from(t.querySelectorAll("graview-video"))){let d=s.shadowRoot??s.attachShadow({mode:"open"});if(!l.pictures){e.delete(s),d.replaceChildren(),w("video",`asks for no pictures: a view places a record's video where its manifest says "pictures": true`);continue}let u=G(s,a,"video"),n={autoplay:s.hasAttribute("autoplay"),cover:s.hasAttribute("cover"),still:h?.matches===!0},b="file"in u?JSON.stringify([u.file,n.autoplay,n.cover]):"";if(e.get(s)===b&&d.childNodes.length>0)continue;if(e.set(s,b),d.replaceChildren(),"why"in u){w("video",u.why);continue}let A=c(u.file.href);if(!A){w("video",`names "${u.file.name}", which this host does not say it serves on this page`);continue}let $=i.createElement("style");$.textContent=":host { display: block; min-width: 0; }",d.appendChild($);let y=N(i,d,u.file,c,A,n);n.autoplay&&f.add(y)}},open(t){if(!l.pictures)return w("full-screen viewer",`asks for no pictures: a view opens a record's picture or video full screen where its manifest says "pictures": true`),!1;let a=G(t,l.shown(),"any");if("why"in a)return w("full-screen viewer",a.why),!1;let s=c(a.file.href);if(!s)return w("full-screen viewer",`names "${a.file.name}", which this host does not say it serves on this page`),!1;p&&k(p);let d=a.file,u=d.caption?.trim()||d.name,n=i.createElement("dialog");n.setAttribute("data-graview-lightbox",""),n.setAttribute("aria-label",E(d)?C(d):u),n.style.cssText="padding:0;border:0;border-radius:var(--graview-radius, 8px);max-width:min(96vw, 1600px);max-height:94vh;background:var(--graview-panel, Canvas);color:var(--graview-ink, CanvasText)";let b=i.createElement("figure");if(b.style.cssText="margin:0;display:grid;gap:8px;padding:10px",E(d))N(i,b,d,c,s);else{let x=i.createElement("img");x.setAttribute("src",s),x.setAttribute("alt",u),x.style.cssText="max-width:100%;max-height:80vh;object-fit:contain;display:block;margin:0 auto",b.appendChild(x)}let A=i.createElement("figcaption");A.style.cssText="display:flex;gap:12px;align-items:center;justify-content:space-between";let $=i.createElement("span");$.textContent=E(d)&&d.duration!==void 0?`${u} \xB7 ${P(d.duration)}`:u;let y=i.createElement("button");return y.type="button",y.textContent="Close",y.addEventListener("click",()=>k(n)),A.append($,y),b.appendChild(A),n.appendChild(b),n.addEventListener("click",x=>x.target===n&&k(n)),n.addEventListener("close",()=>{n.remove(),p===n&&(p=void 0),t.focus?.()}),i.body.appendChild(n),p=n,typeof n.showModal=="function"?n.showModal():n.setAttribute("open",""),y.focus(),!0},dispose(){p&&k(p),p?.remove(),p=void 0,h?.removeEventListener?.("change",v),f.clear()}}}export{S as createGuestMedia,G as namedFile};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as k,b as A,c as L,d as _,e as E,r as B,s as V,t as H,u as N,v as q}from"./chunk.OJGHDWI6.js";import"./chunk.
|
|
1
|
+
import{a as k,b as A,c as L,d as _,e as E,r as B,s as V,t as H,u as N,v as q}from"./chunk.OJGHDWI6.js";import"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var W=["drawElementImageToTexture","copyElementImageToTexture"],S=null,P=(r,e)=>r==="texture"?{texture:e}:{destination:{texture:e}};function Z(){return typeof globalThis>"u"?void 0:globalThis}function v(r,e){let t=[],n=Z(),o=!!(n?.navigator&&"gpu"in n.navigator);o||t.push("navigator.gpu is absent \u2014 WebGPU is unavailable.");let i=r??n?.GPUQueue?.prototype??void 0,a=null;if(i){for(let d of W)if(typeof i[d]=="function"){a=d;break}}a||t.push("No element-capture method on GPUQueue. Run Chromium 147+ with --enable-blink-features=CanvasDrawElement.");let c=e??n?.HTMLCanvasElement?.prototype??void 0,l=typeof c?.updateElementGeometry=="function";l||t.push("canvas.updateElementGeometry is absent \u2014 geometry cannot be reported.");let p=typeof c?.requestPaint=="function";p||t.push("canvas.requestPaint is absent \u2014 there is no capture-safe moment to hook.");let w=!1,h="unknown";if(typeof document<"u"){let d=document.createElement("canvas");w="layoutSubtree"in d||typeof d.captureElementImage=="function","layoutSubtree"in d?h="no":typeof d.captureElementImage=="function"&&(h="yes")}return{available:a!==null,captureMethod:a,geometrySync:l,hitTestFollowsGeometry:l?h:"no",layoutSubtree:w,paintEvents:p,webgpu:o,usable:o&&a!==null,notes:t}}var g=class extends Error{constructor(t){super(`HTML-in-Canvas is unavailable:
|
|
2
2
|
${t.notes.join(`
|
|
3
3
|
`)}`);this.capabilities=t;this.name="PlatformUnavailableError"}};function G(r,e,t){let n=r;for(let o of W){let i=n[o];if(typeof i=="function"){if(S){i.call(n,{source:e},P(S,t));return}try{i.call(n,{source:e},P("texture",t)),S="texture"}catch(a){if(!(a instanceof TypeError)||!/texture/i.test(a.message))throw a;i.call(n,{source:e},P("destination",t)),S="destination"}return}}throw new g(v(r))}function M(r,e=!0){e?r.setAttribute("drawable",""):r.removeAttribute("drawable")}function F(r){let e=r.changedElements;return e?new Set(Array.from(e)):null}function ee(r,e){let t=r;if(typeof t.captureElementImage!="function")throw new g(v(void 0,r));return t.captureElementImage(e)}function O(r,e,t){let n=r;if(typeof n.updateElementGeometry!="function")throw new g(v(void 0,r));n.updateElementGeometry(e,t)}function te(r,e){r.clearElementGeometry?.(e)}function m(r){r.requestPaint?.()}function D(r,e=!0){let t=r;e?t.setAttribute("content","drawable"):t.removeAttribute("content"),"layoutSubtree"in t?t.layoutSubtree=e:e?t.setAttribute("layoutsubtree",""):t.removeAttribute("layoutsubtree")}var I=`
|
|
4
4
|
struct Plane {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk.GHN62OMG.js";import"./chunk.2RASWDMQ.js";import"./chunk.XCWZFLIB.js";import"./chunk.6YK5E7ZQ.js";import"./chunk.AWUO3M5D.js";import"./chunk.VZDHRY3U.js";import"./chunk.V4HVFLFQ.js";import"./chunk.A2R53GWF.js";import"./chunk.QAMW5QDT.js";import"./chunk.B5PJCYBU.js";import"./chunk.Q2EGESEZ.js";import"./chunk.SMHP2CQH.js";import"./chunk.HJCQ6I3S.js";import"./chunk.EJ4MSVX2.js";import"./chunk.KQPKYWDM.js";import"./chunk.72YXFJKC.js";import"./chunk.2PJ6STKA.js";import"./chunk.MBB5A6BT.js";import"./chunk.T535ZLRM.js";import"./chunk.ERPILTRY.js";import"./chunk.OTSBF367.js";import"./chunk.BIDL7GQD.js";import"./chunk.QS32TO4N.js";import"./chunk.JVDPRQ7J.js";import"./chunk.57YDGGJK.js";import"./chunk.H7AH3IW4.js";import"./chunk.4TH3CGAZ.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.MAHNJO6U.js";import"./chunk.75GENXGP.js";import"./chunk.NIAM7OTV.js";import"./chunk.WVUJXDXZ.js";import"./chunk.XYGNS637.js";import"./chunk.DZSZUX34.js";import"./chunk.4EXC26LI.js";import"./chunk.PWAP2GJS.js";import"./chunk.AHPYNDVA.js";import"./chunk.FNVGNISQ.js";import"./chunk.GZHZLJBF.js";import"./chunk.WUVXIUA7.js";import"./chunk.OJGHDWI6.js";import"./chunk.BN7C5ZYX.js";import"./chunk.REUMBCSV.js";import"./chunk.2KIWGQXC.js";import"./chunk.D5LOTCBU.js";import"./chunk.KZUMXT5J.js";import"./chunk.CGK2PY76.js";import"./chunk.CYTTZOYL.js";import"./chunk.SDO3U72B.js";import"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";export{b as declaredLensView,a as formatFor};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{d as z,e as D,f as H}from"./chunk.DBFJVVWF.js";import"./chunk.SSAETRHR.js";import{a as P,b as A,c as p,d as W}from"./chunk.Q355UPFG.js";import"./chunk.YZBJUAS6.js";import"./chunk.2RASWDMQ.js";import"./chunk.XCWZFLIB.js";import"./chunk.AWUO3M5D.js";import"./chunk.VZDHRY3U.js";import"./chunk.V4HVFLFQ.js";import"./chunk.A2R53GWF.js";import"./chunk.QAMW5QDT.js";import"./chunk.B5PJCYBU.js";import"./chunk.Q2EGESEZ.js";import"./chunk.SMHP2CQH.js";import"./chunk.ZZAI57VI.js";import"./chunk.34DRUCH2.js";import"./chunk.NEPQBMFT.js";import"./chunk.2PJ6STKA.js";import"./chunk.MBB5A6BT.js";import"./chunk.T535ZLRM.js";import"./chunk.ERPILTRY.js";import"./chunk.OTSBF367.js";import{a as C,b as O}from"./chunk.MB7LKKUD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.XYGNS637.js";import"./chunk.DZSZUX34.js";import"./chunk.4EXC26LI.js";import"./chunk.PWAP2GJS.js";import"./chunk.AHPYNDVA.js";import"./chunk.FNVGNISQ.js";import"./chunk.GZHZLJBF.js";import"./chunk.WUVXIUA7.js";import"./chunk.OJGHDWI6.js";import"./chunk.BN7C5ZYX.js";import"./chunk.REUMBCSV.js";import"./chunk.2KIWGQXC.js";import"./chunk.D5LOTCBU.js";import"./chunk.KZUMXT5J.js";import"./chunk.CGK2PY76.js";import{G as B,Sa as k,T as L}from"./chunk.CYTTZOYL.js";import"./chunk.SDO3U72B.js";import{qd as R}from"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import{b as E}from"./chunk.AJZBJBMO.js";var r=E(B(),1);var s=E(L(),1);function M(c){let e=document.activeElement;if(e!==null&&e!==document.body&&e!==document.documentElement&&e.isConnected)return;let n=c??document,o=n.querySelector("main")??n.querySelector("[data-graview-page]")??null,t=n.querySelector("[data-graview-page-title]")??o?.querySelector("h1, h2")??o;t instanceof HTMLElement&&(t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1"),t.focus({preventScroll:!0}))}var I=1500;function N(c,e,n){let{store:o,principal:t}=c,l=z(o),g=(0,r.useMemo)(()=>P(o,t),[o,t,l]),w=(0,r.useRef)(n),[b,d]=(0,r.useState)(),[y,u]=(0,r.useState)("");(0,r.useEffect)(()=>{let a=A(o,t,w.current);w.current=o.batches().length,a&&(d({batch:a.batch,at:e,when:Date.now()}),u(""))},[o,t,l]),(0,r.useEffect)(()=>{d(a=>!a||a.at===e?a:Date.now()-a.when<I?{...a,at:e}:void 0)},[e]);let[x,i]=(0,r.useState)(null),v=(0,r.useCallback)(()=>{d(void 0),i(null)},[]),f=(0,r.useCallback)(()=>{i(null);try{let a=W(o,t);a&&u(`Took back \u201C${a.intent}\u201D`)}catch(a){i(a instanceof Error?a.message:String(a))}},[o,t]),S=g&&b?.batch===g.batch&&b.at===e?g:void 0;return{change:g,offered:S,close:v,takeBack:f,refused:x,said:y}}function ee({context:c,docked:e,at:n,since:o,compact:t=!1,className:l,size:g}){let{change:w,offered:b,close:d,takeBack:y,refused:u,said:x}=N(c,n,o),i=e?b:w,v=(0,r.useRef)(null),f=e&&(i!==void 0||u!==null);j(v,f),(0,r.useEffect)(()=>{if(!f)return;let m,h=()=>m=setTimeout(()=>v.current?.matches(":hover, :focus-within")?h():d(),1e4);return h(),()=>clearTimeout(m)},[f,i?.batch,u,d]);let S=x||(e&&i?p(i):""),a=e?{position:"fixed",inset:"auto",margin:0,padding:0,border:"none",background:"none",overflow:"visible",zIndex:R("toast"),width:"max-content",height:"auto",bottom:"calc(16px + env(safe-area-inset-bottom, 0px))",left:16,justifyItems:"start",color:"var(--graview-ink)",...f?{}:{display:"none"}}:{},T=i?(0,s.jsxs)("button",{type:"button","data-testid":"page-undo",title:`${p(i)} \u2014 \u2318Z or Ctrl+Z`,"aria-keyshortcuts":"Meta+Z Control+Z",onClick:m=>{let h=m.currentTarget.closest("[data-graview-face]");y(),requestAnimationFrame(()=>M(h))},...e?{style:U}:{className:H("graview-undo",l),...D(g),...t?{"data-compact":"","aria-label":p(i)}:{}},children:[(0,s.jsx)("span",{"aria-hidden":"true",children:"\u21B6"}),e?(0,s.jsx)("span",{style:K,children:p(i)}):(0,s.jsx)("span",{className:"graview-undo-words",children:t?"Undo":p(i)})]}):null;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{role:"status","aria-live":"polite",style:V,children:S}),(0,s.jsxs)("div",{ref:v,...e?{popover:"manual","data-graview-foot":"","data-graview-offstage":""}:{},"data-testid":e?"face-undo-dock":"page-undo-place",...e?{style:{...F,...a}}:{className:"graview-undo-place"},children:[e?null:(0,s.jsx)("style",{children:q}),e&&i?(0,s.jsxs)("div",{"data-testid":"page-undo-notice",style:Z,children:[T,(0,s.jsx)("button",{type:"button","data-testid":"page-undo-dismiss","aria-label":`Dismiss: ${p(i)}`,title:"Dismiss",onClick:m=>{let h=m.currentTarget.closest("[data-graview-face]");d(),requestAnimationFrame(()=>M(h))},style:$,children:"\xD7"})]}):T,u?(0,s.jsx)("span",{"data-testid":"page-undo-refused",role:"alert",className:"graview-undo-refused",...e?{style:{fontSize:"0.8125rem",lineHeight:1.4,color:"var(--graview-warn)",borderRadius:6,background:"var(--graview-float)",padding:"4px 8px"}}:{},children:u}):null]})]})}function j(c,e){(0,r.useLayoutEffect)(()=>{let n=c.current;if(!n||!e)return;if(typeof n.showPopover=="function"&&!k(n))try{n.showPopover()}catch{}let o=()=>n.parentElement?.closest("[data-embed-content]")??null,t=()=>{O(n,o()),dispatchEvent(new Event(C))};t(),addEventListener("resize",t),addEventListener("scroll",t,!0);let l=typeof ResizeObserver=="function"?new ResizeObserver(t):null;return l?.observe(n),()=>{if(l?.disconnect(),removeEventListener("resize",t),removeEventListener("scroll",t,!0),n.isConnected&&k(n))try{n.hidePopover()}catch{}dispatchEvent(new Event(C))}},[c,e])}var q=`:where(.graview-undo-place){display:grid;justify-items:end;gap:4px;max-width:100%;min-width:0}
|
|
2
|
+
:where(.graview-undo){box-sizing:border-box;display:inline-flex;align-items:center;gap:6px;min-height:var(--graview-control-height,36px);max-width:min(100%,var(--graview-undo-widest,18rem));min-width:0;padding:0 14px;border-radius:999px;border:1px solid var(--graview-edge);background:var(--graview-float);color:var(--graview-ink);font:inherit;font-size:.875rem;cursor:pointer}
|
|
3
|
+
:where(.graview-undo[data-size=sm]){--graview-control-height:30px}
|
|
4
|
+
:where(.graview-undo[data-compact]){padding:0 10px}
|
|
5
|
+
:where(.graview-undo-words){min-width:0;overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
|
|
6
|
+
:where(.graview-undo-refused){font-size:.8125rem;line-height:1.4;color:var(--graview-warn);border-radius:6px}`,F={display:"grid",justifyItems:"end",gap:4,maxWidth:"100%",minWidth:0},U={display:"inline-flex",alignItems:"center",gap:6,minHeight:36,maxWidth:"100%",minWidth:0,borderRadius:999,font:"inherit",fontSize:"0.875rem",cursor:"pointer",textAlign:"start",lineHeight:1.4,padding:"8px 4px 8px 14px",border:"none",background:"none",color:"inherit"},Z={display:"flex",alignItems:"center",gap:2,maxWidth:"100%",minWidth:0,paddingRight:6,borderRadius:"var(--graview-radius, 12px)",border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)"},$={flex:"0 0 auto",minWidth:28,minHeight:28,padding:0,border:"none",background:"none",boxShadow:"none",color:"var(--graview-ink-muted)",font:"inherit",fontSize:"1rem",cursor:"pointer"},K={minWidth:0,overflow:"hidden",overflowWrap:"anywhere",display:"-webkit-box",WebkitBoxOrient:"vertical",WebkitLineClamp:4},V={position:"absolute",width:1,height:1,margin:-1,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",whiteSpace:"nowrap",border:0};export{ee as TakeBack};
|
|
@@ -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.2PJ6STKA.js";import{j as g}from"./chunk.KZUMXT5J.js";import{G as R,Ia as m,T as c}from"./chunk.CYTTZOYL.js";import{a as f}from"./chunk.SDO3U72B.js";import{ta as p}from"./chunk.Q4MI53KK.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.NIAM7OTV.js","./chunk.PWAP2GJS.js","./chunk.AHPYNDVA.js","./chunk.FNVGNISQ.js","./chunk.Q4MI53KK.js","./chunk.FQLNBIQ5.js","./chunk.AJZBJBMO.js"]),import("./chunk.MY5HJW2Z.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};
|
package/dist/preview/index.html
CHANGED
|
@@ -5,67 +5,70 @@
|
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
6
6
|
<title>Graview preview</title>
|
|
7
7
|
<link rel="preload" href="/graview/document" as="fetch" crossorigin="anonymous">
|
|
8
|
-
<link rel="modulepreload" href="/chunk.
|
|
9
|
-
<link rel="modulepreload" href="/chunk.
|
|
10
|
-
<link rel="modulepreload" href="/chunk.
|
|
11
|
-
<link rel="modulepreload" href="/chunk.
|
|
12
|
-
<link rel="modulepreload" href="/chunk.
|
|
13
|
-
<link rel="modulepreload" href="/chunk.
|
|
14
|
-
<link rel="modulepreload" href="/chunk.
|
|
15
|
-
<link rel="modulepreload" href="/chunk.
|
|
16
|
-
<link rel="modulepreload" href="/chunk.
|
|
8
|
+
<link rel="modulepreload" href="/chunk.YXAKHXYB.js">
|
|
9
|
+
<link rel="modulepreload" href="/chunk.PDS4HT46.js">
|
|
10
|
+
<link rel="modulepreload" href="/chunk.Z2ZQJ3DD.js">
|
|
11
|
+
<link rel="modulepreload" href="/chunk.PDMX3GTL.js">
|
|
12
|
+
<link rel="modulepreload" href="/chunk.Q5WEOX3Q.js">
|
|
13
|
+
<link rel="modulepreload" href="/chunk.75GENXGP.js">
|
|
14
|
+
<link rel="modulepreload" href="/chunk.FNVGNISQ.js">
|
|
15
|
+
<link rel="modulepreload" href="/chunk.KZUMXT5J.js">
|
|
16
|
+
<link rel="modulepreload" href="/chunk.CGK2PY76.js">
|
|
17
|
+
<link rel="modulepreload" href="/chunk.CYTTZOYL.js">
|
|
17
18
|
<link rel="modulepreload" href="/chunk.SDO3U72B.js">
|
|
18
|
-
<link rel="modulepreload" href="/chunk.
|
|
19
|
+
<link rel="modulepreload" href="/chunk.Q4MI53KK.js">
|
|
19
20
|
<link rel="modulepreload" href="/chunk.FQLNBIQ5.js">
|
|
20
21
|
<link rel="modulepreload" href="/chunk.AJZBJBMO.js">
|
|
21
|
-
<link rel="modulepreload" href="/chunk.
|
|
22
|
-
<link rel="modulepreload" href="/chunk.
|
|
23
|
-
<link rel="modulepreload" href="/chunk.
|
|
24
|
-
<link rel="modulepreload" href="/chunk.
|
|
25
|
-
<link rel="modulepreload" href="/chunk.
|
|
26
|
-
<link rel="modulepreload" href="/chunk.
|
|
22
|
+
<link rel="modulepreload" href="/chunk.SJUXFPTI.js">
|
|
23
|
+
<link rel="modulepreload" href="/chunk.EJ2WE764.js">
|
|
24
|
+
<link rel="modulepreload" href="/chunk.T3JIZNE7.js">
|
|
25
|
+
<link rel="modulepreload" href="/chunk.26H33GJC.js">
|
|
26
|
+
<link rel="modulepreload" href="/chunk.DBFJVVWF.js">
|
|
27
|
+
<link rel="modulepreload" href="/chunk.SSAETRHR.js">
|
|
27
28
|
<link rel="modulepreload" href="/chunk.Q355UPFG.js">
|
|
28
|
-
<link rel="modulepreload" href="/chunk.
|
|
29
|
-
<link rel="modulepreload" href="/chunk.
|
|
30
|
-
<link rel="modulepreload" href="/chunk.
|
|
31
|
-
<link rel="modulepreload" href="/chunk.
|
|
32
|
-
<link rel="modulepreload" href="/chunk.
|
|
33
|
-
<link rel="modulepreload" href="/chunk.
|
|
34
|
-
<link rel="modulepreload" href="/chunk.
|
|
35
|
-
<link rel="modulepreload" href="/chunk.
|
|
36
|
-
<link rel="modulepreload" href="/chunk.
|
|
37
|
-
<link rel="modulepreload" href="/chunk.
|
|
38
|
-
<link rel="modulepreload" href="/chunk.
|
|
39
|
-
<link rel="modulepreload" href="/chunk.
|
|
40
|
-
<link rel="modulepreload" href="/chunk.
|
|
41
|
-
<link rel="modulepreload" href="/chunk.
|
|
42
|
-
<link rel="modulepreload" href="/chunk.
|
|
43
|
-
<link rel="modulepreload" href="/chunk.
|
|
44
|
-
<link rel="modulepreload" href="/chunk.
|
|
45
|
-
<link rel="modulepreload" href="/chunk.
|
|
46
|
-
<link rel="modulepreload" href="/chunk.
|
|
29
|
+
<link rel="modulepreload" href="/chunk.YZBJUAS6.js">
|
|
30
|
+
<link rel="modulepreload" href="/chunk.NTC2H5ZX.js">
|
|
31
|
+
<link rel="modulepreload" href="/chunk.2RASWDMQ.js">
|
|
32
|
+
<link rel="modulepreload" href="/chunk.XCWZFLIB.js">
|
|
33
|
+
<link rel="modulepreload" href="/chunk.AWUO3M5D.js">
|
|
34
|
+
<link rel="modulepreload" href="/chunk.VZDHRY3U.js">
|
|
35
|
+
<link rel="modulepreload" href="/chunk.V4HVFLFQ.js">
|
|
36
|
+
<link rel="modulepreload" href="/chunk.A2R53GWF.js">
|
|
37
|
+
<link rel="modulepreload" href="/chunk.QAMW5QDT.js">
|
|
38
|
+
<link rel="modulepreload" href="/chunk.B5PJCYBU.js">
|
|
39
|
+
<link rel="modulepreload" href="/chunk.Q2EGESEZ.js">
|
|
40
|
+
<link rel="modulepreload" href="/chunk.SMHP2CQH.js">
|
|
41
|
+
<link rel="modulepreload" href="/chunk.ZZAI57VI.js">
|
|
42
|
+
<link rel="modulepreload" href="/chunk.34DRUCH2.js">
|
|
43
|
+
<link rel="modulepreload" href="/chunk.NEPQBMFT.js">
|
|
44
|
+
<link rel="modulepreload" href="/chunk.2PJ6STKA.js">
|
|
45
|
+
<link rel="modulepreload" href="/chunk.MBB5A6BT.js">
|
|
46
|
+
<link rel="modulepreload" href="/chunk.T535ZLRM.js">
|
|
47
|
+
<link rel="modulepreload" href="/chunk.ERPILTRY.js">
|
|
48
|
+
<link rel="modulepreload" href="/chunk.OTSBF367.js">
|
|
49
|
+
<link rel="modulepreload" href="/chunk.JVDPRQ7J.js">
|
|
47
50
|
<link rel="modulepreload" href="/chunk.BJUUSIQY.js">
|
|
48
|
-
<link rel="modulepreload" href="/chunk.
|
|
49
|
-
<link rel="modulepreload" href="/chunk.
|
|
51
|
+
<link rel="modulepreload" href="/chunk.57YDGGJK.js">
|
|
52
|
+
<link rel="modulepreload" href="/chunk.H7AH3IW4.js">
|
|
50
53
|
<link rel="modulepreload" href="/chunk.XOZU4OFA.js">
|
|
51
|
-
<link rel="modulepreload" href="/chunk.
|
|
54
|
+
<link rel="modulepreload" href="/chunk.4TH3CGAZ.js">
|
|
52
55
|
<link rel="modulepreload" href="/chunk.MB7LKKUD.js">
|
|
53
56
|
<link rel="modulepreload" href="/chunk.WVUJXDXZ.js">
|
|
54
|
-
<link rel="modulepreload" href="/chunk.
|
|
55
|
-
<link rel="modulepreload" href="/chunk.
|
|
56
|
-
<link rel="modulepreload" href="/chunk.
|
|
57
|
-
<link rel="modulepreload" href="/chunk.
|
|
58
|
-
<link rel="modulepreload" href="/chunk.
|
|
57
|
+
<link rel="modulepreload" href="/chunk.XYGNS637.js">
|
|
58
|
+
<link rel="modulepreload" href="/chunk.DZSZUX34.js">
|
|
59
|
+
<link rel="modulepreload" href="/chunk.4EXC26LI.js">
|
|
60
|
+
<link rel="modulepreload" href="/chunk.PWAP2GJS.js">
|
|
61
|
+
<link rel="modulepreload" href="/chunk.AHPYNDVA.js">
|
|
59
62
|
<link rel="modulepreload" href="/chunk.GZHZLJBF.js">
|
|
60
|
-
<link rel="modulepreload" href="/chunk.
|
|
63
|
+
<link rel="modulepreload" href="/chunk.WUVXIUA7.js">
|
|
61
64
|
<link rel="modulepreload" href="/chunk.OJGHDWI6.js">
|
|
62
|
-
<link rel="modulepreload" href="/chunk.
|
|
63
|
-
<link rel="modulepreload" href="/chunk.
|
|
64
|
-
<link rel="modulepreload" href="/chunk.
|
|
65
|
-
<link rel="modulepreload" href="/chunk.
|
|
66
|
-
<link rel="modulepreload" href="/chunk.
|
|
67
|
-
<link rel="modulepreload" href="/chunk.
|
|
68
|
-
<script>(()=>{const later=["/chunk.
|
|
65
|
+
<link rel="modulepreload" href="/chunk.BN7C5ZYX.js">
|
|
66
|
+
<link rel="modulepreload" href="/chunk.REUMBCSV.js">
|
|
67
|
+
<link rel="modulepreload" href="/chunk.2KIWGQXC.js">
|
|
68
|
+
<link rel="modulepreload" href="/chunk.D5LOTCBU.js">
|
|
69
|
+
<link rel="modulepreload" href="/chunk.6HKWAHPT.js">
|
|
70
|
+
<link rel="modulepreload" href="/chunk.2F4AZZQR.js">
|
|
71
|
+
<script>(()=>{const later=["/chunk.ZVG4FXJK.js","/chunk.GHN62OMG.js","/chunk.6YK5E7ZQ.js","/chunk.HJCQ6I3S.js","/chunk.EJ4MSVX2.js","/chunk.KQPKYWDM.js","/chunk.72YXFJKC.js","/chunk.BIDL7GQD.js","/chunk.QS32TO4N.js","/chunk.MAHNJO6U.js","/chunk.NIAM7OTV.js","/chunk.3JCHJLH6.js","/chunk.5QXQ7PBI.js","/chunk.N3T2O6EW.js","/chunk.OXWOUE3W.js","/chunk.KXFNRJ46.js","/chunk.OMRQTLI5.js","/chunk.MIE3ODQ2.js","/chunk.U5P23GO7.js","/chunk.CCQMDZHO.js"],first=[...document.querySelectorAll('link[rel="modulepreload"]')];let left=first.length;const go=()=>{for(const href of later){const link=document.createElement("link");link.rel="modulepreload";link.href=href;document.head.append(link)}};if(left===0)return go();const one=()=>{if(--left===0)go()};for(const link of first){link.addEventListener("load",one,{once:true});link.addEventListener("error",one,{once:true})}})()</script>
|
|
69
72
|
<style>html,body{margin:0;height:100%}#graview-app{min-height:100dvh}</style>
|
|
70
73
|
</head>
|
|
71
74
|
<body>
|