graview 0.1.47 → 0.1.49
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.S5IQFZ5Z.js → chunk.2CO2EJQA.js} +1 -1
- package/dist/preview/{chunk.VAFSSSSI.js → chunk.2N6RQ427.js} +1 -1
- package/dist/preview/{chunk.C44MC5X3.js → chunk.2OLZ6BYI.js} +1 -1
- package/dist/preview/{chunk.GCKZ2YRJ.js → chunk.2OXXGN7C.js} +2 -2
- package/dist/preview/{chunk.Z6TMIAAB.js → chunk.2QKSWK4U.js} +1 -1
- package/dist/preview/chunk.35FUGOSG.js +1 -0
- package/dist/preview/{chunk.IKX4VDTW.js → chunk.3EW6L5DY.js} +1 -1
- package/dist/preview/chunk.3NEALGMI.js +1 -0
- package/dist/preview/{chunk.O4WEJ47H.js → chunk.423SZS7C.js} +3 -3
- package/dist/preview/{chunk.MBETS27C.js → chunk.4D26JY5U.js} +1 -1
- package/dist/preview/{chunk.5A4AOFOA.js → chunk.4HUB3N7I.js} +1 -1
- package/dist/preview/chunk.4K7I7WYF.js +1 -0
- package/dist/preview/{chunk.RUPRZDN3.js → chunk.4OTESF7W.js} +1 -1
- package/dist/preview/{chunk.TJEV5ZAM.js → chunk.4Q5KWYVY.js} +18 -18
- package/dist/preview/{chunk.VXVWUIGO.js → chunk.4QINLTDZ.js} +1 -1
- package/dist/preview/{chunk.EUPSAYEI.js → chunk.4SEY7VWZ.js} +1 -1
- package/dist/preview/chunk.4XKACWLT.js +1 -0
- package/dist/preview/chunk.52QB4YW2.js +1 -0
- package/dist/preview/{chunk.6YD2DLIC.js → chunk.54PZWX23.js} +1 -1
- package/dist/preview/chunk.5YFO6D7J.js +1 -0
- package/dist/preview/chunk.6EGHJCEM.js +1 -0
- package/dist/preview/{chunk.O2WWYZI7.js → chunk.6EHE26ZS.js} +1 -1
- package/dist/preview/{chunk.RG6WNOBW.js → chunk.6RLFO5GA.js} +1 -1
- package/dist/preview/chunk.6WRA3Y7D.js +1 -0
- package/dist/preview/{chunk.IQ2HKGJS.js → chunk.7C4IR4S7.js} +1 -1
- package/dist/preview/{chunk.4YXJPKXD.js → chunk.7JLYEZW4.js} +1 -1
- package/dist/preview/{chunk.VSNHCGKC.js → chunk.7JW5SHRR.js} +1 -1
- package/dist/preview/{chunk.76GF5US2.js → chunk.7MJGZHTS.js} +1 -1
- package/dist/preview/{chunk.F67F6QZ6.js → chunk.7MWLDDFL.js} +1 -1
- package/dist/preview/{chunk.QZEZHCOI.js → chunk.7SGQ3HFG.js} +1 -1
- package/dist/preview/chunk.A7HMVWMG.js +1 -0
- package/dist/preview/{chunk.PKUDIWIF.js → chunk.AGVFW6WC.js} +1 -1
- package/dist/preview/{chunk.FOQ27RAR.js → chunk.AOEXSQDG.js} +1 -1
- package/dist/preview/{chunk.IROYMLER.js → chunk.AP22NNIM.js} +1 -1
- package/dist/preview/{chunk.RNEJYIQ7.js → chunk.AVDXG57A.js} +1 -1
- package/dist/preview/{chunk.N7JT6MG2.js → chunk.B2BLZDBD.js} +1 -1
- package/dist/preview/chunk.B445DZOY.js +1 -0
- package/dist/preview/chunk.BH365UJ5.js +1 -0
- package/dist/preview/{chunk.IPAZOKMQ.js → chunk.BJR6E2CT.js} +1 -1
- package/dist/preview/{chunk.KSM6NVAT.js → chunk.BNU3KXKL.js} +1 -1
- package/dist/preview/chunk.BTORFVKO.js +1 -0
- package/dist/preview/{chunk.OONCUAOH.js → chunk.BU6V76EF.js} +1 -1
- package/dist/preview/{chunk.F2VMMCVK.js → chunk.BVXOLZQ3.js} +1 -1
- package/dist/preview/{chunk.CTQULC5F.js → chunk.C75I24Z5.js} +1 -1
- package/dist/preview/{chunk.WHEUTAXA.js → chunk.CXIIRL67.js} +1 -1
- package/dist/preview/{chunk.4YS7547F.js → chunk.D25QV6DK.js} +1 -1
- package/dist/preview/chunk.D4IKO5YA.js +18 -0
- package/dist/preview/{chunk.Q7RQC3F7.js → chunk.D4K23FUB.js} +1 -1
- package/dist/preview/{chunk.R6V37SR7.js → chunk.D53IGR45.js} +1 -1
- package/dist/preview/chunk.D66RI4QS.js +1 -0
- package/dist/preview/{chunk.BNPQUI3F.js → chunk.DFGXNFFE.js} +1 -1
- package/dist/preview/{chunk.RVJXO5GG.js → chunk.DSNHE4MZ.js} +1 -1
- package/dist/preview/{chunk.UHX4WTM7.js → chunk.DTRNDSMS.js} +1 -1
- package/dist/preview/{chunk.QGG6ZRJ5.js → chunk.DV4GSLGX.js} +2 -2
- package/dist/preview/{chunk.H7KCWCB4.js → chunk.EJAVIZ7Y.js} +1 -1
- package/dist/preview/{chunk.MF73YBJL.js → chunk.EM5CGFNB.js} +1 -1
- package/dist/preview/chunk.EPTUOPPC.js +1 -0
- package/dist/preview/{chunk.L4YNDNX7.js → chunk.ERWBI2NK.js} +1 -1
- package/dist/preview/chunk.EYSQPXVE.js +2 -0
- package/dist/preview/{chunk.47RTA6M3.js → chunk.FIS27KW4.js} +1 -1
- package/dist/preview/chunk.FNK2ZZ5E.js +1 -0
- package/dist/preview/{chunk.5AGW4NRZ.js → chunk.FOYVTN5B.js} +1 -1
- package/dist/preview/{chunk.7ELB37JU.js → chunk.FUMQLGNM.js} +1 -1
- package/dist/preview/chunk.G25JEYCC.js +1 -0
- package/dist/preview/{chunk.IXOQQBJE.js → chunk.G3Q5CYEM.js} +1 -1
- package/dist/preview/chunk.GEY4MA4D.js +6 -0
- package/dist/preview/chunk.GRLPNTUW.js +2 -0
- package/dist/preview/{chunk.2MCZ4CU5.js → chunk.H42WBU5C.js} +1 -1
- package/dist/preview/{chunk.WJS6P7GI.js → chunk.IQHVVQEA.js} +1 -1
- package/dist/preview/{chunk.TCXKPILZ.js → chunk.IVHPJUFM.js} +1 -1
- package/dist/preview/{chunk.FOJDVK2Q.js → chunk.IWEPDTVG.js} +1 -1
- package/dist/preview/{chunk.P4KCZRIG.js → chunk.IYLOA3MV.js} +1 -1
- package/dist/preview/chunk.JBG5UQLM.js +1 -0
- package/dist/preview/{chunk.NFIGGSMJ.js → chunk.KDTNKKOY.js} +1 -1
- package/dist/preview/chunk.KJBXNMIU.js +21 -0
- package/dist/preview/chunk.KLAEKRCA.js +1 -0
- package/dist/preview/{chunk.Z4UM4CMT.js → chunk.KQSD5MLY.js} +1 -1
- package/dist/preview/{chunk.ETR6AV47.js → chunk.KVEDMKUN.js} +1 -1
- package/dist/preview/{chunk.TBQOSI4J.js → chunk.LD6S2FL5.js} +1 -1
- package/dist/preview/{chunk.63JLXGYX.js → chunk.LUL6PFIQ.js} +1 -1
- package/dist/preview/chunk.MCFLCC42.js +12 -0
- package/dist/preview/{chunk.SWWAEOZ7.js → chunk.MJ4XTNTL.js} +1 -1
- package/dist/preview/{chunk.RZF3QM4E.js → chunk.MU5WUTVF.js} +1 -1
- package/dist/preview/{chunk.ZCYGUP3I.js → chunk.MUHFZXPS.js} +1 -1
- package/dist/preview/{chunk.AGIO2GRV.js → chunk.N2S3TMBC.js} +1 -1
- package/dist/preview/{chunk.63MS2LOP.js → chunk.N2S45SSL.js} +1 -1
- package/dist/preview/{chunk.KSXB4LDF.js → chunk.NB6WN4DO.js} +1 -1
- package/dist/preview/{chunk.5M4TMZXC.js → chunk.NBJ4C33P.js} +1 -1
- package/dist/preview/{chunk.WBHM5I3I.js → chunk.NQ7SRWXA.js} +1 -1
- package/dist/preview/chunk.NQDGUIUQ.js +1 -0
- package/dist/preview/{chunk.KRGM25HF.js → chunk.NUUT37ER.js} +1 -1
- package/dist/preview/{chunk.SZR3Z43B.js → chunk.O3ONLQUF.js} +1 -1
- package/dist/preview/chunk.OFBESPHJ.js +1 -0
- package/dist/preview/chunk.OKHEZJBX.js +1 -0
- package/dist/preview/{chunk.2W22AWSL.js → chunk.OL5D7YTW.js} +1 -1
- package/dist/preview/{chunk.SD6N4DGF.js → chunk.ON35FJ5H.js} +1 -1
- package/dist/preview/{chunk.3LDYUO77.js → chunk.OS75HEZP.js} +1 -1
- package/dist/preview/{chunk.DQS7D2W2.js → chunk.OTF3NNTI.js} +1 -1
- package/dist/preview/chunk.P2AC6JRL.js +88 -0
- package/dist/preview/chunk.PBCT33FF.js +1 -0
- package/dist/preview/{chunk.NEEOVRB7.js → chunk.PCVU3LY3.js} +1 -1
- package/dist/preview/chunk.PFEKS3KO.js +5 -0
- package/dist/preview/chunk.PFR3FQBR.js +1 -0
- package/dist/preview/{chunk.VC3UGFHY.js → chunk.Q4KNNJFL.js} +1 -1
- package/dist/preview/chunk.QBHVBL42.js +1 -0
- package/dist/preview/chunk.QPNFWP4Z.js +1 -0
- package/dist/preview/{chunk.24OZGU7J.js → chunk.QQE7N7LB.js} +1 -1
- package/dist/preview/{chunk.DNROW6LX.js → chunk.QQRLUBWQ.js} +1 -1
- package/dist/preview/{chunk.ETPKXUAN.js → chunk.QWX2N2VD.js} +2 -2
- package/dist/preview/chunk.R5IRHCLZ.js +1 -0
- package/dist/preview/{chunk.UV3YU64Z.js → chunk.REANMQ6K.js} +1 -1
- package/dist/preview/{chunk.5TM5VA2H.js → chunk.RI624PFK.js} +1 -1
- package/dist/preview/chunk.RMWLV3PR.js +20 -0
- package/dist/preview/{chunk.7N2GXZYI.js → chunk.RSR2M7ZO.js} +2 -2
- package/dist/preview/chunk.SGJSJGSR.js +1 -0
- package/dist/preview/chunk.SIVMZNHZ.js +1 -0
- package/dist/preview/{chunk.FWSCBHZ5.js → chunk.SPZVEQC5.js} +1 -1
- package/dist/preview/chunk.SR2345SW.js +1 -0
- package/dist/preview/chunk.ST4JHXPS.js +1 -0
- package/dist/preview/chunk.TABIRLQS.js +2 -0
- package/dist/preview/{chunk.52VGZBO3.js → chunk.TBA4GF34.js} +1 -1
- package/dist/preview/{chunk.6TIEX67B.js → chunk.THENABJU.js} +1 -1
- package/dist/preview/{chunk.Y4ZUJUUT.js → chunk.TM6JVVGW.js} +1 -1
- package/dist/preview/{chunk.57ZSMK3R.js → chunk.TSHBXCMU.js} +1 -1
- package/dist/preview/{chunk.PYE3WZM7.js → chunk.UL43GFVC.js} +1 -1
- package/dist/preview/{chunk.RBJAPOZ3.js → chunk.UTRIPGW6.js} +1 -1
- package/dist/preview/{chunk.V7XHNRQM.js → chunk.VSWEKNKS.js} +2 -2
- package/dist/preview/chunk.VV3PNZPI.js +1 -0
- package/dist/preview/chunk.W6CGAPNQ.js +1 -0
- package/dist/preview/{chunk.IJNOT4S4.js → chunk.WQN7EFW3.js} +2 -2
- package/dist/preview/{chunk.PC6PID5X.js → chunk.X4MTZKL3.js} +1 -1
- package/dist/preview/{chunk.C3NHNYA6.js → chunk.XJ7YGW6Y.js} +1 -1
- package/dist/preview/{chunk.MCB26YCQ.js → chunk.XMOIMPUC.js} +1 -1
- package/dist/preview/{chunk.6RY6OSE6.js → chunk.XN7PIWVC.js} +1 -1
- package/dist/preview/chunk.XOZU4OFA.js +1 -0
- package/dist/preview/{chunk.T42S2WMB.js → chunk.XXZFWZ4C.js} +1 -1
- package/dist/preview/{chunk.ZQY6ODXC.js → chunk.YECMUK4X.js} +1 -1
- package/dist/preview/chunk.YSFNPYCD.js +2 -0
- package/dist/preview/{chunk.ZWVN75EY.js → chunk.YXOJKGRC.js} +1 -1
- package/dist/preview/{chunk.CMOXKRWT.js → chunk.ZBL47SFK.js} +1 -1
- package/dist/preview/{chunk.EYI3Y2DY.js → chunk.ZILULTJJ.js} +1 -1
- package/dist/preview/index.html +50 -49
- package/dist/preview/page.js +2 -2
- package/package.json +6 -6
- package/dist/preview/chunk.2CLANQHZ.js +0 -1
- package/dist/preview/chunk.2L3VFGHX.js +0 -1
- package/dist/preview/chunk.4OGOTHRD.js +0 -1
- package/dist/preview/chunk.5G53VDOC.js +0 -1
- package/dist/preview/chunk.64WM4IBI.js +0 -1
- package/dist/preview/chunk.6QVXXQCW.js +0 -2
- package/dist/preview/chunk.7NNI7YH4.js +0 -1
- package/dist/preview/chunk.A3RNSSUQ.js +0 -1
- package/dist/preview/chunk.A7RKTSOH.js +0 -20
- package/dist/preview/chunk.AS4CQBOQ.js +0 -5
- package/dist/preview/chunk.AWXDZUKH.js +0 -1
- package/dist/preview/chunk.AYA7SYIU.js +0 -1
- package/dist/preview/chunk.BBS5C2BY.js +0 -1
- package/dist/preview/chunk.COYLGLTI.js +0 -1
- package/dist/preview/chunk.DX357TZ3.js +0 -2
- package/dist/preview/chunk.GQHAAKJG.js +0 -1
- package/dist/preview/chunk.HDRD33II.js +0 -1
- package/dist/preview/chunk.I6JLOEJU.js +0 -1
- package/dist/preview/chunk.ISNEX772.js +0 -1
- package/dist/preview/chunk.IW7YFPGG.js +0 -1
- package/dist/preview/chunk.IYIN6VSN.js +0 -1
- package/dist/preview/chunk.JUWWRRHA.js +0 -1
- package/dist/preview/chunk.K2NCGPCL.js +0 -1
- package/dist/preview/chunk.KWQ7QOHD.js +0 -2
- package/dist/preview/chunk.MCCUVGTE.js +0 -1
- package/dist/preview/chunk.NDWW5EER.js +0 -1
- package/dist/preview/chunk.OCTOGZVJ.js +0 -3
- package/dist/preview/chunk.OJGUIWDD.js +0 -88
- package/dist/preview/chunk.PBKO5CKD.js +0 -1
- package/dist/preview/chunk.QGVLJTZS.js +0 -1
- package/dist/preview/chunk.RX2M4C5W.js +0 -2
- package/dist/preview/chunk.SGKK4UKP.js +0 -1
- package/dist/preview/chunk.T7RJCEJB.js +0 -18
- package/dist/preview/chunk.UKAPFIPJ.js +0 -1
- package/dist/preview/chunk.VW2VCPJX.js +0 -1
- package/dist/preview/chunk.W6COSBO2.js +0 -21
- package/dist/preview/chunk.WAB7UDHU.js +0 -1
- package/dist/preview/chunk.X5G7FOPY.js +0 -12
- package/dist/preview/chunk.XYEFZ2OO.js +0 -1
- package/dist/preview/chunk.YHH4TWZ2.js +0 -1
- package/dist/preview/chunk.YVONXFKE.js +0 -6
- package/dist/preview/chunk.ZIEHF67C.js +0 -1
- package/dist/preview/chunk.ZL7ZBJUU.js +0 -1
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as k}from"./chunk.G4JJXA63.js";import{a as Q}from"./chunk.AOEXSQDG.js";import{a as Y}from"./chunk.PBCT33FF.js";import{a as X}from"./chunk.DTRNDSMS.js";import{c as _}from"./chunk.LD6S2FL5.js";import{mb as H,nb as q,nd as P,pd as z,qd as G,rd as J}from"./chunk.PFEKS3KO.js";var O=e=>"failed"in e;function ue(e,n){let r=e.schema.kinds,t=e.policy?.sees;if(!t?.length||q(n))return{kinds:r};let s=H(n).roles??[],o=new Set(t.filter(i=>i.roles==="*"||s.some(a=>i.roles.includes(a))).flatMap(i=>i.kinds));return{kinds:r.filter(i=>o.has(i))}}function L(e,n){if(!n)return e;let r=new Set(n.kinds.filter(o=>e.tryDefinition(o)!==void 0));if(r.size===e.kinds.length)return e;let t=new Map,s=o=>{if(r.has(o)){if(!t.has(o)){let i=e.tryDefinition(o),a=Object.fromEntries(Object.entries(i?.edges??{}).flatMap(([l,d])=>{if(d.to==="*")return[[l,d]];let c=d.to.filter(u=>r.has(u));return c.length>0?[[l,{...d,to:c}]]:[]}));t.set(o,{...i,edges:a})}return t.get(o)}};return{...e,definitions:e.definitions.filter(o=>r.has(o.kind)),kinds:e.kinds.filter(o=>r.has(o)),tryDefinition:s,definition:o=>{let i=s(o);if(!i)throw new Error(`Unknown node kind "${o}"`);return i}}}var fe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),y=e=>fe(e).replace(/[-_]+/g," ").trim();function I(e){let n=[];for(let t of e.kinds){let s=e.tryDefinition(t);if(!s)continue;let o=s.display?.labels??{},i=Object.entries(s.fields?.shape??{}).filter(([d])=>d!=="id"&&d!=="kind").map(([d,c])=>{let u=X(c);return{name:d,type:u?.type,...u?.options?{options:u.options}:{},words:(o[d]??y(d)).toLowerCase()}}),a=Object.entries(s.edges??{}).map(([d,c])=>({name:d,from:t,to:c.to==="*"?e.kinds.filter(u=>u!==t):c.to,words:y(d)})),l=(s.plural??`${y(t)}s`).toLowerCase();n.push({kind:t,plural:l,noun:(s.noun??y(t)).toLowerCase(),fields:i,roles:s.fieldRoles??{},edges:a})}let r=new Map(n.map(t=>[t.kind,t]));return{schema:e,kinds:n,info:t=>r.get(t)}}var $=(e,n)=>n===void 0?void 0:e.fields.find(r=>r.name===n),A=e=>e?.type==="date"||e?.type==="datetime",N=e=>e?.type==="number"||e?.type==="integer"||e?.type==="duration",re=e=>` ${e.toLowerCase().replace(/[“”"’‘]/g,"'").replace(/[^\p{L}\p{N}' -]+/gu," ").replace(/\s+/g," ").trim()} `,E=(e,n)=>e.includes(` ${n} `),v=e=>e.endsWith("ies")?`${e.slice(0,-3)}y`:e.endsWith("ses")?e.slice(0,-2):e.endsWith("s")?e.slice(0,-1):e;function pe(e,n){let r=[];for(let t of n.kinds){let s=new Set([t.plural,t.noun,`${t.noun}s`,y(t.kind),`${y(t.kind)}s`]),o=-1;for(let i of s){let a=e.indexOf(` ${i} `);a>=0&&(o<0||a<o)&&(o=a)}o>=0&&r.push({info:t,at:o})}return r.sort((t,s)=>t.at-s.at).map(t=>t.info)}function x(e,n,r){let t=n.trim().toLowerCase();if(t.length===0)return;let s=e.fields.filter(o=>!r||r(o));return s.find(o=>o.words===t||y(o.name)===t||o.name.toLowerCase()===t)??s.find(o=>o.words===v(t)||y(o.name)===v(t))??s.find(o=>t.split(" ").some(i=>i.length>2&&(o.words.split(" ").includes(i)||o.words.split(" ").includes(v(i)))))}function oe(e,n,r){let t=n.trim().toLowerCase();if(t.length!==0)return e.edges.find(s=>s.words===t||s.name.toLowerCase()===t)??e.edges.find(s=>s.to.some(o=>{let i=r.info(o);return i!==void 0&&(i.noun===v(t)||i.plural===t||y(o)===v(t))}))??e.edges.find(s=>t.split(" ").some(o=>o.length>2&&s.words.split(" ").includes(o)))}function U(e){return/ (?:grouped |group |split |sorted |organi[sz]ed )?by ([\p{L}\p{N}' -]+?)(?= (?:and|with|for|in|on|only|where|from|this|that|as|sorted|grouped) |\s*$)/u.exec(e)?.[1]?.trim()}var me=/\bwho\b.*\b(covers?|cover|tends?|owns?|handles?|does|works? on|looks? after|is on|is assigned|staffs?|runs?)\b|\bcoverage\b|\bmatrix\b|\bwho covers\b/,ge=/\bcalendar\b|\bmonth\b|\bagenda\b|\bschedule\b|\bdue\b|\bdeadlines?\b|\bdates?\b|\bwhen\b/,ye=/\btimeline\b|\bover time\b|\bgantt\b|\bspans?\b|\bweek\b/,he=/\bboard\b|\bkanban\b|\bcolumns?\b|\bpipeline\b|\bstages?\b|\bstatus\b/,be=/\blaid out\b|\blayout\b|\bseating\b|\bwhere (?:they|it|each) (?:sits?|lies?|stands?)\b|\bfloor\b/,we=/\bplan\b|\bmap\b|\bregions?\b/,ke=/\blist\b|\btable\b|\bgroup(?:ed)? by\b|\bsort(?:ed)? by\b|\bonly\b|\bjust the\b/;function $e(e){let n=[];return/\blist\b|\btable\b/.test(e)&&n.push("blocks"),me.test(e)&&n.push("coverage"),be.test(e)&&n.push("board"),(/\bfloor plan\b/.test(e)||we.test(e))&&n.push("plan"),ye.test(e)&&n.push("timeline"),ge.test(e)&&n.push("calendar"),he.test(e)&&n.push("columns"),ke.test(e)&&!n.includes("blocks")&&n.push("blocks"),n.length===0&&U(e)&&n.push("columns"),n}var se=e=>{let n=r=>r?` and not ${r}`:"";if(/\boverdue\b|\blate\b|\bpast due\b/.test(e))return{cond:(r,t)=>`days(today(), ${r}) < 0${n(t)}`,says:r=>`overdue by ${r.words}`};if(/\btoday\b/.test(e))return{range:"day",cond:r=>`days(today(), ${r}) == 0`,says:r=>`with ${r.words} today`};if(/\bthis week\b|\bnext 7 days\b|\bnext week\b/.test(e))return{range:"week",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 6`,says:r=>`with ${r.words} in the next week`};if(/\bthis month\b|\bnext 30 days\b|\bnext month\b/.test(e))return{range:"month",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 30`,says:r=>`with ${r.words} in the next month`};if(/\blast month\b|\bpast month\b/.test(e))return{range:"month",cond:r=>`days(today(), ${r}) >= -30 and days(today(), ${r}) <= 0`,says:r=>`with ${r.words} in the last month`};if(/\bthis year\b/.test(e))return{range:"year",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 365`,says:r=>`with ${r.words} in the next year`};if(/\bquarter\b/.test(e))return{range:"quarter",cond:r=>`days(today(), ${r}) >= 0 and days(today(), ${r}) <= 91`,says:r=>`with ${r.words} in the next quarter`}},M=e=>{if(/\bagenda\b|\bin order\b/.test(e))return"agenda";if(/\btoday\b|\bday\b/.test(e))return"day";if(/\bweek\b/.test(e))return"week";if(/\bquarter\b/.test(e))return"quarter";if(/\byears\b/.test(e))return"years";if(/\byear\b/.test(e))return"year";if(/\bmonth\b/.test(e))return"month"},Z=/^(user|person|people|member|staff|gardener|volunteer|owner|agent|employee|worker|team|player|customer|client|contact|party|attendee|guest)s?$/,j=class extends Error{},h=e=>{throw new j(e)};function Se(e,n){let r=e.fields.filter(o=>o.type==="enum");if(n){let o=x(e,n);if(o&&o.type==="enum")return o;o&&h(`${e.plural}' ${o.words} is not a choice, so it has no columns`)}let t=$(e,e.roles.status??e.roles.column);if(t?.type==="enum")return t;let s=r.find(o=>/^(status|stage|state|phase)$/.test(o.name));return s||(r[0]?r[0]:h(`${e.plural} have no choice field to put in columns`))}function ee(e,n){let r=e.fields.filter(A),t=l=>{let d=$(e,e.roles[l]);return A(d)?d:void 0},o=r.find(l=>E(n,l.words)||E(n,y(l.name)))??t("start")??r.find(l=>/^(due|date|on|at|start|starts|begins|from|sown|when)/i.test(l.name))??r[0];if(!o)return h(`no date field on ${e.plural}`);let i=t("end")??r.find(l=>l!==o&&/^(end|ends|until|to|finish|finished|harvested|due|closes|through)/i.test(l.name)),a=e.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));return{start:o,...i&&i!==o?{end:i}:{},...a?{done:a}:{}}}function ie(e){let n=$(e,e.roles.start),r=$(e,e.roles.end),t=$(e,e.roles.column??e.roles.day??e.roles.columns);if(N(n)&&N(r)&&t?.type==="enum")return{start:n,end:r,column:t}}function De(e,n,r,t){let s=[];for(let i of e.kinds)for(let a of i.edges)for(let l of a.to){let d=e.info(l);if(!d||d.kind===i.kind)continue;let c=0;n.includes(i)&&(c+=4),n.includes(d)&&(c+=4),(Z.test(d.kind)||Z.test(d.noun))&&(c+=3),t&&(a.words.includes(t)||d.noun===v(t))&&(c+=5),a.words.split(" ").some(u=>u.length>2&&r.includes(` ${u}`))&&(c+=2),s.push({rows:i,across:d,link:a,score:c})}let o=s.sort((i,a)=>a.score-i.score)[0];return o||h(n[0]?`${n[0].plural} are joined to nothing else, so there is no who-covers-what to draw`:"nothing here is joined to anything else, so there is no who-covers-what to draw")}function ae(e,n,r,t,s){let o=U(t);switch(e){case"columns":{if(o){let i=x(n,o);if(!i||i.type!=="enum"){let a=oe(n,o,r);if(a){let l=r.info(a.to[0]);return{lens:"coverage",kind:n.kind,across:l.kind,link:a.name}}}}return{lens:"columns",kind:n.kind,column:Se(n,o).name}}case"calendar":{let i=ee(n,t),a=M(t);return{lens:"calendar",kind:n.kind,start:i.start.name,...i.end?{end:i.end.name}:{},...i.done?{done:i.done.name}:{},...a?{range:a}:{}}}case"timeline":{let i=ie(n);if(i&&!/\bdates?\b|\bdue\b|\bdeadlines?\b|\bmonths?\b|\byears?\b/.test(t))return{lens:"timeline",kind:n.kind,start:i.start.name,end:i.end.name,column:i.column.name};let a=ee(n,t);return{lens:"calendar",kind:n.kind,start:a.start.name,...a.end?{end:a.end.name}:{},...a.done?{done:a.done.name}:{},range:M(t)??"quarter"}}case"coverage":{let i=De(r,s,t,o);return{lens:"coverage",kind:i.rows.kind,across:i.across.kind,link:i.link.name}}case"board":{let i=$(n,n.roles.x)??n.fields.find(c=>c.name==="x"),a=$(n,n.roles.y)??n.fields.find(c=>c.name==="y");if(!N(i)||!N(a))return h(`${n.plural} have no x and y to be laid out by`);let d=r.kinds.flatMap(c=>c.edges.filter(u=>u.to.includes(n.kind)&&c.kind!==n.kind))[0]??n.edges[0];return d?{lens:"board",kind:n.kind,x:i.name,y:a.name,fill:d.name,...d.from!==n.kind?{fillFrom:"occupant"}:{}}:h(`nothing is joined to ${n.plural} to fill them`)}case"plan":{let i=$(n,n.roles.outline)??n.fields.find(a=>a.name==="outline");return i?{lens:"plan",kind:n.kind,outline:i.name}:h(`${n.plural} have no outline to draw a plan from`)}case"blocks":{let i={lens:"blocks",kind:n.kind,as:/\bcards?\b/.test(t)?"card":"row"},a=/ group(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|sorted|with)|\s*$)/u.exec(t)?.[1]??(o&&!/ sort(?:ed)? by /.test(t)?o:void 0);if(a){let c=x(n,a);if(!c||c.type!=="enum")return h(c?`${n.plural}' ${c.words} is not a choice, so they cannot be grouped by it`:`${n.plural} have nothing called ${a} to group by`);i.group=c.name}let l=/ sort(?:ed)? by ([\p{L}\p{N} -]+?)(?= (?:and|only|grouped|with)|\s*$)/u.exec(t)?.[1];if(l){let c=x(n,l);if(!c)return h(`${n.plural} have nothing called ${l} to sort by`);i.sort={by:c.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}let d=V(n,t);return d.length>0&&(i.where=d),i}}}function V(e,n){let r=[],t=se(n);if(t){let s=e.fields.filter(A),o=$(e,e.roles.start),i=s.find(l=>E(n,l.words))??(A(o)?o:void 0)??s[0];(!i||!A(i))&&h(`no date field on ${e.plural}`);let a=e.fields.find(l=>l.type==="boolean"&&/^(done|finished|complete|completed|closed)$/.test(l.name));r.push({expr:t.cond(i.name,/\boverdue\b|\blate\b|\bpast due\b/.test(n)?a?.name:void 0),says:t.says(i)})}if(/\bonly\b|\bjust\b|\bthat are\b|\bwhich are\b/.test(n)){for(let s of e.fields){if(s.type!=="enum")continue;let o=s.options?.find(i=>E(n,i.toLowerCase())||E(n,y(i)));o&&r.push({expr:`${s.name} == '${o.replace(/'/g,"")}'`,says:`that are ${y(o)}`})}if(/\bnot done\b|\bundone\b|\bunfinished\b|\bopen ones\b|\bstill to do\b/.test(n)){let s=e.fields.find(o=>o.type==="boolean"&&/^(done|finished|complete|completed)$/.test(o.name));s&&r.push({expr:`not ${s.name}`,says:`not ${s.words}`})}}return r}var B={columns:"A board",calendar:"A calendar",timeline:"A timeline",coverage:"A grid",board:"A layout",plan:"A plan",blocks:"A list",reach:"A picture"};function Re(e,n){let r=n.info(e.kind),t=s=>s?$(r,s)?.words??y(s):"";switch(e.lens){case"columns":return{title:`${k(r.plural)} by ${t(e.column)}`,detail:`of ${r.plural} by ${t(e.column)}`};case"calendar":{let s=e.range??"month";if(s==="agenda")return{title:`${k(r.plural)} in date order`,detail:`of ${r.plural} in order of ${t(e.start)}`};let o=s==="years"?"year":s;return{title:`${k(r.plural)} by ${o}`,detail:`of ${r.plural} by ${t(e.start)}, a ${o} at a time`}}case"timeline":return{title:`${k(r.plural)} over the ${t(e.column)}`,detail:`of ${r.plural} from ${t(e.start)} to ${t(e.end)}, by ${t(e.column)}`};case"coverage":{let s=n.info(e.across);return{title:`${k(r.plural)} by ${s.noun}`,detail:`of which ${s.noun} covers which ${r.noun}`}}case"board":return{title:`${k(r.plural)} where they stand`,detail:`of ${r.plural} where they stand`};case"plan":return{title:`${k(r.plural)} on a plan`,detail:`of ${r.plural}`};default:{let s=[e.where?.map(o=>o.says).join(" and "),e.group?`by ${t(e.group)}`:void 0,e.sort?`in order of ${t(e.sort.by)}`:void 0].filter(o=>!!o);return{title:[k(r.plural),...s].join(" "),detail:[`of ${r.plural}`,...s].join(" ")}}}}function Ae(e,n){let r={title:n,on:e.kind};switch(e.lens){case"columns":return{name:"columns",...r,bindings:{[e.kind]:{column:e.column}}};case"calendar":return{name:"calendar",...r,bindings:{[e.kind]:{start:e.start,...e.end?{end:e.end}:{},...e.done?{done:e.done}:{}}},...e.range?{options:{range:e.range}}:{}};case"timeline":return{name:"timeline",...r,bindings:{[e.kind]:{start:e.start,end:e.end,column:e.column}}};case"coverage":return{name:"coverage",...r,bindings:{rows:{kind:e.kind},columns:{kind:e.across},link:{edge:e.link}}};case"board":return{name:"board",...r,bindings:{slots:{kind:e.kind},x:{field:e.x,on:"slots"},y:{field:e.y,on:"slots"},fill:{edge:e.fill}},...e.fillFrom?{options:{fillFrom:e.fillFrom}}:{}};case"plan":return{name:"plan",...r,bindings:{regions:{kind:e.kind},outline:{field:e.outline,on:"regions"}}};default:{let t=e.where?.length?` where ${e.where.map(o=>e.where.length>1?`(${o.expr})`:o.expr).join(" and ")}`:"",s={list:`all('${e.kind}')${t}`,as:e.as??"row"};return e.group&&(s.group=e.group),e.sort&&(s.sort=e.sort.direction?{by:e.sort.by,direction:e.sort.direction}:e.sort.by),s.empty="Nothing here yet.",{name:"blocks",...r,options:{blocks:[s]}}}}}function C(e,n){let{app:r}=n,t=o=>o.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,""),s=new Set(["home","overview",...Q(r,n.views?{views:n.views}:{}).map(o=>o.slug),...(r.lenses??[]).flatMap(o=>o.title?[t(o.title)]:[])]);if(!s.has(t(e)))return e;for(let o=2;;o++)if(!s.has(t(`${e} ${o}`)))return`${e} ${o}`}var ne={title:[],headline:[],text:["tone"],figure:["as","currency","label"],list:["sort","limit","group","empty","as"],progress:["label"],group:["direction"],when:["show"],divider:[]};function Ee(e,n){if(!Array.isArray(n)||n.length===0)return"it has no blocks to draw";if(n.length>40)return"it has more blocks than a place draws";let r=(i,a)=>{if(typeof i!="string"||i.trim()==="")return`its ${a} says nothing`;try{return _(i)}catch(l){return`its ${a} does not read: ${l instanceof Error?l.message.replace(/ \(at character.*$/,""):String(l)}`}},t=i=>{if(i.t==="where")return t(i.set);if(i.t==="call"&&i.fn==="all"){let a=i.args[0];return a?.t==="lit"&&typeof a.value=="string"?e.info(a.value)??null:void 0}},s=(i,a)=>{switch(i.t){case"lit":return;case"ident":return a&&!a.fields.some(l=>l.name===i.name)&&!a.edges.some(l=>l.name===i.name)?`${a.plural} have nothing called ${i.name}`:void 0;case"member":return s(i.object,a);case"list":return i.items.map(l=>s(l,a)).find(Boolean);case"unary":return s(i.operand,a);case"binary":return s(i.left,a)??s(i.right,a);case"where":{let l=t(i.set);return l===null?"Nothing by that name here":s(i.set,a)??s(i.filter,l??void 0)}case"call":return i.fn==="all"?t(i)===null?"Nothing by that name here":void 0:i.args.map(l=>s(l,a)).find(Boolean)}},o=(i,a)=>{if(a>4)return"its blocks nest deeper than a place draws";for(let l of i){if(!w(l))return"a block is not an object";let d=Object.keys(ne).find(p=>p in l);if(!d)return`"${Object.keys(l)[0]??""}" is not a block a place draws`;let c=Object.keys(l).find(p=>p!==d&&p!=="key"&&!ne[d].includes(p));if(c)return`a ${d} block takes no "${c}"`;let u=l[d];if(d==="list"||d==="figure"||d==="when"){if(d==="figure"&&u===!0)continue;let p=r(u,d);if(typeof p=="string")return p;let g=s(p,void 0);if(g)return g;if(d==="list"){let f=t(p);if(f==null)return f===null?"Nothing by that name here":"its list does not say which records it lists, like all('task')";for(let m of["group","sort"]){let b=l[m],S=typeof b=="string"?b:w(b)&&typeof b.by=="string"?b.by:void 0;if(b===void 0)continue;let D=S?f.fields.find(ce=>ce.name===S):void 0;if(!D)return`${f.plural} have nothing called ${String(S??b)} to ${m} by`;if(m==="group"&&D.type!=="enum")return`${f.plural}' ${D.words} is not a choice, so they cannot be grouped by it`}}if(d==="when"){let f=l.show;if(!Array.isArray(f))return"a when block shows a list of blocks";let m=o(f,a+1);if(m)return m}}else if(d==="group"){if(!Array.isArray(u))return"a group block holds a list of blocks";let p=o(u,a+1);if(p)return p}else{if(d!=="divider"&&typeof u!="string")return`a ${d} block says words`;if(typeof u=="string")for(let p of u.matchAll(/\{([^{}]*)\}/g)){let g=p[1].split(/\|(?![|])/)[0],f=r(g,`${d}'s braces`);if(typeof f=="string")return f;let m=s(f,void 0);if(m)return m}}}};return o(n,1)}function T(e,n,r){let t=L(e.schema,r),s=f=>({ok:!1,failed:`Couldn't draw that: ${f.replace(/\.$/,"")}.`});if(!G(n.name)||n.name==="reach")return s(`"${String(n.name)}" is not a picture the seat can draw; it draws ${z.filter(f=>f!=="reach").join(", ")}`);if(typeof n.title!="string"||n.title.trim().length===0||n.title.length>80)return s("it needs a title of a few words");if(typeof n.on!="string"||!t.tryDefinition(n.on))return s("Nothing by that name here");let o=P[n.name],i=n.bindings??{};if(o.binds==="fields")for(let[f,m]of Object.entries(i)){if(!t.tryDefinition(f))return s("Nothing by that name here");let b=Object.keys(t.tryDefinition(f).fields?.shape??{});for(let[S,D]of Object.entries(m??{}))if(typeof D!="string"||!b.includes(D))return s(`${y(f)} has no field "${String(D)}" for its ${S}`);for(let S of o.requiredRoles)if(!(S in(m??{})))return s(`a ${n.name} needs ${y(f)}'s ${S}`)}else if(o.binds==="entities")for(let f of o.requiredRoles){let m=i[f];if(!m)return s(`a ${n.name} needs its ${f}`);if(typeof m.kind=="string"&&!t.tryDefinition(m.kind))return s("Nothing by that name here")}let a={...e,schema:t,lenses:[...e.lenses??[],n]},l=a.lenses.length-1,d=J(a),c=`lenses.${l}`,u=d.findings.find(f=>f.path===c||f.path.startsWith(`${c}.`));if(u)return s(u.message.replace(/^"[^"]*" /,"it "));let p=d.undrawn.find(f=>f.index===l);if(p)return s(p.why);let g=d.drawn.find(f=>f.index===l);if(!g)return s("its bindings name something the app does not have");if(g.as==="overview")return s(`"${n.title}" is the scene's own address; give it another title`);if(n.name==="blocks"){let f=Ee(I(t),n.options?.blocks);if(f)return s(f)}return{ok:!0,drawn:g}}function K(e){return{op:"add-lens",title:e.title,lens:e.name,on:e.on,...e.bindings?{bindings:e.bindings}:{},...e.options?{options:e.options}:{}}}function ve(e){return{op:"remove-lens",title:e.title,on:e.on}}var w=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function de(e){let n=w(e)?e:{},r=String(n.lens??n.name??""),t=n.bindings,s=typeof n.on=="string"?n.on:w(t)&&P[r]?.binds==="fields"?Object.keys(t)[0]??"":"";return{name:r,title:typeof n.title=="string"?n.title.trim():"",on:s,...w(t)?{bindings:t}:{},...w(n.options)?{options:n.options}:{}}}function xe(e){let n=s=>w(e.bindings?.[s])?e.bindings[s]:{},r=s=>typeof s=="string"?s:void 0,t=n(e.on);switch(e.name){case"columns":return r(t.column)?{lens:"columns",kind:e.on,column:t.column}:void 0;case"calendar":{let s=r(e.options?.range);return r(t.start)?{lens:"calendar",kind:e.on,start:t.start,...r(t.end)?{end:t.end}:{},...r(t.done)?{done:t.done}:{},...s?{range:s}:{}}:void 0}case"timeline":return r(t.start)&&r(t.end)&&r(t.column)?{lens:"timeline",kind:e.on,start:t.start,end:t.end,column:t.column}:void 0;case"coverage":{let s=w(e.bindings?.columns)?r(e.bindings.columns.kind):void 0,o=w(e.bindings?.link)?r(e.bindings.link.edge):void 0;return s&&o?{lens:"coverage",kind:e.on,across:s,link:o}:void 0}case"blocks":{let s=e.options?.blocks;if(!Array.isArray(s)||s.length!==1||!w(s[0]))return;let o=s[0],i=new RegExp(`^all\\('${e.on}'\\)(?: where (.+))?$`).exec(String(o.list??""));if(!i)return;let a=o.sort;return{lens:"blocks",kind:e.on,as:o.as==="card"?"card":"row",...typeof o.group=="string"?{group:o.group}:{},...typeof a=="string"?{sort:{by:a}}:w(a)&&typeof a.by=="string"?{sort:{by:a.by,...a.direction==="desc"?{direction:"desc"}:{}}}:{},...i[1]?{where:[{expr:i[1],says:"as asked"}]}:{}}}default:return}}function W(e,n,r,t,s){let o=I(L(e.schema,t)).info(n.on),i=xe(n);return{title:n.title,said:`${B[n.name]??"A picture"} of ${o?.plural??y(n.on)}.`,kind:n.on,lens:n,drawn:r,edit:K(n),by:s,asks:[],...i?{recipe:i}:{}}}function te(e){return{title:e.title,said:e.said,lens:{title:e.lens.title,lens:e.lens.name,on:e.lens.on,...e.lens.bindings?{bindings:e.lens.bindings}:{},...e.lens.options?{options:e.lens.options}:{}},edit:e.edit,by:e.by,check:"It draws, and graview check would take it."}}function F(e,n,r,t,s){let o=Re(e,n),i=e.title??s??C(o.title,r),a=Ae(e,i),l=T(r.app,a,r.sight);return l.ok?{title:i,said:`${B[e.lens]} ${o.detail}.`,kind:e.kind,lens:a,drawn:l.drawn,edit:K(a),by:"template",asks:t,recipe:e}:{failed:l.failed,...r.lastGood?{lastGood:r.lastGood}:{}}}function Ye(e,n){let r=I(L(n.app.schema,n.sight)),t=r.info(e.kind);if(!t)return{failed:"Couldn't draw that: Nothing by that name here."};let s=e.lens==="blocks"&&!e.group&&!e.sort&&!e.where?.length&&e.title===void 0;return F(s?{...e,title:C(`Every ${t.noun}`,n)}:e,r,n,[])}function Le(e,n,r,t){if(r.length>0)return r;let s=i=>{switch(e){case"columns":return i.fields.some(a=>a.type==="enum");case"calendar":return i.fields.some(A);case"timeline":return ie(i)!==void 0||i.fields.some(A);case"coverage":return i.edges.some(a=>a.to.some(l=>l!==i.kind));case"board":return i.fields.some(a=>a.name==="x")&&i.fields.some(a=>a.name==="y");case"plan":return i.fields.some(a=>a.name==="outline")||i.roles.outline!==void 0;default:return!0}};return[...n.kinds.filter(s)].sort((i,a)=>Number(a.fields.some(l=>E(t,l.words)))-Number(i.fields.some(l=>E(t,l.words))))}function Ie(e,n){let r=I(L(n.app.schema,n.sight)),t=re(e),s=$e(t);if(s.length===0)return;let o=pe(t,r),i;for(let a of s){let l=a==="coverage"?[o[0]??r.kinds[0]].filter(d=>!!d):Le(a,r,o,t);for(let d of l)try{let c=ae(a,d,r,t,o),u=F(c,r,n,[e]);if(!O(u))return u;i??=u.failed}catch(c){if(!(c instanceof j))throw c;i??=`Couldn't draw that: ${c.message}.`}l.length===0&&o.length===0&&(i??=`Couldn't draw that: nothing here has what ${B[a].toLowerCase()} needs.`)}return{failed:i??"Couldn't draw that: Nothing by that name here.",...n.lastGood?{lastGood:n.lastGood}:{}}}async function Oe(e,n){let r=n.lastGood?{lastGood:n.lastGood}:{};if(e.trim().length===0)return{failed:"Say what you would like to see, like \u201Ca board of tasks by status\u201D.",...r};let t=Ie(e,n);if(t&&!O(t))return t;if(!n.complete)return t??{failed:"Couldn't draw that: drawing freely needs AI, which isn't on here. Ask for a board, a calendar, a timeline, a list or who covers what.",...r};let s=await le(e,n,void 0);return O(s)&&t?t:s}async function je(e,n,r){let t={lastGood:e},s={...r,lastGood:e},o=I(L(r.app.schema,r.sight)),i=re(n),a=o.info(e.kind),l=[...e.asks,n];if(!a)return{failed:"Couldn't change that: Nothing by that name here.",...t};let d=e.recipe,c=/^ (?:call|name|title) (?:it|this)? ?(.+?) $/.exec(i)??/ (?:call|name) it (.+?) $/.exec(i);try{if(c){let g=n.replace(/^.*?\b(?:call|name|title)\b\s*(?:it|this)?\s*/i,"").replace(/^["“']|["”']$/g,"").trim();if(g.length===0)return{failed:"Couldn't change that: say what to call it.",...t};let f={...e.lens,title:C(g,r)},m=T(r.app,f,r.sight);return m.ok?{...e,title:f.title,lens:f,drawn:m.drawn,edit:K(f),asks:l,...d?{recipe:{...d,title:f.title}}:{}}:{failed:m.failed,...t}}let p=/ as (?:a |an )?(board|kanban|calendar|timeline|list|table|cards|rows|grid|plan|layout)\b/.exec(i);if(p){let g=p[1]==="board"||p[1]==="kanban"?"columns":p[1]==="calendar"?"calendar":p[1]==="timeline"?"timeline":p[1]==="grid"?"coverage":p[1]==="plan"?"plan":p[1]==="layout"?"board":"blocks",f=ae(g,a,o,i,[a]),m=p[1]==="cards"?"card":p[1]==="rows"?"row":void 0,b=g==="blocks"&&d?.lens==="blocks"?{...d,...m?{as:m}:{}}:g==="blocks"&&d?.lens==="columns"?{...f,group:d.column,...m?{as:m}:{}}:f;return F(R(b),o,s,l)}if(d){let g=Te(d,a,o,i);if(g)return F(g,o,s,l)}}catch(p){if(!(p instanceof j))throw p;return{failed:`Couldn't change that: ${p.message}.`,...t}}if(!r.complete)return{failed:"Couldn't change that: changing it freely needs AI, which isn't on here. Try \u201Cgroup by status\u201D, \u201Conly this month\u201D or \u201Cas a calendar\u201D.",...t};let u=await le(n,s,e);return O(u)?u:{...u,asks:l}}var R=e=>{let{title:n,...r}=e;return r};function Te(e,n,r,t){let s=/ (?:group(?:ed)?|split|organi[sz]ed?|put them|columns) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1]??(/^ by /.test(t)?U(t):void 0);if(s){let d=x(n,s);if(d?.type==="enum")return e.lens==="blocks"?{...R(e),group:d.name}:{lens:"columns",kind:e.kind,column:d.name};let c=oe(n,s,r);return c?{lens:"coverage",kind:e.kind,across:c.to[0],link:c.name}:h(d?`${n.plural}' ${d.words} is not a choice, so they cannot be grouped by it`:`${n.plural} have nothing called ${s} to group by`)}let o=/ (?:sort(?:ed)?|order(?:ed)?) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1];if(o){let d=x(n,o);return d?{...e.lens==="blocks"?R(e):{lens:"blocks",kind:e.kind,as:"row",...e.lens==="columns"?{group:e.column}:{}},sort:{by:d.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}:h(`${n.plural} have nothing called ${o} to sort by`)}if(/\b(?:all of them|everything|show all|clear the filter|no filter|without the filter)\b/.test(t)){if(e.lens!=="blocks"||!e.where)return h("it already shows all of them");let{where:d,...c}=R(e);return c}let i=se(t);if(i&&e.lens==="calendar"&&i.range)return{...R(e),range:i.range};if(i&&e.lens==="calendar"&&!i.range)return{lens:"blocks",kind:e.kind,as:"row",sort:{by:e.start},where:V(n,t)};let a=V(n,t);if(a.length>0){let d=e.lens==="blocks"?R(e):{lens:"blocks",kind:e.kind,as:"row",...e.lens==="columns"?{group:e.column}:{}};return{...d,where:[...d.where??[],...a]}}let l=e.lens==="calendar"?M(t):void 0;if(l)return{...R(e),range:l}}function Ne(e){return e.kinds.map(n=>{let r=n.fields.map(o=>`${o.name} (${o.type??"value"}${o.options?`: ${o.options.join(" | ")}`:""})`).join(", "),t=n.edges.map(o=>`${o.name} \u2192 ${o.to.join(" | ")}`).join(", "),s=Object.entries(n.roles).map(([o,i])=>`${o}=${i}`).join(", ");return`- ${n.kind} ("${n.plural}"): ${r}${t?`; relations: ${t}`:""}${s?`; roles: ${s}`:""}`}).join(`
|
|
2
|
+
`)}var Fe=['columns \u2014 a board, records in columns by one choice field: {"lens": "columns", "on": K, "bindings": {K: {"column": "<enum field>"}}}','calendar \u2014 records on a calendar by a date: {"lens": "calendar", "on": K, "bindings": {K: {"start": "<date field>", "end"?: "<date field>", "done"?: "<boolean field>"}}, "options": {"range"?: "day" | "week" | "month" | "quarter" | "year" | "agenda"}}','timeline \u2014 minutes of a day in columns: {"lens": "timeline", "on": K, "bindings": {K: {"start": "<number field>", "end": "<number field>", "column": "<enum field>"}}}','coverage \u2014 who covers what, a grid of two kinds joined by a relation: {"lens": "coverage", "on": K, "bindings": {"rows": {"kind": K}, "columns": {"kind": J}, "link": {"edge": "<relation of K to J>"}}}',`blocks \u2014 anything else, as blocks: {"lens": "blocks", "on": K, "options": {"blocks": [{"headline": "words"}, {"list": "all('K') where <condition>", "group"?: "<enum field>", "sort"?: "<field>" | {"by": "<field>", "direction": "desc"}, "as"?: "row" | "card", "empty"?: "words"}, {"figure": "count(all('K'))", "label": "words"}]}}. Conditions read a record's own fields: status == 'open', not done, days(today(), due) <= 7.`].join(`
|
|
3
|
+
`);function Ce(e,n,r){return["You draw a view of an app's data as JSON \u2014 never code. The app's kinds, their fields (with types) and relations:",Ne(n),"","The lenses you may use (prefer the first four; use blocks only when none of them fits):",Fe,"",r?`The view on screen now:
|
|
4
|
+
${JSON.stringify(r.lens)}
|
|
5
|
+
Change it as asked, and keep everything not asked about.`:"",`Asked: ${JSON.stringify(e)}`,'Answer with ONE JSON object: {"title": "<a few words, like Deliverables by status>", "lens": \u2026, "on": \u2026, "bindings"?: \u2026, "options"?: \u2026}. Name only the kinds, fields and relations listed above. If it cannot be drawn from them, answer {"failed": "<one sentence saying why>"}.'].filter(t=>t!=="").join(`
|
|
6
|
+
`)}async function le(e,n,r){let t=n.lastGood?{lastGood:n.lastGood}:{},s=I(L(n.app.schema,n.sight)),o;try{o=(await n.complete({prompt:Ce(e,s,r)})).text}catch{return{failed:"Couldn't draw that: the model did not answer.",...t}}let i=Y(o);if(typeof i!="object"||i===null||Array.isArray(i))return{failed:"Couldn't draw that: the model's answer was not a view.",...t};let a=i;if(typeof a.failed=="string")return{failed:`Couldn't draw that: ${a.failed.replace(/^Couldn't draw that:\s*/i,"").replace(/\.$/,"")}.`,...t};let l=de(a);if(!G(l.name))return{failed:`Couldn't draw that: "${l.name}" is not a picture the seat can draw.`,...t};let d=l.title?l.title.slice(0,80):r?.title??k(e.trim()).slice(0,80),c={...l,title:r&&r.title===d?d:C(d,n)},u=T(n.app,c,n.sight);return u.ok?{...W(n.app,c,u.drawn,n.sight,"model"),asks:[e]}:{failed:u.failed,...t}}function Qe(e,n,r){let t=[...e.lenses??[]];for(let s of n){let o={name:s.lens,title:s.title,on:s.on,...s.bindings?{bindings:s.bindings}:{},...s.options?{options:s.options}:{}};if(t.some(a=>a.title===o.title))continue;T({...e,lenses:t},o,r).ok&&(t=[...t,o])}return t.length===(e.lenses??[]).length?e:{...e,lenses:t}}async function Ze(e,n,r){let{app:t,drafts:s}=r,o=ue(t,r.principal),i=c=>{let u=de(c);return{lens:u,verdict:T(t,u,o)}};if(e==="keep_lens"){let{lens:c,verdict:u}=i(n);if(!u.ok)return{ok:!1,error:u.failed,reason:"invalid"};if(!s?.keep)return{ok:!1,error:"This app's declaration cannot be written from here."};let p=K(c),g=await s.keep(p);return g.ok?{ok:!0,data:{kept:p,said:g.said??`Adds \u201C${p.title}\u201D to the places.`,undo:ve(p)}}:{ok:!1,error:g.error}}if(n.lens!==void 0){let{lens:c,verdict:u}=i(n.lens);return u.ok?{ok:!0,data:te(W(t,c,u.drawn,o,"model"))}:{ok:!1,error:u.failed,reason:"invalid"}}let a={app:t,sight:o,...s?.complete?{complete:s.complete}:{},...s?.views?{views:s.views}:{}},l=String(n.ask??""),d;if(n.current!==void 0){let{lens:c,verdict:u}=i(n.current);if(!u.ok)return{ok:!1,error:u.failed,reason:"invalid"};d=await je(W(t,c,u.drawn,o,"model"),l,a)}else d=await Oe(l,a);return O(d)?{ok:!1,error:d.failed,reason:"invalid"}:{ok:!0,data:te(d)}}export{O as a,ue as b,T as c,K as d,ve as e,de as f,xe as g,W as h,te as i,Ye as j,Ie as k,Oe as l,je as m,Qe as n,Ze as o};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{a as le,b as I,d as ue,g as ye,h as me,i as pe}from"./chunk.EJAVIZ7Y.js";import{$ as q,C as T,Da as re,Eb as v,F as Z,Fa as ie,G as O,Gb as ce,H as B,Hb as C,I as V,Na as W,O as x,R as X,Ra as se,S as Y,Ta as de,Va as ae,W as j,Y as H,da as M,fa as L,ka as _,ma as J,sa as Q,ta as ee,ua as ne,va as te,ya as oe,yb as fe}from"./chunk.PFEKS3KO.js";var $e=t=>`${t}${t%100>=11&&t%100<=13?"th":["th","st","nd","rd"][t%10]??"th"}`,Re={day:"day",week:"week",month:"month",year:"year"},F=t=>t.length<2?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`;function xe(t,e,n){let o=e.interval??1,i=Re[e.every],s=t.slice(0,10),l=o===1?`Every ${i}`:o===2?`Every other ${i}`:`Every ${o} ${i}s`,d;if(e.every==="week"){let y=(e.on?.length?e.on:[W[new Date(`${s}T00:00:00Z`).getUTCDay()]]).map(r=>H(W.indexOf(r),"long",n));d=o===1?`Every ${F(y)}`:o===2?`Every other ${F(y)}`:`${l} on ${F(y)}`}else if(e.every==="month"){let y=(e.on?.length?e.on:[+s.slice(8,10)]).map(r=>r===-1?"the last day":`the ${$e(Number(r))}`);d=`${l} on ${F(y)}`}else e.every==="year"?d=`${l} on ${j(s,n)}`:d=l;return O.test(t)&&(d+=` at ${Y(t,n)}`),e.until&&(d+=`, until ${x(e.until,n)}`),e.count&&(d+=`, ${e.count===1?"once":`${e.count} times`}`),d}function ge(t,e,n={}){if(!de(e)||typeof t!="string")return;let o=n.today??V(),i=ae(t,e,o),s=xe(t,e,n.locale),l=i.slice(0,4)===o.slice(0,4)?j(i.slice(0,10),n.locale):x(i.slice(0,10),n.locale);return i.slice(0,10)<o?`${s}, last ${l}`:`${s}, next ${l}`}function on(t,e){let n=new Map,o=new Map;for(let i of t){let s=M(e(i.kind),i).trim().toLowerCase();o.set(s,[...o.get(s)??[],i])}for(let i of o.values()){if(i.length<2)continue;let s=new Map;for(let l of i)s.set(l.kind,[...s.get(l.kind)??[],l]);for(let[l,d]of s){if(d.length===1){n.set(d[0].id,J(e(l),l));continue}let y=d.map(f=>new Map(Se(f,e(f.kind)).map(m=>[m.key,m.alone]))),r=[...new Set(y.flatMap(f=>[...f.keys()]))],u=f=>y.every(m=>!/\d/.test(m.get(f)??"")),h=[...r.filter(u),...r.filter(f=>!u(f))],b=(f,m)=>m.map(p=>y[f].get(p)??"").filter(Boolean).join(" \xB7 "),S=f=>new Set(d.map((m,p)=>b(p,f))).size===d.length&&d.every((m,p)=>b(p,f)!==""),c=h.find(f=>S([f])),a=c?void 0:h.flatMap((f,m)=>h.slice(m+1).map(p=>[f,p])).find(f=>S(f));d.forEach((f,m)=>{if(c||a)return void n.set(f.id,b(m,c?[c]:a));let p=h.find($=>{let w=y[m].get($);return w!==void 0&&w!==""&&y.every((R,k)=>k===m||R.get($)!==w)});n.set(f.id,p?y[m].get(p):`${m+1} of ${d.length}`)})}}return n}function rn(t,e){return t?.describe?t.describe(e):`${e.kind} ${M(t,e)}`}var _e=new Set(["id","kind","label"]);function ve(t,e){if(e.length===0)return!1;let n=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&");return new RegExp(`(^|[\\s\xB7,(/])${n}($|[\\s\xB7,)/])`).test(t)}function Se(t,e,n={}){let o=e?.display,i=new Set([..._e,...o?.hide??[]]);typeof t.label=="string"&&e?.label&&!M(e,t).includes(t.label)&&i.delete("label");let s=(n.said??[]).filter(c=>!!c),l=s.filter(c=>c.endsWith("\u2026")).map(c=>c.replace(/…$/,"").trim()).filter(c=>c.length>12),d=[],y=e?.fields?.shape,r=e?.fieldRoles,u=n.glance?o?.glance??[r?.who,r?.when].filter(c=>!!c):he(o?.page),h=n.glance&&o?.glance!==void 0,S=[...new Set(h?u:[...u,...Ne(e),...Object.keys(t)])].filter(c=>Object.hasOwn(t,c)).map(c=>[c,t[c]]);for(let[c,a]of S){if(i.has(c)||a===void 0||a===null)continue;let f=o?.format?.[c],m=f?[]:ne(a);if(m[0]&&n.glance)continue;let p=e?.fields?.shape?.[c],$=!f&&typeof a=="string"&&oe(p)?a:void 0,w=!f&&typeof a=="string"&&le(p);if($&&n.glance)continue;let R=f?void 0:ie(p),k=R?{relation:R,refs:re(a,R)}:void 0;if(k&&(n.glance||k.refs.length===0)||!m[0]&&typeof a=="object"&&(!Array.isArray(a)||a.some(g=>typeof g=="object"&&g!==null))&&f===void 0)continue;let U=typeof a=="string"&&!f?ge(a,t[`${c}Repeat`],{locale:n.locale}):void 0,N=m[0]?m.map(g=>`${g.caption?`${g.name} \u2014 ${g.caption}`:g.name}${Q(g)?` (${ee(g)})`:""}`).join(", "):Array.isArray(a)?a.join(", "):typeof a=="boolean"?a?"Yes":"No":String(a),E=f?void 0:ye(e,c),G=pe(E,a),K=!f&&!E&&typeof a=="number"?v(e?.fields?.shape?.[c]):void 0,z=k?k.refs.length>1?`${k.refs.length} linked records`:"linked record":f?f(a):K?ce(a,K):me(E,a,n.locale)??(Array.isArray(a)||typeof a=="boolean"?N:typeof a=="string"&&U!==void 0?U:typeof a=="string"&&Z.test(a)?x(a,n.locale):typeof a=="string"&&O.test(a)?X(a,n.locale,n.timeZone):typeof a=="string"&&Fe(e,c)?I(e,c,a):N),P=typeof a=="string"&&Te(e,c,z),A=(n.glance||n.excerpt)&&!f&&(P||w)?ue(z,{markdown:w}):z;if(s.includes(A)||l.some(g=>A.startsWith(g))||n.glance&&(typeof a=="string"||typeof a=="number")&&s.some(g=>ve(g,A)))continue;let D=_(e,c),Ae=typeof a=="number"?`${D} ${A}`:typeof a=="boolean"&&!f?`${D}: ${A.toLowerCase()}`:A;if(d.push({key:c,label:D,value:A,stored:N,alone:Ae,long:P,...w?{markdown:!0}:{},...m[0]?{files:m}:{},...$?{app:$}:{},...k?{linked:k}:{},...G?{href:G}:{},...se(y?.[`${c}Repeat`])?{repeats:!0}:{}}),n.limit!==void 0&&d.length>=n.limit)break}return Oe(d,e)}function Oe(t,e){let n=new Map;for(let o of t){let i=Me(e,o.key);i&&n.set(o.key,new Set(i.map(s=>I(e,o.key,s).toLowerCase())))}return n.size<2?t:t.map(o=>{let i=n.get(o.key);return i!==void 0&&[...n].some(([l,d])=>l!==o.key&&[...i].some(y=>d.has(y)))?{...o,alone:`${o.label}: ${o.value.toLowerCase()}`}:o})}function Me(t,e){let n=t?.fields?.shape?.[e];for(let o=0;o<6&&n?._zod?.def?.innerType!==void 0;o++)n=n._zod.def.innerType;return n?._zod?.def?.type==="enum"&&n._zod.def.entries?Object.values(n._zod.def.entries).map(String):void 0}function Fe(t,e){let n=t?.fields?.shape?.[e];for(let o=0;o<6&&n?._zod?.def?.innerType!==void 0;o++)n=n._zod.def.innerType;return n?._zod?.def?.type==="enum"}function Ne(t){let e=t?.fields?.shape;return[...Object.keys(e??{}),...Object.keys(t?.computed??{})]}function he(t){return[...t?.fields??[],...(t?.groups??[]).flatMap(e=>e.fields)]}var Ee=500,ze=160;function De(t){let e=t;for(let n=0;n<6&&e?._zod?.def?.innerType!==void 0;n++)e=e._zod.def.innerType;return e?._zod?.def?.type==="string"?e._zod.def:void 0}function Te(t,e,n){return De(t?.fields?.shape?.[e])?.checks?.some(i=>i._zod?.def?.check==="max_length"&&(i._zod.def.maximum??0)>Ee)?!0:typeof n=="string"&&(n.includes(`
|
|
2
|
+
`)||n.length>ze)}function sn(t,e){let n=t?.display?.page,o=n?.groups??[],i=new Map(e.map(r=>[r.key,r])),s=new Set(he(n)),l=r=>r.flatMap(u=>i.has(u)?[i.get(u)]:[]),d=e.filter(r=>!s.has(r.key));return[{fields:[...l(n?.fields??[]),...o.length>0?[]:d]},...o.map(r=>({title:r.title,fields:l(r.fields)})),...o.length>0?[{title:"Details",fields:d}]:[]].filter(r=>r.fields.length>0)}function je(t,e,n){let o=[...e?.creates??[],...e?.subject&&e.subject.kinds!=="*"?e.subject.kinds:[]];for(let i of o){let s=t.tryDefinition(i),l=s?.fields?.shape??{};if(!s||!(n in l))continue;let d=s.display?.format?.[n];return{label:s.display?.labels?.[n]??_(s,n),option:r=>d?d(r):L(r)}}return{label:_(void 0,n),option:i=>L(i)}}function cn(t,e,n){if(n instanceof fe){let o=e.find(s=>s.name===n.mutation);return`Not yet: ${n.issues.map(s=>{let l=s.path.length>0?je(t,o,String(s.path[0])).label:void 0;return l?`${l} \u2014 ${q(s.message)}`:s.message}).join("; ")}.`}return n instanceof Error?n.message:String(n)}var Le=t=>/^[A-Z]{3}$/.test(t??"");function ke(t){let{format:e,unit:n,currency:o,locale:i}=t,s=Le(n),l=e==="money"||!e&&s,d=l?s?n:o:void 0;return{...l?{format:"money"}:e?{format:e}:{},...n&&!(l&&s)?{unit:n}:{},...d?{currency:d}:{},...i?{locale:i}:{}}}function yn(t){switch(t.format){case"money":return t.currency?`An amount of money in ${t.currency}: a plain number, 1250.5 for 1,250.50 ${t.currency}.`:"An amount of money, in no named currency: a plain number.";case"percent":return"A fraction said as a percent: 0.15 is 15%.";default:return t.unit?`A number of ${t.unit}.`:"A number."}}function be(t){let e=T(t)?.innerType;return e===void 0?t:be(e)}var We={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]},Ce=t=>(t?._zod?.def?.checks??[]).map(e=>e._zod?.def).filter(e=>e!==void 0);function we(t){let e=be(t),n=T(e),o=n?.type,i=Ce(e);if(o==="enum")return{type:"choice",options:Object.keys(n?.entries??{})};let s=te(e);if(s)return s==="image"?{type:"file",image:!0}:s==="video"?{type:"file",video:!0}:{type:"file"};if(o==="boolean")return{type:"boolean"};if(o==="array"){let l=we(n?.element);return l.type==="unknown"?{type:"unknown"}:{type:"several",of:l}}if(o==="number"){let l,d,y;for(let r of i){r.check==="multiple_of"&&typeof r.value=="number"?y=r.value:r.check==="number_format"&&(r.format==="safeint"||r.format==="int32"||r.format==="uint32")&&(y??=1);let u=r.check==="number_format"&&r.format?We[r.format]:void 0,h=u?u[0]:r.check==="greater_than"&&r.inclusive&&typeof r.value=="number"?r.value:void 0,b=u?u[1]:r.check==="less_than"&&r.inclusive&&typeof r.value=="number"?r.value:void 0;h!==void 0&&(l=l===void 0?h:Math.max(l,h)),b!==void 0&&(d=d===void 0?b:Math.min(d,b))}return{type:"number",...l===void 0?{}:{min:l},...d===void 0?{}:{max:d},...y===void 0?{}:{step:y},...C(e)==="duration"?{duration:!0}:{},...v(t)?{amount:ke(v(t))}:{}}}if(o==="string"){if(i.some(u=>u.fn===B||u.format==="datetime")||n?.format==="datetime")return{type:"date",time:!0,instant:!0};let d=[n?.pattern,...i.map(u=>u.pattern)].filter(u=>u instanceof RegExp).map(u=>u.source);if(d.some(u=>u.includes("\\d{4}")))return d.some(u=>u.includes("\\d{2}:\\d{2}"))?{type:"date",time:!0}:{type:"date"};let y=i.some(u=>u.check==="max_length"&&typeof u.maximum=="number"&&u.maximum>500),r=C(e);return y?{type:"text",long:!0}:r==="phone"||r==="place"?{type:"text",holds:r}:{type:"text"}}return{type:"unknown"}}function An(t,e){let n=t?.shape;return!n||!(e in n)?{type:"unknown"}:we(n[e])}export{xe as a,on as b,rn as c,Se as d,sn as e,ke as f,yn as g,be as h,we as i,An as j,je as k,cn as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as D}from"./chunk.PXQVXBNG.js";import{a as L,f as P,g as N,h as R}from"./chunk.G446PWV6.js";import{
|
|
1
|
+
import{a as D}from"./chunk.PXQVXBNG.js";import{a as L,f as P,g as N,h as R}from"./chunk.G446PWV6.js";import{gd as E}from"./chunk.PFEKS3KO.js";var z=e=>typeof e=="object"&&e!==null&&!Array.isArray(e),T=e=>e?._zod?.def;function W(e){let n=T(e);for(;n&&(n.type==="optional"||n.type==="default"||n.type==="nullable"||n.type==="prefault");)n=T(n.innerType);return n}function K(e){if(e?.type==="boolean")return["true","false"];if(e?.type==="enum")return(e.entries?Object.values(e.entries):e.values??[]).filter(n=>typeof n=="string")}var v=e=>e.replace(/([a-z])([A-Z])/g,"$1 $2").replace(/[-_]/g," ").replace(/^./,n=>n.toUpperCase());function J(e,n,i){let a=e.tryDefinition(n);if(!a)return[];let c=new Set(a.display?.hide??[]),r=[];for(let[s,l]of Object.entries(a.fields.shape??{})){if(s==="id"||s==="kind"||s==="label"||c.has(s))continue;let o=W(l);if(o?.type==="array"||o?.type==="object"||o?.type==="record")continue;let u=K(o);r.push({key:s,label:v(s),...u?{options:u}:{}})}let y=new Map;for(let[s,l]of Object.entries(a.edges??{}))y.set(s,l.to==="*"?[]:[...l.to]);for(let s of e.definitions)if(s.kind!==n)for(let[l,o]of Object.entries(s.edges??{}))!y.has(l)&&(o.to==="*"||o.to.includes(n))&&y.set(l,[s.kind]);let g=[];for(let[s,l]of y){r.push({key:s,label:v(s)});let o=i&&l.length===1&&l[0]!==n?e.tryDefinition(l[0]):void 0;for(let[u,f]of Object.entries(o?.fields.shape??{})){let p=W(f);p?.type==="enum"&&!o?.display?.hide?.includes(u)&&g.push({key:`${s}.${u}`,label:`${v(s)} \xB7 ${v(u)}`,options:K(p)})}}return r.push(...g),r.push({key:"is",label:"Is",options:a.lifecycle?["current","past","any","flagged","clear"]:["flagged","clear"]}),r}var I=e=>e.length<=1?e[0]??"":`${e.slice(0,-1).join(", ")} and ${e.at(-1)}`;function G(e,n,i,a={}){if(i==null)return{ok:!0};if(!z(i))return{ok:!1,says:'A filter is an object of a field and the value it keeps, like { where: { stage: "building" } }.'};let c=Object.entries(i);if(c.length===0)return{ok:!0};let r=[];for(let l of n)for(let o of J(e,l,a.through===!0))r.some(u=>u.key===o.key)||r.push(o);let y=n[0]?e.tryDefinition(n[0]):void 0,g=y?y.plural??`${v(y.kind)}s`:"These",s=[];for(let[l,o]of c){let u=r.find(p=>p.key===l);if(!u)return{ok:!1,says:`${g.replace(/^./,p=>p.toUpperCase())} have no field "${l}" to filter by${r.length>0?`; they filter by ${I(r.map(p=>p.key))}`:""}.`};if(typeof o!="string"&&typeof o!="number"&&typeof o!="boolean")return{ok:!1,says:`The filter on "${l}" is ${Array.isArray(o)?"a list":o===null?"null":`a ${typeof o}`}; it keeps one value: a word, a number, or true or false.`};let f=String(o);if(f.trim().length===0)return{ok:!1,says:`The filter on "${l}" keeps nothing; give it a value, or leave "${l}" out.`};if(f.includes(","))return{ok:!1,says:`The filter on "${l}" holds a comma, which an address reads as a second filter; keep one value.`};if(u.options&&u.options.length>0&&!u.options.includes(f))return{ok:!1,says:`${u.label} has no choice "${f}"; its choices are ${I(u.options.map(p=>`"${p}"`))}.`};s.push(`${l}:${f}`)}return{ok:!0,filter:s.join(",")}}var C=e=>e.toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-|-$/g,"");function q(e,n){let i=e.find(r=>r.as===n);if(i)return i;let a=n.trim().toLowerCase(),c=C(n);return e.find(r=>r.title!==void 0&&r.title.trim().toLowerCase()===a)??(c?e.find(r=>r.as===c||r.title!==void 0&&C(r.title)===c):void 0)}function Z(e){let n=[];for(let i of e){if(typeof i!="object"||i===null)continue;let{as:a,slug:c,title:r,kind:y}=i,g=typeof a=="string"&&a.length>0?a:typeof c=="string"&&c.length>0?c:void 0;!g||n.some(s=>s.as===g)||n.push({as:g,title:typeof r=="string"?r:g,kind:typeof y=="string"?y:""})}return n}var F=e=>` Its places: ${e.map(n=>typeof n=="string"?`"${n}"`:n.title&&n.title!==n.as?`"${n.as}" (${n.title})`:`"${n.as}"`).join(", ")||"none"}.`;var b=e=>`"${e.length>80?`${e.slice(0,79)}\u2026`:e}"`,O=(e,n)=>`${"place"in e?`The place ${b(e.place)}`:`${b(e.record)} is no record this viewer may see and`} is no place of this app: it goes nowhere.${F(n)}`;function S(e){let n={};for(let i of e.split(",")){let a=i.indexOf(":");a>0&&(n[i.slice(0,a).trim()]=i.slice(a+1).trim())}return n}function ne(e,n=new Set){return e.kinds.filter(i=>!n.has(i)).map(i=>({slug:E(e,i).slice(1),kind:i}))}function U(e,n){let i=[...new Set(n.places.map(f=>f.as))],a=n.lists.map(f=>f.slug).filter(f=>!i.includes(f)),c;if(e.section!==void 0&&e.section!==null){if(typeof e.section!="string"||D(e.section).length===0||e.section.length>120)return{ok:!1,says:`The section ${typeof e.section=="string"?b(e.section):"asked for"} names nothing on a page: a section is a heading's words or an element's id, like "shipping-soon". It goes nowhere.`};c=e.section}let r=c!==void 0?{section:c}:{};if("record"in e&&n.sees(e.record))return e.where!==void 0&&e.where!==null?{ok:!1,says:`${b(e.record)} is one record, and a filter narrows a list or a place: it goes nowhere. Go to { place, where } for a list narrowed.`}:{ok:!0,arrival:{record:e.record,...r}};let y="place"in e?e.place:e.record,g=q(n.places,y),s=g?void 0:n.lists.find(f=>f.slug===y||f.kind===y);if(!g&&!s)return{ok:!1,says:`${O(e,n.places.filter((f,p,m)=>m.findIndex(t=>t.as===f.as)===p))}${_(a)}`};let l=g?[g.kind]:[s.kind],o;if(e.where!==void 0&&e.where!==null){if(!n.schema)return{ok:!1,says:`The place ${b(y)} cannot be narrowed here: it goes nowhere.`};let f=G(n.schema,l,e.where,{through:s!==void 0});if(!f.ok)return{ok:!1,says:`The filter on ${b(y)} goes nowhere: ${f.says}`};o=f.filter}let u=o?{filter:o}:{};return{ok:!0,arrival:g?{place:g.as,...u,...r}:{list:s.kind,...u,...r}}}var _=e=>e.length===0?"":` Its lists: ${e.slice(0,8).map(n=>`"${n}"`).join(", ")}${e.length>8?` and ${e.length-8} more`:""}.`,M="http://www.w3.org/1999/xhtml",V=e=>{let n=e;return n.metaKey||n.ctrlKey||n.shiftKey||n.altKey||e.type==="click"&&typeof n.button=="number"&&n.button!==0};function re(e){let n=new WeakSet,i=new WeakSet,a=new WeakMap,c=new WeakMap,r=t=>U(t,{sees:e.sees,places:e.places(),lists:e.lists?.()??[],...e.schema?{schema:e.schema}:{}}),y=t=>{let d=r(t);return d.ok?e.onNavigate?.(d.arrival):e.onLost?.(d.says),d.ok},g=t=>{let d=t.getAttribute("data-record"),h=t.getAttribute("data-place"),k=t.getAttribute("data-filter"),w=t.getAttribute("data-section"),$={...k?{where:S(k)}:{},...w?{section:w}:{}};if(d)return{record:d,...$};if(h)return{place:h,...$}},s=t=>{if(!e.hrefOf)return;let d=g(t),h=d?r(d):void 0;return h?.ok?e.hrefOf(h.arrival):void 0},l=t=>t.hasAttribute("tabindex")?!1:(t.setAttribute("tabindex","0"),n.add(t),!0),o=t=>{n.delete(t)&&t.removeAttribute("tabindex")},u=t=>{i.delete(t)&&t.getAttribute("role")==="link"&&t.removeAttribute("role")},f=t=>{let d=a.get(t);d&&(a.delete(t),t.getAttribute("href")===d.href&&t.removeAttribute("href"),d.target!==null&&!t.hasAttribute("target")&&t.setAttribute("target",d.target))},p=t=>{let d=c.get(t);d&&(c.delete(t),o(d))},m={link(t){if(!N(t,[...t.querySelectorAll("input, select, textarea")].some(L))){if(!t.hasAttribute("data-graview-link"))return;t.removeAttribute("data-graview-link"),u(t),o(t),f(t),p(t);return}t.hasAttribute("data-graview-link")||t.setAttribute("data-graview-link","");let h=t.localName==="a"&&t.namespaceURI===M,k=t.getAttribute("href"),w=a.get(t),$=k!==null&&w?.href!==k,A=h&&!$?s(t):void 0;if(A!==void 0){k!==A&&t.setAttribute("href",A),a.set(t,{href:A,target:w?w.target:t.getAttribute("target")}),t.removeAttribute("target"),u(t),o(t);return}if($?a.delete(t):f(t),!t.hasAttribute("role")&&(h||P(t))&&(t.setAttribute("role","link"),i.add(t)),t.localName==="tr"&&t.namespaceURI===M){o(t);let x=[...t.children].find(j=>j.localName==="td"||j.localName==="th");c.get(t)!==x&&p(t),x&&!c.has(t)&&l(x)&&c.set(t,x);return}t.localName!=="button"&&l(t)},refresh(t){for(let d of t.querySelectorAll("[data-record], [data-place], [data-graview-link]"))m.link(d)},pressed(t,d,h){if(t.type!=="click"&&!(t.type==="keydown"&&t.key==="Enter"))return!1;let k=R(d,h,w=>w.hasAttribute("data-graview-link"));return k?(t.stopPropagation(),a.has(k)&&V(t)||(t.preventDefault(),m.follow(k)),!0):!1},follow(t){let d=g(t);d&&y(d)},go:y};return m}export{Z as a,F as b,b as c,O as d,S as e,ne as f,U as g,re as h};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{d as z,e as D,f as H}from"./chunk.
|
|
1
|
+
import{d as z,e as D,f as H}from"./chunk.BJR6E2CT.js";import"./chunk.VSWEKNKS.js";import{a as P,b as A,c as p,d as W}from"./chunk.UGFDSE37.js";import"./chunk.SGJSJGSR.js";import"./chunk.2OXXGN7C.js";import"./chunk.Q4KNNJFL.js";import"./chunk.BH365UJ5.js";import"./chunk.6EHE26ZS.js";import"./chunk.N2S3TMBC.js";import"./chunk.7JW5SHRR.js";import"./chunk.4SEY7VWZ.js";import"./chunk.IVHPJUFM.js";import"./chunk.D53IGR45.js";import"./chunk.MJ4XTNTL.js";import"./chunk.AP22NNIM.js";import"./chunk.SPZVEQC5.js";import"./chunk.FNK2ZZ5E.js";import"./chunk.RSR2M7ZO.js";import"./chunk.EM5CGFNB.js";import"./chunk.N2S45SSL.js";import"./chunk.AGVFW6WC.js";import"./chunk.SIVMZNHZ.js";import{a as C,b as O}from"./chunk.MB7LKKUD.js";import"./chunk.WVUJXDXZ.js";import"./chunk.NQDGUIUQ.js";import"./chunk.DTRNDSMS.js";import"./chunk.3EW6L5DY.js";import"./chunk.AVDXG57A.js";import"./chunk.LD6S2FL5.js";import"./chunk.TABIRLQS.js";import"./chunk.GZHZLJBF.js";import"./chunk.FOYVTN5B.js";import"./chunk.OJGHDWI6.js";import"./chunk.OTF3NNTI.js";import"./chunk.A7HMVWMG.js";import"./chunk.GRLPNTUW.js";import"./chunk.EJAVIZ7Y.js";import"./chunk.423SZS7C.js";import{G as B,Pa as k,R as L}from"./chunk.TM6JVVGW.js";import"./chunk.SDO3U72B.js";import{Hc as R}from"./chunk.PFEKS3KO.js";import"./chunk.2AZTW66C.js";import{b as E}from"./chunk.AJZBJBMO.js";var r=E(B(),1);var s=E(L(),1);function M(c){let e=document.activeElement;if(e!==null&&e!==document.body&&e!==document.documentElement&&e.isConnected)return;let n=c??document,o=n.querySelector("main")??n.querySelector("[data-graview-page]")??null,t=n.querySelector("[data-graview-page-title]")??o?.querySelector("h1, h2")??o;t instanceof HTMLElement&&(t.hasAttribute("tabindex")||t.setAttribute("tabindex","-1"),t.focus({preventScroll:!0}))}var I=1500;function N(c,e,n){let{store:o,principal:t}=c,l=z(o),g=(0,r.useMemo)(()=>P(o,t),[o,t,l]),w=(0,r.useRef)(n),[b,d]=(0,r.useState)(),[y,u]=(0,r.useState)("");(0,r.useEffect)(()=>{let a=A(o,t,w.current);w.current=o.batches().length,a&&(d({batch:a.batch,at:e,when:Date.now()}),u(""))},[o,t,l]),(0,r.useEffect)(()=>{d(a=>!a||a.at===e?a:Date.now()-a.when<I?{...a,at:e}:void 0)},[e]);let[x,i]=(0,r.useState)(null),v=(0,r.useCallback)(()=>{d(void 0),i(null)},[]),f=(0,r.useCallback)(()=>{i(null);try{let a=W(o,t);a&&u(`Took back \u201C${a.intent}\u201D`)}catch(a){i(a instanceof Error?a.message:String(a))}},[o,t]),S=g&&b?.batch===g.batch&&b.at===e?g:void 0;return{change:g,offered:S,close:v,takeBack:f,refused:x,said:y}}function ee({context:c,docked:e,at:n,since:o,compact:t=!1,className:l,size:g}){let{change:w,offered:b,close:d,takeBack:y,refused:u,said:x}=N(c,n,o),i=e?b:w,v=(0,r.useRef)(null),f=e&&(i!==void 0||u!==null);j(v,f),(0,r.useEffect)(()=>{if(!f)return;let m,h=()=>m=setTimeout(()=>v.current?.matches(":hover, :focus-within")?h():d(),1e4);return h(),()=>clearTimeout(m)},[f,i?.batch,u,d]);let S=x||(e&&i?p(i):""),a=e?{position:"fixed",inset:"auto",margin:0,padding:0,border:"none",background:"none",overflow:"visible",zIndex:R("toast"),width:"max-content",height:"auto",bottom:"calc(16px + env(safe-area-inset-bottom, 0px))",left:16,justifyItems:"start",color:"var(--graview-ink)",...f?{}:{display:"none"}}:{},T=i?(0,s.jsxs)("button",{type:"button","data-testid":"page-undo",title:`${p(i)} \u2014 \u2318Z or Ctrl+Z`,"aria-keyshortcuts":"Meta+Z Control+Z",onClick:m=>{let h=m.currentTarget.closest("[data-graview-face]");y(),requestAnimationFrame(()=>M(h))},...e?{style:U}:{className:H("graview-undo",l),...D(g),...t?{"data-compact":"","aria-label":p(i)}:{}},children:[(0,s.jsx)("span",{"aria-hidden":"true",children:"\u21B6"}),e?(0,s.jsx)("span",{style:K,children:p(i)}):(0,s.jsx)("span",{className:"graview-undo-words",children:t?"Undo":p(i)})]}):null;return(0,s.jsxs)(s.Fragment,{children:[(0,s.jsx)("span",{role:"status","aria-live":"polite",style:V,children:S}),(0,s.jsxs)("div",{ref:v,...e?{popover:"manual","data-graview-foot":"","data-graview-offstage":""}:{},"data-testid":e?"face-undo-dock":"page-undo-place",...e?{style:{...F,...a}}:{className:"graview-undo-place"},children:[e?null:(0,s.jsx)("style",{children:q}),e&&i?(0,s.jsxs)("div",{"data-testid":"page-undo-notice",style:Z,children:[T,(0,s.jsx)("button",{type:"button","data-testid":"page-undo-dismiss","aria-label":`Dismiss: ${p(i)}`,title:"Dismiss",onClick:m=>{let h=m.currentTarget.closest("[data-graview-face]");d(),requestAnimationFrame(()=>M(h))},style:$,children:"\xD7"})]}):T,u?(0,s.jsx)("span",{"data-testid":"page-undo-refused",role:"alert",className:"graview-undo-refused",...e?{style:{fontSize:"0.8125rem",lineHeight:1.4,color:"var(--graview-warn)",borderRadius:6,background:"var(--graview-float)",padding:"4px 8px"}}:{},children:u}):null]})]})}function j(c,e){(0,r.useLayoutEffect)(()=>{let n=c.current;if(!n||!e)return;if(typeof n.showPopover=="function"&&!k(n))try{n.showPopover()}catch{}let o=()=>n.parentElement?.closest("[data-embed-content]")??null,t=()=>{O(n,o()),dispatchEvent(new Event(C))};t(),addEventListener("resize",t),addEventListener("scroll",t,!0);let l=typeof ResizeObserver=="function"?new ResizeObserver(t):null;return l?.observe(n),()=>{if(l?.disconnect(),removeEventListener("resize",t),removeEventListener("scroll",t,!0),n.isConnected&&k(n))try{n.hidePopover()}catch{}dispatchEvent(new Event(C))}},[c,e])}var q=`:where(.graview-undo-place){display:grid;justify-items:end;gap:4px;max-width:100%;min-width:0}
|
|
2
2
|
:where(.graview-undo){box-sizing:border-box;display:inline-flex;align-items:center;gap:6px;min-height:var(--graview-control-height,36px);max-width:min(100%,var(--graview-undo-widest,18rem));min-width:0;padding:0 14px;border-radius:999px;border:1px solid var(--graview-edge);background:var(--graview-float);color:var(--graview-ink);font:inherit;font-size:.875rem;cursor:pointer}
|
|
3
3
|
:where(.graview-undo[data-size=sm]){--graview-control-height:30px}
|
|
4
4
|
:where(.graview-undo[data-compact]){padding:0 10px}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
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{s as P}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{s as P}from"./chunk.FOYVTN5B.js";import{$ as I,Da as S,G as M,O as w,R as y,_ as m,s as b,w as T,x as A}from"./chunk.TM6JVVGW.js";import{a as p}from"./chunk.SDO3U72B.js";import{b as f}from"./chunk.AJZBJBMO.js";var C=f(M(),1),h=f(y(),1),x=S(p(()=>(__graviewPreload(import.meta.url,["./chunk.423SZS7C.js","./chunk.TM6JVVGW.js","./chunk.SDO3U72B.js","./chunk.PFEKS3KO.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.XXZFWZ4C.js")))),O=x.part((e,n)=>(0,h.jsx)(e.Timeline,{...n}),{what:"The timeline"}),q=()=>x.prefetch();function K({face:e}){return w()?.open?(0,h.jsx)(C.Suspense,{fallback:null,children:(0,h.jsx)(O,{face:e})}):null}var i=f(M(),1),u=f(y(),1),v=new WeakMap,D=e=>{let n=v.get(e);return n||v.set(e,n={ask:null,doors:[],listeners:new Set}),n},k=e=>{for(let n of e.listeners)n()};function g(e,n){let t=D(e);t.ask=n,k(t)}var N=S(p(()=>(__graviewPreload(import.meta.url,["./chunk.2QKSWK4U.js","./chunk.AVDXG57A.js","./chunk.LD6S2FL5.js","./chunk.TABIRLQS.js","./chunk.423SZS7C.js","./chunk.TM6JVVGW.js","./chunk.SDO3U72B.js","./chunk.PFEKS3KO.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.QQRLUBWQ.js")))),B=N.part((e,n)=>{let t=e.NotifySheet;return(0,u.jsx)(t,{...n})},{what:"Notify me"}),W=N.part((e,n)=>{let t=e.NotifiedList;return(0,u.jsx)(t,{...n})},{quiet:!0}),E=(e,n)=>n===void 0&&(e.onBehalfOf??e).id!==void 0;function F(e,n,t){let c=d=>t.tryDefinition(d)?.noun??d.replace(/[-_]+/g," "),o=e.on!==void 0?e.on:e.about.length===1?e.about[0]:void 0;if(e.act!==void 0){let d=o!==void 0&&n(o)!==void 0?o:void 0;return{label:"Notify me when someone does this\u2026",choices:[{on:"act",act:e.act,...d!==void 0?{record:d}:{}},...d!==void 0?[{on:"act",act:e.act}]:[]]}}if(o===void 0)return null;let s=n(o);if(s!==void 0)return{label:"Notify me when this changes\u2026",choices:[{on:"changed",record:o},{on:"act",record:o},{on:"reaches",kind:s,condition:"",record:o}]};let r=b(o)!==null?[b(o)]:T(o)?A(o):[];if(r.length!==1||!t.kinds.includes(r[0]))return null;let l=r[0],a=c(l);return{label:`Notify me when ${/^[aeiou]/i.test(a)?"an":"a"} ${a} is added\u2026`,choices:[{on:"created",kind:l},{on:"changed",kind:l},{on:"reaches",kind:l,condition:""}]}}function L(){let{store:e,principal:n,subscriptions:t,signIn:c}=m(),o=E(n,c);return(0,i.useMemo)(()=>o?s=>{let r=F(s,a=>e.graph.getNode(a)?.kind,e.schema);return r?{id:"notify",items:[{id:"notify-me",label:r.label,run:()=>g(t,{choices:r.choices,returnTo:s.element??null})}],prepare:()=>N.prefetch()}:null}:null,[o,e,t])}var z=[];function U({children:e}){let n=L(),t=(0,i.useMemo)(()=>n?[n]:z,[n]);return(0,u.jsx)(P,{sections:t,children:e})}function V(){let{subscriptions:e}=m(),n=(0,i.useId)(),t=D(e);(0,i.useEffect)(()=>(t.doors.push(n),k(t),()=>{t.doors.splice(t.doors.indexOf(n),1),k(t)}),[t,n]);let c=(0,i.useMemo)(()=>r=>(t.listeners.add(r),()=>void t.listeners.delete(r)),[t]),o=(0,i.useSyncExternalStore)(c,()=>t.ask,()=>null),s=(0,i.useSyncExternalStore)(c,()=>t.doors[0]===n,()=>!1);return!o||!s?null:(0,u.jsx)(i.Suspense,{fallback:null,children:(0,u.jsx)(B,{ask:o,close:()=>g(e,null)})})}function X({choices:e,label:n="Notify me",style:t,className:c,testId:o="notify-me"}){let{principal:s,subscriptions:r,signIn:l}=m();return E(s,l)?(0,u.jsx)("button",{type:"button","data-testid":o,className:c,onClick:a=>g(r,{choices:e,returnTo:a.currentTarget}),style:t,children:n}):null}function G(){let e=I(),n=e?.subscriptions,t=e?(e.principal.onBehalfOf??e.principal).id:void 0,[c,o]=(0,i.useState)(0);return(0,i.useEffect)(()=>{if(t===void 0||!n)return;let s=!0,r=()=>void Promise.resolve(n.list(t)).then(a=>s&&o(a.length),()=>s&&o(0));r();let l=n.onChange?.(r);return()=>{s=!1,l?.()}},[n,t]),c}function Y({style:e}){return G()===0?null:(0,u.jsx)(i.Suspense,{fallback:null,children:(0,u.jsx)(W,{...e?{style:e}:{}})})}export{q as a,K as b,L as c,U as d,V as e,X as f,G as g,Y as h};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as ee,b as H,c as ne}from"./chunk.
|
|
1
|
+
import{a as ee,b as H,c as ne}from"./chunk.2OLZ6BYI.js";import{A as _,C as U,E as J,I as Q,K as X,N as Y,a as O,i as D,l as G,p as q,s as z,t as W,x as j,y as Z}from"./chunk.423SZS7C.js";import{Ea as $,G as ae,Na as K,R as M,_ as N,aa as T,ra as I}from"./chunk.TM6JVVGW.js";import{uc as C}from"./chunk.PFEKS3KO.js";import{b as F}from"./chunk.AJZBJBMO.js";var o=F(ae(),1);var u=F(M(),1),fe=e=>typeof e=="object"?e:{};function he({rootRef:e,firstLook:t,app:n}){let r=(0,o.useCallback)(()=>e.current,[e]);return t?(0,u.jsx)(Y,{firstLook:t,root:r,app:n}):null}function ge(e,t,n){let{app:r}=e,a=(0,o.useMemo)(()=>{let s=Q(t(r.schema,r.viewSpecs),r),d=n?se(s,n):s,i=e.views?e.views(r.schema,d):s,c=i===d?s:I(s,i);return X(c,r.schema,U(e.brand??r.brand,r.schema)),n?n.register(c):c},[e.views,r.schema,r.viewSpecs,r.lenses,r.pages,r.home,n]);return $(a,e.keptViews)}function se(e,t){let n={...e,register(r,a,s,d){return d?.name!==t.name&&e.register(r,a,s,d),n},...e.home?{home:r=>(t.home||e.home(r),n)}:{}};return n}var k=e=>e?e.getBoundingClientRect().height:0;function be(e,t,n){let r=(0,o.useRef)(n);r.current=n;let a=n!==void 0;(0,o.useLayoutEffect)(()=>{let s=e.current;if(!s||!a)return;let d=()=>{let p=[...s.children],h=p.find(b=>b.hasAttribute("data-graview-app-bar")),m=p.find(b=>b.hasAttribute("data-embed-content")),g=m?.querySelector("[data-embed-measure]")??null,l=p.find(b=>b.hasAttribute("data-graview-place-line"));return{strip:h,line:l,content:m,measure:g}},i=-1,c=()=>{let{strip:p,line:h,content:m,measure:g}=d(),l=Math.ceil(k(p)+k(h)+k(g||m));l!==i&&(i=l,r.current?.(l))};if(c(),typeof ResizeObserver>"u")return;let y=new ResizeObserver(c),R=()=>{y.disconnect();let{strip:p,line:h,content:m,measure:g}=d();for(let l of[s,p,h,m,g])l&&y.observe(l)};R();let w=new MutationObserver(()=>{R(),c()});return w.observe(s,{childList:!0}),()=>{y.disconnect(),w.disconnect()}},[e,t,a])}var we=480,ie=0;function Se(e){let{app:t,seed:n,scheme:r="auto",brand:a=t.brand,fonts:s=!0,height:d="100%",label:i}=e,c=(0,o.useRef)(null);K(c);let y=d==="viewport"?"100dvh":d,R=G(typeof y=="string"&&/vh\b/.test(y)),w=(0,o.useMemo)(()=>`graview-embed-${++ie}`,[]),p=(0,o.useMemo)(()=>e.store??e.remote?.store??H(t,n),[e.store,e.remote,t,n]),h=e.presence??e.remote?.presence,m=e.hostContext?.theme,g=ne(r==="auto"&&m===void 0,a?.scheme),l=r==="auto"?m??g:r,b=(0,o.useMemo)(()=>O(l,a,{scope:`.${w}`}),[l,a,w]);D(e.favicon?C(a):void 0),(0,o.useEffect)(()=>{if(!s||typeof document>"u")return;let v=ee(a);if(!v||document.querySelector(`link[href="${v}"]`))return;let f=document.createElement("link");f.rel="stylesheet",f.href=v,document.head.appendChild(f)},[a,s]);let A=(0,o.useRef)(void 0);(0,o.useLayoutEffect)(()=>{let v=c.current,f=A.current;if(A.current=i,!v||!i)return;let oe=S=>{let E=S.getAttribute("aria-label")??"",x=f&&f!==i?E.startsWith(`${f} \xB7 `)?E.slice(f.length+3):E===f?"":E:E;x===i&&(S.getAttribute("role")==="region"||S.tagName==="SECTION"&&!S.hasAttribute("role"))&&S.setAttribute("role","group");let P=x.startsWith(`${i} \xB7 `)||x===i?x:x?`${i} \xB7 ${x}`:i;P!==E&&S.setAttribute("aria-label",P)},B=()=>v.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(S=>{S.hasAttribute("data-graview-named-by-lens")||oe(S)});B();let V=new MutationObserver(B);return V.observe(v,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>V.disconnect()},[i]);let te=R?`${y}`.replace(/([\d.]+)[sdl]?vh\b/g,(v,f)=>`${+f*R/100}px`):y;return{rootRef:c,scope:w,css:b,scheme:l,store:p,presence:h,brand:a,auto:d==="auto",height:te}}function ve({rootRef:e,board:t}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,u.jsx)(q,{board:t,anchor:n})}function Re(e,t,n){return{brand:n,locale:e.locale,timeZone:e.timeZone,principal:e.principal,seats:e.seats,presence:t,people:e.people,memory:e.memory,presenceTtlMs:e.presenceTtlMs,onKeepLens:e.onKeepLens,ai:e.ai,files:e.files,resolveApp:e.resolveApp,history:e.history,linkedRecords:e.linkedRecords,subscriptions:e.subscriptions,keptViews:e.keptViews,signIn:e.signIn,menuSections:e.menuSections,app:e.app}}function Ee({name:e,heading:t,faces:n,at:r,without:a,home:s,reach:d,standing:i,hostActions:c,keeping:y,onFind:R,switch:w,named:p=!0}){let{brand:h,store:m,principal:g,views:l}=N();T();let b=a?.has("places")?[]:z({store:m,principal:g,views:l}),A=_();return(0,u.jsx)(j,{brand:h,name:e,named:p,description:h?.subtitle,heading:t,faces:n,home:s,places:b,current:r===null?null:W(b,r),reach:d,onFind:R,...w?{switch:w}:{},...n||r===null?{scenePlaces:A}:{},tools:(0,u.jsxs)(u.Fragment,{children:[(0,u.jsx)(J,{clean:i}),(0,u.jsx)(Z,{...c?{hostActions:c}:{},...y?{keeping:y}:{}})]})})}var xe=e=>e===!1?2:Math.min(e+1,6);function Ae(e){let[t,n]=(0,o.useState)(e),r=(0,o.useRef)(void 0),a=(0,o.useRef)(void 0),s=(0,o.useMemo)(()=>({go:r,at:n,pending:a}),[]),d=(0,o.useCallback)(i=>{if(r.current){r.current(i);return}a.current=i,n(i)},[]);return{at:t,setAt:n,steering:s,steer:d}}function de(e){let t=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof t=="string"&&t.length>0?t:typeof e=="object"?"Error":typeof e}}var L=()=>typeof performance<"u"?performance.now():Date.now();function ke(e,t){let n=(0,o.useRef)({onError:e,face:t});return n.current={onError:e,face:t},(0,o.useCallback)((r,a)=>n.current.onError?.(de(r),{module:a.module,face:n.current.face}),[])}function Fe(e,t){let n=(0,o.useRef)(null);n.current===null&&(n.current=L());let r=(0,o.useRef)({onReady:e,face:t});r.current={onReady:e,face:t};let a=(0,o.useRef)(!1);return(0,o.useCallback)(s=>{a.current||(a.current=!0,r.current.onReady?.({ms:Math.max(0,L()-(n.current??L())),face:s}))},[])}var re=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t,n){console.error(`[graview] ${this.props.module} threw while rendering`,t,n.componentStack),this.props.report(t,{module:this.props.module})}render(){return this.state.failed?(0,u.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,u.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,u.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,re as n};
|
|
@@ -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{$ as S,Da as C,F as g,G as T,R as v}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{$ as S,Da as C,F as g,G as T,R as v}from"./chunk.TM6JVVGW.js";import{a as m}from"./chunk.SDO3U72B.js";import"./chunk.PFEKS3KO.js";import"./chunk.2AZTW66C.js";import{b as c}from"./chunk.AJZBJBMO.js";var n=c(T(),1),r=c(v(),1),s=null,u=null,f=new Set,a=()=>{for(let e of f)e()},y=e=>(f.add(e),()=>void f.delete(e)),E=300,d=()=>{u!==null&&clearTimeout(u),u=null};function q(e,t){d(),x.prefetch(),!(s?.element===t&&s.target.on===e.on)&&(s={target:e,element:t},a())}function M(e=!1){if(d(),s!==null){if(e){s=null,a();return}u=setTimeout(()=>{u=null,s=null,a()},E)}}var R=()=>d(),P=()=>s,b="graview:hover-chips",h;function A(e){if(h!==void 0)return h;try{return(e??localStorage).getItem(b)!=="off"}catch{return!0}}function I(e,t){h=e;try{(t??localStorage).setItem(b,e?"on":"off")}catch{}e||(s=null),a()}function w(){let e=S(),t=g(e?.ai),o=e?.memory,l=(0,n.useSyncExternalStore)(y,()=>A(o),()=>!1),i=(0,n.useCallback)(H=>I(H,o),[o]);return{offered:t,on:t&&l,set:i}}function z({legend:e,style:t,choice:o}){let l=w();return l.offered?(0,r.jsxs)("fieldset",{"data-testid":"setting-hover-chips",style:{border:0,margin:0,padding:0,display:"grid",gap:5,...t},children:[(0,r.jsx)("legend",{style:{...e,padding:0},children:"AI suggestions on hover"}),(0,r.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:"A quiet suggestion beside a record the pointer rests on, when the AI is sure of one."}),(0,r.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:[!0,!1].map(i=>(0,r.jsx)("button",{type:"button","aria-pressed":l.on===i,"data-testid":`setting-hover-chips-${i?"on":"off"}`,onClick:()=>l.set(i),style:o(l.on===i),children:i?"On":"Off"},String(i)))})]}):null}var x=C(m(()=>(__graviewPreload(import.meta.url,["./chunk.ST4JHXPS.js","./chunk.3NEALGMI.js","./chunk.UT6642FC.js","./chunk.PBCT33FF.js","./chunk.XOZU4OFA.js","./chunk.35FUGOSG.js","./chunk.OL5D7YTW.js","./chunk.TI4OSTQV.js","./chunk.DTRNDSMS.js","./chunk.A7HMVWMG.js","./chunk.GRLPNTUW.js","./chunk.EJAVIZ7Y.js","./chunk.423SZS7C.js","./chunk.TM6JVVGW.js","./chunk.SDO3U72B.js","./chunk.PFEKS3KO.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.BTORFVKO.js")))),k=x.part((e,t)=>{let o=e.HoverChip;return(0,r.jsx)(o,{...t})},{quiet:!0}),p=null,O=()=>p;function L(){let{on:e}=w(),t=(0,n.useSyncExternalStore)(y,P,()=>null),[o]=(0,n.useState)(()=>Symbol("hover-chip")),l=(0,n.useSyncExternalStore)(y,O,()=>null);return(0,n.useEffect)(()=>{if(e)return p===null&&(p=o,a()),()=>{p===o&&(p=null,s=null,d(),a())}},[e,o,l]),!e||t===null||l!==o||!t.element.isConnected?null:(0,r.jsx)(n.Suspense,{fallback:null,children:(0,r.jsx)(k,{rest:t,hold:R,leave:M})})}export{L as HoverChipDoor,z as HoverChipsSwitch,R as holdRest,A as hoverChipsWanted,M as leaveRest,q as restOn,I as setHoverChipsWanted,w as useHoverChipsSetting};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as ve,b as qe,c as Ie,d as pe,e as R,f as fe,h as Ve}from"./chunk.54PZWX23.js";import{h as Le,i as Ue,j as We}from"./chunk.3EW6L5DY.js";import{a as se,b as ie,c as H,d as Be,e as J,g as ne,h as Ze}from"./chunk.LD6S2FL5.js";import{c as _e,h as y,i as Ne,j as le}from"./chunk.TABIRLQS.js";import{A as Re,Aa as Fe,Ha as De,Ia as ee,Ja as ce,Nb as Ke,Ob as de,Pb as Me,Qb as Pe,Rb as Te,b as W,c as L,dc as Ge,e as xe,ec as Ce,f as Ee,g as q,h as O,k as C,l as X,m as _,n as Ae,o as U,p as K,r as $,s as Q,t as x,u as E,v as B,w as P,x as n,y as M,z as Z}from"./chunk.PFEKS3KO.js";var ue=e=>Object.entries(e).map(([s,r])=>[s,Object.keys(ee(r?.edges))]),me=(e,s)=>Me(e,ue(s));function Ye(e){return[...Object.keys(e.acts??{}),...Object.keys(e.kinds).flatMap(s=>Ke(s)),...Pe(ue(e.kinds))]}var I=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function He(e){if(!I(e)||!I(e.kinds))return e;let s;try{let f=Object.fromEntries(Object.entries(e.kinds).map(([z,i])=>[z,I(i)&&I(i.edges)?{edges:i.edges}:{}]));s=Ye({acts:I(e.acts)?e.acts:{},kinds:f})}catch{return e}let r=new Set(s),t=!1,a=f=>{if(typeof f!="string"||r.has(f))return f;let z=Ge(f,s);return z===void 0?f:(t=!0,z)},d=I(e.policy)&&Array.isArray(e.policy.grants)?{...e.policy,grants:e.policy.grants.map(f=>I(f)&&Array.isArray(f.mutations)?{...f,mutations:f.mutations.map(a)}:f)}:void 0,u=I(e.rules)?Object.fromEntries(Object.entries(e.rules).map(([f,z])=>[f,I(z)&&Array.isArray(z.repairs)?{...z,repairs:z.repairs.map(i=>I(i)?{...i,act:a(i.act)}:i)}:z])):void 0;return t?{...e,...d?{policy:d}:{},...u?{rules:u}:{}}:e}function ge(e,s){let r=Ce(e,Ye(s));return r&&r!==e?`did you mean "${r}"?`:void 0}var he="graview-document",be=1,ke=256*1024,te=64*1024,ze=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,ye=/^[a-z][A-Za-z0-9]*$/,zn=new Set(["id","kind"]),yn=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,hn=["string","text","number","integer","boolean","date","datetime","enum","list","url","email","image","video","file","app-link","phone","place","duration"];function bn(){let e=k=>k in Object.prototype,s=Z(k=>!e(k),"every object already has this name \u2014 choose another"),r=(k,N)=>[...k===void 0?[]:[Ee(k)],...N===void 0?[]:[xe(N)]],t=(k,N)=>O().check(...r(k,N)),a=(k,N,gn)=>K(k).check(...r(N,gn)),d=k=>O().check(q(ze,`${k} names are kebab-case, lower-case words joined by hyphens like "tool-note" (field and relation names are camelCase, like "supersededBy")`)),u=O().check(q(yn,'relation names are one camelCase word, like "supersededBy" (kind names are kebab-case, like "tool-note")'),s),f=O().check(q(ye,'field names are one word or camelCase, like "dueDate", so rules say them bare (kind names are kebab-case, like "tool-note")'),Z(k=>!zn.has(k),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),s),z=t(1,500),i=t(1,2e3),o=t(1,300),p=$({type:B(hn),required:n(_()),description:n(z),label:n(t(1,60)),options:n(a(t(1,80),1,100)),of:n(B(["string","number","date","image","video","file"])),default:n(U()),unit:n(t(void 0,12)),format:n(B(["money","percent","duration","markdown"])),min:n(C()),max:n(C()),step:n(C()),renamedFrom:n(O().check(q(ye))),repeats:n(_())}).check(Re((k,N)=>{k.type==="enum"&&!k.options&&N.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),k.type!=="enum"&&k.options&&N.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),k.type!=="list"&&k.of&&N.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]}),k.repeats&&k.type!=="date"&&k.type!=="datetime"&&N.addIssue({code:"custom",message:'"repeats" belongs only on a date or datetime field',path:["repeats"]})})),w=O().check(q(new RegExp(`${ze.source}|${Fe.source}`),'a relation goes to a kind of this document, like "house", or of another app, like "@nick/house/house"')),m=$({to:x([a(w,1),P("*")]),cardinality:n(B(["one","many"])),description:n(z),inverse:n(t(1,80)),appendOnly:n(_()),renamedFrom:n(O()),tidying:n(P("never"))}),l=x([i,$({expr:i,label:n(t(1,60)),description:n(z)})]),c=$({noun:n(t(1,40)),plural:n(t(1,40)),description:n(z),fields:E(f,p).check(Z(k=>Object.keys(k).length>0,"a kind has at least one field")),label:n(o),describe:n(o),lifecycle:n($({field:f,retired:a(x([O(),C(),_()]),1)})),figure:n(t(void 0,2e4)),glance:n(a(f,1,20)),page:n($({fields:n(a(f,1,40)),groups:n(a($({title:t(1,60),fields:a(f,1,40)}),1,12))})),edges:n(E(u,m)),computed:n(E(O(),l).check(Z(k=>Object.keys(k).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:n(E(O(),O())),renamedFrom:n(O().check(q(ze))),people:n(_()),archives:n(P(!1)),tidying:n(B(["never","no-links"]))}),j=x([O(),C(),_(),Ae(),K(U()),$({expr:i})]),h=O().check(q(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),S=x([$({create:d("kind"),as:n(O().check(q(ye))),set:n(E(f,j))}),$({set:E(f,j),target:n(h)}),$({connect:u,from:h,to:h}),$({sever:u,from:h,to:h}),$({remove:h})]),A=$({title:n(t(1,80)),description:n(z),fromTheOtherEnd:n(t(1,80)),on:n(x([d("kind"),a(d("kind"),1)])),creates:n(d("kind")),sets:n(E(f,j)),writes:n(a(f,1)),connects:n(u),severs:n(u),setsOther:n(E(f,j)),replaces:n(x([P(!0),a(u,1,10)])),removes:n(P(!0)),args:n(E(f,p)),effects:n(a(S,1,20)),allowedWhen:n(i),refusal:n(o),destructive:n(_())}),b=$({act:d("act"),label:n(t(1,80)),args:n(E(O(),j))}),G=$({title:n(t(1,120)),description:n(z),over:x([P("graph"),d("kind")]),when:n(i),require:i,says:n(o),repairs:n(a(b,void 0,10))}),F=$({roles:x([a(d("role"),1),P("*")]),mutations:x([a(d("act"),1),P("*")]),kinds:n(x([K(d("kind")),P("*")])),describe:n(z),self:n(_()),ownEnd:n(_())}),g=n(a(d("field"),1)),v=$({roles:x([a(d("role"),1),P("*")]),kinds:a(d("kind"),1),own:n(_()),via:n(u),fields:g,hide:g}),D=$({grants:K(F),sees:n(K(v))}),oe=$({accent:n(O().check(q(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:n(t(1,60)),currency:n(O().check(q(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:n(t(2,35)),timeZone:n(t(1,64)),logo:n(x([t(1,te),$({src:t(1,te),alt:n(t(1,120))}),$({light:t(1,te),dark:n(t(1,te)),alt:n(t(1,120)),darkFallback:n(P("invert"))})])),favicon:n(x([t(1,te),$({emoji:O()})])),typography:n($({display:n(t(1,200)),body:n(t(1,200)),mono:n(t(1,200))})),shape:n($({radius:n(C().check(L(0),W(32))),density:n(C().check(L(.75),W(1.5)))})),accents:n(E(O(),C().check(L(0),W(360)))),scheme:n(B(["light","dark","auto"])),subtitle:n(P(!1))}),V=E(O(),U()),Y=x([t(1,120),$({by:t(1,120),direction:n(B(["asc","desc"]))})]),je=C().check(X(),L(1),W(9999)),dn=Q({create:n(_()),options:n(Q({sort:n(Y),columnSort:n(Y),search:n(a(t(1,120),void 0,40)),filters:n(a(t(1,120),void 0,40)),horizon:n(x([C().check(X(),L(1),W(200)),Q({years:C().check(X(),L(1),W(200)),title:t(1,80),from:n(je),to:n(je)})]))}))}),ln=$({card:n(K(U())),row:n(K(U())),page:n(K(U()))}),pn=()=>{let k=n(B(["asc","desc"]));return x([t(1,120),$({by:t(1,120),direction:k,then:n(x([t(1,120),$({by:t(1,120),direction:k})]))})])},fn=()=>x([t(1,120),$({by:t(1,120),order:n(a(t(1,80),void 0,40)),closed:n(a(t(1,80),void 0,40))})]),Oe=Q({order:n(K(O())),hide:n(K(O())),first:n(O()),primary:n(a(t(1,80),void 0,40)),scene:n(t(1,40)),pages:n(t(1,40)),lists:n(E(O(),$({filters:n(a(t(1,120),void 0,40)),sort:n(pn()),group:n(fn())})))}),un=$({act:d("act"),title:n(t(1,80)),intro:n(z),fields:n(a(f,1,40)),say:n(z),submit:n(t(1,80)),role:n(d("role"))}),mn=$({$schema:n(O()),format:P(he),formatVersion:P(be),name:t(1,80),description:n(z),version:n(C().check(X(),L(1))),kinds:E(d("kind"),c).check(Z(k=>Object.keys(k).length>0,"a document declares at least one kind"),Z(k=>Object.keys(k).length<=40,"a document declares at most 40 kinds")),computed:n(E(O(),l)),acts:n(E(d("act"),A)),rules:n(E(d("rule"),G)),roles:n(K(d("role"))),policy:n(D),modules:n(V),lenses:n(K(dn)),pages:n(Oe),views:n(E(O(),x([ln,K(U())]))),brand:n(oe),settings:n(K(V)),migrations:n(K(V)),connections:n(E(d("connection"),V)),forms:n(E(d("form"),un))});return{FieldSpec:p,EdgeSpec:m,ComputedSpec:l,KindSpec:c,ValueSpec:j,EffectSpec:S,ActSpec:A,RepairSpec:b,RuleSpec:G,GrantSpec:F,SightSpec:v,PolicySpec:D,BrandSpec:oe,PagesSpec:Oe,DocumentSpec:mn}}var kn,T=()=>kn??=bn(),_n=M(()=>T().FieldSpec),Nn=M(()=>T().EdgeSpec),qn=M(()=>T().ComputedSpec),In=M(()=>T().KindSpec),Vn=M(()=>T().ValueSpec),Bn=M(()=>T().EffectSpec),Ln=M(()=>T().ActSpec),Un=M(()=>T().RepairSpec),Wn=M(()=>T().RuleSpec),Zn=M(()=>T().GrantSpec),Yn=M(()=>T().SightSpec),Hn=M(()=>T().PolicySpec),Jn=M(()=>T().BrandSpec),Xn=M(()=>T().PagesSpec),Je=M(()=>T().DocumentSpec);var $n={};function Xe(e,s=$n,r=be){let{document:t,respelled:a}=ve(e),d=a.length>0?{respelled:a}:{};if(!t||typeof t!="object"||Array.isArray(t))return{document:t};let u=t;if(u.format!==he||typeof u.formatVersion!="number"||u.formatVersion>=r)return{document:t,...d};let f=u.formatVersion,z=structuredClone(u);for(let i=f;i<r;i++){let o=s[i];if(!o)throw new Error(`there is no upgrade from format ${i} to ${i+1}`);z={...o(z),formatVersion:i+1}}return{document:z,from:f,...d}}function Qe(e,s,r){let t=Object.keys(e).filter(f=>e[f].edges?.[s]!==void 0);if(t.length===0)return;let a=t.map(f=>e[f].edges[s].to),d=a.some(f=>f==="*")?"*":[...new Set(a.flatMap(f=>f))];if(r.length===0||r.some(f=>t.includes(f)))return{reversed:!1,kinds:d};let u=t.filter(f=>{let z=e[f].edges[s].to;return z==="*"||r.every(i=>z.includes(i))});return u.length>0?{reversed:!0,kinds:u}:{reversed:!1,kinds:d}}var tn=(e,s)=>{let r=e?.fields[s];return r!==void 0&&(r.type==="duration"||(r.type==="number"||r.type==="integer")&&r.format==="duration")};function en(e,s,r,t){if(t==="out"){let a=e[s]?.edges?.[r]?.to;return a===void 0?[]:a==="*"?Object.keys(e):a}return Object.entries(e).filter(([,a])=>{let d=a.edges?.[r]?.to;return d!==void 0&&(d==="*"||d.includes(s))}).map(([a])=>a)}function $e(e,s,r){if(r.t==="ident")return e[s]?.edges?.[r.name]?en(e,s,r.name,"out"):void 0;if(r.t==="where")return $e(e,s,r.set);if(r.t==="call"&&(r.fn==="out"||r.fn==="in")&&r.args[0]?.t==="lit"&&typeof r.args[0].value=="string")return en(e,s,r.args[0].value,r.fn)}var nn=(e,s,r)=>{let t=s.filter(a=>e[a]?.fields[r]!==void 0);return t.length>0&&t.every(a=>tn(e[a],r))};function on(e,s,r){let t=e.kinds,a=t[s],d=new Map(r),u=new Map,f=(i,o)=>{if(o>8)return!1;switch(i.t){case"ident":return tn(a,i.name)||z(i.name,o+1);case"member":{let p=$e(t,s,i.object);return p!==void 0&&nn(t,p,i.name)}case"call":{if(i.fn!=="sum"&&i.fn!=="min"&&i.fn!=="max")return!1;let[p,w]=i.args,m=p&&$e(t,s,p);return m!==void 0&&w?.t==="ident"&&nn(t,m,w.name)}case"binary":return(i.op==="+"||i.op==="-")&&f(i.left,o)&&f(i.right,o);case"unary":return i.op==="-"&&f(i.operand,o);default:return!1}},z=(i,o)=>{if(a?.computed?.[i]===void 0)return!1;if(u.has(i))return u.get(i);u.set(i,!1);let p=d.get(i),w=p!==void 0&&f(p,o);return u.set(i,w),w};return r.map(([i])=>i).filter(i=>z(i,0))}function sn(e,s,r=`kinds.${e}.page`){let t=s.page;if(!t)return[];let a=[],d=[...Object.keys(s.fields),...Object.keys(s.computed??{})],u=new Set,f=(i,o)=>{d.includes(i)?u.has(i)&&a.push(y("page-field-twice",o,`"${i}" is on ${e}'s page twice; name each field once`)):a.push(y("page-field",o,`${e}'s page is to show "${i}", and ${e} has no field or computed field called that`,`use one of: ${d.join(", ")}`)),u.add(i)};(t.fields??[]).forEach((i,o)=>f(i,`${r}.fields.${o}`));let z=new Set;return(t.groups??[]).forEach((i,o)=>{let p=i.title.trim().toLowerCase();z.has(p)&&a.push(y("page-group-twice",`${r}.groups.${o}.title`,`${e}'s page has two groups called "${i.title}"; give each its own title`)),z.add(p),i.fields.forEach((w,m)=>f(w,`${r}.groups.${o}.fields.${m}`))}),a}function rn(e,s=[]){return Te({declared:Object.keys(e.fields),paged:[...e.page?.fields??[],...(e.page?.groups??[]).flatMap(r=>r.fields)],must:r=>!!e.fields[r].required&&e.fields[r].default===void 0,naming:s})}var wn=new Set(["subject","now","today","me"]);function Sn(e){if((typeof e=="string"?e:JSON.stringify(e??null)).length>ke)return{findings:[y("too-large","",`a document may be at most ${ke/1024} KB`)]};if(typeof e=="string")try{e=JSON.parse(e)}catch(t){return{findings:[y("not-json","",`this is not JSON: ${t.message}`)]}}try{e=Xe(e).document}catch(t){return{findings:[y("format","formatVersion",t.message)]}}e=He(e);let s=Je.safeParse(e);if(!s.success)return{findings:s.error.issues.map(t=>{let a=t.path.map(String).join(".");if(t.code==="unrecognized_keys")return y("unknown-key",a,`${t.keys.map(d=>`"${d}"`).join(", ")} ${t.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(t.code==="invalid_union"&&/\.effects\.\d+$/.test(a))return y("effect-shape",a,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(t.code==="invalid_key"){let d=t.issues?.[0]?.message;return y("shape",a,`the name "${String(t.path.at(-1))}" is not allowed here${d?`: ${d}`:""}`)}return y("shape",a,t.message)})};let r=s.data;return{document:r,findings:jn(r)}}var ae=e=>[e??[]].flat();function an(e){let s=new Map;for(let[r,t]of Object.entries(e.kinds))for(let[a,d]of Object.entries(ee(t.edges))){let u=s.get(a);s.set(a,{name:a,from:[...u?.from??[],r],to:d.to==="*"||u?.to==="*"?"*":[...new Set([...u?.to??[],...d.to])],cardinality:d.cardinality??"many"})}return s}function Et(e){let s=new Map;for(let[t,a]of Object.entries(e.kinds)){let d=ne(a),u=ce(a.edges);s.set(t,{fields:new Set([...Object.keys(a.fields),...u.keys()]),edges:new Map(Object.entries(ee(a.edges)).map(([f,z])=>[f,z.cardinality??"many"])),...d?{computed:d}:{},...u.size>0?{linked:u}:{}})}let r=ne(e);return r&&s.set(_e,{computed:r}),s}function cn(e,s){let r=[],t=ae(e.on),a=(d,u)=>{let f=Qe(s.kinds,d,t)?.reversed===!0,[z,i]=f?["$to","$subject"]:["$subject","$to"];return u==="connect"?{connect:d,from:z,to:i}:{sever:d,from:z,to:i}};if(e.creates){let d=s.kinds[e.creates],u={};for(let f of Object.keys(d?.fields??{}))u[f]=`$${f}`;for(let f of e.effects??[])"set"in f&&!("create"in f)&&R(f.target)==="new"&&Object.assign(u,f.set);r.push({create:e.creates,as:"new",set:u})}return e.sets&&r.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&r.push({set:Object.fromEntries(e.writes.map(d=>[d,`$${d}`]))}),e.connects&&(e.replaces&&r.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),r.push(a(e.connects,"connect"))),e.severs&&r.push(a(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&r.push({set:e.setsOther,target:"$to"}),e.removes&&r.push({remove:"$subject"}),e.effects&&r.push(...e.effects.filter(d=>!(e.creates&&"set"in d&&!("create"in d)&&R(d.target)==="new"))),r}function we(e,s,r){try{let t=H(e),a=se(t);for(let d of a.unknownFunctions)r.push(y("unknown-function",s,`"${d}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return t}catch(t){if(t instanceof ie){r.push(y("expression",s,t.sentence+` (at character ${t.at+1})`));return}throw t}}function Se(e,s,r){try{return J(e)}catch(t){if(t instanceof Be||t instanceof ie){r.push(y("template",s,(t instanceof ie,t.sentence)));return}throw t}}function jn(e){let s=[],r=new Set(Object.keys(e.kinds)),t=an(e),a=e.acts??{},d=new Set(e.roles??[]),u=(i,o)=>ce(e.kinds[i]?.edges).has(o),f=i=>Object.keys(e.kinds).some(o=>u(o,i));for(let[i,o]of Object.entries(e.kinds)){let p=`kinds.${i}`;for(let[m,l]of Object.entries(o.edges??{})){if(!De(l)&&l.to!=="*")for(let c of l.to)r.has(c)||s.push(y("edge-target",`${p}.edges.${m}.to`,`"${c}" is not a kind this document declares`));o.fields[m]&&s.push(y("edge-field-clash",`${p}.edges.${m}`,`"${m}" is both a field and a relation of ${i}`,"rename one of them"))}o.lifecycle&&!o.fields[o.lifecycle.field]&&s.push(y("lifecycle-field",`${p}.lifecycle.field`,`${i} has no field "${o.lifecycle.field}"`));let w=m=>o.computed!==void 0&&Object.hasOwn(o.computed,m);for(let m of o.glance??[])!o.fields[m]&&!w(m)&&s.push(y("glance-field",`${p}.glance`,`a glance at ${i} is to say "${m}", and ${i} has no field or computed field called that`,`use one of: ${[...Object.keys(o.fields),...Object.keys(o.computed??{})].join(", ")}`));s.push(...sn(i,o));for(let m of["label","describe"]){let l=o[m];if(!l)continue;let c=Se(l,`${p}.${m}`,s);for(let j of c??[])if(j.expr){for(let h of se(j.expr).names)if(!o.fields[h]){if(w(h)){Ze(o,h)||s.push(y("template-field",`${p}.${m}`,`${i}'s ${h} is worked out from beyond the record, and a ${m} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${i}'s own fields`));continue}s.push(y("template-field",`${p}.${m}`,`${i} has no field "${h}" for its ${m} to show`,m==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[m,l]of Object.entries(o.fields)){l.default!==void 0&&l.type==="enum"&&!l.options?.includes(String(l.default))&&s.push(y("default-option",`${p}.fields.${m}.default`,`"${String(l.default)}" is not one of ${m}'s options`));let c=`${m}Repeat`;l.repeats&&(o.fields[c]||o.edges?.[c]||o.computed?.[c])&&s.push(y("repeat-clash",`${p}.fields.${m}.repeats`,`${i} already has "${c}", where how ${m} repeats is kept`))}}for(let[i,o]of Object.entries(a)){let p=`acts.${i}`;for(let c of ae(o.on))r.has(c)||s.push(y("act-kind",`${p}.on`,`"${c}" is not a kind this document declares`));let w=ae(o.on),m=cn(o,e);if(o.creates&&o.on===void 0&&o.writes&&r.has(o.creates)){for(let c of o.writes)if(!e.kinds[o.creates].fields[c])if(e.kinds[o.creates].computed?.[c]!==void 0)s.push(y("computed-written",`${p}.writes`,`${o.creates}'s ${c} is worked out, not written: no act can set it`,"write the stored fields it is worked out from"));else{if(u(o.creates,c))continue;s.push(y("act-field",`${p}.writes`,`${o.creates} has no field "${c}"`))}}m.length===0&&s.push(y("act-empty",p,`"${i}" does nothing`,"give it effects or a shorthand such as sets or creates"));let l=new Map;m.forEach((c,j)=>{let h=m.length-(o.effects?.length??0),S=o.effects&&j>=h?`${p}.effects.${j-h}`:p;if("create"in c){if(!r.has(c.create))s.push(y("act-kind",`${S}.create`,`"${c.create}" is not a kind this document declares`));else for(let b of Object.keys(c.set??{}))e.kinds[c.create].fields[b]||(e.kinds[c.create].computed?.[b]!==void 0?s.push(y("computed-written",`${S}.set.${b}`,`${c.create}'s ${b} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):s.push(y("act-field",`${S}.set.${b}`,`${c.create} has no field "${b}"`)));c.as&&l.set(c.as,c.create)}else if("connect"in c||"sever"in c){let b="connect"in c?c.connect:c.sever;!t.has(b)&&!f(b)&&s.push(y("act-edge",`${S}.${"connect"in c?"connect":"sever"}`,`"${b}" is not a relation any kind declares`)),R(c.from)==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in c){let b=R(c.target??"$subject"),G=b==="subject"?w:l.has(b??"")?[l.get(b)]:[];b==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" changes "$subject" but does not say which kinds it is "on"`));for(let F of Object.keys(c.set))for(let g of G)if(!(!r.has(g)||e.kinds[g].fields[F]))if(e.kinds[g].computed?.[F]!==void 0)s.push(y("computed-written",`${S}.set.${F}`,`${g}'s ${F} is worked out, not written: no act can set it`,"set the stored fields it is worked out from"));else{if(u(g,F))continue;s.push(y("act-field",`${S}.set.${F}`,`${g} has no field "${F}"`))}}else"remove"in c&&R(c.remove)==="subject"&&w.length===0&&s.push(y("act-subject",`${p}.on`,`"${i}" removes "$subject" but does not say which kinds it is "on"`));("set"in c&&c.set?Object.values(c.set):[]).forEach(b=>{b&&typeof b=="object"&&!Array.isArray(b)&&"expr"in b&&we(b.expr,`${S}.set`,s)})}),o.allowedWhen&&we(o.allowedWhen,`${p}.allowedWhen`,s),o.refusal&&Se(o.refusal,`${p}.refusal`,s)}for(let[i,o]of Object.entries(e.rules??{})){let p=`rules.${i}`;o.over!=="graph"&&!r.has(o.over)&&s.push(y("rule-kind",`${p}.over`,`"${o.over}" is not a kind this document declares`));let w=o.over==="graph"?void 0:e.kinds[o.over];for(let m of["when","require"]){let l=o[m];if(!l)continue;let c=we(l,`${p}.${m}`,s);if(!c)continue;let j=se(c);for(let h of j.names)if(o.over==="graph")s.push(y("rule-name",`${p}.${m}`,`"${h}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(w&&!w.fields[h]&&!w.edges?.[h]&&w.computed?.[h]===void 0){let S=Object.keys(w.edges??{}).find(A=>A.includes("-")&&A.split("-").includes(h));s.push(y("rule-name",`${p}.${m}`,`${o.over} has no field or relation called "${h}"`,S?`"${S}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${S.replace(/-([a-z0-9])/g,(A,b)=>b.toUpperCase())}"`:void 0))}for(let h of j.edges)!t.has(h)&&!f(h)&&s.push(y("rule-edge",`${p}.${m}`,`"${h}" is not a relation any kind declares`));for(let h of j.sweeps)r.has(h)?o.over!=="graph"&&s.push(Ne("rule-cost",`${p}.${m}`,`this rule looks at every ${h} for every ${o.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):s.push(y("rule-kind",`${p}.${m}`,`"${h}" is not a kind this document declares`))}o.says&&Se(o.says,`${p}.says`,s),(o.repairs??[]).forEach((m,l)=>{!a[m.act]&&!de(m.act)&&!me(m.act,e.kinds)&&s.push(y("repair-act",`${p}.repairs.${l}.act`,`"${m.act}" is not an act this document declares`,ge(m.act,e)))})}let z=e.policy;return z&&(z.grants.forEach((i,o)=>{if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(y("grant-role",`policy.grants.${o}.roles`,`"${p}" is not one of the document's roles`));if(i.mutations!=="*")for(let p of i.mutations)!a[p]&&!de(p)&&!me(p,e.kinds)&&s.push(y("grant-act",`policy.grants.${o}.mutations`,`"${p}" is not an act this document declares`,ge(p,e)))}),(z.sees??[]).forEach((i,o)=>{for(let p of i.kinds)r.has(p)||s.push(y("sight-kind",`policy.sees.${o}.kinds`,`"${p}" is not a kind this document declares`));if(i.roles!=="*"&&d.size>0)for(let p of i.roles)d.has(p)||s.push(y("sight-role",`policy.sees.${o}.roles`,`"${p}" is not one of the document's roles`))})),s.push(...We(e)),s}function On(e){return e.label?[...e.label.matchAll(/\{\s*([A-Za-z_][A-Za-z0-9_]*)/g)].map(s=>s[1]):[fe(e)??[]].flat()}function vn(e,s,r,t){let a=new Map,d=ae(e.on),u=new Map,f=new Map;(d.length>0||s.some(l=>"remove"in l&&R(l.remove)==="subject"||"from"in l&&(R(l.from)==="subject"||R(l.to)==="subject")||"set"in l&&!("create"in l)&&R(l.target??"$subject")==="subject"))&&a.set(pe,{ref:d.length>0?d:"*",required:!0});let i=e.args??{},o=e.writes?.length===1,p=(l,c)=>c&&l.type===c.type&&l.min===void 0&&l.max===void 0&&l.step===void 0?{...l,...c.min===void 0?{}:{min:c.min},...c.max===void 0?{}:{max:c.max},...c.step===void 0?{}:{step:c.step}}:l,w=(l,c)=>c&&l.type===c.type&&l.format===void 0&&l.unit===void 0?{...p(l,c),...c.format?{format:c.format}:{},...c.unit?{unit:c.unit}:{}}:p(l,c),m=(l,c,j)=>{if(l===pe||wn.has(l)||u.has(l)||a.has(l))return;let h=i[l]?w(i[l],j):void 0;a.set(l,h?{field:h,optional:!h.required,required:!!h.required}:c())};for(let l of s)if("create"in l){let c=r.kinds[l.create],j=c?rn(c,On(c)):[],h=S=>j.includes(S)?j.indexOf(S):j.length;for(let[S,A]of Object.entries(l.set??{}).sort(([b],[G])=>h(b)-h(G))){let b=R(A),G=c?.fields[S];if(b&&G){let F=!!G.required&&G.default===void 0;m(b,()=>({field:G,optional:!F,required:F}),G)}}l.as&&u.set(l.as,l.create)}else if("connect"in l||"sever"in l){let c=t.get("connect"in l?l.connect:l.sever);for(let[j,h]of[["from",l.from],["to",l.to]]){let S=R(h);if(!S)continue;let A=j==="to"?c?.to??"*":c?.from??"*";A!=="*"&&!f.has(S)&&f.set(S,A),m(S,()=>({ref:A,required:!0}))}}else if("set"in l){let c=R(l.target??"$subject"),j=c==="subject"?d[0]:u.get(c??"")??f.get(c??"")?.[0];c&&c!=="subject"&&!u.has(c)&&m(c,()=>({ref:"*",required:!0}));for(let[h,S]of Object.entries(l.set)){let A=R(S);if(!A)continue;let b=j?r.kinds[j]?.fields[h]:void 0;m(A,()=>b?{field:b,optional:!o,required:o}:{any:!0,required:!1},b)}}else if("remove"in l){let c=R(l.remove);c&&m(c,()=>({ref:"*",required:!0}))}for(let[l,c]of Object.entries(i))a.has(l)||a.set(l,{field:c,optional:!c.required,required:!!c.required});return a}function At(e,s={}){let r=Sn(e);if(!r.document||le(r.findings))return{ok:!1,findings:r.findings};let t=r.document,a=[...r.findings];s.previous&&a.push(...En(t,s.previous));let d=xn(t,a);return le(d.findings)?{ok:!1,findings:d.findings}:Ve(d,s)}function re(e,s){return e.map(r=>{let t=!r.format&&r.expr?.t==="ident"?s?.[r.expr.name]?.format:void 0;return t==="money"||t==="percent"?{...r,format:t}:r})}function xn(e,s){let r=an(e),t={};for(let[i,o]of Object.entries(e.kinds)){let p=fe(o),w=o.label??(p?`{${p}}`:void 0),m=ne(o),l=m?on(e,i,[...m]):[];t[i]={...w?{label:re(J(w),o.fields)}:{},...o.describe?{describe:re(J(o.describe),o.fields)}:{},...m?{computed:[...m]}:{},...l.length>0?{durations:l}:{}}}let a={};for(let[i,o]of Object.entries(e.acts??{})){let p=cn(o,e),w=vn(o,p,e,r),m=o.destructive??p.some(g=>"remove"in g||"sever"in g||"replace"in g),l=[...new Set(p.flatMap(g=>"create"in g?[g.create]:[]))],c=[...new Set(p.flatMap(g=>"connect"in g?[g.connect]:[]))],j=[...new Set(p.flatMap(g=>"sever"in g?[g.sever]:"replace"in g?g.replace:[]))],h=[...new Set(p.flatMap(g=>"set"in g&&!("create"in g)&&R(g.target??"$subject")==="subject"?Object.keys(g.set):[]))],S=new Map;for(let g of p){if(!("connect"in g)&&!("sever"in g))continue;let v=r.get("connect"in g?g.connect:g.sever);for(let[D,oe]of[["from",g.from],["to",g.to]]){let V=R(oe),Y=D==="to"?v?.to:v?.from;V&&V!=="subject"&&Y&&Y!=="*"&&S.set(V,[...new Set([...S.get(V)??[],...Y])])}}let A={};for(let g of p){if(!("set"in g)||"create"in g)continue;let v=R(g.target??"$subject");for(let D of v&&v!=="subject"&&S.get(v)||[])A[D]=[...new Set([...A[D]??[],...Object.keys(g.set)])]}let b={};for(let g of p)if(!(!("set"in g)||"create"in g||R(g.target??"$subject")!=="subject"))for(let[v,D]of Object.entries(g.set??{}))typeof D=="string"&&R(D)===void 0||typeof D=="number"||typeof D=="boolean"?b[v]=typeof D=="string"&&D.startsWith("$$")?D.slice(1):D:delete b[v];let G=l.length===0&&p.every(g=>!("set"in g)||!g.set||Object.values(g.set).every(v=>!(v&&typeof v=="object"&&!Array.isArray(v)&&"expr"in v))),F=new Map;for(let g of p)if(!(!("set"in g)||!g.set))for(let v of Object.values(g.set))v&&typeof v=="object"&&!Array.isArray(v)&&"expr"in v&&F.set(v.expr,H(v.expr));a[i]={title:o.title??i.replace(/-/g," "),effects:p,args:[...w],...o.allowedWhen?{guard:H(o.allowedWhen)}:{},...o.refusal?{refusal:re(J(o.refusal),e.kinds[[o.on??[]].flat()[0]??""]?.fields)}:{},exprs:[...F],destructive:m,idempotent:G,creates:l,connects:c,severs:j,writes:h,writesOther:A,sets:b}}let d={};for(let[i,o]of Object.entries(e.rules??{}))d[i]={title:o.title??i.replace(/-/g," "),require:H(o.require),...o.when?{when:H(o.when)}:{},...o.says?{says:re(J(o.says),e.kinds[o.over]?.fields)}:{}};let u=qe(e,s),f=Le(e),z=Ue(e);return{format:Ie,document:e,findings:s,kinds:t,...e.computed?{facts:[...ne(e)??[]]}:{},edges:[...r].map(([i,{from:o,to:p,cardinality:w}])=>[i,{from:o,to:p,cardinality:w}]),acts:a,rules:d,brand:u,...Object.keys(f).length>0?{viewSpecs:f}:{},...z?{home:z}:{}}}function Rt(e,s,r){let t=/^defineNode\("([^"]+)"\)/.exec(s)?.[1],a=t?r.kinds[t]:void 0;if(!t||!a)return e;let d=Object.keys(a.fields).filter(u=>u!=="label").slice(0,3);return{...e,path:`kinds.${t}.glance`,fix:`Say which: "glance": [${d.map(u=>`"${u}"`).join(", ")}] on kinds.${t} \u2014 the facts a person compares one by, at a glance.`}}function En(e,s){let r=[],t=new Set(Object.values(s.kinds).flatMap(a=>Object.keys(a.edges??{})));for(let[a,d]of Object.entries(e.kinds)){let u=d.renamedFrom;u&&!s.kinds[u]&&r.push(y("renamed-from-nothing",`kinds.${a}.renamedFrom`,`${a} says it was ${u}, and the previous version has no kind called ${u}`,"name the kind it was, or drop renamedFrom"));let f=s.kinds[u??a];for(let[z,i]of Object.entries(d.fields)){let o=i.renamedFrom;o&&!f?.fields[o]&&r.push(y("renamed-from-nothing",`kinds.${a}.fields.${z}.renamedFrom`,`${z} says it was ${o}, and the previous ${u??a} has no field called ${o}`,"name the field it was, or drop renamedFrom"))}for(let[z,i]of Object.entries(d.edges??{})){let o=i.renamedFrom;o&&!t.has(o)&&r.push(y("renamed-from-nothing",`kinds.${a}.edges.${z}.renamedFrom`,`${z} says it was ${o}, and the previous version has no relation called ${o}`,"name the relation it was, or drop renamedFrom"))}}return r}export{Sn as a,Et as b,cn as c,At as d,Rt as e};
|
|
@@ -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{L as M,N as H,
|
|
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{L as M,N as H,vb as N}from"./chunk.PFEKS3KO.js";var z=()=>(__graviewPreload(import.meta.url,["./chunk.H42WBU5C.js","./chunk.PXQVXBNG.js","./chunk.G446PWV6.js","./chunk.PFEKS3KO.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.RI624PFK.js"));function F(n,l,y){let d=new Map;for(let u of y?.kinds??[])for(let a of n.nodesOfKind(u))l.has(a.id)||d.set(a.id,a);let o=new Set([...l,...d.keys()]),p=new Set(y?.edges??[]),k=new Set;if(p.size>0&&l.size>0){for(let u of l)for(let a of n.outEdges(u))p.has(a.kind)&&d.has(a.to)&&k.add(a.to);for(let u of d.keys())n.outEdges(u).some(a=>p.has(a.kind)&&l.has(a.to))&&k.add(u)}let b=new Map([...[...d].filter(([u])=>k.has(u)),...[...d].filter(([u])=>!k.has(u))]),h=[];if(p.size>0)for(let u of o)for(let a of n.outEdges(u))p.has(a.kind)&&o.has(a.to)&&h.push({kind:a.kind,from:a.from,to:a.to});return{nodes:[...b.values()],edges:h}}function L(n,l,y){let d=[];return()=>{let o=y();for(;d.length>0&&d[0]<=o-l;)d.shift();return d.length>=n?!1:(d.push(o),!0)}}function D(n={},l=Date.now){return{act:L(n.acts??30,n.actWindowMs??6e4,l),message:L(n.messages??120,n.messageWindowMs??1e3,l)}}var S=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function C(n,l){let y=structuredClone(l),d=n.schema.tryDefinition(y.kind),o=y.label;return{...y,label:d?.label?d.label(y):typeof o=="string"&&o.length>0?o:y.id}}function W(n){let l=n.limiter??D(n.limits,n.now),y=n.limits?.maxHeight??4e3,d=`view:${n.view}`,o={applied:0,refused:0,dropped:0},p=()=>n.store.seenBy(n.principal),k=e=>C(n.store,e),b=()=>{if(n.props)return n.props();let e=p(),s=e.graph,r=n.input?.()??{},f=r.node?s.getNode(r.node.id):void 0,i=r.nodes?.flatMap(t=>{let m=s.getNode(t.id);return m?[m]:[]}),g=new Set([...f?[f.id]:[],...(i??[]).map(t=>t.id)]),c=[];for(let t of g)for(let m of s.outEdges(t))g.has(m.to)&&c.push({kind:m.kind,from:m.from,to:m.to});let w=F(s,g,n.reads),R=new Set(c.map(t=>`${t.kind} ${t.from} ${t.to}`));for(let t of w.edges)R.has(`${t.kind} ${t.from} ${t.to}`)||c.push(t);let P=w.nodes.length>0?[...i??[],...w.nodes]:i,x=t=>t?.filter(m=>s.has(m)),T=e.permittedMutations(n.principal).map(t=>({name:t.name,title:t.title??t.name,...t.description!==void 0?{description:t.description}:{},...t.subject?{subject:{kinds:t.subject.kinds,arg:t.subject.arg}}:{}}));return{view:n.view,...f?{node:k(f)}:{},...P?{nodes:P.map(k)}:{},edges:c,...r.label!==void 0?{label:r.label}:{},...r.fidelity!==void 0?{fidelity:r.fidelity}:{},...r.cardinality!==void 0?{cardinality:r.cardinality}:{},...r.mode!==void 0?{mode:r.mode}:{},...r.selected!==void 0?{selected:r.selected}:{},...r.implicated?{implicated:x(r.implicated)}:{},...r.flagged?{flagged:x(r.flagged)}:{},acts:T,...n.theme?{theme:n.theme()}:{},locale:M(),timeZone:H(),...n.placesShown?{places:n.placesShown().map(({as:t,title:m,kind:$})=>({as:t,title:m,kind:$}))}:{}}},h=!1,u=0,a=()=>{if(h)return;u+=1;let e=b();n.send({type:"props",props:n.hand?n.hand(e):e,push:u})},v=!1,E=n.store.subscribe(()=>{v||(v=!0,queueMicrotask(()=>{v=!1,a()}))}),G=(e,s)=>(o.refused+=1,{ok:!1,reason:e,message:s}),j=(e,s,r)=>A([{name:e,args:s}],r),A=(e,s,r)=>{if(!l.act())return G("rate-limited","Too many acts asked for at once; this one was not applied.");let f=[];for(let{name:i,args:g}of e){if(s){let c=s(i,g);if(!c.ok)return G(c.reason,c.message);i=c.name,g=c.args}if(!n.store.allMutations().some(c=>c.name===i))return G("unknown-act","There is no act by that name here.");f.push({name:i,args:g})}try{let i=n.store.applyAll(f,{author:n.principal,via:d,...r?{intent:r}:{}});return o.applied+=1,{ok:!0,intent:i.intent}}catch(i){return i instanceof N?G("refused",i.refusal.message):G("failed","The act could not be applied.")}},O=(e,s,r)=>{let f=Array.isArray(r);if(typeof s!="string"||(f?r.length===0||r.length>100||!r.every(S):!S(r)))return o.refused+=1,n.send({type:"answer",id:e,ok:!1,reason:"malformed",message:"An act is asked for by name, with its arguments as an object, or a list of 1 to 100 of them for several as one change."});let i=A((f?r:[r]).map(g=>({name:s,args:g})),n.judgeAct);n.send(i.ok?{type:"answer",id:e,ok:!0,intent:i.intent}:{type:"answer",id:e,ok:!1,reason:i.reason,message:i.message})};return{receive(e){if(!h){if(!l.message()){o.dropped+=1,n.onFlood?.();return}if(!S(e)||e.nonce!==n.nonce){o.dropped+=1;return}if(e.type==="act"&&(typeof e.id=="string"||typeof e.id=="number"))return O(e.id,e.name,e.args);if(e.type==="navigate"&&n.onArrive&&(typeof e.place=="string"||typeof e.to=="string")){let s={...e.where!==void 0?{where:e.where}:{},...e.section!==void 0?{section:e.section}:{}},r=typeof e.place=="string"?{place:e.place,...s}:{record:e.to,...s},f=n.onArrive;z().then(({judgeDestination:i,listsOf:g})=>{if(h)return;let c=new Set([...n.store.kindsKeptFrom(n.principal),...n.store.modules.disabledKinds]),w=i(r,{sees:R=>p().graph.has(R),places:n.placesShown?.()??[],lists:g(n.store.schema,c),schema:n.store.schema});w.ok?f(w.arrival):(o.dropped+=1,n.onLost?.(w.says))});return}if(e.type==="navigate"&&typeof e.place=="string"){n.places?.().includes(e.place)?n.onNavigatePlace?.(e.place):o.dropped+=1;return}if(e.type==="navigate"&&typeof e.to=="string"){p().graph.has(e.to)?n.onNavigate?.(e.to):o.dropped+=1;return}if(e.type==="render"&&Array.isArray(e.records)&&n.onRender){n.onRender(e.records);return}if(e.type==="style"&&Array.isArray(e.sheets)&&e.sheets.every(s=>typeof s=="string")&&n.onStyle){n.onStyle(e.sheets);return}if(e.type==="hears"&&Array.isArray(e.events)&&n.onHears){n.onHears(e.events.filter(s=>typeof s=="string").slice(0,20));return}if(e.type==="clicks"&&Array.isArray(e.selectors)){n.onClicks?.(e.selectors.filter(s=>typeof s=="string"&&s.length<=500).slice(0,200));return}if(e.type==="gestures"&&Array.isArray(e.bound)&&n.onGestures){n.onGestures(e.bound.slice(0,32));return}if(e.type==="pushed"&&typeof e.push=="number"&&typeof e.ms=="number"&&n.onPushed){n.onPushed(e.push,e.ms);return}if(e.type==="size"&&typeof e.height=="number"&&Number.isFinite(e.height)){n.onSize?.(Math.max(0,Math.min(y,Math.round(e.height))));return}o.dropped+=1}},push:a,pressed(e){return h?{ok:!1,reason:"refused",message:"The view has gone."}:e.ok?j(e.name,e.args):(o.refused+=1,e)},change(e,s){return h?{ok:!1,reason:"refused",message:"The view has gone."}:A(e,void 0,s)},get stats(){return o},dispose(){h=!0,E()}}}export{F as a,D as b,C as c,W as d};
|
|
@@ -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 dt,b as gt,c as mt,d as yt,e as ht,f as wt,g as vt}from"./chunk.OS75HEZP.js";import{a as ft,b as Se,c as bt}from"./chunk.KVEDMKUN.js";import{g as lt}from"./chunk.BRDAO2OF.js";import{e as pt}from"./chunk.FUMQLGNM.js";import{c as ut,f as ct,g as xe}from"./chunk.BVXOLZQ3.js";import{b as ie,d as ae}from"./chunk.KDTNKKOY.js";import{a as ke,e as at}from"./chunk.BBLIT7S7.js";import{a as se,f as st,h as it}from"./chunk.H42WBU5C.js";import"./chunk.PXQVXBNG.js";import"./chunk.G446PWV6.js";import{a as H}from"./chunk.SDO3U72B.js";import"./chunk.PFEKS3KO.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";var kt=["good","warn","bad","neutral","accent"],xt=["value","max","aria-label","placeholder","disabled"],St=["click","change"],Te=["_blank","_self"],Tt=["section","div","span","strong","p","hr","a","button","input","progress"],de={type:{oneOf:kt}},Me={"gv-card":{host:"section",properties:{tone:de},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:de},events:{},children:"text"},"gv-badge":{host:"span",properties:{tone:de},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:de,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"}},Ee=1e4;var jt=0,Bt=1,Ut=2,$t=3,Mt=1,Ft=2,zt=3,qt=1,Xt=3,Yt=8,Re="~",Ke=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),J=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function Et(n,e){return e.type==="url"?"href":e.as??`data-gv-${n.toLowerCase()}`}var Jt=2e3;function Rt(n,e){if(e==null)return{ok:!0,value:null};let d=n.type;if(d==="boolean")return typeof e=="boolean"?{ok:!0,value:e}:{ok:!1,reason:"value"};if(d==="number")return typeof e=="number"&&Number.isFinite(e)?{ok:!0,value:String(e)}:{ok:!1,reason:"value"};if(typeof e!="string"||e.length>Jt)return{ok:!1,reason:d==="url"?"url":"value"};if(typeof d=="object")return d.oneOf.includes(e)?{ok:!0,value:e}:{ok:!1,reason:"value"};if(d==="url"){let m;try{m=new URL(e)}catch{return{ok:!1,reason:"url"}}return m.protocol!=="https:"||m.hostname===""||!/^https:\/\//i.test(e)?{ok:!1,reason:"url"}:{ok:!0,value:m.href}}return{ok:!0,value:e}}function Qt(n){let e=n.host==="a";return Tt.includes(n.host)&&(n.target===void 0||e&&Te.includes(n.target))&&Object.values(n.properties).every(d=>d.type!=="url"||e)&&Object.values(n.properties).every(d=>d.as===void 0||d.type!=="url"&&xt.includes(d.as))&&Object.values(n.events).every(d=>St.includes(d.from))}function Ge(n,e){let d=e.kit??Me,m=e.maxNodes??2e3,o=n.ownerDocument,y=[],w=new Map,W={dom:n,name:Re,component:{host:"div",properties:{},events:{},children:"any"},children:[],listeners:new Map,id:Re};w.set(Re,W);let K=e.links?new Set(e.links.origins.flatMap(r=>{try{let l=new URL(r);return l.protocol==="https:"&&l.hostname!==""?[l.origin]:[]}catch{return[]}})):void 0,_=0,E=0,O=!1,p=r=>{y.push(r),y.length>200&&y.shift()},R=()=>({dom:o.createComment(""),children:[],refused:!0,listeners:new Map}),M=(r,l,h)=>{let u=r.component;if(!Ke(u.properties,l))return p({reason:"property",element:r.name,name:l});let i=u.properties[l],g=Rt(i,h),v=g.ok&&i.type==="url"&&K&&typeof g.value=="string"&&!K.has(new URL(g.value).origin)?{ok:!1,reason:"url"}:g,T=r.dom,f=Et(l,i);if(!v.ok)return T.removeAttribute(f),p({reason:v.reason,element:r.name,name:l});let L=v.value;L===null||L===!1?T.removeAttribute(f):T.setAttribute(f,L===!0?"":L),f==="value"&&"value"in T&&(T.value=typeof L=="string"?L:""),f==="disabled"&&"disabled"in T&&(T.disabled=L!==null&&L!==!1)},k=(r,l,h)=>{let u=r.component;if(!Ke(u.events,l))return p({reason:"event",element:r.name,name:l});let i=r.listeners.get(l);if(i&&(i(),r.listeners.delete(l),E-=1),h==null)return;if(!J(h)||typeof h.listener!="number")return p({reason:"value",element:r.name,name:l});let g=h.listener,v=u.events[l],T=r.dom,f=()=>e.onEvent(g,v.detail==="value"?String(T.value??""):void 0);T.addEventListener(v.from,f),r.listeners.set(l,()=>T.removeEventListener(v.from,f)),E+=1},x=r=>{if(!r.refused){_-=1,r.id!==void 0&&w.delete(r.id);for(let l of r.listeners.values())l();E-=r.listeners.size,r.listeners.clear();for(let l of r.children)x(l)}},A=(r,l)=>{if(!J(r)||typeof r.id!="string"||w.has(r.id))return p({reason:"record"}),R();if(_>=m)return p({reason:"budget"}),O||(O=!0,e.onOverBudget?.()),R();let h=r.id,u=l.component.children;if(r.type===Yt)return R();if(r.type===Xt){if(u==="none")return p({reason:"child",element:l.name}),R();let f={dom:o.createTextNode(String(r.data??"").slice(0,Ee)),children:[],text:!0,listeners:new Map,id:h};return w.set(h,f),_+=1,f}if(r.type!==qt)return p({reason:"record"}),R();let i=String(r.element);if(!Ke(d,i)||!Qt(d[i]))return p({reason:"element",element:i}),R();if(u!=="any")return p({reason:"child",element:i}),R();let g=d[i],v=o.createElement(g.host);v.setAttribute("data-gv",i.replace(/^gv-/,"")),v.className=`graview-guest-${i.replace(/^gv-/,"")}`,g.host==="a"&&(v.setAttribute("rel","noopener noreferrer"),v.setAttribute("target",g.target??"_blank"),v.setAttribute("referrerpolicy","no-referrer")),g.host==="button"&&v.setAttribute("type","button");let T={dom:v,name:i,component:g,children:[],listeners:new Map,id:h};if(w.set(h,T),_+=1,J(r.properties))for(let[f,L]of Object.entries(r.properties))M(T,f,L);if(J(r.attributes))for(let f of Object.keys(r.attributes))p({reason:"attribute",element:i,name:f});if(J(r.eventListeners))for(let[f,L]of Object.entries(r.eventListeners))k(T,f,L);if(Array.isArray(r.children))for(let f of r.children){let L=A(f,T);T.children.push(L),v.appendChild(L.dom)}return T},N=r=>{if(!Array.isArray(r))return p({reason:"record"});let[l,h]=r,u=typeof h=="string"?w.get(h):void 0;if(!u)return p({reason:"record"});switch(l){case jt:{if(u.text)return p({reason:"record"});let i=Number(r[3]),g=Number.isInteger(i)&&i>=0&&i<=u.children.length?i:u.children.length,v=A(r[2],u);u.dom.insertBefore(v.dom,u.children[g]?.dom??null),u.children.splice(g,0,v);return}case Bt:{let i=Number(r[2]),g=u.children[i];if(!g)return p({reason:"record"});u.children.splice(i,1),g.dom.parentNode?.removeChild(g.dom),x(g);return}case Ut:if(!u.text)return p({reason:"record"});u.dom.data=String(r[2]??"").slice(0,Ee);return;case $t:{if(u===W||u.text)return p({reason:"record"});let i=String(r[2]),g=r[4]??Mt;return g===Mt?M(u,i,r[3]):g===zt?k(u,i,r[3]):p(g===Ft?{reason:"attribute",element:u.name,name:i}:{reason:"record"})}default:return p({reason:"record"})}};return{apply(r,l){if(!Array.isArray(r))return p({reason:"record"}),!0;for(let h=0;h<r.length;h+=1){if(l&&h%32===0&&l())return!1;N(r[h])}return!0},get refused(){return y},get size(){return _},get listening(){return E},dispose(){for(let r of W.children)x(r);W.children.length=0,n.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 Kt=new WeakSet;function Zt(n,e){if(n.startsWith("blob:"))return"blob:";try{return new URL(n,e.location.href).origin}catch{return n}}function Gt(n,e,d){let m=Zt(e,n),o=`this page's Content-Security-Policy${d?` (${d})`:""} does not allow a worker from ${m}: it needs worker-src ${m}`;return Kt.has(n)||(Kt.add(n),n.console?.warn?.(`Graview: worker views cannot start on this page, because ${o}. A host that will not allow ${m} 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 er(n,e){return n===""?!0:e.startsWith("blob:")?n.startsWith("blob"):e.startsWith(n)||n.startsWith(e)}function le(n,e){let d="script"in e.source?n.URL.createObjectURL(new n.Blob([e.source.script],{type:"text/javascript"})):void 0,m="script"in e.source?d:e.source.url,o,y,w=!1,W=!1,K=0,_=0,E="",O=0,p=0,R=n.performance,M=R.now(),k,x=u=>{let i=u,g=String(i.effectiveDirective||i.violatedDirective||"").split(" ")[0];/^(worker-src|script-src|script-src-elem|child-src|default-src)$/.test(g)&&er(String(i.blockedURI??""),m)&&(k=g)},A=n.document;A?.addEventListener("securitypolicyviolation",x);let N=()=>A?.removeEventListener("securitypolicyviolation",x),r=()=>{W||(W=!0,y?.close(),o?.terminate(),o=void 0,n.clearTimeout(K),n.clearInterval(_),N(),d&&n.URL.revokeObjectURL(d))},l=(u,i)=>{W||(r(),e.onStop(u,i))},h=()=>{n.clearTimeout(K),N(),E=dt();let u=new n.MessageChannel;y=u.port1;let i=Math.max(1,e.silentMs),g=Math.max(10,Math.min(1e3,Math.floor(i/4)));M=R.now();let v=M;_=n.setInterval(()=>{let f=R.now();if(f-v>g*2&&(M+=f-v-g),v=f,f-M>=i)return l("silent");O+=1,u.port1.postMessage({type:"heartbeat",beat:O})},g);let T={graview:"host-hello",protocol:1,nonce:E,view:e.name};o.postMessage(T,[u.port2]),e.onReady(E,u.port1)};try{o=new n.Worker(m,{name:e.name})}catch(u){o=void 0;let i=u,g=i?.name==="SecurityError"?Gt(n,m,k):`the worker could not be made: ${String(i?.message??u)}`;queueMicrotask(()=>l("start",g))}return o&&(K=n.setTimeout(()=>l("start",`it never said it was ready in ${e.readyMs.toLocaleString("en-US")} ms`),e.readyMs),o.onerror=u=>{let i=typeof u.message=="string"&&u.message!==""?u.message:void 0;if(w)return void e.onError?.(i??"an error");n.clearTimeout(K),n.setTimeout(()=>!w&&l("start",k?Gt(n,m,k):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=u=>{if(!e.limiter.message()||w||!at(u.data)||u.data.protocol!==1){e.onDropped();return}w=!0,h()}),{get worker(){return o},answer(u){let i=u;return typeof i!="object"||i===null||i.type!=="heartbeat"||i.nonce!==E?!1:(typeof i.beat=="number"&&i.beat>p&&i.beat<=O&&(p=i.beat,M=R.now()),!0)},stop:r}}function ue(n,e){let d=e(),m=0;return{draw(o){let y=e();y-d>=1e3&&(d=y,m=0);let w=o(()=>m+(e()-y)>=n);return m+=e()-y,w&&m<n}}}var tr=Symbol.for("graview.view.clicked");function Wt(n,e){n[tr]=Object.freeze([...e])}var rr=H(()=>(__graviewPreload(import.meta.url,["./chunk.BRDAO2OF.js","./chunk.AJZBJBMO.js"]),import("./chunk.MCFLCC42.js"))),nr=H(()=>(__graviewPreload(import.meta.url,["./chunk.FUMQLGNM.js","./chunk.BVXOLZQ3.js","./chunk.KDTNKKOY.js","./chunk.G446PWV6.js","./chunk.PFEKS3KO.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.O3ONLQUF.js"))),or=H(()=>(__graviewPreload(import.meta.url,["./chunk.AJZBJBMO.js"]),import("./chunk.SHNYYBNW.js"))),sr=H(()=>(__graviewPreload(import.meta.url,["./chunk.WVUJXDXZ.js","./chunk.NQDGUIUQ.js","./chunk.DTRNDSMS.js","./chunk.3EW6L5DY.js","./chunk.AVDXG57A.js","./chunk.LD6S2FL5.js","./chunk.TABIRLQS.js","./chunk.EJAVIZ7Y.js","./chunk.PFEKS3KO.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.2N6RQ427.js"))),ir=H(()=>(__graviewPreload(import.meta.url,["./chunk.BVXOLZQ3.js","./chunk.KDTNKKOY.js","./chunk.PFEKS3KO.js","./chunk.2AZTW66C.js","./chunk.AJZBJBMO.js"]),import("./chunk.UL43GFVC.js"))),ar=H(()=>(__graviewPreload(import.meta.url,["./chunk.BBLIT7S7.js","./chunk.AJZBJBMO.js"]),import("./chunk.RRCPEHM4.js")));function dr(n,e,d){switch(n){case"manifest":return d??"Its manifest names something this app does not have.";case"source":return d??`Its code is longer than the ${e.maxSourceBytes.toLocaleString("en-US")} bytes a view may be.`;case"start":return`It could not start${d?`: ${d}.`:"."}`;case"error":return`It failed before it drew anything${d?`: ${d}`:"."}`;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 lr(n,e){let d=n.ownerDocument,m=d.defaultView,{manifest:o}=e,y=d.createElement("div");y.className="graview-worker-view",y.setAttribute("role","region"),y.setAttribute("aria-label",o.title??o.name),y.setAttribute("data-worker-view",o.name),y.style.cssText="display:block;position:relative;contain:layout paint style;isolation:isolate;overflow:clip;min-width:0",n.appendChild(y);let w=y.attachShadow({mode:"open"}),W=e.author?d.createElement("p"):void 0;W&&(W.className="graview-worker-view-author",W.setAttribute("data-worker-view-author",o.name),W.style.cssText="margin:4px 0 0;font-size:0.75rem;color:var(--graview-ink-muted, inherit)",W.textContent=e.author,n.appendChild(W));let K={applied:0,refused:0,dropped:0},_=ie(e.limits),E={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},O,p,R,M,k=!1,x={applied:0,refused:0,dropped:0},A=[],N=()=>{if(!p)return;let t=p.stats;K.applied+=t.applied-x.applied,K.refused+=t.refused-x.refused,K.dropped+=t.dropped-x.dropped,x={...t}},r=()=>{},l,h,u=()=>{let t=w.querySelector("[data-graview-view-root]"),c=m.ResizeObserver;h||!t||typeof c!="function"||(h=new c(b=>{let S=b[b.length-1]?.borderBoxSize?.[0],s=Math.ceil(S?S.blockSize:t.offsetHeight);s!==l&&(l=s,y.setAttribute("data-graview-content-height",String(s)),e.onContentHeight?.(s))}),h.observe(t))},i=()=>{h&&(h.disconnect(),h=void 0,l=void 0,y.removeAttribute("data-graview-content-height"),e.onContentHeight?.(void 0))},g=0,v=()=>{},T=()=>{v(),v=()=>{},N(),p?.dispose(),p=void 0,R?.stop(),r(),m.clearInterval(g)},f=(t,c)=>{if(k)return;k=!0,T(),i(),M?.dispose();let b=dr(t,E,c);y.removeAttribute("data-worker-view-drawn"),y.setAttribute("data-worker-view-failed",t),e.fallback!==!1&&(e.fallback??L)(y,t,b),e.onFailure?.(t,b)},L=(t,c,b)=>{let S=O??(()=>{try{return xe(e.store,e.principal,{manifest:o,...e.input?{input:e.input()}:{}})}catch{return}})(),s=d.createElement("div");s.setAttribute("data-graview-fallback",c),s.style.cssText="padding:12px;display:grid;gap:6px;color:var(--graview-ink, inherit);font-family:var(--graview-font-body, inherit)";let I=d.createElement("strong");I.textContent=o.title??o.name;let C=d.createElement("ul");C.style.cssText="margin:0;padding-left:1.2em";for(let re of[...S?.node?[S.node]:[],...S?.nodes??[]]){let ne=d.createElement("li");ne.textContent=re.label??re.id,C.appendChild(ne)}let U=d.createElement("p");U.style.cssText="margin:0;font-size:0.8125rem;color:var(--graview-ink-muted, inherit)",U.textContent=`This view was stopped. ${b}`,s.append(I,C,U),w.replaceChildren(s)},Oe=ct(o,e.store);if(Oe.length>0)return queueMicrotask(()=>f("manifest",Oe.join(" "))),he();let Ae=t=>{if(("source"in t?new TextEncoder().encode(t.source).length:"script"in t?new TextEncoder().encode(t.script).length:0)>E.maxSourceBytes)return["source"];let b="source"in t?ft(t.source):[];return b.length>0?["source",b.join(" ")]:void 0},$=e.worker,Le=typeof $=="function"?void 0:Ae($);if(Le)return queueMicrotask(()=>f(...Le)),he();let _e=vt(m,()=>Ne(),"blob"),ce=()=>wt(()=>e.theme?.()??yt(y),e.brand,_e),Ie="",pe=()=>{Ie=JSON.stringify(ce()),p?.push()},Ne=()=>{p&&JSON.stringify(ce())!==Ie&&pe()},At=ht(d,Ne),j,B,Pe=o.pictures?or().then(({createGuestPictures:t})=>{k||(j=t(m,{as:"blob",view:`"${o.title??o.name}"`,pictures:o.pictures,...e.limits?{limits:e.limits}:{},...e.file?{file:e.file}:{},moved:()=>p?.push(),onLeft:c=>{V?.postMessage({type:"notice",text:c}),e.onProblem?.(c)}}))}):Promise.resolve();r=()=>{At(),_e.dispose(),j?.dispose(),X?.dispose(),B?.dispose(),te?.dispose()};let V,Q=t=>V?.postMessage(t),Ce=!1,Ve=!1,Z=()=>y.toggleAttribute("data-worker-view-drawn",!k&&Ve&&M!==void 0&&A.length===0&&z.size===0&&!j?.waiting()&&!(B?.waiting??0)),F=m.performance,z=new Map,ee=F.now(),fe=Math.max(10,Math.min(250,Math.floor(E.pushMs/4))),Lt=()=>{g||(ee=F.now(),g=m.setInterval(()=>{let t=F.now(),c=t-ee>fe*2?t-ee-fe:0;ee=t;for(let[b,S]of z){let s=S+c;if(z.set(b,s),t-s>=E.pushMs)return f("slow")}},fe))},_t=ue(E.drawMs,()=>F.now()),De=()=>{},ge=t=>{if(k)return;if(!M)return void A.push(t);let c=M;if(!_t.draw(S=>t[0]==="render"?c.apply(t[1],S):(c.style(t[1]),!0)))return f("slow");t[0]==="render"&&De()},He=()=>st(e.store.schema,new Set([...e.store.kindsKeptFrom(e.principal),...e.store.modules.disabledKinds])),q=it({sees:t=>e.store.seenBy(e.principal).graph.has(t),places:()=>se(e.places?.()??[]),lists:He,schema:e.store.schema,...e.onNavigate?{onNavigate:e.onNavigate}:e.goTo?{onNavigate:t=>gt(e.goTo(),t)}:{},...e.hrefOf?{hrefOf:e.hrefOf}:!e.onNavigate&&e.goTo?{hrefOf:t=>mt(e.goTo(),t)}:{},onLost:t=>{V?.postMessage({type:"notice",text:t}),e.onProblem?.(t)}}),D=new Set,je=new Set,X,Be=!1,Ue=()=>{Be||(Be=!0,sr().then(({createGuestMedia:t})=>{k||(X=t(m,{view:`"${o.title??o.name}"`,pictures:o.pictures!==void 0,shown:()=>O,...e.file?{file:e.file}:{},onProblem:c=>{V?.postMessage({type:"notice",text:c}),e.onProblem?.(c)}}),X.refresh(w))},()=>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.`)))},$e=!1,Fe=!1,me=new Map,ze=()=>{$e||!o.accepts?.length||($e=!0,ir().then(({createGuestDrops:t})=>{k||(B=t(m,{shadow:w,manifest:o,store:e.store,principal:e.principal,files:()=>e.files?.(),shown:()=>D,hears:()=>Fe,idOf:c=>M?.renderer.idOf(c),send:Q,change:(c,b)=>{if(!p)return{ok:!1,reason:"refused",message:"The view has gone."};let S=p.change(c,b);return N(),S},handed:c=>me.set(c.href,c),onProblem:c=>{V?.postMessage({type:"notice",text:c}),e.onProblem?.(c)},onBusy:()=>Z()}),B.refresh())},()=>e.onProblem?.(`The view "${o.title??o.name}" takes files, and the host's drop could not be loaded.`)))},te,qe=[],Xe=!1,It=t=>{qe=t,te?.bind(t),!(Xe||t.length===0)&&(Xe=!0,ar().then(({createGuestGestures:c,unheardWords:b})=>{if(!k){if(o.gestures!==!0){let S=b(o.title??o.name);return V?.postMessage({type:"notice",text:S}),e.onProblem?.(S)}te=c(w,{root:()=>w.querySelector("[data-graview-view-root]")??void 0,idOf:S=>M?.renderer.idOf(S),send:Q}),te.bind(qe)}},()=>{}))},Nt=t=>{let c=e.store.seenBy(e.principal).graph;for(let b of D){let S=c.getNode(b);for(let s of Object.values(S??{}))for(let I of ut(s))if(I.href===t)return I}},Ye=t=>{if(t.localName==="graview-video")return Ue();t.hasAttribute("data-lightbox")&&(t.setAttribute("aria-haspopup","dialog"),Ue())};Promise.all([rr(),nr()]).then(([{createOpenDrawing:t,handedLinks:c,judgeLink:b,linkRefusedWords:S},{createPressReader:s,createSaver:I,fillPrefills:C,judgePress:U,markPresses:re,prefillOf:ne,quietPictures:Pt}])=>{if(k)return;let Y=s(),Qe=(a,G)=>{let P=M?.renderer.idOf(a);P!==void 0&&Q({type:"dom-event",target:P,event:"acted",pressed:G})},we=I({reader:Y,save:(a,G)=>{if(!p)return;let P=p.pressed(U(e.store,o,D,a));N(),Qe(G,{as:a.as,...P})}}),Ze=()=>we.flush();m.addEventListener("pagehide",Ze),v=()=>{m.removeEventListener("pagehide",Ze),we.flush()};let Ct=new WeakSet;De=()=>{q.refresh(w),re(w),Pt(w),C(w,Y,Ct,a=>ne(e.store,e.principal,o,D,a)),X?.refresh(w),B?.refresh()};let et,tt=new Set,Vt=()=>(et!==O&&([et,tt]=[O,c(O)]),tt),rt=new Set;M=t(w,{origin:e.origin??m.location.origin,link:a=>b(a,{handed:Vt(),...e.links?{origins:e.links.origins}:{}}),...e.asset?{asset:e.asset}:{},...e.images?{imageOrigins:e.images.origins}:{},...o.pictures?{picture:a=>j?.drawn(a)}:{},onRefused:a=>{if(a.reason==="url"&&a.element==="a"&&a.address!==void 0&&!rt.has(a.address)){rt.add(a.address);let P=S(a.address,e.links?.origins);return V?.postMessage({type:"notice",text:P}),e.onProblem?.(P)}if(a.reason!=="url"||a.element!=="img"||a.address===void 0||je.has(a.address))return;je.add(a.address);let G=lt(a.address,{...e.images?{origins:e.images.origins}:{},assets:e.asset!==void 0},a.length);V?.postMessage({type:"notice",text:G}),e.onProblem?.(G)},...e.limits?.maxNodes!==void 0?{maxNodes:e.limits.maxNodes}:{},onOverBudget:()=>f("nodes"),send:Q,onFieldSet:a=>Y.filled(a),onAttribute:(a,G)=>{(G==="data-record"||G==="data-place")&&q.link(a),G==="data-lightbox"&&Ye(a),G==="data-drop"&&ze()},decorate:a=>{(a.hasAttribute("data-record")||a.hasAttribute("data-place"))&&q.link(a),Ye(a),a.hasAttribute("data-drop")&&ze()},before:(a,G,P)=>{Y.heard(a,G),we.heard(a,G,P),q.pressed(a,G,P);let ve=G.closest("a[href]");ve&&P.contains(ve)&&!ve.hasAttribute("data-graview-link")&&a.type==="click"&&a.stopPropagation();let oe=G.closest("[data-lightbox]"),nt=a.type==="keydown"?a.key:void 0;if(oe&&P.contains(oe)&&a.isTrusted&&(a.type==="click"||(nt==="Enter"||nt===" ")&&oe.localName!=="button")&&(a.preventDefault(),a.stopPropagation(),X?.open(oe)),B?.before(a,G,P))return!1;let be=Y.press(a,G,P);if(!be||!p)return;a.stopPropagation(),a.type==="keydown"&&a.preventDefault();let Dt=p.pressed(U(e.store,o,D,be));N();let ot={as:be.as,...Dt},Ht=G.closest("[data-act]");return queueMicrotask(()=>Qe(Ht,ot)),{pressed:ot}}});for(let a of A.splice(0))ge(a);u(),Z()},()=>f("start","the view's drawing could not be loaded"));let ye=t=>R=le(m,{source:t,name:o.name,limiter:_,readyMs:e.limits?.readyMs??5e3,silentMs:e.limits?.silentMs??5e3,onDropped:()=>K.dropped+=1,onStop:(c,b)=>f(c,b),onError:c=>{Ce||f("error",c)},onReady:(c,b)=>{V=b,Lt();let S=ae({store:e.store,principal:e.principal,view:o.name,nonce:c,send:s=>{s.type==="props"&&typeof s.push=="number"&&(z.set(s.push,F.now()),Z()),b.postMessage(s)},props:()=>{let s=xe(e.store,e.principal,{manifest:o,...e.input?{input:e.input()}:{},theme:ce(),...e.places?{places:se(e.places())}:{}});return D=new Set([...s.node?[s.node.id]:[],...(s.nodes??[]).map(I=>I.id)]),O=s,s},...j?{hand:j.hand}:{},judgeAct:(s,I)=>pt(e.store,o,s,I,{shown:D,file:C=>me.get(C)??Nt(C),dropped:C=>me.has(C)}),onHears:s=>{s.includes("drop")&&(Fe=!0)},onGestures:It,onClicks:s=>Wt(y,s),onRender:s=>{Ce=!0,ge(["render",s])},onPushed:(s,I)=>{if(z.delete(s),I>=E.pushMs)return f("slow");Ve=!0,Z()},onFlood:()=>f("flood"),onStyle:s=>ge(["style",s]),places:()=>[...new Set([...se(e.places?.()??[]).map(s=>s.as),...He().map(s=>s.slug)])],...e.limits?{limits:e.limits}:{},limiter:_});p=S,b.onmessage=({data:s})=>{if(!R?.answer(s)&&(S.receive(s),N(),!k&&s?.nonce===c&&s.type==="navigate")){let I={...s.where!==void 0?{where:s.where}:{},...s.section!==void 0?{section:s.section}:{}},C=typeof s.place=="string"?{place:s.place,...I}:typeof s.to=="string"&&{record:s.to,...I};C&&q.go(C)}},pe()}}),Je=t=>{"source"in t?(o.pictures?Promise.all([Se(t.source),Pe]).then(([c])=>c):Se(t.source)).then(c=>{k||ye({script:c})},()=>f("start","the view's runtime could not be loaded")):o.pictures?Pe.then(()=>{k||ye(t)},()=>f("start","the view's pictures could not be loaded")):ye(t)};return typeof $=="function"?bt($).then(t=>{if(k)return;let c=Ae(t);c?f(...c):Je(t)},t=>f("source",`Its code did not arrive${t instanceof Error&&t.message?`: ${t.message}`:""}.`)):Je($),he();function he(){return{element:y,shadow:w,get worker(){return R?.worker},update:()=>{p&&pe()},get stats(){return N(),K},get refused(){return M?.refused??[]},get contentHeight(){return l},dispose(){k=!0,T(),h?.disconnect(),M?.dispose(),y.remove(),W?.remove()}}}}var Ot="graview-guest-kit";function Vr(n,e){let d=n.ownerDocument,m=d.defaultView;if(!d.getElementById(Ot)){let x=d.createElement("style");x.id=Ot,x.textContent=We,d.head.appendChild(x)}let o=d.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),n.appendChild(o);let y={applied:0,refused:0,dropped:0},w=ie(e.limits),W=ue(e.limits?.drawMs??100,()=>m.performance.now()),K,_,E,O=!1,p={applied:0,refused:0,dropped:0},R=()=>{if(!K)return;let x=K.stats;y.applied+=x.applied-p.applied,y.refused+=x.refused-p.refused,y.dropped+=x.dropped-p.dropped,p={...x}},M=()=>{R(),K?.dispose(),K=void 0,E?.stop()},k=(x,A)=>{O||(O=!0,M(),_?.dispose(),e.onFailure?.(x,A))};return E=le(m,{source:e.worker,name:e.view,limiter:w,readyMs:e.limits?.readyMs??5e3,silentMs:e.limits?.silentMs??5e3,onDropped:()=>y.dropped+=1,onStop:(x,A)=>k(x,A),onReady:(x,A)=>{let N=Ge(o,{...e.kit?{kit:e.kit}:{},...e.links?{links:e.links}:{},onEvent:(l,h)=>A.postMessage({type:"event",listener:l,...h!==void 0?{detail:h}:{}}),...e.limits?.maxNodes!==void 0?{maxNodes:e.limits.maxNodes}:{},onOverBudget:()=>k("budget")});_=N;let r=ae({store:e.store,principal:e.principal,view:e.view,nonce:x,send:l=>A.postMessage(l),onRender:l=>{W.draw(h=>N.apply(l,h))||k("slow")},...e.input?{input:e.input}:{},...e.onNavigate?{onNavigate:e.onNavigate}:{},onSize:e.onSize??(l=>o.style.minHeight=`${l}px`),...e.limits?{limits:e.limits}:{},limiter:w});K=r,A.onmessage=l=>{E?.answer(l.data)||(r.receive(l.data),R())},r.push()}}),{element:o,get worker(){return E?.worker},update:()=>K?.push(),get stats(){return R(),y},get refused(){return _?.refused??[]},dispose(){O=!0,M(),_?.dispose(),o.remove()}}}export{Me as GUEST_KIT,We as GUEST_KIT_CSS,Te as KIT_LINK_TARGETS,kt as KIT_TONES,Ge as createKitRenderer,Et as hostAttribute,Rt as kitValue,Vr as mountGuestWorker,lr as mountWorkerView};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{k as a,l as b,m as c,n as d,o as e,p as f,q as g,r as h,s as i}from"./chunk.ST4JHXPS.js";import"./chunk.3NEALGMI.js";import"./chunk.UT6642FC.js";import"./chunk.PBCT33FF.js";import"./chunk.XOZU4OFA.js";import"./chunk.35FUGOSG.js";import"./chunk.OL5D7YTW.js";import"./chunk.TI4OSTQV.js";import"./chunk.DTRNDSMS.js";import"./chunk.A7HMVWMG.js";import"./chunk.GRLPNTUW.js";import"./chunk.EJAVIZ7Y.js";import"./chunk.423SZS7C.js";import"./chunk.TM6JVVGW.js";import"./chunk.SDO3U72B.js";import"./chunk.PFEKS3KO.js";import"./chunk.2AZTW66C.js";import"./chunk.AJZBJBMO.js";export{i as GhostTray,h as InlineAiMenu,g as askAgain,c as askInline,a as askOf,b as drawPanel,d as heldSuggestion,e as suggestOnce,f as takeOffer};
|