graview 0.1.24 → 0.1.25
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/preview/{chunk.47GRZWQN.js → chunk.2AJMM7JG.js} +1 -1
- package/dist/preview/{chunk.2VX6H2LL.js → chunk.2WFEFZAW.js} +1 -1
- package/dist/preview/chunk.2YVXTTC2.js +1 -0
- package/dist/preview/{chunk.AKOC43TV.js → chunk.6DU4XN2F.js} +1 -1
- package/dist/preview/{chunk.RT3XFR6E.js → chunk.6OBXKKB5.js} +2 -2
- package/dist/preview/{chunk.7EN53F4Q.js → chunk.6UL2JUEH.js} +1 -1
- package/dist/preview/chunk.6WFN4C46.js +107 -0
- package/dist/preview/{chunk.Y4R77MKX.js → chunk.7BAUPTMY.js} +1 -1
- package/dist/preview/chunk.A4SJ7EEY.js +1 -0
- package/dist/preview/{chunk.BNSY25SG.js → chunk.ACKTGTOT.js} +1 -1
- package/dist/preview/{chunk.7U7Q3HIS.js → chunk.B57EIGTS.js} +1 -1
- package/dist/preview/{chunk.ISAMJ7AK.js → chunk.BJ2Y5F66.js} +1 -1
- package/dist/preview/{chunk.3O2QU7LU.js → chunk.BYUQOV3O.js} +1 -1
- package/dist/preview/chunk.C5N4RTPF.js +1 -0
- package/dist/preview/{chunk.XDPRWUCJ.js → chunk.CFL2B2Z5.js} +1 -1
- package/dist/preview/{chunk.UM5IPM22.js → chunk.DEZEXD24.js} +1 -1
- package/dist/preview/{chunk.6MCK7K3M.js → chunk.DJ72CUS7.js} +1 -1
- package/dist/preview/{chunk.WOTNMTIY.js → chunk.DSZ3I557.js} +1 -1
- package/dist/preview/chunk.EA4BZKPG.js +1 -0
- package/dist/preview/{chunk.GDIRDJF3.js → chunk.EKZWX6NG.js} +1 -1
- package/dist/preview/{chunk.RGXNZ7PN.js → chunk.F26676IW.js} +1 -1
- package/dist/preview/{chunk.NRWJ6PLU.js → chunk.F2KDFGHR.js} +1 -1
- package/dist/preview/chunk.FWV4XAZA.js +1 -0
- package/dist/preview/chunk.G3BOZHKR.js +1 -0
- package/dist/preview/{chunk.HH6WIUK3.js → chunk.H4LHHT56.js} +6 -6
- package/dist/preview/{chunk.FKQTQ3FV.js → chunk.HQX5FGYT.js} +1 -1
- package/dist/preview/{chunk.TWFYXD3P.js → chunk.I5ELK6JF.js} +1 -1
- package/dist/preview/{chunk.WEGBBWWK.js → chunk.I6T3FDQS.js} +1 -1
- package/dist/preview/{chunk.DQL3WKR3.js → chunk.IB6PGEU7.js} +1 -1
- package/dist/preview/{chunk.LW7KV5SL.js → chunk.JCZH55RX.js} +1 -1
- package/dist/preview/{chunk.XUXCDUKC.js → chunk.JEMQBV6K.js} +1 -1
- package/dist/preview/{chunk.AXACXB4D.js → chunk.JIXW4WIO.js} +1 -1
- package/dist/preview/chunk.JW3E4SAC.js +1 -0
- package/dist/preview/{chunk.HDEQXJWX.js → chunk.KUTTVYOB.js} +1 -1
- package/dist/preview/{chunk.53RZI5PM.js → chunk.LHFEOEYY.js} +1 -1
- package/dist/preview/{chunk.D3CYTXNZ.js → chunk.MJ67MK4R.js} +1 -1
- package/dist/preview/{chunk.BLAODPYJ.js → chunk.ORJ3T4IW.js} +1 -1
- package/dist/preview/{chunk.TDW6QEG4.js → chunk.PY42PBMB.js} +1 -1
- package/dist/preview/{chunk.VTBAKTFP.js → chunk.QOYC424P.js} +2 -2
- package/dist/preview/{chunk.OXODTBOP.js → chunk.R6F3YMRK.js} +1 -1
- package/dist/preview/chunk.RAE4M3KQ.js +8 -0
- package/dist/preview/chunk.RUFAVEXB.js +1 -0
- package/dist/preview/chunk.RVEMN5WU.js +1 -0
- package/dist/preview/{chunk.XDVKD6VX.js → chunk.S24R4MRK.js} +3 -3
- package/dist/preview/{chunk.S4FO7Y2Q.js → chunk.S56LSUHV.js} +1 -1
- package/dist/preview/{chunk.HAQ4KHRY.js → chunk.SSOTDXRS.js} +1 -1
- package/dist/preview/{chunk.TWGB347L.js → chunk.T6KID3WO.js} +1 -1
- package/dist/preview/chunk.TAOT74FR.js +1 -0
- package/dist/preview/chunk.TTODVIXW.js +1 -0
- package/dist/preview/{chunk.XJNXSQT4.js → chunk.U6BWYBPM.js} +1 -1
- package/dist/preview/{chunk.KKTHQJ6F.js → chunk.UOYH2DFX.js} +1 -1
- package/dist/preview/{chunk.MYCTNK6D.js → chunk.US4KIJSW.js} +1 -1
- package/dist/preview/{chunk.42U4UBDE.js → chunk.WX5CJ7PI.js} +1 -1
- package/dist/preview/chunk.WXO3XUNW.js +1 -0
- package/dist/preview/{chunk.6XBLDV4A.js → chunk.YZZGD5OY.js} +1 -1
- package/dist/preview/{chunk.C7KLA2MW.js → chunk.ZJVIH6IF.js} +1 -1
- package/dist/preview/{chunk.PRXKRG6O.js → chunk.ZRVDIVYY.js} +1 -1
- package/dist/preview/chunk.ZV7ZFH2S.js +1 -0
- package/dist/preview/page.js +2 -2
- package/package.json +6 -6
- package/dist/preview/chunk.2STFOAXA.js +0 -1
- package/dist/preview/chunk.33C6VZAD.js +0 -1
- package/dist/preview/chunk.3TNQPFIK.js +0 -1
- package/dist/preview/chunk.54NSG7BX.js +0 -1
- package/dist/preview/chunk.6O67NOZR.js +0 -1
- package/dist/preview/chunk.7Q7S7YCA.js +0 -1
- package/dist/preview/chunk.EUCXNNCZ.js +0 -107
- package/dist/preview/chunk.FRNIWOKD.js +0 -1
- package/dist/preview/chunk.H3HRTEW7.js +0 -1
- package/dist/preview/chunk.KWSXL3A2.js +0 -1
- package/dist/preview/chunk.UEBBASQW.js +0 -1
- package/dist/preview/chunk.UIZWVBJ7.js +0 -1
- package/dist/preview/chunk.VLNI5U6H.js +0 -1
- package/dist/preview/chunk.XCOPECOJ.js +0 -1
- package/dist/preview/chunk.ZQ4HFIIS.js +0 -8
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{a as ge,b as ye,e as he,f as J,g as be}from"./chunk.ISAMJ7AK.js";import{f as fe}from"./chunk.6XBLDV4A.js";import{$a as ae,A as z,G as E,I as T,Jb as ue,L as ne,M as te,N as X,O as re,Pa as ie,R as _,Rb as pe,Tb as me,U as H,V as oe,_a as q,ea as se,lb as le,nb as de,zb as ce}from"./chunk.ZQ4HFIIS.js";function Pe(t,r,n){let s=t.tryDefinition(r)?.fields.shape,e=z(s?.[n]),l=!1,i=!1;for(;e&&(e.type==="optional"||e.type==="default"||e.type==="nullable"||e.type==="prefault");)(e.type==="optional"||e.type==="nullable")&&(l=!0),(e.type==="default"||e.type==="prefault")&&(i=!0),e=z(e.innerType);if(e?.type!=="enum")return;let y=(e.entries?Object.values(e.entries):e.values??[]).filter(u=>typeof u=="string");return y.length>0?{values:y,empty:l&&!i}:void 0}function L(t,r,n){let s=Pe(t,r,n);if(!s)return[];let e=t.tryDefinition(r),l=s.values.map(i=>({value:i,label:te(e,n,i)}));return s.empty&&l.push({value:null,label:`No ${_(e,n).toLowerCase()}`}),l}function U(t,r,n){let s=t[r];return typeof s=="string"&&n.some(e=>e.value===s)?s:null}function Q(t,r,n,s,e=L(t.schema,n.kind,s)){let l=we(t.schema,t.allMutations(),n.kind,s,e),i=U(n,s,e),y=[];for(let{value:u,by:A,acts:O}of l)if(u!==i)for(let $ of O){let I=A==="step"?{[$.subject.arg]:n.id}:{[$.subject.arg]:n.id,[s]:u},R={name:$.name,args:I};if($.input.safeParse(I).success&&t.permits(R,r).ok){try{se(t.graph,$,I)}catch{continue}y.push({to:u,call:R,title:$.title??$.name});break}}return y}function we(t,r,n,s,e=L(t,n,s)){let l=xe(t,r,n,s),i=ve(t,r,n,s);return e.flatMap(y=>{if(y.value===null)return[];let u=l.filter(A=>A.sets?.[s]===y.value);return[{value:y.value,label:y.label,by:u.length>0?"step":i.length>0?"value":"none",acts:u.length>0?u:i}]})}function xe(t,r,n,s){return r.filter(e=>e.subject!==void 0&&e.derived===void 0&&typeof e.sets?.[s]=="string"&&q(t,e).includes(n))}function ve(t,r,n,s){let e=t.tryDefinition(n);return e?r.filter(l=>{if(!l.subject||!q(t,l).includes(n)||!ae(l,e).includes(s))return!1;let i=l.input.shape;return i!==void 0&&s in i}).sort((l,i)=>+(l.derived!==void 0)-+(i.derived!==void 0)):[]}var Y=(t,r)=>r&&t[r]!==void 0?String(t[r]):"";function Re(t,r,n){let s=d=>t.tryDefinition(d)?r.nodesOfKind(d).filter(k=>E(t.tryDefinition(d),k)):[],e=s(n.rows),l=s(n.columns),i=new Set(e.map(d=>d.id)),y=new Set(l.map(d=>d.id)),u=r.allEdges(),A=[],O=n.link;if(typeof O=="string"){let d=p=>t.tryDefinition(p)?.edges?.[O]?.to,k=(d(n.columns)??[]).some(p=>p===n.rows||p==="*"),w=(d(n.rows)??[]).some(p=>p===n.columns||p==="*"),D=k||!w;for(let p of u){if(p.kind!==O)continue;let m=D?p.to:p.from,o=D?p.from:p.to;i.has(m)&&y.has(o)&&A.push({rowId:m,columnId:o,via:[]})}}else{let d=new Map(O.path.map(w=>[w,new Map]));for(let w of u){let D=d.get(w.kind);if(!D)continue;let p=D.get(w.from);p?p.push(w.to):D.set(w.from,[w.to]);let m=D.get(w.to);m?m.push(w.from):D.set(w.to,[w.from])}let k=new Set;for(let w of l){let D=[{id:w.id,via:[]}];for(let p of O.path){let m=[],o=new Set;for(let f of D)for(let P of d.get(p).get(f.id)??[])o.has(`${f.id}|${P}`)||(o.add(`${f.id}|${P}`),m.push({id:P,via:[...f.via,f.id]}));D=m}for(let p of D){let m=`${p.id}|${w.id}`;!i.has(p.id)||k.has(m)||(k.add(m),A.push({rowId:p.id,columnId:w.id,via:p.via.slice(1)}))}}}let $=n.groupOrder??[],I=d=>$.indexOf(d)===-1?$.length:$.indexOf(d),R=e.map(d=>{let k=d;return{node:d,label:String(k.label??T(t.tryDefinition(d.kind),d)),group:Y(k,n.rowGroup),ref:Y(k,n.rowRef)}}).sort((d,k)=>I(d.group)-I(k.group)||(d.ref<k.ref?-1:d.ref>k.ref?1:0)),N=l.map(d=>({node:d,label:T(t.tryDefinition(d.kind),d),group:Y(d,n.columnGroup)})).sort((d,k)=>d.group<k.group?-1:d.group>k.group?1:d.node.id<k.node.id?-1:d.node.id>k.node.id?1:0);return{rows:R,columns:N,cells:A}}function $e(t,r,n){let{rows:s,columns:e,cells:l}=Re(t,r,n),i=(o,f)=>X(t,o,f),y=o=>X(t,o,1).replace(/^1 /,""),u=o=>({id:o.id,kind:o.kind,title:T(t.tryDefinition(o.kind),o),parts:[]}),A=o=>{let f=r.getNode(o);if(!f)return null;let P=t.tryDefinition(f.kind),M=T(P,f),K=H(f,P,{limit:3,said:[M],glance:!0}).map(B=>B.alone.startsWith(B.label)?`${B.label.toLowerCase()}${B.alone.slice(B.label.length)}`:B.alone);return[M,...K].join(", ")},O=typeof n.link=="string"?[]:n.link.path.slice(0,-1).flatMap((o,f,P)=>{let M=ce(t,n.columns,P.slice(0,f+1));return M.ok?[...M.reached]:[]}),$=[{t:"text",text:`${i(n.rows,s.length)} against ${i(n.columns,e.length)}${O.length>0?`, through ${[...new Set(O)].map(o=>i(o,2).replace(/^2 /,"")).join(" and ")}`:""}${e.length>0?`: ${e.map(o=>o.label).join(", ")}`:""}.`}],I=new Map(e.map(o=>[o.node.id,o.label])),R=new Map(e.map((o,f)=>[o.node.id,f])),N=new Map,d=new Map;for(let o of l){let f=N.get(o.rowId);f?f.push(o):N.set(o.rowId,[o]);let P=d.get(o.columnId);P?P.add(o.rowId):d.set(o.columnId,new Set([o.rowId]))}for(let o of s){let P=[...N.get(o.node.id)??[]].sort((M,K)=>R.get(M.columnId)-R.get(K.columnId)).map(M=>{let K=M.via.map(A).filter(B=>B!==null);return`${I.get(M.columnId)}${K.length>0?` (${K.join("; ")})`:""}`});$.push({t:"field",label:o.label,text:P.length>0?P.join(", "):"none"})}$.push({t:"list",as:"name",columns:1,groups:e.map(o=>{let f=d.get(o.node.id)??new Set,P=s.filter(M=>f.has(M.node.id)).map(M=>u(M.node));return{heading:`${o.label} (${P.length})`,items:P}})});let k=new Set(l.map(o=>o.rowId)),w=new Set(l.map(o=>o.columnId)),D=s.filter(o=>!k.has(o.node.id)),p=e.filter(o=>!w.has(o.node.id)),m=n.rows===n.columns;return D.length>0&&$.push({t:"text",text:`${m?`${D.length} with none across`:`${i(n.rows,D.length)} with no ${y(n.columns)}`}: ${D.map(o=>o.label).join(", ")}.`}),p.length>0&&$.push({t:"text",text:`${m?`${p.length} with none down`:`${i(n.columns,p.length)} on no ${y(n.rows)}`}: ${p.map(o=>o.label).join(", ")}.`}),$}function Z(t,r,n,s={}){let{app:e,blocks:l=n?e?.viewSpecs?.[n.kind]?.[s.slot??"page"]:e?.home}=s;if(!l?.length)return[];let i=s.firstHeading??(n||s.blocks?void 0:1),y=be(t,r,n,{...s,money:s.money??e?.brand,firstHeading:i});return n&&!y.node?[]:ye(typeof l[0]?.t=="string"?l:ge(l),y)}var Ae=240,ke=10,Ce=1160,je=40,Me=640,Oe=3,Ie=t=>Math.max(1,Math.floor((Math.min(t,Ce)-je+ke)/(Ae+ke)));function Be(t,r,n,s){let{app:e}=s,l=s.width??1440,i=s.today??new Date().toISOString().slice(0,10),y=t.seenBy(r),u=y.schema,A=y.graph,O=me(e),$=typeof n=="string"?n.trim():n.slug,I=typeof n=="string"?O.find(a=>a.slug===$||a.title===$||a.address===$):O.find(a=>a.slug===n.slug&&a.kind===n.kind)??n,R=!I&&typeof n=="string"?A.getNode($):void 0;if(!I&&!R)return{ok:!1,error:`"${$}" is not a place this app has, nor a record this seat can see.`,places:O.map(a=>a.slug)};let N=[],d=e.viewSpecs??{},k=Ie(l),w=(a,h)=>Z(y,null,a,{app:e,today:i,...h}),D=(a,h,b)=>{let g=u.tryDefinition(a.kind),S=T(g,a);if(h==="name")return{id:a.id,kind:a.kind,title:S,parts:[]};if(d[a.kind]?.[h]){let j=w(a,{slot:h}),[F,...v]=j,C=F?.t==="title";return{id:a.id,kind:a.kind,title:C?F.text:S,parts:p(C?v:j,b,`views.${a.kind}.${h}`,` (${a.id})`,C?1:0)}}if(h==="row")return{id:a.id,kind:a.kind,title:S,parts:[]};let c=g?.computed?J(u,A,a):a,G=H(c,g,{limit:3,said:[S],glance:!0});return{id:a.id,kind:a.kind,title:S,parts:G.map(j=>({t:"text",text:j.alone}))}};function p(a,h,b,g="",S=0){let x=[];return a.forEach((c,G)=>{let j=`${b}.${G+S}`;switch("problem"in c&&c.problem&&N.push({at:`${j}${g}`,says:c.problem}),c.t){case"title":x.push({t:"heading",level:3,text:c.text});return;case"text":x.push({t:"text",text:c.text,...c.tone?{tone:c.tone}:{}});return;case"badge":x.push({t:"badge",text:c.text});return;case"field":x.push({t:"field",label:c.label,text:c.text});return;case"progress":x.push({t:"progress",label:c.label,text:c.text});return;case"group":x.push(...p(c.blocks,h,`${j}.group`,g));return;case"when":x.push(...p(c.blocks,h,`${j}.show`,g));return;case"divider":case"figure":return;case"headline":x.push({t:"heading",level:c.level,text:c.text});return;case"number":x.push({t:"figure",text:c.text,...c.label?{label:c.label}:{}});return;case"list":{if(c.failed){x.push({t:"text",text:"\u2014"});return}if(c.members.length===0){c.empty&&x.push({t:"list",as:c.as,columns:1,groups:[],empty:c.empty});return}let F=h+1,v=F>Oe?"name":c.as,C=(c.groups??[{value:null,members:c.members}]).map(W=>({..."heading"in W&&W.heading?{heading:W.heading}:{},items:W.members.map(De=>D(De,v,F))}));x.push({t:"list",as:v,columns:v==="card"?k:1,groups:C,...c.more>0?{more:c.more}:{}});return}}}),x}let m=[],o,f,P;if(R){f="record";let a=u.tryDefinition(R.kind),h=T(a,R);P={slug:R.id,title:h,kind:R.kind,address:ie(u,R.kind,R.id)},d[R.kind]?.page&&m.push(...p(w(R,{slot:"page"}),1,`views.${R.kind}.page`));let g=a?.computed?J(u,A,R):R;for(let S of oe(a,H(g,a,{said:[h]}))){S.title&&m.push({t:"heading",level:2,text:S.title});for(let x of S.fields)m.push({t:"field",label:x.label,text:x.value})}}else{let a=I;P={slug:a.slug,title:a.title,kind:a.kind,address:a.address};let h=a.lens?ue(e).drawn.find(b=>b.as===a.slug&&(a.kind===null||b.kinds.includes(a.kind))):void 0;if(a.kind===null){let b=e.brand,g=b?.name??e.name,S=b?.logo&&de(b.logo)?b.logo:void 0;if(o={name:g,...b?.subtitle?{subtitle:b.subtitle}:{},...S?{logo:{alt:b?.logoAlt??g,...le(S)?{drawn:"inline SVG"}:{drawn:"image",src:S}}}:{}},e.home)f="blocks",m=p(w(null,{}),0,"views.home");else{f="derived";let x=new Set(e.pages?.hide??[]),c=pe(u.kinds,e.pages?.order).filter(G=>!x.has(G));m.push({t:"heading",level:1,text:e.name??"Home"});for(let G of c){let j=A.nodesOfKind(G).filter(F=>E(u.tryDefinition(G),F)).length;j>0&&m.push({t:"text",text:`${j} ${V(u,G,j)}`})}}}else if(h?.lens==="blocks")f="lens:blocks",m=p(w(null,{blocks:h.options.blocks??[]}),0,`lenses.${h.index}.options.blocks`);else if(h?.lens==="columns"){f="lens:columns";let b=h.options.bindings??{};for(let g of Object.keys(b)){let S=b[g]?.column;if(!S)continue;let x=L(u,g,S),c=A.nodesOfKind(g).filter(v=>E(u.tryDefinition(g),v));Object.keys(b).length>1&&m.push({t:"heading",level:2,text:V(u,g,2).replace(/^./,v=>v.toUpperCase())}),m.push({t:"text",text:`${c.length} ${V(u,g,c.length)} in columns by ${_(u.tryDefinition(g),S).toLowerCase()}.`});let G=x.map(v=>({column:v,items:c.filter(C=>U(C,S,x)===v.value).map(C=>D(C,"card",1))})).filter(({column:v,items:C})=>v.value!==null||C.length>0).map(({column:v,items:C})=>({heading:`${v.label} (${C.length})`,items:C}));m.push({t:"list",as:"card",columns:1,groups:G});let j=new Map;for(let v of c)for(let C of Q(t,r,v,S,x))j.set(C.to,(j.get(C.to)??new Set).add(`"${C.title}"`));let F=x.filter(v=>v.value!==null&&j.has(v.value)).map(v=>`to ${v.label} by ${[...j.get(v.value)].join(" or ")}`);m.push({t:"text",text:F.length>0?`Moves: ${F.join("; ")}.`:"Moves: none for this seat."})}}else if(h?.lens==="coverage")f="lens:coverage",m=$e(u,A,h.options);else if(h){f=`lens:${h.lens}`;let b=h.kinds.flatMap(g=>A.nodesOfKind(g).filter(S=>E(u.tryDefinition(g),S)));m.push({t:"text",text:`A ${h.lens} of ${b.length} ${h.kinds.map(g=>V(u,g,b.length)).join(" and ")}.`}),m.push({t:"list",as:"name",columns:1,groups:[{items:b.map(g=>D(g,"name",1))}]})}else{f="derived";let b=A.nodesOfKind(a.kind).filter(g=>E(u.tryDefinition(a.kind),g));m.push({t:"heading",level:1,text:a.title}),b.length===0?m.push({t:"list",as:"row",columns:1,groups:[],empty:`No ${V(u,a.kind,0)} yet.`}):m.push({t:"list",as:"row",columns:1,groups:[{items:b.map(g=>D(g,"row",1))}]})}}let M=r.kind==="system"?"the system":(r.roles??[]).length>0?(r.roles??[]).join(", "):r.kind,K=l<Me?"phone":"wide",B=P.kind===null?Ge(u,A):[],ee={...o?{masthead:o}:{},...B.length>0?{facts:B}:{},place:P,seat:M,width:l,variant:K,drawnBy:f,parts:m,problems:N};return{ok:!0,description:{...ee,text:Se(ee)}}}function Ge(t,r){let n=he(t,r,null),s=e=>Array.isArray(e)?e.map(s).join(", "):e===null?"nothing":typeof e=="boolean"?e?"yes":"no":typeof e=="object"?e.label:String(e);return[...fe(t)].map(([e,l])=>{let i=l.label??ne(e);return Object.hasOwn(n.values,e)?{name:e,label:i,value:s(n.values[e])}:{name:e,label:i,refused:n.refused[e]??"it could not be worked out"}})}function V(t,r,n){let s=t.tryDefinition(r);if(n===1)return s?.noun??r;let e=re(t,r);return e.charAt(0).toLowerCase()+e.slice(1)}function Se(t){let r=[`${t.place.title} (${t.place.address}) \u2014 as ${t.seat}, ${t.width} wide (${t.variant}).`],n=t.masthead;n&&r.push(`Masthead: ${n.logo?`the logo ("${n.logo.alt}", ${n.logo.drawn==="image"?n.logo.src:"inline SVG"}), `:""}${n.name}${n.subtitle?` \u2014 ${n.subtitle}`:""}`);let s=(e,l)=>{for(let i of e)switch(i.t){case"heading":r.push(`${l}${"#".repeat(i.level)} ${i.text}`);break;case"text":r.push(`${l}${i.text}`);break;case"badge":r.push(`${l}[${i.text}]`);break;case"field":case"progress":r.push(`${l}${i.label}: ${i.text}`);break;case"figure":r.push(`${l}${i.text}${i.label?` \u2014 ${i.label}`:""}`);break;case"list":if(i.groups.length===0){i.empty&&r.push(`${l}(${i.empty})`);break}for(let y of i.groups){y.heading&&r.push(`${l}${y.heading}:`);for(let u of y.items)r.push(`${l}${y.heading?" ":""}- ${u.title}`),s(u.parts,`${l}${y.heading?" ":" "}`)}i.as==="card"&&i.columns>1&&r.push(`${l}(cards, ${i.columns} across)`),i.more&&r.push(`${l}and ${i.more} more`);break}};if(s(t.parts,""),t.facts){r.push("Facts of the whole graph (what fact('<name>') reads):");for(let e of t.facts)r.push(`- ${e.label} (${e.name}): ${e.value??`not worked out \u2014 ${e.refused}`}`)}if(t.problems.length>0){r.push("Problems:");for(let e of t.problems)r.push(`- ${e.at}: ${e.says}`)}return r.join(`
|
|
1
|
+
import{a as ge,b as ye,e as he,f as J,g as be}from"./chunk.BJ2Y5F66.js";import{f as fe}from"./chunk.YZZGD5OY.js";import{$a as ie,B as z,Bb as ce,H as E,J as T,Ka as se,Lb as ue,M as ne,N as te,O as X,P as re,S as _,Tb as pe,V as H,Vb as me,W as oe,ab as q,bb as ae,nb as le,pb as de}from"./chunk.RAE4M3KQ.js";function Pe(t,r,n){let s=t.tryDefinition(r)?.fields.shape,e=z(s?.[n]),l=!1,i=!1;for(;e&&(e.type==="optional"||e.type==="default"||e.type==="nullable"||e.type==="prefault");)(e.type==="optional"||e.type==="nullable")&&(l=!0),(e.type==="default"||e.type==="prefault")&&(i=!0),e=z(e.innerType);if(e?.type!=="enum")return;let y=(e.entries?Object.values(e.entries):e.values??[]).filter(u=>typeof u=="string");return y.length>0?{values:y,empty:l&&!i}:void 0}function L(t,r,n){let s=Pe(t,r,n);if(!s)return[];let e=t.tryDefinition(r),l=s.values.map(i=>({value:i,label:te(e,n,i)}));return s.empty&&l.push({value:null,label:`No ${_(e,n).toLowerCase()}`}),l}function U(t,r,n){let s=t[r];return typeof s=="string"&&n.some(e=>e.value===s)?s:null}function Q(t,r,n,s,e=L(t.schema,n.kind,s)){let l=we(t.schema,t.allMutations(),n.kind,s,e),i=U(n,s,e),y=[];for(let{value:u,by:A,acts:O}of l)if(u!==i)for(let $ of O){let I=A==="step"?{[$.subject.arg]:n.id}:{[$.subject.arg]:n.id,[s]:u},R={name:$.name,args:I};if($.input.safeParse(I).success&&t.permits(R,r).ok){try{ie(t.graph,$,I)}catch{continue}y.push({to:u,call:R,title:$.title??$.name});break}}return y}function we(t,r,n,s,e=L(t,n,s)){let l=xe(t,r,n,s),i=ve(t,r,n,s);return e.flatMap(y=>{if(y.value===null)return[];let u=l.filter(A=>A.sets?.[s]===y.value);return[{value:y.value,label:y.label,by:u.length>0?"step":i.length>0?"value":"none",acts:u.length>0?u:i}]})}function xe(t,r,n,s){return r.filter(e=>e.subject!==void 0&&e.derived===void 0&&typeof e.sets?.[s]=="string"&&q(t,e).includes(n))}function ve(t,r,n,s){let e=t.tryDefinition(n);return e?r.filter(l=>{if(!l.subject||!q(t,l).includes(n)||!ae(l,e).includes(s))return!1;let i=l.input.shape;return i!==void 0&&s in i}).sort((l,i)=>+(l.derived!==void 0)-+(i.derived!==void 0)):[]}var Y=(t,r)=>r&&t[r]!==void 0?String(t[r]):"";function Re(t,r,n){let s=d=>t.tryDefinition(d)?r.nodesOfKind(d).filter(k=>E(t.tryDefinition(d),k)):[],e=s(n.rows),l=s(n.columns),i=new Set(e.map(d=>d.id)),y=new Set(l.map(d=>d.id)),u=r.allEdges(),A=[],O=n.link;if(typeof O=="string"){let d=p=>t.tryDefinition(p)?.edges?.[O]?.to,k=(d(n.columns)??[]).some(p=>p===n.rows||p==="*"),w=(d(n.rows)??[]).some(p=>p===n.columns||p==="*"),D=k||!w;for(let p of u){if(p.kind!==O)continue;let m=D?p.to:p.from,o=D?p.from:p.to;i.has(m)&&y.has(o)&&A.push({rowId:m,columnId:o,via:[]})}}else{let d=new Map(O.path.map(w=>[w,new Map]));for(let w of u){let D=d.get(w.kind);if(!D)continue;let p=D.get(w.from);p?p.push(w.to):D.set(w.from,[w.to]);let m=D.get(w.to);m?m.push(w.from):D.set(w.to,[w.from])}let k=new Set;for(let w of l){let D=[{id:w.id,via:[]}];for(let p of O.path){let m=[],o=new Set;for(let f of D)for(let P of d.get(p).get(f.id)??[])o.has(`${f.id}|${P}`)||(o.add(`${f.id}|${P}`),m.push({id:P,via:[...f.via,f.id]}));D=m}for(let p of D){let m=`${p.id}|${w.id}`;!i.has(p.id)||k.has(m)||(k.add(m),A.push({rowId:p.id,columnId:w.id,via:p.via.slice(1)}))}}}let $=n.groupOrder??[],I=d=>$.indexOf(d)===-1?$.length:$.indexOf(d),R=e.map(d=>{let k=d;return{node:d,label:String(k.label??T(t.tryDefinition(d.kind),d)),group:Y(k,n.rowGroup),ref:Y(k,n.rowRef)}}).sort((d,k)=>I(d.group)-I(k.group)||(d.ref<k.ref?-1:d.ref>k.ref?1:0)),N=l.map(d=>({node:d,label:T(t.tryDefinition(d.kind),d),group:Y(d,n.columnGroup)})).sort((d,k)=>d.group<k.group?-1:d.group>k.group?1:d.node.id<k.node.id?-1:d.node.id>k.node.id?1:0);return{rows:R,columns:N,cells:A}}function $e(t,r,n){let{rows:s,columns:e,cells:l}=Re(t,r,n),i=(o,f)=>X(t,o,f),y=o=>X(t,o,1).replace(/^1 /,""),u=o=>({id:o.id,kind:o.kind,title:T(t.tryDefinition(o.kind),o),parts:[]}),A=o=>{let f=r.getNode(o);if(!f)return null;let P=t.tryDefinition(f.kind),M=T(P,f),K=H(f,P,{limit:3,said:[M],glance:!0}).map(B=>B.alone.startsWith(B.label)?`${B.label.toLowerCase()}${B.alone.slice(B.label.length)}`:B.alone);return[M,...K].join(", ")},O=typeof n.link=="string"?[]:n.link.path.slice(0,-1).flatMap((o,f,P)=>{let M=ce(t,n.columns,P.slice(0,f+1));return M.ok?[...M.reached]:[]}),$=[{t:"text",text:`${i(n.rows,s.length)} against ${i(n.columns,e.length)}${O.length>0?`, through ${[...new Set(O)].map(o=>i(o,2).replace(/^2 /,"")).join(" and ")}`:""}${e.length>0?`: ${e.map(o=>o.label).join(", ")}`:""}.`}],I=new Map(e.map(o=>[o.node.id,o.label])),R=new Map(e.map((o,f)=>[o.node.id,f])),N=new Map,d=new Map;for(let o of l){let f=N.get(o.rowId);f?f.push(o):N.set(o.rowId,[o]);let P=d.get(o.columnId);P?P.add(o.rowId):d.set(o.columnId,new Set([o.rowId]))}for(let o of s){let P=[...N.get(o.node.id)??[]].sort((M,K)=>R.get(M.columnId)-R.get(K.columnId)).map(M=>{let K=M.via.map(A).filter(B=>B!==null);return`${I.get(M.columnId)}${K.length>0?` (${K.join("; ")})`:""}`});$.push({t:"field",label:o.label,text:P.length>0?P.join(", "):"none"})}$.push({t:"list",as:"name",columns:1,groups:e.map(o=>{let f=d.get(o.node.id)??new Set,P=s.filter(M=>f.has(M.node.id)).map(M=>u(M.node));return{heading:`${o.label} (${P.length})`,items:P}})});let k=new Set(l.map(o=>o.rowId)),w=new Set(l.map(o=>o.columnId)),D=s.filter(o=>!k.has(o.node.id)),p=e.filter(o=>!w.has(o.node.id)),m=n.rows===n.columns;return D.length>0&&$.push({t:"text",text:`${m?`${D.length} with none across`:`${i(n.rows,D.length)} with no ${y(n.columns)}`}: ${D.map(o=>o.label).join(", ")}.`}),p.length>0&&$.push({t:"text",text:`${m?`${p.length} with none down`:`${i(n.columns,p.length)} on no ${y(n.rows)}`}: ${p.map(o=>o.label).join(", ")}.`}),$}function Z(t,r,n,s={}){let{app:e,blocks:l=n?e?.viewSpecs?.[n.kind]?.[s.slot??"page"]:e?.home}=s;if(!l?.length)return[];let i=s.firstHeading??(n||s.blocks?void 0:1),y=be(t,r,n,{...s,money:s.money??e?.brand,firstHeading:i});return n&&!y.node?[]:ye(typeof l[0]?.t=="string"?l:ge(l),y)}var Ae=240,ke=10,Ce=1160,je=40,Me=640,Oe=3,Ie=t=>Math.max(1,Math.floor((Math.min(t,Ce)-je+ke)/(Ae+ke)));function Be(t,r,n,s){let{app:e}=s,l=s.width??1440,i=s.today??new Date().toISOString().slice(0,10),y=t.seenBy(r),u=y.schema,A=y.graph,O=me(e),$=typeof n=="string"?n.trim():n.slug,I=typeof n=="string"?O.find(a=>a.slug===$||a.title===$||a.address===$):O.find(a=>a.slug===n.slug&&a.kind===n.kind)??n,R=!I&&typeof n=="string"?A.getNode($):void 0;if(!I&&!R)return{ok:!1,error:`"${$}" is not a place this app has, nor a record this seat can see.`,places:O.map(a=>a.slug)};let N=[],d=e.viewSpecs??{},k=Ie(l),w=(a,h)=>Z(y,null,a,{app:e,today:i,...h}),D=(a,h,b)=>{let g=u.tryDefinition(a.kind),S=T(g,a);if(h==="name")return{id:a.id,kind:a.kind,title:S,parts:[]};if(d[a.kind]?.[h]){let j=w(a,{slot:h}),[F,...v]=j,C=F?.t==="title";return{id:a.id,kind:a.kind,title:C?F.text:S,parts:p(C?v:j,b,`views.${a.kind}.${h}`,` (${a.id})`,C?1:0)}}if(h==="row")return{id:a.id,kind:a.kind,title:S,parts:[]};let c=g?.computed?J(u,A,a):a,G=H(c,g,{limit:3,said:[S],glance:!0});return{id:a.id,kind:a.kind,title:S,parts:G.map(j=>({t:"text",text:j.alone}))}};function p(a,h,b,g="",S=0){let x=[];return a.forEach((c,G)=>{let j=`${b}.${G+S}`;switch("problem"in c&&c.problem&&N.push({at:`${j}${g}`,says:c.problem}),c.t){case"title":x.push({t:"heading",level:3,text:c.text});return;case"text":x.push({t:"text",text:c.text,...c.tone?{tone:c.tone}:{}});return;case"badge":x.push({t:"badge",text:c.text});return;case"field":x.push({t:"field",label:c.label,text:c.text});return;case"progress":x.push({t:"progress",label:c.label,text:c.text});return;case"group":x.push(...p(c.blocks,h,`${j}.group`,g));return;case"when":x.push(...p(c.blocks,h,`${j}.show`,g));return;case"divider":case"figure":return;case"headline":x.push({t:"heading",level:c.level,text:c.text});return;case"number":x.push({t:"figure",text:c.text,...c.label?{label:c.label}:{}});return;case"list":{if(c.failed){x.push({t:"text",text:"\u2014"});return}if(c.members.length===0){c.empty&&x.push({t:"list",as:c.as,columns:1,groups:[],empty:c.empty});return}let F=h+1,v=F>Oe?"name":c.as,C=(c.groups??[{value:null,members:c.members}]).map(W=>({..."heading"in W&&W.heading?{heading:W.heading}:{},items:W.members.map(De=>D(De,v,F))}));x.push({t:"list",as:v,columns:v==="card"?k:1,groups:C,...c.more>0?{more:c.more}:{}});return}}}),x}let m=[],o,f,P;if(R){f="record";let a=u.tryDefinition(R.kind),h=T(a,R);P={slug:R.id,title:h,kind:R.kind,address:se(u,R.kind,R.id)},d[R.kind]?.page&&m.push(...p(w(R,{slot:"page"}),1,`views.${R.kind}.page`));let g=a?.computed?J(u,A,R):R;for(let S of oe(a,H(g,a,{said:[h]}))){S.title&&m.push({t:"heading",level:2,text:S.title});for(let x of S.fields)m.push({t:"field",label:x.label,text:x.value})}}else{let a=I;P={slug:a.slug,title:a.title,kind:a.kind,address:a.address};let h=a.lens?ue(e).drawn.find(b=>b.as===a.slug&&(a.kind===null||b.kinds.includes(a.kind))):void 0;if(a.kind===null){let b=e.brand,g=b?.name??e.name,S=b?.logo&&de(b.logo)?b.logo:void 0;if(o={name:g,...b?.subtitle?{subtitle:b.subtitle}:{},...S?{logo:{alt:b?.logoAlt??g,...le(S)?{drawn:"inline SVG"}:{drawn:"image",src:S}}}:{}},e.home)f="blocks",m=p(w(null,{}),0,"views.home");else{f="derived";let x=new Set(e.pages?.hide??[]),c=pe(u.kinds,e.pages?.order).filter(G=>!x.has(G));m.push({t:"heading",level:1,text:e.name??"Home"});for(let G of c){let j=A.nodesOfKind(G).filter(F=>E(u.tryDefinition(G),F)).length;j>0&&m.push({t:"text",text:`${j} ${V(u,G,j)}`})}}}else if(h?.lens==="blocks")f="lens:blocks",m=p(w(null,{blocks:h.options.blocks??[]}),0,`lenses.${h.index}.options.blocks`);else if(h?.lens==="columns"){f="lens:columns";let b=h.options.bindings??{};for(let g of Object.keys(b)){let S=b[g]?.column;if(!S)continue;let x=L(u,g,S),c=A.nodesOfKind(g).filter(v=>E(u.tryDefinition(g),v));Object.keys(b).length>1&&m.push({t:"heading",level:2,text:V(u,g,2).replace(/^./,v=>v.toUpperCase())}),m.push({t:"text",text:`${c.length} ${V(u,g,c.length)} in columns by ${_(u.tryDefinition(g),S).toLowerCase()}.`});let G=x.map(v=>({column:v,items:c.filter(C=>U(C,S,x)===v.value).map(C=>D(C,"card",1))})).filter(({column:v,items:C})=>v.value!==null||C.length>0).map(({column:v,items:C})=>({heading:`${v.label} (${C.length})`,items:C}));m.push({t:"list",as:"card",columns:1,groups:G});let j=new Map;for(let v of c)for(let C of Q(t,r,v,S,x))j.set(C.to,(j.get(C.to)??new Set).add(`"${C.title}"`));let F=x.filter(v=>v.value!==null&&j.has(v.value)).map(v=>`to ${v.label} by ${[...j.get(v.value)].join(" or ")}`);m.push({t:"text",text:F.length>0?`Moves: ${F.join("; ")}.`:"Moves: none for this seat."})}}else if(h?.lens==="coverage")f="lens:coverage",m=$e(u,A,h.options);else if(h){f=`lens:${h.lens}`;let b=h.kinds.flatMap(g=>A.nodesOfKind(g).filter(S=>E(u.tryDefinition(g),S)));m.push({t:"text",text:`A ${h.lens} of ${b.length} ${h.kinds.map(g=>V(u,g,b.length)).join(" and ")}.`}),m.push({t:"list",as:"name",columns:1,groups:[{items:b.map(g=>D(g,"name",1))}]})}else{f="derived";let b=A.nodesOfKind(a.kind).filter(g=>E(u.tryDefinition(a.kind),g));m.push({t:"heading",level:1,text:a.title}),b.length===0?m.push({t:"list",as:"row",columns:1,groups:[],empty:`No ${V(u,a.kind,0)} yet.`}):m.push({t:"list",as:"row",columns:1,groups:[{items:b.map(g=>D(g,"row",1))}]})}}let M=r.kind==="system"?"the system":(r.roles??[]).length>0?(r.roles??[]).join(", "):r.kind,K=l<Me?"phone":"wide",B=P.kind===null?Ge(u,A):[],ee={...o?{masthead:o}:{},...B.length>0?{facts:B}:{},place:P,seat:M,width:l,variant:K,drawnBy:f,parts:m,problems:N};return{ok:!0,description:{...ee,text:Se(ee)}}}function Ge(t,r){let n=he(t,r,null),s=e=>Array.isArray(e)?e.map(s).join(", "):e===null?"nothing":typeof e=="boolean"?e?"yes":"no":typeof e=="object"?e.label:String(e);return[...fe(t)].map(([e,l])=>{let i=l.label??ne(e);return Object.hasOwn(n.values,e)?{name:e,label:i,value:s(n.values[e])}:{name:e,label:i,refused:n.refused[e]??"it could not be worked out"}})}function V(t,r,n){let s=t.tryDefinition(r);if(n===1)return s?.noun??r;let e=re(t,r);return e.charAt(0).toLowerCase()+e.slice(1)}function Se(t){let r=[`${t.place.title} (${t.place.address}) \u2014 as ${t.seat}, ${t.width} wide (${t.variant}).`],n=t.masthead;n&&r.push(`Masthead: ${n.logo?`the logo ("${n.logo.alt}", ${n.logo.drawn==="image"?n.logo.src:"inline SVG"}), `:""}${n.name}${n.subtitle?` \u2014 ${n.subtitle}`:""}`);let s=(e,l)=>{for(let i of e)switch(i.t){case"heading":r.push(`${l}${"#".repeat(i.level)} ${i.text}`);break;case"text":r.push(`${l}${i.text}`);break;case"badge":r.push(`${l}[${i.text}]`);break;case"field":case"progress":r.push(`${l}${i.label}: ${i.text}`);break;case"figure":r.push(`${l}${i.text}${i.label?` \u2014 ${i.label}`:""}`);break;case"list":if(i.groups.length===0){i.empty&&r.push(`${l}(${i.empty})`);break}for(let y of i.groups){y.heading&&r.push(`${l}${y.heading}:`);for(let u of y.items)r.push(`${l}${y.heading?" ":""}- ${u.title}`),s(u.parts,`${l}${y.heading?" ":" "}`)}i.as==="card"&&i.columns>1&&r.push(`${l}(cards, ${i.columns} across)`),i.more&&r.push(`${l}and ${i.more} more`);break}};if(s(t.parts,""),t.facts){r.push("Facts of the whole graph (what fact('<name>') reads):");for(let e of t.facts)r.push(`- ${e.label} (${e.name}): ${e.value??`not worked out \u2014 ${e.refused}`}`)}if(t.problems.length>0){r.push("Problems:");for(let e of t.problems)r.push(`- ${e.at}: ${e.says}`)}return r.join(`
|
|
2
2
|
`)}export{L as a,U as b,Q as c,we as d,xe as e,ve as f,Z as g,Be as h,Se as i};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as a}from"./chunk.
|
|
1
|
+
import{b as a}from"./chunk.JCZH55RX.js";import{l as i}from"./chunk.2WFEFZAW.js";import{Ba as o}from"./chunk.RAE4M3KQ.js";function p(r){let t=r.within??{};return o({...t.sort?{sort:t.sort}:{},...t.filter?{filter:t.filter}:{},...t.group?{group:t.group}:{},...t.q?{q:t.q}:{}})}function s(r,t){let m=a(t),e=r;for(let n of["sort","filter","group","q"])e=i(e,n,m[n]??null);return e}export{p as a,s as b};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import{g as ot,h as ue,k as st,l as he}from"./chunk.
|
|
1
|
+
import{g as ot,h as ue,k as st,l as he}from"./chunk.2YVXTTC2.js";import{a as ae,b as Q,c as ce,d as it,f as rt,g as ie}from"./chunk.BJ2Y5F66.js";import{a as ne,b as et}from"./chunk.SSOTDXRS.js";import{i as J,j,k as tt,l as nt}from"./chunk.ZRVDIVYY.js";import{a as lt,b as dt}from"./chunk.PY42PBMB.js";import{d as at}from"./chunk.JCZH55RX.js";import{C as Fe,F as Ke,G as _e,P as je,Y as Ue,a as Ge,ba as qe,ca as N,da as Xe,ea as le,fa as me,ia as _,j as Ie,ja as Ye,l as He,la as de,m as Oe,na as Je,pa as ye,q as ze,qa as Qe,ra as fe,y as ge,ya as Ze}from"./chunk.2WFEFZAW.js";import{J as T,K as Ve,M as I,N as Be,R as Le,S as De,U as Y,V as Z,W as Me,ea as We,fb as ee}from"./chunk.RAE4M3KQ.js";import{a as te,b as D}from"./chunk.MRK6QJV5.js";import{b as A}from"./chunk.AJZBJBMO.js";var M=A(te(),1);var H=A(D(),1);function ct({id:e,max:t=8,empty:a,hide:n}){let{store:r}=N();le();let d=Et(r,e,r.violations()),i=n?d.flatMap(c=>{let p=c.ids.filter(u=>!n.has(u));return p.length>0?[{...c,ids:p}]:[]}):d;return i.length===0?a&&d.length===0?(0,H.jsx)("p",{style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-faint)"},children:a}):null:(0,H.jsx)("div",{"data-graview-primitive":"connections",style:{display:"flex",flexDirection:"column",gap:12},children:i.map(c=>{let p=c.ids.slice(0,t),u=c.ids.length-p.length;return(0,H.jsxs)("section",{style:{display:"flex",flexDirection:"column",gap:6},children:[(0,H.jsx)("h2",{...c.said?{"aria-label":c.said}:{},style:{margin:0,fontSize:"0.75rem",fontWeight:600,letterSpacing:"0.09em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:c.label}),(0,H.jsxs)("div",{style:{display:"flex",flexWrap:"wrap",gap:6},children:[p.map(o=>{let s=r.graph.getNode(o);return s?(0,H.jsx)(j,{pickId:o,hue:ee(s.kind),title:`Go to the ${Y(r.schema.tryDefinition(s.kind),s.kind)}`,label:T(r.schema.tryDefinition(s.kind),s)},o):null}),u>0?(0,H.jsx)(j,{label:`+${u} more`}):null]})]},c.key)})})}function Et(e,t,a=[]){let n=e.graph.getNode(t);if(!n)return[];let r=new Map,d=[];for(let i of a)if(i.subjectId===t)for(let c of i.nodeIds)c!==t&&!d.includes(c)&&e.graph.has(c)&&d.push(c);d.length>0&&r.set("judges",{key:"judges",label:"what it finds wrong",ids:d});for(let i of e.graph.allEdges()){let c=i.from===t?i.to:i.to===t?i.from:null;if(c===null||c===t)continue;let p=e.graph.getNode(c);if(!p)continue;let u=i.from===t?"out":"in",o=u==="out"?n.kind:p.kind,s=Vt(e.schema,o,i.kind,u),w=`${i.kind}:${u}:${s.label}`,y=r.get(w)??{key:w,...s,ids:[]};y.ids.includes(c)||y.ids.push(c),r.set(w,y)}for(let i of r.values())i.ids.sort();return[...r.values()].sort((i,c)=>i.key<c.key?-1:i.key>c.key?1:0)}function Vt(e,t,a,n){let r=Le(e,t,a,n),d=I(a).toLowerCase();return r.trim().toLowerCase()!==d?{label:r}:n==="out"?{label:`\u2192 ${d}`,said:d}:{label:`\u2190 ${d}`,said:`${d}, pointing here`}}var P=A(te(),1);var W=A(D(),1),Bt=/^\s*(\d{1,6})[.)]\s+(.*)$/s,Lt=/^\s*[-*•]\s+(.*)$/s;function Dt(e){let t=[];for(let a of e.replace(/\r\n?/g,`
|
|
2
2
|
`).split(/\n[ \t]*\n+/)){let n=null,r=()=>{n&&(n.t==="p"?n.lines.length>0:n.items.length>0)&&t.push(n),n=null};for(let d of a.split(`
|
|
3
|
-
`)){let i=Bt.exec(d),c=i?null:Lt.exec(d);if(i)n?.t!=="ol"&&(r(),n={t:"ol",start:Number(i[1]),items:[]}),n.items.push(i[2]);else if(c)n?.t!=="ul"&&(r(),n={t:"ul",items:[]}),n.items.push(c[1]);else if(n&&n.t!=="p"&&/^\s+\S/.test(d)){let p=n.items;p[p.length-1]=`${p[p.length-1]} ${d.trim()}`}else d.trim().length>0&&(n?.t!=="p"&&(r(),n={t:"p",lines:[]}),n.lines.push(d.trim()))}r()}return t}function we(e){return/[\r\n]/.test(e)}var Mt={display:"grid",gap:"0.7em",minWidth:0,overflowWrap:"anywhere"},Wt={margin:0},ut={margin:0,paddingInlineStart:"1.6em",display:"grid",gap:"0.3em"};function re({text:e,className:t,style:a}){return(0,W.jsx)("div",{"data-graview-text-body":"",...t?{className:t}:{},style:{...Mt,...a},children:Dt(e).map((n,r)=>n.t==="p"?(0,W.jsx)("p",{style:Wt,children:n.lines.map((d,i)=>(0,W.jsxs)("span",{children:[i>0?(0,W.jsx)("br",{}):null,d]},i))},r):n.t==="ol"?(0,W.jsx)("ol",{start:n.start,style:ut,children:n.items.map((d,i)=>(0,W.jsx)("li",{children:d},i))},r):(0,W.jsx)("ul",{style:ut,children:n.items.map((d,i)=>(0,W.jsx)("li",{children:d},i))},r))})}var f=A(D(),1);function mt({nodeId:e,field:t,value:a,stored:n=a}){let{fields:r,commit:d}=ue(e),i=r.find(h=>h.field===t),{store:c}=N(),p=c.graph.getNode(e)?.kind,u=c.schema.definitions.find(h=>h.kind===p),o=De(u,t).toLowerCase(),[s,w]=(0,P.useState)(!1),[y,v]=(0,P.useState)(n),S=(0,P.useRef)(null),b=(0,P.useRef)(null),k=(0,P.useRef)(!1),R=h=>{k.current=h,w(!1)};if((0,P.useEffect)(()=>v(n),[n,s]),(0,P.useEffect)(()=>{s?S.current?.focus():k.current&&(k.current=!1,b.current?.focus())},[s]),!i)return(0,f.jsx)("span",{"data-graview-field":t,"data-graview-readonly":"",title:`Read-only \u2014 nothing this app declares changes the ${o}`,style:{color:"var(--graview-ink)",cursor:"default",overflowWrap:"anywhere"},children:a});if(!s)return(0,f.jsx)("button",{ref:b,type:"button","data-graview-field":t,"data-graview-editable":i.mutation,title:`${i.title} \u2014 changes the ${o}, and can be undone`,onClick:()=>w(!0),style:{all:"unset",cursor:"text",display:"inline-flex",alignItems:"flex-end",minHeight:24,minWidth:24,maxWidth:"100%",overflowWrap:"anywhere",paddingBottom:1,borderBottom:"1px dashed var(--graview-edge-bright)",color:"var(--graview-ink)"},children:a});let $=(h,{left:L=!1}={})=>{R(!L),!(h===n||h===""||h===void 0)&&d(i,h)};if(!i.takesValue){let h=[i,...i.alternatives];return(0,f.jsx)("span",{role:"group","aria-label":`Change ${I(t).toLowerCase()}`,"data-graview-field":t,style:{display:"inline-flex",gap:6,alignItems:"center",flexWrap:"wrap"},onKeyDown:L=>{L.key==="Escape"&&R(!0)},children:h.map((L,U)=>(0,f.jsx)("button",{type:"button",ref:U===0?S:void 0,"data-graview-act":L.mutation,onClick:()=>{R(!0),d(L,void 0)},onBlur:B=>{let O=B.relatedTarget;(!O||!B.currentTarget.parentElement?.contains(O))&&R(!1)},style:{padding:"2px 9px",fontSize:"0.8125rem",borderRadius:999},children:L.title},L.mutation))})}return(0,f.jsxs)("form",{style:{display:"inline-flex",gap:4},onSubmit:h=>{h.preventDefault(),$(pt(i,y))},children:[i.shape.type==="choice"?(0,f.jsx)("select",{ref:S,"aria-label":I(t),"data-graview-field":t,value:y,onChange:h=>$(h.target.value),onBlur:()=>R(!1),style:{font:"inherit",fontSize:"inherit"},children:i.shape.options.map(h=>(0,f.jsx)("option",{value:h,children:Be(u,t,h)},h))}):(0,f.jsx)("input",{ref:S,"aria-label":I(t),"data-graview-field":t,type:i.shape.type==="number"?"number":i.shape.type==="date"?i.shape.time?"datetime-local":"date":"text",...i.shape.type==="number"&&i.shape.min!==void 0?{min:i.shape.min}:{},...i.shape.type==="number"&&i.shape.max!==void 0?{max:i.shape.max}:{},...i.shape.type==="number"&&i.shape.step!==void 0?{step:i.shape.step}:{},value:y,onChange:h=>v(h.target.value),onBlur:()=>$(pt(i,y),{left:!0}),onKeyDown:h=>{h.key==="Escape"&&R(!0)},style:{font:"inherit",fontSize:"inherit",width:`${Math.max(6,y.length+1)}ch`,minHeight:24,display:"inline-flex",alignItems:"center",padding:"0 3px"}}),i.open.length>0?(0,f.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:["also needs ",i.open.map(h=>h.name).join(", ")]}):null]})}function pt(e,t){return e.shape.type==="number"?Number(t):t}function yt({id:e,hide:t=[],limit:a=10,labels:n={},shown:r=[]}){let{store:d}=N(),i=me(e);if(!i)return null;let c=d.schema.tryDefinition(i.kind),p=Z(i,c,{limit:a,said:r}).filter(u=>!t.includes(u.key));return p.length===0?null:(0,f.jsx)("div",{"data-graview-fields":i.id,style:{display:"grid",gap:14,alignContent:"start",minWidth:0,fontSize:"0.875rem"},children:Me(c,p).map((u,o)=>{let s=(0,f.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto 1fr",gap:"5px 16px",alignContent:"start",minWidth:0},children:u.fields.map(y=>y.long?(0,f.jsx)(It,{nodeId:i.id,field:y.key,label:n[y.key]??y.label,value:y.value,labelStyle:gt,style:{gridColumn:"1 / -1",marginTop:6}},y.key):(0,f.jsxs)("div",{style:{display:"contents"},children:[(0,f.jsx)("dt",{style:{...gt,whiteSpace:"nowrap"},children:n[y.key]??y.label}),(0,f.jsx)("dd",{style:{margin:0,minWidth:0},children:(0,f.jsx)(mt,{nodeId:i.id,field:y.key,value:y.value,stored:y.stored})})]},y.key))});if(!u.title)return(0,f.jsx)("div",{children:s},o);let w=`graview-field-group-${i.id}-${o}`;return(0,f.jsxs)("div",{role:"group","aria-labelledby":w,style:{display:"grid",gap:6,minWidth:0},children:[(0,f.jsx)("p",{id:w,"data-graview-field-group":u.title,style:Gt,children:u.title}),s]},o)})})}var gt={color:"var(--graview-ink-faint)",fontSize:"0.8125rem"},Gt={margin:0,fontSize:"0.75rem",letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--graview-ink-muted)",fontWeight:560};function It(e){return Xe()?(0,f.jsx)(Ot,{...e}):(0,f.jsx)(Ht,{...e})}function Ht({field:e,label:t,value:a,labelStyle:n,valueStyle:r,style:d}){return(0,f.jsxs)("div",{"data-graview-long":e,style:{display:"grid",gap:6,minWidth:0,...d},children:[(0,f.jsx)("dt",{style:n,children:t}),(0,f.jsx)("dd",{style:{margin:0,minWidth:0,...r},children:(0,f.jsx)("div",{"data-graview-field":e,children:(0,f.jsx)(re,{text:a})})})]})}function Ot({nodeId:e,field:t,label:a,value:n,labelStyle:r,valueStyle:d,style:i}){let{fields:c,commit:p}=ue(e),u=c.find(k=>k.field===t&&k.takesValue),[o,s]=(0,P.useState)(!1),w=(0,P.useRef)(null),y=(0,P.useRef)(!1);(0,P.useEffect)(()=>{!o&&y.current&&(y.current=!1,w.current?.focus())},[o]);let v=k=>{y.current=k,s(!1)},S=a.toLowerCase(),b=(0,f.jsx)(re,{text:n});return(0,f.jsxs)("div",{"data-graview-long":t,style:{display:"grid",gap:6,minWidth:0,...i},children:[(0,f.jsxs)("dt",{style:{display:"flex",alignItems:"baseline",gap:10,...r},children:[(0,f.jsx)("span",{children:a}),u&&!o?(0,f.jsx)("button",{ref:w,type:"button","data-graview-editable":u.mutation,"aria-label":`Edit the ${S}`,title:`${u.title} \u2014 changes the ${S}, and can be undone`,onClick:()=>s(!0),style:Ft,children:"Edit"}):null]}),(0,f.jsx)("dd",{style:{margin:0,minWidth:0,...d},children:o&&u?(0,f.jsx)(P.Suspense,{fallback:b,children:(0,f.jsx)(zt,{field:t,label:a,value:n,onCancel:()=>v(!0),onSave:(k,R)=>{v(!R),k!==n&&p(u,k)}})}):(0,f.jsx)("div",{"data-graview-field":t,...u?{}:{"data-graview-readonly":"",title:`Read-only \u2014 nothing this app declares changes the ${S}`},...u?{onClick:()=>s(!0)}:{},style:{cursor:u?"text":"default",minWidth:0},children:b})})]})}var zt=(0,P.lazy)(()=>import("./chunk.4HGBVU5B.js")),Ft={all:"unset",cursor:"pointer",fontSize:"0.75rem",letterSpacing:"normal",textTransform:"none",color:"var(--graview-accent)",borderBottom:"1px dashed currentColor",minHeight:24,minWidth:24,display:"inline-flex",alignItems:"flex-end"};function ft({nodeId:e,children:t}){let{fields:a}=ue(e),n=me(e);if(!n)return(0,f.jsx)(f.Fragment,{children:t});let r=a.find(d=>{let i=n[d.field];return typeof i=="string"&&i===t});return r?(0,f.jsx)(mt,{nodeId:e,field:r.field,value:t}):(0,f.jsx)(f.Fragment,{children:t})}var ht=A(te(),1),oe=(0,ht.createContext)(null);var g=A(D(),1),Kt=Ze(Ge(()=>import("./chunk.47GRZWQN.js"))).part((e,t)=>(0,g.jsx)(e.ArrangeBar,{...t}),{what:"Arranging this list"});function ve(e){let{brand:t}=N();return ee(e,t?.accents)}function _t(e,t){if(!t.endsWith("\u2026")&&!t.endsWith("..."))return;let a=t.replace(/[…]|\.\.\.$/g,"").trim();if(!(a.length<12)){for(let n of Object.values(e))if(typeof n=="string"&&n.length>a.length&&n.startsWith(a))return n}}function jt(e,t){let n=Math.max(0,...e.slice(0,t*2).map(d=>d.length))*7.5+28<=212/2?2:1,r=t*n;return{columns:n,shown:Math.min(e.length,r)}}var Ut=8,wt=500,qt=12;function vt(e){return{x:e.clientX,y:e.clientY,pointerType:e.pointerType??""}}function Xt(e,t,a){let n=performance.now()+wt,r=["pointerdown","pointerup","mousedown","mouseup","dblclick"],d=s=>{if(performance.now()>n||!(s instanceof MouseEvent))return!1;let w=vt(s);return t.pointerType&&w.pointerType&&t.pointerType!==w.pointerType?!1:Math.hypot(w.x-t.x,w.y-t.y)<=qt},i=s=>{if(!d(s))return u();s.stopPropagation()},c=s=>{if(!d(s))return u();s.stopPropagation(),s.preventDefault(),e.removeEventListener("click",c,!0),setTimeout(u,50),a()},p=!1,u=()=>{if(!p){p=!0,clearTimeout(o),e.removeEventListener("click",c,!0);for(let s of r)e.removeEventListener(s,i,!0)}};for(let s of r)e.addEventListener(s,i,!0);e.addEventListener("click",c,!0);let o=setTimeout(u,wt)}function Yt({View:e,members:t,mode:a,flagged:n}){let{isSelected:r}=ye(),d=t.slice(0,Ut);return(0,g.jsxs)("div",{"data-graview-rows":"",style:{display:"grid",gap:4,minWidth:0},children:[d.map(i=>(0,g.jsx)("div",{"data-graview-pick":i.id,style:{minWidth:0,cursor:"pointer"},children:(0,g.jsx)(e,{node:i,cardinality:"one",fidelity:"glyph",mode:a,selected:r(i.id),...n?.includes(i.id)?{flagged:[i.id]}:{}})},i.id)),t.length>d.length?(0,g.jsx)(j,{label:`+${t.length-d.length} more`}):null]})}var Jt=11/15;function Qt({text:e,accent:t}){let a=(0,M.useRef)(null),n=(0,M.useRef)(null),[r,d]=(0,M.useState)(1),[i,c]=(0,M.useState)(!1),p=r<1?`${r}em`:void 0;return(0,M.useLayoutEffect)(()=>{let u=a.current,o=n.current;if(!u||!o)return;let s=()=>{let y=u.clientWidth,v=o.offsetWidth;if(y<=0||v<=0)return;let S=parseFloat(getComputedStyle(o).fontSize)/parseFloat(getComputedStyle(u).fontSize)||1,b=v/S,k=Math.max(Jt,Math.min(1,Math.floor(y/b*100)/100));d(R=>Math.abs(R-k)<.01?R:k),c(b*k>y+.5)};if(s(),typeof ResizeObserver>"u")return;let w=new ResizeObserver(s);return w.observe(u),()=>w.disconnect()},[e]),(0,g.jsx)("span",{ref:a,"data-graview-district-name":"",...r<1?{"data-graview-fitted":""}:{},...i?{title:e}:{},style:{display:"block",minWidth:0,fontSize:"0.9375rem",lineHeight:1.25,letterSpacing:"0.05em",textTransform:"uppercase",color:t?"var(--graview-accent)":"var(--graview-ink-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(0,g.jsx)("span",{ref:n,style:{fontSize:p},children:e})})}function Zt(e,t){return!!e?.display?.page?.groups?.length||Z(t,e).some(a=>a.long)}function St(e,t=de(e)){for(let a of e.kinds){let n=e.tryDefinition(a),r=n?.plural??`${String(a)}s`,d=o=>{let s=o.node,w=Qe(),y=(0,M.useContext)(oe);if(!s)return null;let v=y?.nodeId===s.id?y:null,S=T(n,s),b=o.mode==="fullscreen"?_t(s,S)??S:S,k=We(w,[s.id]);return(0,g.jsxs)(J,{title:(0,g.jsx)(ft,{nodeId:s.id,children:v?.title??b}),...v?{}:{subtitle:n?.describe?Ve(n,s):n?.description??String(a)},selected:o.selected,...o.flagged?.includes(s.id)?{tone:"warning"}:{},fit:!0,children:[v?(0,g.jsx)(oe.Provider,{value:null,children:v.body}):null,(0,g.jsxs)("div",{style:{display:"grid",gridTemplateColumns:Zt(n,s)?"minmax(0, 1fr)":"minmax(200px, 1fr) minmax(220px, 1.4fr)",gap:"22px 34px",alignItems:"start"},children:[(0,g.jsx)(yt,{id:s.id,shown:[b,S,n?.description,v?.title],...v?{hide:[...v.fields]}:{}}),(0,g.jsx)(ct,{id:s.id,empty:`Nothing is connected to this ${Y(n,String(a))} yet.`,...v?{hide:v.records}:{}})]}),k.length>0?(0,g.jsx)("p",{"data-graview-broken":"",style:{margin:"14px 0 0",paddingTop:12,borderTop:"1px solid var(--graview-edge)",fontSize:"0.875rem",color:"var(--graview-warn)"},children:k.map(R=>R.message).join(" \xB7 ")}):null]})},i=o=>{let s=o.node;if(!s)return null;let{store:w}=N(),y=n?.computed?rt(w.schema,w.graph,s):s,v=Z(y,n,{limit:3,said:[T(n,s)],glance:!0}),S=ve(a);return(0,g.jsx)(J,{title:T(n,s),selected:o.selected,tone:o.flagged?.includes(s.id)?"warning":"muted",fit:!0,children:(0,g.jsx)(tt,{items:v.map(b=>({id:b.key,label:b.alone,hue:S})),max:3})})},c=o=>{let s=o.node,w=ve(a),y=he().marks.flag;if(!s)return null;let v=o.flagged?.includes(s.id)??!1;return(0,g.jsx)(j,{label:v?`${T(n,s)} ${y}`:T(n,s),hue:w,selected:o.selected,title:v?`${I(Y(n,String(a)))} \u2014 implicated in a problem`:I(Y(n,String(a)))})},p=o=>{let{brand:s,store:w,views:y}=N(),{view:v,go:S}=fe(),b=o.nodes??[],k=y.lookup(String(a),{cardinality:"one",fidelity:"glyph"}),R=k!==void 0&&!Ye(k)?k:void 0,$=lt(v),h=at(b,$,{schema:e,graph:w.graph,flagged:new Set(o.flagged??[])}),L=C=>({id:C.id,label:T(e.tryDefinition(C.kind),C),hue:ee(C.kind,s?.accents)}),U=o.fidelity==="full"&&b.length>1?(0,g.jsx)(M.Suspense,{fallback:null,children:(0,g.jsx)(Kt,{schema:e,graph:w.graph,kind:String(a),arrangement:$,onChange:C=>S(dt(v,C)),kept:{shown:h.nodes.length,of:b.length},style:{marginBottom:8}})}):null,B=C=>C.some(E=>o.flagged?.includes(E.id)),O=(C,E,q)=>R?(0,g.jsx)(J,{title:C,meta:B(E)?`\u26A0 ${E.length}`:E.length,tone:B(E)?"warning":"muted",children:(0,g.jsx)(Yt,{View:R,members:E,mode:o.mode,...o.flagged?{flagged:o.flagged}:{}})},q):(0,g.jsx)(nt,{label:C,count:E.length,flagged:B(E),items:E.map(L)},q);return h.grouped?(0,g.jsxs)("div",{style:{display:"grid",gap:8},"data-graview-grouped":$.group?.by,children:[U,h.groups.map(C=>O(`${o.label??r} \xB7 ${C.label}`,C.nodes,C.key||"-"))]}):(0,g.jsxs)("div",{style:{display:"grid",gap:4},children:[U,O(o.label??r,h.nodes)]})},u=o=>{let s=o.nodes??[],w=jt(s.map(m=>T(n,m)),o.openedRows??je(s.length)),y=ve(a),{brand:v}=N(),S=et(String(a),e,v),b=he().marks.flag,{selection:k}=ye(),{toggle:R,view:$,go:h}=fe(),{views:L,hiddenKinds:U}=N(),B=$.overview&&!U.has(String(a))?L.places().filter(m=>m.kind===String(a)):[],O=ot(),C=o.focused?$.within?.view??B[0]?.as:void 0,E=s.filter(m=>o.flagged?.includes(m.id)).length,q=E>0,z=o.focused||o.raised,$e=o.rank==="secondary"&&!z,V=o.nestedUnder!==void 0,Ae=new Set(k),At=st(),F=z?0:s.filter(m=>At.includes(m.id)&&!Ae.has(m.id)).length,pe=F>0&&!q,se=qe(),X=se&&!V?se.byKind[String(a)]??0:0,Tt=V?8:Math.min(46,10+Math.round(Math.sqrt(s.length)*8)),Te=V?(0,g.jsx)("span",{style:{fontSize:"0.75rem",lineHeight:1.25,letterSpacing:"0.05em",textTransform:"uppercase",color:z?"var(--graview-accent)":"var(--graview-ink-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:o.label??r}):(0,g.jsx)(Qt,{text:o.label??r,accent:!!z});return(0,g.jsxs)("div",{className:"graview-kind-card","data-graview-rank":o.rank,"data-graview-landmark":S||void 0,"data-graview-nested":V||void 0,"data-graview-tied":F||void 0,"data-graview-hits":se&&!V?X:void 0,"data-graview-emphasis":se&&!V?X>0?"lit":"dimmed":void 0,...n?.description||V?{title:V?[o.label??r,n?.description].filter(Boolean).join(" \u2014 "):n.description}:{},style:{position:"relative",height:"100%","--graview-hue":Math.round(y),"--graview-marquee-room":B.length>0&&O?`${O(B.map(m=>m.title))+(S?4:42)}px`:"0px"},children:[S?(0,g.jsx)("span",{className:"graview-kind-block graview-kind-landmark","data-graview-opened":o.opened||void 0,"aria-hidden":"true",style:{"--graview-rise":Tt},children:(0,g.jsx)(ne,{kind:String(a),schema:e,...v?{brand:v}:{},size:96})}):null,(0,g.jsxs)("div",{className:"graview-kind-face","data-graview-opened":o.opened||void 0,style:{display:"flex",flexDirection:"column",gap:V?1:3,padding:V?"5px 7px":"7px 10px",borderRadius:"var(--graview-radius-sm, 9px)",justifyContent:"center",position:"relative",height:"100%",overflow:"hidden",boxSizing:"border-box",border:z?"1px solid var(--graview-accent)":F>0?"1px solid var(--graview-accent-dim)":`1px solid hsl(${Math.round(y)} 55% var(--graview-tint-lightness) / 0.34)`,backgroundColor:"var(--graview-panel)",backgroundImage:`linear-gradient(hsl(${Math.round(y)} 55% var(--graview-tint-lightness) / calc(var(--graview-tint-alpha) * ${z?1.1:$e?.28:.5})), hsl(${Math.round(y)} 55% var(--graview-tint-lightness) / calc(var(--graview-tint-alpha) * ${z?1.1:$e?.28:.5})))`,boxShadow:z?"0 0 0 1px var(--graview-accent-dim)":void 0},children:[!V&&s.length>0?(0,g.jsx)("div",{"data-graview-tally":s.length,"data-graview-broken":E||void 0,"aria-hidden":"true",style:{position:"absolute",left:0,right:0,top:0,display:"flex",height:3,background:`hsl(${Math.round(y)} 55% var(--graview-tint-lightness) / 0.4)`},children:E>0?(0,g.jsx)("span",{style:{width:`${Math.max(6,Math.round(E/s.length*100))}%`,background:"var(--graview-warn)"}}):null}):null,S?(0,g.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:V?4:6},children:[(0,g.jsx)(ne,{kind:String(a),schema:e,...v?{brand:v}:{},size:V?14:18}),Te]}):Te,(0,g.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:"0.875rem"},children:[(0,g.jsx)("span",{style:{fontVariantNumeric:"tabular-nums",color:q?"var(--graview-warn)":pe?"var(--graview-accent)":"var(--graview-ink-faint)"},children:s.length===0?"none yet":pe?F===s.length?`${F} tied`:`${F} of ${s.length} tied`:`${q?`${b} `:""}${s.length}`}),(o.retired??0)>0?(0,g.jsxs)("button",{type:"button",className:"graview-kind-past","data-graview-retired":o.retired,title:`${o.retired} retired ${r.toLowerCase()} \u2014 press to widen the view to the past`,onClick:m=>{m.stopPropagation(),h(ze($,!0))},onDoubleClick:m=>m.stopPropagation(),onPointerDown:m=>m.stopPropagation(),children:["+",o.retired," past"]}):null,X>0?(0,g.jsxs)("button",{type:"button",className:"graview-kind-hits","data-testid":`hits-${String(a)}`,title:`${X} ${X===1?"match":"matches"} for \u201C${$.q??""}\u201D \u2014 press to go in, narrowed`,onClick:m=>{m.stopPropagation(),h(Ke($,ge(String(a)),{ownPicture:!0,...$.q?{carry:$.q}:{}}))},onDoubleClick:m=>m.stopPropagation(),onPointerDown:m=>m.stopPropagation(),children:[X," match"]}):null,F>0&&!pe?(0,g.jsxs)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-accent)"},children:[F," tied"]}):null,o.hasOwnView?(0,g.jsx)("span",{title:`${r} has a view of its own`,"aria-label":"has its own view",style:{fontSize:"0.6875rem",color:"var(--graview-accent)"},children:"\u25C6"}):null,!V&&s.length>0&&!o.focused?(0,g.jsxs)("button",{type:"button",className:"graview-kind-open","data-testid":`open-${String(a)}`,"aria-expanded":o.opened??!1,title:o.opened?"Close it up":`See the ${r} in here`,onClick:m=>{m.stopPropagation(),R(ge(String(a)))},onDoubleClick:m=>m.stopPropagation(),onPointerDown:m=>m.stopPropagation(),children:[(0,g.jsx)("span",{className:"graview-kind-open-word",children:o.opened?"close":"open"})," ",o.opened?"\u25B4":"\u25BE"]}):null]}),o.opened?(0,g.jsxs)("div",{className:"graview-kind-members","data-graview-buildings":o.plot?.side??1,style:{display:"grid",gridTemplateColumns:`repeat(${w.columns}, minmax(0, 1fr))`,gap:3},children:[s.slice(0,w.shown).map(m=>{let K=o.flagged?.includes(m.id)??!1,G=T(n,m);return(0,g.jsx)(j,{pickId:m.id,label:K?`${G} ${b}`:G,title:K?`${G} \u2014 implicated in a problem`:void 0,hue:y,selected:Ae.has(m.id)},m.id)}),s.length>w.shown?(0,g.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",padding:"2px 4px",gridColumn:"1 / -1"},children:["+",s.length-w.shown," more \u2014 double-click to go in"]}):null]}):null]}),!V&&B.length>0?(0,g.jsx)("div",{className:"graview-drive-in","data-testid":`drive-in-${String(a)}`,"data-graview-showing":C,onPointerDown:m=>m.stopPropagation(),onDoubleClick:m=>m.stopPropagation(),children:(0,g.jsx)("div",{className:"graview-drive-in-marquee",role:"group","aria-label":`${r}: pictures`,"data-graview-thumbs":B.length===1?"one":"two",children:B.map(m=>{let K=C===m.as;return(0,g.jsxs)("div",{className:"graview-drive-in-thumb","data-graview-pressed":K||void 0,children:[(0,g.jsx)("span",{className:"graview-drive-in-thumb-title","aria-hidden":"true",children:m.title}),(0,g.jsx)("button",{type:"button",className:"graview-drive-in-thumb-press","data-testid":`showing-${m.as}`,"aria-label":`${r}: ${m.title}`,"aria-pressed":K,title:K?`${m.title} is showing \u2014 press again to open it`:`Show ${m.title} on the billboard \u2014 double-click to open it`,onClick:G=>{G.stopPropagation();let Ee=()=>h(_e($,String(a),m.as));if(G.detail>=2||K&&o.focused){Ee();return}h(He(Ie(Oe($,!0),Fe(String(a))),"view",m.as)),G.detail===1&&Xt(G.currentTarget.ownerDocument,vt(G.nativeEvent),Ee)}})]},m.as)})})}):null]})};p.generic=!0,u.generic=!0,t.register(a,{cardinality:"one",fidelity:"full"},_(d)).register(a,{cardinality:"one",fidelity:"summary"},_(i)).register(a,{cardinality:"one",fidelity:"glyph"},_(c)).register(a,{cardinality:"many",fidelity:"full"},_(p)).register(a,{cardinality:"many",fidelity:"summary"},_(p)).register(a,{cardinality:"many",fidelity:"glyph"},_(u))}return t}var x=A(te(),1);var Se=A(te(),1);var be=A(D(),1),kt=new WeakMap;function en(e){let t=kt.get(e);return t||kt.set(e,t=St(e,de(e))),t}var ke=Je;function bt(){return(0,Se.useContext)(ke)}function Kn({children:e}){return(0,be.jsx)(ke.Provider,{value:!0,children:e})}function xt(e){let t=(0,Se.useContext)(ke),{store:a}=N();if(t)return null;let n=e.kind??e.node?.kind??e.nodes?.[0]?.kind;if(!n)return null;let r=en(a.schema).lookup(n,{cardinality:e.cardinality,fidelity:e.fidelity});return r?(0,be.jsx)(r,{...e}):null}var l=A(D(),1),Nt=(0,x.createContext)(null),tn=(e,t)=>e.trim().toLowerCase().replace(/[_-]+/g," ")===t.trim().toLowerCase().replace(/[_-]+/g," "),nn=(0,x.createContext)(null),Re=(0,x.createContext)(null);function an({block:e}){let t=(0,x.useContext)(Re),a=t?.slots?.[e.key],n=(0,l.jsx)(rn,{block:e});return a?(0,l.jsx)(x.Suspense,{fallback:n,children:(0,l.jsx)(a,{block:e,node:t.node,drawn:n})}):n}function rn({block:e}){let t=(0,x.useContext)(Nt),a=(0,x.useContext)(ln),n=(0,x.useContext)(Ne);if(t&&e.t==="badge"&&t.values.some(r=>tn(r,e.text))||t&&e.t==="field"&&t.field!==void 0&&e.field===t.field)return null;switch(e.t){case"title":return(0,l.jsx)("strong",{className:"graview-spec-title",children:e.text});case"text":return we(e.text)?(0,l.jsx)("div",{className:"graview-spec-text",...e.tone?{"data-graview-tone":e.tone}:{},children:(0,l.jsx)(re,{text:e.text})}):(0,l.jsx)("p",{className:"graview-spec-text",...e.tone?{"data-graview-tone":e.tone}:{},children:e.text});case"badge":return(0,l.jsx)("span",{className:"graview-spec-badge","data-graview-tone":e.tone,children:e.text});case"field":return(0,l.jsxs)("span",{className:"graview-spec-field","data-graview-field":e.field,children:[(0,l.jsx)("span",{className:"graview-spec-label",children:e.label}),(0,l.jsx)("span",{className:"graview-spec-value",...we(e.text)?{style:{whiteSpace:"pre-line"}}:{},children:e.href?(0,l.jsx)("a",{className:"graview-spec-link",href:e.href,rel:"noopener noreferrer",target:"_blank",children:e.text}):e.text})]});case"progress":return e.value===void 0||e.max===void 0?(0,l.jsxs)("span",{className:"graview-spec-progress",children:[(0,l.jsx)("span",{className:"graview-spec-label",children:e.label}),(0,l.jsx)("span",{className:"graview-spec-value",children:e.text})]}):(0,l.jsxs)("span",{className:"graview-spec-progress",children:[(0,l.jsx)("span",{className:"graview-spec-label",children:e.label}),(0,l.jsx)("span",{className:"graview-spec-track",role:"progressbar","aria-label":e.label,"aria-valuemin":0,"aria-valuemax":e.max,"aria-valuenow":Math.max(0,Math.min(e.value,e.max)),"aria-valuetext":e.text,children:(0,l.jsx)("span",{className:"graview-spec-fill",style:{width:`${Math.round(Math.max(0,Math.min(e.value,e.max))/e.max*100)}%`}})}),(0,l.jsx)("span",{className:"graview-spec-value",children:e.text})]});case"group":return(0,l.jsx)("span",{className:"graview-spec-group","data-direction":e.direction,children:(0,l.jsx)(xe,{blocks:e.blocks})});case"when":return e.shown?(0,l.jsx)(xe,{blocks:e.blocks}):null;case"divider":return(0,l.jsx)("hr",{className:"graview-spec-divider"});case"figure":return(0,l.jsx)(on,{});case"headline":{let r=`h${Math.min(6,e.level+a)}`,d=(0,l.jsx)(r,{className:"graview-spec-headline","data-level":e.level,children:e.text});return n!==null&&e.level===1?(0,l.jsxs)(l.Fragment,{children:[d,n]}):d}case"number":return(0,l.jsxs)("span",{className:"graview-spec-number",children:[(0,l.jsx)("span",{className:"graview-spec-number-value",children:e.text}),e.label?(0,l.jsx)("span",{className:"graview-spec-label",children:e.label}):null]});case"list":return(0,l.jsx)(cn,{list:e})}}function on(){let e=(0,x.useContext)(Re)?.figure;return e?(0,l.jsx)("span",{className:"graview-spec-figure","aria-hidden":"true",children:e()}):null}function xe({blocks:e}){return e.map((t,a)=>(0,l.jsx)(an,{block:t},a))}function Rt({blocks:e,ctx:t,view:a}){let n=(0,x.useContext)(nn)?.[a];return(0,l.jsx)(Re.Provider,{value:{figure:t.figure,slots:n,node:t.node},children:(0,l.jsx)(xe,{blocks:e})})}function Ce({blocks:e,ctx:t,view:a}){return(0,l.jsx)(Rt,{blocks:Q(e,t),ctx:t,view:a})}var Ct=3,Pt=(0,x.createContext)(0),sn=(0,x.createContext)(null),ln=(0,x.createContext)(0),Ne=(0,x.createContext)(null);function dn({node:e,as:t,depth:a,said:n=null}){let{store:r,views:d}=N(),i=T(r.schema.tryDefinition(e.kind),e),c=d.lookup(e.kind,{cardinality:"one",fidelity:t==="card"?"summary":"glyph"});return(0,l.jsxs)("li",{className:"graview-spec-item","data-graview-listed":e.id,"data-as":t,children:[a<=Ct&&c?(0,l.jsx)(Ue,{mode:"scene",children:(0,l.jsx)(Pt.Provider,{value:a,children:(0,l.jsx)(Nt.Provider,{value:n,children:(0,l.jsx)(c,{node:e,cardinality:"one",fidelity:t==="card"?"summary":"glyph",mode:"scene",selected:!1})})})}):(0,l.jsx)("span",{className:"graview-spec-item-name",children:i}),(0,l.jsx)($t,{node:e,label:i})]})}function $t({node:e,label:t}){let a=(0,x.useContext)(sn);return a?(0,l.jsx)("a",{className:"graview-spec-item-link",href:a.href(e),"aria-label":t,onClick:n=>{n.metaKey||n.ctrlKey||n.shiftKey||n.button!==0||(n.preventDefault(),n.stopPropagation(),a.go(e))}}):(0,l.jsx)("button",{type:"button",className:"graview-spec-item-link","data-graview-pick":e.id,"aria-label":t})}function cn({list:e}){let t=(0,x.useContext)(Pt)+1,{store:a}=N();if(e.failed)return(0,l.jsx)("p",{className:"graview-spec-text",children:"\u2014"});if(e.members.length===0)return e.empty?(0,l.jsx)("p",{className:"graview-spec-text graview-spec-empty",children:e.empty}):null;let n=(i,c=null)=>t>Ct?(0,l.jsx)("ul",{className:"graview-spec-list","data-as":"names",children:i.map(p=>(0,l.jsxs)("li",{className:"graview-spec-item","data-graview-listed":p.id,"data-as":"name",children:[(0,l.jsx)("span",{className:"graview-spec-item-name",children:T(a.schema.tryDefinition(p.kind),p)}),(0,l.jsx)($t,{node:p,label:T(a.schema.tryDefinition(p.kind),p)})]},p.id))}):(0,l.jsx)("ul",{className:"graview-spec-list","data-as":e.as,children:i.map(p=>(0,l.jsx)(dn,{node:p,as:e.as,depth:t,said:c},p.id))}),r=e.more>0?(0,l.jsx)("p",{className:"graview-spec-text graview-spec-more",children:`and ${e.more} more`}):null;if(!e.groups)return(0,l.jsxs)("div",{className:"graview-spec-listing",children:[n(e.members),r]});let d=`h${e.headingLevel}`;return(0,l.jsxs)("div",{className:"graview-spec-listing",children:[e.groups.map(i=>(0,l.jsxs)("section",{className:"graview-spec-list-group","data-graview-group":i.value??"",children:[i.heading?(0,l.jsx)(d,{className:"graview-spec-list-heading",children:i.heading}):null,n(i.members,i.value!==null?{values:[i.value,...i.heading?[i.heading]:[]]}:null)]},i.value??"")),r]})}function na({blocks:e,heading:t=2,firstHeading:a,slot:n,view:r=n}){let{store:d,brand:i}=N();le();let c=ie(d,null,null,{heading:t,firstHeading:a,money:i}),p=(0,x.useContext)(Ne),u=e.some(o=>o.t==="headline");return(0,l.jsxs)("div",{className:`graview-spec graview-spec-${n}`,"data-graview-spec":n,children:[p!==null&&!u?p:null,(0,l.jsx)(Ne.Provider,{value:u?p:null,children:(0,l.jsx)(Ce,{blocks:e,ctx:c,view:r})})]})}function Pe(e,t="card"){let{store:a,brand:n}=N(),r=a.schema;return{...ie(a,null,e,{slot:t,money:n}),figure:()=>(0,l.jsx)(ne,{kind:e.kind,schema:r,...n?{brand:n}:{},size:22})}}function un({slot:e,blocks:t,node:a,selected:n}){let r=Pe(a,e);return(0,l.jsx)("div",{className:`graview-spec graview-spec-${e}`,"data-graview-spec":e,"data-graview-kind":a.kind,...e==="row"&&t.some(it)?{"data-graview-tall":""}:{},...n?{"data-selected":""}:{},children:(0,l.jsx)(Ce,{blocks:t,ctx:r,view:`${a.kind}.${e}`})})}function pn({blocks:e,node:t,selected:a,flagged:n}){let r=Pe(t),[d,...i]=e,c=d?.t==="title";return(0,l.jsx)(J,{...c?{title:Q([d],r)[0].text}:{},selected:a,tone:n?"warning":"muted",fit:!0,children:(0,l.jsx)("div",{className:"graview-spec graview-spec-card","data-graview-spec":"card","data-graview-kind":t.kind,children:(0,l.jsx)(Ce,{blocks:c?i:e,ctx:r,view:`${t.kind}.card`})})})}function gn({blocks:e,props:t}){let a=t.node,n=Pe(a,"page"),r=bt(),d=Q(e,n),i=ce(e,d),c=i.title!==void 0&&(!r||i.title===T(n.schema?.tryDefinition(a.kind),a)),p=(0,l.jsx)("div",{className:"graview-spec graview-spec-page","data-graview-spec":"page","data-graview-kind":a.kind,children:(0,l.jsx)(Rt,{blocks:c?d.slice(1):d,ctx:n,view:`${a.kind}.page`})});return r?p:(0,l.jsx)(oe.Provider,{value:{nodeId:a.id,...i.title!==void 0?{title:i.title}:{},body:p,fields:i.fields,records:i.records},children:(0,l.jsx)(xt,{...t})})}function aa(e,t,a){return typeof e=="function"?e.says?.(t,a):void 0}function mn({blocks:e,node:t,selected:a}){let{store:n}=N();return(0,l.jsx)("div",{title:T(n.schema.tryDefinition(t.kind),t),style:{minWidth:0,maxWidth:"100%"},children:(0,l.jsx)(un,{slot:"row",blocks:e,node:t,selected:a})})}function ia(e,t,a){if(!a)return e;let n=new Set(t.kinds);for(let[r,d]of Object.entries(a)){if(!n.has(r)||!d)continue;let i=r;if(d.card){let c=ae(d.card),p=u=>u.node?(0,l.jsx)(pn,{blocks:c,node:u.node,selected:u.selected,flagged:u.flagged?.includes(u.node.id)??!1}):null;e.register(i,{cardinality:"one",fidelity:"summary"},p)}if(d.row){let c=ae(d.row),p=u=>u.node?(0,l.jsx)(mn,{blocks:c,node:u.node,selected:u.selected}):null;p.says=(u,o)=>ce(c,Q(c,ie({graph:o,schema:t},null,u,{slot:"row"}))),e.register(i,{cardinality:"one",fidelity:"glyph"},p)}if(d.page){let c=ae(d.page),p=u=>u.node?(0,l.jsx)(gn,{blocks:c,props:u}):null;p.says=(u,o)=>ce(c,Q(c,ie({graph:o,schema:t},null,u))),e.register(i,{cardinality:"one",fidelity:"full"},p)}}return e}export{mt as a,It as b,St as c,Kn as d,Nt as e,sn as f,ln as g,Ne as h,$t as i,na as j,aa as k,ia as l};
|
|
3
|
+
`)){let i=Bt.exec(d),c=i?null:Lt.exec(d);if(i)n?.t!=="ol"&&(r(),n={t:"ol",start:Number(i[1]),items:[]}),n.items.push(i[2]);else if(c)n?.t!=="ul"&&(r(),n={t:"ul",items:[]}),n.items.push(c[1]);else if(n&&n.t!=="p"&&/^\s+\S/.test(d)){let p=n.items;p[p.length-1]=`${p[p.length-1]} ${d.trim()}`}else d.trim().length>0&&(n?.t!=="p"&&(r(),n={t:"p",lines:[]}),n.lines.push(d.trim()))}r()}return t}function we(e){return/[\r\n]/.test(e)}var Mt={display:"grid",gap:"0.7em",minWidth:0,overflowWrap:"anywhere"},Wt={margin:0},ut={margin:0,paddingInlineStart:"1.6em",display:"grid",gap:"0.3em"};function re({text:e,className:t,style:a}){return(0,W.jsx)("div",{"data-graview-text-body":"",...t?{className:t}:{},style:{...Mt,...a},children:Dt(e).map((n,r)=>n.t==="p"?(0,W.jsx)("p",{style:Wt,children:n.lines.map((d,i)=>(0,W.jsxs)("span",{children:[i>0?(0,W.jsx)("br",{}):null,d]},i))},r):n.t==="ol"?(0,W.jsx)("ol",{start:n.start,style:ut,children:n.items.map((d,i)=>(0,W.jsx)("li",{children:d},i))},r):(0,W.jsx)("ul",{style:ut,children:n.items.map((d,i)=>(0,W.jsx)("li",{children:d},i))},r))})}var f=A(D(),1);function mt({nodeId:e,field:t,value:a,stored:n=a}){let{fields:r,commit:d}=ue(e),i=r.find(h=>h.field===t),{store:c}=N(),p=c.graph.getNode(e)?.kind,u=c.schema.definitions.find(h=>h.kind===p),o=De(u,t).toLowerCase(),[s,w]=(0,P.useState)(!1),[y,v]=(0,P.useState)(n),S=(0,P.useRef)(null),b=(0,P.useRef)(null),k=(0,P.useRef)(!1),R=h=>{k.current=h,w(!1)};if((0,P.useEffect)(()=>v(n),[n,s]),(0,P.useEffect)(()=>{s?S.current?.focus():k.current&&(k.current=!1,b.current?.focus())},[s]),!i)return(0,f.jsx)("span",{"data-graview-field":t,"data-graview-readonly":"",title:`Read-only \u2014 nothing this app declares changes the ${o}`,style:{color:"var(--graview-ink)",cursor:"default",overflowWrap:"anywhere"},children:a});if(!s)return(0,f.jsx)("button",{ref:b,type:"button","data-graview-field":t,"data-graview-editable":i.mutation,title:`${i.title} \u2014 changes the ${o}, and can be undone`,onClick:()=>w(!0),style:{all:"unset",cursor:"text",display:"inline-flex",alignItems:"flex-end",minHeight:24,minWidth:24,maxWidth:"100%",overflowWrap:"anywhere",paddingBottom:1,borderBottom:"1px dashed var(--graview-edge-bright)",color:"var(--graview-ink)"},children:a});let $=(h,{left:L=!1}={})=>{R(!L),!(h===n||h===""||h===void 0)&&d(i,h)};if(!i.takesValue){let h=[i,...i.alternatives];return(0,f.jsx)("span",{role:"group","aria-label":`Change ${I(t).toLowerCase()}`,"data-graview-field":t,style:{display:"inline-flex",gap:6,alignItems:"center",flexWrap:"wrap"},onKeyDown:L=>{L.key==="Escape"&&R(!0)},children:h.map((L,U)=>(0,f.jsx)("button",{type:"button",ref:U===0?S:void 0,"data-graview-act":L.mutation,onClick:()=>{R(!0),d(L,void 0)},onBlur:B=>{let O=B.relatedTarget;(!O||!B.currentTarget.parentElement?.contains(O))&&R(!1)},style:{padding:"2px 9px",fontSize:"0.8125rem",borderRadius:999},children:L.title},L.mutation))})}return(0,f.jsxs)("form",{style:{display:"inline-flex",gap:4},onSubmit:h=>{h.preventDefault(),$(pt(i,y))},children:[i.shape.type==="choice"?(0,f.jsx)("select",{ref:S,"aria-label":I(t),"data-graview-field":t,value:y,onChange:h=>$(h.target.value),onBlur:()=>R(!1),style:{font:"inherit",fontSize:"inherit"},children:i.shape.options.map(h=>(0,f.jsx)("option",{value:h,children:Be(u,t,h)},h))}):(0,f.jsx)("input",{ref:S,"aria-label":I(t),"data-graview-field":t,type:i.shape.type==="number"?"number":i.shape.type==="date"?i.shape.time?"datetime-local":"date":"text",...i.shape.type==="number"&&i.shape.min!==void 0?{min:i.shape.min}:{},...i.shape.type==="number"&&i.shape.max!==void 0?{max:i.shape.max}:{},...i.shape.type==="number"&&i.shape.step!==void 0?{step:i.shape.step}:{},value:y,onChange:h=>v(h.target.value),onBlur:()=>$(pt(i,y),{left:!0}),onKeyDown:h=>{h.key==="Escape"&&R(!0)},style:{font:"inherit",fontSize:"inherit",width:`${Math.max(6,y.length+1)}ch`,minHeight:24,display:"inline-flex",alignItems:"center",padding:"0 3px"}}),i.open.length>0?(0,f.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:["also needs ",i.open.map(h=>h.name).join(", ")]}):null]})}function pt(e,t){return e.shape.type==="number"?Number(t):t}function yt({id:e,hide:t=[],limit:a=10,labels:n={},shown:r=[]}){let{store:d}=N(),i=me(e);if(!i)return null;let c=d.schema.tryDefinition(i.kind),p=Z(i,c,{limit:a,said:r}).filter(u=>!t.includes(u.key));return p.length===0?null:(0,f.jsx)("div",{"data-graview-fields":i.id,style:{display:"grid",gap:14,alignContent:"start",minWidth:0,fontSize:"0.875rem"},children:Me(c,p).map((u,o)=>{let s=(0,f.jsx)("dl",{style:{margin:0,display:"grid",gridTemplateColumns:"auto 1fr",gap:"5px 16px",alignContent:"start",minWidth:0},children:u.fields.map(y=>y.long?(0,f.jsx)(It,{nodeId:i.id,field:y.key,label:n[y.key]??y.label,value:y.value,labelStyle:gt,style:{gridColumn:"1 / -1",marginTop:6}},y.key):(0,f.jsxs)("div",{style:{display:"contents"},children:[(0,f.jsx)("dt",{style:{...gt,whiteSpace:"nowrap"},children:n[y.key]??y.label}),(0,f.jsx)("dd",{style:{margin:0,minWidth:0},children:(0,f.jsx)(mt,{nodeId:i.id,field:y.key,value:y.value,stored:y.stored})})]},y.key))});if(!u.title)return(0,f.jsx)("div",{children:s},o);let w=`graview-field-group-${i.id}-${o}`;return(0,f.jsxs)("div",{role:"group","aria-labelledby":w,style:{display:"grid",gap:6,minWidth:0},children:[(0,f.jsx)("p",{id:w,"data-graview-field-group":u.title,style:Gt,children:u.title}),s]},o)})})}var gt={color:"var(--graview-ink-faint)",fontSize:"0.8125rem"},Gt={margin:0,fontSize:"0.75rem",letterSpacing:"0.06em",textTransform:"uppercase",color:"var(--graview-ink-muted)",fontWeight:560};function It(e){return Xe()?(0,f.jsx)(Ot,{...e}):(0,f.jsx)(Ht,{...e})}function Ht({field:e,label:t,value:a,labelStyle:n,valueStyle:r,style:d}){return(0,f.jsxs)("div",{"data-graview-long":e,style:{display:"grid",gap:6,minWidth:0,...d},children:[(0,f.jsx)("dt",{style:n,children:t}),(0,f.jsx)("dd",{style:{margin:0,minWidth:0,...r},children:(0,f.jsx)("div",{"data-graview-field":e,children:(0,f.jsx)(re,{text:a})})})]})}function Ot({nodeId:e,field:t,label:a,value:n,labelStyle:r,valueStyle:d,style:i}){let{fields:c,commit:p}=ue(e),u=c.find(k=>k.field===t&&k.takesValue),[o,s]=(0,P.useState)(!1),w=(0,P.useRef)(null),y=(0,P.useRef)(!1);(0,P.useEffect)(()=>{!o&&y.current&&(y.current=!1,w.current?.focus())},[o]);let v=k=>{y.current=k,s(!1)},S=a.toLowerCase(),b=(0,f.jsx)(re,{text:n});return(0,f.jsxs)("div",{"data-graview-long":t,style:{display:"grid",gap:6,minWidth:0,...i},children:[(0,f.jsxs)("dt",{style:{display:"flex",alignItems:"baseline",gap:10,...r},children:[(0,f.jsx)("span",{children:a}),u&&!o?(0,f.jsx)("button",{ref:w,type:"button","data-graview-editable":u.mutation,"aria-label":`Edit the ${S}`,title:`${u.title} \u2014 changes the ${S}, and can be undone`,onClick:()=>s(!0),style:Ft,children:"Edit"}):null]}),(0,f.jsx)("dd",{style:{margin:0,minWidth:0,...d},children:o&&u?(0,f.jsx)(P.Suspense,{fallback:b,children:(0,f.jsx)(zt,{field:t,label:a,value:n,onCancel:()=>v(!0),onSave:(k,R)=>{v(!R),k!==n&&p(u,k)}})}):(0,f.jsx)("div",{"data-graview-field":t,...u?{}:{"data-graview-readonly":"",title:`Read-only \u2014 nothing this app declares changes the ${S}`},...u?{onClick:()=>s(!0)}:{},style:{cursor:u?"text":"default",minWidth:0},children:b})})]})}var zt=(0,P.lazy)(()=>import("./chunk.4HGBVU5B.js")),Ft={all:"unset",cursor:"pointer",fontSize:"0.75rem",letterSpacing:"normal",textTransform:"none",color:"var(--graview-accent)",borderBottom:"1px dashed currentColor",minHeight:24,minWidth:24,display:"inline-flex",alignItems:"flex-end"};function ft({nodeId:e,children:t}){let{fields:a}=ue(e),n=me(e);if(!n)return(0,f.jsx)(f.Fragment,{children:t});let r=a.find(d=>{let i=n[d.field];return typeof i=="string"&&i===t});return r?(0,f.jsx)(mt,{nodeId:e,field:r.field,value:t}):(0,f.jsx)(f.Fragment,{children:t})}var ht=A(te(),1),oe=(0,ht.createContext)(null);var g=A(D(),1),Kt=Ze(Ge(()=>import("./chunk.2AJMM7JG.js"))).part((e,t)=>(0,g.jsx)(e.ArrangeBar,{...t}),{what:"Arranging this list"});function ve(e){let{brand:t}=N();return ee(e,t?.accents)}function _t(e,t){if(!t.endsWith("\u2026")&&!t.endsWith("..."))return;let a=t.replace(/[…]|\.\.\.$/g,"").trim();if(!(a.length<12)){for(let n of Object.values(e))if(typeof n=="string"&&n.length>a.length&&n.startsWith(a))return n}}function jt(e,t){let n=Math.max(0,...e.slice(0,t*2).map(d=>d.length))*7.5+28<=212/2?2:1,r=t*n;return{columns:n,shown:Math.min(e.length,r)}}var Ut=8,wt=500,qt=12;function vt(e){return{x:e.clientX,y:e.clientY,pointerType:e.pointerType??""}}function Xt(e,t,a){let n=performance.now()+wt,r=["pointerdown","pointerup","mousedown","mouseup","dblclick"],d=s=>{if(performance.now()>n||!(s instanceof MouseEvent))return!1;let w=vt(s);return t.pointerType&&w.pointerType&&t.pointerType!==w.pointerType?!1:Math.hypot(w.x-t.x,w.y-t.y)<=qt},i=s=>{if(!d(s))return u();s.stopPropagation()},c=s=>{if(!d(s))return u();s.stopPropagation(),s.preventDefault(),e.removeEventListener("click",c,!0),setTimeout(u,50),a()},p=!1,u=()=>{if(!p){p=!0,clearTimeout(o),e.removeEventListener("click",c,!0);for(let s of r)e.removeEventListener(s,i,!0)}};for(let s of r)e.addEventListener(s,i,!0);e.addEventListener("click",c,!0);let o=setTimeout(u,wt)}function Yt({View:e,members:t,mode:a,flagged:n}){let{isSelected:r}=ye(),d=t.slice(0,Ut);return(0,g.jsxs)("div",{"data-graview-rows":"",style:{display:"grid",gap:4,minWidth:0},children:[d.map(i=>(0,g.jsx)("div",{"data-graview-pick":i.id,style:{minWidth:0,cursor:"pointer"},children:(0,g.jsx)(e,{node:i,cardinality:"one",fidelity:"glyph",mode:a,selected:r(i.id),...n?.includes(i.id)?{flagged:[i.id]}:{}})},i.id)),t.length>d.length?(0,g.jsx)(j,{label:`+${t.length-d.length} more`}):null]})}var Jt=11/15;function Qt({text:e,accent:t}){let a=(0,M.useRef)(null),n=(0,M.useRef)(null),[r,d]=(0,M.useState)(1),[i,c]=(0,M.useState)(!1),p=r<1?`${r}em`:void 0;return(0,M.useLayoutEffect)(()=>{let u=a.current,o=n.current;if(!u||!o)return;let s=()=>{let y=u.clientWidth,v=o.offsetWidth;if(y<=0||v<=0)return;let S=parseFloat(getComputedStyle(o).fontSize)/parseFloat(getComputedStyle(u).fontSize)||1,b=v/S,k=Math.max(Jt,Math.min(1,Math.floor(y/b*100)/100));d(R=>Math.abs(R-k)<.01?R:k),c(b*k>y+.5)};if(s(),typeof ResizeObserver>"u")return;let w=new ResizeObserver(s);return w.observe(u),()=>w.disconnect()},[e]),(0,g.jsx)("span",{ref:a,"data-graview-district-name":"",...r<1?{"data-graview-fitted":""}:{},...i?{title:e}:{},style:{display:"block",minWidth:0,fontSize:"0.9375rem",lineHeight:1.25,letterSpacing:"0.05em",textTransform:"uppercase",color:t?"var(--graview-accent)":"var(--graview-ink-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:(0,g.jsx)("span",{ref:n,style:{fontSize:p},children:e})})}function Zt(e,t){return!!e?.display?.page?.groups?.length||Z(t,e).some(a=>a.long)}function St(e,t=de(e)){for(let a of e.kinds){let n=e.tryDefinition(a),r=n?.plural??`${String(a)}s`,d=o=>{let s=o.node,w=Qe(),y=(0,M.useContext)(oe);if(!s)return null;let v=y?.nodeId===s.id?y:null,S=T(n,s),b=o.mode==="fullscreen"?_t(s,S)??S:S,k=We(w,[s.id]);return(0,g.jsxs)(J,{title:(0,g.jsx)(ft,{nodeId:s.id,children:v?.title??b}),...v?{}:{subtitle:n?.describe?Ve(n,s):n?.description??String(a)},selected:o.selected,...o.flagged?.includes(s.id)?{tone:"warning"}:{},fit:!0,children:[v?(0,g.jsx)(oe.Provider,{value:null,children:v.body}):null,(0,g.jsxs)("div",{style:{display:"grid",gridTemplateColumns:Zt(n,s)?"minmax(0, 1fr)":"minmax(200px, 1fr) minmax(220px, 1.4fr)",gap:"22px 34px",alignItems:"start"},children:[(0,g.jsx)(yt,{id:s.id,shown:[b,S,n?.description,v?.title],...v?{hide:[...v.fields]}:{}}),(0,g.jsx)(ct,{id:s.id,empty:`Nothing is connected to this ${Y(n,String(a))} yet.`,...v?{hide:v.records}:{}})]}),k.length>0?(0,g.jsx)("p",{"data-graview-broken":"",style:{margin:"14px 0 0",paddingTop:12,borderTop:"1px solid var(--graview-edge)",fontSize:"0.875rem",color:"var(--graview-warn)"},children:k.map(R=>R.message).join(" \xB7 ")}):null]})},i=o=>{let s=o.node;if(!s)return null;let{store:w}=N(),y=n?.computed?rt(w.schema,w.graph,s):s,v=Z(y,n,{limit:3,said:[T(n,s)],glance:!0}),S=ve(a);return(0,g.jsx)(J,{title:T(n,s),selected:o.selected,tone:o.flagged?.includes(s.id)?"warning":"muted",fit:!0,children:(0,g.jsx)(tt,{items:v.map(b=>({id:b.key,label:b.alone,hue:S})),max:3})})},c=o=>{let s=o.node,w=ve(a),y=he().marks.flag;if(!s)return null;let v=o.flagged?.includes(s.id)??!1;return(0,g.jsx)(j,{label:v?`${T(n,s)} ${y}`:T(n,s),hue:w,selected:o.selected,title:v?`${I(Y(n,String(a)))} \u2014 implicated in a problem`:I(Y(n,String(a)))})},p=o=>{let{brand:s,store:w,views:y}=N(),{view:v,go:S}=fe(),b=o.nodes??[],k=y.lookup(String(a),{cardinality:"one",fidelity:"glyph"}),R=k!==void 0&&!Ye(k)?k:void 0,$=lt(v),h=at(b,$,{schema:e,graph:w.graph,flagged:new Set(o.flagged??[])}),L=C=>({id:C.id,label:T(e.tryDefinition(C.kind),C),hue:ee(C.kind,s?.accents)}),U=o.fidelity==="full"&&b.length>1?(0,g.jsx)(M.Suspense,{fallback:null,children:(0,g.jsx)(Kt,{schema:e,graph:w.graph,kind:String(a),arrangement:$,onChange:C=>S(dt(v,C)),kept:{shown:h.nodes.length,of:b.length},style:{marginBottom:8}})}):null,B=C=>C.some(E=>o.flagged?.includes(E.id)),O=(C,E,q)=>R?(0,g.jsx)(J,{title:C,meta:B(E)?`\u26A0 ${E.length}`:E.length,tone:B(E)?"warning":"muted",children:(0,g.jsx)(Yt,{View:R,members:E,mode:o.mode,...o.flagged?{flagged:o.flagged}:{}})},q):(0,g.jsx)(nt,{label:C,count:E.length,flagged:B(E),items:E.map(L)},q);return h.grouped?(0,g.jsxs)("div",{style:{display:"grid",gap:8},"data-graview-grouped":$.group?.by,children:[U,h.groups.map(C=>O(`${o.label??r} \xB7 ${C.label}`,C.nodes,C.key||"-"))]}):(0,g.jsxs)("div",{style:{display:"grid",gap:4},children:[U,O(o.label??r,h.nodes)]})},u=o=>{let s=o.nodes??[],w=jt(s.map(m=>T(n,m)),o.openedRows??je(s.length)),y=ve(a),{brand:v}=N(),S=et(String(a),e,v),b=he().marks.flag,{selection:k}=ye(),{toggle:R,view:$,go:h}=fe(),{views:L,hiddenKinds:U}=N(),B=$.overview&&!U.has(String(a))?L.places().filter(m=>m.kind===String(a)):[],O=ot(),C=o.focused?$.within?.view??B[0]?.as:void 0,E=s.filter(m=>o.flagged?.includes(m.id)).length,q=E>0,z=o.focused||o.raised,$e=o.rank==="secondary"&&!z,V=o.nestedUnder!==void 0,Ae=new Set(k),At=st(),F=z?0:s.filter(m=>At.includes(m.id)&&!Ae.has(m.id)).length,pe=F>0&&!q,se=qe(),X=se&&!V?se.byKind[String(a)]??0:0,Tt=V?8:Math.min(46,10+Math.round(Math.sqrt(s.length)*8)),Te=V?(0,g.jsx)("span",{style:{fontSize:"0.75rem",lineHeight:1.25,letterSpacing:"0.05em",textTransform:"uppercase",color:z?"var(--graview-accent)":"var(--graview-ink-muted)",whiteSpace:"nowrap",overflow:"hidden",textOverflow:"ellipsis"},children:o.label??r}):(0,g.jsx)(Qt,{text:o.label??r,accent:!!z});return(0,g.jsxs)("div",{className:"graview-kind-card","data-graview-rank":o.rank,"data-graview-landmark":S||void 0,"data-graview-nested":V||void 0,"data-graview-tied":F||void 0,"data-graview-hits":se&&!V?X:void 0,"data-graview-emphasis":se&&!V?X>0?"lit":"dimmed":void 0,...n?.description||V?{title:V?[o.label??r,n?.description].filter(Boolean).join(" \u2014 "):n.description}:{},style:{position:"relative",height:"100%","--graview-hue":Math.round(y),"--graview-marquee-room":B.length>0&&O?`${O(B.map(m=>m.title))+(S?4:42)}px`:"0px"},children:[S?(0,g.jsx)("span",{className:"graview-kind-block graview-kind-landmark","data-graview-opened":o.opened||void 0,"aria-hidden":"true",style:{"--graview-rise":Tt},children:(0,g.jsx)(ne,{kind:String(a),schema:e,...v?{brand:v}:{},size:96})}):null,(0,g.jsxs)("div",{className:"graview-kind-face","data-graview-opened":o.opened||void 0,style:{display:"flex",flexDirection:"column",gap:V?1:3,padding:V?"5px 7px":"7px 10px",borderRadius:"var(--graview-radius-sm, 9px)",justifyContent:"center",position:"relative",height:"100%",overflow:"hidden",boxSizing:"border-box",border:z?"1px solid var(--graview-accent)":F>0?"1px solid var(--graview-accent-dim)":`1px solid hsl(${Math.round(y)} 55% var(--graview-tint-lightness) / 0.34)`,backgroundColor:"var(--graview-panel)",backgroundImage:`linear-gradient(hsl(${Math.round(y)} 55% var(--graview-tint-lightness) / calc(var(--graview-tint-alpha) * ${z?1.1:$e?.28:.5})), hsl(${Math.round(y)} 55% var(--graview-tint-lightness) / calc(var(--graview-tint-alpha) * ${z?1.1:$e?.28:.5})))`,boxShadow:z?"0 0 0 1px var(--graview-accent-dim)":void 0},children:[!V&&s.length>0?(0,g.jsx)("div",{"data-graview-tally":s.length,"data-graview-broken":E||void 0,"aria-hidden":"true",style:{position:"absolute",left:0,right:0,top:0,display:"flex",height:3,background:`hsl(${Math.round(y)} 55% var(--graview-tint-lightness) / 0.4)`},children:E>0?(0,g.jsx)("span",{style:{width:`${Math.max(6,Math.round(E/s.length*100))}%`,background:"var(--graview-warn)"}}):null}):null,S?(0,g.jsxs)("div",{style:{display:"flex",alignItems:"flex-start",gap:V?4:6},children:[(0,g.jsx)(ne,{kind:String(a),schema:e,...v?{brand:v}:{},size:V?14:18}),Te]}):Te,(0,g.jsxs)("div",{style:{display:"flex",alignItems:"center",gap:5,fontSize:"0.875rem"},children:[(0,g.jsx)("span",{style:{fontVariantNumeric:"tabular-nums",color:q?"var(--graview-warn)":pe?"var(--graview-accent)":"var(--graview-ink-faint)"},children:s.length===0?"none yet":pe?F===s.length?`${F} tied`:`${F} of ${s.length} tied`:`${q?`${b} `:""}${s.length}`}),(o.retired??0)>0?(0,g.jsxs)("button",{type:"button",className:"graview-kind-past","data-graview-retired":o.retired,title:`${o.retired} retired ${r.toLowerCase()} \u2014 press to widen the view to the past`,onClick:m=>{m.stopPropagation(),h(ze($,!0))},onDoubleClick:m=>m.stopPropagation(),onPointerDown:m=>m.stopPropagation(),children:["+",o.retired," past"]}):null,X>0?(0,g.jsxs)("button",{type:"button",className:"graview-kind-hits","data-testid":`hits-${String(a)}`,title:`${X} ${X===1?"match":"matches"} for \u201C${$.q??""}\u201D \u2014 press to go in, narrowed`,onClick:m=>{m.stopPropagation(),h(Ke($,ge(String(a)),{ownPicture:!0,...$.q?{carry:$.q}:{}}))},onDoubleClick:m=>m.stopPropagation(),onPointerDown:m=>m.stopPropagation(),children:[X," match"]}):null,F>0&&!pe?(0,g.jsxs)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-accent)"},children:[F," tied"]}):null,o.hasOwnView?(0,g.jsx)("span",{title:`${r} has a view of its own`,"aria-label":"has its own view",style:{fontSize:"0.6875rem",color:"var(--graview-accent)"},children:"\u25C6"}):null,!V&&s.length>0&&!o.focused?(0,g.jsxs)("button",{type:"button",className:"graview-kind-open","data-testid":`open-${String(a)}`,"aria-expanded":o.opened??!1,title:o.opened?"Close it up":`See the ${r} in here`,onClick:m=>{m.stopPropagation(),R(ge(String(a)))},onDoubleClick:m=>m.stopPropagation(),onPointerDown:m=>m.stopPropagation(),children:[(0,g.jsx)("span",{className:"graview-kind-open-word",children:o.opened?"close":"open"})," ",o.opened?"\u25B4":"\u25BE"]}):null]}),o.opened?(0,g.jsxs)("div",{className:"graview-kind-members","data-graview-buildings":o.plot?.side??1,style:{display:"grid",gridTemplateColumns:`repeat(${w.columns}, minmax(0, 1fr))`,gap:3},children:[s.slice(0,w.shown).map(m=>{let K=o.flagged?.includes(m.id)??!1,G=T(n,m);return(0,g.jsx)(j,{pickId:m.id,label:K?`${G} ${b}`:G,title:K?`${G} \u2014 implicated in a problem`:void 0,hue:y,selected:Ae.has(m.id)},m.id)}),s.length>w.shown?(0,g.jsxs)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",padding:"2px 4px",gridColumn:"1 / -1"},children:["+",s.length-w.shown," more \u2014 double-click to go in"]}):null]}):null]}),!V&&B.length>0?(0,g.jsx)("div",{className:"graview-drive-in","data-testid":`drive-in-${String(a)}`,"data-graview-showing":C,onPointerDown:m=>m.stopPropagation(),onDoubleClick:m=>m.stopPropagation(),children:(0,g.jsx)("div",{className:"graview-drive-in-marquee",role:"group","aria-label":`${r}: pictures`,"data-graview-thumbs":B.length===1?"one":"two",children:B.map(m=>{let K=C===m.as;return(0,g.jsxs)("div",{className:"graview-drive-in-thumb","data-graview-pressed":K||void 0,children:[(0,g.jsx)("span",{className:"graview-drive-in-thumb-title","aria-hidden":"true",children:m.title}),(0,g.jsx)("button",{type:"button",className:"graview-drive-in-thumb-press","data-testid":`showing-${m.as}`,"aria-label":`${r}: ${m.title}`,"aria-pressed":K,title:K?`${m.title} is showing \u2014 press again to open it`:`Show ${m.title} on the billboard \u2014 double-click to open it`,onClick:G=>{G.stopPropagation();let Ee=()=>h(_e($,String(a),m.as));if(G.detail>=2||K&&o.focused){Ee();return}h(He(Ie(Oe($,!0),Fe(String(a))),"view",m.as)),G.detail===1&&Xt(G.currentTarget.ownerDocument,vt(G.nativeEvent),Ee)}})]},m.as)})})}):null]})};p.generic=!0,u.generic=!0,t.register(a,{cardinality:"one",fidelity:"full"},_(d)).register(a,{cardinality:"one",fidelity:"summary"},_(i)).register(a,{cardinality:"one",fidelity:"glyph"},_(c)).register(a,{cardinality:"many",fidelity:"full"},_(p)).register(a,{cardinality:"many",fidelity:"summary"},_(p)).register(a,{cardinality:"many",fidelity:"glyph"},_(u))}return t}var x=A(te(),1);var Se=A(te(),1);var be=A(D(),1),kt=new WeakMap;function en(e){let t=kt.get(e);return t||kt.set(e,t=St(e,de(e))),t}var ke=Je;function bt(){return(0,Se.useContext)(ke)}function Kn({children:e}){return(0,be.jsx)(ke.Provider,{value:!0,children:e})}function xt(e){let t=(0,Se.useContext)(ke),{store:a}=N();if(t)return null;let n=e.kind??e.node?.kind??e.nodes?.[0]?.kind;if(!n)return null;let r=en(a.schema).lookup(n,{cardinality:e.cardinality,fidelity:e.fidelity});return r?(0,be.jsx)(r,{...e}):null}var l=A(D(),1),Nt=(0,x.createContext)(null),tn=(e,t)=>e.trim().toLowerCase().replace(/[_-]+/g," ")===t.trim().toLowerCase().replace(/[_-]+/g," "),nn=(0,x.createContext)(null),Re=(0,x.createContext)(null);function an({block:e}){let t=(0,x.useContext)(Re),a=t?.slots?.[e.key],n=(0,l.jsx)(rn,{block:e});return a?(0,l.jsx)(x.Suspense,{fallback:n,children:(0,l.jsx)(a,{block:e,node:t.node,drawn:n})}):n}function rn({block:e}){let t=(0,x.useContext)(Nt),a=(0,x.useContext)(ln),n=(0,x.useContext)(Ne);if(t&&e.t==="badge"&&t.values.some(r=>tn(r,e.text))||t&&e.t==="field"&&t.field!==void 0&&e.field===t.field)return null;switch(e.t){case"title":return(0,l.jsx)("strong",{className:"graview-spec-title",children:e.text});case"text":return we(e.text)?(0,l.jsx)("div",{className:"graview-spec-text",...e.tone?{"data-graview-tone":e.tone}:{},children:(0,l.jsx)(re,{text:e.text})}):(0,l.jsx)("p",{className:"graview-spec-text",...e.tone?{"data-graview-tone":e.tone}:{},children:e.text});case"badge":return(0,l.jsx)("span",{className:"graview-spec-badge","data-graview-tone":e.tone,children:e.text});case"field":return(0,l.jsxs)("span",{className:"graview-spec-field","data-graview-field":e.field,children:[(0,l.jsx)("span",{className:"graview-spec-label",children:e.label}),(0,l.jsx)("span",{className:"graview-spec-value",...we(e.text)?{style:{whiteSpace:"pre-line"}}:{},children:e.href?(0,l.jsx)("a",{className:"graview-spec-link",href:e.href,rel:"noopener noreferrer",target:"_blank",children:e.text}):e.text})]});case"progress":return e.value===void 0||e.max===void 0?(0,l.jsxs)("span",{className:"graview-spec-progress",children:[(0,l.jsx)("span",{className:"graview-spec-label",children:e.label}),(0,l.jsx)("span",{className:"graview-spec-value",children:e.text})]}):(0,l.jsxs)("span",{className:"graview-spec-progress",children:[(0,l.jsx)("span",{className:"graview-spec-label",children:e.label}),(0,l.jsx)("span",{className:"graview-spec-track",role:"progressbar","aria-label":e.label,"aria-valuemin":0,"aria-valuemax":e.max,"aria-valuenow":Math.max(0,Math.min(e.value,e.max)),"aria-valuetext":e.text,children:(0,l.jsx)("span",{className:"graview-spec-fill",style:{width:`${Math.round(Math.max(0,Math.min(e.value,e.max))/e.max*100)}%`}})}),(0,l.jsx)("span",{className:"graview-spec-value",children:e.text})]});case"group":return(0,l.jsx)("span",{className:"graview-spec-group","data-direction":e.direction,children:(0,l.jsx)(xe,{blocks:e.blocks})});case"when":return e.shown?(0,l.jsx)(xe,{blocks:e.blocks}):null;case"divider":return(0,l.jsx)("hr",{className:"graview-spec-divider"});case"figure":return(0,l.jsx)(on,{});case"headline":{let r=`h${Math.min(6,e.level+a)}`,d=(0,l.jsx)(r,{className:"graview-spec-headline","data-level":e.level,children:e.text});return n!==null&&e.level===1?(0,l.jsxs)(l.Fragment,{children:[d,n]}):d}case"number":return(0,l.jsxs)("span",{className:"graview-spec-number",children:[(0,l.jsx)("span",{className:"graview-spec-number-value",children:e.text}),e.label?(0,l.jsx)("span",{className:"graview-spec-label",children:e.label}):null]});case"list":return(0,l.jsx)(cn,{list:e})}}function on(){let e=(0,x.useContext)(Re)?.figure;return e?(0,l.jsx)("span",{className:"graview-spec-figure","aria-hidden":"true",children:e()}):null}function xe({blocks:e}){return e.map((t,a)=>(0,l.jsx)(an,{block:t},a))}function Rt({blocks:e,ctx:t,view:a}){let n=(0,x.useContext)(nn)?.[a];return(0,l.jsx)(Re.Provider,{value:{figure:t.figure,slots:n,node:t.node},children:(0,l.jsx)(xe,{blocks:e})})}function Ce({blocks:e,ctx:t,view:a}){return(0,l.jsx)(Rt,{blocks:Q(e,t),ctx:t,view:a})}var Ct=3,Pt=(0,x.createContext)(0),sn=(0,x.createContext)(null),ln=(0,x.createContext)(0),Ne=(0,x.createContext)(null);function dn({node:e,as:t,depth:a,said:n=null}){let{store:r,views:d}=N(),i=T(r.schema.tryDefinition(e.kind),e),c=d.lookup(e.kind,{cardinality:"one",fidelity:t==="card"?"summary":"glyph"});return(0,l.jsxs)("li",{className:"graview-spec-item","data-graview-listed":e.id,"data-as":t,children:[a<=Ct&&c?(0,l.jsx)(Ue,{mode:"scene",children:(0,l.jsx)(Pt.Provider,{value:a,children:(0,l.jsx)(Nt.Provider,{value:n,children:(0,l.jsx)(c,{node:e,cardinality:"one",fidelity:t==="card"?"summary":"glyph",mode:"scene",selected:!1})})})}):(0,l.jsx)("span",{className:"graview-spec-item-name",children:i}),(0,l.jsx)($t,{node:e,label:i})]})}function $t({node:e,label:t}){let a=(0,x.useContext)(sn);return a?(0,l.jsx)("a",{className:"graview-spec-item-link",href:a.href(e),"aria-label":t,onClick:n=>{n.metaKey||n.ctrlKey||n.shiftKey||n.button!==0||(n.preventDefault(),n.stopPropagation(),a.go(e))}}):(0,l.jsx)("button",{type:"button",className:"graview-spec-item-link","data-graview-pick":e.id,"aria-label":t})}function cn({list:e}){let t=(0,x.useContext)(Pt)+1,{store:a}=N();if(e.failed)return(0,l.jsx)("p",{className:"graview-spec-text",children:"\u2014"});if(e.members.length===0)return e.empty?(0,l.jsx)("p",{className:"graview-spec-text graview-spec-empty",children:e.empty}):null;let n=(i,c=null)=>t>Ct?(0,l.jsx)("ul",{className:"graview-spec-list","data-as":"names",children:i.map(p=>(0,l.jsxs)("li",{className:"graview-spec-item","data-graview-listed":p.id,"data-as":"name",children:[(0,l.jsx)("span",{className:"graview-spec-item-name",children:T(a.schema.tryDefinition(p.kind),p)}),(0,l.jsx)($t,{node:p,label:T(a.schema.tryDefinition(p.kind),p)})]},p.id))}):(0,l.jsx)("ul",{className:"graview-spec-list","data-as":e.as,children:i.map(p=>(0,l.jsx)(dn,{node:p,as:e.as,depth:t,said:c},p.id))}),r=e.more>0?(0,l.jsx)("p",{className:"graview-spec-text graview-spec-more",children:`and ${e.more} more`}):null;if(!e.groups)return(0,l.jsxs)("div",{className:"graview-spec-listing",children:[n(e.members),r]});let d=`h${e.headingLevel}`;return(0,l.jsxs)("div",{className:"graview-spec-listing",children:[e.groups.map(i=>(0,l.jsxs)("section",{className:"graview-spec-list-group","data-graview-group":i.value??"",children:[i.heading?(0,l.jsx)(d,{className:"graview-spec-list-heading",children:i.heading}):null,n(i.members,i.value!==null?{values:[i.value,...i.heading?[i.heading]:[]]}:null)]},i.value??"")),r]})}function na({blocks:e,heading:t=2,firstHeading:a,slot:n,view:r=n}){let{store:d,brand:i}=N();le();let c=ie(d,null,null,{heading:t,firstHeading:a,money:i}),p=(0,x.useContext)(Ne),u=e.some(o=>o.t==="headline");return(0,l.jsxs)("div",{className:`graview-spec graview-spec-${n}`,"data-graview-spec":n,children:[p!==null&&!u?p:null,(0,l.jsx)(Ne.Provider,{value:u?p:null,children:(0,l.jsx)(Ce,{blocks:e,ctx:c,view:r})})]})}function Pe(e,t="card"){let{store:a,brand:n}=N(),r=a.schema;return{...ie(a,null,e,{slot:t,money:n}),figure:()=>(0,l.jsx)(ne,{kind:e.kind,schema:r,...n?{brand:n}:{},size:22})}}function un({slot:e,blocks:t,node:a,selected:n}){let r=Pe(a,e);return(0,l.jsx)("div",{className:`graview-spec graview-spec-${e}`,"data-graview-spec":e,"data-graview-kind":a.kind,...e==="row"&&t.some(it)?{"data-graview-tall":""}:{},...n?{"data-selected":""}:{},children:(0,l.jsx)(Ce,{blocks:t,ctx:r,view:`${a.kind}.${e}`})})}function pn({blocks:e,node:t,selected:a,flagged:n}){let r=Pe(t),[d,...i]=e,c=d?.t==="title";return(0,l.jsx)(J,{...c?{title:Q([d],r)[0].text}:{},selected:a,tone:n?"warning":"muted",fit:!0,children:(0,l.jsx)("div",{className:"graview-spec graview-spec-card","data-graview-spec":"card","data-graview-kind":t.kind,children:(0,l.jsx)(Ce,{blocks:c?i:e,ctx:r,view:`${t.kind}.card`})})})}function gn({blocks:e,props:t}){let a=t.node,n=Pe(a,"page"),r=bt(),d=Q(e,n),i=ce(e,d),c=i.title!==void 0&&(!r||i.title===T(n.schema?.tryDefinition(a.kind),a)),p=(0,l.jsx)("div",{className:"graview-spec graview-spec-page","data-graview-spec":"page","data-graview-kind":a.kind,children:(0,l.jsx)(Rt,{blocks:c?d.slice(1):d,ctx:n,view:`${a.kind}.page`})});return r?p:(0,l.jsx)(oe.Provider,{value:{nodeId:a.id,...i.title!==void 0?{title:i.title}:{},body:p,fields:i.fields,records:i.records},children:(0,l.jsx)(xt,{...t})})}function aa(e,t,a){return typeof e=="function"?e.says?.(t,a):void 0}function mn({blocks:e,node:t,selected:a}){let{store:n}=N();return(0,l.jsx)("div",{title:T(n.schema.tryDefinition(t.kind),t),style:{minWidth:0,maxWidth:"100%"},children:(0,l.jsx)(un,{slot:"row",blocks:e,node:t,selected:a})})}function ia(e,t,a){if(!a)return e;let n=new Set(t.kinds);for(let[r,d]of Object.entries(a)){if(!n.has(r)||!d)continue;let i=r;if(d.card){let c=ae(d.card),p=u=>u.node?(0,l.jsx)(pn,{blocks:c,node:u.node,selected:u.selected,flagged:u.flagged?.includes(u.node.id)??!1}):null;e.register(i,{cardinality:"one",fidelity:"summary"},p)}if(d.row){let c=ae(d.row),p=u=>u.node?(0,l.jsx)(mn,{blocks:c,node:u.node,selected:u.selected}):null;p.says=(u,o)=>ce(c,Q(c,ie({graph:o,schema:t},null,u,{slot:"row"}))),e.register(i,{cardinality:"one",fidelity:"glyph"},p)}if(d.page){let c=ae(d.page),p=u=>u.node?(0,l.jsx)(gn,{blocks:c,props:u}):null;p.says=(u,o)=>ce(c,Q(c,ie({graph:o,schema:t},null,u))),e.register(i,{cardinality:"one",fidelity:"full"},p)}}return e}export{mt as a,It as b,St as c,Kn as d,Nt as e,sn as f,ln as g,Ne as h,$t as i,na as j,aa as k,ia as l};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{a as k}from"./chunk.G4JJXA63.js";import{a as Q}from"./chunk.42U4UBDE.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.WEGBBWWK.js";import"./chunk.6MCK7K3M.js";import{e as P}from"./chunk.54NSG7BX.js";import"./chunk.6KJSFIO7.js";import"./chunk.UM5IPM22.js";import{c as G}from"./chunk.6XBLDV4A.js";import"./chunk.WOTNMTIY.js";import{Gb as C,Hb as J,Ib as K,Jb as X,Tb as Y,ra as z,sa as H}from"./chunk.ZQ4HFIIS.js";import"./chunk.AJZBJBMO.js";var L=e=>"failed"in e;function ue(e,n){let r=e.schema.kinds,t=e.policy?.sees;if(!t?.length||H(n))return{kinds:r};let s=z(n).roles??[],i=new Set(t.filter(o=>o.roles==="*"||s.some(a=>o.roles.includes(a))).flatMap(o=>o.kinds));return{kinds:r.filter(o=>i.has(o))}}function O(e,n){if(!n)return e;let r=new Set(n.kinds.filter(i=>e.tryDefinition(i)!==void 0));if(r.size===e.kinds.length)return e;let t=new Map,s=i=>{if(r.has(i)){if(!t.has(i)){let o=e.tryDefinition(i),a=Object.fromEntries(Object.entries(o?.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(i,{...o,edges:a})}return t.get(i)}};return{...e,definitions:e.definitions.filter(i=>r.has(i.kind)),kinds:e.kinds.filter(i=>r.has(i)),tryDefinition:s,definition:i=>{let o=s(i);if(!o)throw new Error(`Unknown node kind "${i}"`);return o}}}var fe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),y=e=>fe(e).replace(/[-_]+/g," ").trim();function j(e){let n=[];for(let t of e.kinds){let s=e.tryDefinition(t);if(!s)continue;let i=s.display?.labels??{},o=Object.entries(s.fields?.shape??{}).filter(([d])=>d!=="id"&&d!=="kind").map(([d,c])=>{let u=P(c);return{name:d,type:u?.type,...u?.options?{options:u.options}:{},words:(i[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:o,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",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`]),i=-1;for(let o of s){let a=e.indexOf(` ${o} `);a>=0&&(i<0||a<i)&&(i=a)}i>=0&&r.push({info:t,at:i})}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(i=>!r||r(i));return s.find(i=>i.words===t||y(i.name)===t||i.name.toLowerCase()===t)??s.find(i=>i.words===v(t)||y(i.name)===v(t))??s.find(i=>t.split(" ").some(o=>o.length>2&&(i.words.split(" ").includes(o)||i.words.split(" ").includes(v(o)))))}function se(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(i=>{let o=r.info(i);return o!==void 0&&(o.noun===v(t)||o.plural===t||y(i)===v(t))}))??e.edges.find(s=>t.split(" ").some(i=>i.length>2&&s.words.split(" ").includes(i)))}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 ge=/\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/,me=/\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"),ge.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"),me.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 oe=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`}},_=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?$/,I=class extends Error{},h=e=>{throw new I(e)};function Se(e,n){let r=e.fields.filter(i=>i.type==="enum");if(n){let i=x(e,n);if(i&&i.type==="enum")return i;i&&h(`${e.plural}' ${i.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(i=>/^(status|stage|state|phase)$/.test(i.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},i=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(!i)return h(`no date field on ${e.plural}`);let o=t("end")??r.find(l=>l!==i&&/^(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:i,...o&&o!==i?{end:o}:{},...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 o of e.kinds)for(let a of o.edges)for(let l of a.to){let d=e.info(l);if(!d||d.kind===o.kind)continue;let c=0;n.includes(o)&&(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:o,across:d,link:a,score:c})}let i=s.sort((o,a)=>a.score-o.score)[0];return i||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 i=U(t);switch(e){case"columns":{if(i){let o=x(n,i);if(!o||o.type!=="enum"){let a=se(n,i,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,i).name}}case"calendar":{let o=ee(n,t),a=_(t);return{lens:"calendar",kind:n.kind,start:o.start.name,...o.end?{end:o.end.name}:{},...o.done?{done:o.done.name}:{},...a?{range:a}:{}}}case"timeline":{let o=ie(n);if(o&&!/\bdates?\b|\bdue\b|\bdeadlines?\b|\bmonths?\b|\byears?\b/.test(t))return{lens:"timeline",kind:n.kind,start:o.start.name,end:o.end.name,column:o.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:_(t)??"quarter"}}case"coverage":{let o=De(r,s,t,i);return{lens:"coverage",kind:o.rows.kind,across:o.across.kind,link:o.link.name}}case"board":{let o=$(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(o)||!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:o.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 o=$(n,n.roles.outline)??n.fields.find(a=>a.name==="outline");return o?{lens:"plan",kind:n.kind,outline:o.name}:h(`${n.plural} have no outline to draw a plan from`)}case"blocks":{let o={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]??(i&&!/ sort(?:ed)? by /.test(t)?i: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`);o.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`);o.sort={by:c.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}let d=M(n,t);return d.length>0&&(o.where=d),o}}}function M(e,n){let r=[],t=oe(n);if(t){let s=e.fields.filter(A),i=$(e,e.roles.start),o=s.find(l=>E(n,l.words))??(A(i)?i:void 0)??s[0];(!o||!A(o))&&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(o.name,/\boverdue\b|\blate\b|\bpast due\b/.test(n)?a?.name:void 0),says:t.says(o)})}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 i=s.options?.find(o=>E(n,o.toLowerCase())||E(n,y(o)));i&&r.push({expr:`${s.name} == '${i.replace(/'/g,"")}'`,says:`that are ${y(i)}`})}if(/\bnot done\b|\bundone\b|\bunfinished\b|\bopen ones\b|\bstill to do\b/.test(n)){let s=e.fields.find(i=>i.type==="boolean"&&/^(done|finished|complete|completed)$/.test(i.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 i=s==="years"?"year":s;return{title:`${k(r.plural)} by ${i}`,detail:`of ${r.plural} by ${t(e.start)}, a ${i} 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(i=>i.says).join(" and "),e.group?`by ${t(e.group)}`:void 0,e.sort?`in order of ${t(e.sort.by)}`:void 0].filter(i=>!!i);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(i=>e.where.length>1?`(${i.expr})`:i.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 q(e,n){let r=s=>s.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,""),t=new Set(["home","overview",...Y(n).map(s=>s.slug),...(n.lenses??[]).flatMap(s=>s.title?[r(s.title)]:[])]);if(!t.has(r(e)))return e;for(let s=2;;s++)if(!t.has(r(`${e} ${s}`)))return`${e} ${s}`}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=(o,a)=>{if(typeof o!="string"||o.trim()==="")return`its ${a} says nothing`;try{return G(o)}catch(l){return`its ${a} does not read: ${l instanceof Error?l.message.replace(/ \(at character.*$/,""):String(l)}`}},t=o=>{if(o.t==="where")return t(o.set);if(o.t==="call"&&o.fn==="all"){let a=o.args[0];return a?.t==="lit"&&typeof a.value=="string"?e.info(a.value)??null:void 0}},s=(o,a)=>{switch(o.t){case"lit":return;case"ident":return a&&!a.fields.some(l=>l.name===o.name)&&!a.edges.some(l=>l.name===o.name)?`${a.plural} have nothing called ${o.name}`:void 0;case"member":return s(o.object,a);case"list":return o.items.map(l=>s(l,a)).find(Boolean);case"unary":return s(o.operand,a);case"binary":return s(o.left,a)??s(o.right,a);case"where":{let l=t(o.set);return l===null?"Nothing by that name here":s(o.set,a)??s(o.filter,l??void 0)}case"call":return o.fn==="all"?t(o)===null?"Nothing by that name here":void 0:o.args.map(l=>s(l,a)).find(Boolean)}},i=(o,a)=>{if(a>4)return"its blocks nest deeper than a place draws";for(let l of o){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 m=s(p,void 0);if(m)return m;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 g of["group","sort"]){let b=l[g],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 ${g} by`;if(g==="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 g=i(f,a+1);if(g)return g}}else if(d==="group"){if(!Array.isArray(u))return"a group block holds a list of blocks";let p=i(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 m=p[1].split(/\|(?![|])/)[0],f=r(m,`${d}'s braces`);if(typeof f=="string")return f;let g=s(f,void 0);if(g)return g}}}};return i(n,1)}function T(e,n,r){let t=O(e.schema,r),s=f=>({ok:!1,failed:`Couldn't draw that: ${f.replace(/\.$/,"")}.`});if(!K(n.name)||n.name==="reach")return s(`"${String(n.name)}" is not a picture the seat can draw; it draws ${J.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 i=C[n.name],o=n.bindings??{};if(i.binds==="fields")for(let[f,g]of Object.entries(o)){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(g??{}))if(typeof D!="string"||!b.includes(D))return s(`${y(f)} has no field "${String(D)}" for its ${S}`);for(let S of i.requiredRoles)if(!(S in(g??{})))return s(`a ${n.name} needs ${y(f)}'s ${S}`)}else if(i.binds==="entities")for(let f of i.requiredRoles){let g=o[f];if(!g)return s(`a ${n.name} needs its ${f}`);if(typeof g.kind=="string"&&!t.tryDefinition(g.kind))return s("Nothing by that name here")}let a={...e,schema:t,lenses:[...e.lenses??[],n]},l=a.lenses.length-1,d=X(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 m=d.drawn.find(f=>f.index===l);if(!m)return s("its bindings name something the app does not have");if(m.as==="overview")return s(`"${n.title}" is the scene's own address; give it another title`);if(n.name==="blocks"){let f=Ee(j(t),n.options?.blocks);if(f)return s(f)}return{ok:!0,drawn:m}}function F(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)&&C[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,i=w(e.bindings?.link)?r(e.bindings.link.edge):void 0;return s&&i?{lens:"coverage",kind:e.on,across:s,link:i}:void 0}case"blocks":{let s=e.options?.blocks;if(!Array.isArray(s)||s.length!==1||!w(s[0]))return;let i=s[0],o=new RegExp(`^all\\('${e.on}'\\)(?: where (.+))?$`).exec(String(i.list??""));if(!o)return;let a=i.sort;return{lens:"blocks",kind:e.on,as:i.as==="card"?"card":"row",...typeof i.group=="string"?{group:i.group}:{},...typeof a=="string"?{sort:{by:a}}:w(a)&&typeof a.by=="string"?{sort:{by:a.by,...a.direction==="desc"?{direction:"desc"}:{}}}:{},...o[1]?{where:[{expr:o[1],says:"as asked"}]}:{}}}default:return}}function V(e,n,r,t,s){let i=j(O(e.schema,t)).info(n.on),o=xe(n);return{title:n.title,said:`${B[n.name]??"A picture"} of ${i?.plural??y(n.on)}.`,kind:n.on,lens:n,drawn:r,edit:F(n),by:s,asks:[],...o?{recipe:o}:{}}}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 W(e,n,r,t,s){let i=Re(e,n),o=e.title??s??q(i.title,r.app),a=Ae(e,o),l=T(r.app,a,r.sight);return l.ok?{title:o,said:`${B[e.lens]} ${i.detail}.`,kind:e.kind,lens:a,drawn:l.drawn,edit:F(a),by:"template",asks:t,recipe:e}:{failed:l.failed,...r.lastGood?{lastGood:r.lastGood}:{}}}function Le(e,n,r,t){if(r.length>0)return r;let s=o=>{switch(e){case"columns":return o.fields.some(a=>a.type==="enum");case"calendar":return o.fields.some(A);case"timeline":return ie(o)!==void 0||o.fields.some(A);case"coverage":return o.edges.some(a=>a.to.some(l=>l!==o.kind));case"board":return o.fields.some(a=>a.name==="x")&&o.fields.some(a=>a.name==="y");case"plan":return o.fields.some(a=>a.name==="outline")||o.roles.outline!==void 0;default:return!0}};return[...n.kinds.filter(s)].sort((o,a)=>Number(a.fields.some(l=>E(t,l.words)))-Number(o.fields.some(l=>E(t,l.words))))}function Ie(e,n){let r=j(O(n.app.schema,n.sight)),t=re(e),s=$e(t);if(s.length===0)return;let i=pe(t,r),o;for(let a of s){let l=a==="coverage"?[i[0]??r.kinds[0]].filter(d=>!!d):Le(a,r,i,t);for(let d of l)try{let c=ae(a,d,r,t,i),u=W(c,r,n,[e]);if(!L(u))return u;o??=u.failed}catch(c){if(!(c instanceof I))throw c;o??=`Couldn't draw that: ${c.message}.`}l.length===0&&i.length===0&&(o??=`Couldn't draw that: nothing here has what ${B[a].toLowerCase()} needs.`)}return{failed:o??"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&&!L(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 L(s)&&t?t:s}async function je(e,n,r){let t={lastGood:e},s={...r,lastGood:e},i=j(O(r.app.schema,r.sight)),o=re(n),a=i.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(o)??/ (?:call|name) it (.+?) $/.exec(o);try{if(c){let m=n.replace(/^.*?\b(?:call|name|title)\b\s*(?:it|this)?\s*/i,"").replace(/^["“']|["”']$/g,"").trim();if(m.length===0)return{failed:"Couldn't change that: say what to call it.",...t};let f={...e.lens,title:q(m,r.app)},g=T(r.app,f,r.sight);return g.ok?{...e,title:f.title,lens:f,drawn:g.drawn,edit:F(f),asks:l,...d?{recipe:{...d,title:f.title}}:{}}:{failed:g.failed,...t}}let p=/ as (?:a |an )?(board|kanban|calendar|timeline|list|table|cards|rows|grid|plan|layout)\b/.exec(o);if(p){let m=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(m,a,i,o,[a]),g=p[1]==="cards"?"card":p[1]==="rows"?"row":void 0,b=m==="blocks"&&d?.lens==="blocks"?{...d,...g?{as:g}:{}}:m==="blocks"&&d?.lens==="columns"?{...f,group:d.column,...g?{as:g}:{}}:f;return W(R(b),i,s,l)}if(d){let m=Te(d,a,i,o);if(m)return W(m,i,s,l)}}catch(p){if(!(p instanceof I))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 L(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=se(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 i=/ (?:sort(?:ed)?|order(?:ed)?) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1];if(i){let d=x(n,i);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 ${i} 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 o=oe(t);if(o&&e.lens==="calendar"&&o.range)return{...R(e),range:o.range};if(o&&e.lens==="calendar"&&!o.range)return{lens:"blocks",kind:e.kind,as:"row",sort:{by:e.start},where:M(n,t)};let a=M(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"?_(t):void 0;if(l)return{...R(e),range:l}}function Ne(e){return e.kinds.map(n=>{let r=n.fields.map(i=>`${i.name} (${i.type??"value"}${i.options?`: ${i.options.join(" | ")}`:""})`).join(", "),t=n.edges.map(i=>`${i.name} \u2192 ${i.to.join(" | ")}`).join(", "),s=Object.entries(n.roles).map(([i,o])=>`${i}=${o}`).join(", ");return`- ${n.kind} ("${n.plural}"): ${r}${t?`; relations: ${t}`:""}${s?`; roles: ${s}`:""}`}).join(`
|
|
1
|
+
import{a as k}from"./chunk.G4JJXA63.js";import{a as Q}from"./chunk.WX5CJ7PI.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.I6T3FDQS.js";import"./chunk.DJ72CUS7.js";import{e as P}from"./chunk.A4SJ7EEY.js";import"./chunk.6KJSFIO7.js";import"./chunk.DEZEXD24.js";import{c as G}from"./chunk.YZZGD5OY.js";import"./chunk.DSZ3I557.js";import{Ib as C,Jb as J,Kb as K,Lb as X,Vb as Y,ha as z,ia as H}from"./chunk.RAE4M3KQ.js";import"./chunk.AJZBJBMO.js";var L=e=>"failed"in e;function ue(e,n){let r=e.schema.kinds,t=e.policy?.sees;if(!t?.length||H(n))return{kinds:r};let s=z(n).roles??[],i=new Set(t.filter(o=>o.roles==="*"||s.some(a=>o.roles.includes(a))).flatMap(o=>o.kinds));return{kinds:r.filter(o=>i.has(o))}}function O(e,n){if(!n)return e;let r=new Set(n.kinds.filter(i=>e.tryDefinition(i)!==void 0));if(r.size===e.kinds.length)return e;let t=new Map,s=i=>{if(r.has(i)){if(!t.has(i)){let o=e.tryDefinition(i),a=Object.fromEntries(Object.entries(o?.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(i,{...o,edges:a})}return t.get(i)}};return{...e,definitions:e.definitions.filter(i=>r.has(i.kind)),kinds:e.kinds.filter(i=>r.has(i)),tryDefinition:s,definition:i=>{let o=s(i);if(!o)throw new Error(`Unknown node kind "${i}"`);return o}}}var fe=e=>e.replace(/([a-z0-9])([A-Z])/g,"$1-$2").toLowerCase(),y=e=>fe(e).replace(/[-_]+/g," ").trim();function j(e){let n=[];for(let t of e.kinds){let s=e.tryDefinition(t);if(!s)continue;let i=s.display?.labels??{},o=Object.entries(s.fields?.shape??{}).filter(([d])=>d!=="id"&&d!=="kind").map(([d,c])=>{let u=P(c);return{name:d,type:u?.type,...u?.options?{options:u.options}:{},words:(i[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:o,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",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`]),i=-1;for(let o of s){let a=e.indexOf(` ${o} `);a>=0&&(i<0||a<i)&&(i=a)}i>=0&&r.push({info:t,at:i})}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(i=>!r||r(i));return s.find(i=>i.words===t||y(i.name)===t||i.name.toLowerCase()===t)??s.find(i=>i.words===v(t)||y(i.name)===v(t))??s.find(i=>t.split(" ").some(o=>o.length>2&&(i.words.split(" ").includes(o)||i.words.split(" ").includes(v(o)))))}function se(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(i=>{let o=r.info(i);return o!==void 0&&(o.noun===v(t)||o.plural===t||y(i)===v(t))}))??e.edges.find(s=>t.split(" ").some(i=>i.length>2&&s.words.split(" ").includes(i)))}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 ge=/\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/,me=/\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"),ge.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"),me.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 oe=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`}},_=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?$/,I=class extends Error{},h=e=>{throw new I(e)};function Se(e,n){let r=e.fields.filter(i=>i.type==="enum");if(n){let i=x(e,n);if(i&&i.type==="enum")return i;i&&h(`${e.plural}' ${i.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(i=>/^(status|stage|state|phase)$/.test(i.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},i=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(!i)return h(`no date field on ${e.plural}`);let o=t("end")??r.find(l=>l!==i&&/^(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:i,...o&&o!==i?{end:o}:{},...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 o of e.kinds)for(let a of o.edges)for(let l of a.to){let d=e.info(l);if(!d||d.kind===o.kind)continue;let c=0;n.includes(o)&&(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:o,across:d,link:a,score:c})}let i=s.sort((o,a)=>a.score-o.score)[0];return i||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 i=U(t);switch(e){case"columns":{if(i){let o=x(n,i);if(!o||o.type!=="enum"){let a=se(n,i,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,i).name}}case"calendar":{let o=ee(n,t),a=_(t);return{lens:"calendar",kind:n.kind,start:o.start.name,...o.end?{end:o.end.name}:{},...o.done?{done:o.done.name}:{},...a?{range:a}:{}}}case"timeline":{let o=ie(n);if(o&&!/\bdates?\b|\bdue\b|\bdeadlines?\b|\bmonths?\b|\byears?\b/.test(t))return{lens:"timeline",kind:n.kind,start:o.start.name,end:o.end.name,column:o.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:_(t)??"quarter"}}case"coverage":{let o=De(r,s,t,i);return{lens:"coverage",kind:o.rows.kind,across:o.across.kind,link:o.link.name}}case"board":{let o=$(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(o)||!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:o.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 o=$(n,n.roles.outline)??n.fields.find(a=>a.name==="outline");return o?{lens:"plan",kind:n.kind,outline:o.name}:h(`${n.plural} have no outline to draw a plan from`)}case"blocks":{let o={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]??(i&&!/ sort(?:ed)? by /.test(t)?i: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`);o.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`);o.sort={by:c.name,.../\b(newest|latest|desc|descending|most)\b/.test(t)?{direction:"desc"}:{}}}let d=M(n,t);return d.length>0&&(o.where=d),o}}}function M(e,n){let r=[],t=oe(n);if(t){let s=e.fields.filter(A),i=$(e,e.roles.start),o=s.find(l=>E(n,l.words))??(A(i)?i:void 0)??s[0];(!o||!A(o))&&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(o.name,/\boverdue\b|\blate\b|\bpast due\b/.test(n)?a?.name:void 0),says:t.says(o)})}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 i=s.options?.find(o=>E(n,o.toLowerCase())||E(n,y(o)));i&&r.push({expr:`${s.name} == '${i.replace(/'/g,"")}'`,says:`that are ${y(i)}`})}if(/\bnot done\b|\bundone\b|\bunfinished\b|\bopen ones\b|\bstill to do\b/.test(n)){let s=e.fields.find(i=>i.type==="boolean"&&/^(done|finished|complete|completed)$/.test(i.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 i=s==="years"?"year":s;return{title:`${k(r.plural)} by ${i}`,detail:`of ${r.plural} by ${t(e.start)}, a ${i} 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(i=>i.says).join(" and "),e.group?`by ${t(e.group)}`:void 0,e.sort?`in order of ${t(e.sort.by)}`:void 0].filter(i=>!!i);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(i=>e.where.length>1?`(${i.expr})`:i.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 q(e,n){let r=s=>s.toLowerCase().replace(/[^\p{L}\p{N}]+/gu,"-").replace(/^-+|-+$/g,""),t=new Set(["home","overview",...Y(n).map(s=>s.slug),...(n.lenses??[]).flatMap(s=>s.title?[r(s.title)]:[])]);if(!t.has(r(e)))return e;for(let s=2;;s++)if(!t.has(r(`${e} ${s}`)))return`${e} ${s}`}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=(o,a)=>{if(typeof o!="string"||o.trim()==="")return`its ${a} says nothing`;try{return G(o)}catch(l){return`its ${a} does not read: ${l instanceof Error?l.message.replace(/ \(at character.*$/,""):String(l)}`}},t=o=>{if(o.t==="where")return t(o.set);if(o.t==="call"&&o.fn==="all"){let a=o.args[0];return a?.t==="lit"&&typeof a.value=="string"?e.info(a.value)??null:void 0}},s=(o,a)=>{switch(o.t){case"lit":return;case"ident":return a&&!a.fields.some(l=>l.name===o.name)&&!a.edges.some(l=>l.name===o.name)?`${a.plural} have nothing called ${o.name}`:void 0;case"member":return s(o.object,a);case"list":return o.items.map(l=>s(l,a)).find(Boolean);case"unary":return s(o.operand,a);case"binary":return s(o.left,a)??s(o.right,a);case"where":{let l=t(o.set);return l===null?"Nothing by that name here":s(o.set,a)??s(o.filter,l??void 0)}case"call":return o.fn==="all"?t(o)===null?"Nothing by that name here":void 0:o.args.map(l=>s(l,a)).find(Boolean)}},i=(o,a)=>{if(a>4)return"its blocks nest deeper than a place draws";for(let l of o){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 m=s(p,void 0);if(m)return m;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 g of["group","sort"]){let b=l[g],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 ${g} by`;if(g==="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 g=i(f,a+1);if(g)return g}}else if(d==="group"){if(!Array.isArray(u))return"a group block holds a list of blocks";let p=i(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 m=p[1].split(/\|(?![|])/)[0],f=r(m,`${d}'s braces`);if(typeof f=="string")return f;let g=s(f,void 0);if(g)return g}}}};return i(n,1)}function T(e,n,r){let t=O(e.schema,r),s=f=>({ok:!1,failed:`Couldn't draw that: ${f.replace(/\.$/,"")}.`});if(!K(n.name)||n.name==="reach")return s(`"${String(n.name)}" is not a picture the seat can draw; it draws ${J.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 i=C[n.name],o=n.bindings??{};if(i.binds==="fields")for(let[f,g]of Object.entries(o)){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(g??{}))if(typeof D!="string"||!b.includes(D))return s(`${y(f)} has no field "${String(D)}" for its ${S}`);for(let S of i.requiredRoles)if(!(S in(g??{})))return s(`a ${n.name} needs ${y(f)}'s ${S}`)}else if(i.binds==="entities")for(let f of i.requiredRoles){let g=o[f];if(!g)return s(`a ${n.name} needs its ${f}`);if(typeof g.kind=="string"&&!t.tryDefinition(g.kind))return s("Nothing by that name here")}let a={...e,schema:t,lenses:[...e.lenses??[],n]},l=a.lenses.length-1,d=X(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 m=d.drawn.find(f=>f.index===l);if(!m)return s("its bindings name something the app does not have");if(m.as==="overview")return s(`"${n.title}" is the scene's own address; give it another title`);if(n.name==="blocks"){let f=Ee(j(t),n.options?.blocks);if(f)return s(f)}return{ok:!0,drawn:m}}function F(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)&&C[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,i=w(e.bindings?.link)?r(e.bindings.link.edge):void 0;return s&&i?{lens:"coverage",kind:e.on,across:s,link:i}:void 0}case"blocks":{let s=e.options?.blocks;if(!Array.isArray(s)||s.length!==1||!w(s[0]))return;let i=s[0],o=new RegExp(`^all\\('${e.on}'\\)(?: where (.+))?$`).exec(String(i.list??""));if(!o)return;let a=i.sort;return{lens:"blocks",kind:e.on,as:i.as==="card"?"card":"row",...typeof i.group=="string"?{group:i.group}:{},...typeof a=="string"?{sort:{by:a}}:w(a)&&typeof a.by=="string"?{sort:{by:a.by,...a.direction==="desc"?{direction:"desc"}:{}}}:{},...o[1]?{where:[{expr:o[1],says:"as asked"}]}:{}}}default:return}}function V(e,n,r,t,s){let i=j(O(e.schema,t)).info(n.on),o=xe(n);return{title:n.title,said:`${B[n.name]??"A picture"} of ${i?.plural??y(n.on)}.`,kind:n.on,lens:n,drawn:r,edit:F(n),by:s,asks:[],...o?{recipe:o}:{}}}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 W(e,n,r,t,s){let i=Re(e,n),o=e.title??s??q(i.title,r.app),a=Ae(e,o),l=T(r.app,a,r.sight);return l.ok?{title:o,said:`${B[e.lens]} ${i.detail}.`,kind:e.kind,lens:a,drawn:l.drawn,edit:F(a),by:"template",asks:t,recipe:e}:{failed:l.failed,...r.lastGood?{lastGood:r.lastGood}:{}}}function Le(e,n,r,t){if(r.length>0)return r;let s=o=>{switch(e){case"columns":return o.fields.some(a=>a.type==="enum");case"calendar":return o.fields.some(A);case"timeline":return ie(o)!==void 0||o.fields.some(A);case"coverage":return o.edges.some(a=>a.to.some(l=>l!==o.kind));case"board":return o.fields.some(a=>a.name==="x")&&o.fields.some(a=>a.name==="y");case"plan":return o.fields.some(a=>a.name==="outline")||o.roles.outline!==void 0;default:return!0}};return[...n.kinds.filter(s)].sort((o,a)=>Number(a.fields.some(l=>E(t,l.words)))-Number(o.fields.some(l=>E(t,l.words))))}function Ie(e,n){let r=j(O(n.app.schema,n.sight)),t=re(e),s=$e(t);if(s.length===0)return;let i=pe(t,r),o;for(let a of s){let l=a==="coverage"?[i[0]??r.kinds[0]].filter(d=>!!d):Le(a,r,i,t);for(let d of l)try{let c=ae(a,d,r,t,i),u=W(c,r,n,[e]);if(!L(u))return u;o??=u.failed}catch(c){if(!(c instanceof I))throw c;o??=`Couldn't draw that: ${c.message}.`}l.length===0&&i.length===0&&(o??=`Couldn't draw that: nothing here has what ${B[a].toLowerCase()} needs.`)}return{failed:o??"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&&!L(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 L(s)&&t?t:s}async function je(e,n,r){let t={lastGood:e},s={...r,lastGood:e},i=j(O(r.app.schema,r.sight)),o=re(n),a=i.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(o)??/ (?:call|name) it (.+?) $/.exec(o);try{if(c){let m=n.replace(/^.*?\b(?:call|name|title)\b\s*(?:it|this)?\s*/i,"").replace(/^["“']|["”']$/g,"").trim();if(m.length===0)return{failed:"Couldn't change that: say what to call it.",...t};let f={...e.lens,title:q(m,r.app)},g=T(r.app,f,r.sight);return g.ok?{...e,title:f.title,lens:f,drawn:g.drawn,edit:F(f),asks:l,...d?{recipe:{...d,title:f.title}}:{}}:{failed:g.failed,...t}}let p=/ as (?:a |an )?(board|kanban|calendar|timeline|list|table|cards|rows|grid|plan|layout)\b/.exec(o);if(p){let m=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(m,a,i,o,[a]),g=p[1]==="cards"?"card":p[1]==="rows"?"row":void 0,b=m==="blocks"&&d?.lens==="blocks"?{...d,...g?{as:g}:{}}:m==="blocks"&&d?.lens==="columns"?{...f,group:d.column,...g?{as:g}:{}}:f;return W(R(b),i,s,l)}if(d){let m=Te(d,a,i,o);if(m)return W(m,i,s,l)}}catch(p){if(!(p instanceof I))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 L(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=se(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 i=/ (?:sort(?:ed)?|order(?:ed)?) by ([\p{L}\p{N} -]+?)(?= (?:and|only|with)|\s*$)/u.exec(t)?.[1];if(i){let d=x(n,i);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 ${i} 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 o=oe(t);if(o&&e.lens==="calendar"&&o.range)return{...R(e),range:o.range};if(o&&e.lens==="calendar"&&!o.range)return{lens:"blocks",kind:e.kind,as:"row",sort:{by:e.start},where:M(n,t)};let a=M(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"?_(t):void 0;if(l)return{...R(e),range:l}}function Ne(e){return e.kinds.map(n=>{let r=n.fields.map(i=>`${i.name} (${i.type??"value"}${i.options?`: ${i.options.join(" | ")}`:""})`).join(", "),t=n.edges.map(i=>`${i.name} \u2192 ${i.to.join(" | ")}`).join(", "),s=Object.entries(n.roles).map(([i,o])=>`${i}=${o}`).join(", ");return`- ${n.kind} ("${n.plural}"): ${r}${t?`; relations: ${t}`:""}${s?`; roles: ${s}`:""}`}).join(`
|
|
2
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
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
4
|
${JSON.stringify(r.lens)}
|