graview 0.1.21 → 0.1.22
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/README.md +22 -4
- package/dist/index.d.ts +7 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +14 -4
- package/dist/index.js.map +1 -1
- package/dist/preview/chunk.2F7OKRDK.js +9 -0
- package/dist/preview/chunk.3HEJZPJM.js +1040 -0
- package/dist/preview/chunk.3MLQ3Q5X.js +1 -0
- package/dist/preview/chunk.4CDEIDKB.js +1 -0
- package/dist/preview/chunk.4HGBVU5B.js +1 -0
- package/dist/preview/chunk.4JSMCNF7.js +1 -0
- package/dist/preview/chunk.4UQLZ7VW.js +1 -0
- package/dist/preview/chunk.5JNXQHN4.js +1 -0
- package/dist/preview/chunk.5MAMCKVU.js +1 -0
- package/dist/preview/chunk.6C7SJJQO.js +1 -0
- package/dist/preview/chunk.6CLHFNDM.js +321 -0
- package/dist/preview/chunk.6KJSFIO7.js +1 -0
- package/dist/preview/chunk.75WDSWXL.js +20 -0
- package/dist/preview/chunk.7YC34AIK.js +1 -0
- package/dist/preview/chunk.7YCQZJGB.js +1 -0
- package/dist/preview/chunk.ACZGK7LQ.js +1 -0
- package/dist/preview/chunk.AHDOKM4O.js +1 -0
- package/dist/preview/chunk.AJZBJBMO.js +1 -0
- package/dist/preview/chunk.AZG6V3PF.js +1 -0
- package/dist/preview/chunk.AZYJTNSM.js +107 -0
- package/dist/preview/chunk.BQV62QEL.js +61 -0
- package/dist/preview/chunk.CJQL7AHT.js +3 -0
- package/dist/preview/chunk.DAKED3WK.js +1 -0
- package/dist/preview/chunk.DJ26NOOW.js +1 -0
- package/dist/preview/chunk.DN4D4HGX.js +1 -0
- package/dist/preview/chunk.DO4P2UK4.js +1 -0
- package/dist/preview/chunk.ELEHYYCN.js +1 -0
- package/dist/preview/chunk.ENMNLR73.js +2 -0
- package/dist/preview/chunk.EQOU4POV.js +1 -0
- package/dist/preview/chunk.FLDFRFDH.js +23 -0
- package/dist/preview/chunk.FLJP3BGP.js +1 -0
- package/dist/preview/chunk.G4JJXA63.js +1 -0
- package/dist/preview/chunk.HCK6IHGP.js +1 -0
- package/dist/preview/chunk.IKT7JQUW.js +14 -0
- package/dist/preview/chunk.JE4VH767.js +16 -0
- package/dist/preview/chunk.K7UJG5II.js +1 -0
- package/dist/preview/chunk.KFLY4MAT.js +1 -0
- package/dist/preview/chunk.KWYU5NPM.js +1 -0
- package/dist/preview/chunk.L5G5DTFX.js +1 -0
- package/dist/preview/chunk.LGUV2J6Q.js +1 -0
- package/dist/preview/chunk.LSLFKW4M.js +1 -0
- package/dist/preview/chunk.LZQZP2PD.js +2 -0
- package/dist/preview/chunk.M4XNUM2A.js +6 -0
- package/dist/preview/chunk.MRK6QJV5.js +25 -0
- package/dist/preview/chunk.NOXC454O.js +1 -0
- package/dist/preview/chunk.ONDILMIX.js +1 -0
- package/dist/preview/chunk.OR6ZWN76.js +1 -0
- package/dist/preview/chunk.PC6FAJF5.js +1 -0
- package/dist/preview/chunk.Q5WEOX3Q.js +1 -0
- package/dist/preview/chunk.Q7WQ5UIE.js +1 -0
- package/dist/preview/chunk.R5K7NK4U.js +1 -0
- package/dist/preview/chunk.SCLIBKLS.js +1 -0
- package/dist/preview/chunk.SQD7ZPEJ.js +1 -0
- package/dist/preview/chunk.THBP5EES.js +1 -0
- package/dist/preview/chunk.UNRYIETM.js +1 -0
- package/dist/preview/chunk.VNC6H6IM.js +1 -0
- package/dist/preview/chunk.VRXWNUDR.js +1 -0
- package/dist/preview/chunk.VVZ2Z7OS.js +29 -0
- package/dist/preview/chunk.WGNF4E67.js +1 -0
- package/dist/preview/chunk.WTF3CP76.js +1 -0
- package/dist/preview/chunk.WWRWXFYR.js +0 -0
- package/dist/preview/chunk.XEJS2VS5.js +8 -0
- package/dist/preview/chunk.XYZ7KAMZ.js +1 -0
- package/dist/preview/chunk.Y235YZSZ.js +8 -0
- package/dist/preview/chunk.YAONM74M.js +19 -0
- package/dist/preview/chunk.YSYT3ASK.js +1 -0
- package/dist/preview/chunk.YU64JSAL.js +1 -0
- package/dist/preview/chunk.ZFUQA3KT.js +1 -0
- package/dist/preview/chunk.ZKUXPS44.js +2 -0
- package/dist/preview/chunk.ZQZ557VR.js +1 -0
- package/dist/preview/index.html +13 -0
- package/dist/preview/page.js +34 -0
- package/package.json +7 -7
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as m}from"./chunk.VRXWNUDR.js";import{j as f}from"./chunk.ACZGK7LQ.js";import{Aa as T,ca as c,ea as b,ua as L,xa as R}from"./chunk.4JSMCNF7.js";import{L as A,W as I,X as k,sa as x}from"./chunk.Y235YZSZ.js";import{a as W,b as C}from"./chunk.MRK6QJV5.js";import{b as w}from"./chunk.AJZBJBMO.js";var u=w(W(),1);var e=w(C(),1);function z(i=4){let{store:n}=c(),p=b();return(0,u.useMemo)(()=>[...n.batches()].reverse().slice(0,i).map(a=>({intent:a.intent,author:a.author.kind,...a.author.id?{authorId:a.author.id}:{},by:a.author,...a.ops[0]?.via?{via:a.ops[0].via}:{},touched:[...new Set(a.ops.filter(o=>!x(o)).flatMap(o=>o.writes))],batch:a.id,...a.ops.every(x)?{withheld:!0}:{}})),[n,p,i])}function H({batch:i}){let{store:n,principal:p,noteSeat:a}=c(),o=b(),[h,y]=(0,u.useState)(null),l=(0,u.useMemo)(()=>n.canUndo(i),[n,i,o]);if(!l.ok&&l.ops.length===0)return null;let s=!l.ok,g=s?l.includeBatches:[];return(0,e.jsxs)("span",{style:{marginLeft:"auto",flex:"0 0 auto",display:"grid",justifyItems:"end",gap:2},children:[(0,e.jsx)("button",{type:"button","data-testid":"undo-turn",title:s?`${l.message} \u2014 undo those too`:"Take this back, keeping everything since",onClick:()=>{y(null);try{let d=n.log.all().find(t=>t.batch===i&&t.author.kind==="agent");n.undo(s?[i,...g]:i,{author:p}),d&&a({type:"home",author:d.author})}catch(d){y(d instanceof Error?d.message:String(d))}},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,padding:"1px 8px",fontSize:"0.75rem",...s?{borderColor:"var(--graview-warn)",color:"var(--graview-warn)"}:{}},children:s?`undo +${g.length}`:"undo"}),h?(0,e.jsx)("span",{"data-testid":"undo-refused",role:"alert",style:{fontSize:"0.75rem",lineHeight:1.4,color:"var(--graview-warn)",maxWidth:260,textAlign:"right"},children:h}):null]})}function O(){let i=()=>{let n=new URL(window.location.href);return n.searchParams.set("fresh","1"),n.toString()};return(0,e.jsx)("a",{href:"#fresh","data-testid":"start-fresh",title:"Forget every edit made in this browser and return to the example",onClick:n=>{n.preventDefault(),window.location.assign(i())},style:{display:"inline-flex",alignItems:"center",minHeight:24,minWidth:24,fontSize:"0.8125rem",color:"var(--graview-ink-muted)",textDecoration:"underline",textDecorationColor:"var(--graview-edge-bright)",textUnderlineOffset:3},children:"Start fresh"})}function N({calls:i,seat:n,remembers:p=!1}){let a=z(),{store:o,principal:h,seats:y,people:l}=c(),s=i.some(t=>t.phase==="running"),g=R("activity"),d=g.open;return n===void 0&&i.length===0&&a.length===0&&!p?null:(0,e.jsxs)("div",{style:{position:"relative"},children:[(0,e.jsxs)("button",{type:"button","data-testid":"activity-button",...g.trigger,onClick:g.toggle,title:s?"An agent is working":"What has happened",style:{display:"inline-flex",alignItems:"center",gap:6,minHeight:30,padding:"0 8px",borderRadius:8,border:"1px solid transparent",background:"transparent",boxShadow:"none",fontSize:"0.875rem",whiteSpace:"nowrap",color:s?"var(--graview-accent)":"var(--graview-ink-muted)"},children:[s?(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,background:"var(--graview-accent)"}}):null,a.length>0?a.length:"",(0,e.jsxs)("svg",{className:"graview-activity-mark",width:"15",height:"15",viewBox:"0 0 16 16","aria-hidden":"true",focusable:"false",style:{display:"var(--graview-activity-mark, none)"},children:[(0,e.jsx)("circle",{cx:"8",cy:"8",r:"5.75",fill:"none",stroke:"currentColor",strokeWidth:"1.4"}),(0,e.jsx)("path",{d:"M8 4.75 V8 L10.25 9.5",fill:"none",stroke:"currentColor",strokeWidth:"1.4",strokeLinecap:"round",strokeLinejoin:"round"})]}),(0,e.jsx)("span",{className:"graview-activity-word",children:" Activity"})]}),!d&&n!==void 0?(0,e.jsx)("div",{hidden:!0,"data-testid":"agent-seat-seated",children:n}):null,d?(0,e.jsxs)("section",{...g.pane,"aria-label":"Activity","data-testid":"activity","data-graview-offstage":"",style:{...L,width:300,maxHeight:"min(52cqh, 460px)",overflow:"auto",display:"flex",flexDirection:"column",gap:9,padding:12,borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-high)"},children:[(0,e.jsx)("h2",{style:{...T,margin:0},children:"Activity"}),n!==void 0?(0,e.jsxs)("div",{"data-testid":"agent-seat-row",style:{display:"grid",gap:5,paddingBottom:i.length>0||a.length>0?9:0,...i.length>0||a.length>0?{borderBottom:"1px solid var(--graview-edge)"}:{}},children:[(0,e.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"The agent's seat"}),n]}):null,i.length>0?(0,e.jsx)("ol",{style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:7},children:i.slice(0,6).map((t,v)=>(0,e.jsxs)("li",{style:{display:"grid",gap:2,fontSize:"0.8125rem",lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsx)("span",{"aria-hidden":"true",style:{width:6,height:6,borderRadius:999,flex:"0 0 auto",background:t.phase==="running"?"var(--graview-accent)":t.phase==="failed"?"var(--graview-warn)":"var(--graview-edge-bright)"}}),(0,e.jsxs)("span",{style:{color:"var(--graview-ink)"},children:[t.mutating?"changed":"read"," \xB7"," ",o.allMutations().find(r=>r.name===t.name)?.title??A(t.name)]})]}),!t.mutating&&t.reads&&t.reads.length>0?(0,e.jsxs)("div",{"data-testid":"activity-reads",style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:[[...new Set(t.reads)].slice(0,3).map(r=>(0,e.jsx)(f,{label:m(o,r),pickId:r},r)),new Set(t.reads).size>3?(0,e.jsxs)("span",{style:{color:"var(--graview-ink-muted)"},children:["+",new Set(t.reads).size-3]}):null]}):Object.values(t.args).some(r=>typeof r=="string")?(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4,paddingLeft:12},children:Object.entries(t.args).filter(r=>typeof r[1]=="string").slice(0,3).map(([r,S])=>(0,e.jsx)(f,{label:m(o,S),pickId:S},r))}):null,t.error?(0,e.jsx)("div",{style:{paddingLeft:12,color:"var(--graview-warn)"},children:t.error}):null]},`${t.at}:${v}`))}):null,a.length>0?(0,e.jsx)("ol",{"data-testid":"diff-log",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:6,fontSize:"0.8125rem"},children:a.map((t,v)=>t.withheld?(0,e.jsx)("li",{"data-testid":"withheld-change",style:{display:"grid",gap:3,lineHeight:1.45},children:(0,e.jsx)("span",{"data-touched":"",style:{color:"var(--graview-ink-muted)",fontStyle:"italic"},children:t.intent})},`change:${v}`):(0,e.jsxs)("li",{style:{display:"grid",gap:3,lineHeight:1.45},children:[(0,e.jsxs)("div",{style:{display:"flex",alignItems:"baseline",gap:6},children:[(0,e.jsxs)("span",{style:{minWidth:0},children:[(0,e.jsxs)("strong",{style:{fontWeight:600},children:[t.author==="human"&&t.by?.onBehalfOf===void 0&&(t.authorId===void 0||h.id===void 0||t.authorId===h.id)?"you":I(t.by??{kind:t.author,id:t.authorId},{graph:o.graph,schema:o.schema,seats:y,people:l}),k(t.via)?(0,e.jsxs)("span",{style:{fontWeight:400,color:"var(--graview-ink-muted)"},children:[", ",k(t.via)]}):null]})," ",(0,e.jsx)("span",{style:{color:"var(--graview-ink-muted)"},children:t.intent})]}),t.batch?(0,e.jsx)(H,{batch:t.batch}):null]}),(0,e.jsx)("div",{"data-touched":t.touched.join(" "),style:{display:"flex",flexWrap:"wrap",gap:4},children:t.touched.slice(0,4).map(r=>(0,e.jsx)(f,{label:m(o,r),pickId:r},r))})]},`change:${v}`))}):null,p?(0,e.jsxs)("div",{"data-testid":"remembered",style:{display:"flex",alignItems:"baseline",justifyContent:"space-between",gap:10,paddingTop:8,borderTop:"1px solid var(--graview-edge)",fontSize:"0.8125rem",color:"var(--graview-ink-faint)"},children:[(0,e.jsx)("span",{children:"Remembered in this browser"}),(0,e.jsx)(O,{})]}):null]}):null]})}export{N as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Aa as v,Ca as q,Da as W,Fa as T,Ga as A,H as x,Ha as h,I as R,Ia as k,L as O,Ra as j,Sa as B,ya as G,za as F}from"./chunk.Y235YZSZ.js";function L(e,r){return e===void 0||e===!0?!0:e===!1?!1:e[r]!==!1}function V(e){let r={};return e.query&&e.query.trim().length>0&&(r.q=e.query),e.sort&&(r.sort=e.sort.direction==="desc"?`${e.sort.by}:desc`:e.sort.by),e.filter?.length&&(r.filter=e.filter.map(o=>`${o.key}:${o.value}`).join(",")),e.group&&(r.group=e.group.bucket?`${e.group.by}:${e.group.bucket}`:e.group.by),r}function Y(e,r){let o=[],i={};if(e.query&&(i.query=e.query),e.sort&&(r.sorts.some(l=>l.key===e.sort.by)?i.sort=e.sort:o.push(`sort ${e.sort.by}`)),e.filter){let l=e.filter.filter(p=>r.filters.find(a=>a.key===p.key)?!0:(o.push(`filter ${p.key}`),!1));l.length>0&&(i.filter=l)}return e.group&&(r.groups.some(l=>l.key===e.group.by)?i.group=e.group:o.push(`group ${e.group.by}`)),{arrangement:i,dropped:o}}function N(e,r){return R(e.schema.tryDefinition(r.kind),A(r))}var z=(e,r)=>e==null?r==null?0:1:r==null?-1:typeof e=="number"&&typeof r=="number"?e-r:typeof e=="boolean"&&typeof r=="boolean"?e===r?0:e?1:-1:String(e).localeCompare(String(r),void 0,{numeric:!0,sensitivity:"base"});function I(e,r,o){if(o==="label")return N(e,r);let i=e.schema.tryDefinition(r.kind);return i&&o in(i.fields.shape??{})?T(r)[o]:h(e.graph,r.id,o).map(p=>N(e,p)).sort()[0]}var P=/^(\d{4})-(\d{2})-(\d{2})/;function U(e,r){let o=P.exec(e);if(!o)return;let[,i,l,p]=o;if(r==="day")return`${i}-${l}-${p}`;if(r==="month")return`${i}-${l}-01`;if(r==="year")return`${i}-01-01`;if(r==="decade")return`${String(Number(i)-Number(i)%10).padStart(4,"0")}-01-01`;let s=new Date(Date.UTC(Number(i),Number(l)-1,Number(p))),a=(s.getUTCDay()+6)%7;return s.setUTCDate(s.getUTCDate()-a),s.toISOString().slice(0,10)}var Q=["January","February","March","April","May","June","July","August","September","October","November","December"];function _(e,r){return r==="month"?`${Q[Number(e.slice(5,7))-1]} ${e.slice(0,4)}`:r==="week"?`Week of ${e}`:r==="year"?e.slice(0,4):r==="decade"?`The ${e.slice(0,4)}s`:e}function K(e,r){let{words:o,conditions:i}=j(r);if(o.length===0&&i.length===0)return()=>!0;let l=new Map,p=s=>{let a=l.get(s);return a||(a=new Set(q(e.schema,s).filters.map(u=>u.key)),l.set(s,a)),a};return s=>{let a=p(s.kind),u=i.filter(g=>a.has(g.key));return u.every(g=>k(e,s,g))?o.length>0?B(e.schema.tryDefinition(s.kind),A(s),o)!==void 0:u.length>0:!1}}function X(e,r,o){let i=r.query?.trim(),l=i?e.filter(K(o,i)):e,p=r.filter?.length?l.filter(n=>r.filter.every(f=>k(o,n,f))):[...l],s=r.sort,a=s?p.map((n,f)=>({node:n,index:f,value:I(o,n,s.by)})).sort((n,f)=>{let t=z(n.value,f.value),d=s.direction==="desc"&&t!==0&&n.value!==void 0&&f.value!==void 0?-t:t;return d!==0?d:n.index-f.index}).map(n=>n.node):p,u=r.group;if(!u)return{nodes:a,groups:[{key:"",label:"",nodes:a}],grouped:!1};let g=new Map,c=(n,f,t)=>{let d=g.get(n)??{label:f,nodes:[]};d.nodes.push(t),g.set(n,d)},$=a[0],m=$?o.schema.tryDefinition($.kind):void 0,C=m?.fields.shape??{},E=m?G(m,u.by):O(u.by),b=u.by in C,y=b?F(C[u.by]):void 0,H=v(o.schema,$?.kind??"").find(n=>n.key===u.by)?.label,S=b?`No ${E.toLowerCase()}`:`Without ${(H??O(u.by)).toLowerCase()}`,M=b?new Map:x([...new Map(a.flatMap(n=>h(o.graph,n.id,u.by)).map(n=>[n.id,n])).values()].map(A),n=>o.schema.tryDefinition(n));for(let n of a){if(b){let t=T(n)[u.by];if(t==null||t==="")c("",S,n);else if(y==="date"){let d=u.bucket??"day",D=U(String(t),d);D?c(D,_(D,d),n):c("",S,n)}else if(y==="boolean")c(t?"1":"0",t?"Yes":"No",n);else{let d=m?.display?.format?.[u.by];c(String(t),d?d(t):String(t),n)}continue}let f=h(o.graph,n.id,u.by).map(t=>({id:t.id,label:M.has(t.id)?`${N(o,t)} \xB7 ${M.get(t.id)}`:N(o,t)})).sort((t,d)=>t.label.localeCompare(d.label));f.length===0?c("",S,n):c(f.map(t=>t.id).join(","),f.map(t=>t.label).join(", "),n)}let w=y==="choice"?W(C[u.by]):void 0,J=[...g.entries()].sort(([n,f],[t,d])=>n===""?1:t===""?-1:w?w.indexOf(n)-w.indexOf(t):y==="boolean"?t.localeCompare(n):y==="date"?n.localeCompare(t):f.label.localeCompare(d.label)).map(([n,f])=>({key:n,label:f.label,nodes:f.nodes}));return{nodes:a,groups:J,grouped:!0}}export{L as a,V as b,Y as c,X as d};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as D}from"./chunk.AZG6V3PF.js";import{a as O,c as V,f as K,g as q,k as z,l as W,m as U}from"./chunk.6CLHFNDM.js";import{c as j}from"./chunk.WGNF4E67.js";import{e as _,g as J,i as Q}from"./chunk.R5K7NK4U.js";import{ca as T,ea as $,ma as G,ta as I}from"./chunk.4JSMCNF7.js";import{Cb as H,bb as P,lb as L,mb as M}from"./chunk.Y235YZSZ.js";import{a as ne,b as N}from"./chunk.MRK6QJV5.js";import{b as A}from"./chunk.AJZBJBMO.js";var o=A(ne(),1);function te(e){let t=[e?.typography?.body,e?.typography?.display,e?.typography?.mono],n=[];for(let a of t){let r=a?.split(",")[0]?.trim().replace(/^["']|["']$/g,"");!r||M(r)||r.toLowerCase()!==P.toLowerCase()&&(n.includes(r)||n.push(r))}return n}function X(e){let t=te(e);return t.length===0?null:`https://fonts.googleapis.com/css2?${t.map(a=>`family=${encodeURIComponent(a).replace(/%20/g,"+")}:wght@400;500;600;700`).join("&")}&display=swap`}var y=A(N(),1);function ye(e,t){let{app:n}=e;return(0,o.useMemo)(()=>{let a=J(t(n.schema,n.viewSpecs),n),r=e.views?G(a,e.views(n.schema,a)):a;return Q(r,n.schema,_(e.brand??n.brand,n.schema)),r},[e.views,n.schema,n.viewSpecs,n.lenses,n.pages,n.home])}function re(e,t){return new H({schema:e.schema,mutations:e.mutations??[],invariants:e.invariants??[],...t?{snapshot:t}:{},...e.policy?{policy:e.policy}:{},...e.intelligence?{intelligence:e.intelligence}:{}})}function Y(e){if(typeof document>"u")return e==="dark"?"dark":"light";let t=document.documentElement.dataset.theme;return t==="dark"||t==="light"?t:e==="dark"||e==="light"?e:typeof matchMedia=="function"&&matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"}function oe(e,t){let[n,a]=(0,o.useState)(()=>Y(t));return(0,o.useEffect)(()=>{if(!e||typeof document>"u")return;let r=()=>a(Y(t));r();let s=new MutationObserver(r);s.observe(document.documentElement,{attributes:!0,attributeFilter:["data-theme"]});let u=typeof matchMedia=="function"?matchMedia("(prefers-color-scheme: dark)"):null;return u?.addEventListener?.("change",r),()=>{s.disconnect(),u?.removeEventListener?.("change",r)}},[e,t]),n}var R=e=>e?e.getBoundingClientRect().height:0;function pe(e,t,n){let a=(0,o.useRef)(n);a.current=n;let r=n!==void 0;(0,o.useLayoutEffect)(()=>{let s=e.current;if(!s||!r)return;let u=()=>{let l=[...s.children],g=l.find(c=>c.hasAttribute("data-graview-app-bar")),m=l.find(c=>c.hasAttribute("data-embed-content")),h=m?.querySelector("[data-embed-measure]")??null,d=l.find(c=>c.hasAttribute("data-graview-place-line"));return{strip:g,line:d,content:m,measure:h}},i=-1,p=()=>{let{strip:l,line:g,content:m,measure:h}=u(),d=Math.ceil(R(l)+R(g)+R(h||m));d!==i&&(i=d,a.current?.(d))};if(p(),typeof ResizeObserver>"u")return;let f=new ResizeObserver(p),w=()=>{f.disconnect();let{strip:l,line:g,content:m,measure:h}=u();for(let d of[s,l,g,m,h])d&&f.observe(d)};w();let v=new MutationObserver(()=>{w(),p()});return v.observe(s,{childList:!0}),()=>{f.disconnect(),v.disconnect()}},[e,t,r])}var fe=480,ae=0;function he(e){let{app:t,seed:n,scheme:a="auto",brand:r=t.brand,fonts:s=!0,height:u="100%",label:i}=e,p=(0,o.useRef)(null);I(p);let f=(0,o.useMemo)(()=>`graview-embed-${++ae}`,[]),w=(0,o.useMemo)(()=>e.store??e.remote?.store??re(t,n),[e.store,e.remote,t,n]),v=e.presence??e.remote?.presence,l=e.hostContext?.theme,g=oe(a==="auto"&&l===void 0,r?.scheme),m=a==="auto"?l??g:a,h=(0,o.useMemo)(()=>O(m,r,{scope:`.${f}`}),[m,r,f]);V(e.favicon?L(r):void 0),(0,o.useEffect)(()=>{if(!s||typeof document>"u")return;let c=X(r);if(!c||document.querySelector(`link[href="${c}"]`))return;let b=document.createElement("link");b.rel="stylesheet",b.href=c,document.head.appendChild(b)},[r,s]);let d=(0,o.useRef)(void 0);return(0,o.useLayoutEffect)(()=>{let c=p.current,b=d.current;if(d.current=i,!c||!i)return;let ee=S=>{let E=S.getAttribute("aria-label")??"",x=b&&b!==i?E.startsWith(`${b} \xB7 `)?E.slice(b.length+3):E===b?"":E:E;x===i&&(S.getAttribute("role")==="region"||S.tagName==="SECTION"&&!S.hasAttribute("role"))&&S.setAttribute("role","group");let B=x.startsWith(`${i} \xB7 `)||x===i?x:x?`${i} \xB7 ${x}`:i;B!==E&&S.setAttribute("aria-label",B)},k=()=>c.querySelectorAll("aside, nav, main, header, footer, section[aria-label]:not([role]), [role=region], [role=complementary], [role=navigation], [role=search]").forEach(S=>{S.hasAttribute("data-graview-named-by-lens")||ee(S)});k();let C=new MutationObserver(k);return C.observe(c,{childList:!0,subtree:!0,attributes:!0,attributeFilter:["aria-label"]}),()=>C.disconnect()},[i]),{rootRef:p,scope:f,css:h,scheme:m,store:w,presence:v,brand:r,auto:u==="auto",height:u}}function ge({rootRef:e,board:t}){let n=(0,o.useCallback)(()=>e.current?.querySelector("[data-embed-content]")??e.current,[e]);return(0,y.jsx)(j,{board:t,anchor:n})}function be(e,t,n){return{...n?{brand:n}:{},...e.principal?{principal:e.principal}:{},...e.seats?{seats:e.seats}:{},...t?{presence:t}:{},...e.people?{people:e.people}:{},...e.memory?{memory:e.memory}:{},...e.presenceTtlMs!==void 0?{presenceTtlMs:e.presenceTtlMs}:{},...e.onKeepLens?{onKeepLens:e.onKeepLens}:{},...e.ai?{ai:e.ai}:{},settings:e.app.settings??[]}}function Se({name:e,heading:t,faces:n,at:a,without:r,home:s,reach:u,standing:i,hostActions:p,keeping:f,onFind:w,switch:v}){let{brand:l,store:g,principal:m,views:h}=T();$();let d=r?.has("places")?[]:K({store:g,principal:m,views:h}),c=D();return(0,y.jsx)(z,{brand:l,name:e,description:l?.subtitle,heading:t,faces:n,home:s,places:d,current:a===null?null:q(d,a),reach:u,onFind:w,...v?{switch:v}:{},...n?{scenePlaces:c}:{},tools:(0,y.jsxs)(y.Fragment,{children:[(0,y.jsx)(U,{clean:i}),(0,y.jsx)(W,{...p?{hostActions:p}:{},...f?{keeping:f}:{}})]})})}var ve=e=>e===!1?2:Math.min(e+1,6);function we(e){let[t,n]=(0,o.useState)(e),a=(0,o.useRef)(void 0),r=(0,o.useRef)(void 0),s=(0,o.useMemo)(()=>({go:a,at:n,pending:r}),[]),u=(0,o.useCallback)(i=>{if(a.current){a.current(i);return}r.current=i,n(i)},[]);return{at:t,setAt:n,steering:s,steer:u}}function ie(e){let t=typeof e=="object"&&e!==null?e.name:void 0;return{name:typeof t=="string"&&t.length>0?t:typeof e=="object"?"Error":typeof e}}var F=()=>typeof performance<"u"?performance.now():Date.now();function Ee(e,t){let n=(0,o.useRef)({onError:e,face:t});return n.current={onError:e,face:t},(0,o.useCallback)((a,r)=>n.current.onError?.(ie(a),{module:r.module,face:n.current.face}),[])}function xe(e,t){let n=(0,o.useRef)(null);n.current===null&&(n.current=F());let a=(0,o.useRef)({onReady:e,face:t});a.current={onReady:e,face:t};let r=(0,o.useRef)(!1);return(0,o.useCallback)(s=>{r.current||(r.current=!0,a.current.onReady?.({ms:Math.max(0,F()-(n.current??F())),face:s}))},[])}var Z=class extends o.Component{state={failed:!1};static getDerivedStateFromError(){return{failed:!0}}componentDidCatch(t,n){console.error(`[graview] ${this.props.module} threw while rendering`,t,n.componentStack),this.props.report(t,{module:this.props.module})}render(){return this.state.failed?(0,y.jsxs)("div",{role:"alert","data-graview-face-error":this.props.module,...this.props.content?{"data-embed-content":""}:{},style:this.props.content?{flex:"1 1 auto",display:"grid",alignContent:"center",justifyItems:"center",gap:8,padding:24,background:"var(--graview-ground)",color:"var(--graview-ink)",fontSize:"0.9375rem"}:{display:"inline-flex",alignItems:"center",gap:6,fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:[(0,y.jsx)("span",{children:this.props.content?"This part of the app could not draw.":"Could not draw."}),(0,y.jsx)("button",{type:"button",onClick:()=>this.setState({failed:!1}),style:{padding:"3px 11px",fontSize:"0.8125rem"},children:"Try again"})]}):this.props.children}};export{ye as a,re as b,pe as c,fe as d,he as e,ge as f,be as g,Se as h,ve as i,we as j,Ee as k,xe as l,Z as m};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
import{C as L,D as T,S as D}from"./chunk.Y235YZSZ.js";var Y=1e4,g=class{constructor(i){this.nodes=i}},B="",c=class extends Error{constructor(f,l){super(f);this.sentence=f;this.at=l}},_=class extends c{},V=t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!(t instanceof g)&&typeof t.id=="string",U=t=>{let i=new Set;return new g(t.filter(f=>!i.has(f.id)&&i.add(f.id)))},p=t=>t===null?"nothing":t instanceof g?"a set of records":Array.isArray(t)?"a list":V(t)?"a record":typeof t=="string"?"a word":typeof t;function P(t,i){let f=i.budget??Y,l=(n,s)=>{if(f-=n,f<0)throw new _("this rule looks at too much of the graph to judge in one go",s)},b=i.today??new Date().toISOString().slice(0,10),A=i.now??new Date().toISOString(),w=new Map,F=new Set,G=i.bindings,I=(n,s,e,o)=>{let u=`${n?.id}\0${s}`;if(w.has(u))return w.get(u);if(F.has(u))throw new c(`"${s}"${n?` of ${D(n.kind)}`:""} depends on itself`,o);F.add(u);let r=G;G=void 0;try{let a=h(e,n);return w.set(u,a),a}finally{G=r,F.delete(u)}},M=(n,s,e)=>{l(1,e);let o=i.kinds.get(n.kind),u=o?.computed?.get(s);if(u)return I(n,s,u,e);let r=Object.hasOwn(n,s);if(o?.fields.has(s)||r){let d=r?n[s]:void 0;return d===void 0?null:d}let a=o?.edges.get(s);if(a){let d=i.graph.out(n.id,s);return l(d.length,e),a==="one"?d[0]??null:new g(d)}if(s==="id")return n.id;throw new c(`${D(n.kind)} has no field or relation called "${s}"`,e)},S=(n,s,e)=>{if(n instanceof g)return n;if(n===null)return new g([]);if(V(n))return new g([n]);throw new c(`${e}(\u2026) needs a set of records, and was given ${p(n)}`,s)},k=(n,s,e)=>{if(n===null)return null;if(typeof n=="string")return n;if(typeof n=="number"||typeof n=="boolean")return String(n);throw new c(`${e}(\u2026) needs a word, and was given ${p(n)}`,s)},O=(n,s,e)=>{let o=k(n,s,e);if(o===null)return null;let u=Date.parse(o.length===10?`${o}T00:00:00Z`:o);if(Number.isNaN(u))throw new c(`${e}(\u2026) needs a date, and "${o}" is not one`,s);return u},E=(n,s)=>V(n)&&V(s)?n.id===s.id:V(n)&&typeof s=="string"?n.id===s:typeof n=="string"&&V(s)?n===s.id:Array.isArray(n)&&Array.isArray(s)?n.length===s.length&&n.every((e,o)=>E(e,s[o])):n===s,N=(n,s,e)=>{if(n===null)return!1;if(typeof n=="boolean")return n;throw new c(`${e} must be true or false, and was ${p(n)}`,s)},R=(n,s)=>h(s,n);function h(n,s){switch(l(1,n.at),n.t){case"lit":return n.value;case"list":return n.items.map(e=>h(e,s));case"ident":{let e=G&&Object.hasOwn(G,n.name)?G[n.name]:void 0;if(e!==void 0)return e;if(s)return M(s,n.name,n.at);throw new c(`"${n.name}" means nothing in a rule over the whole graph`,n.at)}case"member":{let e=h(n.object,s);if(e===null)return null;if(V(e))return M(e,n.name,n.at);throw new c(`".${n.name}" needs a record before it, and was given ${p(e)}`,n.at)}case"unary":{let e=h(n.operand,s);if(n.op==="!")return!N(e,n.at,"what follows not");if(e===null)return null;if(typeof e!="number")throw new c(`"-" needs a number, and was given ${p(e)}`,n.at);return-e}case"where":{let e=S(h(n.set,s),n.at,"where");return l(e.nodes.length,n.at),new g(e.nodes.filter(o=>N(R(o,n.filter),n.at,"a where condition")))}case"binary":return z(n,s);case"call":return H(n,s)}}function z(n,s){if(n.op==="&&")return N(h(n.left,s),n.at,"each side of and")&&N(h(n.right,s),n.at,"each side of and");if(n.op==="||")return N(h(n.left,s),n.at,"each side of or")||N(h(n.right,s),n.at,"each side of or");let e=h(n.left,s),o=h(n.right,s);if(n.op==="&"||n.op==="|"||n.op==="-"&&(e instanceof g||o instanceof g)){let u=S(e,n.at,n.op).nodes,r=S(o,n.at,n.op).nodes;l(u.length+r.length,n.at);let a=new Set(r.map(d=>d.id));return U(n.op==="|"?[...u,...r]:u.filter(d=>a.has(d.id)===(n.op==="&")))}switch(n.op){case"==":return E(e,o);case"!=":return!E(e,o);case"in":{if(o===null)return!1;if(o instanceof g)return o.nodes.some(u=>E(e,u));if(Array.isArray(o))return o.some(u=>E(e,u));if(typeof o=="string"&&typeof e=="string")return o.includes(e);throw new c(`"in" needs a list or a set on its right, and was given ${p(o)}`,n.at)}case"<":case"<=":case">":case">=":{if(e===null||o===null)return!1;if(!(typeof e=="number"&&typeof o=="number"||typeof e=="string"&&typeof o=="string"))throw new c(`cannot compare ${p(e)} with ${p(o)}`,n.at);return n.op==="<"?e<o:n.op==="<="?e<=o:n.op===">"?e>o:e>=o}default:{if(e===null||o===null)return null;if(n.op==="+"&&(typeof e=="string"||typeof o=="string")){let u=`${k(e,n.at,"+")}${k(o,n.at,"+")}`;if(u.length>1e4)throw new c("that makes a word too long",n.at);return u}if(typeof e!="number"||typeof o!="number")throw new c(`"${n.op}" needs numbers, and was given ${p(e)} and ${p(o)}`,n.at);return(n.op==="/"||n.op==="%")&&o===0?null:n.op==="+"?e+o:n.op==="-"?e-o:n.op==="*"?e*o:n.op==="/"?e/o:e%o}}}function H(n,s){let e=(r,a=r)=>{if(n.args.length<r||n.args.length>a)throw new c(`${n.fn}(\u2026) takes ${r===a?r:`${r} to ${a}`} argument${a===1?"":"s"}`,n.at)},o=r=>h(n.args[r],s),u=r=>{let a=o(r);if(typeof a!="string")throw new c(`${n.fn}(\u2026) needs a quoted name, like ${n.fn}('name')`,n.at);return a};switch(n.fn){case"out":case"in":{e(1,2);let r=($,m)=>n.fn==="out"?i.graph.out($,m):i.graph.in($,m);if(n.args.length===2){let $=S(o(0),n.at,n.fn).nodes,m=u(1);return U($.flatMap(y=>{let x=r(y.id,m);return l(x.length+1,n.at),x}))}let a=u(0);if(!s)throw new c(`${n.fn}('${a}') needs a record to start from`,n.at);let d=r(s.id,a);return l(d.length,n.at),new g(d)}case"all":{e(1);let r=i.graph.nodesOfKind(u(0));return l(r.length,n.at),new g(r)}case"count":return e(1),S(o(0),n.at,"count").nodes.length;case"exists":return e(1),S(o(0),n.at,"exists").nodes.length>0;case"every":case"some":{e(2);let r=S(o(0),n.at,n.fn);l(r.nodes.length,n.at);let a=d=>N(R(d,n.args[1]),n.at,`the condition in ${n.fn}(\u2026)`);return n.fn==="every"?r.nodes.every(a):r.nodes.some(a)}case"sum":case"min":case"max":{e(2);let r=S(o(0),n.at,n.fn);l(r.nodes.length,n.at);let a=n.args[1],d=a.t==="lit"&&typeof a.value=="string"?a.value:void 0,$=a.t==="ident"?`'${a.name}'`:d!==void 0?`'${d}'`:"\u2026",m=r.nodes.map(y=>a.t==="ident"?M(y,a.name,n.at):d!==void 0?M(y,d,n.at):R(y,a)).filter(y=>{if(y===null)return!1;if(typeof y!="number")throw new c(`${n.fn}(\u2026, ${$}) needs a number for each member, and found ${p(y)}`,n.at);return!0});return n.fn==="sum"?m.reduce((y,x)=>y+x,0):m.length===0?null:n.fn==="min"?Math.min(...m):Math.max(...m)}case"fact":{e(1);let r=u(0),a=i.kinds.get(B)?.computed?.get(r);if(!a)throw new c(`no fact is called "${r}"`,n.at);return I(null,r,a,n.at)}case"first":return e(1),S(o(0),n.at,"first").nodes[0]??null;case"sort":{e(2,3);let r=S(o(0),n.at,"sort"),a=n.args.length===3?o(2):"asc";if(a!=="asc"&&a!=="desc")throw new c("sort(\u2026) goes 'asc' or 'desc'",n.at);let d=r.nodes.length;l(d+d*Math.ceil(Math.log2(d+1)),n.at);let $=r.nodes.map((y,x)=>({node:y,i:x,key:R(y,n.args[1])})),m=a==="desc"?-1:1;return $.sort((y,x)=>K(y.key,x.key,m,n.at)||y.i-x.i),new g($.map(y=>y.node))}case"either":{if(n.args.length<1)throw new c("either(\u2026) takes at least one argument",n.at);for(let r=0;r<n.args.length;r++){let a=o(r);if(a!==null&&!(a instanceof g&&a.nodes.length===0))return a}return null}case"present":{e(1);let r=o(0);return r===null||r===""?!1:Array.isArray(r)?r.length>0:r instanceof g?r.nodes.length>0:!0}case"len":{e(1);let r=o(0);if(r===null)return 0;if(typeof r=="string"||Array.isArray(r))return r.length;if(r instanceof g)return r.nodes.length;throw new c(`len(\u2026) needs a word or a list, and was given ${p(r)}`,n.at)}case"contains":case"startsWith":{e(2);let r=o(0),a=o(1);if(r===null||a===null)return!1;if(n.fn==="contains"&&Array.isArray(r))return r.some(m=>E(m,a));let d=k(r,n.at,n.fn),$=k(a,n.at,n.fn);return n.fn==="contains"?d.toLowerCase().includes($.toLowerCase()):d.startsWith($)}case"lower":{e(1);let r=k(o(0),n.at,"lower");return r===null?null:r.toLowerCase()}case"today":return e(0),b;case"now":return e(0),A;case"date":{e(1);let r=O(o(0),n.at,"date");return r===null?null:new Date(r).toISOString().slice(0,10)}case"days":case"hours":{e(2);let r=O(o(0),n.at,n.fn),a=O(o(1),n.at,n.fn);if(r===null||a===null)return null;let d=(a-r)/(n.fn==="days"?864e5:36e5);return n.fn==="days"?Math.round(d):d}case"if":return e(3),N(o(0),n.at,"the condition in if(\u2026)")?o(1):o(2);default:throw new c(`"${n.fn}" is not a function the rule language knows`,n.at)}}function K(n,s,e,o){if(n===null||s===null)return n===s?0:n===null?1:-1;if(Array.isArray(n)&&Array.isArray(s)){for(let r=0;r<Math.max(n.length,s.length);r++){let a=K(n[r]??null,s[r]??null,e,o);if(a!==0)return a}return 0}let u=r=>typeof r=="number"||typeof r=="string"||typeof r=="boolean"?typeof r:p(r);if(u(n)!==u(s)||typeof n=="object"||typeof s=="object")throw new c(`sort(\u2026) cannot put ${p(n)} and ${p(s)} in order`,o);return typeof n=="string"?e*(n<s?-1:n>s?1:0):e*(Number(n)-Number(s))}return h(t,i.subject)}var tn=["out","in","all","count","exists","every","some","sum","min","max","present","len","contains","startsWith","lower","today","now","date","days","hours","if","first","sort","either","fact"];var rn=(t,i,f,l)=>({severity:"error",code:t,path:i,message:f,...l?{fix:l}:{}}),on=(t,i,f,l)=>({severity:"warning",code:t,path:i,message:f,...l?{fix:l}:{}}),sn=t=>t.some(i=>i.severity==="error");function an(t){return t.map(i=>`${i.severity==="error"?"\u2717":i.severity==="warning"?"!":"\xB7"} ${i.path||"(document)"}: ${i.message}${i.fix?` \u2014 ${i.fix}`:""}`).join(`
|
|
2
|
+
`)}var cn=["money","percent","date","relative","upper","lower","count","words","and","plural"],J={getNode:()=>{},allNodes:()=>[],allEdges:()=>[],nodesOfKind:()=>[],edgesOfKind:()=>[],out:()=>[],in:()=>[],neighbors:()=>[],has:()=>!1};function fn(t,i,f,l=[],b){return j(t,i,f,l,b)}function Q(t,i={}){let f=Number.isInteger(t),l={maximumFractionDigits:f?0:2,minimumFractionDigits:f?0:2};try{return new Intl.NumberFormat(i.locale??"en-US",i.currency?{style:"currency",currency:i.currency,...l}:l).format(t)}catch{return t.toLocaleString("en-US",l)}}var W=["zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"],q=["","","twenty","thirty","forty","fifty","sixty","seventy","eighty","ninety"];function X(t){return!Number.isInteger(t)||t<0||t>99?t.toLocaleString("en-US",{maximumFractionDigits:2}):t<20?W[t]:t%10===0?q[t/10]:`${q[Math.floor(t/10)]}-${W[t%10]}`}function Z(t){return t.length<=1?t[0]??"":`${t.slice(0,-1).join(", ")} and ${t[t.length-1]}`}function v(t){return/[^aeiou]y$/i.test(t)?`${t.slice(0,-1)}ies`:/(s|x|z|ch|sh)$/i.test(t)?`${t}es`:`${t}s`}var C=t=>String(t.name??t.title??t.label??t.id);function j(t,i,f,l=[],b){if(i==="plural"){let A=t instanceof g?t.nodes.length:Array.isArray(t)?t.length:typeof t=="number"?t:null;return A===null||l[0]===void 0?"\u2014":A===1?l[0]:l[1]??v(l[0])}if(t===null)return"\u2014";if(t instanceof g)return i==="count"?String(t.nodes.length):i==="and"?Z(t.nodes.map(C)):t.nodes.map(C).join(", ");if(Array.isArray(t)){if(i==="count")return String(t.length);let A=t.map(w=>j(w,void 0,f,[],b));return i==="and"?Z(A):A.join(", ")}if(typeof t=="object")return C(t);switch(i){case"words":return typeof t=="number"?X(t):String(t);case"money":return typeof t=="number"?Q(t,b):String(t);case"percent":return typeof t=="number"?`${Math.round(t*100)}%`:String(t);case"upper":return String(t).toUpperCase();case"lower":return String(t).toLowerCase();case"date":return T(String(t).slice(0,10));case"relative":{let A=Date.parse(String(t).length===10?`${t}T00:00:00Z`:String(t));if(Number.isNaN(A))return String(t);let w=Math.round((A-Date.parse(`${f}T00:00:00Z`))/864e5);return w===0?"today":w===1?"tomorrow":w===-1?"yesterday":w>0?`in ${w} days`:`${-w} days ago`}default:return typeof t=="string"&&L.test(t)?T(t):String(t)}}function gn(t,i){let f=i.today??new Date().toISOString().slice(0,10);return t.map(l=>{if(l.text!==void 0)return l.text;try{let b=P(l.expr,{graph:i.graph??J,subject:i.node,kinds:i.kinds,today:f,budget:i.budget??500,...i.bindings?{bindings:i.bindings}:{}});return j(b,l.format,f,l.formatArgs,i.money)}catch(b){if(b instanceof c)return"\u2014";throw b}}).join("")}export{g as a,B as b,c,_ as d,P as e,tn as f,rn as g,on as h,sn as i,an as j,cn as k,J as l,fn as m,Q as n,gn as o};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import{a as k}from"./chunk.G4JJXA63.js";import{a as Q}from"./chunk.SQD7ZPEJ.js";import"./chunk.Q5WEOX3Q.js";import"./chunk.UNRYIETM.js";import"./chunk.6C7SJJQO.js";import{e as P}from"./chunk.DO4P2UK4.js";import"./chunk.6KJSFIO7.js";import"./chunk.FLJP3BGP.js";import{c as G}from"./chunk.ENMNLR73.js";import"./chunk.LZQZP2PD.js";import{Db as C,Eb as J,Fb as K,Gb as X,Qb as Y,pa as z,qa as H}from"./chunk.Y235YZSZ.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
|
+
`)}var Fe=['columns \u2014 a board, records in columns by one choice field: {"lens": "columns", "on": K, "bindings": {K: {"column": "<enum field>"}}}','calendar \u2014 records on a calendar by a date: {"lens": "calendar", "on": K, "bindings": {K: {"start": "<date field>", "end"?: "<date field>", "done"?: "<boolean field>"}}, "options": {"range"?: "day" | "week" | "month" | "quarter" | "year" | "agenda"}}','timeline \u2014 minutes of a day in columns: {"lens": "timeline", "on": K, "bindings": {K: {"start": "<number field>", "end": "<number field>", "column": "<enum field>"}}}','coverage \u2014 who covers what, a grid of two kinds joined by a relation: {"lens": "coverage", "on": K, "bindings": {"rows": {"kind": K}, "columns": {"kind": J}, "link": {"edge": "<relation of K to J>"}}}',`blocks \u2014 anything else, as blocks: {"lens": "blocks", "on": K, "options": {"blocks": [{"headline": "words"}, {"list": "all('K') where <condition>", "group"?: "<enum field>", "sort"?: "<field>" | {"by": "<field>", "direction": "desc"}, "as"?: "row" | "card", "empty"?: "words"}, {"figure": "count(all('K'))", "label": "words"}]}}. Conditions read a record's own fields: status == 'open', not done, days(today(), due) <= 7.`].join(`
|
|
3
|
+
`);function Ce(e,n,r){return["You draw a view of an app's data as JSON \u2014 never code. The app's kinds, their fields (with types) and relations:",Ne(n),"","The lenses you may use (prefer the first four; use blocks only when none of them fits):",Fe,"",r?`The view on screen now:
|
|
4
|
+
${JSON.stringify(r.lens)}
|
|
5
|
+
Change it as asked, and keep everything not asked about.`:"",`Asked: ${JSON.stringify(e)}`,'Answer with ONE JSON object: {"title": "<a few words, like Deliverables by status>", "lens": \u2026, "on": \u2026, "bindings"?: \u2026, "options"?: \u2026}. Name only the kinds, fields and relations listed above. If it cannot be drawn from them, answer {"failed": "<one sentence saying why>"}.'].filter(t=>t!=="").join(`
|
|
6
|
+
`)}async function le(e,n,r){let t=n.lastGood?{lastGood:n.lastGood}:{},s=j(O(n.app.schema,n.sight)),i;try{i=await n.complete(Ce(e,s,r))}catch{return{failed:"Couldn't draw that: the model did not answer.",...t}}let o=Q(i);if(typeof o!="object"||o===null||Array.isArray(o))return{failed:"Couldn't draw that: the model's answer was not a view.",...t};let a=o;if(typeof a.failed=="string")return{failed:`Couldn't draw that: ${a.failed.replace(/^Couldn't draw that:\s*/i,"").replace(/\.$/,"")}.`,...t};let l=de(a);if(!K(l.name))return{failed:`Couldn't draw that: "${l.name}" is not a picture the seat can draw.`,...t};let d=l.title?l.title.slice(0,80):r?.title??k(e.trim()).slice(0,80),c={...l,title:r&&r.title===d?d:q(d,n.app)},u=T(n.app,c,n.sight);return u.ok?{...V(n.app,c,u.drawn,n.sight,"model"),asks:[e]}:{failed:u.failed,...t}}function Qe(e,n,r){let t=[...e.lenses??[]];for(let s of n){let i={name:s.lens,title:s.title,on:s.on,...s.bindings?{bindings:s.bindings}:{},...s.options?{options:s.options}:{}};if(t.some(a=>a.title===i.title))continue;T({...e,lenses:t},i,r).ok&&(t=[...t,i])}return t.length===(e.lenses??[]).length?e:{...e,lenses:t}}async function Ze(e,n,r){let{app:t,drafts:s}=r,i=ue(t,r.principal),o=c=>{let u=de(c);return{lens:u,verdict:T(t,u,i)}};if(e==="keep_lens"){let{lens:c,verdict:u}=o(n);if(!u.ok)return{ok:!1,error:u.failed,reason:"invalid"};if(!s?.keep)return{ok:!1,error:"This app's declaration cannot be written from here."};let p=F(c),m=await s.keep(p);return m.ok?{ok:!0,data:{kept:p,said:m.said??`Adds \u201C${p.title}\u201D to the places.`,undo:ve(p)}}:{ok:!1,error:m.error}}if(n.lens!==void 0){let{lens:c,verdict:u}=o(n.lens);return u.ok?{ok:!0,data:te(V(t,c,u.drawn,i,"model"))}:{ok:!1,error:u.failed,reason:"invalid"}}let a={app:t,sight:i,...s?.complete?{complete:s.complete}:{}},l=String(n.ask??""),d;if(n.current!==void 0){let{lens:c,verdict:u}=o(n.current);if(!u.ok)return{ok:!1,error:u.failed,reason:"invalid"};d=await je(V(t,c,u.drawn,i,"model"),l,a)}else d=await Oe(l,a);return L(d)?{ok:!1,error:d.failed,reason:"invalid"}:{ok:!0,data:te(d)}}export{te as draftAnswer,V as draftFromLens,ue as draftSight,Oe as draftView,L as isDraftFailure,T as judgeLens,F as lensEditOf,de as lensFromSpec,xe as recipeOfLens,je as refineDraft,Ze as runDraftTool,ve as takeBackEditOf,Ie as templateDraft,Qe as withReaderLenses};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import{a as _}from"./chunk.AJZBJBMO.js";var Y=_(u=>{"use strict";var R=Symbol.for("react.transitional.element"),U=Symbol.for("react.portal"),D=Symbol.for("react.fragment"),q=Symbol.for("react.strict_mode"),b=Symbol.for("react.profiler"),z=Symbol.for("react.consumer"),G=Symbol.for("react.context"),B=Symbol.for("react.forward_ref"),W=Symbol.for("react.suspense"),Q=Symbol.for("react.memo"),h=Symbol.for("react.lazy"),X=Symbol.for("react.activity"),S=Symbol.iterator;function Z(t){return t===null||typeof t!="object"?null:(t=S&&t[S]||t["@@iterator"],typeof t=="function"?t:null)}var O={isMounted:function(){return!1},enqueueForceUpdate:function(){},enqueueReplaceState:function(){},enqueueSetState:function(){}},H=Object.assign,g={};function E(t,e,n){this.props=t,this.context=e,this.refs=g,this.updater=n||O}E.prototype.isReactComponent={};E.prototype.setState=function(t,e){if(typeof t!="object"&&typeof t!="function"&&t!=null)throw Error("takes an object of state variables to update or a function which returns an object of state variables.");this.updater.enqueueSetState(this,t,e,"setState")};E.prototype.forceUpdate=function(t){this.updater.enqueueForceUpdate(this,t,"forceUpdate")};function N(){}N.prototype=E.prototype;function m(t,e,n){this.props=t,this.context=e,this.refs=g,this.updater=n||O}var C=m.prototype=new N;C.constructor=m;H(C,E.prototype);C.isPureReactComponent=!0;var j=Array.isArray;function T(){}var i={H:null,A:null,T:null,S:null},$=Object.prototype.hasOwnProperty;function d(t,e,n){var r=n.ref;return{$$typeof:R,type:t,key:e,ref:r!==void 0?r:null,props:n}}function J(t,e){return d(t.type,e,t.props)}function A(t){return typeof t=="object"&&t!==null&&t.$$typeof===R}function V(t){var e={"=":"=0",":":"=2"};return"$"+t.replace(/[=:]/g,function(n){return e[n]})}var w=/\/+/g;function v(t,e){return typeof t=="object"&&t!==null&&t.key!=null?V(""+t.key):e.toString(36)}function K(t){switch(t.status){case"fulfilled":return t.value;case"rejected":throw t.reason;default:switch(typeof t.status=="string"?t.then(T,T):(t.status="pending",t.then(function(e){t.status==="pending"&&(t.status="fulfilled",t.value=e)},function(e){t.status==="pending"&&(t.status="rejected",t.reason=e)})),t.status){case"fulfilled":return t.value;case"rejected":throw t.reason}}throw t}function l(t,e,n,r,o){var s=typeof t;(s==="undefined"||s==="boolean")&&(t=null);var f=!1;if(t===null)f=!0;else switch(s){case"bigint":case"string":case"number":f=!0;break;case"object":switch(t.$$typeof){case R:case U:f=!0;break;case h:return f=t._init,l(f(t._payload),e,n,r,o)}}if(f)return o=o(t),f=r===""?"."+v(t,0):r,j(o)?(n="",f!=null&&(n=f.replace(w,"$&/")+"/"),l(o,e,n,"",function(L){return L})):o!=null&&(A(o)&&(o=J(o,n+(o.key==null||t&&t.key===o.key?"":(""+o.key).replace(w,"$&/")+"/")+f)),e.push(o)),1;f=0;var p=r===""?".":r+":";if(j(t))for(var c=0;c<t.length;c++)r=t[c],s=p+v(r,c),f+=l(r,e,n,s,o);else if(c=Z(t),typeof c=="function")for(t=c.call(t),c=0;!(r=t.next()).done;)r=r.value,s=p+v(r,c++),f+=l(r,e,n,s,o);else if(s==="object"){if(typeof t.then=="function")return l(K(t),e,n,r,o);throw e=String(t),Error("Objects are not valid as a React child (found: "+(e==="[object Object]"?"object with keys {"+Object.keys(t).join(", ")+"}":e)+"). If you meant to render a collection of children, use an array instead.")}return f}function a(t,e,n){if(t==null)return t;var r=[],o=0;return l(t,r,"","",function(s){return e.call(n,s,o++)}),r}function F(t){if(t._status===-1){var e=t._result;e=e(),e.then(function(n){(t._status===0||t._status===-1)&&(t._status=1,t._result=n)},function(n){(t._status===0||t._status===-1)&&(t._status=2,t._result=n)}),t._status===-1&&(t._status=0,t._result=e)}if(t._status===1)return t._result.default;throw t._result}var P=typeof reportError=="function"?reportError:function(t){if(typeof window=="object"&&typeof window.ErrorEvent=="function"){var e=new window.ErrorEvent("error",{bubbles:!0,cancelable:!0,message:typeof t=="object"&&t!==null&&typeof t.message=="string"?String(t.message):String(t),error:t});if(!window.dispatchEvent(e))return}else if(typeof process=="object"&&typeof process.emit=="function"){process.emit("uncaughtException",t);return}console.error(t)},tt={map:a,forEach:function(t,e,n){a(t,function(){e.apply(this,arguments)},n)},count:function(t){var e=0;return a(t,function(){e++}),e},toArray:function(t){return a(t,function(e){return e})||[]},only:function(t){if(!A(t))throw Error("React.Children.only expected to receive a single React element child.");return t}};u.Activity=X;u.Children=tt;u.Component=E;u.Fragment=D;u.Profiler=b;u.PureComponent=m;u.StrictMode=q;u.Suspense=W;u.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE=i;u.__COMPILER_RUNTIME={__proto__:null,c:function(t){return i.H.useMemoCache(t)}};u.cache=function(t){return function(){return t.apply(null,arguments)}};u.cacheSignal=function(){return null};u.cloneElement=function(t,e,n){if(t==null)throw Error("The argument must be a React element, but you passed "+t+".");var r=H({},t.props),o=t.key;if(e!=null)for(s in e.key!==void 0&&(o=""+e.key),e)!$.call(e,s)||s==="key"||s==="__self"||s==="__source"||s==="ref"&&e.ref===void 0||(r[s]=e[s]);var s=arguments.length-2;if(s===1)r.children=n;else if(1<s){for(var f=Array(s),p=0;p<s;p++)f[p]=arguments[p+2];r.children=f}return d(t.type,o,r)};u.createContext=function(t){return t={$$typeof:G,_currentValue:t,_currentValue2:t,_threadCount:0,Provider:null,Consumer:null},t.Provider=t,t.Consumer={$$typeof:z,_context:t},t};u.createElement=function(t,e,n){var r,o={},s=null;if(e!=null)for(r in e.key!==void 0&&(s=""+e.key),e)$.call(e,r)&&r!=="key"&&r!=="__self"&&r!=="__source"&&(o[r]=e[r]);var f=arguments.length-2;if(f===1)o.children=n;else if(1<f){for(var p=Array(f),c=0;c<f;c++)p[c]=arguments[c+2];o.children=p}if(t&&t.defaultProps)for(r in f=t.defaultProps,f)o[r]===void 0&&(o[r]=f[r]);return d(t,s,o)};u.createRef=function(){return{current:null}};u.forwardRef=function(t){return{$$typeof:B,render:t}};u.isValidElement=A;u.lazy=function(t){return{$$typeof:h,_payload:{_status:-1,_result:t},_init:F}};u.memo=function(t,e){return{$$typeof:Q,type:t,compare:e===void 0?null:e}};u.startTransition=function(t){var e=i.T,n={};i.T=n;try{var r=t(),o=i.S;o!==null&&o(n,r),typeof r=="object"&&r!==null&&typeof r.then=="function"&&r.then(T,P)}catch(s){P(s)}finally{e!==null&&n.types!==null&&(e.types=n.types),i.T=e}};u.unstable_useCacheRefresh=function(){return i.H.useCacheRefresh()};u.use=function(t){return i.H.use(t)};u.useActionState=function(t,e,n){return i.H.useActionState(t,e,n)};u.useCallback=function(t,e){return i.H.useCallback(t,e)};u.useContext=function(t){return i.H.useContext(t)};u.useDebugValue=function(){};u.useDeferredValue=function(t,e){return i.H.useDeferredValue(t,e)};u.useEffect=function(t,e){return i.H.useEffect(t,e)};u.useEffectEvent=function(t){return i.H.useEffectEvent(t)};u.useId=function(){return i.H.useId()};u.useImperativeHandle=function(t,e,n){return i.H.useImperativeHandle(t,e,n)};u.useInsertionEffect=function(t,e){return i.H.useInsertionEffect(t,e)};u.useLayoutEffect=function(t,e){return i.H.useLayoutEffect(t,e)};u.useMemo=function(t,e){return i.H.useMemo(t,e)};u.useOptimistic=function(t,e){return i.H.useOptimistic(t,e)};u.useReducer=function(t,e,n){return i.H.useReducer(t,e,n)};u.useRef=function(t){return i.H.useRef(t)};u.useState=function(t){return i.H.useState(t)};u.useSyncExternalStore=function(t,e,n){return i.H.useSyncExternalStore(t,e,n)};u.useTransition=function(){return i.H.useTransition()};u.version="19.2.8"});var et=_((st,k)=>{"use strict";k.exports=Y()});var x=_(y=>{"use strict";var nt=Symbol.for("react.transitional.element"),rt=Symbol.for("react.fragment");function M(t,e,n){var r=null;if(n!==void 0&&(r=""+n),e.key!==void 0&&(r=""+e.key),"key"in e){n={};for(var o in e)o!=="key"&&(n[o]=e[o])}else n=e;return e=n.ref,{$$typeof:nt,type:t,key:r,ref:e!==void 0?e:null,props:n}}y.Fragment=rt;y.jsx=M;y.jsxs=M});var ut=_((it,I)=>{"use strict";I.exports=x()});export{et as a,ut as b};
|
|
2
|
+
/*! Bundled license information:
|
|
3
|
+
|
|
4
|
+
react/cjs/react.production.js:
|
|
5
|
+
(**
|
|
6
|
+
* @license React
|
|
7
|
+
* react.production.js
|
|
8
|
+
*
|
|
9
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
10
|
+
*
|
|
11
|
+
* This source code is licensed under the MIT license found in the
|
|
12
|
+
* LICENSE file in the root directory of this source tree.
|
|
13
|
+
*)
|
|
14
|
+
|
|
15
|
+
react/cjs/react-jsx-runtime.production.js:
|
|
16
|
+
(**
|
|
17
|
+
* @license React
|
|
18
|
+
* react-jsx-runtime.production.js
|
|
19
|
+
*
|
|
20
|
+
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
|
21
|
+
*
|
|
22
|
+
* This source code is licensed under the MIT license found in the
|
|
23
|
+
* LICENSE file in the root directory of this source tree.
|
|
24
|
+
*)
|
|
25
|
+
*/
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{b as K}from"./chunk.6CLHFNDM.js";import{a as se}from"./chunk.R5K7NK4U.js";import{a as V}from"./chunk.BQV62QEL.js";import{l as ie,m as G}from"./chunk.DAKED3WK.js";import{f as _,g as N,h as B}from"./chunk.ACZGK7LQ.js";import{Aa as ae,W as ee,a as O,ca as D,da as te,ea as ne,pa as oe,ra as re,ya as F}from"./chunk.4JSMCNF7.js";import{P as J,Q,pb as Z,ub as z}from"./chunk.Y235YZSZ.js";import{a as $,b as T}from"./chunk.MRK6QJV5.js";import{b as k}from"./chunk.AJZBJBMO.js";var i=k($(),1);var x=k(T(),1),le=336,w=16,ue=640,L=F(O(()=>import("./chunk.THBP5EES.js"))),fe=L.part((t,n)=>{let s=t.SeatPanel;return(0,x.jsx)(s,{...n})},{what:"The conversation"});function xe({respond:t,onCall:n,onPick:s,start:g="field",onMove:l,place:S,onDraft:h}){let{brand:r,seatTalk:d}=D(),f=ee(d),m=r?.name?.trim()||"this app",y=(0,i.useRef)(null),o=(0,i.useRef)(null),[a,c]=(0,i.useState)(""),[v,P]=(0,i.useState)(!1),C=(0,i.useRef)(null),b=g==="hidden",p=f.open&&!b;(0,i.useEffect)(()=>b?void 0:d.drawn(),[d,b]),(0,i.useLayoutEffect)(()=>{let e=y.current?.parentElement;if(!e)return;let E=()=>P(e.getBoundingClientRect().width<ue);if(E(),typeof ResizeObserver>"u")return;let M=new ResizeObserver(E);return M.observe(e),()=>M.disconnect()},[b]),(0,i.useEffect)(()=>{typeof window<"u"&&window.dispatchEvent(new Event(se))},[p,f.side,v]),(0,i.useEffect)(()=>{let e=y.current;if(b||p||!e||typeof window>"u")return;let E=(e.closest("[data-graview-embed]")??document.documentElement).style,M=()=>{let Y=e.getBoundingClientRect(),X=e.offsetParent?.getBoundingClientRect(),ce=X?X.bottom-Y.top:Y.height+w;E.setProperty("--graview-foot-room",`${Math.max(0,Math.round(ce+w))}px`)};M();let U=typeof ResizeObserver>"u"?null:new ResizeObserver(M);return U?.observe(e),()=>{U?.disconnect(),E.removeProperty("--graview-foot-room")}},[b,p,v,f.side]),(0,i.useEffect)(()=>{!p||f.pending===null||(j(),o.current?.focus({preventScroll:!0}))},[p,f.pending]);let j=()=>{let e=typeof document>"u"?null:document.activeElement;e instanceof HTMLElement&&e!==document.body&&!y.current?.contains(e)&&(C.current=e)},H=()=>{j(),L.prefetch(),d.setOpen(!0)},q=()=>{d.setOpen(!1);let e=C.current;C.current=null,e?.isConnected&&e.focus({preventScroll:!0}),document.activeElement!==e&&o.current?.focus({preventScroll:!0})};if(b)return null;let R=!v&&f.side==="right",pe=v?p?{left:0,right:0,bottom:0,padding:"8px 12px calc(12px + env(safe-area-inset-bottom, 0px))",borderRadius:"12px 12px 0 0",...de}:{left:w,right:w,bottom:`calc(${w}px + env(safe-area-inset-bottom, 0px))`}:p?{[R?"right":"left"]:w/2-1,bottom:w/2-1,width:le+w+2,padding:w/2,borderRadius:12,...de}:{[R?"right":"left"]:w,bottom:w,width:le};return(0,x.jsxs)("section",{ref:y,role:"region","aria-label":`Ask ${m}`,"data-testid":"seat","data-graview-seat":p?"open":"closed","data-graview-seat-side":R?"right":"left","data-graview-seat-shape":v?"phone":"desk","data-graview-foot":"","data-graview-offstage":"",onMouseDown:e=>e.stopPropagation(),onKeyDown:e=>{e.key!=="Escape"||!p||(e.preventDefault(),e.stopPropagation(),q())},style:{position:"absolute",zIndex:z("rail"),boxSizing:"border-box",display:"flex",flexDirection:"column",gap:8,pointerEvents:"auto",...pe},children:[(0,x.jsxs)("h2",{style:{...ae,margin:0},children:["Ask ",m]}),p?(0,x.jsx)(i.Suspense,{fallback:null,children:(0,x.jsx)(fe,{phone:v,side:R?"right":"left",name:m,onClose:q,...t?{respond:t}:{},...n?{onCall:n}:{},...s?{onPick:s}:{},...l?{onMove:l}:{},...S?{place:S}:{},...h?{onDraft:h}:{}})}):null,(0,x.jsx)("form",{onSubmit:e=>{e.preventDefault();let E=a.trim();p||H(),!(!E||f.busy)&&(d.ask(E),c(""))},style:{display:"flex",margin:0},children:(0,x.jsx)("input",{ref:o,"data-testid":"seat-field",type:"text",enterKeyHint:"send",autoComplete:"off",value:a,placeholder:`Ask ${m}\u2026`,"aria-label":`Ask ${m}`,onPointerEnter:()=>L.prefetch(),onFocus:()=>L.prefetch(),onClick:()=>{p||H()},onChange:e=>{c(e.target.value),p||H()},style:{flex:"1 1 auto",minWidth:0,boxSizing:"border-box",height:38,padding:"0 12px",font:"inherit",fontSize:"0.9375rem",color:"var(--graview-ink)",background:"var(--graview-panel)",border:"1px solid var(--graview-edge)",borderRadius:8}})})]})}var de={background:"var(--graview-float)",border:"1px solid var(--graview-edge)",boxShadow:"var(--graview-lift-high)"};var W=k($(),1),I=k(T(),1),me=F(O(()=>import("./chunk.XYZ7KAMZ.js"))),ge=me.part((t,n)=>{let s=t.DraftFrame;return(0,I.jsx)(s,{...n})},{what:"The view"});function Te(t){let{seatTalk:n}=D();return(0,W.useSyncExternalStore)(n.subscribe,()=>n.get().draft!==null,()=>!1)?(0,I.jsx)(W.Suspense,{fallback:null,children:(0,I.jsx)(ge,{...t})}):null}function Re(t={}){return t.scope===void 0?V:K(V,t.scope)}var A=k($(),1),u=k(T(),1);function We({inside:t=!1}={}){let{store:n,view:s,emphasis:g,setEmphasis:l}=D(),S=ie(),{selection:h,set:r}=oe(),{show:d}=re(),f=ne(),m=(0,A.useMemo)(()=>{let o=new Map;for(let a of n.graph.allEdges()){let c=o.get(a.kind)??{count:0,ends:new Set};c.count+=1;for(let v of[a.from,a.to]){let P=n.graph.getNode(v);P&&c.ends.add(`kind:${P.kind}`)}o.set(a.kind,c)}return[...o.entries()].sort(([a],[c])=>a.localeCompare(c)).map(([a,c])=>({kind:a,count:c.count,ends:[...c.ends]}))},[n,f]);if((0,A.useEffect)(()=>()=>l(null),[l]),!s.overview&&!t||m.length===0)return null;let y=new Set;for(let o of h){if(o.startsWith("kind:")){y.add(o);continue}let a=n.graph.getNode(o);a&&y.add(`kind:${a.kind}`)}return(0,u.jsxs)("section",{"aria-label":"What the lines mean",role:t?"group":void 0,"data-testid":"relation-key",style:t?{display:"grid",gap:1}:{position:"absolute",left:16,top:14,zIndex:z("rail"),display:"grid",gap:1,padding:"8px 10px",borderRadius:10,border:"1px solid var(--graview-edge)",background:"var(--graview-float)",boxShadow:"var(--graview-lift-low)",maxWidth:he,animation:"graview-settle 380ms 280ms ease backwards"},children:[t?null:(0,u.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.16em",textTransform:"uppercase",color:"var(--graview-ink-faint)",paddingBottom:2},children:m.length===1?"1 relation":`${m.length} relations`}),m.map(({kind:o,count:a,ends:c})=>{let{connector:v,style:P}=G(S,o),C=ye(n.schema,o),b=g!==null?g===o:y.size===0||c.some(p=>y.has(p));return(0,u.jsxs)("button",{type:"button",title:n.schema.edge(o)?.description===void 0?`${a} of these`:C.words,onMouseEnter:()=>l(o),onMouseLeave:()=>l(null),onFocus:()=>l(o),onBlur:()=>l(null),onClick:()=>{r(c),d(null)},style:{all:"unset",outline:"revert-layer",cursor:"pointer",display:"grid",gridTemplateColumns:"30px 1fr auto",alignItems:"center",gap:8,minHeight:23,padding:"2px 4px",borderRadius:6,opacity:b?1:.4},children:[(0,u.jsx)("svg",{width:"30",height:"8","aria-hidden":"true",style:{display:"block",opacity:v.visible?1:.35},children:(0,u.jsx)("path",{d:"M 1 4 L 29 4",fill:"none",stroke:N(P),strokeWidth:B(P,!0),strokeDasharray:_[P.pattern],strokeLinecap:"round"})}),(0,u.jsxs)("span",{style:{display:"grid",minWidth:0},"data-graview-relation-words":o,children:[(0,u.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink)"},children:C.words}),(0,u.jsx)("span",{style:{fontSize:"0.6875rem",color:"var(--graview-ink-faint)"},children:C.ends})]}),v.visible?null:(0,u.jsx)("span",{"data-graview-quiet":o,style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",fontStyle:"italic"},children:"not drawn"}),(0,u.jsx)("span",{style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)",fontVariantNumeric:"tabular-nums"},children:a})]},o)})]})}var he="min(280px, calc(100% - 28px))";function ye(t,n,s){let g=t.edge(n)?.from??[],l=new Map;for(let r of s!==void 0&&g.includes(s)?[s]:g.length>0?g:[""]){let d=Q(t,r,n,"out");l.set(d,[...l.get(d)??[],r])}let S=r=>r==="*"?"anything":J(t,r),h=[...l].map(([r,d])=>{let f=d.flatMap(y=>t.tryDefinition(y)?.edges[n]?.to??[]),m=d[0]&&f.length>0?`${d.map(S).join(", ")} \u2192 ${(f.includes("*")?["*"]:[...new Set(f)]).map(S).join(", ")}`:"";return[r.charAt(0).toUpperCase()+r.slice(1),m]});return{words:h.map(([r])=>r).join(" \xB7 "),ends:h.flatMap(([,r])=>r?[r]:[]).join(" \xB7 ")}}function He({edgeKind:t,kit:n,width:s=30}){let g=te(),l=(0,A.useMemo)(()=>Z(n??g?.brand?.kit),[n,g?.brand?.kit]),{connector:S,style:h}=G(l,t);return(0,u.jsx)("svg",{width:s,height:"8","aria-hidden":"true","data-testid":"relation-mark","data-graview-relation":t,style:{display:"inline-block",verticalAlign:"middle",opacity:S.visible?1:.35},children:(0,u.jsx)("path",{d:`M 1 4 L ${s-1} 4`,fill:"none",stroke:N(h),strokeWidth:B(h,!0),strokeDasharray:_[h.pattern],strokeLinecap:"round"})})}export{xe as a,Te as b,We as c,he as d,He as e,Re as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function d(e,t){let a=e.batches();for(let i=a.length-1;i>=0;i--){let n=a[i];if(n.undone||n.ops.length===0||n.ops.every(o=>o.undoes!==void 0))continue;let c=n.author;if(!(c.kind==="human"&&(t?.id===void 0||c.id===void 0||c.id===t.id)))continue;let r=e.canUndo(n.id);if(!(!r.ok||!r.ops.every(o=>!o.mutation||e.permits(o.mutation,t).ok)))return{batch:n.id,intent:n.intent}}}function h(e,t,a){let i=d(e,t);return i&&e.batches().slice(a).some(n=>n.id===i.batch)?i:void 0}var f=e=>`Take back \u201C${e.intent}\u201D`;function m(e,t){let a=d(e,t);return a&&e.undo(a.batch,t?{author:t}:{}),a}function l(e){let t=e.target;return!e.defaultPrevented&&!e.altKey&&!e.shiftKey&&(e.metaKey||e.ctrlKey)&&e.key.toLowerCase()==="z"&&!(t instanceof HTMLElement&&(t.isContentEditable||t.matches("input, textarea, select")))}export{d as a,h as b,f as c,m as d,l as e};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as x,c as G}from"./chunk.7YCQZJGB.js";import"./chunk.AZG6V3PF.js";import"./chunk.6CLHFNDM.js";import"./chunk.WGNF4E67.js";import"./chunk.R5K7NK4U.js";import"./chunk.AHDOKM4O.js";import{C as O,c as b,d as P,j as v,x as k,z as I}from"./chunk.4JSMCNF7.js";import{La as S,Lb as W,wa as A,xa as E}from"./chunk.Y235YZSZ.js";import"./chunk.MRK6QJV5.js";import"./chunk.AJZBJBMO.js";var $=(e,i)=>S(e,i).slice(1);function V(e,i){let l=e.split("/").filter(Boolean);return l.length===i.length&&l.every((a,f)=>a.startsWith(":")||a==="*"||a===i[f])}var R=["problems","search","map","places"];function j(e,i,l,a,f=[]){let{schema:r}=i,o=r.kinds,h=t=>{if(t.startsWith(k))return(t.slice(k.length).split("|")[0]??"").split("+").every(U=>o.includes(U));let y=I(t);return y!==null?o.includes(y):t.startsWith("edge:")||l.graph.getNode(t)!==void 0},[p="/",u]=e.path.split("?"),n=p.split("/").filter(Boolean),m=u?`?${u}`:"",d=n.length>0&&!R.includes(n[0])?o.find(t=>$(r,t)===n[0]):void 0,c=e.path;if(n[0]==="places"&&n.length===2)`/places/${n[1]}`!==W&&!a.some(t=>t.as===decodeURIComponent(n[1]))&&(c="/");else if(d){let t=n[1]===void 0?void 0:decodeURIComponent(n[1]);c=`/${$(r,d)}${t!==void 0&&l.graph.getNode(t)?.kind===d?`/${n[1]}`:""}${m}`}else n.length>0&&n.length<=2&&!R.includes(n[0])&&!f.some(t=>V(t.path,n))&&(c="/");let g=P(e.stop),w=g.within?.view,F=w!==void 0&&!a.some(t=>t.as===w),s=g;if(F){let{view:t,...y}=g.within??{};s={...s,within:y}}if(g.focusId&&!h(g.focusId)){let t=e.kind&&o.includes(e.kind)?O(e.kind):null;s={...v(s,t),zoom:!1}}return s={...s,relation:s.relation&&(o.includes(s.relation)||r.edgeKinds.includes(s.relation))?s.relation:null,expanded:s.expanded.filter(h),pins:Object.fromEntries(Object.entries(s.pins).filter(([t])=>h(t))),...s.selection?{selection:s.selection.filter(h)}:{}},{face:e.face,path:c,stop:b(s),...e.kind?{kind:e.kind}:{}}}function B(e,i,l){let a=e.at,f=e.pages?.routes()??[];if(e.routing!=="address"||typeof window>"u")return j(a,e.app,i,l,f);let{pathname:r,search:o,hash:h}=window.location,p=E(r,e.basePath),u=x({routing:"address",...e.basePath===void 0?{}:{basePath:e.basePath},face:a.face}),n=u==="pages",m={...a,face:u,...p===null?{}:n?{path:p+o}:{stop:G(e.basePath)??a.stop}},d=j(m,e.app,i,l,f),c=n?d.path===m.path?null:A(d.path,e.basePath===void 0?{}:{basePath:e.basePath}):d.stop===b(P(m.stop))?null:r+o+d.stop;return p!==null&&c!==null&&c!==r+o+h&&window.history.replaceState(window.history.state,"",c),d}export{j as settle,B as settleAt};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{c as a,l as o}from"./chunk.CJQL7AHT.js";import"./chunk.BQV62QEL.js";import"./chunk.DAKED3WK.js";import"./chunk.WWRWXFYR.js";import"./chunk.ZFUQA3KT.js";import"./chunk.DO4P2UK4.js";import"./chunk.6KJSFIO7.js";import"./chunk.FLJP3BGP.js";import"./chunk.ENMNLR73.js";import"./chunk.LZQZP2PD.js";import"./chunk.SCLIBKLS.js";import"./chunk.ACZGK7LQ.js";import"./chunk.AHDOKM4O.js";import"./chunk.3MLQ3Q5X.js";import"./chunk.LGUV2J6Q.js";import{la as n}from"./chunk.4JSMCNF7.js";import"./chunk.Y235YZSZ.js";import"./chunk.MRK6QJV5.js";import"./chunk.AJZBJBMO.js";var w=new WeakMap;function p(e,i){let t=w.get(e);t||w.set(e,t=new Map);let r=t.get(i);return r||t.set(i,r=o(a(e,n(e)),e,i)),r}export{p as frameworkViews};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function t(n){if(Array.isArray(n))return n.map(t);if(n&&typeof n=="object"){let r={};for(let o of Object.keys(n).sort()){let e=n[o];e!==void 0&&(r[o]=t(e))}return r}return n}function i(n){return JSON.stringify(t(n))??"undefined"}export{i as a};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as c,b as d,c as e,d as f,e as g,f as h,g as i}from"./chunk.YAONM74M.js";import{a,b}from"./chunk.3MLQ3Q5X.js";import"./chunk.LGUV2J6Q.js";import"./chunk.4JSMCNF7.js";import"./chunk.Y235YZSZ.js";import"./chunk.MRK6QJV5.js";import"./chunk.AJZBJBMO.js";export{c as ARRANGE_NARROW,h as ArrangeBar,i as arrangementCaption,a as arrangementOf,f as directionWords,e as inSentence,g as preloadArrangeLists,d as sayCondition,b as withArrangement};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as g,ya as w}from"./chunk.4JSMCNF7.js";import{Gb as L}from"./chunk.Y235YZSZ.js";import{a as C,b as V}from"./chunk.MRK6QJV5.js";import{b as u}from"./chunk.AJZBJBMO.js";var E="[data-graview-foot]",N="graview:foot-moved";var D=()=>({width:document.documentElement.clientWidth||innerWidth,height:innerHeight});function j(t,e){let o=D(),r=e?.getBoundingClientRect()??{left:0,top:0,right:o.width,bottom:o.height},i=Math.max(0,r.left),c=Math.min(o.width,r.right),s=Math.max(0,r.top),l=Math.min(o.height,r.bottom),m=Math.max(0,c-i),x=m<640;t.style.translate="none",t.style.top="auto",t.style.right="auto",t.style.maxWidth=`${Math.max(0,Math.min(560,m-2*16))}px`;let p=t.getBoundingClientRect();if(p.width===0&&p.height===0&&t.style.left!=="")return;let f=p.width,A=p.height;t.style.visibility=e&&l-s<A+16?"hidden":"";let h=x?i+(m-f)/2:i+16,y=o.height-l+16,v=[...document.querySelectorAll(E)].filter(n=>n!==t&&!t.contains(n)&&!n.contains(t)).map(n=>n.getBoundingClientRect()).filter(n=>n.width>0&&n.height>0&&n.right>i&&n.left<c&&n.bottom>s&&n.top<l),P=n=>n.bottom-n.top>(l-s)*.4;if(!x)for(let n of v)P(n)&&n.left<=h+1&&n.right+16>h&&n.right+16+f<=c&&(h=n.right+16);let R=v.filter(n=>!P(n));for(let n=!0,b=0;n&&b<R.length+1;b++){n=!1;for(let d of R){let M=o.height-y;d.right>h&&d.left<h+f&&d.bottom>M-A&&d.top<M&&(y=o.height-d.top+16/2,n=!0)}}t.style.left=`${Math.round(h)}px`,t.style.bottom=`calc(${Math.round(y)}px + env(safe-area-inset-bottom, 0px))`}function z(t,e){let o=D(),r=e?.getBoundingClientRect()??{left:0,top:0,right:o.width,bottom:o.height},i=Math.max(0,r.left),c=Math.min(o.width,r.right),s=Math.max(0,c-i);t.style.translate="none",t.style.bottom="auto",t.style.right="auto",t.style.maxWidth=`${Math.max(0,Math.min(560,s-2*16))}px`;let l=t.getBoundingClientRect().width;t.style.left=`${Math.round(i+(s-l)/2)}px`,t.style.top=`${Math.round(Math.max(16/2,r.top+16/2))}px`}var O=t=>`graview:lenses:${t}`,q=(t,e)=>t?.name??e.kinds.join(",");function k(t){try{let e=JSON.parse(localStorage.getItem(O(t))??"[]");return Array.isArray(e)?e.filter(o=>typeof o?.title=="string"&&typeof o.lens=="string"):[]}catch{return[]}}var S=u(C(),1);var a=u(V(),1),G=w(g(()=>import("./chunk.YU64JSAL.js")));function B({lens:t,view:e}){let o=G.current.declaredLensView(t);return(0,a.jsx)(o,{...e})}var K=G.part((t,e)=>(0,a.jsx)(B,{...e}),{what:"This picture"});function $(t){return o=>(0,a.jsx)(S.Suspense,{fallback:null,children:(0,a.jsx)(K,{lens:t,view:o})})}var T=w(g(()=>import("./chunk.4CDEIDKB.js")));function W({blocks:t,view:e}){let o=T.current.homeView(t);return(0,a.jsx)(o,{...e})}var _=T.part((t,e)=>(0,a.jsx)(W,{...e}),{what:"The home"});function F(t){let e=o=>(0,a.jsx)(S.Suspense,{fallback:null,children:(0,a.jsx)(_,{blocks:t,view:o})});return Object.defineProperty(e,Symbol.for("graview.home-blocks"),{value:!0}),e}function tt(t,e){return e.home&&e.home.length>0&&t.home?.(F(e.home)),H(t,e),t.arrange?.(e.pages),t}function H(t,e,o){for(let r of L(e).drawn){if(o&&t.places().some(s=>s.title===r.title))continue;let i=$(r),c={title:r.title,...r.across?{across:r.across}:{},...o?{beside:o}:{}};for(let s of r.kinds)t.register(s,{cardinality:"many",fidelity:"full"},i,c),t.register(s,{cardinality:"many",fidelity:"summary"},i,c)}}function I(t,e,o){o.length>0&&H(t,{schema:e,lenses:o.map(({lens:r,...i})=>({...i,name:r}))},!0)}function et(t,e,o){I(t,e,k(o))}export{N as a,j as b,z as c,O as d,q as e,k as f,tt as g,I as h,et as i};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as p}from"./chunk.AHDOKM4O.js";import{ab as u}from"./chunk.Y235YZSZ.js";import{b as c}from"./chunk.MRK6QJV5.js";import{b as h}from"./chunk.AJZBJBMO.js";var s={person:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><circle cx="11.6" cy="5.4" r="2.5"/><path d="M7.9 12.4c0-2.1 1.7-3.8 3.7-3.8s3.7 1.7 3.7 3.8v3.2H7.9z"/><path d="M8 12.6 6.4 17.2"/><path d="M15.2 12.6 16.8 17.2"/><path d="M9.8 15.6v5"/><path d="M13.4 15.6v5"/></svg>',plot:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M2.6 9.4 12 4.6l9.4 4.8-9.4 4.8z"/><path d="M2.6 9.4v4.4l9.4 4.8 9.4-4.8V9.4"/><path d="M12 14.2v4.4"/><path d="M7 11.9v3"/><path d="M17 11.9v3"/></svg>',box:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M3.4 7.9 12 3.6l8.6 4.3-8.6 4.3z"/><path d="M3.4 7.9v8.2L12 20.4l8.6-4.3V7.9"/><path d="M12 12.2v8.2"/></svg>',task:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M4.4 6.6 12 2.9l7.6 3.7v9.5L12 19.8 4.4 16.1z"/><path d="M12 12.4v7.4"/><path d="M4.4 6.6 12 10.3l7.6-3.7"/><path d="M8 9.6l2.4 2.4L16 8.4"/></svg>',shift:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M3.2 8.2 12 4l8.8 4.2-8.8 4.2z"/><path d="M3.2 8.2v7.2L12 19.6l8.8-4.2V8.2"/><path d="M12 12.4v7.2"/><path d="M6.6 10.8v3.4"/><path d="M9.3 12v3.4"/></svg>',list:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M2.8 10.4 12 6l9.2 4.4-9.2 4.4z"/><path d="M2.8 10.4v3.2L12 18l9.2-4.4v-3.2"/><path d="M6.6 8.6 15.8 13"/><path d="M9.4 7.2 18.6 11.6"/></svg>',vehicle:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M2.8 14.2 5 9.4l8.6-1.6 5.4 3-1 3.6z"/><path d="M2.8 14.2v2.2h2.4"/><path d="M18 16.4h1.9l.1-2.2"/><circle cx="7.6" cy="16.6" r="1.9"/><circle cx="16.1" cy="16.6" r="1.9"/><path d="M8.6 8.2 9.8 12l7.2-1"/></svg>',rule:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M5.4 19.4V6.6l12 12.8z"/><path d="M5.4 6.6 7.6 5.5l12 12.8-2.2 1.1"/><path d="M5.4 19.4 7.6 18.3h12"/><path d="M5.4 10.1h1.7"/><path d="M5.4 13.3h1.7"/><path d="M5.4 16.5h1.7"/></svg>',note:'<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="1.4" stroke-linecap="round" stroke-linejoin="round"><path d="M6.2 6.2 14.8 10.5v9L6.2 15.2z"/><path d="M12.4 9.3 14.8 10.5l-.6 2.3"/><path d="M8.2 10.6 12.8 12.9"/><path d="M8.2 13.2 11.4 14.8"/></svg>'},v=Object.keys(s);function i(e){if(e)return s[e]??(e.trimStart().startsWith("<svg")?e:void 0)}var a=h(c(),1);function B({kind:e,schema:o,brand:n,size:r=16,title:t}){let f=o?.tryDefinition?.(e)?.figure,d=i(n?.figures?.[e]??f),l=Math.round(u(e,n?.accents)),g=p(d);return d?(0,a.jsx)("span",{"aria-hidden":t===void 0?"true":void 0,...t===void 0?{}:{role:"img","aria-label":t},"data-graview-figure":e,"data-graview-figure-kind":"figure",dangerouslySetInnerHTML:g,style:{display:"inline-flex",alignItems:"center",justifyContent:"center",width:r,height:r,flex:"0 0 auto",color:`hsl(${l} 55% 52%)`,"--graview-figure-size":`${r}px`}}):(0,a.jsx)("span",{"aria-hidden":t===void 0?"true":void 0,...t===void 0?{}:{role:"img","aria-label":t},"data-graview-figure":e,"data-graview-figure-kind":"dot",style:{display:"inline-block",width:Math.round(r*.8),height:Math.round(r*.5),flex:"0 0 auto",background:`hsl(${l} 55% 52%)`,clipPath:"polygon(50% 0, 100% 50%, 50% 100%, 0 50%)"}})}function A(e,o,n){return i(n?.figures?.[e]??o?.tryDefinition?.(e)?.figure)!==void 0}export{B as a,A as b};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as f,I as d,Sb as y,fa as m,ha as p}from"./chunk.Y235YZSZ.js";function v(n){let e=n.indexOf("{"),t=n.indexOf("["),a=t!==-1&&(e===-1||t<e)?t:e;if(a===-1)return;let r=n[a],i=r==="["?"]":"}",o=0,l=!1,s=!1;for(let u=a;u<n.length;u++){let c=n[u];if(l){s?s=!1:c==="\\"?s=!0:c==='"'&&(l=!1);continue}if(c==='"')l=!0;else if(c===r)o+=1;else if(c===i&&(o-=1,o===0))try{return JSON.parse(n.slice(a,u+1))}catch{return}}}function g(n,e){let t;try{t=n.mutation(e.mutation)}catch{return e}let a={...e.args},r=!1;for(let i of y(t.input)){if(i.control!=="node")continue;let o=a[i.name];if(typeof o!="string"||o.length===0||n.graph.getNode(o))continue;let l=o.trim().toLowerCase(),s=[...n.graph.allNodes()].filter(u=>(i.kinds.includes("*")||i.kinds.includes(u.kind))&&d(n.schema.tryDefinition(u.kind),u).trim().toLowerCase()===l);s.length===1&&(a[i.name]=s[0].id,r=!0)}return r?{...e,args:a}:e}function P(n,e,t){let a=t===void 0?null:new Set(t),r=[];for(let i of e){if(typeof i.mutation!="string")continue;let o=!0;try{n.mutation(i.mutation)}catch{o=!1}o?a&&!a.has(i.mutation)&&r.push({proposal:i,why:"not-allowed"}):r.push({proposal:i,why:"unknown"})}return r}function x(n,e,t){let a=t===void 0?null:new Set(t);return e.filter(r=>{if(typeof r.mutation!="string"||a&&!a.has(r.mutation))return!1;try{n.mutation(r.mutation)}catch{return!1}return r.args!==null&&typeof r.args=="object"})}function C(n,e){let t=n.allMutations().find(l=>l.name===e.mutation);if(t?.describe){let l=g(n,e),s=t.input.safeParse?.(l.args);if(s?.success)try{return t.describe(s.data,n.graph)}catch{}}let a=t?.subject?.arg,r=a?e.args[a]:void 0,i=typeof r=="string"?n.graph.getNode(r):void 0,o=t?.title??e.mutation;return i?`${o} \u2014 ${d(n.schema.tryDefinition(i.kind),i)}`:o}function b(n,e){let t=n.allMutations().find(o=>o.name===e.mutation);if(!t)return[];e=g(n,e);let a=t.input.shape??{},r=m(t.input),i=[];for(let o of Object.keys(a)){if(k(a[o]))continue;let l=e.args[o],s=r.find(c=>c.name===o);l!=null&&l!==""&&(!s||typeof l!="string"||n.graph.getNode(l)!==void 0)||i.push({name:o,...s?{kinds:s.kinds}:{},...s?{candidates:s.kinds.includes("*")?n.graph.allNodes().map(c=>c.id):s.kinds.flatMap(c=>n.graph.nodesOfKind(c).map(h=>h.id))}:{},shape:p(t.input,o)})}return i}function k(n){let e=f(n)?.type;return e==="optional"||e==="default"||e==="nullable"}export{v as a,g as b,P as c,x as d,C as e,b as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as B}from"./chunk.G4JJXA63.js";import{d as J,e as ee,f as te,g as ne}from"./chunk.K7UJG5II.js";import{j as Q,k as X}from"./chunk.XEJS2VS5.js";import{a as G}from"./chunk.4UQLZ7VW.js";import"./chunk.DN4D4HGX.js";import"./chunk.DJ26NOOW.js";import"./chunk.SQD7ZPEJ.js";import"./chunk.WGNF4E67.js";import"./chunk.R5K7NK4U.js";import{a as Z,d as q}from"./chunk.HCK6IHGP.js";import{a as Y}from"./chunk.VRXWNUDR.js";import"./chunk.DAKED3WK.js";import"./chunk.WWRWXFYR.js";import"./chunk.ZFUQA3KT.js";import"./chunk.DO4P2UK4.js";import"./chunk.6KJSFIO7.js";import"./chunk.FLJP3BGP.js";import"./chunk.ENMNLR73.js";import"./chunk.LZQZP2PD.js";import"./chunk.SCLIBKLS.js";import"./chunk.ACZGK7LQ.js";import"./chunk.AHDOKM4O.js";import"./chunk.LGUV2J6Q.js";import{Aa as V,W as _,ca as x,j as z,m as F,qa as U,r as W}from"./chunk.4JSMCNF7.js";import{I as P,N as O,O as A,S as j,T as N,aa as E}from"./chunk.Y235YZSZ.js";import{a as ge,b as K}from"./chunk.MRK6QJV5.js";import{b as I}from"./chunk.AJZBJBMO.js";var L=3;function se(e,t){return t.id?e.graph.getNode(t.id):void 0}function oe(e){return e?/^(?:kind|aggregate):([^:]+)$/.exec(e)?.[1]:void 0}function re(e,t){if(t)return e.find(n=>n.nodeIds.includes(t)||n.subjectId===t)}var fe=e=>{let t=e.trim();if(!t)return t;let n=t.charAt(0).toUpperCase()+t.slice(1);return/[.!?…]$/.test(n)?n:`${n}.`};function ae({store:e,subject:t,violations:n,place:i}){let o=se(e,t),s=re(n,o?.id??null);if(s)return fe(s.message);if(o){let d=o.kind;return`${P(e.schema.tryDefinition(d),o)}, ${j(N(e.schema.tryDefinition(d),d))}.`}let c=i?.kind??oe(t.id);if(c){let d=e.graph.nodesOfKind(c).length,p=i?.title??t.name,g=A(e.schema,c),f=O(e.schema,c,d);return p.toLowerCase()===g.toLowerCase()?`${d===1?"There is":"There are"} ${f} here.`:`${p}: ${f}.`}let r=e.schema.kinds.map(d=>({kind:d,count:e.graph.nodesOfKind(d).length})).filter(d=>d.count>0).sort((d,p)=>p.count-d.count).slice(0,3);if(r.length===0)return"Nothing here yet.";let a=r.map(d=>O(e.schema,d.kind,d.count));return`The whole thing: ${a.length===1?a[0]:`${a.slice(0,-1).join(", ")} and ${a[a.length-1]}`}.`}function le(e){let{store:t,subject:n,violations:i}=e,o=se(t,n),s=[];o&&re(i,o.id)?s.push({ask:`What's wrong with ${n.name}?`,why:"problem"}):i.length>0&&s.push({ask:"What needs attention?",why:"problem"});let c=o?o.kind:e.place?.kind??oe(n.id),r=me(e,c);if(r)s.push(r);else{let d=Se(e,c);d&&s.push(d)}let a=we(e,c);return a&&s.push(a),s.length<L&&(o?s.push({ask:`Tell me about ${n.name}`,why:"about"}):s.push({ask:"What is here?",why:"here"})),s.slice(0,L)}function de(e,t){return e.schema.tryDefinition(t)?.fields?.shape??{}}function ye(e){let t=e;for(let n=0;n<4&&t;n++){let i=t;if(Array.isArray(i.options)&&i.options.every(o=>typeof o=="string"))return i.options;t=typeof i.unwrap=="function"?i.unwrap():i._def?.innerType}}var ie=/^\d{4}-\d{2}-\d{2}/,he=["due","deadline","date","when"];function me(e,t){let{store:n}=e,i=e.today;if(!i||!ie.test(i))return;let o=new Date(`${i.slice(0,10)}T00:00:00Z`);o.setUTCDate(o.getUTCDate()+6);let s=o.toISOString().slice(0,10),c=[...new Set([...t?[t]:[],...n.schema.kinds])];for(let r of c){let a=he.find(g=>g in de(n,r));if(!a||!n.graph.nodesOfKind(r).some(g=>{let f=g[a],S=g.done;return typeof f=="string"&&ie.test(f)&&f.slice(0,10)>=i.slice(0,10)&&f.slice(0,10)<=s&&S!==!0}))continue;let p=A(n.schema,r);return{ask:`${B(p)} due this week`,why:"due"}}}function Se(e,t){let n=e.place?.title,i=(e.places??[]).find(o=>o.kind!==null&&o.picture===!0&&o.title!==n&&o.kind!==t);return i?{ask:`Go to ${i.title}`,why:"go"}:void 0}function we(e,t){let{store:n}=e,i=[...n.schema.kinds].sort((s,c)=>n.graph.nodesOfKind(c).length-n.graph.nodesOfKind(s).length),o=[...new Set([...t?[t]:[],...i])];for(let s of o){if(n.graph.nodesOfKind(s).length<2)continue;let c=de(n,s),r=Object.keys(c).find(p=>(ye(c[p])?.length??0)>=2);if(!r)continue;let a=A(n.schema,s).toLowerCase(),d=r.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").toLowerCase();return{ask:`Show ${a} as a board by ${d}`,why:"draw"}}}function ce(e,{store:t,subject:n}){let i=r=>n.id!==null&&(r.nodeIds.includes(n.id)||Object.values(r.args).includes(n.id)),o=e.filter(r=>r.provider==="invariant"&&i(r)),s=e.filter(r=>r.pinned==="user"&&!o.includes(r));return[...o,...s].sort((r,a)=>Number(r.destructive??!1)-Number(a.destructive??!1)).slice(0,L).map(r=>({affordance:r,label:ke(r,{store:t,subject:n})}))}var be=e=>/^[a-z0-9]+(?:[-_][a-z0-9]+)+$|^[a-z]+[A-Z][A-Za-z0-9]*$/.test(e);function ke(e,{store:t,subject:n}){let i=e.label,o=be(i)||i===e.mutation;if(o){let a=i.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").toLowerCase();i=a.charAt(0).toUpperCase()+a.slice(1)}let s=n.id?t.graph.getNode(n.id):void 0,c=s!==void 0&&e.nodeIds.length<=1&&(e.nodeIds[0]??s.id)===s.id;if(c&&/\bit\b/.test(i))return i.replace(/\bit\b/,n.name);let r=t.allMutations().find(a=>a.name===e.mutation);if(e.open.length===0&&r?.describe&&(o||c))try{let a=r.describe(e.args,t.graph);if(a.trim())return a.trim()}catch{}return i}var h=I(ge(),1);var u=I(K(),1);function Ne({phone:e,side:t,name:n,onClose:i,respond:o,onCall:s,onPick:c,onMove:r,place:a,onDraft:d}){let{seatTalk:p}=x(),g=_(p),f=ve(c),S=[...g.turns].reverse().find(y=>y.role==="seat"),m=e&&g.draft!==null,b=(0,h.useRef)(null);return(0,h.useLayoutEffect)(()=>{let y=b.current;if(!y)return;let w=m?[...y.querySelectorAll("ol > li")].pop():void 0;if(w){let C=w.getBoundingClientRect().top-y.getBoundingClientRect().top+y.scrollTop;y.style.maxHeight=`min(${Math.ceil(y.scrollHeight-C)}px, ${ue})`}y.scrollTop=y.scrollHeight},[g.turns.length,g.busy,m]),(0,u.jsxs)("div",{"data-testid":"seat-panel",...m?{"data-graview-seat-yields":""}:{},style:{display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",gap:4,minHeight:0},children:[(0,u.jsxs)("div",{style:{display:"flex",alignItems:"center",justifyContent:e?"center":"flex-end",gap:2,position:"relative",minHeight:28},children:[e?(0,u.jsx)("button",{type:"button","data-testid":"seat-grab","aria-label":`Close Ask ${n}`,title:"Close",onClick:i,style:{...M,width:64},children:(0,u.jsx)("span",{"aria-hidden":"true",style:{display:"block",width:36,height:4,margin:"0 auto",borderRadius:2,background:"var(--graview-edge-strong, var(--graview-ink-faint))"}})}):(0,u.jsx)("button",{type:"button","data-testid":"seat-side","aria-label":t==="left"?"Move to the right":"Move to the left",title:t==="left"?"Move to the right":"Move to the left",onClick:()=>p.setSide(t==="left"?"right":"left"),style:M,children:(0,u.jsx)("span",{"aria-hidden":"true",children:"\u21C4"})}),e?null:(0,u.jsx)("button",{type:"button","data-testid":"seat-close","aria-label":`Close Ask ${n}`,title:"Close",onClick:i,style:M,children:(0,u.jsx)("span",{"aria-hidden":"true",children:"\u2715"})})]}),(0,u.jsx)("div",{ref:b,"data-testid":"seat-body",style:{minHeight:0,maxHeight:m?ue:e?"calc(70cqh - 96px)":"min(520px, calc(100cqh - 112px))",overflowY:"auto",overflowX:"hidden",padding:"0 4px"},children:(0,u.jsx)(ee,{shared:!0,composer:!1,testId:"seat",onPick:f,...r?{onMove:r}:{},...a?{place:a}:{},...d?{onDraft:d}:{},empty:(0,u.jsx)(Ae,{...a?{here:a}:{}}),...o?{respond:o}:{},...s?{onCall:s}:{}})}),(0,u.jsx)("p",{"aria-live":"polite","data-testid":"seat-said",style:V,children:g.busy?"":S?.text??""})]})}function ve(e){let{setView:t}=x();return(0,h.useCallback)(n=>e?e(n):t(i=>W(z(F(i,!1),n),[n])),[e,t])}function Ae({here:e}){let{store:t,views:n,view:i,seatTalk:o}=x(),s=J({hover:!1}),c=Z(t,U()),r=(0,h.useMemo)(()=>c.map(l=>l.line?{...l,message:q(l)}:l),[c]),a=s.id?t.graph.getNode(s.id):void 0,d=e??i.within?.view,p=s.because==="place"&&s.id===null?n.places().find(l=>l.title===s.name):d?n.places().find(l=>l.as===d):void 0,g=t.today(),f={store:t,subject:{id:s.id,name:s.name},violations:r,place:p?{title:p.title,kind:p.kind}:null,places:n.places().map(l=>({title:l.title,kind:l.kind,picture:!0})),...g?{today:g}:{}},S=ae(f),m=le(f),b=(0,h.useMemo)(()=>({pins:G(),...a?{focus:a.id,about:[a.id]}:{}}),[a?.id]),{affordances:y}=Q(b),w=a?ce(y,{store:t,subject:{id:s.id,name:s.name}}):[],{apply:C,preview:pe}=X(),[k,$]=(0,h.useState)(null),[D,H]=(0,h.useState)(null),R=(l,v)=>{try{return pe(l,v),C(l,v),H(null),!0}catch(T){return H(E(t.schema,t.allMutations(),T)),!1}};return(0,u.jsxs)("div",{"data-testid":"seat-here",style:{display:"grid",gap:10,padding:"2px 2px 6px"},children:[(0,u.jsx)("p",{"data-testid":"seat-where",style:{margin:0,fontSize:"0.9375rem",lineHeight:1.45,color:"var(--graview-ink)"},children:S}),w.length>0?(0,u.jsx)("ul",{"aria-label":"What you can do",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:6},children:w.map(({affordance:l,label:v})=>(0,u.jsx)("li",{children:(0,u.jsx)("button",{type:"button","data-testid":"seat-act","data-affordance":l.id,"aria-pressed":k?.id===l.id,title:l.why,onClick:()=>l.open.length>0?$(T=>T?.id===l.id?null:l):void R(l),style:{...te,minHeight:30,textAlign:"start",...l.destructive?{color:"var(--graview-warn)"}:{}},children:v})},l.id))}):null,k?(0,u.jsx)(Y,{affordance:k,onApply:l=>{R(k,l)&&$(null)},onCancel:()=>$(null)}):null,D?(0,u.jsx)("p",{"data-testid":"seat-refused",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-warn)"},children:D}):null,m.length>0?(0,u.jsx)("ul",{"aria-label":"Things to ask",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:2,justifyItems:"start"},children:m.map(l=>(0,u.jsx)("li",{children:(0,u.jsx)("button",{type:"button","data-testid":"seat-suggestion","data-graview-why":l.why,onClick:()=>o.ask(l.ask),style:ne,children:l.ask})},l.ask))}):null]})}var ue="min(5.5em, 22cqh)",M={display:"inline-grid",placeItems:"center",width:28,height:28,padding:0,font:"inherit",fontSize:"0.875rem",lineHeight:1,color:"var(--graview-ink-muted)",background:"transparent",border:"1px solid transparent",borderRadius:6,boxShadow:"none",cursor:"pointer"};export{Ne as SeatPanel,ve as useSeatGo};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as U,b as V,c as W,d as q,e as b,f as z,h as J}from"./chunk.6C7SJJQO.js";import{a as L,b as H,c as A,d as X,j as Q,k as Z,l as ee}from"./chunk.DO4P2UK4.js";import{a as M,b as K,c as E,d as Y,e as F,g as R,h as ne}from"./chunk.ENMNLR73.js";import{b as B,g as u,h as I,i as G}from"./chunk.LZQZP2PD.js";var ce={};function te(e,t=ce,i=H){let{document:r,respelled:f}=U(e),l=f.length>0?{respelled:f}:{};if(!r||typeof r!="object"||Array.isArray(r))return{document:r};let p=r;if(p.format!==L||typeof p.formatVersion!="number"||p.formatVersion>=i)return{document:r,...l};let a=p.formatVersion,o=structuredClone(p);for(let s=a;s<i;s++){let c=t[s];if(!c)throw new Error(`there is no upgrade from format ${s} to ${s+1}`);o={...c(o),formatVersion:s+1}}return{document:o,from:a,...l}}function se(e,t,i){let r=Object.keys(e).filter(a=>e[a].edges?.[t]!==void 0);if(r.length===0)return;let f=r.map(a=>e[a].edges[t].to),l=f.some(a=>a==="*")?"*":[...new Set(f.flatMap(a=>a))];if(i.length===0||i.some(a=>r.includes(a)))return{reversed:!1,kinds:l};let p=r.filter(a=>{let o=e[a].edges[t].to;return o==="*"||i.every(s=>o.includes(s))});return p.length>0?{reversed:!0,kinds:p}:{reversed:!1,kinds:l}}function oe(e,t,i=`kinds.${e}.page`){let r=t.page;if(!r)return[];let f=[],l=[...Object.keys(t.fields),...Object.keys(t.computed??{})],p=new Set,a=(s,c)=>{l.includes(s)?p.has(s)&&f.push(u("page-field-twice",c,`"${s}" is on ${e}'s page twice; name each field once`)):f.push(u("page-field",c,`${e}'s page is to show "${s}", and ${e} has no field or computed field called that`,`use one of: ${l.join(", ")}`)),p.add(s)};(r.fields??[]).forEach((s,c)=>a(s,`${i}.fields.${c}`));let o=new Set;return(r.groups??[]).forEach((s,c)=>{let d=s.title.trim().toLowerCase();o.has(d)&&f.push(u("page-group-twice",`${i}.groups.${c}.title`,`${e}'s page has two groups called "${s.title}"; give each its own title`)),o.add(d),s.fields.forEach(($,n)=>a($,`${i}.groups.${c}.fields.${n}`))}),f}var de=new Set(["subject","now","today"]);function fe(e){if(typeof e=="string"){if(e.length>A)return{findings:[u("too-large","",`a document may be at most ${A/1024} KB`)]};try{e=JSON.parse(e)}catch(r){return{findings:[u("not-json","",`this is not JSON: ${r.message}`)]}}}else if(JSON.stringify(e??null).length>A)return{findings:[u("too-large","",`a document may be at most ${A/1024} KB`)]};try{e=te(e).document}catch(r){return{findings:[u("format","formatVersion",r.message)]}}let t=X.safeParse(e);if(!t.success)return{findings:t.error.issues.map(r=>{let f=r.path.map(String).join(".");if(r.code==="unrecognized_keys")return u("unknown-key",f,`${r.keys.map(l=>`"${l}"`).join(", ")} ${r.keys.length===1?"is":"are"} not part of a Graview document here`,"check the spelling against docs/declaration-document.md");if(r.code==="invalid_union"&&/\.effects\.\d+$/.test(f))return u("effect-shape",f,"this effect is not one Graview knows",'an effect is one of {"create": kind, "as"?: name, "set"?: {field: value}}, {"set": {field: value, \u2026}, "target"?: "$ref"}, {"connect"|"sever": relation, "from": "$ref", "to": "$ref"}, {"remove": "$ref"}');if(r.code==="invalid_key"){let l=r.issues?.[0]?.message;return u("shape",f,`the name "${String(r.path.at(-1))}" is not allowed here${l?`: ${l}`:""}`)}return u("shape",f,r.message)})};let i=t.data;return{document:i,findings:le(i)}}var P=e=>e===void 0?[]:Array.isArray(e)?e:[e];function re(e){let t=new Map;for(let[i,r]of Object.entries(e.kinds))for(let[f,l]of Object.entries(r.edges??{})){let p=t.get(f);t.set(f,{name:f,from:[...p?.from??[],i],to:l.to==="*"||p?.to==="*"?"*":[...new Set([...p?.to??[],...l.to])],cardinality:l.cardinality??"many"})}return t}function Ge(e){let t=new Map;for(let[r,f]of Object.entries(e.kinds)){let l=R(f);t.set(r,{fields:new Set(Object.keys(f.fields)),edges:new Map(Object.entries(f.edges??{}).map(([p,a])=>[p,a.cardinality??"many"])),...l?{computed:l}:{}})}let i=R(e);return i&&t.set(B,{computed:i}),t}function ie(e,t){let i=[],r=P(e.on),f=(l,p)=>{let a=se(t.kinds,l,r)?.reversed===!0,[o,s]=a?["$to","$subject"]:["$subject","$to"];return p==="connect"?{connect:l,from:o,to:s}:{sever:l,from:o,to:s}};if(e.creates){let l=t.kinds[e.creates],p={};for(let a of Object.keys(l?.fields??{}))p[a]=`$${a}`;for(let a of e.effects??[])"set"in a&&!("create"in a)&&b(a.target)==="new"&&Object.assign(p,a.set);i.push({create:e.creates,as:"new",set:p})}return e.sets&&i.push({set:e.sets}),e.writes&&!(e.creates&&e.on===void 0)&&i.push({set:Object.fromEntries(e.writes.map(l=>[l,`$${l}`]))}),e.connects&&(e.replaces&&i.push({replace:e.replaces===!0?[e.connects]:[...e.replaces],keep:e.connects}),i.push(f(e.connects,"connect"))),e.severs&&i.push(f(e.severs,"sever")),e.setsOther&&(e.connects||e.severs)&&i.push({set:e.setsOther,target:"$to"}),e.removes&&i.push({remove:"$subject"}),e.effects&&i.push(...e.effects.filter(l=>!(e.creates&&"set"in l&&!("create"in l)&&b(l.target)==="new"))),i}function C(e,t,i){try{let r=E(e),f=M(r);for(let l of f.unknownFunctions)i.push(u("unknown-function",t,`"${l}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));return r}catch(r){if(r instanceof K){i.push(u("expression",t,r.sentence+` (at character ${r.at+1})`));return}throw r}}function N(e,t,i){try{return F(e)}catch(r){if(r instanceof Y||r instanceof K){i.push(u("template",t,(r instanceof K,r.sentence)));return}throw r}}function le(e){let t=[],i=new Set(Object.keys(e.kinds)),r=re(e),f=e.acts??{},l=new Set(e.roles??[]);for(let[a,o]of Object.entries(e.kinds)){let s=`kinds.${a}`;for(let[d,$]of Object.entries(o.edges??{})){if($.to!=="*")for(let n of $.to)i.has(n)||t.push(u("edge-target",`${s}.edges.${d}.to`,`"${n}" is not a kind this document declares`));o.fields[d]&&t.push(u("edge-field-clash",`${s}.edges.${d}`,`"${d}" is both a field and a relation of ${a}`,"rename one of them"))}o.lifecycle&&!o.fields[o.lifecycle.field]&&t.push(u("lifecycle-field",`${s}.lifecycle.field`,`${a} has no field "${o.lifecycle.field}"`));let c=d=>o.computed!==void 0&&Object.hasOwn(o.computed,d);for(let d of o.glance??[])!o.fields[d]&&!c(d)&&t.push(u("glance-field",`${s}.glance`,`a glance at ${a} is to say "${d}", and ${a} has no field or computed field called that`,`use one of: ${[...Object.keys(o.fields),...Object.keys(o.computed??{})].join(", ")}`));t.push(...oe(a,o));for(let d of["label","describe"]){let $=o[d];if(!$)continue;let n=N($,`${s}.${d}`,t);for(let m of n??[])if(m.expr){for(let y of M(m.expr).names)if(!o.fields[y]){if(c(y)){ne(o,y)||t.push(u("template-field",`${s}.${d}`,`${a}'s ${y} is worked out from beyond the record, and a ${d} is said with no graph to read`,`show it in a view instead, or name a computed field worked out from ${a}'s own fields`));continue}t.push(u("template-field",`${s}.${d}`,`${a} has no field "${y}" for its ${d} to show`,d==="label"?"a label can only show the record's own fields and what they work out":void 0))}}}for(let[d,$]of Object.entries(o.fields))$.default!==void 0&&$.type==="enum"&&!$.options?.includes(String($.default))&&t.push(u("default-option",`${s}.fields.${d}.default`,`"${String($.default)}" is not one of ${d}'s options`))}for(let[a,o]of Object.entries(f)){let s=`acts.${a}`;for(let n of P(o.on))i.has(n)||t.push(u("act-kind",`${s}.on`,`"${n}" is not a kind this document declares`));let c=P(o.on),d=ie(o,e);if(o.creates&&o.on===void 0&&o.writes&&i.has(o.creates))for(let n of o.writes)e.kinds[o.creates].fields[n]||(e.kinds[o.creates].computed?.[n]!==void 0?t.push(u("computed-written",`${s}.writes`,`${o.creates}'s ${n} is worked out, not written: no act can set it`,"write the stored fields it is worked out from")):t.push(u("act-field",`${s}.writes`,`${o.creates} has no field "${n}"`)));d.length===0&&t.push(u("act-empty",s,`"${a}" does nothing`,"give it effects or a shorthand such as sets or creates"));let $=new Map;d.forEach((n,m)=>{let y=d.length-(o.effects?.length??0),w=o.effects&&m>=y?`${s}.effects.${m-y}`:s;if("create"in n){if(!i.has(n.create))t.push(u("act-kind",`${w}.create`,`"${n.create}" is not a kind this document declares`));else for(let h of Object.keys(n.set??{}))e.kinds[n.create].fields[h]||(e.kinds[n.create].computed?.[h]!==void 0?t.push(u("computed-written",`${w}.set.${h}`,`${n.create}'s ${h} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):t.push(u("act-field",`${w}.set.${h}`,`${n.create} has no field "${h}"`)));n.as&&$.set(n.as,n.create)}else if("connect"in n||"sever"in n){let h="connect"in n?n.connect:n.sever;r.has(h)||t.push(u("act-edge",`${w}.${"connect"in n?"connect":"sever"}`,`"${h}" is not a relation any kind declares`)),b(n.from)==="subject"&&c.length===0&&t.push(u("act-subject",`${s}.on`,`"${a}" acts on "$subject" but does not say which kinds it is "on"`))}else if("set"in n){let h=b(n.target??"$subject"),O=h==="subject"?c:$.has(h??"")?[$.get(h)]:[];h==="subject"&&c.length===0&&t.push(u("act-subject",`${s}.on`,`"${a}" changes "$subject" but does not say which kinds it is "on"`));for(let S of Object.keys(n.set))for(let x of O)!i.has(x)||e.kinds[x].fields[S]||(e.kinds[x].computed?.[S]!==void 0?t.push(u("computed-written",`${w}.set.${S}`,`${x}'s ${S} is worked out, not written: no act can set it`,"set the stored fields it is worked out from")):t.push(u("act-field",`${w}.set.${S}`,`${x} has no field "${S}"`)))}else"remove"in n&&b(n.remove)==="subject"&&c.length===0&&t.push(u("act-subject",`${s}.on`,`"${a}" removes "$subject" but does not say which kinds it is "on"`));("set"in n&&n.set?Object.values(n.set):[]).forEach(h=>{h&&typeof h=="object"&&!Array.isArray(h)&&"expr"in h&&C(h.expr,`${w}.set`,t)})}),o.allowedWhen&&C(o.allowedWhen,`${s}.allowedWhen`,t),o.refusal&&N(o.refusal,`${s}.refusal`,t)}for(let[a,o]of Object.entries(e.rules??{})){let s=`rules.${a}`;o.over!=="graph"&&!i.has(o.over)&&t.push(u("rule-kind",`${s}.over`,`"${o.over}" is not a kind this document declares`));let c=o.over==="graph"?void 0:e.kinds[o.over];for(let d of["when","require"]){let $=o[d];if(!$)continue;let n=C($,`${s}.${d}`,t);if(!n)continue;let m=M(n);for(let y of m.names)if(o.over==="graph")t.push(u("rule-name",`${s}.${d}`,`"${y}" means nothing in a rule over the whole graph`,`name a kind in "over", or use all('kind')`));else if(c&&!c.fields[y]&&!c.edges?.[y]&&c.computed?.[y]===void 0){let w=Object.keys(c.edges??{}).find(v=>v.includes("-")&&v.split("-").includes(y));t.push(u("rule-name",`${s}.${d}`,`${o.over} has no field or relation called "${y}"`,w?`"${w}" reads as a subtraction in a rule; rename the relation to one camelCase word, like "${w.replace(/-([a-z0-9])/g,(v,h)=>h.toUpperCase())}"`:void 0))}for(let y of m.edges)r.has(y)||t.push(u("rule-edge",`${s}.${d}`,`"${y}" is not a relation any kind declares`));for(let y of m.sweeps)i.has(y)?o.over!=="graph"&&t.push(I("rule-cost",`${s}.${d}`,`this rule looks at every ${y} for every ${o.over}, which grows slowly as the app grows`,"walk a relation with out()/in() instead of all() where you can")):t.push(u("rule-kind",`${s}.${d}`,`"${y}" is not a kind this document declares`))}o.says&&N(o.says,`${s}.says`,t),(o.repairs??[]).forEach((d,$)=>{!f[d.act]&&!/^(edit|remove)-/.test(d.act)&&t.push(u("repair-act",`${s}.repairs.${$}.act`,`"${d.act}" is not an act this document declares`))})}let p=e.policy;return p&&(p.grants.forEach((a,o)=>{if(a.roles!=="*"&&l.size>0)for(let s of a.roles)l.has(s)||t.push(u("grant-role",`policy.grants.${o}.roles`,`"${s}" is not one of the document's roles`));if(a.mutations!=="*")for(let s of a.mutations)!f[s]&&!/^(edit|remove)-/.test(s)&&t.push(u("grant-act",`policy.grants.${o}.mutations`,`"${s}" is not an act this document declares`))}),(p.sees??[]).forEach((a,o)=>{for(let s of a.kinds)i.has(s)||t.push(u("sight-kind",`policy.sees.${o}.kinds`,`"${s}" is not a kind this document declares`));if(a.roles!=="*"&&l.size>0)for(let s of a.roles)l.has(s)||t.push(u("sight-role",`policy.sees.${o}.roles`,`"${s}" is not one of the document's roles`))})),t.push(...ee(e)),t}function ue(e,t,i,r){let f=new Map,l=P(e.on),p=new Map,a=new Map;(l.length>0||t.some(n=>"remove"in n&&b(n.remove)==="subject"||"from"in n&&(b(n.from)==="subject"||b(n.to)==="subject")||"set"in n&&!("create"in n)&&b(n.target??"$subject")==="subject"))&&f.set(q,{ref:l.length>0?l:"*",required:!0});let s=e.args??{},c=e.writes?.length===1,d=(n,m)=>m&&n.type===m.type&&n.min===void 0&&n.max===void 0&&n.step===void 0?{...n,...m.min===void 0?{}:{min:m.min},...m.max===void 0?{}:{max:m.max},...m.step===void 0?{}:{step:m.step}}:n,$=(n,m,y)=>{if(n===q||de.has(n)||p.has(n)||f.has(n))return;let w=s[n]?d(s[n],y):void 0;f.set(n,w?{field:w,optional:!w.required,required:!!w.required}:m())};for(let n of t)if("create"in n){let m=i.kinds[n.create];for(let[y,w]of Object.entries(n.set??{})){let v=b(w),h=m?.fields[y];if(v&&h){let O=!!h.required&&h.default===void 0;$(v,()=>({field:h,optional:!O,required:O}),h)}}n.as&&p.set(n.as,n.create)}else if("connect"in n||"sever"in n){let m=r.get("connect"in n?n.connect:n.sever);for(let[y,w]of[["from",n.from],["to",n.to]]){let v=b(w);if(!v)continue;let h=y==="to"?m?.to??"*":m?.from??"*";h!=="*"&&!a.has(v)&&a.set(v,h),$(v,()=>({ref:h,required:!0}))}}else if("set"in n){let m=b(n.target??"$subject"),y=m==="subject"?l[0]:p.get(m??"")??a.get(m??"")?.[0];m&&m!=="subject"&&!p.has(m)&&$(m,()=>({ref:"*",required:!0}));for(let[w,v]of Object.entries(n.set)){let h=b(v);if(!h)continue;let O=y?i.kinds[y]?.fields[w]:void 0;$(h,()=>O?{field:O,optional:!c,required:c}:{any:!0,required:!1},O)}}else if("remove"in n){let m=b(n.remove);m&&$(m,()=>({ref:"*",required:!0}))}for(let[n,m]of Object.entries(s))f.has(n)||f.set(n,{field:m,optional:!m.required,required:!!m.required});return f}function qe(e,t={}){let i=fe(e);if(!i.document||G(i.findings))return{ok:!1,findings:i.findings};let r=i.document,f=[...i.findings];t.previous&&f.push(...ge(r,t.previous));let l=pe(r,f);return G(l.findings)?{ok:!1,findings:l.findings}:J(l,t)}function pe(e,t){let i=re(e),r={};for(let[s,c]of Object.entries(e.kinds)){let d=z(c),$=c.label??(d?`{${d}}`:void 0),n=R(c);r[s]={...$?{label:F($)}:{},...c.describe?{describe:F(c.describe)}:{},...n?{computed:[...n]}:{}}}let f={};for(let[s,c]of Object.entries(e.acts??{})){let d=ie(c,e),$=ue(c,d,e,i),n=c.destructive??d.some(g=>"remove"in g||"sever"in g||"replace"in g),m=[...new Set(d.flatMap(g=>"create"in g?[g.create]:[]))],y=[...new Set(d.flatMap(g=>"connect"in g?[g.connect]:[]))],w=[...new Set(d.flatMap(g=>"sever"in g?[g.sever]:"replace"in g?g.replace:[]))],v=[...new Set(d.flatMap(g=>"set"in g&&!("create"in g)&&b(g.target??"$subject")==="subject"?Object.keys(g.set):[]))],h=new Map;for(let g of d){if(!("connect"in g)&&!("sever"in g))continue;let k=i.get("connect"in g?g.connect:g.sever);for(let[j,ae]of[["from",g.from],["to",g.to]]){let D=b(ae),T=j==="to"?k?.to:k?.from;D&&D!=="subject"&&T&&T!=="*"&&h.set(D,[...new Set([...h.get(D)??[],...T])])}}let O={};for(let g of d){if(!("set"in g)||"create"in g)continue;let k=b(g.target??"$subject");for(let j of k&&k!=="subject"&&h.get(k)||[])O[j]=[...new Set([...O[j]??[],...Object.keys(g.set)])]}let S={};for(let g of d)if(!(!("set"in g)||"create"in g||b(g.target??"$subject")!=="subject"))for(let[k,j]of Object.entries(g.set??{}))typeof j=="string"&&b(j)===void 0||typeof j=="number"||typeof j=="boolean"?S[k]=typeof j=="string"&&j.startsWith("$$")?j.slice(1):j:delete S[k];let x=m.length===0&&d.every(g=>!("set"in g)||!g.set||Object.values(g.set).every(k=>!(k&&typeof k=="object"&&!Array.isArray(k)&&"expr"in k))),_=new Map;for(let g of d)if(!(!("set"in g)||!g.set))for(let k of Object.values(g.set))k&&typeof k=="object"&&!Array.isArray(k)&&"expr"in k&&_.set(k.expr,E(k.expr));f[s]={title:c.title??s.replace(/-/g," "),effects:d,args:[...$],...c.allowedWhen?{guard:E(c.allowedWhen)}:{},...c.refusal?{refusal:F(c.refusal)}:{},exprs:[..._],destructive:n,idempotent:x,creates:m,connects:y,severs:w,writes:v,writesOther:O,sets:S}}let l={};for(let[s,c]of Object.entries(e.rules??{}))l[s]={title:c.title??s.replace(/-/g," "),require:E(c.require),...c.when?{when:E(c.when)}:{},...c.says?{says:F(c.says)}:{}};let p=V(e,t),a=Q(e),o=Z(e);return{format:W,document:e,findings:t,kinds:r,...e.computed?{facts:[...R(e)??[]]}:{},edges:[...i].map(([s,{from:c,to:d,cardinality:$}])=>[s,{from:c,to:d,cardinality:$}]),acts:f,rules:l,brand:p,...Object.keys(a).length>0?{viewSpecs:a}:{},...o?{home:o}:{}}}function Ce(e,t){let i=e.split(/[\s:·]/).find(r=>r.length>0)??e;return t.kinds[i]?`kinds.${i}`:t.acts?.[i]?`acts.${i}`:t.rules?.[i]?`rules.${i}`:e}function Ne(e,t,i){let r=/^defineNode\("([^"]+)"\)/.exec(t)?.[1],f=r?i.kinds[r]:void 0;if(!r||!f)return e;let l=Object.keys(f.fields).filter(p=>p!=="label").slice(0,3);return{...e,path:`kinds.${r}.glance`,fix:`Say which: "glance": [${l.map(p=>`"${p}"`).join(", ")}] on kinds.${r} \u2014 the facts a person compares one by, at a glance.`}}function ge(e,t){let i=[],r=new Set(Object.values(t.kinds).flatMap(f=>Object.keys(f.edges??{})));for(let[f,l]of Object.entries(e.kinds)){let p=l.renamedFrom;p&&!t.kinds[p]&&i.push(u("renamed-from-nothing",`kinds.${f}.renamedFrom`,`${f} says it was ${p}, and the previous version has no kind called ${p}`,"name the kind it was, or drop renamedFrom"));let a=t.kinds[p??f];for(let[o,s]of Object.entries(l.fields)){let c=s.renamedFrom;c&&!a?.fields[c]&&i.push(u("renamed-from-nothing",`kinds.${f}.fields.${o}.renamedFrom`,`${o} says it was ${c}, and the previous ${p??f} has no field called ${c}`,"name the field it was, or drop renamedFrom"))}for(let[o,s]of Object.entries(l.edges??{})){let c=s.renamedFrom;c&&!r.has(c)&&i.push(u("renamed-from-nothing",`kinds.${f}.edges.${o}.renamedFrom`,`${o} says it was ${c}, and the previous version has no relation called ${c}`,"name the relation it was, or drop renamedFrom"))}}return i}export{fe as a,Ge as b,ie as c,qe as d,Ce as e,Ne as f};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{A as l,H as p,O as k,P as y,c}from"./chunk.VVZ2Z7OS.js";import"./chunk.EQOU4POV.js";import"./chunk.ONDILMIX.js";import{b as m}from"./chunk.NOXC454O.js";import"./chunk.IKT7JQUW.js";import"./chunk.6CLHFNDM.js";import"./chunk.R5K7NK4U.js";import"./chunk.HCK6IHGP.js";import"./chunk.YAONM74M.js";import"./chunk.CJQL7AHT.js";import"./chunk.BQV62QEL.js";import"./chunk.DAKED3WK.js";import"./chunk.WWRWXFYR.js";import"./chunk.ZFUQA3KT.js";import"./chunk.DO4P2UK4.js";import"./chunk.6KJSFIO7.js";import"./chunk.FLJP3BGP.js";import"./chunk.ENMNLR73.js";import"./chunk.LZQZP2PD.js";import"./chunk.SCLIBKLS.js";import"./chunk.ACZGK7LQ.js";import"./chunk.AHDOKM4O.js";import"./chunk.3MLQ3Q5X.js";import"./chunk.LGUV2J6Q.js";import{U as s,W as d,da as g}from"./chunk.4JSMCNF7.js";import"./chunk.Y235YZSZ.js";import{a as S,b as f}from"./chunk.MRK6QJV5.js";import{b as n}from"./chunk.AJZBJBMO.js";var u=n(S(),1);var t=n(f(),1);function D({context:a}){let r=l(),h=g(),[w]=(0,u.useState)(()=>s(null)),o=d(h?.seatTalk??w),P=()=>{(window.history.state?.idx??0)>0?r(-1):r("/")};return(0,t.jsxs)(k,{context:a,"data-testid":"draft-page",children:[(0,t.jsx)(y,{context:a,...o.draft?{"data-testid":"draft-title"}:{},children:o.draft?o.draft.title:"Nothing drawn"}),o.draft?(0,t.jsx)(m,{page:!0,go:e=>r(e.address),onPick:e=>{let i=a.store.graph.getNode(e);i&&r(c(a.store.schema,i.kind,e))},onDiscard:P}):(0,t.jsxs)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:["Ask for a way of seeing \u2014 \u201Ca board of tasks by status\u201D \u2014 and it is drawn here."," ",(0,t.jsx)(p,{to:"/",style:{color:"var(--graview-accent)"},children:"Home \u2192"})]})]})}export{D as DraftPage};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{B as q,ca as G,i as j}from"./chunk.4JSMCNF7.js";import{H as P,I as H,L,Q as R,T as K,_ as T}from"./chunk.Y235YZSZ.js";import{a as V,b as M}from"./chunk.MRK6QJV5.js";import{b as E}from"./chunk.AJZBJBMO.js";var a=E(V(),1),s=E(M(),1);function ne({affordance:r,onApply:o,onCancel:u}){let{store:l}=G(),[y,m]=(0,a.useState)({}),[f,x]=(0,a.useState)(""),[A,$]=(0,a.useState)(_),W=(0,a.useId)(),O=(0,a.useRef)(null),b=r.open.filter(e=>!(e.name in y)),i=b[0];if((0,a.useEffect)(()=>x(""),[i?.name]),(0,a.useEffect)(()=>{O.current?.scrollIntoView?.({block:"nearest",inline:"nearest"})},[i?.name]),(0,a.useLayoutEffect)(()=>{let e=O.current,t=typeof document>"u"?null:document.activeElement;if(!e||t&&t!==document.body&&!e.contains(t))return;let p=e.querySelector("form input, [role=group] button:not([disabled])");p&&p!==t&&p.focus()},[i?.name]),!i)return null;let h=e=>{let t={...y,[i.name]:e};if(r.open.filter(c=>!(c.name in t)).length===0){let c=o(Object.fromEntries(Object.entries(t).filter(([,C])=>C!==void 0)));c&&c.length>0&&m(Object.fromEntries(Object.entries(t).filter(([C])=>!c.includes(C))))}else m(t)},F=i.optional?(0,s.jsx)("button",{type:"button",onClick:()=>h(void 0),style:{fontSize:"0.8125rem"},children:"Skip"}):null,n=i.shape??{type:"unknown"},d=Y(i,n),g=T(l.schema,l.allMutations().find(e=>e.name===r.mutation),i.name),[N,B]=(0,a.useState)(""),I=(0,a.useMemo)(()=>{let e=d.map(t=>l.graph.getNode(t)).filter(t=>t!==void 0);return P(e,t=>l.schema.tryDefinition(t))},[d,l]),z=e=>{let t=Q(l,n,e),p=n.type==="choice"||n.type==="several"&&n.of.type==="choice"?g.option(e):t,c=I.get(e);return c?`${p} \xB7 ${c}`:p},w=(0,a.useMemo)(()=>{let e=N.trim().toLowerCase();return e===""?d:d.filter(t=>z(t).toLowerCase().includes(e))},[d,N,l,n,I]),v=n.type==="several",D=v&&d.length===0,k=i.kinds&&i.kinds.length>0&&!i.kinds.includes("*")?i.kinds.map(e=>L(K(l.schema.tryDefinition(e),e))).join(" or "):g.label,U=r.open.length>1?`${k} \xB7 ${r.open.length-b.length+1} of ${r.open.length}`:k;return(0,s.jsxs)("div",{ref:O,"data-graview-asking":r.id,style:{display:"grid",gridTemplateColumns:"minmax(0, 1fr)",gap:4,padding:"5px 0 2px"},children:[r.open.length>1||d.length>0?(0,s.jsx)("span",{id:W,style:{fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:U}):null,d.length>S?(0,s.jsx)("input",{type:"search",value:N,onChange:e=>B(e.target.value),placeholder:`Filter ${d.length}\u2026`,"aria-label":`Filter ${k}`,"data-testid":"ask-filter",style:{font:"inherit",fontSize:"0.8125rem",minWidth:0,padding:"3px 7px"}}):null,d.length>0?(0,s.jsxs)("div",{role:"group","aria-labelledby":W,style:{display:"flex",flexWrap:"wrap",gap:4},children:[w.slice(0,S).map(e=>{let t=A.includes(e);return(0,s.jsx)("button",{type:"button","aria-label":`${k}: ${z(e)}`,...v?{"aria-pressed":t}:{},style:{padding:"3px 9px",fontSize:"0.8125rem",...t?{borderColor:"var(--graview-accent)",color:"var(--graview-accent)"}:{}},onClick:()=>v?$(p=>p.includes(e)?p.filter(c=>c!==e):[...p,e]):h(n.type==="boolean"?e==="yes":e),children:z(e)},e)}),w.length>S?(0,s.jsxs)("span",{"data-testid":"ask-more",style:{alignSelf:"center",fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:[w.length-S," more \u2014 type to narrow"]}):null,w.length===0?(0,s.jsxs)("span",{"data-testid":"ask-none",style:{alignSelf:"center",fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:["None of the ",d.length," match that."]}):null,v?(0,s.jsx)("button",{type:"button",disabled:A.length===0,style:{fontSize:"0.8125rem"},onClick:()=>{let e=A;$(_),h(e)},children:b.length>1?"Next":"Apply"}):null,F]}):(0,s.jsxs)("form",{style:{display:"flex",flexWrap:"wrap",gap:4},onSubmit:e=>{if(e.preventDefault(),D){h(f.split(/[,\n]/).map(t=>t.trim()).filter(Boolean));return}f.trim().length!==0&&h(n.type==="number"?Number(f):f)},children:[n.type==="text"&&n.long?(0,s.jsx)("textarea",{autoFocus:!0,name:i.name,"aria-label":g.label,placeholder:g.label,value:f,rows:4,onChange:e=>x(e.target.value),onKeyDown:e=>{e.key==="Escape"?u():e.key==="Enter"&&(e.metaKey||e.ctrlKey)&&(e.preventDefault(),e.currentTarget.form?.requestSubmit())},style:{flex:"1 1 100%",minWidth:0,font:"inherit",fontSize:"0.875rem",lineHeight:1.45,padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)",resize:"vertical",fieldSizing:"content",minHeight:"5.5em",maxHeight:"40vh"}}):(0,s.jsx)("input",{autoFocus:!0,type:n.type==="date"?n.time?"datetime-local":"date":n.type==="number"?"number":"text",name:i.name,"aria-label":g.label,placeholder:D?`${g.label}, separated by commas`:g.label,value:f,...n.type==="number"&&n.min!==void 0?{min:n.min}:{},...n.type==="number"&&n.max!==void 0?{max:n.max}:{},...n.type==="number"&&n.step!==void 0?{step:n.step}:{},onChange:e=>x(e.target.value),onKeyDown:e=>{e.key==="Escape"&&u()},style:{flex:1,minWidth:0,font:"inherit",fontSize:"0.875rem",padding:"5px 8px",borderRadius:7,border:"1px solid var(--graview-edge)",background:"var(--graview-panel)",color:"var(--graview-ink)"}}),(0,s.jsx)("button",{type:"submit",disabled:!D&&f.trim().length===0,style:{fontSize:"0.8125rem"},children:b.length>1?"Next":"Apply"}),F]})]})}var _=[],S=10;function Y(r,o){return r.candidates&&r.candidates.length>0?r.candidates:o.type==="choice"?o.options:o.type==="several"&&o.of.type==="choice"?o.of.options:o.type==="boolean"?J:[]}var J=["yes","no"];function Q(r,o,u){return o.type==="boolean"||o.type==="choice"||o.type==="several"&&o.of.type==="choice"?u:X(r,u)}function X(r,o){let u=j(o);if(u){let m=R(r.schema,r.graph.getNode(u.from)?.kind??"",u.kind,"out");return m.charAt(0).toUpperCase()+m.slice(1)}let l=q(o);if(l.length>0)return l.map(m=>r.schema.tryDefinition(m)?.plural??`${m}s`).join(" + ");let y=r.graph.getNode(o);return y?H(r.schema.tryDefinition(y.kind),y):o}export{ne as a,X as b};
|