graview 0.1.62 → 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.js +6 -6
- package/dist/index.js.map +1 -1
- package/dist/preview/{chunk.THVC2BEC.js → chunk.24HNOLUS.js} +1 -1
- package/dist/preview/chunk.25CQCCLN.js +1 -0
- package/dist/preview/{chunk.YP2QSPXU.js → chunk.26H33GJC.js} +1 -1
- package/dist/preview/{chunk.DPEIT3TW.js → chunk.2F4AZZQR.js} +1 -1
- package/dist/preview/chunk.2KIWGQXC.js +2 -0
- package/dist/preview/{chunk.UQQKDBIH.js → chunk.2PJ6STKA.js} +1 -1
- package/dist/preview/{chunk.ELTV44HU.js → chunk.2RASWDMQ.js} +2 -2
- package/dist/preview/chunk.33XNYHI6.js +1 -0
- package/dist/preview/{chunk.TIALD6SC.js → chunk.34DRUCH2.js} +1 -1
- package/dist/preview/{chunk.MDEX6ZVE.js → chunk.36OE6RKG.js} +1 -1
- package/dist/preview/{chunk.A3OL2BI2.js → chunk.37FLKAVZ.js} +1 -1
- package/dist/preview/chunk.3JCHJLH6.js +1 -0
- package/dist/preview/chunk.3OQ6S6H4.js +1 -0
- package/dist/preview/chunk.47QEWSSE.js +1 -0
- package/dist/preview/{chunk.7M4HNKDR.js → chunk.4DAKQXDG.js} +1 -1
- package/dist/preview/{chunk.QIPASE42.js → chunk.4EXC26LI.js} +1 -1
- package/dist/preview/{chunk.VJBBVLGZ.js → chunk.4MEQUUG4.js} +1 -1
- package/dist/preview/{chunk.Y2YYH3JN.js → chunk.4TH3CGAZ.js} +1 -1
- package/dist/preview/{chunk.PZQNR4KZ.js → chunk.57YDGGJK.js} +1 -1
- package/dist/preview/{chunk.O75HWF3F.js → chunk.5GC4VAHU.js} +1 -1
- package/dist/preview/{chunk.WEOVK2T4.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.TM4EPUNO.js → chunk.6XHPBJ5F.js} +1 -1
- package/dist/preview/chunk.6YK5E7ZQ.js +4 -0
- package/dist/preview/{chunk.LGRLVJGS.js → chunk.6Z2GHQQH.js} +3 -3
- package/dist/preview/chunk.72YXFJKC.js +2 -0
- package/dist/preview/{chunk.T3UQ7ZQK.js → chunk.735AFUP5.js} +1 -1
- package/dist/preview/chunk.75GENXGP.js +1 -0
- package/dist/preview/{chunk.KMV6PJFL.js → chunk.A2R53GWF.js} +1 -1
- package/dist/preview/{chunk.OWT3VVOT.js → chunk.AHPYNDVA.js} +2 -2
- package/dist/preview/chunk.ATDIDPKZ.js +1 -0
- package/dist/preview/{chunk.F7YXLYLX.js → chunk.AW26EETU.js} +1 -1
- package/dist/preview/{chunk.I77ZGIFE.js → chunk.AWUO3M5D.js} +1 -1
- package/dist/preview/{chunk.AQRB7LDA.js → chunk.B46UZHGW.js} +1 -1
- package/dist/preview/{chunk.A3ZC2JBO.js → chunk.B5PJCYBU.js} +1 -1
- package/dist/preview/{chunk.VACKSKGJ.js → chunk.BF3EZCG3.js} +1 -1
- package/dist/preview/chunk.BKQICGFW.js +1 -0
- package/dist/preview/{chunk.DDUCIUVW.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.B23WZQXQ.js → chunk.CAXILB7K.js} +1 -1
- package/dist/preview/{chunk.UVA7AALY.js → chunk.CCQMDZHO.js} +1 -1
- package/dist/preview/{chunk.G4ULQK64.js → chunk.CGK2PY76.js} +1 -1
- package/dist/preview/{chunk.DEAP3H2L.js → chunk.CI4RZL4Z.js} +1 -1
- 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.7XLS6XTY.js → chunk.DDFRFSVN.js} +1 -1
- package/dist/preview/{chunk.GX4G4BX3.js → chunk.DIFIHNR3.js} +1 -1
- package/dist/preview/{chunk.VN23AGIY.js → chunk.DWK3GXRR.js} +1 -1
- package/dist/preview/{chunk.ZN3PUM2I.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.22BZU7ME.js → chunk.EJ4MSVX2.js} +1 -1
- package/dist/preview/chunk.ERPILTRY.js +1 -0
- package/dist/preview/{chunk.DC35FJAB.js → chunk.FFXBDOKA.js} +1 -1
- package/dist/preview/{chunk.UXMPFPFH.js → chunk.FGDGTES4.js} +2 -2
- package/dist/preview/chunk.FNVGNISQ.js +3 -0
- package/dist/preview/{chunk.ROZTJ6IY.js → chunk.FXCQJPN4.js} +1 -1
- package/dist/preview/chunk.G2JAYG2Z.js +1 -0
- package/dist/preview/{chunk.UFDJXQQQ.js → chunk.GHN62OMG.js} +6 -6
- package/dist/preview/{chunk.5ODHHH35.js → chunk.H5SN46VK.js} +1 -1
- package/dist/preview/{chunk.W4BKYSZX.js → chunk.H7AH3IW4.js} +1 -1
- package/dist/preview/{chunk.6JO5HQDR.js → chunk.HMMK7LCL.js} +1 -1
- package/dist/preview/{chunk.SVPKUWZU.js → chunk.HOFATBGD.js} +1 -1
- package/dist/preview/{chunk.JT3MFPRD.js → chunk.HRNNRA2I.js} +1 -1
- package/dist/preview/{chunk.7KVUUEZA.js → chunk.HSMJHCR3.js} +1 -1
- package/dist/preview/{chunk.RPDH32XV.js → chunk.IEDCFSN5.js} +1 -1
- package/dist/preview/{chunk.PCDUV3WP.js → chunk.JIEDJEHK.js} +1 -1
- package/dist/preview/chunk.JNIDS66Z.js +1 -0
- package/dist/preview/{chunk.DDO3GLEJ.js → chunk.JO3BBRSR.js} +1 -1
- package/dist/preview/{chunk.H5S7OL2U.js → chunk.JVDPRQ7J.js} +1 -1
- package/dist/preview/{chunk.SEHRPTNA.js → chunk.K7TK3KRB.js} +1 -1
- package/dist/preview/{chunk.ELOFPE25.js → chunk.KB5BCW23.js} +1 -1
- package/dist/preview/{chunk.6AKW7TXM.js → chunk.KL5H7KEV.js} +1 -1
- package/dist/preview/{chunk.ILIIBSGA.js → chunk.KPQLM4TM.js} +1 -1
- package/dist/preview/{chunk.2N4Z5K5S.js → chunk.KQPKYWDM.js} +1 -1
- package/dist/preview/{chunk.QHY5NVYH.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.AJSUHPBE.js → chunk.MBB5A6BT.js} +1 -1
- package/dist/preview/chunk.MENLUNM5.js +1 -0
- package/dist/preview/{chunk.PLTH2LW5.js → chunk.MIE3ODQ2.js} +1 -1
- package/dist/preview/{chunk.QDWSU47A.js → chunk.MT5DXJKN.js} +1 -1
- package/dist/preview/{chunk.AFNSAQEQ.js → chunk.MY5HJW2Z.js} +1 -1
- package/dist/preview/{chunk.5HGD6OWL.js → chunk.N3T2O6EW.js} +2 -2
- package/dist/preview/{chunk.66P5IDTH.js → chunk.NEPQBMFT.js} +1 -1
- package/dist/preview/{chunk.NOGGSLVG.js → chunk.NIAM7OTV.js} +1 -1
- package/dist/preview/{chunk.BZMQDEIY.js → chunk.NTC2H5ZX.js} +1 -1
- package/dist/preview/chunk.NWWJNNEK.js +2 -0
- package/dist/preview/{chunk.5J3O2FVG.js → chunk.O3YIWIVQ.js} +1 -1
- package/dist/preview/chunk.O67JXUVG.js +1 -0
- package/dist/preview/{chunk.4HEFUOLV.js → chunk.OIMGD7FR.js} +1 -1
- package/dist/preview/{chunk.DD2NKFDX.js → chunk.OM2NIQWA.js} +1 -1
- package/dist/preview/chunk.OMRQTLI5.js +1 -0
- package/dist/preview/{chunk.O2BHPYA4.js → chunk.OTSBF367.js} +2 -2
- package/dist/preview/{chunk.Y4FZKUOK.js → chunk.OXWOUE3W.js} +1 -1
- package/dist/preview/{chunk.2B6P4GPS.js → chunk.PDMX3GTL.js} +1 -1
- package/dist/preview/{chunk.75GVFX7L.js → chunk.PDS4HT46.js} +1 -1
- package/dist/preview/{chunk.EVBCEEQ4.js → chunk.PWAP2GJS.js} +1 -1
- package/dist/preview/chunk.Q2EGESEZ.js +1 -0
- package/dist/preview/{chunk.L3WTKQQL.js → chunk.Q4GJIJAU.js} +1 -1
- package/dist/preview/chunk.Q4MI53KK.js +5 -0
- package/dist/preview/{chunk.SWMDFXUX.js → chunk.QAMW5QDT.js} +1 -1
- package/dist/preview/{chunk.M4AYA2PL.js → chunk.QS32TO4N.js} +1 -1
- package/dist/preview/{chunk.BLUKSGI4.js → chunk.QSPLKCTX.js} +1 -1
- package/dist/preview/{chunk.WPXPVD33.js → chunk.R4HDKNT3.js} +1 -1
- package/dist/preview/chunk.REUMBCSV.js +1 -0
- package/dist/preview/{chunk.MAKODQO3.js → chunk.RUFYORIJ.js} +1 -1
- package/dist/preview/{chunk.5YAOKOGV.js → chunk.SGPXYDSG.js} +1 -1
- package/dist/preview/chunk.SJUXFPTI.js +1 -0
- package/dist/preview/{chunk.OUDATENL.js → chunk.SME4HD5I.js} +1 -1
- package/dist/preview/{chunk.2GEJNG2U.js → chunk.SMHP2CQH.js} +1 -1
- package/dist/preview/chunk.SSAETRHR.js +5 -0
- package/dist/preview/{chunk.MYNMBOLD.js → chunk.STDJ6XG5.js} +1 -1
- package/dist/preview/{chunk.IQ3PRWGO.js → chunk.T3JIZNE7.js} +2 -2
- package/dist/preview/chunk.T535ZLRM.js +1 -0
- package/dist/preview/{chunk.QGU5QTR6.js → chunk.UAVK54Z6.js} +1 -1
- package/dist/preview/{chunk.RD2X25XB.js → chunk.V4HVFLFQ.js} +1 -1
- package/dist/preview/chunk.V6IL7CIZ.js +1 -0
- package/dist/preview/{chunk.T6WHGKWR.js → chunk.VCTAFSZ5.js} +1 -1
- package/dist/preview/{chunk.OWOOKLIU.js → chunk.VZDHRY3U.js} +1 -1
- package/dist/preview/{chunk.X6KYRBL6.js → chunk.WBS7ND2C.js} +1 -1
- package/dist/preview/chunk.WNS5LEO5.js +1 -0
- package/dist/preview/chunk.WUVXIUA7.js +1 -0
- package/dist/preview/{chunk.Z2TDZSMN.js → chunk.WYPCLZL7.js} +1 -1
- package/dist/preview/{chunk.IQMD7DG3.js → chunk.XBYJCGPU.js} +1 -1
- package/dist/preview/{chunk.CHHYIMB7.js → chunk.XCEZCOX4.js} +1 -1
- package/dist/preview/{chunk.CY3ELWCM.js → chunk.XCWZFLIB.js} +1 -1
- package/dist/preview/chunk.XIW4SZHD.js +1 -0
- package/dist/preview/{chunk.FULEUL34.js → chunk.XUO67YMT.js} +1 -1
- package/dist/preview/{chunk.RYRQ66JN.js → chunk.XUXZW7DU.js} +1 -1
- package/dist/preview/chunk.XYGNS637.js +1 -0
- package/dist/preview/{chunk.H7N7WN4U.js → chunk.Y4ZM75WL.js} +1 -1
- package/dist/preview/{chunk.5STU3KYG.js → chunk.YOUB3J3Y.js} +1 -1
- package/dist/preview/{chunk.3FON2Y72.js → chunk.YXAKHXYB.js} +1 -1
- package/dist/preview/chunk.YZBJUAS6.js +1 -0
- package/dist/preview/{chunk.7V56P2A7.js → chunk.Z2ZQJ3DD.js} +1 -1
- package/dist/preview/{chunk.OFWNMTGB.js → chunk.ZELWW7UA.js} +2 -2
- package/dist/preview/{chunk.N6EJXXQK.js → chunk.ZLTHWCKL.js} +2 -2
- package/dist/preview/chunk.ZP7JEVVU.js +1 -0
- package/dist/preview/{chunk.NUWDMH47.js → chunk.ZRH5X3MR.js} +1 -1
- package/dist/preview/{chunk.DNVWSWL2.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.4TX6VCBT.js → chunk.ZZAI57VI.js} +1 -1
- package/dist/preview/index.html +53 -52
- package/dist/preview/page.js +2 -2
- package/dist/preview/splash.js +7 -6
- package/package.json +6 -6
- package/dist/preview/chunk.2AT3GRXM.js +0 -1
- package/dist/preview/chunk.4HRYB7HF.js +0 -1
- package/dist/preview/chunk.5MZYCELA.js +0 -6
- package/dist/preview/chunk.7OBIBPYH.js +0 -1
- package/dist/preview/chunk.7YOAW7ED.js +0 -1
- package/dist/preview/chunk.ACTXR2MI.js +0 -3
- package/dist/preview/chunk.AI34V6WV.js +0 -74
- package/dist/preview/chunk.CAKFNKN5.js +0 -1
- package/dist/preview/chunk.CGALLZ54.js +0 -1
- package/dist/preview/chunk.DHJ3FQTR.js +0 -1
- package/dist/preview/chunk.DZZL5IDD.js +0 -5
- package/dist/preview/chunk.H24OC6OE.js +0 -1
- package/dist/preview/chunk.H73ZPYUX.js +0 -1
- package/dist/preview/chunk.HANJZ6FA.js +0 -1
- package/dist/preview/chunk.HIMQ65QT.js +0 -1
- package/dist/preview/chunk.IQPILSV3.js +0 -18
- package/dist/preview/chunk.IYBEXENQ.js +0 -1
- package/dist/preview/chunk.J7Q2WAF4.js +0 -28
- package/dist/preview/chunk.JYFZCJ4N.js +0 -2
- package/dist/preview/chunk.KDXU5DT3.js +0 -1
- package/dist/preview/chunk.KL7E4YHJ.js +0 -1
- package/dist/preview/chunk.LAYQ5PFS.js +0 -1
- package/dist/preview/chunk.LTZUF5VG.js +0 -1
- package/dist/preview/chunk.M7RESZB6.js +0 -25
- package/dist/preview/chunk.MGALQLRW.js +0 -1
- package/dist/preview/chunk.NAD7ZXYP.js +0 -1
- package/dist/preview/chunk.NHTGAP3G.js +0 -3
- package/dist/preview/chunk.NUYA4BWI.js +0 -1
- package/dist/preview/chunk.OKZT2QBM.js +0 -2
- package/dist/preview/chunk.OUPURRDE.js +0 -1
- package/dist/preview/chunk.PD2DECOP.js +0 -1
- package/dist/preview/chunk.PKWQKFPE.js +0 -2
- package/dist/preview/chunk.RMR24LFJ.js +0 -4
- package/dist/preview/chunk.RRKI24WY.js +0 -1
- package/dist/preview/chunk.SGCW2XRC.js +0 -1
- package/dist/preview/chunk.SS7234R6.js +0 -1
- package/dist/preview/chunk.TKUNRFDE.js +0 -1
- package/dist/preview/chunk.U6ZRJKVM.js +0 -1
- package/dist/preview/chunk.UKQUUPKE.js +0 -1
- package/dist/preview/chunk.VC3V7HLL.js +0 -1
- package/dist/preview/chunk.VIH5AX7S.js +0 -5
- package/dist/preview/chunk.WKI5INH7.js +0 -1
- package/dist/preview/chunk.Y4S7CDRB.js +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as cn,c as un}from"./chunk.W4BKYSZX.js";import{j as x}from"./chunk.OKZT2QBM.js";import{c as Z}from"./chunk.ACTXR2MI.js";import{$b as E,Ec as U,_b as on,db as V,ga as H,hc as rn,ic as an,ja as T,ka as K,la as en,ma as tn,pa as sn,qa as J,ra as G,vc as Q,wd as dn}from"./chunk.DZZL5IDD.js";function fn(){return{name:"insight",derive({store:n,nodes:d,kindSelection:t}){let f=[],v=l=>T(n.schema.tryDefinition(l.kind),l);for(let l of d){if([...n.schema.edgeKinds].reduce((c,w)=>c+n.graph.out(l.id,w).length+n.graph.in(l.id,w).length,0)===0){f.push({id:`insight:island:${l.id}`,text:`${v(l)} is connected to nothing yet`,nodeIds:[l.id]});continue}for(let c of n.schema.edgeKinds){let w=n.graph.in(l.id,c).length;if(w<3)continue;let s=[...n.graph.allEdges()].filter(a=>a.kind===c),e=s.length;e>=4&&w/e>.6&&f.push({id:`insight:load:${l.id}:${c}`,text:`${v(l)} ${vn(n,s,c,w)}`,nodeIds:[l.id]})}}for(let l of t){if(n.graph.nodesOfKind(l).length>0)continue;let A=n.schema.definitions.filter(c=>c.kind!==l).filter(c=>Object.values(c.edges).some(w=>w.to!=="*"&&w.to.includes(l))).map(c=>c.plural??`${c.kind}s`);A.length>0&&f.push({id:`insight:gap:${l}`,text:`Nothing here yet, though ${A.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:f}}}}function vn(n,d,t,f){let v=new Set(d.map(s=>n.graph.getNode(s.from)?.kind).filter(s=>s!==void 0)),l=v.size===1?[...v][0]:void 0,A=d.length,c=Z(n.schema,l??[...v][0]??"",t,"in"),w=s=>l?en(n.schema,l,s):String(s);return f===A?`${c}: all ${w(f)}`:`${c}: ${f} of the ${w(A)}`}function ln(n){let d=new Map;if(n.length===0)return d;let t=n.slice(-512),f=new Set;for(let l of t)l.undoes&&f.add(l.undoes);let v=n[n.length-1].seq;for(let l of t){if(!l.mutation||f.has(l.id))continue;let A=Math.pow(.5,(v-l.seq)/64);d.set(l.mutation.name,(d.get(l.mutation.name)??0)+A)}return d}function hn(n){return 8*(n/(n+1))}var bn=100;function gn(){return{name:"invariant",derive({store:n,selection:d,nodes:t,violations:f}){let v=s=>T(n.schema.tryDefinition(s.kind),s),l=new Set(d),A=f.filter(s=>s.nodeIds.some(e=>l.has(e))||s.subjectId!==void 0&&l.has(s.subjectId)),c=[],w=[];A.forEach((s,e)=>{w.push({id:`violation:${s.invariant}:${e}`,text:s.message,nodeIds:s.nodeIds}),s.repairs.forEach((a,h)=>{c.push({id:`invariant:${s.invariant}:${e}:${h}`,label:a.label,provider:"invariant",mutation:a.mutation,args:a.args??{},open:(a.missing??[]).map(m=>{let r=n.allMutations().find(g=>g.name===a.mutation);if(!r)return{name:m};let o=E(r.input).find(g=>g.name===m),k=o?o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id)):void 0;return{name:m,shape:x(r.input,m),...o?{kinds:o.kinds}:{},...k?{candidates:k}:{}}}),score:bn-h-(a.missing?.length??0),why:s.message,nodeIds:s.nodeIds,...s.subjectId===void 0?{}:{subjectId:s.subjectId}})})});for(let s of t){let e=n.allInvariants().filter(a=>{if(a.scope==="graph")return!1;let h=a.scope;return h.kind!==s.kind?!1:h.match?h.match(s):!0});e.length!==0&&(A.some(a=>a.subjectId===s.id||a.nodeIds.includes(s.id))||w.push({id:`holds:${s.id}`,text:`${v(s)} holds \u2014 nothing currently breaks ${e.length===1?"it":`any of its ${e.length} rules`}`,nodeIds:[s.id]}))}return{affordances:c,observations:w}}}}var X=40;function pn(){return{name:"schema",derive({store:n,selection:d,nodes:t,kindSelection:f,edgeSelection:v,principal:l}){let A=(e,a)=>l!==void 0&&!n.permits({name:e,args:a},l).ok,c=[];if(t.length===0&&v.length>0){for(let e of v){let a=n.graph.getNode(e.from),h=n.graph.getNode(e.to);if(!a||!h)continue;let m=un(n,e);m?.provisional&&c.push({id:`schema:edge:${Q}:${e.kind}:${e.from}:${e.to}`,label:"Keep this link",provider:"schema",mutation:Q,args:{kind:e.kind,from:e.from,to:e.to},open:[],score:64,why:cn(m),nodeIds:[e.from,e.to]});for(let r of n.allMutations()){let o=(r.connects??[]).includes(e.kind),k=(r.severs??[]).includes(e.kind);if(!o&&!k||r.derived?.relation!==void 0&&r.derived.kind!==a.kind)continue;let g={},$=[],j=E(r.input);for(let p of j){let S=p.kinds.includes("*")||p.kinds.includes(a.kind),P=p.kinds.includes("*")||p.kinds.includes(h.kind),y=S&&!j.some(I=>I!==p&&(I.kinds.includes(a.kind)||I.kinds.includes("*")));S&&!P?g[p.name]=e.from:P&&!S?g[p.name]=e.to:S&&P&&y?g[p.name]=e.from:$.push({name:p.name,kinds:p.kinds,candidates:[e.from,e.to],shape:x(r.input,p.name)})}for(let p of q(r.input,""))p in g||$.some(S=>S.name===p)||$.push({name:p,shape:x(r.input,p)});$.every(p=>p.optional===!0?!0:p.kinds!==void 0?(p.candidates?.length??0)>0:(p.candidates?.length??0)>0||p.shape!==void 0&&p.shape.type!=="unknown")&&(o&&!k&&$.length===0||c.push({id:`schema:edge:${r.name}:${e.kind}:${e.from}:${e.to}`,label:K(r),provider:"schema",mutation:r.name,args:g,open:$,...r.destructive?{destructive:!0}:{},score:(k?62:58)-$.length,why:`this line is "${Z(n.schema,n.graph.getNode(e.from)?.kind??"",e.kind,"out")}"`,nodeIds:[e.from,e.to]}))}}return{affordances:c}}if(t.length===0&&f.length>0){let e=new Set(f),a=[];for(let h of n.allMutations()){if(!(h.creates??[]).some(o=>e.has(o)))continue;let m=[];for(let o of E(h.input)){let k=o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id));m.push({name:o.name,kinds:o.kinds,candidates:k,shape:x(h.input,o.name),...o.optional?{optional:!0}:{}})}for(let o of q(h.input,""))m.some(k=>k.name===o)||m.push({name:o,shape:x(h.input,o)});if(!m.every(o=>o.optional===!0?!0:o.kinds!==void 0?(o.candidates?.length??0)>0:(o.candidates?.length??0)>0||o.shape!==void 0&&o.shape.type!=="unknown")&&!A(h.name,{})){let o=m.filter(k=>k.optional!==!0&&k.kinds!==void 0&&!k.kinds.includes("*")&&(k.candidates?.length??0)===0);if(o.length>0){let k=[...new Set(o.flatMap(g=>g.kinds??[]))].map(g=>J(G(n.schema.tryDefinition(g),g)));a.push({id:`schema:waits:${h.name}`,text:`"${h.title??h.name}" cannot begin until there is ${k.length===1?k[0]:`${k.slice(0,-1).join(", ")} and ${k[k.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${h.name}`,label:K(h),provider:"schema",mutation:h.name,args:{},open:m,score:X-m.length,why:`this makes ${(h.creates??[]).filter(o=>e.has(o)).map(o=>J(G(n.schema.tryDefinition(o),o))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:a}}if(t.length===0)return{};let w=new Set(t.map(e=>e.kind)),s=(e,a,h)=>{let m=[];for(let r of n.graph.allEdges()){if(!a.includes(r.kind))continue;let o=r.from===e?r.to:r.to===e?r.from:null;if(!o)continue;let k=n.graph.getNode(o);k&&(!h.includes("*")&&!h.includes(k.kind)||m.includes(o)||m.push(o))}return m};for(let e of n.allMutations()){let a=e.subject;if(!a||!(a.kinds==="*"?!0:[...w].every(u=>a.kinds.includes(u))))continue;let m=e.derived?.act;if((m==="archive"||m==="merge")&&t.some(u=>V(u))||m==="unarchive"&&!t.some(u=>V(u))||m==="leave-alone"&&t.every(u=>U(n,u.id))||m==="allow-tidying"&&!t.some(u=>U(n,u.id)))continue;let r=t.length===1?t[0].id:null,o=e.severs??[],k=e.connects??[];if(r&&o.length>0&&k.length===0&&s(r,o,["*"]).length===0)continue;let g=[];for(let u of E(e.input)){if(u.name===a.arg)continue;let p=u.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):u.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(P=>P.id));if(r&&k.length>0){let S=new Set(s(r,k,u.kinds));p=p.filter(P=>!S.has(P))}else r&&o.length>0&&(p=s(r,o,u.kinds));g.push({name:u.name,kinds:u.kinds,candidates:p.filter(S=>!d.includes(S)),shape:x(e.input,u.name),...u.optional?{optional:!0}:{}})}for(let u of q(e.input,a.arg))g.some(p=>p.name===u)||g.push({name:u,shape:x(e.input,u)});if(g.length===0&&r){let u=Sn(e.input,a.arg);if(u.length>0&&!wn(n,e.name,{[a.arg]:r}))for(let p of u){let S=E(e.input).find(P=>P.name===p);g.push({name:p,optional:!0,...S?{kinds:S.kinds}:{},shape:x(e.input,p)})}}if(!g.every(u=>u.optional===!0?!0:u.kinds!==void 0?(u.candidates?.length??0)>0:(u.candidates?.length??0)>0||u.shape!==void 0&&u.shape.type!=="unknown")&&!A(e.name,r?{[a.arg]:r}:{}))continue;let j=t.map(u=>({[a.arg]:u.id}));g.length===0&&!j.some(u=>n.wouldChange({name:e.name,args:u}))||c.push({id:`schema:${e.name}`,label:t.length>1?`${K(e)} (${t.length})`:K(e),provider:"schema",mutation:e.name,args:j[0]??{},open:g,...e.destructive?{destructive:!0}:{},...e.derived?.act==="archive"||e.derived?.act==="merge"||e.derived?.act==="leave-alone"||e.derived?.act==="allow-tidying"?{setsAside:!0}:{},...o.length>0||k.length>0?{ties:!0}:{},...t.length>1?{batch:j}:{},score:X-g.length,why:t.length>1?`all ${t.length} selected nodes are ${[...w].map(u=>tn(n.schema,u).toLowerCase()).join(" or ")}`:`this is ${J(G(n.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(u=>u.id)})}if(t.length===1){let e=t[0];for(let a of n.allMutations()){let h=a.subject,m=a.severs??[],r=a.connects??[];if(!h||m.length===0&&r.length===0)continue;let o=h.kinds==="*"?"*":h.kinds;if(o==="*"||o.includes(e.kind))continue;let k=E(a.input),g=k.find(y=>y.name!==h.arg&&(y.kinds.includes("*")||y.kinds.includes(e.kind)));if(!g)continue;let $=o,j=$.includes("*")?n.graph.allNodes().map(y=>y.id):$.flatMap(y=>n.graph.nodesOfKind(y).map(I=>I.id)),u=new Set(s(e.id,r.length>0?r:m,$)),p=r.length>0?j.filter(y=>!u.has(y)):j.filter(y=>u.has(y));if(p.length===0)continue;let S=[{name:h.arg,kinds:$,candidates:p,shape:x(a.input,h.arg)}];for(let y of k){if(y.name===g.name||y.name===h.arg)continue;let I=y.kinds.includes("*")?n.graph.allNodes().map(L=>L.id):y.kinds.flatMap(L=>n.graph.nodesOfKind(L).map(O=>O.id));S.push({name:y.name,kinds:y.kinds,candidates:I,shape:x(a.input,y.name),...y.optional?{optional:!0}:{}})}for(let y of q(a.input,g.name))y===h.arg||S.some(I=>I.name===y)||S.push({name:y,shape:x(a.input,y)});S.every(y=>y.optional===!0?!0:y.kinds!==void 0?(y.candidates?.length??0)>0:(y.candidates?.length??0)>0||y.shape!==void 0&&y.shape.type!=="unknown")&&c.push({id:`schema:tie:${a.name}:${e.id}`,label:a.fromTheOtherEnd??K(a),provider:"schema",mutation:a.name,args:{[g.name]:e.id},open:S,ties:!0,...a.destructive?{destructive:!0}:{},score:X-S.length+2,why:`${m.length>0?"this one is on":"this one could join"} ${S[0].candidates.length===1?"it":"one of these"}`,nodeIds:[e.id]})}}return{affordances:c}}}}function Sn(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&v.safeParse(void 0).success).map(([f])=>f):[]}function wn(n,d,t){try{return n.preview({name:d,args:t}),!0}catch{return!1}}function q(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&!v.safeParse(void 0).success).map(([f])=>f):[]}var An=70,$n=80,On=new Set(["id","kind"]);function mn(){return{name:"structure",derive({store:n,nodes:d}){let t=c=>T(n.schema.tryDefinition(c.kind),c);if(d.length<2)return{};let f=[],v=[],l=d.map(c=>c.id);for(let c of n.schema.edgeKinds){let w=In(d.map(e=>new Set([...n.graph.out(e.id,c).map(a=>a.id),...n.graph.in(e.id,c).map(a=>a.id)])));for(let e of w){let a=n.graph.getNode(e);a&&f.push({id:`shared:${c}:${e}`,text:`all ${d.length} share "${t(a)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]})}let s=new Map;for(let e of d)for(let a of[...n.graph.out(e.id,c),...n.graph.in(e.id,c)])s.set(a.id,(s.get(a.id)??0)+1);for(let[e,a]of s){if(a!==d.length-1||d.length<3||l.includes(e))continue;let h=n.graph.getNode(e);if(!h)continue;let m=d.find(r=>![...n.graph.out(r.id,c),...n.graph.in(r.id,c)].some(o=>o.id===e));if(m&&(f.push({id:`near-shared:${c}:${e}`,text:`all but "${t(m)}" share "${t(h)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]}),!(!n.schema.edgeAllowed(c,m.kind,h.kind)&&!n.schema.edgeAllowed(c,h.kind,m.kind))))for(let r of n.allMutations()){let o=r.subject;if(!o||o.kinds!=="*"&&!o.kinds.includes(m.kind)||(r.connects!==void 0||r.severs!==void 0)&&!(r.connects??[]).includes(c))continue;let g=Pn(r.input,h.kind);g&&v.push({id:`structure:join:${r.name}:${m.id}:${e}`,label:`${K(r)}: bring "${t(m)}" in line with the others`,provider:"structure",mutation:r.name,args:{[o.arg]:m.id,[g]:e},open:[],score:An,why:`every other selected node is connected to "${t(h)}"`,nodeIds:[m.id,e]})}}}let A=new Map;for(let c of d)A.set(c.kind,[...A.get(c.kind)??[],c]);for(let[c,w]of A){if(w.length<2)continue;let s=w,e=w.map(r=>r.id),a=A.size>1?`${c}:`:"",h=new Set;for(let r of s)for(let o of Object.keys(r))On.has(o)||h.add(o);let m=r=>n.schema.definitions.find(o=>o.kind===r);for(let r of[...h].sort()){let o=m(s[0].kind),k=sn(o,r).toLowerCase(),g=o?.display?.format?.[r],$=O=>{if(!g)return O;try{return String(g(JSON.parse(O)))}catch{return O}},j=s.map(O=>O[r]),u=new Map;if(j.forEach((O,R)=>{let D=JSON.stringify(O??null),M=u.get(D);M?M.push(s[R]):u.set(D,[s[R]])}),u.size===1){let O=[...u.keys()][0];if(O==="null")continue;f.push({id:`agree:${a}${r}`,text:`all ${s.length} share the ${k} ${$(O)}`,nodeIds:e});continue}if(s.length<3||u.size!==2)continue;let p=[...u.entries()].sort((O,R)=>R[1].length-O[1].length),[S,P]=p[0],[,y]=p[1];if(y.length!==1||S==="null")continue;let I=y[0],L=JSON.parse(S);f.push({id:`odd-one-out:${a}${r}`,text:`${P.length} share the ${k} ${$(S)}; "${t(I)}" does not`,nodeIds:e});for(let O of n.allMutations()){let R=O.subject;if(!R||R.kinds!=="*"&&!R.kinds.includes(I.kind))continue;let D=kn(O.input);if(!D||!(r in D))continue;let M={[R.arg]:I.id,[r]:L},C=!0;for(let[W,z]of Object.entries(D)){if(W in M||z.safeParse(void 0).success)continue;let B=I[W];if(B===void 0){C=!1;break}M[W]=B}!C||!O.input.safeParse(M).success||v.push({id:`structure:align:${O.name}:${r}:${I.id}`,label:`Align the ${k} of "${t(I)}" with the other ${P.length}`,provider:"structure",mutation:O.name,args:M,open:[],score:$n,why:`${P.length} of ${s.length} share the ${k} ${$(S)}`,nodeIds:e})}}}return{affordances:v,observations:f}}}}function In(n){if(n.length===0)return[];let[d,...t]=n;return[...d].filter(f=>t.every(v=>v.has(f))).sort()}function kn(n){return n.shape??null}function Pn(n,d){let t=kn(n);if(!t)return null;for(let[f]of Object.entries(t)){let v=on(t[f]);if(v&&(v.includes("*")||v.includes(d)))return f}return null}function jn(){return[gn(),mn(),pn(),fn()]}function Xn(n,d,t={}){let f=yn(),v=t.providers??jn(),l=d.map(i=>n.graph.getNode(i)).filter(i=>i!==void 0),A={store:n,selection:d,nodes:l,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:n.violations(t.context),context:t.context??{},principal:t.principal??{kind:"human"}},c=[],w=[];for(let i of v){let b=i.derive(A);c.push(...b.affordances??[]),w.push(...b.observations??[])}let s=new Map(n.allMutations().map(i=>[i.name,i]));c.forEach((i,b)=>{let N=i.open.length>1?s.get(i.mutation):void 0;N&&(c[b]={...i,open:an(i.open,rn(n.schema,N))})});let e=new Set(n.allMutations().filter(i=>i.pinned).map(i=>i.name)),a=new Set(t.pins?.pinned??[]),h=new Set(t.pins?.unpinned??[]),m=i=>a.has(i.mutation)?"user":e.has(i.mutation)&&!h.has(i.mutation)?"declared":void 0,r=i=>{let b=m(i);return b?{...i,pinned:b}:i},o=new Map;for(let[i,b]of ln(n.log.all()))o.set(i,hn(b));let k=i=>i.pinned==="user"?0:i.pinned==="declared"?1:2,g=i=>i.score+(o.get(i.mutation)??0),$=new Map(n.allMutations().map(i=>[i.name,i])),j=new Map,u=i=>{let b=$.get(i.mutation);if(!b)return[];let N=j.get(i.mutation);N||(N=E(b.input).map(F=>F.name),j.set(i.mutation,N));let _=[];for(let F of i.batch??[i.args])for(let Y of N){let nn=F[Y]??i.args[Y];typeof nn=="string"&&_.push(nn)}return _},p=t.focus,S=4,P=i=>i.open.length>0?1:0,y=i=>{if(p===void 0)return S;let b=u(i);return b.length>0?b.includes(p)?I(i,0):S:i.nodeIds.includes(p)||i.subjectId===p?I(i,1):S},I=(i,b)=>i.provider==="invariant"?b:2+P(i),L=i=>i.setsAside?1:0,O=Nn(c).map(r),R=new Map(O.map((i,b)=>[i,b])),D=O.sort((i,b)=>{let N=Number(i.destructive??!1)-Number(b.destructive??!1);if(N!==0)return N;let _=L(i)-L(b);if(_!==0)return _;let F=y(i)-y(b);return F!==0?F:y(i)<2?R.get(i)-R.get(b):+(b.provider==="invariant")-+(i.provider==="invariant")||k(i)-k(b)||g(b)-g(i)||i.id.localeCompare(b.id)}),M=t.principal??{kind:"human"},C=[],W=[];for(let i of D){let b=n.permits({name:i.mutation,args:{...i.args,...i.batch?.[0]??{}}},M);if(b.ok)C.push(i);else{let N=Rn(n,i,M);if(N==="done")continue;N?C.push(N):W.push({...i,refusal:b.refusal})}}let z=C.map((i,b)=>({...i,rank:b})),B=W.map((i,b)=>({...i,rank:C.length+b}));return{affordances:t.limit===void 0?z:z.slice(0,t.limit),withheld:B,observations:xn(w),ms:yn()-f}}function Nn(n){let d=new Map;for(let t of n){let f=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),v=d.get(f);(!v||t.score>v.score)&&d.set(f,t)}return[...d.values()]}function xn(n){let d=new Map;for(let t of n)d.set(t.text,t);return[...d.values()]}function yn(){return typeof performance<"u"?performance.now():Date.now()}function Yn(n,d,t={},f={}){let v=(d.batch??[d.args]).map(A=>({name:d.mutation,args:{...d.args,...A,...t}})),l=n.allMutations().find(A=>A.name===d.mutation);return n.applyAll(v,{...l?.describe?{}:{intent:d.label},...f.author?{author:f.author}:{}})}function ne(n,d,t={},f={}){try{return n.preview({name:d.mutation,args:{...d.args,...t}})}catch(v){throw f.pressed&&dn(v,f.pressed.author?.id),v}}function Rn(n,d,t){let f=n.allMutations().find(s=>s.name===d.mutation)?.subject,v=f!==void 0&&d.args[f.arg]===void 0,l=v?d.open.find(s=>s.name===f.arg):d.open.find(s=>s.name!==f?.arg&&s.candidates);if(!l?.candidates)return;let A=s=>n.permits({name:d.mutation,args:{...d.args,...d.batch?.[0]??{},[l.name]:s}},t).ok,c=l.candidates.filter(A),w=t.id===void 0?void 0:n.graph.getNode(t.id);if(c.length===0){let s=v?f.kinds:"*";return w!==void 0&&(s==="*"||s.includes(w.kind))&&A(w.id)?"done":void 0}return c.length===1&&c[0]===t.id?{...d,args:{...d.args,[l.name]:t.id},open:d.open.filter(s=>s!==l)}:{...d,open:d.open.map(s=>s===l?{...s,candidates:c}:s)}}export{Xn as a,Yn as b,ne as c};
|
|
1
|
+
import{b as cn,c as un}from"./chunk.H7AH3IW4.js";import{j as x}from"./chunk.2KIWGQXC.js";import{c as Z}from"./chunk.D5LOTCBU.js";import{Ac as Q,Ed as dn,Mc as U,dc as on,ec as E,fb as V,ga as H,la as T,ma as K,mc as rn,na as en,nc as an,oa as tn,ra as sn,sa as J,ta as G}from"./chunk.Q4MI53KK.js";function fn(){return{name:"insight",derive({store:n,nodes:d,kindSelection:t}){let f=[],v=l=>T(n.schema.tryDefinition(l.kind),l);for(let l of d){if([...n.schema.edgeKinds].reduce((c,w)=>c+n.graph.out(l.id,w).length+n.graph.in(l.id,w).length,0)===0){f.push({id:`insight:island:${l.id}`,text:`${v(l)} is connected to nothing yet`,nodeIds:[l.id]});continue}for(let c of n.schema.edgeKinds){let w=n.graph.in(l.id,c).length;if(w<3)continue;let s=[...n.graph.allEdges()].filter(a=>a.kind===c),e=s.length;e>=4&&w/e>.6&&f.push({id:`insight:load:${l.id}:${c}`,text:`${v(l)} ${vn(n,s,c,w)}`,nodeIds:[l.id]})}}for(let l of t){if(n.graph.nodesOfKind(l).length>0)continue;let A=n.schema.definitions.filter(c=>c.kind!==l).filter(c=>Object.values(c.edges).some(w=>w.to!=="*"&&w.to.includes(l))).map(c=>c.plural??`${c.kind}s`);A.length>0&&f.push({id:`insight:gap:${l}`,text:`Nothing here yet, though ${A.join(" and ")} expect to connect to these`,nodeIds:[]})}return{observations:f}}}}function vn(n,d,t,f){let v=new Set(d.map(s=>n.graph.getNode(s.from)?.kind).filter(s=>s!==void 0)),l=v.size===1?[...v][0]:void 0,A=d.length,c=Z(n.schema,l??[...v][0]??"",t,"in"),w=s=>l?en(n.schema,l,s):String(s);return f===A?`${c}: all ${w(f)}`:`${c}: ${f} of the ${w(A)}`}function ln(n){let d=new Map;if(n.length===0)return d;let t=n.slice(-512),f=new Set;for(let l of t)l.undoes&&f.add(l.undoes);let v=n[n.length-1].seq;for(let l of t){if(!l.mutation||f.has(l.id))continue;let A=Math.pow(.5,(v-l.seq)/64);d.set(l.mutation.name,(d.get(l.mutation.name)??0)+A)}return d}function hn(n){return 8*(n/(n+1))}var bn=100;function gn(){return{name:"invariant",derive({store:n,selection:d,nodes:t,violations:f}){let v=s=>T(n.schema.tryDefinition(s.kind),s),l=new Set(d),A=f.filter(s=>s.nodeIds.some(e=>l.has(e))||s.subjectId!==void 0&&l.has(s.subjectId)),c=[],w=[];A.forEach((s,e)=>{w.push({id:`violation:${s.invariant}:${e}`,text:s.message,nodeIds:s.nodeIds}),s.repairs.forEach((a,h)=>{c.push({id:`invariant:${s.invariant}:${e}:${h}`,label:a.label,provider:"invariant",mutation:a.mutation,args:a.args??{},open:(a.missing??[]).map(m=>{let r=n.allMutations().find(g=>g.name===a.mutation);if(!r)return{name:m};let o=E(r.input).find(g=>g.name===m),k=o?o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id)):void 0;return{name:m,shape:x(r.input,m),...o?{kinds:o.kinds}:{},...k?{candidates:k}:{}}}),score:bn-h-(a.missing?.length??0),why:s.message,nodeIds:s.nodeIds,...s.subjectId===void 0?{}:{subjectId:s.subjectId}})})});for(let s of t){let e=n.allInvariants().filter(a=>{if(a.scope==="graph")return!1;let h=a.scope;return h.kind!==s.kind?!1:h.match?h.match(s):!0});e.length!==0&&(A.some(a=>a.subjectId===s.id||a.nodeIds.includes(s.id))||w.push({id:`holds:${s.id}`,text:`${v(s)} holds \u2014 nothing currently breaks ${e.length===1?"it":`any of its ${e.length} rules`}`,nodeIds:[s.id]}))}return{affordances:c,observations:w}}}}var X=40;function pn(){return{name:"schema",derive({store:n,selection:d,nodes:t,kindSelection:f,edgeSelection:v,principal:l}){let A=(e,a)=>l!==void 0&&!n.permits({name:e,args:a},l).ok,c=[];if(t.length===0&&v.length>0){for(let e of v){let a=n.graph.getNode(e.from),h=n.graph.getNode(e.to);if(!a||!h)continue;let m=un(n,e);m?.provisional&&c.push({id:`schema:edge:${Q}:${e.kind}:${e.from}:${e.to}`,label:"Keep this link",provider:"schema",mutation:Q,args:{kind:e.kind,from:e.from,to:e.to},open:[],score:64,why:cn(m),nodeIds:[e.from,e.to]});for(let r of n.allMutations()){let o=(r.connects??[]).includes(e.kind),k=(r.severs??[]).includes(e.kind);if(!o&&!k||r.derived?.relation!==void 0&&r.derived.kind!==a.kind)continue;let g={},$=[],j=E(r.input);for(let p of j){let S=p.kinds.includes("*")||p.kinds.includes(a.kind),P=p.kinds.includes("*")||p.kinds.includes(h.kind),y=S&&!j.some(I=>I!==p&&(I.kinds.includes(a.kind)||I.kinds.includes("*")));S&&!P?g[p.name]=e.from:P&&!S?g[p.name]=e.to:S&&P&&y?g[p.name]=e.from:$.push({name:p.name,kinds:p.kinds,candidates:[e.from,e.to],shape:x(r.input,p.name)})}for(let p of q(r.input,""))p in g||$.some(S=>S.name===p)||$.push({name:p,shape:x(r.input,p)});$.every(p=>p.optional===!0?!0:p.kinds!==void 0?(p.candidates?.length??0)>0:(p.candidates?.length??0)>0||p.shape!==void 0&&p.shape.type!=="unknown")&&(o&&!k&&$.length===0||c.push({id:`schema:edge:${r.name}:${e.kind}:${e.from}:${e.to}`,label:K(r),provider:"schema",mutation:r.name,args:g,open:$,...r.destructive?{destructive:!0}:{},score:(k?62:58)-$.length,why:`this line is "${Z(n.schema,n.graph.getNode(e.from)?.kind??"",e.kind,"out")}"`,nodeIds:[e.from,e.to]}))}}return{affordances:c}}if(t.length===0&&f.length>0){let e=new Set(f),a=[];for(let h of n.allMutations()){if(!(h.creates??[]).some(o=>e.has(o)))continue;let m=[];for(let o of E(h.input)){let k=o.kinds.includes("*")?n.graph.allNodes().map(g=>g.id):o.kinds.flatMap(g=>n.graph.nodesOfKind(g).map($=>$.id));m.push({name:o.name,kinds:o.kinds,candidates:k,shape:x(h.input,o.name),...o.optional?{optional:!0}:{}})}for(let o of q(h.input,""))m.some(k=>k.name===o)||m.push({name:o,shape:x(h.input,o)});if(!m.every(o=>o.optional===!0?!0:o.kinds!==void 0?(o.candidates?.length??0)>0:(o.candidates?.length??0)>0||o.shape!==void 0&&o.shape.type!=="unknown")&&!A(h.name,{})){let o=m.filter(k=>k.optional!==!0&&k.kinds!==void 0&&!k.kinds.includes("*")&&(k.candidates?.length??0)===0);if(o.length>0){let k=[...new Set(o.flatMap(g=>g.kinds??[]))].map(g=>J(G(n.schema.tryDefinition(g),g)));a.push({id:`schema:waits:${h.name}`,text:`"${h.title??h.name}" cannot begin until there is ${k.length===1?k[0]:`${k.slice(0,-1).join(", ")} and ${k[k.length-1]}`}.`,nodeIds:[]})}continue}c.push({id:`schema:add:${h.name}`,label:K(h),provider:"schema",mutation:h.name,args:{},open:m,score:X-m.length,why:`this makes ${(h.creates??[]).filter(o=>e.has(o)).map(o=>J(G(n.schema.tryDefinition(o),o))).join(", ")}`,nodeIds:[]})}return{affordances:c,observations:a}}if(t.length===0)return{};let w=new Set(t.map(e=>e.kind)),s=(e,a,h)=>{let m=[];for(let r of n.graph.allEdges()){if(!a.includes(r.kind))continue;let o=r.from===e?r.to:r.to===e?r.from:null;if(!o)continue;let k=n.graph.getNode(o);k&&(!h.includes("*")&&!h.includes(k.kind)||m.includes(o)||m.push(o))}return m};for(let e of n.allMutations()){let a=e.subject;if(!a||!(a.kinds==="*"?!0:[...w].every(u=>a.kinds.includes(u))))continue;let m=e.derived?.act;if((m==="archive"||m==="merge")&&t.some(u=>V(u))||m==="unarchive"&&!t.some(u=>V(u))||m==="leave-alone"&&t.every(u=>U(n,u.id))||m==="allow-tidying"&&!t.some(u=>U(n,u.id)))continue;let r=t.length===1?t[0].id:null,o=e.severs??[],k=e.connects??[];if(r&&o.length>0&&k.length===0&&s(r,o,["*"]).length===0)continue;let g=[];for(let u of E(e.input)){if(u.name===a.arg)continue;let p=u.kinds.includes("*")?n.graph.allNodes().map(S=>S.id):u.kinds.flatMap(S=>n.graph.nodesOfKind(S).map(P=>P.id));if(r&&k.length>0){let S=new Set(s(r,k,u.kinds));p=p.filter(P=>!S.has(P))}else r&&o.length>0&&(p=s(r,o,u.kinds));g.push({name:u.name,kinds:u.kinds,candidates:p.filter(S=>!d.includes(S)),shape:x(e.input,u.name),...u.optional?{optional:!0}:{}})}for(let u of q(e.input,a.arg))g.some(p=>p.name===u)||g.push({name:u,shape:x(e.input,u)});if(g.length===0&&r){let u=Sn(e.input,a.arg);if(u.length>0&&!wn(n,e.name,{[a.arg]:r}))for(let p of u){let S=E(e.input).find(P=>P.name===p);g.push({name:p,optional:!0,...S?{kinds:S.kinds}:{},shape:x(e.input,p)})}}if(!g.every(u=>u.optional===!0?!0:u.kinds!==void 0?(u.candidates?.length??0)>0:(u.candidates?.length??0)>0||u.shape!==void 0&&u.shape.type!=="unknown")&&!A(e.name,r?{[a.arg]:r}:{}))continue;let j=t.map(u=>({[a.arg]:u.id}));g.length===0&&!j.some(u=>n.wouldChange({name:e.name,args:u}))||c.push({id:`schema:${e.name}`,label:t.length>1?`${K(e)} (${t.length})`:K(e),provider:"schema",mutation:e.name,args:j[0]??{},open:g,...e.destructive?{destructive:!0}:{},...e.derived?.act==="archive"||e.derived?.act==="merge"||e.derived?.act==="leave-alone"||e.derived?.act==="allow-tidying"?{setsAside:!0}:{},...o.length>0||k.length>0?{ties:!0}:{},...t.length>1?{batch:j}:{},score:X-g.length,why:t.length>1?`all ${t.length} selected nodes are ${[...w].map(u=>tn(n.schema,u).toLowerCase()).join(" or ")}`:`this is ${J(G(n.schema.tryDefinition(t[0].kind),t[0].kind))}`,nodeIds:t.map(u=>u.id)})}if(t.length===1){let e=t[0];for(let a of n.allMutations()){let h=a.subject,m=a.severs??[],r=a.connects??[];if(!h||m.length===0&&r.length===0)continue;let o=h.kinds==="*"?"*":h.kinds;if(o==="*"||o.includes(e.kind))continue;let k=E(a.input),g=k.find(y=>y.name!==h.arg&&(y.kinds.includes("*")||y.kinds.includes(e.kind)));if(!g)continue;let $=o,j=$.includes("*")?n.graph.allNodes().map(y=>y.id):$.flatMap(y=>n.graph.nodesOfKind(y).map(I=>I.id)),u=new Set(s(e.id,r.length>0?r:m,$)),p=r.length>0?j.filter(y=>!u.has(y)):j.filter(y=>u.has(y));if(p.length===0)continue;let S=[{name:h.arg,kinds:$,candidates:p,shape:x(a.input,h.arg)}];for(let y of k){if(y.name===g.name||y.name===h.arg)continue;let I=y.kinds.includes("*")?n.graph.allNodes().map(L=>L.id):y.kinds.flatMap(L=>n.graph.nodesOfKind(L).map(O=>O.id));S.push({name:y.name,kinds:y.kinds,candidates:I,shape:x(a.input,y.name),...y.optional?{optional:!0}:{}})}for(let y of q(a.input,g.name))y===h.arg||S.some(I=>I.name===y)||S.push({name:y,shape:x(a.input,y)});S.every(y=>y.optional===!0?!0:y.kinds!==void 0?(y.candidates?.length??0)>0:(y.candidates?.length??0)>0||y.shape!==void 0&&y.shape.type!=="unknown")&&c.push({id:`schema:tie:${a.name}:${e.id}`,label:a.fromTheOtherEnd??K(a),provider:"schema",mutation:a.name,args:{[g.name]:e.id},open:S,ties:!0,...a.destructive?{destructive:!0}:{},score:X-S.length+2,why:`${m.length>0?"this one is on":"this one could join"} ${S[0].candidates.length===1?"it":"one of these"}`,nodeIds:[e.id]})}}return{affordances:c}}}}function Sn(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&v.safeParse(void 0).success).map(([f])=>f):[]}function wn(n,d,t){try{return n.preview({name:d,args:t}),!0}catch{return!1}}function q(n,d){let t=n.shape;return t?Object.entries(t).filter(([f,v])=>f!==d&&!v.safeParse(void 0).success).map(([f])=>f):[]}var An=70,$n=80,On=new Set(["id","kind"]);function mn(){return{name:"structure",derive({store:n,nodes:d}){let t=c=>T(n.schema.tryDefinition(c.kind),c);if(d.length<2)return{};let f=[],v=[],l=d.map(c=>c.id);for(let c of n.schema.edgeKinds){let w=In(d.map(e=>new Set([...n.graph.out(e.id,c).map(a=>a.id),...n.graph.in(e.id,c).map(a=>a.id)])));for(let e of w){let a=n.graph.getNode(e);a&&f.push({id:`shared:${c}:${e}`,text:`all ${d.length} share "${t(a)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]})}let s=new Map;for(let e of d)for(let a of[...n.graph.out(e.id,c),...n.graph.in(e.id,c)])s.set(a.id,(s.get(a.id)??0)+1);for(let[e,a]of s){if(a!==d.length-1||d.length<3||l.includes(e))continue;let h=n.graph.getNode(e);if(!h)continue;let m=d.find(r=>![...n.graph.out(r.id,c),...n.graph.in(r.id,c)].some(o=>o.id===e));if(m&&(f.push({id:`near-shared:${c}:${e}`,text:`all but "${t(m)}" share "${t(h)}" (${H(c).toLowerCase()})`,nodeIds:[...l,e]}),!(!n.schema.edgeAllowed(c,m.kind,h.kind)&&!n.schema.edgeAllowed(c,h.kind,m.kind))))for(let r of n.allMutations()){let o=r.subject;if(!o||o.kinds!=="*"&&!o.kinds.includes(m.kind)||(r.connects!==void 0||r.severs!==void 0)&&!(r.connects??[]).includes(c))continue;let g=Pn(r.input,h.kind);g&&v.push({id:`structure:join:${r.name}:${m.id}:${e}`,label:`${K(r)}: bring "${t(m)}" in line with the others`,provider:"structure",mutation:r.name,args:{[o.arg]:m.id,[g]:e},open:[],score:An,why:`every other selected node is connected to "${t(h)}"`,nodeIds:[m.id,e]})}}}let A=new Map;for(let c of d)A.set(c.kind,[...A.get(c.kind)??[],c]);for(let[c,w]of A){if(w.length<2)continue;let s=w,e=w.map(r=>r.id),a=A.size>1?`${c}:`:"",h=new Set;for(let r of s)for(let o of Object.keys(r))On.has(o)||h.add(o);let m=r=>n.schema.definitions.find(o=>o.kind===r);for(let r of[...h].sort()){let o=m(s[0].kind),k=sn(o,r).toLowerCase(),g=o?.display?.format?.[r],$=O=>{if(!g)return O;try{return String(g(JSON.parse(O)))}catch{return O}},j=s.map(O=>O[r]),u=new Map;if(j.forEach((O,R)=>{let D=JSON.stringify(O??null),M=u.get(D);M?M.push(s[R]):u.set(D,[s[R]])}),u.size===1){let O=[...u.keys()][0];if(O==="null")continue;f.push({id:`agree:${a}${r}`,text:`all ${s.length} share the ${k} ${$(O)}`,nodeIds:e});continue}if(s.length<3||u.size!==2)continue;let p=[...u.entries()].sort((O,R)=>R[1].length-O[1].length),[S,P]=p[0],[,y]=p[1];if(y.length!==1||S==="null")continue;let I=y[0],L=JSON.parse(S);f.push({id:`odd-one-out:${a}${r}`,text:`${P.length} share the ${k} ${$(S)}; "${t(I)}" does not`,nodeIds:e});for(let O of n.allMutations()){let R=O.subject;if(!R||R.kinds!=="*"&&!R.kinds.includes(I.kind))continue;let D=kn(O.input);if(!D||!(r in D))continue;let M={[R.arg]:I.id,[r]:L},C=!0;for(let[W,z]of Object.entries(D)){if(W in M||z.safeParse(void 0).success)continue;let B=I[W];if(B===void 0){C=!1;break}M[W]=B}!C||!O.input.safeParse(M).success||v.push({id:`structure:align:${O.name}:${r}:${I.id}`,label:`Align the ${k} of "${t(I)}" with the other ${P.length}`,provider:"structure",mutation:O.name,args:M,open:[],score:$n,why:`${P.length} of ${s.length} share the ${k} ${$(S)}`,nodeIds:e})}}}return{affordances:v,observations:f}}}}function In(n){if(n.length===0)return[];let[d,...t]=n;return[...d].filter(f=>t.every(v=>v.has(f))).sort()}function kn(n){return n.shape??null}function Pn(n,d){let t=kn(n);if(!t)return null;for(let[f]of Object.entries(t)){let v=on(t[f]);if(v&&(v.includes("*")||v.includes(d)))return f}return null}function jn(){return[gn(),mn(),pn(),fn()]}function Xn(n,d,t={}){let f=yn(),v=t.providers??jn(),l=d.map(i=>n.graph.getNode(i)).filter(i=>i!==void 0),A={store:n,selection:d,nodes:l,kindSelection:t.kindSelection??[],edgeSelection:t.edgeSelection??[],violations:n.violations(t.context),context:t.context??{},principal:t.principal??{kind:"human"}},c=[],w=[];for(let i of v){let b=i.derive(A);c.push(...b.affordances??[]),w.push(...b.observations??[])}let s=new Map(n.allMutations().map(i=>[i.name,i]));c.forEach((i,b)=>{let N=i.open.length>1?s.get(i.mutation):void 0;N&&(c[b]={...i,open:an(i.open,rn(n.schema,N))})});let e=new Set(n.allMutations().filter(i=>i.pinned).map(i=>i.name)),a=new Set(t.pins?.pinned??[]),h=new Set(t.pins?.unpinned??[]),m=i=>a.has(i.mutation)?"user":e.has(i.mutation)&&!h.has(i.mutation)?"declared":void 0,r=i=>{let b=m(i);return b?{...i,pinned:b}:i},o=new Map;for(let[i,b]of ln(n.log.all()))o.set(i,hn(b));let k=i=>i.pinned==="user"?0:i.pinned==="declared"?1:2,g=i=>i.score+(o.get(i.mutation)??0),$=new Map(n.allMutations().map(i=>[i.name,i])),j=new Map,u=i=>{let b=$.get(i.mutation);if(!b)return[];let N=j.get(i.mutation);N||(N=E(b.input).map(F=>F.name),j.set(i.mutation,N));let _=[];for(let F of i.batch??[i.args])for(let Y of N){let nn=F[Y]??i.args[Y];typeof nn=="string"&&_.push(nn)}return _},p=t.focus,S=4,P=i=>i.open.length>0?1:0,y=i=>{if(p===void 0)return S;let b=u(i);return b.length>0?b.includes(p)?I(i,0):S:i.nodeIds.includes(p)||i.subjectId===p?I(i,1):S},I=(i,b)=>i.provider==="invariant"?b:2+P(i),L=i=>i.setsAside?1:0,O=Nn(c).map(r),R=new Map(O.map((i,b)=>[i,b])),D=O.sort((i,b)=>{let N=Number(i.destructive??!1)-Number(b.destructive??!1);if(N!==0)return N;let _=L(i)-L(b);if(_!==0)return _;let F=y(i)-y(b);return F!==0?F:y(i)<2?R.get(i)-R.get(b):+(b.provider==="invariant")-+(i.provider==="invariant")||k(i)-k(b)||g(b)-g(i)||i.id.localeCompare(b.id)}),M=t.principal??{kind:"human"},C=[],W=[];for(let i of D){let b=n.permits({name:i.mutation,args:{...i.args,...i.batch?.[0]??{}}},M);if(b.ok)C.push(i);else{let N=Rn(n,i,M);if(N==="done")continue;N?C.push(N):W.push({...i,refusal:b.refusal})}}let z=C.map((i,b)=>({...i,rank:b})),B=W.map((i,b)=>({...i,rank:C.length+b}));return{affordances:t.limit===void 0?z:z.slice(0,t.limit),withheld:B,observations:xn(w),ms:yn()-f}}function Nn(n){let d=new Map;for(let t of n){let f=[t.mutation,JSON.stringify(t.args),JSON.stringify(t.batch??null)].join("|"),v=d.get(f);(!v||t.score>v.score)&&d.set(f,t)}return[...d.values()]}function xn(n){let d=new Map;for(let t of n)d.set(t.text,t);return[...d.values()]}function yn(){return typeof performance<"u"?performance.now():Date.now()}function Yn(n,d,t={},f={}){let v=(d.batch??[d.args]).map(A=>({name:d.mutation,args:{...d.args,...A,...t}})),l=n.allMutations().find(A=>A.name===d.mutation);return n.applyAll(v,{...l?.describe?{}:{intent:d.label},...f.author?{author:f.author}:{}})}function ne(n,d,t={},f={}){try{return n.preview({name:d.mutation,args:{...d.args,...t}})}catch(v){throw f.pressed&&dn(v,f.pressed.author?.id),v}}function Rn(n,d,t){let f=n.allMutations().find(s=>s.name===d.mutation)?.subject,v=f!==void 0&&d.args[f.arg]===void 0,l=v?d.open.find(s=>s.name===f.arg):d.open.find(s=>s.name!==f?.arg&&s.candidates);if(!l?.candidates)return;let A=s=>n.permits({name:d.mutation,args:{...d.args,...d.batch?.[0]??{},[l.name]:s}},t).ok,c=l.candidates.filter(A),w=t.id===void 0?void 0:n.graph.getNode(t.id);if(c.length===0){let s=v?f.kinds:"*";return w!==void 0&&(s==="*"||s.includes(w.kind))&&A(w.id)?"done":void 0}return c.length===1&&c[0]===t.id?{...d,args:{...d.args,[l.name]:t.id},open:d.open.filter(s=>s!==l)}:{...d,open:d.open.map(s=>s===l?{...s,candidates:c}:s)}}export{Xn as a,Yn as b,ne as c};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./chunk.GZHZLJBF.js";import{
|
|
1
|
+
import"./chunk.GZHZLJBF.js";import{o as D}from"./chunk.WUVXIUA7.js";import"./chunk.OJGHDWI6.js";import"./chunk.BN7C5ZYX.js";import"./chunk.REUMBCSV.js";import{a as $}from"./chunk.2KIWGQXC.js";import"./chunk.D5LOTCBU.js";import"./chunk.KZUMXT5J.js";import"./chunk.CGK2PY76.js";import{G as P,T as C}from"./chunk.CYTTZOYL.js";import"./chunk.SDO3U72B.js";import{Ua as w,Wa as R,_a as c,ba as S}from"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import{b as k}from"./chunk.AJZBJBMO.js";var m=k(P(),1);var e=k(C(),1),W=[["","Does not repeat"],["day","Daily"],["week","Weekly"],["month","Monthly"],["year","Yearly"]],E=r=>`${r}${r%100>=11&&r%100<=13?"th":["th","st","nd","rd"][r%10]??"th"}`,v={display:"flex",flexWrap:"wrap",gap:"6px 12px",alignItems:"center"};function N({value:r,onChange:d,start:p,label:s,name:l="repeat"}){let f=(0,m.useId)(),a=c(r)?r:void 0,i=typeof p=="string"&&/^\d{4}-\d{2}-\d{2}/.test(p)?p:void 0,u=i?w[new Date(`${i.slice(0,10)}T00:00:00Z`).getUTCDay()]:void 0,o=t=>{let n={...a??{every:"week"},...t};for(let b of Object.keys(n))n[b]===void 0&&delete n[b];d(n)},y=a?.every??"week",g=a?.on??(u?[u]:[]);return(0,e.jsxs)("fieldset",{"data-graview-part":"field","data-graview-field":"repeat","data-graview-repeat":l,style:{display:"grid",gap:8,border:"1px solid var(--graview-edge)",borderRadius:8,padding:"8px 12px",margin:0,minWidth:0},children:[(0,e.jsx)("legend",{"data-graview-part":"label",style:{padding:"0 4px"},children:s}),(0,e.jsxs)("div",{style:v,children:[(0,e.jsx)("label",{htmlFor:`${f}-every`,children:"Repeats"}),(0,e.jsx)("select",{id:`${f}-every`,name:`${l}.every`,value:a?.every??"",onChange:t=>{let n=t.target.value;d(n===""?void 0:{...a?.interval?{interval:a.interval}:{},...a?.until?{until:a.until}:{},every:n})},"data-graview-part":"control",children:W.map(([t,n])=>(0,e.jsx)("option",{value:t,children:n},t))}),a?(0,e.jsxs)("label",{style:v,children:["every",(0,e.jsx)("input",{type:"number",min:1,max:99,name:`${l}.interval`,"aria-label":`Every how many ${y}s`,value:a.interval??1,onChange:t=>o({interval:Number(t.target.value)>1?Math.min(99,Math.round(Number(t.target.value))):void 0}),style:{width:"4.5em"},"data-graview-part":"control"}),y,(a.interval??1)>1?"s":""]}):null]}),a?.every==="week"?(0,e.jsxs)("div",{role:"group","aria-label":"On",style:v,children:[(0,e.jsx)("span",{"aria-hidden":"true",children:"On"}),w.map((t,n)=>(0,e.jsxs)("label",{style:{display:"inline-flex",gap:4,alignItems:"center",minHeight:24},children:[(0,e.jsx)("input",{type:"checkbox",name:`${l}.on`,value:t,checked:g.includes(t),onChange:b=>{let h=w.filter(x=>x===t?b.target.checked:g.includes(x));o({on:h.length===0||h.length===1&&h[0]===u?void 0:h})}}),S(n,"short")]},t))]}):null,a?.every==="month"?(0,e.jsxs)("label",{style:v,children:["On",(0,e.jsxs)("select",{name:`${l}.on`,value:a.on?.[0]===-1?"last":"",onChange:t=>o({on:t.target.value==="last"?[-1]:void 0}),"data-graview-part":"control",children:[(0,e.jsx)("option",{value:"",children:i?`the ${E(Number(i.slice(8,10)))}`:"the same day"}),(0,e.jsx)("option",{value:"last",children:"the last day"})]})]}):null,a?(0,e.jsxs)("label",{style:v,children:["Until",(0,e.jsx)("input",{type:"date",name:`${l}.until`,value:a.until??"",onChange:t=>o({until:t.target.value||void 0}),"data-graview-part":"control"})]}):null,(0,e.jsx)("p",{"aria-live":"polite","data-graview-repeat-said":"",style:{margin:0,color:"var(--graview-ink-dim)",fontSize:"0.8125rem"},children:a?$(i??"",a):"Does not repeat"})]})}function K({nodeId:r,field:d,start:p,value:s,label:l}){let{fields:f,commit:a}=D(r),i=f.find(t=>t.field===R(d)&&t.takesValue&&t.open.length===0),[u,o]=(0,m.useState)(!1),[y,g]=(0,m.useState)(c(s)?s:void 0);return i?u?(0,e.jsxs)("form",{onSubmit:t=>{t.preventDefault(),o(!1),a(i,y??null)},style:{display:"grid",gap:6,marginTop:6},children:[(0,e.jsx)(N,{value:y,onChange:g,start:p,label:l,name:R(d)}),(0,e.jsxs)("div",{style:{display:"flex",gap:8},children:[(0,e.jsx)("button",{type:"submit","data-graview-repeat-keep":d,children:"Keep"}),(0,e.jsx)("button",{type:"button",onClick:()=>o(!1),children:"Cancel"})]})]}):(0,e.jsx)("button",{type:"button","data-graview-repeat-open":d,onClick:()=>(g(c(s)?s:void 0),o(!0)),style:{marginInlineStart:8,fontSize:"0.75rem",padding:"1px 8px",borderRadius:999,minHeight:24},children:c(s)?"Change how it repeats":"Repeat\u2026"}):null}export{K as RepeatEditor,N as RepeatPicker};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as I,j as M,k as O}from"./chunk.SWMDFXUX.js";import"./chunk.A3ZC2JBO.js";import{g as P}from"./chunk.NAD7ZXYP.js";import{l as D}from"./chunk.2GEJNG2U.js";import"./chunk.NUYA4BWI.js";import"./chunk.OKZT2QBM.js";import{b as C}from"./chunk.ACTXR2MI.js";import"./chunk.AI34V6WV.js";import"./chunk.G4ULQK64.js";import{G as q,T as F}from"./chunk.M7RESZB6.js";import"./chunk.SDO3U72B.js";import{hd as E,ja as L}from"./chunk.DZZL5IDD.js";import"./chunk.FQLNBIQ5.js";import{b as N}from"./chunk.AJZBJBMO.js";var f=N(q(),1);var n=N(F(),1),R=40,B=60;function T(l,o,s){return l.allNodes().filter(i=>i.kind===o).map(i=>i[s])}function Y(l){if(l.length<2)return[];let o=[...l].sort((a,d)=>a-d),s=o[o.length-1]-o[0];if(s<=0)return[];let i=Math.max(1,10**Math.floor(Math.log10(s/4))),e=s/4>=i*5?i*5:i,t=a=>Math.round(a/e)*e;return[...new Set([.2,.4,.6,.8].map(a=>t(o[Math.floor(a*(o.length-1))])))].filter(a=>a>0)}function _(l,o,s){let i=new Set(s.far??[]),e=new Map;for(let t of o.allNodes())i.has(t.kind)&&e.set(t.id,L(l.tryDefinition(t.kind),t));return[...e.entries()].map(([t,a])=>({id:t,label:a}))}function K(l,o,s){let i=_(l,o,s);return(i.length<=R?i:i.map(t=>({end:t,ties:o.out(t.id).length+o.in(t.id).length})).sort((t,a)=>a.ties-t.ties||t.end.label.localeCompare(a.end.label)).slice(0,R).map(t=>t.end)).sort((t,a)=>t.label.localeCompare(a.label))}function U(l,o,s){let i=[];for(let e of s.filters){let t=i.length;if(e.about==="is")for(let a of e.options??[])i.push({value:`is:${a}`,label:a,group:e.label,condition:{key:"is",value:a}});else if(e.about==="edge"){i.push({value:`${e.key}:*`,label:"anything",group:e.label,condition:{key:e.key,value:"*"}}),i.push({value:`${e.key}:none`,label:"nothing",group:e.label,condition:{key:e.key,value:"none"}});for(let a of K(l,o,e))i.push({value:`${e.key}:${a.id}`,label:a.label,group:e.label,condition:{key:e.key,value:a.id}})}else if(e.type==="date")for(let a of["before","after","on"])i.push({value:`${e.key}:${a}`,label:`${a}\u2026`,group:e.label,ask:{key:e.key,op:a,label:e.label}});else if(e.type==="number"){let a=l.tryDefinition(s.kind),d=Y(T(o,s.kind,e.key).filter(p=>typeof p=="number"));for(let p of["at-most","at-least"])for(let v of p==="at-most"?d:[...d].reverse())i.push({value:`${e.key}:${p}:${v}`,label:`${p==="at-most"?"at most":"at least"} ${C(a,e.key,v)}`,group:e.label,condition:{key:e.key,value:`${p}:${v}`}})}else if(e.type==="text"){let a=[...new Set(T(o,s.kind,e.key).filter(d=>typeof d=="string"&&d.length>0&&!d.includes(",")))].sort((d,p)=>d.localeCompare(p));if(a.length>=2&&a.length<=B)for(let d of a)i.push({value:`${e.key}:${d}`,label:d,group:e.label,condition:{key:e.key,value:d}})}else if(e.type==="boolean")i.push({value:`${e.key}:true`,label:"yes",group:e.label,condition:{key:e.key,value:"true"}}),i.push({value:`${e.key}:false`,label:"no",group:e.label,condition:{key:e.key,value:"false"}});else if(e.about==="via"){let a=l.tryDefinition(e.far?.[0]??"");for(let d of e.options??[])i.push({value:`${e.key}:${d}`,label:C(a,e.key.split(".")[1],d),group:e.label,condition:{key:e.key,value:d}})}else for(let a of e.options??[])i.push({value:`${e.key}:${a}`,label:C(l.tryDefinition(s.kind),e.key,a),group:e.label,condition:{key:e.key,value:a}});for(let a=t;a<i.length;a++)i[a]={...i[a],key:e.key}}return i}function V(l,o,s,i){let e=l.tryDefinition(o);return["at-most","at-least"].map(t=>({value:`${s.key}:${t}:${i}`,label:`${t==="at-most"?"at most":"at least"} ${C(e,s.key,i)}`,group:s.label,key:s.key,condition:{key:s.key,value:`${t}:${i}`}}))}function G(l){let o=l.trim().replace(/(?<=\d),(?=\d{3}\b)/g,"");return/^-?\d+(\.\d+)?$/.test(o)?Number(o):null}function j(l,o,s){let i=U(l,o,s);return s.filters.flatMap(e=>{let t=i.filter(d=>d.key===e.key);if(e.type==="number"&&e.about!=="edge")return[{key:e.key,label:e.label,entries:t,atNumber:d=>V(l,s.kind,e,d)}];if(t.length===0)return[];if(e.about!=="edge")return[{key:e.key,label:e.label,entries:t}];let a=_(l,o,e);return a.length<I?[{key:e.key,label:e.label,entries:t}]:[{key:e.key,label:e.label,entries:t.filter(d=>d.value===`${e.key}:*`||d.value===`${e.key}:none`),typed:[...a].sort((d,p)=>d.label.localeCompare(p.label))}]})}var z=8;function H(l,o){let s=o.trim().toLocaleLowerCase();if(!s)return{shown:[],more:0};let e=[...l.filter(t=>t.label.toLocaleLowerCase().includes(s))].sort((t,a)=>+!t.label.toLocaleLowerCase().startsWith(s)-+!a.label.toLocaleLowerCase().startsWith(s));return{shown:e.slice(0,z),more:Math.max(0,e.length-z)}}var J=["day","week","month","year","decade"];function ie(l){let{which:o,schema:s,graph:i,offers:e,arrangement:t,set:a,toggle:d,has:p,done:v}=l,m=l.testId,A=(0,f.useRef)(null);(0,f.useEffect)(()=>{let u=A.current?.closest("[data-graview-popover]");!u||document.activeElement!==u||(u.querySelector('[aria-pressed="true"]')??u.querySelector("button, input"))?.focus({preventScroll:!0})},[]);let y=t.sort?e.sorts.find(u=>u.key===t.sort.by):void 0,S=t.group?e.groups.find(u=>u.key===t.group.by):void 0,b=O(y),r=e.natural?e.sorts.find(u=>u.key===e.natural.by):void 0,k=o==="filter"||o==="all"&&l.parts?.filter?j(s,i,e):[],w=u=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:"Sort by"}),(0,n.jsx)($,{testId:`${m}-sort-default`,value:"",on:!t.sort,onPress:()=>(a({sort:void 0}),u()),children:r?`As declared (${M(r.label)})`:"As they were added"}),e.sorts.map(g=>(0,n.jsx)($,{value:g.key,on:t.sort?.by===g.key,onPress:()=>(a({sort:{by:g.key,direction:t.sort?.direction??"asc"}}),u()),children:g.label},g.key)),t.sort?(0,n.jsxs)("div",{role:"group","aria-label":"Order","data-testid":`${m}-direction`,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:"Order"}),["asc","desc"].map(g=>(0,n.jsx)($,{testId:`${m}-direction-${g}`,value:g,on:t.sort.direction===g,onPress:()=>(a({sort:{by:t.sort.by,direction:g}}),u()),children:b[g]},g))]}):null]}),c=u=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:"Group by"}),(0,n.jsx)($,{testId:`${m}-group-none`,value:"",on:!t.group,onPress:()=>(a({group:void 0}),u()),children:"Not grouped"}),e.groups.map(g=>(0,n.jsx)($,{value:g.key,on:t.group?.by===g.key,onPress:()=>(a({group:{by:g.key}}),u()),children:g.label},g.key)),t.group&&S?.buckets?(0,n.jsxs)("div",{role:"group","aria-label":"How wide a group is","data-testid":`${m}-bucket`,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:"Each group"}),J.map(g=>(0,n.jsx)($,{testId:`${m}-bucket-${g}`,value:g,on:(t.group.bucket??"day")===g,onPress:()=>(a({group:{by:t.group.by,bucket:g}}),u()),children:`A ${g}`},g))]}):null]}),x=u=>(0,n.jsx)(Q,{sections:k,has:p,testId:m,onToggle:g=>(d(g),u())}),h=l.parts??{sort:!0,group:!0,filter:!0};return(0,n.jsxs)("div",{ref:A,style:{display:"contents"},children:[(0,n.jsx)("style",{children:Z}),o==="sort"?w(v):o==="group"?c(v):o==="filter"?x(v):(0,n.jsxs)(n.Fragment,{children:[h.sort?(0,n.jsx)("div",{role:"group","aria-label":"Sort",children:w(v)}):null,h.group?(0,n.jsx)("div",{role:"group","aria-label":"Group",children:c(v)}):null,h.filter?(0,n.jsx)("div",{role:"group","aria-label":"Filter",children:x(v)}):null]})]})}function $({value:l,on:o,onPress:s,testId:i,children:e}){return(0,n.jsx)("button",{type:"button",className:"graview-arrange-item",value:l,"data-value":l,"aria-pressed":o,onClick:s,...i?{"data-testid":i}:{},children:e})}function Q({sections:l,has:o,testId:s,onToggle:i}){let[e,t]=(0,f.useState)(null),[a,d]=(0,f.useState)(""),[p,v]=(0,f.useState)(()=>new Set(l.length===1?[l[0].key]:[])),[m,A]=(0,f.useState)({});if(e)return(0,n.jsx)(X,{ask:e,testId:s,onDay:r=>i({key:e.key,value:`${e.op}:${r}`}),onCancel:()=>t(null)});let y=r=>(0,n.jsx)($,{value:r.value,on:r.condition?o(r.condition):!1,onPress:()=>r.condition?i(r.condition):t(r.ask),children:r.label},r.value),S=(r,k)=>{let w=(r.typed??[]).filter(h=>o({key:r.key,value:h.id})),c=H(r.typed??[],k),x=[...w,...c.shown.filter(h=>!w.includes(h))];return(0,n.jsxs)(n.Fragment,{children:[x.map(h=>y({value:`${r.key}:${h.id}`,label:h.label,group:r.label,key:r.key,condition:{key:r.key,value:h.id}})),k.trim()&&c.shown.length===0?(0,n.jsx)("span",{className:"graview-arrange-none",children:"None is called that."}):null,c.more>0?(0,n.jsx)("span",{className:"graview-arrange-none",children:`${c.more} more \u2014 type more of the name`}):null]})},b=a.trim().toLocaleLowerCase();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"graview-arrange-find",children:[(0,n.jsx)("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:"Find a filter"}),(0,n.jsx)("input",{type:"search","data-testid":`${s}-filter-find`,value:a,placeholder:"Find a filter, a name or a number\u2026",onChange:r=>d(r.target.value)})]}),l.map(r=>{let k=r.entries.filter(c=>c.condition&&o(c.condition)).length+(r.typed??[]).filter(c=>o({key:r.key,value:c.id})).length;if(b){let c=r.label.toLocaleLowerCase().includes(b),x=r.atNumber&&G(b)!==null?r.atNumber(G(b)):[],h=[...x,...c?r.entries:r.entries.filter(g=>g.label.toLocaleLowerCase().includes(b)&&!x.some(W=>W.value===g.value))],u=r.typed?H(r.typed,b):{shown:[],more:0};return h.length===0&&u.shown.length===0?null:(0,n.jsxs)("div",{role:"group","aria-label":r.label,"data-section":r.key,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:r.label}),h.map(y),r.typed?S(r,b):null]},r.key)}if(r.entries.length===0&&!r.typed)return null;let w=p.has(r.key);return(0,n.jsxs)("div",{role:"group","aria-label":r.label,"data-section":r.key,children:[(0,n.jsxs)("button",{type:"button",className:"graview-arrange-section","data-testid":`${s}-section`,"data-key":r.key,"aria-expanded":w,onClick:()=>v(c=>c.has(r.key)?new Set([...c].filter(x=>x!==r.key)):new Set([...c,r.key])),children:[(0,n.jsx)("span",{children:r.label}),k>0?(0,n.jsx)("span",{className:"graview-arrange-on",children:`${k} on`}):null]}),w?(0,n.jsxs)(n.Fragment,{children:[r.typed?(0,n.jsx)("input",{type:"search",className:"graview-arrange-far","data-testid":`${s}-far-find`,"data-key":r.key,"aria-label":`${r.label}: type a name`,placeholder:`Type a name (${r.typed.length})\u2026`,autoFocus:!0,value:m[r.key]??"",onChange:c=>A({...m,[r.key]:c.target.value})}):null,r.entries.map(y),r.typed?S(r,m[r.key]??""):null]}):null]},r.key)})]})}function X({ask:l,testId:o,onDay:s,onCancel:i}){let[e,t]=(0,f.useState)(""),a=/^\d{4}-\d{2}-\d{2}$/.test(e)&&Number(e.slice(0,4))>=1e3,d=()=>{a&&s(e)};return(0,n.jsxs)("div",{role:"group","aria-label":`${l.label} ${l.op} which day`,"data-testid":`${o}-ask-day`,className:"graview-arrange-ask",children:[(0,n.jsx)("p",{"aria-hidden":"true",children:`${l.label} ${l.op}`}),(0,n.jsx)("input",{type:"date","data-testid":`${o}-day`,"aria-label":`${l.label} ${l.op} which day`,autoFocus:!0,value:e,onChange:p=>t(p.target.value),onKeyDown:p=>{p.key==="Enter"?(p.preventDefault(),d()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),p.nativeEvent.stopImmediatePropagation(),i())}}),(0,n.jsxs)("span",{children:[(0,n.jsx)("button",{type:"button","data-testid":`${o}-day-add`,disabled:!a,onClick:d,children:"Add"}),(0,n.jsx)("button",{type:"button",onClick:i,children:"Never mind"})]})]})}var Z=`
|
|
1
|
+
import{a as I,j as M,k as O}from"./chunk.QAMW5QDT.js";import"./chunk.B5PJCYBU.js";import{g as P}from"./chunk.Q2EGESEZ.js";import{l as D}from"./chunk.SMHP2CQH.js";import"./chunk.REUMBCSV.js";import"./chunk.2KIWGQXC.js";import{b as C}from"./chunk.D5LOTCBU.js";import"./chunk.KZUMXT5J.js";import"./chunk.CGK2PY76.js";import{G as q,T as F}from"./chunk.CYTTZOYL.js";import"./chunk.SDO3U72B.js";import{la as L,pd as E}from"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import{b as N}from"./chunk.AJZBJBMO.js";var f=N(q(),1);var n=N(F(),1),R=40,B=60;function T(l,o,s){return l.allNodes().filter(i=>i.kind===o).map(i=>i[s])}function Y(l){if(l.length<2)return[];let o=[...l].sort((a,d)=>a-d),s=o[o.length-1]-o[0];if(s<=0)return[];let i=Math.max(1,10**Math.floor(Math.log10(s/4))),e=s/4>=i*5?i*5:i,t=a=>Math.round(a/e)*e;return[...new Set([.2,.4,.6,.8].map(a=>t(o[Math.floor(a*(o.length-1))])))].filter(a=>a>0)}function _(l,o,s){let i=new Set(s.far??[]),e=new Map;for(let t of o.allNodes())i.has(t.kind)&&e.set(t.id,L(l.tryDefinition(t.kind),t));return[...e.entries()].map(([t,a])=>({id:t,label:a}))}function K(l,o,s){let i=_(l,o,s);return(i.length<=R?i:i.map(t=>({end:t,ties:o.out(t.id).length+o.in(t.id).length})).sort((t,a)=>a.ties-t.ties||t.end.label.localeCompare(a.end.label)).slice(0,R).map(t=>t.end)).sort((t,a)=>t.label.localeCompare(a.label))}function U(l,o,s){let i=[];for(let e of s.filters){let t=i.length;if(e.about==="is")for(let a of e.options??[])i.push({value:`is:${a}`,label:a,group:e.label,condition:{key:"is",value:a}});else if(e.about==="edge"){i.push({value:`${e.key}:*`,label:"anything",group:e.label,condition:{key:e.key,value:"*"}}),i.push({value:`${e.key}:none`,label:"nothing",group:e.label,condition:{key:e.key,value:"none"}});for(let a of K(l,o,e))i.push({value:`${e.key}:${a.id}`,label:a.label,group:e.label,condition:{key:e.key,value:a.id}})}else if(e.type==="date")for(let a of["before","after","on"])i.push({value:`${e.key}:${a}`,label:`${a}\u2026`,group:e.label,ask:{key:e.key,op:a,label:e.label}});else if(e.type==="number"){let a=l.tryDefinition(s.kind),d=Y(T(o,s.kind,e.key).filter(p=>typeof p=="number"));for(let p of["at-most","at-least"])for(let v of p==="at-most"?d:[...d].reverse())i.push({value:`${e.key}:${p}:${v}`,label:`${p==="at-most"?"at most":"at least"} ${C(a,e.key,v)}`,group:e.label,condition:{key:e.key,value:`${p}:${v}`}})}else if(e.type==="text"){let a=[...new Set(T(o,s.kind,e.key).filter(d=>typeof d=="string"&&d.length>0&&!d.includes(",")))].sort((d,p)=>d.localeCompare(p));if(a.length>=2&&a.length<=B)for(let d of a)i.push({value:`${e.key}:${d}`,label:d,group:e.label,condition:{key:e.key,value:d}})}else if(e.type==="boolean")i.push({value:`${e.key}:true`,label:"yes",group:e.label,condition:{key:e.key,value:"true"}}),i.push({value:`${e.key}:false`,label:"no",group:e.label,condition:{key:e.key,value:"false"}});else if(e.about==="via"){let a=l.tryDefinition(e.far?.[0]??"");for(let d of e.options??[])i.push({value:`${e.key}:${d}`,label:C(a,e.key.split(".")[1],d),group:e.label,condition:{key:e.key,value:d}})}else for(let a of e.options??[])i.push({value:`${e.key}:${a}`,label:C(l.tryDefinition(s.kind),e.key,a),group:e.label,condition:{key:e.key,value:a}});for(let a=t;a<i.length;a++)i[a]={...i[a],key:e.key}}return i}function V(l,o,s,i){let e=l.tryDefinition(o);return["at-most","at-least"].map(t=>({value:`${s.key}:${t}:${i}`,label:`${t==="at-most"?"at most":"at least"} ${C(e,s.key,i)}`,group:s.label,key:s.key,condition:{key:s.key,value:`${t}:${i}`}}))}function G(l){let o=l.trim().replace(/(?<=\d),(?=\d{3}\b)/g,"");return/^-?\d+(\.\d+)?$/.test(o)?Number(o):null}function j(l,o,s){let i=U(l,o,s);return s.filters.flatMap(e=>{let t=i.filter(d=>d.key===e.key);if(e.type==="number"&&e.about!=="edge")return[{key:e.key,label:e.label,entries:t,atNumber:d=>V(l,s.kind,e,d)}];if(t.length===0)return[];if(e.about!=="edge")return[{key:e.key,label:e.label,entries:t}];let a=_(l,o,e);return a.length<I?[{key:e.key,label:e.label,entries:t}]:[{key:e.key,label:e.label,entries:t.filter(d=>d.value===`${e.key}:*`||d.value===`${e.key}:none`),typed:[...a].sort((d,p)=>d.label.localeCompare(p.label))}]})}var z=8;function H(l,o){let s=o.trim().toLocaleLowerCase();if(!s)return{shown:[],more:0};let e=[...l.filter(t=>t.label.toLocaleLowerCase().includes(s))].sort((t,a)=>+!t.label.toLocaleLowerCase().startsWith(s)-+!a.label.toLocaleLowerCase().startsWith(s));return{shown:e.slice(0,z),more:Math.max(0,e.length-z)}}var J=["day","week","month","year","decade"];function ie(l){let{which:o,schema:s,graph:i,offers:e,arrangement:t,set:a,toggle:d,has:p,done:v}=l,m=l.testId,A=(0,f.useRef)(null);(0,f.useEffect)(()=>{let u=A.current?.closest("[data-graview-popover]");!u||document.activeElement!==u||(u.querySelector('[aria-pressed="true"]')??u.querySelector("button, input"))?.focus({preventScroll:!0})},[]);let y=t.sort?e.sorts.find(u=>u.key===t.sort.by):void 0,S=t.group?e.groups.find(u=>u.key===t.group.by):void 0,b=O(y),r=e.natural?e.sorts.find(u=>u.key===e.natural.by):void 0,k=o==="filter"||o==="all"&&l.parts?.filter?j(s,i,e):[],w=u=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:"Sort by"}),(0,n.jsx)($,{testId:`${m}-sort-default`,value:"",on:!t.sort,onPress:()=>(a({sort:void 0}),u()),children:r?`As declared (${M(r.label)})`:"As they were added"}),e.sorts.map(g=>(0,n.jsx)($,{value:g.key,on:t.sort?.by===g.key,onPress:()=>(a({sort:{by:g.key,direction:t.sort?.direction??"asc"}}),u()),children:g.label},g.key)),t.sort?(0,n.jsxs)("div",{role:"group","aria-label":"Order","data-testid":`${m}-direction`,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:"Order"}),["asc","desc"].map(g=>(0,n.jsx)($,{testId:`${m}-direction-${g}`,value:g,on:t.sort.direction===g,onPress:()=>(a({sort:{by:t.sort.by,direction:g}}),u()),children:b[g]},g))]}):null]}),c=u=>(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)("p",{children:"Group by"}),(0,n.jsx)($,{testId:`${m}-group-none`,value:"",on:!t.group,onPress:()=>(a({group:void 0}),u()),children:"Not grouped"}),e.groups.map(g=>(0,n.jsx)($,{value:g.key,on:t.group?.by===g.key,onPress:()=>(a({group:{by:g.key}}),u()),children:g.label},g.key)),t.group&&S?.buckets?(0,n.jsxs)("div",{role:"group","aria-label":"How wide a group is","data-testid":`${m}-bucket`,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:"Each group"}),J.map(g=>(0,n.jsx)($,{testId:`${m}-bucket-${g}`,value:g,on:(t.group.bucket??"day")===g,onPress:()=>(a({group:{by:t.group.by,bucket:g}}),u()),children:`A ${g}`},g))]}):null]}),x=u=>(0,n.jsx)(Q,{sections:k,has:p,testId:m,onToggle:g=>(d(g),u())}),h=l.parts??{sort:!0,group:!0,filter:!0};return(0,n.jsxs)("div",{ref:A,style:{display:"contents"},children:[(0,n.jsx)("style",{children:Z}),o==="sort"?w(v):o==="group"?c(v):o==="filter"?x(v):(0,n.jsxs)(n.Fragment,{children:[h.sort?(0,n.jsx)("div",{role:"group","aria-label":"Sort",children:w(v)}):null,h.group?(0,n.jsx)("div",{role:"group","aria-label":"Group",children:c(v)}):null,h.filter?(0,n.jsx)("div",{role:"group","aria-label":"Filter",children:x(v)}):null]})]})}function $({value:l,on:o,onPress:s,testId:i,children:e}){return(0,n.jsx)("button",{type:"button",className:"graview-arrange-item",value:l,"data-value":l,"aria-pressed":o,onClick:s,...i?{"data-testid":i}:{},children:e})}function Q({sections:l,has:o,testId:s,onToggle:i}){let[e,t]=(0,f.useState)(null),[a,d]=(0,f.useState)(""),[p,v]=(0,f.useState)(()=>new Set(l.length===1?[l[0].key]:[])),[m,A]=(0,f.useState)({});if(e)return(0,n.jsx)(X,{ask:e,testId:s,onDay:r=>i({key:e.key,value:`${e.op}:${r}`}),onCancel:()=>t(null)});let y=r=>(0,n.jsx)($,{value:r.value,on:r.condition?o(r.condition):!1,onPress:()=>r.condition?i(r.condition):t(r.ask),children:r.label},r.value),S=(r,k)=>{let w=(r.typed??[]).filter(h=>o({key:r.key,value:h.id})),c=H(r.typed??[],k),x=[...w,...c.shown.filter(h=>!w.includes(h))];return(0,n.jsxs)(n.Fragment,{children:[x.map(h=>y({value:`${r.key}:${h.id}`,label:h.label,group:r.label,key:r.key,condition:{key:r.key,value:h.id}})),k.trim()&&c.shown.length===0?(0,n.jsx)("span",{className:"graview-arrange-none",children:"None is called that."}):null,c.more>0?(0,n.jsx)("span",{className:"graview-arrange-none",children:`${c.more} more \u2014 type more of the name`}):null]})},b=a.trim().toLocaleLowerCase();return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsxs)("label",{className:"graview-arrange-find",children:[(0,n.jsx)("span",{style:{position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"},children:"Find a filter"}),(0,n.jsx)("input",{type:"search","data-testid":`${s}-filter-find`,value:a,placeholder:"Find a filter, a name or a number\u2026",onChange:r=>d(r.target.value)})]}),l.map(r=>{let k=r.entries.filter(c=>c.condition&&o(c.condition)).length+(r.typed??[]).filter(c=>o({key:r.key,value:c.id})).length;if(b){let c=r.label.toLocaleLowerCase().includes(b),x=r.atNumber&&G(b)!==null?r.atNumber(G(b)):[],h=[...x,...c?r.entries:r.entries.filter(g=>g.label.toLocaleLowerCase().includes(b)&&!x.some(W=>W.value===g.value))],u=r.typed?H(r.typed,b):{shown:[],more:0};return h.length===0&&u.shown.length===0?null:(0,n.jsxs)("div",{role:"group","aria-label":r.label,"data-section":r.key,children:[(0,n.jsx)("p",{"aria-hidden":"true",children:r.label}),h.map(y),r.typed?S(r,b):null]},r.key)}if(r.entries.length===0&&!r.typed)return null;let w=p.has(r.key);return(0,n.jsxs)("div",{role:"group","aria-label":r.label,"data-section":r.key,children:[(0,n.jsxs)("button",{type:"button",className:"graview-arrange-section","data-testid":`${s}-section`,"data-key":r.key,"aria-expanded":w,onClick:()=>v(c=>c.has(r.key)?new Set([...c].filter(x=>x!==r.key)):new Set([...c,r.key])),children:[(0,n.jsx)("span",{children:r.label}),k>0?(0,n.jsx)("span",{className:"graview-arrange-on",children:`${k} on`}):null]}),w?(0,n.jsxs)(n.Fragment,{children:[r.typed?(0,n.jsx)("input",{type:"search",className:"graview-arrange-far","data-testid":`${s}-far-find`,"data-key":r.key,"aria-label":`${r.label}: type a name`,placeholder:`Type a name (${r.typed.length})\u2026`,autoFocus:!0,value:m[r.key]??"",onChange:c=>A({...m,[r.key]:c.target.value})}):null,r.entries.map(y),r.typed?S(r,m[r.key]??""):null]}):null]},r.key)})]})}function X({ask:l,testId:o,onDay:s,onCancel:i}){let[e,t]=(0,f.useState)(""),a=/^\d{4}-\d{2}-\d{2}$/.test(e)&&Number(e.slice(0,4))>=1e3,d=()=>{a&&s(e)};return(0,n.jsxs)("div",{role:"group","aria-label":`${l.label} ${l.op} which day`,"data-testid":`${o}-ask-day`,className:"graview-arrange-ask",children:[(0,n.jsx)("p",{"aria-hidden":"true",children:`${l.label} ${l.op}`}),(0,n.jsx)("input",{type:"date","data-testid":`${o}-day`,"aria-label":`${l.label} ${l.op} which day`,autoFocus:!0,value:e,onChange:p=>t(p.target.value),onKeyDown:p=>{p.key==="Enter"?(p.preventDefault(),d()):p.key==="Escape"&&(p.preventDefault(),p.stopPropagation(),p.nativeEvent.stopImmediatePropagation(),i())}}),(0,n.jsxs)("span",{children:[(0,n.jsx)("button",{type:"button","data-testid":`${o}-day-add`,disabled:!a,onClick:d,children:"Add"}),(0,n.jsx)("button",{type:"button",onClick:i,children:"Never mind"})]})]})}var Z=`
|
|
2
2
|
.graview-arrange-list{display:grid;align-content:start;width:min(300px,calc(100vw - 24px));height:auto;max-height:min(70vh,520px);overflow:auto;overscroll-behavior:contain;margin:0;padding:0 6px 6px;border-radius:10px;border:1px solid var(--graview-edge);background:linear-gradient(var(--graview-float),var(--graview-float)),var(--graview-panel);box-shadow:var(--graview-lift-high);color:var(--graview-ink);font-size:.875rem;line-height:1.3}
|
|
3
3
|
.graview-arrange-list>*:first-child:not(.graview-arrange-find){margin-top:6px}
|
|
4
4
|
@media (max-width:519px){.graview-arrange-list{left:0!important;right:0!important;top:auto!important;bottom:0!important;width:100%!important;max-height:min(80dvh,560px)!important;border-radius:14px 14px 0 0;padding-bottom:calc(10px + env(safe-area-inset-bottom))}}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{G as l,N as p,U as k,W as y,c}from"./chunk.26H33GJC.js";import"./chunk.DBFJVVWF.js";import"./chunk.SSAETRHR.js";import"./chunk.Q355UPFG.js";import{b as m}from"./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"./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 S,H as s,I as d,T as f,ca as g}from"./chunk.CYTTZOYL.js";import"./chunk.SDO3U72B.js";import"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import{b as n}from"./chunk.AJZBJBMO.js";var u=n(S(),1);var t=n(f(),1);function D({context:a}){let r=l(),h=g(),[w]=(0,u.useState)(()=>s(null)),o=d(h?.seatTalk??w),P=()=>{(window.history.state?.idx??0)>0?r(-1):r("/")};return(0,t.jsxs)(k,{context:a,"data-testid":"draft-page",children:[(0,t.jsx)(y,{context:a,...o.draft?{"data-testid":"draft-title"}:{},children:o.draft?o.draft.title:"Nothing drawn"}),o.draft?(0,t.jsx)(m,{page:!0,go:e=>r(e.address),onPick:e=>{let i=a.store.graph.getNode(e);i&&r(c(a.store.schema,i.kind,e))},onDiscard:P}):(0,t.jsxs)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:["Ask for a way of seeing \u2014 \u201Ca board of tasks by status\u201D \u2014 and it is drawn here."," ",(0,t.jsx)(p,{to:"/",style:{color:"var(--graview-accent)"},children:"Home \u2192"})]})]})}export{D as DraftPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as a,l as o}from"./chunk.AWUO3M5D.js";import"./chunk.VZDHRY3U.js";import"./chunk.V4HVFLFQ.js";import"./chunk.A2R53GWF.js";import"./chunk.B5PJCYBU.js";import"./chunk.Q2EGESEZ.js";import"./chunk.SMHP2CQH.js";import"./chunk.2PJ6STKA.js";import"./chunk.MBB5A6BT.js";import"./chunk.T535ZLRM.js";import"./chunk.ERPILTRY.js";import"./chunk.OTSBF367.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{va as n}from"./chunk.CYTTZOYL.js";import"./chunk.SDO3U72B.js";import"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import"./chunk.AJZBJBMO.js";var w=new WeakMap;function p(e,i){let t=w.get(e);t||w.set(e,t=new Map);let r=t.get(i);return r||t.set(i,r=a(o(e,n(e)),e,i)),r}export{p as frameworkViews};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as M}from"./chunk.
|
|
1
|
+
import{a as M}from"./chunk.T3JIZNE7.js";import"./chunk.ERPILTRY.js";import"./chunk.XOZU4OFA.js";import{f as H,g as x,h as R}from"./chunk.4TH3CGAZ.js";import{a as $}from"./chunk.PDS4HT46.js";import{a as T,b as A,c as C}from"./chunk.PDMX3GTL.js";import"./chunk.REUMBCSV.js";import"./chunk.2KIWGQXC.js";import"./chunk.D5LOTCBU.js";import{a as P,c as O}from"./chunk.CGK2PY76.js";import{G as k,Q as E,T as g}from"./chunk.CYTTZOYL.js";import"./chunk.SDO3U72B.js";import"./chunk.Q4MI53KK.js";import"./chunk.FQLNBIQ5.js";import{b as l}from"./chunk.AJZBJBMO.js";var s=l(k());var n=l(g()),V={maxWidth:560,margin:"0 auto",padding:"40px 20px 64px",display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:16};function B({app:r,store:e,form:o,principal:i,heading:c=1,onSubmitted:a}){let t=(0,s.useMemo)(()=>H(r,o,e.allMutations()),[r,o,e]),d=E(e),v=(0,s.useMemo)(()=>d?e.seenBy(i):e,[d,e,i]),[p,b]=(0,s.useState)(!1),u=(0,s.useRef)(null);(0,s.useEffect)(()=>{p&&u.current?.focus()},[p]);let y=`h${c}`;if(!d)return null;if(!t)return(0,n.jsx)("main",{"data-graview-visitor-form":o,style:V,children:(0,n.jsx)("p",{role:"alert",children:"There is no form here."})});let S=R(t);return(0,n.jsxs)("main",{"data-graview-visitor-form":o,"aria-labelledby":"graview-visitor-form-title",style:V,children:[(0,n.jsx)(y,{id:"graview-visitor-form-title",style:{margin:0,fontSize:"var(--graview-text-title)"},children:t.title}),p?(0,n.jsxs)("div",{ref:u,role:"status",tabIndex:-1,"data-graview-part":"received",style:{display:"grid",gap:8,outline:"none"},children:[(0,n.jsx)("p",{style:{margin:0,fontWeight:600},children:S.said}),S.next?(0,n.jsx)("p",{style:{margin:0},children:S.next}):null]}):(0,n.jsxs)(n.Fragment,{children:[t.intro?(0,n.jsx)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:t.intro}):null,(0,n.jsx)(M,{store:v,mutation:t.act,principal:i,only:t.fields.map(h=>h.name),label:t.submit,onDone:()=>{b(!0),a?.(o)}})]})]})}var m=l(k()),F=l(O()),G=l($());var f=l(g());function D(r){let{app:e,form:o,principal:i,scheme:c="auto",brand:a=e.brand,fonts:t=!0,height:d}=r,v=(0,m.useMemo)(()=>typeof i!="string"?i:e.forms?.[o]?x(e,o,i):{kind:"human",id:i,roles:[]},[e,o,i]),p=(0,m.useMemo)(()=>r.store??r.remote?.store??A(e,r.seed),[r.store,r.remote,e,r.seed]),b=C(c==="auto",a?.scheme),u=c==="auto"?b:c,y=`graview-form-${(0,m.useId)().replace(/[^a-zA-Z0-9_-]/g,"")}`,S=(0,m.useMemo)(()=>P(u,a,{scope:`.${y}`}),[u,a,y]);return(0,m.useEffect)(()=>{if(!t||typeof document>"u")return;let h=T(a);if(!h||document.querySelector(`link[href="${h}"]`))return;let w=document.createElement("link");w.rel="stylesheet",w.href=h,document.head.appendChild(w)},[a,t]),(0,f.jsxs)("section",{className:y,"aria-label":r.label??e.forms?.[o]?.title??e.name,"data-graview-embed":"form","data-graview-scheme":u,style:{position:"relative",isolation:"isolate",...d===void 0?{}:{minHeight:d},background:"var(--graview-ground)",color:"var(--graview-ink)",fontFamily:"var(--graview-font-body, system-ui)"},children:[(0,f.jsx)("style",{children:S}),(0,f.jsx)(B,{app:e,store:p,form:o,principal:v,heading:r.heading??1,...r.onSubmitted?{onSubmitted:r.onSubmitted}:{}})]})}function K(r,e){e.app.forms?.[e.form]||x(e.app,e.form,"form:");let o=e.store??e.remote?.store??A(e.app,e.seed),i=null;function c(){let[t,d]=(0,m.useState)(e.scheme??"auto");return i=d,(0,f.jsx)(D,{...e,store:o,scheme:t})}let a=(0,G.createRoot)(r);return(0,F.flushSync)(()=>a.render((0,f.jsx)(c,{}))),{store:o,setScheme:t=>(0,F.flushSync)(()=>i?.(t)),unmount:()=>a.unmount()}}export{D as FormEmbed,K as mount};
|