graview 0.1.22 → 0.1.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/preview/chunk.2STFOAXA.js +1 -0
- package/dist/preview/chunk.2VX6H2LL.js +1 -0
- package/dist/preview/chunk.33C6VZAD.js +1 -0
- package/dist/preview/{chunk.L5G5DTFX.js → chunk.3O2QU7LU.js} +1 -1
- package/dist/preview/chunk.3TNQPFIK.js +1 -0
- package/dist/preview/{chunk.SQD7ZPEJ.js → chunk.42U4UBDE.js} +1 -1
- package/dist/preview/{chunk.Q7WQ5UIE.js → chunk.47GRZWQN.js} +1 -1
- package/dist/preview/{chunk.HCK6IHGP.js → chunk.53RZI5PM.js} +1 -1
- package/dist/preview/{chunk.DO4P2UK4.js → chunk.54NSG7BX.js} +1 -1
- package/dist/preview/{chunk.6C7SJJQO.js → chunk.6MCK7K3M.js} +1 -1
- package/dist/preview/{chunk.DAKED3WK.js → chunk.6O67NOZR.js} +1 -1
- package/dist/preview/{chunk.ENMNLR73.js → chunk.6XBLDV4A.js} +1 -1
- package/dist/preview/chunk.7EN53F4Q.js +9 -0
- package/dist/preview/chunk.7Q7S7YCA.js +1 -0
- package/dist/preview/{chunk.BQV62QEL.js → chunk.7U7Q3HIS.js} +1 -1
- package/dist/preview/{chunk.6CLHFNDM.js → chunk.AKOC43TV.js} +14 -14
- package/dist/preview/{chunk.7YCQZJGB.js → chunk.AXACXB4D.js} +1 -1
- package/dist/preview/{chunk.ZKUXPS44.js → chunk.BLAODPYJ.js} +1 -1
- package/dist/preview/chunk.BNSY25SG.js +1 -0
- package/dist/preview/{chunk.XYZ7KAMZ.js → chunk.C7KLA2MW.js} +1 -1
- package/dist/preview/{chunk.WGNF4E67.js → chunk.D3CYTXNZ.js} +1 -1
- package/dist/preview/chunk.DQL3WKR3.js +1 -0
- package/dist/preview/chunk.EUCXNNCZ.js +107 -0
- package/dist/preview/{chunk.VVZ2Z7OS.js → chunk.FKQTQ3FV.js} +1 -1
- package/dist/preview/{chunk.DJ26NOOW.js → chunk.FRNIWOKD.js} +1 -1
- package/dist/preview/chunk.GDIRDJF3.js +1 -0
- package/dist/preview/chunk.H3HRTEW7.js +1 -0
- package/dist/preview/{chunk.SCLIBKLS.js → chunk.HAQ4KHRY.js} +1 -1
- package/dist/preview/{chunk.JE4VH767.js → chunk.HDEQXJWX.js} +1 -1
- package/dist/preview/chunk.HH6WIUK3.js +8 -0
- package/dist/preview/{chunk.ZFUQA3KT.js → chunk.ISAMJ7AK.js} +1 -1
- package/dist/preview/{chunk.FLDFRFDH.js → chunk.KKTHQJ6F.js} +2 -2
- package/dist/preview/chunk.KWSXL3A2.js +1 -0
- package/dist/preview/{chunk.LGUV2J6Q.js → chunk.LW7KV5SL.js} +1 -1
- package/dist/preview/{chunk.R5K7NK4U.js → chunk.MYCTNK6D.js} +1 -1
- package/dist/preview/chunk.NRWJ6PLU.js +1 -0
- package/dist/preview/{chunk.M4XNUM2A.js → chunk.OXODTBOP.js} +1 -1
- package/dist/preview/{chunk.ACZGK7LQ.js → chunk.PRXKRG6O.js} +1 -1
- package/dist/preview/{chunk.EQOU4POV.js → chunk.RGXNZ7PN.js} +1 -1
- package/dist/preview/chunk.RT3XFR6E.js +20 -0
- package/dist/preview/{chunk.ELEHYYCN.js → chunk.S4FO7Y2Q.js} +1 -1
- package/dist/preview/{chunk.3MLQ3Q5X.js → chunk.TDW6QEG4.js} +1 -1
- package/dist/preview/{chunk.VNC6H6IM.js → chunk.TWFYXD3P.js} +1 -1
- package/dist/preview/{chunk.AZG6V3PF.js → chunk.TWGB347L.js} +1 -1
- package/dist/preview/chunk.UEBBASQW.js +1 -0
- package/dist/preview/chunk.UIZWVBJ7.js +1 -0
- package/dist/preview/{chunk.FLJP3BGP.js → chunk.UM5IPM22.js} +1 -1
- package/dist/preview/{chunk.NOXC454O.js → chunk.VLNI5U6H.js} +1 -1
- package/dist/preview/{chunk.CJQL7AHT.js → chunk.VTBAKTFP.js} +2 -2
- package/dist/preview/{chunk.UNRYIETM.js → chunk.WEGBBWWK.js} +1 -1
- package/dist/preview/{chunk.LZQZP2PD.js → chunk.WOTNMTIY.js} +1 -1
- package/dist/preview/{chunk.THBP5EES.js → chunk.XCOPECOJ.js} +1 -1
- package/dist/preview/chunk.XDPRWUCJ.js +1 -0
- package/dist/preview/{chunk.3HEJZPJM.js → chunk.XDVKD6VX.js} +1 -1
- package/dist/preview/{chunk.YAONM74M.js → chunk.XJNXSQT4.js} +1 -1
- package/dist/preview/{chunk.ZQZ557VR.js → chunk.XUXCDUKC.js} +1 -1
- package/dist/preview/chunk.Y4R77MKX.js +1 -0
- package/dist/preview/chunk.ZQ4HFIIS.js +8 -0
- package/dist/preview/page.js +2 -2
- package/package.json +6 -6
- package/dist/preview/chunk.2F7OKRDK.js +0 -9
- package/dist/preview/chunk.4CDEIDKB.js +0 -1
- package/dist/preview/chunk.4JSMCNF7.js +0 -1
- package/dist/preview/chunk.4UQLZ7VW.js +0 -1
- package/dist/preview/chunk.5MAMCKVU.js +0 -1
- package/dist/preview/chunk.75WDSWXL.js +0 -20
- package/dist/preview/chunk.7YC34AIK.js +0 -1
- package/dist/preview/chunk.AZYJTNSM.js +0 -107
- package/dist/preview/chunk.DN4D4HGX.js +0 -1
- package/dist/preview/chunk.K7UJG5II.js +0 -1
- package/dist/preview/chunk.KFLY4MAT.js +0 -1
- package/dist/preview/chunk.KWYU5NPM.js +0 -1
- package/dist/preview/chunk.LSLFKW4M.js +0 -1
- package/dist/preview/chunk.OR6ZWN76.js +0 -1
- package/dist/preview/chunk.PC6FAJF5.js +0 -1
- package/dist/preview/chunk.VRXWNUDR.js +0 -1
- package/dist/preview/chunk.WTF3CP76.js +0 -1
- package/dist/preview/chunk.XEJS2VS5.js +0 -8
- package/dist/preview/chunk.Y235YZSZ.js +0 -8
- package/dist/preview/chunk.YU64JSAL.js +0 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as n}from"./chunk.EUCXNNCZ.js";import"./chunk.FKQTQ3FV.js";import"./chunk.RGXNZ7PN.js";import"./chunk.ONDILMIX.js";import{f as s}from"./chunk.VLNI5U6H.js";import"./chunk.GDIRDJF3.js";import"./chunk.Y4R77MKX.js";import"./chunk.FRNIWOKD.js";import"./chunk.42U4UBDE.js";import"./chunk.IKT7JQUW.js";import"./chunk.AKOC43TV.js";import"./chunk.MYCTNK6D.js";import"./chunk.53RZI5PM.js";import"./chunk.XJNXSQT4.js";import"./chunk.VTBAKTFP.js";import"./chunk.7U7Q3HIS.js";import"./chunk.6O67NOZR.js";import"./chunk.WWRWXFYR.js";import"./chunk.ISAMJ7AK.js";import"./chunk.54NSG7BX.js";import"./chunk.6KJSFIO7.js";import"./chunk.UM5IPM22.js";import"./chunk.6XBLDV4A.js";import"./chunk.WOTNMTIY.js";import"./chunk.HAQ4KHRY.js";import"./chunk.PRXKRG6O.js";import"./chunk.AHDOKM4O.js";import"./chunk.TDW6QEG4.js";import"./chunk.LW7KV5SL.js";import"./chunk.2VX6H2LL.js";import"./chunk.ZQ4HFIIS.js";import{a as y,b as i}from"./chunk.MRK6QJV5.js";import{b as r}from"./chunk.AJZBJBMO.js";var c=r(y(),1),e=r(i(),1);function v({store:d,views:t,as:a,scope:o}){let l=(0,c.useMemo)(()=>s({scope:`.${o}`}),[o]);return(0,e.jsxs)("div",{"data-testid":"embed-picture","data-embed-content":"",tabIndex:0,"aria-label":t.places().find(m=>m.as===a)?.title??"The picture",style:{flex:"1 1 auto",minHeight:0,display:"grid",gridTemplateRows:"minmax(0, 1fr)",overflow:"auto",background:"var(--graview-ground)",color:"var(--graview-ink)",fontFamily:"var(--graview-font-body, system-ui)"},children:[(0,e.jsx)("style",{children:l}),(0,e.jsx)(n,{store:d,views:t,as:a})]})}export{v as PictureFace};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{Ab as jt,Bb as Ut,Db as $t,Sa as Gt,Sb as qt,W as Wt,Wa as Kt,Xa as Ft,Zb as Se,_b as Ke,db as Bt,xb as zt}from"./chunk.ZQ4HFIIS.js";import{a as G,b as ve}from"./chunk.MRK6QJV5.js";import{b as N}from"./chunk.AJZBJBMO.js";function rr(e){let t,n=!1,o,r,i=0;return()=>{if(n)return Promise.resolve(t);if(o)return o;let a=i>0&&r!==void 0?$n(r):e();i+=1;let u=a.then(l=>(t=l,n=!0,o=void 0,l),l=>{throw o=void 0,r??=qn(l),l});return o=u,u}}var Yt=0;function $n(e){return Yt+=1,import(`${e}${e.includes("?")?"&":"?"}retry=${Yt}`)}function qn(e,t=import.meta.url){let n=e instanceof Error?e.message:typeof e=="string"?e:"",o=/^(?:Failed to fetch|error loading) dynamically imported module: ([a-z]+:\/\/[^\s"'<>]+)/.exec(n)?.[1]?.replace(/[.,;:)\]]+$/,""),r=i=>i.split("/",3).join("/");return o&&r(o)===r(t)?o:void 0}var Z={focusId:null,relation:null,expanded:[],pins:{}},be=e=>{let t=Number(e);return Number.isFinite(t)?t:null};function $(e){let t=new URLSearchParams;e.focusId&&t.set("focus",e.focusId),e.relation&&t.set("relation",e.relation),e.overview&&t.set("overview","1"),e.zoom&&t.set("zoom","1"),e.past&&t.set("past","1"),e.shown&&e.shown.length>0&&t.set("show",[...e.shown].sort().join(",")),e.selection!==void 0&&e.selection.length>0&&t.set("sel",[...e.selection].sort().join(",")),e.expanded.length>0&&t.set("expand",[...e.expanded].sort().join(","));for(let o of Object.keys(e.pins).sort()){let r=e.pins[o];t.set(`pin.${o}`,`${xe(r.x)},${xe(r.y)}`)}e.pan&&(e.pan.x!==0||e.pan.y!==0)&&t.set("pan",`${xe(e.pan.x)},${xe(e.pan.y)}`);for(let o of Object.keys(e.within??{}).sort()){let r=e.within[o];r.length>0&&t.set(`in.${o}`,r)}e.q&&e.q.trim().length>0&&t.set("q",e.q);let n=t.toString();return n?`#${n}`:"#"}function Yn(e){return e&&e.startsWith("agg:")?`aggregate:${e.slice(4)}`:e}function Ee(e){let t=e.includes("#")?e.slice(e.indexOf("#")+1):e,n=new URLSearchParams(t),o=Object.create(null);for(let[m,p]of n){if(!m.startsWith("pin."))continue;let[h,S]=p.split(","),A=h===void 0?null:be(h),w=S===void 0?null:be(S);A===null||w===null||(o[m.slice(4)]={x:A,y:w})}let r=Object.create(null);for(let[m,p]of n)!m.startsWith("in.")||p.length===0||(r[m.slice(3)]=p);let i=n.get("view");i&&i.length>0&&r.view===void 0&&(r.view=i);let a=n.get("pan")?.split(",")??[],u=a[0]===void 0?null:be(a[0]),l=a[1]===void 0?null:be(a[1]),c=(n.get("sel")??"").split(",").filter(m=>m.length>0).sort(),f=n.get("overview")==="1";return{...c.length>0?{selection:c}:{},...f?{overview:!0}:{},...n.get("zoom")==="1"?{zoom:!0}:{},...n.get("past")==="1"?{past:!0}:{},...n.get("show")?{shown:[...new Set(n.get("show").split(",").filter(Boolean))].sort()}:{},...u!==null&&l!==null?{pan:{x:u,y:l}}:{},...Object.keys(r).length>0?{within:r}:{},...n.get("q")?.trim()?{q:n.get("q")}:{},focusId:Yn(n.get("focus")),relation:n.get("relation"),expanded:(n.get("expand")??"").split(",").filter(m=>m.length>0&&(f||!m.startsWith("kind:"))).sort(),pins:o}}function ar(e){let t=Ee(e);return $(t)==="#"?{...t,overview:!0}:t}function sr(e){let t=$(e);return t==="#overview=1"?"":t}function xe(e){return Math.round(e*100)/100}function Qt(e,t){return $(e)===$(t)}var Fe="edge:";function lr(e,t,n){let o=r=>encodeURIComponent(r);return`${Fe}${o(e)}:${o(t)}:${o(n)}`}function Xt(e){if(!e.startsWith(Fe))return null;let t=e.slice(Fe.length).split(":");if(t.length!==3)return null;let[n,o,r]=t;if(!n||!o||!r)return null;try{return{kind:decodeURIComponent(n),from:decodeURIComponent(o),to:decodeURIComponent(r)}}catch{return null}}function Me(e){let{pan:t,...n}=e;return{...n,pins:{}}}function q(e,t){if(t===e.focusId)return{...e,focusId:t};let n=Me(e);return{...n.within?.q!==void 0?ye(n,"q",null):n,focusId:t}}function Jt(e,t){return{...e,relation:t}}function ye(e,t,n){let o={...e.within??{}};if(n===null?delete o[t]:o[t]=n,Object.keys(o).length===0){let{within:r,...i}=e;return i}return{...e,within:o}}function Be(e,t){if(t!==e.overview&&(e=Me(e)),!t){let n=e.expanded.filter(o=>!o.startsWith("kind:"));return{...e,overview:!1,expanded:n}}return{...e,overview:t}}function dr(e,t,n){let o=new Set(e.shown??[]);if(n?o.add(t):o.delete(t),o.size===0){let{shown:r,...i}=e;return i}return{...e,shown:[...o].sort()}}function Qn(e,t){if(t===null||t.trim().length===0){let{q:n,...o}=e;return o}return{...e,q:t}}function cr(e){let t=e.q!==void 0&&e.within?.q===e.q;return Qn(t?ye(e,"q",null):e,null)}function ur(e,t){if(!t){let{past:n,...o}=e;return o}return{...e,past:!0}}function Pe(e,t){if(t.length===0){let{selection:n,...o}=e;return o}return{...e,selection:[...t]}}function ge(e,t){if(t!==(e.zoom===!0)&&(e=Me(e)),!t){let{zoom:n,...o}=e;return o}return{...e,zoom:!0}}function Re(e,t){let n=new Set(e.expanded);return n.has(t)?n.delete(t):n.add(t),{...e,expanded:[...n].sort()}}function pr(e,t){if(t===null||t.x===0&&t.y===0){let{pan:n,...o}=e;return o}return{...e,pan:t}}function fr(e){return Me(e)}function yr(e,t,n){let o={...e.pins};return n===null?delete o[t]:o[t]=n,{...e,pins:o}}var ke="aggregate:",Ae="kind:";function ze(e){return`${Ae}${e}`}function ee(e){return e.startsWith(Ae)?e.slice(Ae.length):null}var hr="kinds:beyond";function Xn(e){let t=ee(e);return t?[t]:X(e)}function te(...e){return`${ke}${[...e].sort().join("+")}`}function Zt(e){return e.startsWith(ke)}function X(e){return!Zt(e)||e.includes("|")?[]:e.slice(ke.length).split("+").filter(Boolean)}function en(e,t,n={}){let o=ee(t);if(o!==null&&e.overview&&n.ownPicture!==!0)return Re(e,t);let r=o!==null?te(o):t;if(e.zoom&&e.focusId===r&&!(o!==null&&n.carry))return ge(e,!1);if(o!==null&&n.carry){let i=Be({...q(e,r),relation:null},!1);return ye(ge(i,!0),"q",n.carry)}return ge({...q(e,r),relation:null},!0)}function Jn(e,t,n){return ye(Be(q(e,te(t)),!1),"view",n)}function wr(e,t){return e.id<t.id?-1:e.id>t.id?1:0}var tn="aggregate:";function je(e){return e.startsWith(tn)&&e.includes("|")}function Zn(e,t){let n=0,o=138;for(let r of e.split(" ")){let i=t(r),a=o+t(" ")+i;if(a<=138)o=a;else{let u=Math.ceil(i/138)||1;n+=u,o=i-(u-1)*138}}return n}var eo=16.25,Ue=27,to=(e,t)=>{let n=Math.ceil(e.length*7.1/138);return t?Math.max(Ue,Math.ceil(Math.max(n,Zn(e,t))*eo)+6):Math.max(Ue,n*16+6)};function no(e,t,n){return e.length===0?0:10+e.reduce((o,r)=>o+to(r,n),0)+(e.length-1)*2}var nn=27,on=8,oo=4,rn=64,ro=e=>Math.max(1,Math.min(on,e)),io=e=>e*nn+rn;var ao=(e,t)=>e.length*t*.58;var $e=N(G(),1),so={turns:[],outcomes:new Map,busy:!1,open:!1,side:"left",pending:null,drawn:0,draft:null,draftNote:null},an=e=>`graview:seat:${e}`;function lo(e){if(!e)return{};try{let t=sessionStorage.getItem(e);if(!t)return{};let n=JSON.parse(t);return{...Array.isArray(n.turns)?{turns:n.turns}:{},...Array.isArray(n.outcomes)?{outcomes:new Map(n.outcomes)}:{},...typeof n.open=="boolean"?{open:n.open}:{},...n.side==="left"||n.side==="right"?{side:n.side}:{},...n.draft?.drawn?{draft:n.draft}:{}}}catch{return{}}}function co(e,t){if(e)try{sessionStorage.setItem(e,JSON.stringify({turns:t.turns.slice(-40),outcomes:[...t.outcomes],open:t.open,side:t.side,draft:t.draft}))}catch{}}function qe(e){let t=e===null?null:an(e),n={...so,...lo(t)},o=new Set,r=(i,a=!0)=>{n=i,a&&co(t,n);for(let u of[...o])u()};return{get:()=>n,subscribe(i){return o.add(i),()=>void o.delete(i)},setTurns:i=>r({...n,turns:i(n.turns)}),settle:(i,a)=>r({...n,outcomes:new Map(n.outcomes).set(i,a)}),setBusy:i=>r({...n,busy:i},!1),setOpen:i=>{n.open!==i&&r({...n,open:i})},setSide:i=>{n.side!==i&&r({...n,side:i})},ask:i=>r({...n,open:!0,pending:i.trim()||null}),takePending(){let i=n.pending;return i!==null&&r({...n,pending:null},!1),i},drawn(){return r({...n,drawn:n.drawn+1},!1),()=>r({...n,drawn:Math.max(0,n.drawn-1)},!1)},setDraft:(i,a=null)=>r({...n,draft:i,draftNote:a})}}function uo(e){let t=()=>e.get().drawn>0;return(0,$e.useSyncExternalStore)(e.subscribe,t,t)}function po(e){return(0,$e.useSyncExternalStore)(e.subscribe,e.get,e.get)}var Ye={};var fo="I can answer about what's in this app. Open questions need AI, which isn't on here.",yo="Answered with AI";var sn=e=>`graview:setting:${e}`;function ln(){return localStorage}function dn(e,t){try{let n=(t??ln()).getItem(sn(e.name));if(n!==null&&e.options.some(o=>o.value===n))return n}catch{}return e.initial}function cn(e,t,n){try{(n??ln()).setItem(sn(e.name),t)}catch{}}function un(e,t){if(typeof document>"u")return;let n=document.documentElement;if(e.honored==="root-font-size"){n.style.fontSize=t===e.initial?"":t;return}let o=`graview${e.name.replace(/-([a-z0-9])/g,(r,i)=>i.toUpperCase()).replace(/^[a-z]/,r=>r.toUpperCase())}`;t===e.initial?delete n.dataset[o]:n.dataset[o]=t}var T=N(G(),1);function pn(e){return e?.closest?.("[data-graview-pick]")?.getAttribute("data-graview-pick")??null}function Qe(e){return Se(e)}var go=12,mo=4;function ho(e,t,n){let o=Qe(t);return e.get(o)??{participant:o,who:t.id??t.kind,at:null,mode:"docked",since:n,trail:[]}}var Te=(e,t)=>t===null||e[e.length-1]===t?e:[...e,t].slice(-go);function fn(e,t){let n=e.filter(r=>r.length>0);if(n.length===0)return null;if(n.length<=mo)return n[0];let o=new Set(n.map(r=>t(r)).filter(r=>r!==void 0));return o.size===1?ze([...o][0]):n[0]}function Xe(e,t,n){let o=new Map(e);if(t.type==="rest"){for(let[a,u]of e)u.mode!=="asking"&&u.mode!=="docked"&&t.at-u.since>=t.holdMs&&o.set(a,{...u,mode:"docked",at:null,trail:[],say:void 0,confidence:void 0});return o}if(t.author.kind!=="agent")return o;let r=ho(e,t.author,t.at),i=a=>o.set(r.participant,{...r,...a,since:t.at});switch(t.type){case"read":{let a=fn(t.ids,n);return i({at:a,mode:"reading",trail:Te(r.trail,a)}),o}case"about-to-write":case"write":{let a=fn(t.ids,n);return i({at:a,mode:"writing",trail:Te(r.trail,a),say:void 0,confidence:void 0}),o}case"refused":return i({at:t.where,mode:"refused",say:t.say,confidence:void 0,trail:Te(r.trail,t.where)}),o;case"asking":return i({at:t.where??r.at,mode:"asking",say:t.say,...t.confidence!==void 0?{confidence:t.confidence}:{confidence:void 0},trail:Te(r.trail,t.where)}),o;case"said":return i({say:t.say,...t.confidence!==void 0?{confidence:t.confidence}:{confidence:void 0},...t.caption?{caption:t.caption}:{}}),o;case"over":return i({over:t.over}),o;case"home":return i({at:null,mode:"docked",trail:[],say:void 0,confidence:void 0,over:null}),o;default:return o}}var yn="graview:session";function gn(e){let t=()=>typeof crypto<"u"&&"randomUUID"in crypto?crypto.randomUUID().slice(0,8):Math.random().toString(36).slice(2,10);try{let n=e??sessionStorage,o=n.getItem(yn);if(o)return o;let r=t();return n.setItem(yn,r),r}catch{return t()}}var Je={name:"share-where",title:"Where you are",description:"Whether the others here see which stop you are on.",honored:"root-attribute",options:[{value:"shared",label:"Shown"},{value:"private",label:"Hidden"}],initial:"shared"},Ze={name:"share-over",title:"What you point at",description:"Whether the others see the thing under your pointer, outlined in your color.",honored:"root-attribute",options:[{value:"private",label:"Kept to yourself"},{value:"shared",label:"Outlined for others"}],initial:"private"},mn=[Je,Ze],So=800;function hn(e){let{channel:t,store:n,view:o,principal:r,session:i,robots:a,seatWho:u,settingValues:l,setView:c,ttlMs:f=1e4,people:m,seats:p}=e,[h,S]=(0,T.useState)(()=>new Map),[A,w]=(0,T.useState)(null),[v,y]=(0,T.useState)(null),[E,P]=(0,T.useState)(null),H=typeof r.id=="string"&&r.id.length>0,O=H&&(l[Je.name]??Je.initial)==="shared",L=O&&(l[Ze.name]??Ze.initial)==="shared",b=Qe({kind:r.kind,...r.id?{id:r.id}:{},session:i}),k=H?Wt(r,{graph:n.graph,schema:n.schema,...p?{seats:p}:{},...m?{people:m}:{}}):"",V=u?a.get(`agent:${u}:${i}`):void 0,C=(0,T.useMemo)(()=>!t||!O?null:{participant:b,kind:r.kind,name:k,...r.onBehalfOf?.id?{onBehalfOf:r.onBehalfOf.id,...r.onBehalfOf.name?{onBehalfOfName:r.onBehalfOf.name}:{}}:{},hue:Bt(r.id??"nobody"),stop:E??$(o),...L?{over:A}:{},...V?{robot:{at:V.at,mode:V.mode}}:{},at:new Date().toISOString()},[t,O,L,b,k,r.id,r.kind,r.onBehalfOf?.id,r.onBehalfOf?.name,o,E,A,V?.at,V?.mode]);(0,T.useEffect)(()=>{if(!t||!C)return;t.here(C);let R=setInterval(()=>t.here({...C,at:new Date().toISOString()}),So);return()=>clearInterval(R)},[t,C]),(0,T.useEffect)(()=>t?t.onWho(_=>S(Ke(new Map,_,Date.now(),f))):void 0,[t,f]);let ae=h.size>0;(0,T.useEffect)(()=>{if(!ae)return;let R=setInterval(()=>{S(_=>{let Q=Ke(_,[],Date.now(),f);return Q.size===_.size?_:Q})},Math.max(250,Math.min(1e3,f/4)));return()=>clearInterval(R)},[ae,f]),(0,T.useEffect)(()=>{if(!t||typeof window>"u")return;let R=()=>t.leave();return window.addEventListener("pagehide",R),()=>window.removeEventListener("pagehide",R)},[t]),(0,T.useEffect)(()=>{if(!L||typeof document>"u")return;let R=null,_=Q=>{let se=pn(Q.target);se!==R&&(R=se,w(se))};return document.addEventListener("pointermove",_,{passive:!0}),()=>document.removeEventListener("pointermove",_)},[L]);let W=(0,T.useRef)(null),K=v?h.get(v)??null:null,we=(0,T.useCallback)(R=>{W.current=null,y(R)},[]);return(0,T.useEffect)(()=>{if(v){if(!K){y(null);return}K.stop!==W.current?.stop&&(W.current={stop:K.stop,at:Date.now()},c(Ee(K.stop)))}},[v,K,c]),(0,T.useEffect)(()=>{let R=W.current;!v||R===null||Date.now()-R.at<400||Qt(o,Ee(R.stop))||y(null)},[o,v]),(0,T.useEffect)(()=>{if(!v||typeof document>"u")return;let R=_=>{_.key==="Escape"&&y(null)};return document.addEventListener("keydown",R),()=>document.removeEventListener("keydown",R)},[v]),(0,T.useMemo)(()=>({who:h,sharing:C?{participant:b,name:k}:null,following:K,follow:we,sayWhere:P}),[h,C,b,k,K,we])}var B=N(G(),1);function wn(e){return Se(e.author)}function vo(e,t){return e.length>1?"co-edited":t==="rule"?"rule":t==="agent"?"autonomous":"directed"}function Sn(e,t,n,o,r){let i=new Map;for(let[l,c]of e)o-c.at<r&&i.set(l,c);let a=new Set(n.flatMap(l=>l.nodeIds)),u=(l,c,f)=>{let m=i.get(l),p=m?.participants.includes(wn(c))?m.participants:[...m?.participants??[],wn(c)];i.set(l,{at:o,manner:vo(p,c.author.kind),intent:c.intent,wrote:(m?.wrote??!1)||(f.wrote??!1),read:(m?.read??!1)||(f.read??!1),broke:(m?.broke??!1)||a.has(l),participants:p})};for(let l of t){for(let c of l.writes)u(c,l,{wrote:!0});for(let c of l.reads)l.writes.includes(c)||u(c,l,{read:!0})}for(let l of n)for(let c of l.nodeIds){let f=i.get(c);i.set(c,{at:o,manner:f?.manner??"rule",intent:f?.intent??l.message,wrote:f?.wrote??!1,read:f?.read??!1,broke:!0,participants:f?.participants??["rule::"]})}return i}var bo=2600;function vn(e,t=bo){let[n,o]=(0,B.useState)(()=>new Map),r=(0,B.useRef)(n);r.current=n;let i=(0,B.useRef)(null),a=(0,B.useCallback)(l=>{r.current=l,o(l),i.current&&clearTimeout(i.current),i.current=setTimeout(()=>{r.current=new Map,o(new Map)},t)},[t]);(0,B.useEffect)(()=>{let l=e.violations(),c=e.subscribe((f,m)=>{let p=e.violations(),h=$t(e.allInvariants(),l,p).introduces;l=p,a(Sn(r.current,m,h.map(S=>({nodeIds:S.nodeIds,message:S.message})),Date.now(),t))});return()=>{c(),i.current&&clearTimeout(i.current)}},[e,t,a]);let u=(0,B.useCallback)(l=>{l.reads.length!==0&&a(Sn(r.current,[xo(l)],[],Date.now(),t))},[t,a]);return{activity:n,noteAttention:u}}function xo(e){return{id:`attention:${e.intent}`,seq:-1,batch:"attention",author:e.author,intent:e.intent,mutation:null,primitives:[],inverse:[],reads:e.reads,writes:[],at:new Date().toISOString()}}var s=N(G(),1);function bn(){let e=null,t=new Set,n=new Set,o=r=>{for(let i of n)i(r)};return{subscribe(r){return t.add(r),t.size===1&&o(!0),()=>{t.delete(r),t.size===0&&(e=null,o(!1))}},snapshot:()=>e,set(r){if(!(e===r||e&&r&&e.x===r.x&&e.y===r.y)){e=r;for(let i of t)i()}},get listeners(){return t.size},onActive(r){return n.add(r),()=>void n.delete(r)}}}function xn(){let e=!1,t=new Set;return{moving:()=>e,set(n){if(n!==e){e=n;for(let o of t)o()}},subscribe(n){return t.add(n),()=>t.delete(n)}}}var me=N(ve(),1),Oe=(0,s.createContext)(null),Pn=(0,s.createContext)("scene");function Eo({mode:e,children:t}){return(0,me.jsx)(Pn.Provider,{value:e,children:t})}function Mo(){return(0,s.useContext)(Pn)}var Rn={kind:"human"},Po=[],Ro=[],Ao=[],et=[];function An(e,t){let n=(0,s.useId)();(0,s.useEffect)(()=>{if(!globalThis.__graviewWatch)return;let o=t??Rn,r=()=>{jt(e,o,n),Ut(e)};r();let i,a=e.subscribe(()=>{clearTimeout(i),i=setTimeout(r,250)});return()=>{clearTimeout(i),a(),globalThis.__graviewWatch?.unseen?.({words:[],from:n,gone:!0})}},[e,t,n])}function ko({store:e,views:t,initialView:n,scheme:o="dark",initialSelection:r,principal:i,seats:a=Po,onSeat:u,people:l=Ro,memory:c,presenceTtlMs:f,app:m,settings:p=m?.settings??Ao,presence:h,brand:S,onKeepLens:A,providers:w,ai:v=Ye,view:y,onViewChange:E,children:P}){let[H,O]=(0,s.useState)(null),L=H??i??a[0]?.principal??Rn,b=(0,s.useMemo)(()=>e.seenBy(L),[e,L]);An(e,L);let[k]=(0,s.useState)(()=>gn(c)),[V,C]=(0,s.useState)(!1),ae=(0,s.useCallback)(()=>C(!0),[]),W=(0,s.useMemo)(()=>h?[...p,...mn]:p,[p,h]),[K]=(0,s.useState)(()=>n??nt(t,e.schema)),[we,R]=(0,s.useState)(()=>Pe(K??Z,r??K?.selection??[])),_=(0,s.useRef)(K??Z).current,[Q,se]=(0,s.useState)(null),[pt,Gn]=(0,s.useState)(null),De=(0,s.useContext)(Oe),[ft]=(0,s.useState)(()=>De?.seatTalk??qe(S?.name??e.schema.kinds.join(","))),He=A??De?.onKeepLens,yt=m??De?.app,gt=(0,s.useRef)(null),mt=(0,s.useCallback)(d=>{gt.current=d},[]),ht=(0,s.useCallback)(d=>gt.current?.whereIs(d)??null,[]),[wt]=(0,s.useState)(()=>bn()),[St]=(0,s.useState)(()=>xn()),[We,Kn]=(0,s.useState)(null),[le,vt]=(0,s.useState)(()=>new Map),de=(0,s.useRef)(le);de.current=le;let ce=(0,s.useRef)(null),Ge=(0,s.useCallback)(d=>b.graph.getNode(d)?.kind,[b]),U=(0,s.useCallback)(d=>{let g=Xe(de.current,d,Ge);de.current=g,vt(g),ce.current&&clearTimeout(ce.current),[...g.values()].some(M=>M.mode!=="docked"&&M.mode!=="asking")&&(ce.current=setTimeout(()=>{let M=Xe(de.current,{type:"rest",at:Date.now(),holdMs:tt},Ge);de.current=M,vt(M)},tt+20))},[Ge]),bt=(0,s.useCallback)(d=>U({...d,at:d.at??Date.now()}),[U]),xt=(0,s.useCallback)(d=>{Kn(d),d&&U({type:"home",author:{kind:"agent",id:d,session:k},at:Date.now()})},[U,k]);(0,s.useEffect)(()=>b.subscribe((d,g)=>{for(let x of g)x.author.kind==="agent"&&U({type:"write",author:x.author,ids:x.writes,at:Date.now()})}),[b,U]),(0,s.useEffect)(()=>()=>{ce.current&&clearTimeout(ce.current)},[]);let j=(0,s.useMemo)(()=>({...L,session:k}),[L,k]),Et=(0,s.useCallback)(d=>{O(d),u?.(d)},[u]),[ue,Fn]=(0,s.useState)(()=>Object.fromEntries(W.map(d=>[d.name,dn(d,c)])));(0,s.useEffect)(()=>{for(let d of W)un(d,ue[d.name]??d.initial)},[W,ue]);let Mt=(0,s.useCallback)((d,g)=>{let x=W.find(M=>M.name===d);!x||!x.options.some(M=>M.value===g)||(cn(x,g,c),Fn(M=>({...M,[d]:g})))},[W,c]),[Pt,Bn]=(0,s.useState)(null),{activity:Rt,noteAttention:At}=vn(b),kt=(0,s.useCallback)(d=>{At(d),U({type:"read",author:d.author,ids:d.reads,at:Date.now()})},[At,U]),J=(0,s.useCallback)(d=>{if(ee(d)!==null||X(d).length>0||je(d))return!0;let g=Xt(d);return g?b.graph.allEdges().some(x=>x.kind===g.kind&&x.from===g.from&&x.to===g.to):b.graph.getNode(d)!==void 0},[b]),Tt=(0,s.useCallback)(d=>{let g=d.selection??et,x=g.filter(J),M=x.length===g.length?d:Pe(d,x);return M.focusId!==null&&!J(M.focusId)&&(M=q(M,null)),M},[J]),pe=(0,s.useCallback)(d=>{let g=Tt(d),x=Mn(b,j,g.shown);if(g.focusId!==null&&x.size>0){let M=X(g.focusId),Ht=b.graph.getNode(g.focusId);(M.length>0?M.every(Un=>x.has(Un)):Ht?x.has(Ht.kind):!1)&&(g={...g,focusId:null})}if(!g.overview&&g.focusId===null){let M=_.focusId!==null&&!J(_.focusId)?nt(t,e.schema)??{...Z,overview:!0}:_;M.focusId!==null&&J(M.focusId)?g={...g,focusId:M.focusId}:M.overview===!0&&(g={...g,overview:!0})}return g},[Tt,J,b,_,j,t,e.schema]),F=pe(y??we),Ot=(0,s.useMemo)(()=>Mn(b,j,F.shown),[b,j,F.shown]),Vt=(0,s.useMemo)(()=>[...b.modules.administered.entries()].map(([d,g])=>{let x=b.mayAdminister(d,j);return{name:d,...g.description?{description:g.description}:{},kinds:g.kinds??[],canShow:x,shown:x&&(F.shown??[]).includes(d)}}),[b,j,F.shown]),fe=(0,s.useCallback)(d=>{let g=x=>pe(typeof d=="function"?d(x):d);if(y!==void 0){E?.(g(y));return}E&&E(g(F)),R(x=>g(x))},[F,E,y,pe]);(0,s.useEffect)(()=>{y===void 0&&R(d=>{let g=pe(d);return g===d?d:g})},[F,y,pe]);let It=F.selection??et,Lt=(0,s.useCallback)(d=>{fe(g=>Pe(g,typeof d=="function"?d(g.selection??et):d))},[fe]),{who:Ct,following:_t,follow:Nt,sayWhere:zn,sharing:Dt}=hn({channel:h,store:b,view:F,principal:j,session:k,robots:le,seatWho:We,settingValues:ue,setView:fe,seats:a,people:l,...f!==void 0?{ttlMs:f}:{}}),jn=(0,s.useMemo)(()=>({store:b,scheme:o,views:t,view:F,setView:fe,homeView:_,selection:It,setSelection:Lt,menuAt:Q,setMenuAt:se,whereIs:ht,pointer:wt,motion:St,registerScene:mt,robots:le,noteSeat:bt,seatWho:We,registerSeatWho:xt,actsDoor:pt,registerActsDoor:Gn,seatTalk:ft,...c?{memory:c}:{},who:Ct,following:_t,follow:Nt,sayWhere:zn,sharing:Dt,session:k,ai:v,movedByHand:V,noteMoved:ae,emphasis:Pt,setEmphasis:Bn,activity:Rt,noteAttention:kt,principal:j,seats:a,people:l,takeSeat:Et,settings:W,settingValues:ue,chooseSetting:Mt,hiddenKinds:Ot,administered:Vt,...w?{providers:w}:{},...S?{brand:S}:{},...He?{onKeepLens:He}:{},app:yt}),[b,o,t,F,fe,It,Lt,Q,ht,wt,St,mt,le,bt,We,xt,pt,ft,c,Ct,_t,Nt,Dt,k,v,V,ae,Pt,Rt,kt,j,a,l,Et,W,ue,Mt,Ot,Vt,w,S,He,yt]);return(0,me.jsx)(Oe.Provider,{value:jn,children:(0,me.jsx)(To,{children:P})})}var kn=(0,s.createContext)(null);function To({children:e}){let{store:t,view:n,views:o,principal:r,hiddenKinds:i,selection:a}=Y(),u=Ve(),l=n.q,c=n.focusId,f=!!(l&&l.trim().length>0),m=(0,s.useMemo)(()=>f?{flagged:new Set(t.violations().flatMap(S=>S.nodeIds)),touched:Kt(t.log.all())}:null,[t,u,f]),p=c?t.graph.getNode(c)?.kind??ee(c)??(X(c).length===1?X(c)[0]:void 0):void 0,h=(0,s.useMemo)(()=>!l||!m?null:Ft(t,l,{...p?{inKind:p}:{},principal:r,places:o.places(),kinds:t.schema.kinds.filter(S=>!i.has(S)),from:[...a,...c&&t.graph.has(c)?[c]:[]],flagged:m.flagged,touched:m.touched,limit:200}),[t,l,r,o,i,a,c,p,m]);return(0,me.jsx)(kn.Provider,{value:h,children:e})}var En=new WeakMap;function ri(e){let t=En.get(e);return t||En.set(e,t=new Set(e.matched)),t}function Oo(){return(0,s.useContext)(kn)}function Y(){let e=(0,s.useContext)(Oe);if(!e)throw new Error("useGraview must be used inside a <GraviewProvider>.");return e}function Vo(){return(0,s.useContext)(Oe)??null}function Ve(){let{store:e}=Y(),t=(0,s.useRef)(null),n=(0,s.useRef)(null),o=(0,s.useCallback)(()=>(n.current!==e&&(n.current=e,t.current=null),t.current??=e.graph.allNodes(),t.current),[e]),r=(0,s.useCallback)(i=>e.subscribe(()=>{t.current=null,i()}),[e]);return(0,s.useSyncExternalStore)(r,o,o)}function Io(e){let{store:t}=Y(),n=(0,s.useCallback)(r=>t.subscribe(r),[t]),o=(0,s.useCallback)(()=>e===null?void 0:t.graph.getNode(e),[t,e]);return(0,s.useSyncExternalStore)(n,o,o)}function Mn(e,t,n){let o=new Set(e.modules.disabledKinds);for(let r of e.kindsKeptFrom(t))o.add(r);for(let[r,i]of e.modules.administered)if(!(e.mayAdminister(r,t)&&(n??[]).includes(r)))for(let a of i.kinds??[])o.add(a);return o}var tt=2600;function nt(e,t){let n=qt(e.arrangement?.()?.first,t,e.places());if(!(!n||n.to==="home"))return n.to==="place"?{...Z,focusId:te(n.place.kind),within:{view:n.place.as}}:{...Z,focusId:te(n.kind)}}var Ie=Symbol.for("graview.default-view");function Tn(e){return Object.defineProperty(e,Ie,{value:!0,enumerable:!1}),e}function On(e){return typeof e=="function"&&e[Ie]===!0}var ot=Symbol.for("graview.replaces-page");function Vn(e){return typeof e=="function"&&e[ot]===!0}function Co(e){return Gt(e)}function _o(e,t){if(t===e)return e;for(let r of t.registrations()){let i={...r.title?{title:r.title}:{},...r.across?{across:r.across}:{},...r.beside?{beside:!0}:{}};e.register(r.kind,{cardinality:r.cardinality,fidelity:r.fidelity},r.view,i)}let n=t.arrangement?.();n&&e.arrange?.(n);let o=t.homeView?.();return o&&e.home?.(o),e}var oe=N(G(),1);function No(){let{selection:e,setSelection:t}=Y();return(0,oe.useMemo)(()=>({selection:e,set:n=>t(n),clear:()=>t([]),toggle:n=>t(o=>o.includes(n)?o.filter(r=>r!==n):[...o,n]),isSelected:n=>e.includes(n)}),[e,t])}function Do(){let{store:e}=Y(),t=Ve();return(0,oe.useMemo)(()=>Ho(e),[e,t])}var In=new WeakMap;function Ho(e){let t=In.get(e);if(!t){let n={violations:null};e.subscribe(()=>{n.violations=null}),In.set(e,n),t=n}return t.violations??=e.violations(),t.violations}function Wo(){let{view:e,setView:t}=Y();return(0,oe.useMemo)(()=>({view:e,url:$(e),focus:n=>t(o=>q(o,n)),show:n=>t(o=>Jt(o,n)),toggle:n=>t(o=>Re(o,n)),go:n=>t(n)}),[e,t])}var ne={at:0,depth:0,listeners:new Set,tell(){for(let e of this.listeners)e()}};typeof window<"u"&&window.addEventListener("popstate",e=>{let t=e.state;ne.at=typeof t?.graview=="number"?t.graview:0,ne.at>ne.depth&&(ne.depth=ne.at),ne.tell()});var I=N(G(),1),it={profile:{trigger:"profile-button",pane:"profile",opens:"press",focus:"into",drawn:["shell","embed"]},problems:{trigger:"standing",pane:"problems",opens:"press",focus:"into",drawn:["shell","embed"]},places:{trigger:"app-places-open",pane:"app-places",opens:"press",focus:"into",drawn:["embed"]},here:{trigger:"here-open",pane:"here-list",opens:"press",focus:"into",drawn:["shell","embed","pages"]},activity:{trigger:"activity-button",pane:"activity",opens:"press",focus:"into",drawn:["shell","embed","pages"]},find:{trigger:"find-box",pane:"find-strip",opens:"typing",focus:"stays",drawn:["shell"]},districts:{trigger:"beyond-more",pane:"beyond-list",opens:"press",focus:"into",drawn:["shell","embed"]},acts:{trigger:null,pane:"context-menu",opens:"context-menu",focus:"into",drawn:["shell","embed"]},arrange:{trigger:"arrange-add",pane:"arrange-list",opens:"press",focus:"into",drawn:["pages"]},"studio-ask":{trigger:"studio-agent",pane:"studio-agent-panel",opens:"press",focus:"into",drawn:["studio"]}},Go={position:"fixed",inset:"auto",margin:0,zIndex:zt("popover"),boxSizing:"border-box"},Le=6,re=8,Ko=e=>typeof e.showPopover=="function";function Ce(e){try{return e.matches(":popover-open")}catch{return!1}}function Fo(e){if(typeof e=="function"){let o=e();return o?{left:o.x,right:o.x,top:o.y,bottom:o.y}:null}let t=e.current;if(!t||!t.isConnected)return null;let n=t.getBoundingClientRect();return{left:n.left,right:n.right,top:n.top,bottom:n.bottom}}function at(e,t,n={}){let o=Fo(t);if(!o)return;let r={width:document.documentElement.clientWidth||innerWidth,height:innerHeight},i=e.dataset.graviewDesignedHeight??=e.style.maxHeight;e.style.maxHeight=i;let a=e.getBoundingClientRect(),u=r.height-o.bottom-Le-re,l=o.top-Le-re,c=a.height<=u||u>=l,f=Math.max(96,Math.floor(c?u:l)),m=Math.min(a.height,f);a.height>f&&(e.style.maxHeight=i?`min(${i}, ${f}px)`:`${f}px`);let p=a.width,h=n.align==="start"?o.left:o.right-p,S=typeof t=="function"?null:t.current?.closest("[data-graview-embed]")?.getBoundingClientRect();S&&p<=S.right-S.left&&(h<S.left?h=o.left+p<=S.right?o.left:S.left:h+p>S.right&&(h=o.right-p>=S.left?o.right-p:S.right-p));let A=p>=r.width-2*re?Math.max(0,(r.width-p)/2):Math.max(re,Math.min(h,r.width-re-p)),w=c?o.bottom+Le:Math.max(re,o.top-Le-m);e.style.left=`${Math.round(A)}px`,e.style.top=`${Math.round(w)}px`}function Ln(e,t,n,o={}){let r=o.align??"end";(0,I.useLayoutEffect)(()=>{let i=e.current;if(!t||!i)return;if(Ko(i)&&!Ce(i))try{i.showPopover(),zo()}catch{}let a=0,u=c=>{c?.target instanceof Node&&i.contains(c.target)||(cancelAnimationFrame(a),a=requestAnimationFrame(()=>at(i,n,{align:r})))};at(i,n,{align:r}),addEventListener("resize",u),addEventListener("scroll",u,!0);let l=typeof ResizeObserver>"u"?null:new ResizeObserver(()=>u());return l?.observe(i),()=>{if(cancelAnimationFrame(a),removeEventListener("resize",u),removeEventListener("scroll",u,!0),l?.disconnect(),i.isConnected&&Ce(i))try{i.hidePopover()}catch{}}},[t,e,r])}var st=new Set;function Bo(e){return st.add(e),()=>st.delete(e)}function zo(){for(let e of st)if(!(!e.isConnected||!Ce(e)))try{e.hidePopover(),e.showPopover()}catch{}}var ie=null,jo='button:not([disabled]), [href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])';function Uo(e){for(let t of e.querySelectorAll(jo))if(t.closest("[hidden]")===null&&getComputedStyle(t).visibility!=="hidden")return t;return e}var rt=()=>{let e=document.activeElement;return e===null||e===document.body};function $o(e,t={}){let{at:n,returnTo:o,onOpenChange:r}=t,i=t.popover!==!1,[a,u]=(0,I.useState)(!1),l=t.open??a,c=(0,I.useRef)(null),f=(0,I.useRef)(null),m=(0,I.useCallback)(y=>{c.current=y},[]),p=(0,I.useCallback)(y=>{f.current=y},[]),h=`graview-popover-${(0,I.useId)().replace(/:/g,"")}`,S=(0,I.useRef)({onOpenChange:r,returnTo:o,controlled:t.open!==void 0});S.current={onOpenChange:r,returnTo:o,controlled:t.open!==void 0};let A=(0,I.useCallback)(y=>{S.current.controlled||u(y),S.current.onOpenChange?.(y)},[]),w=(0,I.useCallback)(()=>{(document.querySelector(`[aria-controls="${h}"]`)??c.current??S.current.returnTo?.()??null)?.focus({preventScroll:!0})},[h]),v=(0,I.useCallback)(y=>{let E=f.current,P=typeof document>"u"?null:document.activeElement,H=P===null||P===document.body||E!==null&&E.contains(P);A(!1),!(!y||!H)&&(w(),requestAnimationFrame(()=>{rt()&&w()}))},[A,w]);return Ln(f,i&&l,n??c,t.align?{align:t.align}:{}),(0,I.useEffect)(()=>{if(!i||!l)return;let y={name:e,close:()=>v(!1)};if(ie&&ie.close!==y.close&&ie.close(),ie=y,it[e].focus==="into"){let b=f.current;b&&!b.contains(document.activeElement)&&Uo(b).focus({preventScroll:!0})}let E=b=>{b.key==="Escape"&&v(!0)},P=b=>{let k=b.target;if(!(k instanceof Node))return;let V=f.current;if(V?.contains(k)||c.current?.contains(k))return;let C=k instanceof Element?k.closest('[role="dialog"], [role="alertdialog"]'):null;C&&!(V&&C.contains(V))||(v(!1),it[e].focus==="into"&&requestAnimationFrame(()=>{(rt()||V!==null&&V.contains(document.activeElement))&&w()}))},H=null,O=null,L=b=>{let k=b.target;if(!(k instanceof Element))return;let V=f.current,C=k.closest('[role="dialog"], [role="alertdialog"]');!C||V&&(V.contains(C)||C.contains(V))||(H=C,v(!1))};return document.addEventListener("keydown",E),document.addEventListener("pointerdown",P,!0),document.addEventListener("focusin",L),()=>{document.removeEventListener("keydown",E),document.removeEventListener("pointerdown",P,!0),document.removeEventListener("focusin",L);let b=H;b&&typeof MutationObserver<"u"&&(O?.disconnect(),O=new MutationObserver(()=>{b.isConnected||(O?.disconnect(),requestAnimationFrame(()=>{(rt()||document.activeElement.closest("[hidden]")!==null)&&w()}))}),O.observe(document.body,{childList:!0,subtree:!0}),setTimeout(()=>O?.disconnect(),10*6e4)),ie?.close===y.close&&(ie=null)}},[i,l,e,v,w]),{open:l,setOpen:y=>y?A(!0):v(!0),toggle:()=>l?v(!0):A(!0),trigger:{ref:m,"aria-expanded":l,"aria-controls":h,"data-graview-popover-trigger":e},pane:{ref:p,id:h,popover:"manual",tabIndex:-1,"data-graview-popover":e,"data-graview-overlay":""}}}var D=N(G(),1),z=N(ve(),1),lt=new Set,Cn=!1;function dt(){for(let e of[...lt])e()}function qo(){Cn||typeof window>"u"||(Cn=!0,window.addEventListener("online",dt))}function Yo(e){let t,n=!1,o=!1,r,i=0,a=new Set,u=()=>{i+=1;for(let p of[...a])p()},l=p=>(a.add(p),()=>void a.delete(p)),c=()=>i,f=()=>void m().catch(()=>{});function m(){if(n)return Promise.resolve(t);if(r)return r;let p=e().then(h=>(t=h,n=!0,o=!1,r=void 0,lt.delete(f),u(),h),h=>{throw r=void 0,o=!0,lt.add(f),qo(),u(),h});return p.catch(()=>{}),r=p,p}return{load:m,prefetch:f,get current(){return t},get failed(){return o},part(p,h={}){let S=h.what??"This part";function A(y){(0,D.useSyncExternalStore)(l,c,c);let E=(0,D.useRef)(null),P=(0,D.useRef)(null),H=(0,D.useRef)(!1);return(0,D.useEffect)(()=>{o&&r===void 0&&f()},[]),n&&typeof document<"u"&&E.current!==null&&document.activeElement===E.current&&(H.current=!0),(0,D.useLayoutEffect)(()=>{if(!(!n||!H.current)){H.current=!1;for(let O=P.current?.nextElementSibling??null;O!==null;O=O.nextElementSibling){let L=O.matches(_n)?O:O.querySelector(_n);if(L instanceof HTMLElement){L.focus();return}}}}),n?(0,z.jsxs)(z.Fragment,{children:[H.current?(0,z.jsx)("span",{ref:P,hidden:!0}):null,p(t,y)]}):h.quiet?null:(0,z.jsx)(Qo,{what:S,button:E,...h.as?{as:h.as}:{}})}let w=(0,D.lazy)(()=>m().then(()=>({default:A}),()=>({default:A})));function v(y){let[E]=(0,D.useState)(()=>n||o);return(0,D.createElement)(E?A:w,y)}return v}}}var _n="button,a[href],input,select,textarea,[tabindex]:not([tabindex='-1'])";function Qo({what:e,button:t,as:n="p"}){let r=typeof navigator<"u"&&navigator.onLine===!1?`${e} will load when you're back online.`:`${e} didn't load.`;return(0,z.jsxs)(n,{"data-testid":"lazy-part-missing",style:{margin:0,fontSize:"0.875rem",color:"var(--graview-ink-muted)"},children:[(0,z.jsx)("span",{role:"status",children:r})," ",(0,z.jsx)("button",{ref:t,type:"button","data-testid":"lazy-part-retry",onClick:dt,style:{font:"inherit",fontWeight:600,color:"var(--graview-ink)",background:"none",border:"1px solid var(--graview-edge)",borderRadius:6,padding:"2px 10px"},children:"Try again"})]})}var _e=N(G(),1);var Xo=(0,_e.createContext)(null);var Nn=N(G(),1),Jo=(0,Nn.createContext)(!1);var Dn=N(G(),1),Zo=(0,Dn.createContext)(null);var Hn=N(G(),1),ct='button:not([disabled]), a[href], input:not([disabled]):not([type="hidden"]), select:not([disabled]), textarea:not([disabled]), summary, [tabindex]:not([tabindex="-1"])',ut=e=>e instanceof HTMLElement&&(e.matches(ct)||e.hasAttribute("tabindex")),he=e=>typeof e.checkVisibility=="function"?e.checkVisibility():e.getClientRects().length>0;function er(e,t){let n=l=>l.replace(/["\\]/g,"\\$&"),o=t.getAttribute("data-testid"),r=t.getAttribute("data-graview-pick"),i=t.getAttribute("aria-label"),a=o?`[data-testid="${n(o)}"]`:r?`[data-graview-pick="${n(r)}"]`:i?`${t.tagName.toLowerCase()}[aria-label="${n(i)}"]`:null;if(!a)return null;let u=e.querySelector(a);return u&&ut(u)&&he(u)?u:null}var tr=e=>e.isConnected&&ut(e)&&!e.matches(":disabled")&&e instanceof HTMLElement&&he(e);function Wn(e,t){let n=t?er(e,t):null;if(n)return n;let o=e.querySelector("[data-graview-view][tabindex]");if(o&&he(o))return o;for(let r of e.querySelectorAll(ct))if(he(r))return r;return ut(e)&&he(e)?e:null}function nr(e){(0,Hn.useEffect)(()=>{let t=e.current;if(!t||typeof MutationObserver>"u")return;let n=[],o=w=>{let v=w.target;if(v instanceof Element){n=[];for(let y=v;y&&y!==t.parentElement;y=y.parentElement)n.push(y)}},r=!1,i=!1,a=t.ownerDocument,u=()=>!i&&a.defaultView!==null,l=(w,v)=>void setTimeout(()=>u()&&v(),w),c=w=>void requestAnimationFrame(()=>u()&&w()),f=w=>{if(r=!1,i)return;let v=a.activeElement;if(!(!(v===null||v===a.body||v===a.documentElement)||n.length===0)){if(tr(n[0])){w&&n[0]instanceof HTMLElement&&n[0].focus({preventScroll:!0});return}for(let E of n.slice(1)){if(!E.isConnected)continue;let P=Wn(E,n[0]);if(P){P.focus({preventScroll:!0}),n=[];return}}}},m=(w,v=Date.now()+2500)=>{l(100,()=>{f(w);let y=a.activeElement;(y===null||y===a.body||y===a.documentElement)&&n.length>0&&Date.now()<v&&m(w,v)})},p=()=>{r||n.length===0||(r=!0,l(60,()=>c(()=>{f(!1),m(!1)})))},h=w=>{if(!(w instanceof KeyboardEvent&&!["Enter"," ","Escape"].includes(w.key))){if(!(w instanceof KeyboardEvent)){let v=w.target instanceof Element?w.target.closest(ct):null,y=a.activeElement,E=y===null||y===a.body||y===a.documentElement;if(v&&E&&t.contains(v)){n=[];for(let P=v;P&&P!==t.parentElement;P=P.parentElement)n.push(P);l(150,()=>c(()=>{f(!1),m(!1)}));return}}!(w instanceof KeyboardEvent)&&!(w.target instanceof Node&&n[0]?.contains(w.target))||l(150,()=>c(()=>{f(!0),m(!0)}))}},S=new MutationObserver(()=>{n.length>0&&!n[0].isConnected&&p()}),A=w=>{w.relatedTarget===null&&p()};return t.addEventListener("focusin",o),t.addEventListener("focusout",A),t.addEventListener("click",h),t.addEventListener("keydown",h),S.observe(t,{childList:!0,subtree:!0}),()=>{i=!0,t.removeEventListener("focusin",o),t.removeEventListener("focusout",A),t.removeEventListener("click",h),t.removeEventListener("keydown",h),S.disconnect()}},[e])}var Ne=N(G(),1);function Hi(e){let[t,n]=(0,Ne.useState)(null);return(0,Ne.useEffect)(()=>{let o=e.current;if(!o||typeof ResizeObserver>"u")return;let r=()=>n(Math.round(o.getBoundingClientRect().width));r();let i=new ResizeObserver(r);return i.observe(o),()=>i.disconnect()},[e]),t}var Wi={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(50%)",whiteSpace:"nowrap"};export{rr as a,Z as b,$ as c,Ee as d,ar as e,sr as f,Qt as g,lr as h,Xt as i,q as j,Jt as k,ye as l,Be as m,dr as n,Qn as o,cr as p,ur as q,Pe as r,ge as s,Re as t,pr as u,fr as v,yr as w,ke as x,ze as y,ee as z,hr as A,Xn as B,te as C,Zt as D,X as E,en as F,Jn as G,wr as H,tn as I,je as J,Ue as K,no as L,nn as M,oo as N,rn as O,ro as P,io as Q,ao as R,fo as S,yo as T,qe as U,uo as V,po as W,pn as X,Eo as Y,Mo as Z,An as _,ko as $,ri as aa,Oo as ba,Y as ca,Vo as da,Ve as ea,Io as fa,nt as ga,Xo as ha,Tn as ia,On as ja,Vn as ka,Co as la,_o as ma,Jo as na,Zo as oa,No as pa,Do as qa,Wo as ra,ne as sa,nr as ta,Go as ua,Ce as va,Bo as wa,$o as xa,Yo as ya,Hi as za,Wi as Aa};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a as b,b as c,c as d,d as e,e as f,f as g}from"./chunk.WEGBBWWK.js";import"./chunk.6MCK7K3M.js";import"./chunk.54NSG7BX.js";import"./chunk.6KJSFIO7.js";import"./chunk.6XBLDV4A.js";import"./chunk.WOTNMTIY.js";import{va as a}from"./chunk.ZQ4HFIIS.js";import"./chunk.AJZBJBMO.js";export{a as ActRefusal,e as compileDocumentWithoutCheck,d as effectsOf,f as frameworkPath,g as inDocumentWords,c as kindShapes,b as readDocument};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{b as m}from"./chunk.
|
|
1
|
+
import{b as m}from"./chunk.NRWJ6PLU.js";import{j as f}from"./chunk.PRXKRG6O.js";import{Aa as T,ca as c,ea as b,ua as L,xa as R}from"./chunk.2VX6H2LL.js";import{L as A,W as I,X as k,ua as x}from"./chunk.ZQ4HFIIS.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{a,b,c,d,e,f,g,h,i}from"./chunk.BLAODPYJ.js";import"./chunk.ISAMJ7AK.js";import"./chunk.54NSG7BX.js";import"./chunk.6KJSFIO7.js";import"./chunk.UM5IPM22.js";import"./chunk.6XBLDV4A.js";import"./chunk.WOTNMTIY.js";import"./chunk.ZQ4HFIIS.js";import"./chunk.AJZBJBMO.js";export{f as columnActs,c as columnMoves,b as columnOf,d as columnReach,e as columnSteps,h as describePlace,i as placeText,g as resolveFor,a as statusColumns};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A as f,I as d,
|
|
1
|
+
import{A as f,I as d,Vb as y,ha as m,ja as p}from"./chunk.ZQ4HFIIS.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};
|
|
@@ -1 +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.
|
|
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.XJNXSQT4.js";import{a,b}from"./chunk.TDW6QEG4.js";import"./chunk.LW7KV5SL.js";import"./chunk.2VX6H2LL.js";import"./chunk.ZQ4HFIIS.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as y}from"./chunk.
|
|
1
|
+
import{a as y}from"./chunk.HAQ4KHRY.js";import{Aa as g,a as f,ya as m}from"./chunk.2VX6H2LL.js";import{T as p}from"./chunk.ZQ4HFIIS.js";import{a as R,b as c}from"./chunk.MRK6QJV5.js";import{b as u}from"./chunk.AJZBJBMO.js";var s=u(R(),1);var r=u(c(),1),S,h=()=>S??=m(f(()=>import("./chunk.KWSXL3A2.js")));function L(e){let[n,t]=(0,s.useState)(()=>h().current);return(0,s.useEffect)(()=>{if(!e||n)return;let i=!0;return h().load().then(a=>i&&t(a),()=>{}),()=>{i=!1}},[e,n]),n}function D(e,n){let t=L(n.length>0);return(0,s.useMemo)(()=>t?t.withLines(e,n):n,[t,e,n])}function I(e,n){let t=L(n.some(i=>i.shape));return(0,s.useMemo)(()=>{let i=new Map;if(!t)return i;for(let a of n){let l=t.ruleLine(a,e);l&&i.set(a.name,l)}return i},[t,e,n])}function M(e){let n=e.line;if(!(!n||e.message.endsWith(` \u2014 ${n.text}`)||e.message===b(e)))return e.message}function b(e){let n=e.line;return n?n.record!==void 0?`${n.record} \u2014 ${n.text}`:n.text:e.message}var P={name:{},op:{color:"var(--graview-ink-muted)",fontWeight:500},value:{fontWeight:600,fontVariantNumeric:"tabular-nums"},word:{color:"var(--graview-ink-muted)"},open:{color:"var(--graview-ink-faint)"},close:{color:"var(--graview-ink-faint)"}};function w({parts:e}){return(0,r.jsx)(r.Fragment,{children:e.map((n,t)=>(0,r.jsxs)("span",{children:[n.space?" ":"",(0,r.jsx)("span",{"data-graview-rule-part":n.as,style:P[n.as],children:n.text})]},t))})}function x(e,n){let t=p(e?.tryDefinition(n),n);return t.charAt(0).toUpperCase()+t.slice(1)}function C({line:e,schema:n,brand:t,lead:i=e.record===void 0?"kind":"record",stacked:a=!1,style:l}){let d=e.kind,o=i==="kind"?d?x(n,d):void 0:i==="record"?e.record:void 0,k=i==="kind"&&o?`${o}: ${e.said}`:i==="record"&&o?`${o} \u2014 ${e.said}`:e.said;return(0,r.jsxs)("span",{"data-graview-rule-line":"",style:{overflowWrap:"anywhere",...l},children:[(0,r.jsx)("span",{style:g,children:k}),(0,r.jsxs)("span",{"aria-hidden":"true",children:[i!=="none"&&d?(0,r.jsx)("span",{style:{display:"inline-flex",verticalAlign:"-0.1em",marginRight:"0.4em"},children:(0,r.jsx)(y,{kind:d,...n?{schema:n}:{},...t?{brand:t}:{},size:13})}):null,o?(0,r.jsxs)("span",{"data-graview-rule-head":"",style:{fontWeight:600,marginRight:i==="record"||a?0:"0.6em"},children:[o,i==="record"&&!a?(0,r.jsx)("span",{style:{color:"var(--graview-ink-faint)",fontWeight:400},children:" \u2014 "}):null]}):null,a&&o?(0,r.jsx)("br",{}):null,(0,r.jsx)(w,{parts:e.parts}),e.when&&e.when.length>0?(0,r.jsxs)("span",{"data-graview-rule-when":"",style:{color:"var(--graview-ink-faint)"},children:[", when ",(0,r.jsx)(w,{parts:e.when})]}):null]})]})}function z(e){return e.line?e.label&&e.label.trim().length>0?e.label:void 0:e.label&&e.label!==e.message?e.label:void 0}export{D as a,I as b,M as c,b as d,C as e,z as f};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as H,b as N,c as C,d as de,e as le}from"./chunk.ENMNLR73.js";import{g as l}from"./chunk.LZQZP2PD.js";import{B as ce,a as G,b as K,d as te,e as ie,f as O,g as p,j,k as oe,l as R,m as re,n as E,o as b,q as g,r as se,s as w,t as m,u as _,v,w as i,x as F,y as ae}from"./chunk.Y235YZSZ.js";var Oe="graview-document",je=1,sn=256*1024,X=64*1024,ue=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,J=/^[a-z][A-Za-z0-9]*$/,Re=new Set(["id","kind"]),Ee=e=>e in Object.prototype,fe=F(e=>!Ee(e),"every object already has this name \u2014 choose another"),pe=(e,n)=>[...e===void 0?[]:[ie(e)],...n===void 0?[]:[te(n)]],f=(e,n)=>p().check(...pe(e,n)),h=(e,n,s)=>b(e).check(...pe(n,s)),z=e=>p().check(O(ue,`${e} names are lower-case words joined by hyphens, like "booked-vendor"`)),Ae=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,I=p().check(O(Ae,'relation names are one camelCase word, like "tendedBy"'),fe),x=p().check(O(J,'field names are one word or camelCase, like "dueDate" \u2014 rules say them bare'),F(e=>!Re.has(e),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),fe),A=f(1,500),M=f(1,2e3),q=f(1,300),Fe=["string","text","number","integer","boolean","date","datetime","enum","list","url","email"],ge=g({type:_(Fe),required:i(R()),description:i(A),label:i(f(1,60)),options:i(h(f(1,80),1,100)),of:i(_(["string","number","date"])),default:i(E()),unit:i(f(void 0,12)),format:i(_(["money","percent","duration"])),min:i(j()),max:i(j()),step:i(j()),renamedFrom:i(p().check(O(J)))}).check(ae((e,n)=>{e.type==="enum"&&!e.options&&n.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),e.type!=="enum"&&e.options&&n.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),e.type!=="list"&&e.of&&n.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]})})),Ve=g({to:w([h(z("kind"),1),v("*")]),cardinality:i(_(["one","many"])),description:i(A),inverse:i(f(1,80)),appendOnly:i(R()),renamedFrom:i(p())}),ye=w([M,g({expr:M,label:i(f(1,60)),description:i(A)})]),Te=g({noun:i(f(1,40)),plural:i(f(1,40)),description:i(A),fields:m(x,ge).check(F(e=>Object.keys(e).length>0,"a kind has at least one field")),label:i(q),describe:i(q),lifecycle:i(g({field:x,retired:h(w([p(),j(),R()]),1)})),figure:i(f(void 0,2e4)),glance:i(h(x,1,20)),page:i(g({fields:i(h(x,1,40)),groups:i(h(g({title:f(1,60),fields:h(x,1,40)}),1,12))})),edges:i(m(I,Ve)),computed:i(m(p(),ye).check(F(e=>Object.keys(e).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:i(m(p(),p())),renamedFrom:i(p().check(O(ue)))}),B=w([p(),j(),R(),re(),b(E()),g({expr:M})]),D=p().check(O(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),_e=w([g({create:z("kind"),as:i(p().check(O(J))),set:i(m(x,B))}),g({set:m(x,B),target:i(D)}),g({connect:I,from:D,to:D}),g({sever:I,from:D,to:D}),g({remove:D})]),De=g({title:i(f(1,80)),description:i(A),fromTheOtherEnd:i(f(1,80)),on:i(w([z("kind"),h(z("kind"),1)])),creates:i(z("kind")),sets:i(m(x,B)),writes:i(h(x,1)),connects:i(I),severs:i(I),setsOther:i(m(x,B)),replaces:i(w([v(!0),h(I,1,10)])),removes:i(v(!0)),args:i(m(x,ge)),effects:i(h(_e,1,20)),allowedWhen:i(M),refusal:i(q),destructive:i(R())}),Ie=g({act:z("act"),label:i(f(1,80)),args:i(m(p(),B))}),Me=g({title:i(f(1,120)),description:i(A),over:w([v("graph"),z("kind")]),when:i(M),require:M,says:i(q),repairs:i(h(Ie,void 0,10))}),Le=g({roles:w([h(z("role"),1),v("*")]),mutations:w([h(z("act"),1),v("*")]),kinds:i(w([b(z("kind")),v("*")])),describe:i(A),self:i(R())}),Ke=g({roles:w([h(z("role"),1),v("*")]),kinds:h(z("kind"),1),own:i(R())}),Be=g({grants:b(Le),sees:i(b(Ke))}),Ge=g({accent:i(p().check(O(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:i(f(1,60)),currency:i(p().check(O(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:i(f(2,35)),logo:i(w([f(1,X),g({src:f(1,X),alt:i(f(1,120))})])),favicon:i(f(1,X)),typography:i(g({display:i(f(1,200)),body:i(f(1,200)),mono:i(f(1,200))})),shape:i(g({radius:i(j().check(K(0),G(32))),density:i(j().check(K(.75),G(1.5)))})),accents:i(m(p(),j().check(K(0),G(360)))),scheme:i(_(["light","dark","auto"]))}),P=m(p(),E()),Ne=g({card:i(b(E())),row:i(b(E())),page:i(b(E()))}),Ce=se({order:i(b(p())),hide:i(b(p())),first:i(p()),primary:i(h(f(1,80),void 0,40)),scene:i(f(1,40)),pages:i(f(1,40))}),an=g({$schema:i(p()),format:v(Oe),formatVersion:v(je),name:f(1,80),description:i(A),version:i(j().check(oe(),K(1))),kinds:m(z("kind"),Te).check(F(e=>Object.keys(e).length>0,"a document declares at least one kind"),F(e=>Object.keys(e).length<=40,"a document declares at most 40 kinds")),computed:i(m(p(),ye)),acts:i(m(z("act"),De)),rules:i(m(z("rule"),Me)),roles:i(b(z("role"))),policy:i(Be),modules:i(P),lenses:i(b(P)),pages:i(Ce),views:i(m(p(),w([Ne,b(E())]))),brand:i(Ge),settings:i(b(P)),migrations:i(b(P))});var W=e=>e?._zod?.def,Pe=/^\^\\d\{4\}-\\d\{2\}-\\d\{2\}\$$/;function qe(e){let n=W(e),s=!0,r;for(let t=0;n&&t<4;t++){if(n.type==="optional"||n.type==="nullable")s=!1;else if(n.type==="default")s=!1,r=n.defaultValue;else break;n=W(n.innerType)}if(!n)return{why:"it is not a zod field"};let c=ce(e),d={...s?{required:!0}:{},...r!==void 0?{default:r}:{},...c?{description:c}:{}},a=(n.checks??[]).map(t=>W(t));switch(n.type){case"string":{let t=n.format;return t==="email"?{spec:{type:"email",...d}}:t==="url"?{spec:{type:"url",...d}}:t==="date"?{spec:{type:"date",...d}}:t==="datetime"?{spec:{type:"datetime",...d}}:a.some(o=>o?.format==="regex"&&Pe.test(String(o?.pattern?.source??"")))?{spec:{type:"date",...d}}:{spec:{type:"string",...d}}}case"number":{let t={};for(let o of a){let u=o?.value;typeof u=="number"&&(o?.check==="greater_than"&&o.inclusive?t.min=Math.max(t.min??u,u):o?.check==="less_than"&&o.inclusive?t.max=Math.min(t.max??u,u):o?.check==="multiple_of"&&(t.step=u))}return{spec:{type:a.some(o=>o?.format==="safeint"||o?.format==="int")?"integer":"number",...t,...d}}}case"boolean":return{spec:{type:"boolean",...d}};case"enum":{let t=Object.keys(n.entries??{});return t.length>0?{spec:{type:"enum",options:t,...d}}:{why:"it is an enum with no options"}}case"array":{let t=W(n.element),o=t?.type==="number"?"number":t?.type==="string"?"string":void 0;return o?{spec:{type:"list",of:o,...d}}:{why:`it is a list of ${String(t?.type??"something")}, and a document lists words, numbers or dates`}}default:return{why:`it is a ${String(n.type)}, which a document has no field type for`}}}function ln(e){let n=qe(e);return"spec"in n?n.spec:void 0}var Q=["card","row","page"],ee=["good","warn","bad","neutral","accent"],me=["money","percent","date","relative","count"],he=4,U=40,be=["number","money","percent"],We=["card","row"],ze=100,Z={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone"],badge:["tone"],field:["as","currency","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label"]},Ze=Object.keys(Z),ke=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`;function hn(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function bn(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var Ue={field:()=>!1,relation:()=>!1,figure:!1},Ye=e=>e.kind??"the home",V=(e,n)=>e!==void 0&&Object.hasOwn(e,n),S=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function $e(e,n,s){let r=H(e);for(let c of r.unknownFunctions)s.findings.push(l("unknown-function",n,`"${c}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let c of r.names){if(s.kind===null){s.findings.push(l("view-name",n,`"${c}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}c==="id"||s.spec.field(c)||s.spec.relation(c)||s.findings.push(l("view-name",n,`${s.kind} has no field or relation called "${c}"`))}for(let c of r.edges)s.edges.has(c)||s.findings.push(l("view-edge",n,`"${c}" is not a relation any kind declares`));for(let c of r.sweeps)s.kinds.has(c)||s.findings.push(l("view-kind",n,`"${c}" is not a kind this document declares`))}function L(e,n,s){if(typeof e!="string"||e.length===0||e.length>2e3){s.findings.push(l("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{$e(C(e),n,s)}catch(r){if(!(r instanceof N))throw r;s.findings.push(l("expression",n,`${r.sentence} (at character ${r.at+1})`))}}function ne(e,n,s){if(typeof e!="string"||e.length===0||e.length>300){s.findings.push(l("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let r;try{r=le(e)}catch(c){if(c instanceof de||c instanceof N){s.findings.push(l("template",n,c.sentence));return}throw c}for(let c of r)c.expr&&$e(c.expr,n,s)}function He(e,n,s){if(typeof e=="string"){ee.includes(e)||s.findings.push(l("view-tone",n,`"${e}" is not a tone`,`use one of ${ee.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(S(e)&&Object.keys(e).length===1&&"expr"in e){L(e.expr,`${n}.expr`,s);return}s.findings.push(l("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${ee.join(", ")}`))}function Y(e,n,s,r){if(!Array.isArray(e)){r.findings.push(l("view-shape",n,"a view is a list of blocks"));return}if(s>he){r.findings.push(l("view-depth",n,`blocks nest at most ${he} deep`,"flatten a group or a condition"));return}e.forEach((c,d)=>Xe(c,`${n}.${d}`,s,r))}function Xe(e,n,s,r){if(r.count++,!S(e)){r.findings.push(l("view-block",n,"a block is an object naming what it shows",`one of ${ke}`));return}let c=Object.keys(e),d=c.filter(o=>Ze.includes(o)&&!(o==="group"&&c.includes("list")));if(d.length===0){r.findings.push(l("view-block",n,`${c.length>0?c.map(o=>`"${o}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${ke}`));return}if(d.length>1){r.findings.push(l("view-block",n,`a block is one thing, and this says ${d.map(o=>`"${o}"`).join(" and ")}`,"split it into two blocks"));return}let a=d[0];for(let o of c)o!==a&&o!="key"&&!Z[a].includes(o)&&r.findings.push(l("unknown-key",`${n}.${o}`,`"${o}" is not part of a ${a} block`,Z[a].length>0?`a ${a} block may also say ${Z[a].map(u=>`"${u}"`).join(", ")}`:`a ${a} block says nothing else`));let t=e[a];switch(a){case"title":case"headline":case"text":case"badge":ne(t,`${n}.${a}`,r),"tone"in e&&He(e.tone,`${n}.tone`,r);return;case"field":{if(typeof t!="string"||!r.spec.field(t)){let o=typeof t=="string"&&r.spec.relation(t);r.findings.push(l("view-field",`${n}.field`,`${r.kind} has no field ${typeof t=="string"?`"${t}"`:"by that name"}`,o?`"${t}" is a relation; show it with {"text": "{${t}.name}"}`:void 0))}"as"in e&&!me.includes(e.as)&&r.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show a field`,`use one of ${me.join(", ")}`)),Se(e,n,r,"field"),"label"in e&&nn(e.label,`${n}.label`,r);return}case"progress":{!S(t)||Object.keys(t).some(o=>o!=="value"&&o!=="max")||!("value"in t)||!("max"in t)?r.findings.push(l("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(L(t.value,`${n}.progress.value`,r),L(t.max,`${n}.progress.max`,r)),"label"in e&&ne(e.label,`${n}.label`,r);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&r.findings.push(l("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),Y(t,`${n}.group`,s+1,r);return;case"when":L(t,`${n}.when`,r),"show"in e?Y(e.show,`${n}.show`,s+1,r):r.findings.push(l("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof t=="string")return Je(e,n,r);for(let o of["as","currency","label"])o in e&&r.findings.push(l("unknown-key",`${n}.${o}`,`"${o}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));t!==!0?r.findings.push(l("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):r.spec.figure||r.findings.push(l("view-figure",`${n}.figure`,`${Ye(r)} has no figure to show`,r.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return en(e,n,r);case"divider":t!==!0&&r.findings.push(l("view-block",`${n}.${a}`,`write {"${a}": true}`));return}}function Je(e,n,s){L(e.figure,`${n}.figure`,s),"as"in e&&!be.includes(e.as)&&s.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${be.join(", ")}`)),Se(e,n,s,"figure"),"label"in e&&ne(e.label,`${n}.label`,s)}function Se(e,n,s,r){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?s.findings.push(l("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&s.findings.push(l("view-currency",`${n}.currency`,`a currency belongs on a ${r} shown as money`,'add "as": "money"')))}function Qe(e,n){let s=[...n.kinds],r=(d,a)=>{let t=new Set;for(let o of d){let u=n.vocabulary.namesOf(o)?.targets?.(a);if(u==="*")return s;for(let y of u??[])t.add(y)}return t.size>0?[...t]:void 0},c=d=>{switch(d.t){case"ident":return n.kind!==null&&n.spec.relation(d.name)?r([n.kind],d.name):void 0;case"member":{let a=c(d.object);return a?r(a,d.name):void 0}case"where":return c(d.set);case"call":{let a=d.args[0],t=a?.t==="lit"&&typeof a.value=="string"?a.value:void 0;if(d.fn==="all")return t!==void 0&&n.kinds.has(t)?[t]:void 0;let o=d.args.length===2&&d.args[1]?.t==="lit"&&typeof d.args[1].value=="string"?d.args[1].value:void 0;if(d.fn==="out"&&o!==void 0){let u=c(a);return u?r(u,o):void 0}if(d.fn==="out")return t!==void 0&&n.kind!==null?r([n.kind],t):void 0;if(d.fn==="in"){let u=o??t,y=o!==void 0?c(a):n.kind!==null?[n.kind]:void 0,k=u!==void 0?n.vocabulary.sources(u).filter($=>{let T=n.vocabulary.namesOf($)?.targets?.(u);return!y||T==="*"||y.some(xe=>T?.includes(xe))}):[];return k.length>0?k:void 0}if((d.fn==="sort"||d.fn==="first")&&a)return c(a);if(d.fn==="either"){let u=d.args.map(c);return u.every(y=>y!==void 0)?[...new Set(u.flatMap(y=>y??[]))]:void 0}return}default:return}};return c(e)}function we(e,n,s,r){let c;try{c=C(e)}catch(a){if(!(a instanceof N))throw a;r.findings.push(l("expression",n,`${a.sentence} (at character ${a.at+1})`));return}let d=H(c);for(let a of d.unknownFunctions)r.findings.push(l("unknown-function",n,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of d.edges)r.edges.has(a)||r.findings.push(l("view-edge",n,`"${a}" is not a relation any kind declares`));if(s)for(let a of d.names)a==="id"||s.some(t=>r.vocabulary.namesOf(t)?.field(a)||r.vocabulary.namesOf(t)?.relation(a))||r.findings.push(l("view-name",n,`${s.join(" and ")} ${s.length===1?"has":"have"} no field or relation called "${a}"`))}function en(e,n,s){let r=e.list;L(r,`${n}.list`,s);let c;if(typeof r=="string")try{c=Qe(C(r),s)}catch{c=void 0}let d=t=>{if(!c)return[...s.kinds].map(u=>s.vocabulary.namesOf(u)?.choices?.(t)).find(u=>u!==void 0);let o=c.map(u=>s.vocabulary.namesOf(u)?.choices?.(t));return o.every(u=>u!==void 0)?[...new Set(o.flatMap(u=>u??[]))]:void 0},a=c?c.join(" and "):"any kind";if("sort"in e){let t=e.sort;if(typeof t=="string")we(t,`${n}.sort`,c,s);else if(S(t)&&typeof t.by=="string"&&Object.keys(t).every(o=>o==="by"||o==="direction")){let o=t.direction;o!==void 0&&o!=="asc"&&o!=="desc"&&o!=="choices"?s.findings.push(l("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(o)}"`,'"choices" puts a choice field in the order its choices are declared')):o==="choices"?d(t.by)===void 0&&s.findings.push(l("list-sort",`${n}.sort.by`,`"${t.by}" is not a choice field of ${a}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):we(t.by,`${n}.sort.by`,c,s)}else s.findings.push(l("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let t=e.limit;(typeof t!="number"||!Number.isInteger(t)||t<1||t>ze)&&s.findings.push(l("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${ze}`))}if("group"in e){let t=e.group,o=typeof t=="string"?t:S(t)&&typeof t.by=="string"?t.by:void 0;if(!(typeof t=="string"||S(t)&&Object.keys(t).every(y=>y==="by"||y==="headings"))||o===void 0)s.findings.push(l("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}}'));else{let y=d(o);if(y===void 0&&s.findings.push(l("list-group",`${n}.group`,`"${o}" is not a choice field of ${a}, so it has no choices to group by`,"group by a field whose type is enum")),S(t)&&"headings"in t){let k=t.headings;if(!S(k)||Object.values(k).some($=>typeof $!="string"||$.length===0||$.length>80))s.findings.push(l("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(y)for(let $ of Object.keys(k))y.includes($)||s.findings.push(l("list-group",`${n}.group.headings.${$}`,`"${$}" is not one of ${o}'s choices`,`use ${y.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&s.findings.push(l("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!We.includes(e.as)&&s.findings.push(l("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function nn(e,n,s){(typeof e!="string"||e.length===0||e.length>60)&&s.findings.push(l("view-label",n,"a label is a few words, at most 60 characters"))}function ve(e,n,s,r,c,d,a){let t={kind:null,spec:Ue,kinds:r,edges:c,vocabulary:s,findings:d,count:0};Array.isArray(e)&&e.length===0&&d.push(l("view-shape",n,`${a} has no blocks`,'give it one: {"headline": "\u2026"}')),Y(e,n,1,t),t.count>U&&d.push(l("view-size",n,`${a} has ${t.count} blocks; a view has at most ${U}`,"show less"))}function tn(e,n,s,r,c){Array.isArray(e)&&e.forEach((d,a)=>{if(!S(d)||d.name!=="blocks"||!S(d.options)||!("blocks"in d.options))return;let t=[];ve(d.options.blocks,`lenses.${a}.options.blocks`,n,s,r,t,`the lens "${String(d.title??a)}"`);for(let o of t)c.push({...o,severity:"warning"})})}function on(e,n,s,r,c,d,a){let t=[];if(e===void 0)return t;if(!S(e))return t.push(l("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),t;for(let[o,u]of Object.entries(e)){if(o==="home"&&Array.isArray(u)){ve(u,`${n}.home`,a,r,c,t,"the home");continue}let y=s(o);if(!y){t.push(l("view-kind",`${n}.${o}`,`"${o}" is not a kind this ${d} declares`));continue}if(!S(u)){t.push(l("view-shape",`${n}.${o}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let k of Object.keys(u))Q.includes(k)||t.push(l("view-slot",`${n}.${o}.${k}`,`"${k}" is not a place a view is drawn`,`use ${Q.map($=>`"${$}"`).join(", ")}`));for(let k of Q){let $=u[k];if($===void 0)continue;let T={kind:o,spec:y,kinds:r,edges:c,vocabulary:a,findings:t,count:0};Y($,`${n}.${o}.${k}`,1,T),T.count>U&&t.push(l("view-size",`${n}.${o}.${k}`,`this ${k} has ${T.count} blocks; a view has at most ${U}`,"show less, or move detail to the page"))}}return t}function zn(e){let n=new Set(Object.keys(e.kinds)),s=new Set(Object.values(e.kinds).flatMap(a=>Object.keys(a.edges??{}))),r=a=>{let t=V(e.kinds,a)?e.kinds[a]:void 0;return t?{field:o=>V(t.fields,o)||V(t.computed,o),relation:o=>V(t.edges,o),figure:t.figure!==void 0,choices:o=>V(t.fields,o)&&t.fields[o].type==="enum"?t.fields[o].options:void 0,targets:o=>V(t.edges,o)?t.edges[o].to:void 0}:void 0},c={namesOf:r,sources:a=>Object.keys(e.kinds).filter(t=>V(e.kinds[t].edges,a))},d=on(e.views,"views",r,n,s,"document",c);return tn(e.lenses,c,n,s,d),d}export{Oe as a,je as b,sn as c,an as d,ln as e,ee as f,me as g,be as h,ze as i,hn as j,bn as k,zn as l};
|
|
1
|
+
import{a as H,b as N,c as C,d as de,e as le}from"./chunk.6XBLDV4A.js";import{g as l}from"./chunk.WOTNMTIY.js";import{B as ce,a as G,b as K,d as te,e as ie,f as O,g as p,j,k as oe,l as R,m as re,n as E,o as b,q as g,r as se,s as w,t as m,u as _,v,w as i,x as F,y as ae}from"./chunk.ZQ4HFIIS.js";var Oe="graview-document",je=1,sn=256*1024,X=64*1024,ue=/^[a-z][a-z0-9]*(?:-[a-z0-9]+)*$/,J=/^[a-z][A-Za-z0-9]*$/,Re=new Set(["id","kind"]),Ee=e=>e in Object.prototype,fe=F(e=>!Ee(e),"every object already has this name \u2014 choose another"),pe=(e,n)=>[...e===void 0?[]:[ie(e)],...n===void 0?[]:[te(n)]],f=(e,n)=>p().check(...pe(e,n)),h=(e,n,s)=>b(e).check(...pe(n,s)),z=e=>p().check(O(ue,`${e} names are lower-case words joined by hyphens, like "booked-vendor"`)),Ae=/^(?:[a-z][a-z0-9]*(?:-[a-z0-9]+)*|[a-z][A-Za-z0-9]*)$/,I=p().check(O(Ae,'relation names are one camelCase word, like "tendedBy"'),fe),x=p().check(O(J,'field names are one word or camelCase, like "dueDate" \u2014 rules say them bare'),F(e=>!Re.has(e),'a field cannot be called "id" or "kind" \u2014 the framework keeps those; try "type" or "category"'),fe),A=f(1,500),M=f(1,2e3),q=f(1,300),Fe=["string","text","number","integer","boolean","date","datetime","enum","list","url","email"],ge=g({type:_(Fe),required:i(R()),description:i(A),label:i(f(1,60)),options:i(h(f(1,80),1,100)),of:i(_(["string","number","date"])),default:i(E()),unit:i(f(void 0,12)),format:i(_(["money","percent","duration"])),min:i(j()),max:i(j()),step:i(j()),renamedFrom:i(p().check(O(J)))}).check(ae((e,n)=>{e.type==="enum"&&!e.options&&n.addIssue({code:"custom",message:'an enum field lists its "options"',path:["options"]}),e.type!=="enum"&&e.options&&n.addIssue({code:"custom",message:'"options" belongs only on an enum field',path:["options"]}),e.type!=="list"&&e.of&&n.addIssue({code:"custom",message:'"of" belongs only on a list field',path:["of"]})})),Ve=g({to:w([h(z("kind"),1),v("*")]),cardinality:i(_(["one","many"])),description:i(A),inverse:i(f(1,80)),appendOnly:i(R()),renamedFrom:i(p())}),ye=w([M,g({expr:M,label:i(f(1,60)),description:i(A)})]),Te=g({noun:i(f(1,40)),plural:i(f(1,40)),description:i(A),fields:m(x,ge).check(F(e=>Object.keys(e).length>0,"a kind has at least one field")),label:i(q),describe:i(q),lifecycle:i(g({field:x,retired:h(w([p(),j(),R()]),1)})),figure:i(f(void 0,2e4)),glance:i(h(x,1,20)),page:i(g({fields:i(h(x,1,40)),groups:i(h(g({title:f(1,60),fields:h(x,1,40)}),1,12))})),edges:i(m(I,Ve)),computed:i(m(p(),ye).check(F(e=>Object.keys(e).length<=20,"a kind works out at most 20 computed fields"))),fieldRoles:i(m(p(),p())),renamedFrom:i(p().check(O(ue)))}),B=w([p(),j(),R(),re(),b(E()),g({expr:M})]),D=p().check(O(/^\$[A-Za-z][A-Za-z0-9]*$/,'a reference is "$" and a name, like "$subject" or "$new"')),_e=w([g({create:z("kind"),as:i(p().check(O(J))),set:i(m(x,B))}),g({set:m(x,B),target:i(D)}),g({connect:I,from:D,to:D}),g({sever:I,from:D,to:D}),g({remove:D})]),De=g({title:i(f(1,80)),description:i(A),fromTheOtherEnd:i(f(1,80)),on:i(w([z("kind"),h(z("kind"),1)])),creates:i(z("kind")),sets:i(m(x,B)),writes:i(h(x,1)),connects:i(I),severs:i(I),setsOther:i(m(x,B)),replaces:i(w([v(!0),h(I,1,10)])),removes:i(v(!0)),args:i(m(x,ge)),effects:i(h(_e,1,20)),allowedWhen:i(M),refusal:i(q),destructive:i(R())}),Ie=g({act:z("act"),label:i(f(1,80)),args:i(m(p(),B))}),Me=g({title:i(f(1,120)),description:i(A),over:w([v("graph"),z("kind")]),when:i(M),require:M,says:i(q),repairs:i(h(Ie,void 0,10))}),Le=g({roles:w([h(z("role"),1),v("*")]),mutations:w([h(z("act"),1),v("*")]),kinds:i(w([b(z("kind")),v("*")])),describe:i(A),self:i(R())}),Ke=g({roles:w([h(z("role"),1),v("*")]),kinds:h(z("kind"),1),own:i(R())}),Be=g({grants:b(Le),sees:i(b(Ke))}),Ge=g({accent:i(p().check(O(/^#[0-9a-fA-F]{6}$/,'an accent is a color like "#c2577a"'))),name:i(f(1,60)),currency:i(p().check(O(/^[A-Z]{3}$/,'a currency is its three-letter code, like "USD" or "EUR"'))),locale:i(f(2,35)),logo:i(w([f(1,X),g({src:f(1,X),alt:i(f(1,120))})])),favicon:i(f(1,X)),typography:i(g({display:i(f(1,200)),body:i(f(1,200)),mono:i(f(1,200))})),shape:i(g({radius:i(j().check(K(0),G(32))),density:i(j().check(K(.75),G(1.5)))})),accents:i(m(p(),j().check(K(0),G(360)))),scheme:i(_(["light","dark","auto"]))}),P=m(p(),E()),Ne=g({card:i(b(E())),row:i(b(E())),page:i(b(E()))}),Ce=se({order:i(b(p())),hide:i(b(p())),first:i(p()),primary:i(h(f(1,80),void 0,40)),scene:i(f(1,40)),pages:i(f(1,40))}),an=g({$schema:i(p()),format:v(Oe),formatVersion:v(je),name:f(1,80),description:i(A),version:i(j().check(oe(),K(1))),kinds:m(z("kind"),Te).check(F(e=>Object.keys(e).length>0,"a document declares at least one kind"),F(e=>Object.keys(e).length<=40,"a document declares at most 40 kinds")),computed:i(m(p(),ye)),acts:i(m(z("act"),De)),rules:i(m(z("rule"),Me)),roles:i(b(z("role"))),policy:i(Be),modules:i(P),lenses:i(b(P)),pages:i(Ce),views:i(m(p(),w([Ne,b(E())]))),brand:i(Ge),settings:i(b(P)),migrations:i(b(P))});var W=e=>e?._zod?.def,Pe=/^\^\\d\{4\}-\\d\{2\}-\\d\{2\}\$$/;function qe(e){let n=W(e),s=!0,r;for(let t=0;n&&t<4;t++){if(n.type==="optional"||n.type==="nullable")s=!1;else if(n.type==="default")s=!1,r=n.defaultValue;else break;n=W(n.innerType)}if(!n)return{why:"it is not a zod field"};let c=ce(e),d={...s?{required:!0}:{},...r!==void 0?{default:r}:{},...c?{description:c}:{}},a=(n.checks??[]).map(t=>W(t));switch(n.type){case"string":{let t=n.format;return t==="email"?{spec:{type:"email",...d}}:t==="url"?{spec:{type:"url",...d}}:t==="date"?{spec:{type:"date",...d}}:t==="datetime"?{spec:{type:"datetime",...d}}:a.some(o=>o?.format==="regex"&&Pe.test(String(o?.pattern?.source??"")))?{spec:{type:"date",...d}}:{spec:{type:"string",...d}}}case"number":{let t={};for(let o of a){let u=o?.value;typeof u=="number"&&(o?.check==="greater_than"&&o.inclusive?t.min=Math.max(t.min??u,u):o?.check==="less_than"&&o.inclusive?t.max=Math.min(t.max??u,u):o?.check==="multiple_of"&&(t.step=u))}return{spec:{type:a.some(o=>o?.format==="safeint"||o?.format==="int")?"integer":"number",...t,...d}}}case"boolean":return{spec:{type:"boolean",...d}};case"enum":{let t=Object.keys(n.entries??{});return t.length>0?{spec:{type:"enum",options:t,...d}}:{why:"it is an enum with no options"}}case"array":{let t=W(n.element),o=t?.type==="number"?"number":t?.type==="string"?"string":void 0;return o?{spec:{type:"list",of:o,...d}}:{why:`it is a list of ${String(t?.type??"something")}, and a document lists words, numbers or dates`}}default:return{why:`it is a ${String(n.type)}, which a document has no field type for`}}}function ln(e){let n=qe(e);return"spec"in n?n.spec:void 0}var Q=["card","row","page"],ee=["good","warn","bad","neutral","accent"],me=["money","percent","date","relative","count"],he=4,U=40,be=["number","money","percent"],We=["card","row"],ze=100,Z={title:[],headline:[],list:["sort","limit","group","empty","as"],text:["tone"],badge:["tone"],field:["as","currency","label"],progress:["label"],group:["direction"],when:["show"],divider:[],figure:["as","currency","label"]},Ze=Object.keys(Z),ke=`{"title": "{name}"}, {"headline": "{count(all('offer'))} offers"}, {"figure": expr, "as"?: "number"|"money"|"percent", "currency"?, "label"?}, {"list": expr, "sort"?, "limit"?, "group"?, "empty"?, "as"?: "card"|"row"}, {"text": "\u2026", "tone"?}, {"badge": "{status}", "tone"?}, {"field": "quote", "as"?, "currency"?, "label"?}, {"progress": {"value": expr, "max": expr}, "label"?}, {"group": [blocks], "direction"?: "row"|"column"}, {"when": expr, "show": [blocks]}, {"divider": true}, {"figure": true}`;function hn(e){return Object.fromEntries(Object.entries(e.views??{}).filter(([,n])=>!Array.isArray(n)))}function bn(e){let n=e.views?.home;return Array.isArray(n)?n:void 0}var Ue={field:()=>!1,relation:()=>!1,figure:!1},Ye=e=>e.kind??"the home",V=(e,n)=>e!==void 0&&Object.hasOwn(e,n),S=e=>typeof e=="object"&&e!==null&&!Array.isArray(e);function $e(e,n,s){let r=H(e);for(let c of r.unknownFunctions)s.findings.push(l("unknown-function",n,`"${c}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let c of r.names){if(s.kind===null){s.findings.push(l("view-name",n,`"${c}" names nothing here: these blocks are about no one record`,"reach records with all('<kind>'), like count(all('offer')) or first(all('party') where role == 'client').name"));continue}c==="id"||s.spec.field(c)||s.spec.relation(c)||s.findings.push(l("view-name",n,`${s.kind} has no field or relation called "${c}"`))}for(let c of r.edges)s.edges.has(c)||s.findings.push(l("view-edge",n,`"${c}" is not a relation any kind declares`));for(let c of r.sweeps)s.kinds.has(c)||s.findings.push(l("view-kind",n,`"${c}" is not a kind this document declares`))}function L(e,n,s){if(typeof e!="string"||e.length===0||e.length>2e3){s.findings.push(l("view-expression",n,`an expression is a line of the rule language, like "status == 'booked'"`));return}try{$e(C(e),n,s)}catch(r){if(!(r instanceof N))throw r;s.findings.push(l("expression",n,`${r.sentence} (at character ${r.at+1})`))}}function ne(e,n,s){if(typeof e!="string"||e.length===0||e.length>300){s.findings.push(l("view-template",n,'a template is words with {field} in braces, like "{name}" or "{quote|money}", at most 300 characters'));return}let r;try{r=le(e)}catch(c){if(c instanceof de||c instanceof N){s.findings.push(l("template",n,c.sentence));return}throw c}for(let c of r)c.expr&&$e(c.expr,n,s)}function He(e,n,s){if(typeof e=="string"){ee.includes(e)||s.findings.push(l("view-tone",n,`"${e}" is not a tone`,`use one of ${ee.join(", ")}, or {"expr": "if(status == 'booked', 'good', 'neutral')"}`));return}if(S(e)&&Object.keys(e).length===1&&"expr"in e){L(e.expr,`${n}.expr`,s);return}s.findings.push(l("view-tone",n,'a tone is a word or {"expr": \u2026}',`one of ${ee.join(", ")}`))}function Y(e,n,s,r){if(!Array.isArray(e)){r.findings.push(l("view-shape",n,"a view is a list of blocks"));return}if(s>he){r.findings.push(l("view-depth",n,`blocks nest at most ${he} deep`,"flatten a group or a condition"));return}e.forEach((c,d)=>Xe(c,`${n}.${d}`,s,r))}function Xe(e,n,s,r){if(r.count++,!S(e)){r.findings.push(l("view-block",n,"a block is an object naming what it shows",`one of ${ke}`));return}let c=Object.keys(e),d=c.filter(o=>Ze.includes(o)&&!(o==="group"&&c.includes("list")));if(d.length===0){r.findings.push(l("view-block",n,`${c.length>0?c.map(o=>`"${o}"`).join(", "):"an empty object"} is not a block Graview knows`,`one of ${ke}`));return}if(d.length>1){r.findings.push(l("view-block",n,`a block is one thing, and this says ${d.map(o=>`"${o}"`).join(" and ")}`,"split it into two blocks"));return}let a=d[0];for(let o of c)o!==a&&o!="key"&&!Z[a].includes(o)&&r.findings.push(l("unknown-key",`${n}.${o}`,`"${o}" is not part of a ${a} block`,Z[a].length>0?`a ${a} block may also say ${Z[a].map(u=>`"${u}"`).join(", ")}`:`a ${a} block says nothing else`));let t=e[a];switch(a){case"title":case"headline":case"text":case"badge":ne(t,`${n}.${a}`,r),"tone"in e&&He(e.tone,`${n}.tone`,r);return;case"field":{if(typeof t!="string"||!r.spec.field(t)){let o=typeof t=="string"&&r.spec.relation(t);r.findings.push(l("view-field",`${n}.field`,`${r.kind} has no field ${typeof t=="string"?`"${t}"`:"by that name"}`,o?`"${t}" is a relation; show it with {"text": "{${t}.name}"}`:void 0))}"as"in e&&!me.includes(e.as)&&r.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to show a field`,`use one of ${me.join(", ")}`)),Se(e,n,r,"field"),"label"in e&&nn(e.label,`${n}.label`,r);return}case"progress":{!S(t)||Object.keys(t).some(o=>o!=="value"&&o!=="max")||!("value"in t)||!("max"in t)?r.findings.push(l("view-progress",`${n}.progress`,'progress is {"value": expression, "max": expression}')):(L(t.value,`${n}.progress.value`,r),L(t.max,`${n}.progress.max`,r)),"label"in e&&ne(e.label,`${n}.label`,r);return}case"group":"direction"in e&&e.direction!=="row"&&e.direction!=="column"&&r.findings.push(l("view-direction",`${n}.direction`,`a group runs "row" or "column", not "${String(e.direction)}"`)),Y(t,`${n}.group`,s+1,r);return;case"when":L(t,`${n}.when`,r),"show"in e?Y(e.show,`${n}.show`,s+1,r):r.findings.push(l("view-when",n,'a condition says what it shows: {"when": expr, "show": [blocks]}'));return;case"figure":if(typeof t=="string")return Je(e,n,r);for(let o of["as","currency","label"])o in e&&r.findings.push(l("unknown-key",`${n}.${o}`,`"${o}" belongs to a figure that works a number out; {"figure": true} is the kind's picture`,`write {"figure": "count(all('offer'))", "as": "number"}`));t!==!0?r.findings.push(l("view-block",`${n}.figure`,`a figure is a number worked out, {"figure": "sum(all('offer'), net)", "as": "money"}, or the kind's picture, {"figure": true}`)):r.spec.figure||r.findings.push(l("view-figure",`${n}.figure`,`${Ye(r)} has no figure to show`,r.kind===null?`work a number out: {"figure": "count(all('offer'))"}`:'give the kind a "figure", or leave this block out'));return;case"list":return en(e,n,r);case"divider":t!==!0&&r.findings.push(l("view-block",`${n}.${a}`,`write {"${a}": true}`));return}}function Je(e,n,s){L(e.figure,`${n}.figure`,s),"as"in e&&!be.includes(e.as)&&s.findings.push(l("view-format",`${n}.as`,`"${String(e.as)}" is not a way to say a figure`,`use one of ${be.join(", ")}`)),Se(e,n,s,"figure"),"label"in e&&ne(e.label,`${n}.label`,s)}function Se(e,n,s,r){"currency"in e&&(typeof e.currency!="string"||!/^[A-Z]{3}$/.test(e.currency)?s.findings.push(l("view-currency",`${n}.currency`,'a currency is its three-letter code, like "USD" or "EUR"')):e.as!=="money"&&s.findings.push(l("view-currency",`${n}.currency`,`a currency belongs on a ${r} shown as money`,'add "as": "money"')))}function Qe(e,n){let s=[...n.kinds],r=(d,a)=>{let t=new Set;for(let o of d){let u=n.vocabulary.namesOf(o)?.targets?.(a);if(u==="*")return s;for(let y of u??[])t.add(y)}return t.size>0?[...t]:void 0},c=d=>{switch(d.t){case"ident":return n.kind!==null&&n.spec.relation(d.name)?r([n.kind],d.name):void 0;case"member":{let a=c(d.object);return a?r(a,d.name):void 0}case"where":return c(d.set);case"call":{let a=d.args[0],t=a?.t==="lit"&&typeof a.value=="string"?a.value:void 0;if(d.fn==="all")return t!==void 0&&n.kinds.has(t)?[t]:void 0;let o=d.args.length===2&&d.args[1]?.t==="lit"&&typeof d.args[1].value=="string"?d.args[1].value:void 0;if(d.fn==="out"&&o!==void 0){let u=c(a);return u?r(u,o):void 0}if(d.fn==="out")return t!==void 0&&n.kind!==null?r([n.kind],t):void 0;if(d.fn==="in"){let u=o??t,y=o!==void 0?c(a):n.kind!==null?[n.kind]:void 0,k=u!==void 0?n.vocabulary.sources(u).filter($=>{let T=n.vocabulary.namesOf($)?.targets?.(u);return!y||T==="*"||y.some(xe=>T?.includes(xe))}):[];return k.length>0?k:void 0}if((d.fn==="sort"||d.fn==="first")&&a)return c(a);if(d.fn==="either"){let u=d.args.map(c);return u.every(y=>y!==void 0)?[...new Set(u.flatMap(y=>y??[]))]:void 0}return}default:return}};return c(e)}function we(e,n,s,r){let c;try{c=C(e)}catch(a){if(!(a instanceof N))throw a;r.findings.push(l("expression",n,`${a.sentence} (at character ${a.at+1})`));return}let d=H(c);for(let a of d.unknownFunctions)r.findings.push(l("unknown-function",n,`"${a}" is not a function the rule language knows`,"see docs/declaration-document.md#expression-language"));for(let a of d.edges)r.edges.has(a)||r.findings.push(l("view-edge",n,`"${a}" is not a relation any kind declares`));if(s)for(let a of d.names)a==="id"||s.some(t=>r.vocabulary.namesOf(t)?.field(a)||r.vocabulary.namesOf(t)?.relation(a))||r.findings.push(l("view-name",n,`${s.join(" and ")} ${s.length===1?"has":"have"} no field or relation called "${a}"`))}function en(e,n,s){let r=e.list;L(r,`${n}.list`,s);let c;if(typeof r=="string")try{c=Qe(C(r),s)}catch{c=void 0}let d=t=>{if(!c)return[...s.kinds].map(u=>s.vocabulary.namesOf(u)?.choices?.(t)).find(u=>u!==void 0);let o=c.map(u=>s.vocabulary.namesOf(u)?.choices?.(t));return o.every(u=>u!==void 0)?[...new Set(o.flatMap(u=>u??[]))]:void 0},a=c?c.join(" and "):"any kind";if("sort"in e){let t=e.sort;if(typeof t=="string")we(t,`${n}.sort`,c,s);else if(S(t)&&typeof t.by=="string"&&Object.keys(t).every(o=>o==="by"||o==="direction")){let o=t.direction;o!==void 0&&o!=="asc"&&o!=="desc"&&o!=="choices"?s.findings.push(l("list-sort",`${n}.sort.direction`,`a list is sorted "asc", "desc" or "choices", not "${String(o)}"`,'"choices" puts a choice field in the order its choices are declared')):o==="choices"?d(t.by)===void 0&&s.findings.push(l("list-sort",`${n}.sort.by`,`"${t.by}" is not a choice field of ${a}, so it has no declared order`,'sort by a choice field, or say "asc" or "desc"')):we(t.by,`${n}.sort.by`,c,s)}else s.findings.push(l("list-sort",`${n}.sort`,'a sort is a key, like "net", or {"by": key, "direction": "asc" | "desc" | "choices"}'))}if("limit"in e){let t=e.limit;(typeof t!="number"||!Number.isInteger(t)||t<1||t>ze)&&s.findings.push(l("list-limit",`${n}.limit`,`a limit is a whole number from 1 to ${ze}`))}if("group"in e){let t=e.group,o=typeof t=="string"?t:S(t)&&typeof t.by=="string"?t.by:void 0;if(!(typeof t=="string"||S(t)&&Object.keys(t).every(y=>y==="by"||y==="headings"))||o===void 0)s.findings.push(l("list-group",`${n}.group`,'a group is a choice field, like "type", or {"by": "type", "headings": {"pain": "What hurts"}}'));else{let y=d(o);if(y===void 0&&s.findings.push(l("list-group",`${n}.group`,`"${o}" is not a choice field of ${a}, so it has no choices to group by`,"group by a field whose type is enum")),S(t)&&"headings"in t){let k=t.headings;if(!S(k)||Object.values(k).some($=>typeof $!="string"||$.length===0||$.length>80))s.findings.push(l("list-group",`${n}.group.headings`,'headings are words per choice, like {"pain": "What hurts"}, at most 80 characters each'));else if(y)for(let $ of Object.keys(k))y.includes($)||s.findings.push(l("list-group",`${n}.group.headings.${$}`,`"${$}" is not one of ${o}'s choices`,`use ${y.join(", ")}`))}}}"empty"in e&&(typeof e.empty!="string"||e.empty.length===0||e.empty.length>200)&&s.findings.push(l("list-empty",`${n}.empty`,"what an empty list says is a sentence, at most 200 characters")),"as"in e&&!We.includes(e.as)&&s.findings.push(l("list-as",`${n}.as`,`a list draws each record as its "card" or its "row", not "${String(e.as)}"`))}function nn(e,n,s){(typeof e!="string"||e.length===0||e.length>60)&&s.findings.push(l("view-label",n,"a label is a few words, at most 60 characters"))}function ve(e,n,s,r,c,d,a){let t={kind:null,spec:Ue,kinds:r,edges:c,vocabulary:s,findings:d,count:0};Array.isArray(e)&&e.length===0&&d.push(l("view-shape",n,`${a} has no blocks`,'give it one: {"headline": "\u2026"}')),Y(e,n,1,t),t.count>U&&d.push(l("view-size",n,`${a} has ${t.count} blocks; a view has at most ${U}`,"show less"))}function tn(e,n,s,r,c){Array.isArray(e)&&e.forEach((d,a)=>{if(!S(d)||d.name!=="blocks"||!S(d.options)||!("blocks"in d.options))return;let t=[];ve(d.options.blocks,`lenses.${a}.options.blocks`,n,s,r,t,`the lens "${String(d.title??a)}"`);for(let o of t)c.push({...o,severity:"warning"})})}function on(e,n,s,r,c,d,a){let t=[];if(e===void 0)return t;if(!S(e))return t.push(l("view-shape",n,'views are an object of kinds, each with a "card", a "row" or a "page"')),t;for(let[o,u]of Object.entries(e)){if(o==="home"&&Array.isArray(u)){ve(u,`${n}.home`,a,r,c,t,"the home");continue}let y=s(o);if(!y){t.push(l("view-kind",`${n}.${o}`,`"${o}" is not a kind this ${d} declares`));continue}if(!S(u)){t.push(l("view-shape",`${n}.${o}`,`a kind's views are {"card": [blocks], "row": [blocks], "page": [blocks]}`));continue}for(let k of Object.keys(u))Q.includes(k)||t.push(l("view-slot",`${n}.${o}.${k}`,`"${k}" is not a place a view is drawn`,`use ${Q.map($=>`"${$}"`).join(", ")}`));for(let k of Q){let $=u[k];if($===void 0)continue;let T={kind:o,spec:y,kinds:r,edges:c,vocabulary:a,findings:t,count:0};Y($,`${n}.${o}.${k}`,1,T),T.count>U&&t.push(l("view-size",`${n}.${o}.${k}`,`this ${k} has ${T.count} blocks; a view has at most ${U}`,"show less, or move detail to the page"))}}return t}function zn(e){let n=new Set(Object.keys(e.kinds)),s=new Set(Object.values(e.kinds).flatMap(a=>Object.keys(a.edges??{}))),r=a=>{let t=V(e.kinds,a)?e.kinds[a]:void 0;return t?{field:o=>V(t.fields,o)||V(t.computed,o),relation:o=>V(t.edges,o),figure:t.figure!==void 0,choices:o=>V(t.fields,o)&&t.fields[o].type==="enum"?t.fields[o].options:void 0,targets:o=>V(t.edges,o)?t.edges[o].to:void 0}:void 0},c={namesOf:r,sources:a=>Object.keys(e.kinds).filter(t=>V(e.kinds[t].edges,a))},d=on(e.views,"views",r,n,s,"document",c);return tn(e.lenses,c,n,s,d),d}export{Oe as a,je as b,sn as c,an as d,ln as e,ee as f,me as g,be as h,ze as i,hn as j,bn as k,zn as l};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a as Ve}from"./chunk.6KJSFIO7.js";import{b as Ce,c as te,d as Ie,e as W,g as le,h as Ke,o as J}from"./chunk.LZQZP2PD.js";import{F as Ee,S as ze,Y as De,Z as $e,a as me,b as he,ba as Pe,c as we,d as H,da as Ge,db as Te,f as se,g as C,h as ke,i as be,j as ne,ja as ce,k as ve,ka as Me,l as Oe,n as Ae,nb as Fe,o as Re,ob as Ne,p as ae,ta as Z,u as je,w as de,x as xe,z as Se}from"./chunk.Y235YZSZ.js";function tn(n,c){let e=n.brand??{},i=e.accent?Ne(e.accent):void 0;i&&!i.ok&&c.push(Ke("brand","brand.accent",`that accent cannot make a readable brand, so the app keeps Graview's colors: ${i.why}`,"pick a color further from orange-red, or a darker one"));let l=typeof e.logo=="string"?{src:e.logo}:e.logo,d=e.name??n.name,O=e.typography?Object.fromEntries(Object.entries(e.typography).filter(([,R])=>typeof R=="string"&&!/url\(|@import|[;{}<>\\]/i.test(R)).map(([R,E])=>[R,Fe(E)])):void 0;return{name:d,schemes:i?.ok?i.schemes:Te,...e.currency?{currency:e.currency}:{},...e.locale?{locale:e.locale}:{},...l?{logo:l.src,logoAlt:l.alt??d}:{},...e.favicon?{favicon:e.favicon}:{},...n.description?{subtitle:n.description}:{},...O?{typography:O}:{},...e.shape?{shape:e.shape}:{},...e.accents?{accents:e.accents}:{},...e.scheme?{scheme:e.scheme}:{}}}function Le(n){let{currency:c,locale:e}=n.brand??{};return{...c?{currency:c}:{},...e?{locale:e}:{}}}var He=[{where:"settings[]",was:"honoured",now:"honored",since:"0.1.16"},{where:"pages",was:"overview",now:"scene",since:"0.1.17"}],pe=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function qe(n,c=He){if(!pe(n))return{document:n,respelled:[]};let e=[],i=n;for(let l of c)i=fe(i,l.where.split("."),l,"",e);return{document:i,respelled:e}}function fe(n,c,e,i,l){if(c.length===0){if(!pe(n)||!Object.hasOwn(n,e.was))return n;l.push(`${i}${e.was}`);let{[e.was]:G,...z}=n;return Object.hasOwn(n,e.now)?z:{...z,[e.now]:G}}if(!pe(n))return n;let[d,...O]=c,R=d.endsWith("[]"),E=R?d.slice(0,-2):d,j=n[E],P=j;if(!R)P=fe(j,O,e,`${i}${E}.`,l);else if(Array.isArray(j)){let G=j.map((z,M)=>fe(z,O,e,`${i}${E}.${M}.`,l));P=G.some((z,M)=>z!==j[M])?G:j}return P===j?n:{...n,[E]:P}}var Be="graview-compiled@1",I="id",Ze=n=>typeof n=="string"&&/^\$[A-Za-z][A-Za-z0-9]*$/.test(n)?n.slice(1):void 0;function We(n){let c=Object.entries(n.fields);return c.find(([,e])=>e.required&&(e.type==="string"||e.type==="text"))?.[0]??c.find(([,e])=>e.type==="string")?.[0]}function _e(n,c){let e;switch(n.type){case"string":e=C().check(H(500));break;case"text":e=C().check(H(2e4));break;case"number":case"integer":{let i=[...n.type==="integer"?[ve()]:[],...n.min===void 0?[]:[he(n.min)],...n.max===void 0?[]:[me(n.max)],...n.step===void 0?[]:[we(n.step)]];e=i.length>0?ne().check(...i):ne();break}case"boolean":e=Oe();break;case"date":e=C().check(se(/^\d{4}-\d{2}-\d{2}$/,"a date like 2026-10-02"));break;case"datetime":e=C().check(xe(i=>!Number.isNaN(Date.parse(i)),"a date and time like 2026-10-02T14:30:00Z"));break;case"enum":e=je(n.options);break;case"list":e=Re(n.of==="number"?ne():n.of==="date"?C().check(se(/^\d{4}-\d{2}-\d{2}$/)):C().check(H(500))).check(H(200));break;case"url":e=be();break;case"email":e=ke();break}return n.description&&(e=e.check(Se(n.description))),c?de(e):e}var U=n=>{throw new Z(`there is no record "${n}"`,"invalid")},Je=n=>"field"in n?_e(n.field,n.optional):"ref"in n?Ge(n.ref):de(Ae()),Ue=new WeakMap;var re=n=>typeof n=="object"&&n!==null&&!Array.isArray(n),ye=(n,c)=>re(c)&&Object.keys(n??{}).length===Object.keys(c).length&&Object.keys(n??{}).every(e=>Object.hasOwn(c,e));function mn(n,c={}){let e=re(n)?n.format:void 0;if(e!==Be)return{ok:!1,findings:[le("compiled-format","format",e===void 0?"this is not a compiled Graview app":`this compiled app is ${JSON.stringify(e)}, and this build reads ${Be}`,"compile the document instead")]};let i=n,l=qe(i.document).document,d=l===i.document?i:{...i,document:l},O=re(l)&&typeof l.name=="string"&&re(l.kinds)&&ye(l.kinds,d.kinds)&&ye(l.acts,d.acts)&&ye(l.rules,d.rules)&&Array.isArray(d.edges)&&Array.isArray(d.findings),R={ok:!1,findings:[le("compiled-shape","","this compiled app's parts do not match its document","compile the document instead")]};if(!O)return R;try{return Qe(d,c)}catch{return R}}function Qe(n,c={}){let{document:e}=n,i=c.today??(()=>new Date().toISOString().slice(0,10)),l=new Map(n.edges.map(([f,r])=>[f,r])),d=new Map;for(let[f,r]of Object.entries(e.kinds)){let k=n.kinds[f]?.computed;d.set(f,{fields:new Set(Object.keys(r.fields)),edges:new Map(Object.entries(r.edges??{}).map(([w,x])=>[w,x.cardinality??"many"])),...k?{computed:new Map(k)}:{}})}n.facts&&d.set(Ce,{computed:new Map(n.facts)});let O=Le(e),R=Object.entries(e.kinds).map(([f,r])=>{let k={};for(let[o,y]of Object.entries(r.fields))k[o]=_e(y,!y.required);let{label:w,describe:x}=n.kinds[f]??{},D=Object.entries(r.computed??{}).map(([o,y])=>[o,typeof y=="string"?{expr:y}:y]),S=Object.fromEntries([...Object.entries(r.fields).filter(([,o])=>o.label).map(([o,y])=>[o,y.label]),...D.filter(([,o])=>o.label).map(([o,y])=>[o,y.label])]),T=Object.fromEntries(Object.entries(r.fields).filter(([,o])=>o.default!==void 0).map(([o,y])=>[o,y.default])),K=Object.fromEntries(Object.entries(r.edges??{}).map(([o,{renamedFrom:y,...V}])=>[o,V])),g=o=>r[o]?{[o]:r[o]}:{};return Ee(f,{fields:ae(k),edges:K,...g("plural"),...g("noun"),...g("description"),...w?{label:o=>J(w,{node:o,kinds:d,today:i(),money:O})||o.id}:{},...x?{describe:o=>J(x,{node:o,kinds:d,today:i(),money:O})}:{},...g("lifecycle"),...g("figure"),...g("fieldRoles"),...r.computed&&Object.keys(r.computed).length>0?{computed:r.computed}:{},...Object.keys(S).length>0||r.glance||r.page?{display:{...Object.keys(S).length>0?{labels:S}:{},...r.glance?{glance:[...r.glance]}:{},...r.page?{page:r.page}:{}}}:{},...Object.keys(T).length>0?{defaults:T}:{}})}),E=De(R,e.computed);function j(f){return E.tryDefinition(f.kind)?.label?.(f)??f.id}let P=[];for(let[f,r]of Object.entries(e.acts??{})){let k=n.acts[f],{title:w,effects:x,guard:D,refusal:S,destructive:T,idempotent:K,creates:g,connects:o,severs:y,writes:V,writesOther:Q,sets:h}=k,L=new Map(k.args),F={};for(let[u,b]of L)F[u]=Je(b);let q=r.on===void 0?[]:Array.isArray(r.on)?r.on:[r.on],X=new Map(k.exprs);P.push(Pe(f,{input:ae(F),title:w,...r.description?{description:r.description}:{},...r.fromTheOtherEnd?{fromTheOtherEnd:r.fromTheOtherEnd}:{},...L.has(I)?{subject:{kinds:q.length>0?q:"*",arg:I}}:{},...T?{destructive:!0}:{},...K?{idempotent:!0}:{},...g.length>0?{creates:g}:{},...o.length>0?{connects:o}:{},...y.length>0?{severs:y}:{},writes:V,...Object.keys(Q).length>0?{writesOther:Q}:{},...Object.keys(h).length>0?{sets:h}:{},describe:(u,b)=>{let v=typeof u[I]=="string"?b.getNode(u[I]):void 0,$=v?j(v):Object.values(u).find(m=>typeof m=="string");return $?`${w}: ${String($)}`:w},apply(u,b){let v=u.graph,$=typeof b[I]=="string"?b[I]:void 0,m=$?v.getNode($):void 0;if($&&!m&&U($),m&&q.length>0&&!q.includes(m.kind))throw new Z(`"${w}" acts on ${q.join(" or ")}, not on ${ze(m.kind)}`,"invalid");let Y={};for(let[t,s]of Object.entries(b))s!==void 0&&(Y[t]=s);if(D&&m){let t;try{t=W(D,{graph:v,subject:m,kinds:d,bindings:Y,today:i()})}catch(s){throw s instanceof te?new Z(`"${w}" could not be judged: ${s.sentence}`):s}if(t!==!0)throw new Z(S?J(S,{node:m,kinds:d,graph:v,bindings:Y,today:i(),money:O}):`"${w}" is not allowed for ${j(m)} right now`)}let ee=new Map,oe=t=>v.has(t)||[...ee.values()].includes(t),ue=new Set,ie=t=>{let s=$e(t);ue.has(s)||(ue.add(s),u.removeEdge(t))},B=(t,s)=>{if(t&&typeof t=="object"&&!Array.isArray(t)&&"expr"in t)try{return W(X.get(t.expr),{graph:v,subject:s??m??null,kinds:d,bindings:Y,today:i()})}catch(p){throw p instanceof te?new Z(`"${w}" could not work out a value: ${p.sentence}`):p}let a=Ze(t);return a===void 0?typeof t=="string"&&t.startsWith("$$")?t.slice(1):t:a==="subject"?$:a==="now"?new Date().toISOString():a==="today"?i():ee.has(a)?ee.get(a):b[a]};for(let t of x)if("create"in t){let s=e.kinds[t.create],a={kind:t.create};for(let[_,N]of Object.entries(s.fields))N.default!==void 0&&(a[_]=N.default);for(let[_,N]of Object.entries(t.set??{})){let ge=B(N,void 0);ge!==void 0&&(a[_]=ge)}let p=We(s),A=u.freshId(String((p&&a[p])??t.create),t.create);u.addNode({id:A,...a}),t.as&&ee.set(t.as,A)}else if("connect"in t||"sever"in t){let s="connect"in t?t.connect:t.sever,a=String(B(t.from,void 0)??""),p=String(B(t.to,void 0)??"");if(oe(a)||U(a),oe(p)||U(p),"connect"in t){if(l.get(s)?.cardinality==="one")for(let A of v.out(a,s))A.id!==p&&ie({kind:s,from:a,to:A.id});v.out(a,s).some(A=>A.id===p)||u.addEdge({kind:s,from:a,to:p})}else ie({kind:s,from:a,to:p})}else if("set"in t){let s=String(B(t.target??"$subject",void 0)??""),a=v.getNode(s);!a&&!oe(s)&&U(s);let p={};for(let[A,_]of Object.entries(t.set)){let N=B(_,a);N!==void 0&&(p[A]=N)}Object.keys(p).length>0&&u.patchNode(s,p)}else if("remove"in t){let s=String(B(t.remove,void 0)??"");v.has(s)||U(s),u.removeNode(s)}else if("replace"in t&&m){let s=b.to;for(let a of t.replace){let p=l.get(a)?.from.includes(m.kind)??!0;for(let A of p?v.out(m.id,a):v.in(m.id,a))a===t.keep&&A.id===s||ie(p?{kind:a,from:m.id,to:A.id}:{kind:a,from:A.id,to:m.id})}}}}))}let G=[];for(let[f,r]of Object.entries(e.rules??{})){let{title:k,require:w,when:x,says:D}=n.rules[f],S=r.repairs??[],T=(g,o)=>{let y={graph:g,subject:o,kinds:d,today:i()},V;try{if(x&&W(x,y)!==!0)return[];V=W(w,y)===!0}catch(h){throw h instanceof Ie?new Me(h.sentence):h instanceof te?new Error(h.sentence):h}if(V)return[];let Q=S.flatMap(h=>{let L=e.acts?.[h.act],F={};o&&(L?.on||/^(edit|remove)-/.test(h.act))&&(F[I]=o.id);for(let[u,b]of Object.entries(h.args??{}))F[u]=Ze(b)==="subject"?o?.id:b;let X=(L?n.acts[h.act].args:[]).filter(([u,b])=>b.required&&F[u]===void 0).map(([u])=>u);return[{mutation:h.act,label:h.label??L?.title??h.act.replace(/-/g," "),args:F,...X.length>0?{missing:X}:{}}]});return[{invariant:f,...o?{subjectId:o.id}:{},label:k,message:D?J(D,{node:o,kinds:d,graph:g,today:i(),money:O}):o?`${j(o)}: ${k}`:k,nodeIds:o?[o.id]:[],repairs:Q}]},K={label:k,shape:{over:r.over,require:w,when:x,says:D,declared:e.kinds,money:O,kinds:d,today:i},judgment:{require:r.require,...r.when?{when:r.when}:{},...r.says?{says:r.says}:{}},...r.description?{description:r.description}:{},...S.length>0?{repairs:S.map(g=>g.act)}:{}};G.push(r.over==="graph"?ce(f,{scope:"graph",...K,evaluate:({graph:g})=>T(g,null)}):ce(f,{scope:{kind:r.over},...K,evaluate:({graph:g,subject:o})=>T(g,o)}))}let z=e.policy?{grants:e.policy.grants,...e.policy.sees?{sees:e.policy.sees}:{},...e.roles?{roles:e.roles}:{}}:void 0,M={name:e.name,schema:E,mutations:P,invariants:G,...z?{policy:z}:{},...n.brand?{brand:n.brand}:{},...e.modules?{modules:e.modules}:{},...e.lenses?{lenses:e.lenses}:{},...e.pages?{pages:e.pages}:{},...e.settings?{settings:e.settings}:{},...n.viewSpecs?{viewSpecs:n.viewSpecs}:{},...n.home?{home:n.home}:{},version:e.version??1};return Ve(M,e),Ue.set(M,n),{ok:!0,app:M,document:e,findings:n.findings,sights:e.policy?.sees,kinds:d}}export{qe as a,tn as b,Be as c,I as d,Ze as e,We as f,mn as g,Qe as h};
|
|
1
|
+
import{a as Ve}from"./chunk.6KJSFIO7.js";import{b as Ce,c as te,d as Ie,e as W,g as le,h as Ke,o as J}from"./chunk.WOTNMTIY.js";import{F as Ee,S as ze,Y as De,Z as $e,a as me,b as he,c as we,d as H,da as Pe,f as se,fa as Ge,g as C,gb as Te,h as ke,i as be,j as ne,k as ve,l as Oe,la as ce,ma as Me,n as Ae,o as Re,p as ae,qb as Fe,rb as Ne,u as je,va as Z,w as de,x as xe,z as Se}from"./chunk.ZQ4HFIIS.js";function tn(n,c){let e=n.brand??{},i=e.accent?Ne(e.accent):void 0;i&&!i.ok&&c.push(Ke("brand","brand.accent",`that accent cannot make a readable brand, so the app keeps Graview's colors: ${i.why}`,"pick a color further from orange-red, or a darker one"));let l=typeof e.logo=="string"?{src:e.logo}:e.logo,d=e.name??n.name,O=e.typography?Object.fromEntries(Object.entries(e.typography).filter(([,R])=>typeof R=="string"&&!/url\(|@import|[;{}<>\\]/i.test(R)).map(([R,E])=>[R,Fe(E)])):void 0;return{name:d,schemes:i?.ok?i.schemes:Te,...e.currency?{currency:e.currency}:{},...e.locale?{locale:e.locale}:{},...l?{logo:l.src,logoAlt:l.alt??d}:{},...e.favicon?{favicon:e.favicon}:{},...n.description?{subtitle:n.description}:{},...O?{typography:O}:{},...e.shape?{shape:e.shape}:{},...e.accents?{accents:e.accents}:{},...e.scheme?{scheme:e.scheme}:{}}}function Le(n){let{currency:c,locale:e}=n.brand??{};return{...c?{currency:c}:{},...e?{locale:e}:{}}}var He=[{where:"settings[]",was:"honoured",now:"honored",since:"0.1.16"},{where:"pages",was:"overview",now:"scene",since:"0.1.17"}],pe=n=>typeof n=="object"&&n!==null&&!Array.isArray(n);function qe(n,c=He){if(!pe(n))return{document:n,respelled:[]};let e=[],i=n;for(let l of c)i=fe(i,l.where.split("."),l,"",e);return{document:i,respelled:e}}function fe(n,c,e,i,l){if(c.length===0){if(!pe(n)||!Object.hasOwn(n,e.was))return n;l.push(`${i}${e.was}`);let{[e.was]:G,...z}=n;return Object.hasOwn(n,e.now)?z:{...z,[e.now]:G}}if(!pe(n))return n;let[d,...O]=c,R=d.endsWith("[]"),E=R?d.slice(0,-2):d,j=n[E],P=j;if(!R)P=fe(j,O,e,`${i}${E}.`,l);else if(Array.isArray(j)){let G=j.map((z,M)=>fe(z,O,e,`${i}${E}.${M}.`,l));P=G.some((z,M)=>z!==j[M])?G:j}return P===j?n:{...n,[E]:P}}var Be="graview-compiled@1",I="id",Ze=n=>typeof n=="string"&&/^\$[A-Za-z][A-Za-z0-9]*$/.test(n)?n.slice(1):void 0;function We(n){let c=Object.entries(n.fields);return c.find(([,e])=>e.required&&(e.type==="string"||e.type==="text"))?.[0]??c.find(([,e])=>e.type==="string")?.[0]}function _e(n,c){let e;switch(n.type){case"string":e=C().check(H(500));break;case"text":e=C().check(H(2e4));break;case"number":case"integer":{let i=[...n.type==="integer"?[ve()]:[],...n.min===void 0?[]:[he(n.min)],...n.max===void 0?[]:[me(n.max)],...n.step===void 0?[]:[we(n.step)]];e=i.length>0?ne().check(...i):ne();break}case"boolean":e=Oe();break;case"date":e=C().check(se(/^\d{4}-\d{2}-\d{2}$/,"a date like 2026-10-02"));break;case"datetime":e=C().check(xe(i=>!Number.isNaN(Date.parse(i)),"a date and time like 2026-10-02T14:30:00Z"));break;case"enum":e=je(n.options);break;case"list":e=Re(n.of==="number"?ne():n.of==="date"?C().check(se(/^\d{4}-\d{2}-\d{2}$/)):C().check(H(500))).check(H(200));break;case"url":e=be();break;case"email":e=ke();break}return n.description&&(e=e.check(Se(n.description))),c?de(e):e}var U=n=>{throw new Z(`there is no record "${n}"`,"invalid")},Je=n=>"field"in n?_e(n.field,n.optional):"ref"in n?Ge(n.ref):de(Ae()),Ue=new WeakMap;var re=n=>typeof n=="object"&&n!==null&&!Array.isArray(n),ye=(n,c)=>re(c)&&Object.keys(n??{}).length===Object.keys(c).length&&Object.keys(n??{}).every(e=>Object.hasOwn(c,e));function mn(n,c={}){let e=re(n)?n.format:void 0;if(e!==Be)return{ok:!1,findings:[le("compiled-format","format",e===void 0?"this is not a compiled Graview app":`this compiled app is ${JSON.stringify(e)}, and this build reads ${Be}`,"compile the document instead")]};let i=n,l=qe(i.document).document,d=l===i.document?i:{...i,document:l},O=re(l)&&typeof l.name=="string"&&re(l.kinds)&&ye(l.kinds,d.kinds)&&ye(l.acts,d.acts)&&ye(l.rules,d.rules)&&Array.isArray(d.edges)&&Array.isArray(d.findings),R={ok:!1,findings:[le("compiled-shape","","this compiled app's parts do not match its document","compile the document instead")]};if(!O)return R;try{return Qe(d,c)}catch{return R}}function Qe(n,c={}){let{document:e}=n,i=c.today??(()=>new Date().toISOString().slice(0,10)),l=new Map(n.edges.map(([f,r])=>[f,r])),d=new Map;for(let[f,r]of Object.entries(e.kinds)){let k=n.kinds[f]?.computed;d.set(f,{fields:new Set(Object.keys(r.fields)),edges:new Map(Object.entries(r.edges??{}).map(([w,x])=>[w,x.cardinality??"many"])),...k?{computed:new Map(k)}:{}})}n.facts&&d.set(Ce,{computed:new Map(n.facts)});let O=Le(e),R=Object.entries(e.kinds).map(([f,r])=>{let k={};for(let[o,y]of Object.entries(r.fields))k[o]=_e(y,!y.required);let{label:w,describe:x}=n.kinds[f]??{},D=Object.entries(r.computed??{}).map(([o,y])=>[o,typeof y=="string"?{expr:y}:y]),S=Object.fromEntries([...Object.entries(r.fields).filter(([,o])=>o.label).map(([o,y])=>[o,y.label]),...D.filter(([,o])=>o.label).map(([o,y])=>[o,y.label])]),T=Object.fromEntries(Object.entries(r.fields).filter(([,o])=>o.default!==void 0).map(([o,y])=>[o,y.default])),K=Object.fromEntries(Object.entries(r.edges??{}).map(([o,{renamedFrom:y,...V}])=>[o,V])),g=o=>r[o]?{[o]:r[o]}:{};return Ee(f,{fields:ae(k),edges:K,...g("plural"),...g("noun"),...g("description"),...w?{label:o=>J(w,{node:o,kinds:d,today:i(),money:O})||o.id}:{},...x?{describe:o=>J(x,{node:o,kinds:d,today:i(),money:O})}:{},...g("lifecycle"),...g("figure"),...g("fieldRoles"),...r.computed&&Object.keys(r.computed).length>0?{computed:r.computed}:{},...Object.keys(S).length>0||r.glance||r.page?{display:{...Object.keys(S).length>0?{labels:S}:{},...r.glance?{glance:[...r.glance]}:{},...r.page?{page:r.page}:{}}}:{},...Object.keys(T).length>0?{defaults:T}:{}})}),E=De(R,e.computed);function j(f){return E.tryDefinition(f.kind)?.label?.(f)??f.id}let P=[];for(let[f,r]of Object.entries(e.acts??{})){let k=n.acts[f],{title:w,effects:x,guard:D,refusal:S,destructive:T,idempotent:K,creates:g,connects:o,severs:y,writes:V,writesOther:Q,sets:h}=k,L=new Map(k.args),F={};for(let[u,b]of L)F[u]=Je(b);let q=r.on===void 0?[]:Array.isArray(r.on)?r.on:[r.on],X=new Map(k.exprs);P.push(Pe(f,{input:ae(F),title:w,...r.description?{description:r.description}:{},...r.fromTheOtherEnd?{fromTheOtherEnd:r.fromTheOtherEnd}:{},...L.has(I)?{subject:{kinds:q.length>0?q:"*",arg:I}}:{},...T?{destructive:!0}:{},...K?{idempotent:!0}:{},...g.length>0?{creates:g}:{},...o.length>0?{connects:o}:{},...y.length>0?{severs:y}:{},writes:V,...Object.keys(Q).length>0?{writesOther:Q}:{},...Object.keys(h).length>0?{sets:h}:{},describe:(u,b)=>{let v=typeof u[I]=="string"?b.getNode(u[I]):void 0,$=v?j(v):Object.values(u).find(m=>typeof m=="string");return $?`${w}: ${String($)}`:w},apply(u,b){let v=u.graph,$=typeof b[I]=="string"?b[I]:void 0,m=$?v.getNode($):void 0;if($&&!m&&U($),m&&q.length>0&&!q.includes(m.kind))throw new Z(`"${w}" acts on ${q.join(" or ")}, not on ${ze(m.kind)}`,"invalid");let Y={};for(let[t,s]of Object.entries(b))s!==void 0&&(Y[t]=s);if(D&&m){let t;try{t=W(D,{graph:v,subject:m,kinds:d,bindings:Y,today:i()})}catch(s){throw s instanceof te?new Z(`"${w}" could not be judged: ${s.sentence}`):s}if(t!==!0)throw new Z(S?J(S,{node:m,kinds:d,graph:v,bindings:Y,today:i(),money:O}):`"${w}" is not allowed for ${j(m)} right now`)}let ee=new Map,oe=t=>v.has(t)||[...ee.values()].includes(t),ue=new Set,ie=t=>{let s=$e(t);ue.has(s)||(ue.add(s),u.removeEdge(t))},B=(t,s)=>{if(t&&typeof t=="object"&&!Array.isArray(t)&&"expr"in t)try{return W(X.get(t.expr),{graph:v,subject:s??m??null,kinds:d,bindings:Y,today:i()})}catch(p){throw p instanceof te?new Z(`"${w}" could not work out a value: ${p.sentence}`):p}let a=Ze(t);return a===void 0?typeof t=="string"&&t.startsWith("$$")?t.slice(1):t:a==="subject"?$:a==="now"?new Date().toISOString():a==="today"?i():ee.has(a)?ee.get(a):b[a]};for(let t of x)if("create"in t){let s=e.kinds[t.create],a={kind:t.create};for(let[_,N]of Object.entries(s.fields))N.default!==void 0&&(a[_]=N.default);for(let[_,N]of Object.entries(t.set??{})){let ge=B(N,void 0);ge!==void 0&&(a[_]=ge)}let p=We(s),A=u.freshId(String((p&&a[p])??t.create),t.create);u.addNode({id:A,...a}),t.as&&ee.set(t.as,A)}else if("connect"in t||"sever"in t){let s="connect"in t?t.connect:t.sever,a=String(B(t.from,void 0)??""),p=String(B(t.to,void 0)??"");if(oe(a)||U(a),oe(p)||U(p),"connect"in t){if(l.get(s)?.cardinality==="one")for(let A of v.out(a,s))A.id!==p&&ie({kind:s,from:a,to:A.id});v.out(a,s).some(A=>A.id===p)||u.addEdge({kind:s,from:a,to:p})}else ie({kind:s,from:a,to:p})}else if("set"in t){let s=String(B(t.target??"$subject",void 0)??""),a=v.getNode(s);!a&&!oe(s)&&U(s);let p={};for(let[A,_]of Object.entries(t.set)){let N=B(_,a);N!==void 0&&(p[A]=N)}Object.keys(p).length>0&&u.patchNode(s,p)}else if("remove"in t){let s=String(B(t.remove,void 0)??"");v.has(s)||U(s),u.removeNode(s)}else if("replace"in t&&m){let s=b.to;for(let a of t.replace){let p=l.get(a)?.from.includes(m.kind)??!0;for(let A of p?v.out(m.id,a):v.in(m.id,a))a===t.keep&&A.id===s||ie(p?{kind:a,from:m.id,to:A.id}:{kind:a,from:A.id,to:m.id})}}}}))}let G=[];for(let[f,r]of Object.entries(e.rules??{})){let{title:k,require:w,when:x,says:D}=n.rules[f],S=r.repairs??[],T=(g,o)=>{let y={graph:g,subject:o,kinds:d,today:i()},V;try{if(x&&W(x,y)!==!0)return[];V=W(w,y)===!0}catch(h){throw h instanceof Ie?new Me(h.sentence):h instanceof te?new Error(h.sentence):h}if(V)return[];let Q=S.flatMap(h=>{let L=e.acts?.[h.act],F={};o&&(L?.on||/^(edit|remove)-/.test(h.act))&&(F[I]=o.id);for(let[u,b]of Object.entries(h.args??{}))F[u]=Ze(b)==="subject"?o?.id:b;let X=(L?n.acts[h.act].args:[]).filter(([u,b])=>b.required&&F[u]===void 0).map(([u])=>u);return[{mutation:h.act,label:h.label??L?.title??h.act.replace(/-/g," "),args:F,...X.length>0?{missing:X}:{}}]});return[{invariant:f,...o?{subjectId:o.id}:{},label:k,message:D?J(D,{node:o,kinds:d,graph:g,today:i(),money:O}):o?`${j(o)}: ${k}`:k,nodeIds:o?[o.id]:[],repairs:Q}]},K={label:k,shape:{over:r.over,require:w,when:x,says:D,declared:e.kinds,money:O,kinds:d,today:i},judgment:{require:r.require,...r.when?{when:r.when}:{},...r.says?{says:r.says}:{}},...r.description?{description:r.description}:{},...S.length>0?{repairs:S.map(g=>g.act)}:{}};G.push(r.over==="graph"?ce(f,{scope:"graph",...K,evaluate:({graph:g})=>T(g,null)}):ce(f,{scope:{kind:r.over},...K,evaluate:({graph:g,subject:o})=>T(g,o)}))}let z=e.policy?{grants:e.policy.grants,...e.policy.sees?{sees:e.policy.sees}:{},...e.roles?{roles:e.roles}:{}}:void 0,M={name:e.name,schema:E,mutations:P,invariants:G,...z?{policy:z}:{},...n.brand?{brand:n.brand}:{},...e.modules?{modules:e.modules}:{},...e.lenses?{lenses:e.lenses}:{},...e.pages?{pages:e.pages}:{},...e.settings?{settings:e.settings}:{},...n.viewSpecs?{viewSpecs:n.viewSpecs}:{},...n.home?{home:n.home}:{},version:e.version??1};return Ve(M,e),Ue.set(M,n),{ok:!0,app:M,document:e,findings:n.findings,sights:e.policy?.sees,kinds:d}}export{qe as a,tn as b,Be as c,I as d,Ze as e,We as f,mn as g,Qe as h};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{e as z}from"./chunk.
|
|
1
|
+
import{e as z}from"./chunk.PRXKRG6O.js";import{E as N,R as O,ba as T,ca as m,d as B,ea as b,oa as V,qa as $}from"./chunk.2VX6H2LL.js";import{$a as F,A,ha as D,ja as R,sb as P,tb as j}from"./chunk.ZQ4HFIIS.js";import{a as w,b as K}from"./chunk.MRK6QJV5.js";import{b as y}from"./chunk.AJZBJBMO.js";var G=y(w(),1);var g=y(K(),1);function L(n){let e=n?.hint;return typeof e=="string"&&e.length>0?e:void 0}function J(n){if(n instanceof Error&&n.message)return n.message;let e=String(n);return e==="[object Object]"?"The view threw without a message.":e}var C=class extends G.Component{static contextType=V;state={};static getDerivedStateFromError(e){return{error:e}}componentDidCatch(e,t){console.error(`[graview] the ${this.props.view??"view"} of ${this.props.kind} threw while rendering`,e,t.componentStack),this.context?.(e,{module:"@graview/react"})}render(){let{error:e}=this.state;if(!e)return this.props.children;let t=L(e);return(0,g.jsxs)("div",{role:"alert","data-graview-view-error":this.props.kind,style:{display:"flex",flexDirection:"column",gap:"0.375rem",padding:"var(--graview-pad, 12px)",height:"100%",overflow:"auto",boxSizing:"border-box",borderRadius:"var(--graview-radius-sm, 6px)",background:"var(--graview-panel-warning, #fdf3ec)",color:"var(--graview-ink, #1a1a1a)",font:"var(--graview-font-body, 13px/1.45 system-ui)",fontSize:"0.875rem",lineHeight:1.45},children:[(0,g.jsx)("strong",{style:{color:"var(--graview-warn, #b4462a)"},children:this.props.view?`${this.props.view} could not draw`:"This view could not draw"}),(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:this.props.kind}),(0,g.jsx)("span",{children:J(e)}),t?(0,g.jsx)("span",{style:{color:"var(--graview-ink-muted, #555)"},children:t}):null]})}};var I=y(w(),1);function Q(){return m().activity}function X(n){let{noteAttention:e,noteSeat:t}=m();(0,I.useEffect)(()=>n.onCall(r=>{let i=n.author??{kind:"agent"},s=r.args?.said;r.phase==="ok"&&typeof s=="string"&&s.length>0&&t({type:"said",author:i,say:s}),!(r.phase!=="ok"||!r.reads||r.reads.length===0)&&e({reads:r.reads,author:i,intent:`read ${r.name}`})}),[n,e,t])}var l=y(w(),1);function Y(n,{units:e,target:t=0,legibleAt:r=260}){let[i,s]=(0,l.useState)(e);(0,l.useEffect)(()=>{let o=n.current;if(o===null||typeof ResizeObserver>"u")return;let a=new ResizeObserver(([c])=>{let u=c?.contentRect.width??0;u>0&&s(u)});return a.observe(o),()=>a.disconnect()},[n]);let d=i/e;return{scale:d,width:i,touchable:d*t>=24,legible:i>=r}}function Z(n="--graview-font-body",e="sans-serif"){let t=(0,l.useRef)(void 0),r=(0,l.useMemo)(()=>{if(typeof getComputedStyle!="function"||typeof document>"u")return e;let i=getComputedStyle(document.documentElement).getPropertyValue(n).trim();return i.length>0?i:e},[n,e]);return(0,l.useMemo)(()=>{t.current===void 0&&(t.current=typeof document>"u"?null:document.createElement("canvas").getContext("2d")??null);let i=t.current;return i===null?O:(s,d)=>{i.font=`${d}px ${r}`;let o=i.measureText(s).width;return o>0?o:O(s,d)}},[r])}function me(n,e,t){let[r,i]=(0,l.useState)(!1);return(0,l.useEffect)(()=>{(document.fonts?.ready??Promise.resolve()).then(()=>i(!0))},[]),(0,l.useMemo)(()=>{let s=n.current,d=r&&s?document.createElement("canvas").getContext("2d"):null;if(d)return d.font=`600 ${.8125*e}px ${getComputedStyle(s).fontFamily}`,d.measureText("M").width>0?o=>d.measureText(o).width:void 0},[r,e,t])}var ee=(0,l.createContext)(void 0);function ne(){return(0,l.useContext)(ee)}function W(n,e){let t=n.graph.getNode(e);if(!t)return[];let r=t.kind,i=n.schema.tryDefinition(r);if(!i)return[];let s=new Map;for(let d of n.allMutations()){let o=d.subject;if(!o||!(o.kinds==="*"||o.kinds.includes(r)))continue;let c=d.input.shape??{};for(let u of F(d,i)){let p=u in c,h=[];for(let f of Object.keys(c)){if(f===o.arg||f===u||te(c[f]))continue;let x=D(d.input).find(v=>v.name===f);h.push({name:f,...x?{kinds:x.kinds}:{},...x?{candidates:x.kinds.includes("*")?n.graph.allNodes().map(v=>v.id):x.kinds.flatMap(v=>n.graph.nodesOfKind(v).map(H=>H.id))}:{},shape:R(d.input,f)})}let E={field:u,mutation:d.name,title:d.title??d.name,shape:p?R(d.input,u):{type:"unknown"},takesValue:p,alternatives:[],open:h,call:f=>({name:d.name,args:p?{[o.arg]:e,[u]:f}:{[o.arg]:e}})};s.set(u,[...s.get(u)??[],E])}}return[...s.values()].map(d=>{let o=[...d.filter(u=>u.takesValue),...d.filter(u=>!u.takesValue)],[a,...c]=o;return{...a,alternatives:c}})}function te(n){let e=A(n)?.type;return e==="optional"||e==="default"||e==="nullable"}var k=y(w(),1);function oe(n){let{store:e,principal:t}=m(),r=b(),i=(0,k.useMemo)(()=>n===null?[]:W(e,n),[e,n,r]),s=(0,k.useCallback)((d,o,a={})=>{let c=d.call(o);e.apply({name:c.name,args:{...c.args,...a}},{author:t})},[e,t]);return{fields:i,commit:s}}var S=y(w(),1);function re(){let n=$();return(0,S.useMemo)(()=>[...new Set(n.flatMap(e=>e.nodeIds))],[n])}function ie(){let n=U(),e=T();return(0,S.useMemo)(()=>{if(!e)return n;let t=e.matched;return t.length===0&&n.length===0?[q]:[...new Set([...n,...t])]},[e,n])}function U(){let{store:n,selection:e}=m(),t=b();return(0,S.useMemo)(()=>{if(e.length===0)return[];let r=new Set(e),i=new Set(r);for(let s of n.graph.allEdges())r.has(s.from)&&i.add(s.to),r.has(s.to)&&i.add(s.from);for(let s of n.violations())if(s.subjectId!==void 0&&r.has(s.subjectId))for(let d of s.nodeIds)i.add(d);return[...i]},[n,e,t])}var q="search:nothing";var _=y(w(),1);function ae(){let{brand:n}=m(),e=n?.kit;return(0,_.useMemo)(()=>P(e),[e])}function se(n,e){let t=j(n,e),r={...t.color!==void 0?{color:t.color}:{},...t.pattern!==void 0?{pattern:t.pattern}:{},...t.width!==void 0?{width:t.width}:{},...t.cap!==void 0?{cap:t.cap}:{},...t.opacity!==void 0?{opacity:t.opacity}:{}};return{connector:t,style:z(e,{[e]:r})}}var M=3;function de(n){let e=B(n),t=e.focusId;if(!t)return null;if(e.within?.view){let[i]=N(t);if(i)return{at:`screen:${i}`,audience:!0}}return{at:t,audience:!1}}function Ae(n,e,t){let r=[],i=new Map,s=new Map,d=0;for(let o of n){let a=de(o.stop),c=a?e(a.at):null;if(!a||!c){o.name&&r.push({kind:"edge",presence:o,point:{x:t-8,y:40+d++*28}});continue}if(!o.name){let f=s.get(a.at);s.set(a.at,{n:(f?.n??0)+1,box:c});continue}let u=i.get(a.at)??[];if(u.push(o),i.set(a.at,u),u.length>M)continue;let p=c,h=u.length-1,E=a.audience?{x:p.x+p.width*.5+(h-1)*26,y:p.y+Math.min(p.height,24)}:{x:p.x+p.width*.5-26-h*22,y:p.y+p.height-4};r.push({kind:"person",presence:o,point:E,at:a.at,index:h,of:u.length,audience:a.audience})}for(let[o,a]of i){if(a.length<=M)continue;let c=e(o);c&&r.push({kind:"count",at:o,point:{x:c.x+c.width*.5+2*26+18,y:c.y+c.height-4},n:a.length-M})}for(let[o,{n:a,box:c}]of s)r.push({kind:"count",at:o,point:{x:c.x+c.width*.5+40,y:c.y+c.height-4},n:a});for(let o of n)if(o.name){if(o.robot?.at&&o.robot.mode!=="docked"){let a=e(o.robot.at);a&&r.push({kind:"robot",presence:o,point:{x:a.x+a.width/2+22,y:a.y+a.height-4},mode:o.robot.mode})}if(o.over){let a=e(o.over);a&&r.push({kind:"over",presence:o,box:a})}}return r}export{Q as a,X as b,Y as c,Z as d,me as e,ee as f,ne as g,oe as h,re as i,ie as j,U as k,ae as l,se as m,Ae as n,C as o};
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{f as O,k as b}from"./chunk.
|
|
1
|
+
import{f as O,k as b}from"./chunk.WOTNMTIY.js";function K(n,s){return s===1&&["every","some","sum","min","max","sort"].includes(n.fn)}function S(n){let s=new Set,e=new Set,r=[],i=[],o=new Set(O),a=(l,f)=>{switch(l.t){case"lit":return;case"ident":f||s.add(l.name);return;case"list":l.items.forEach(c=>a(c,f));return;case"member":a(l.object,f);return;case"unary":a(l.operand,f);return;case"binary":a(l.left,f),a(l.right,f);return;case"where":a(l.set,f),a(l.filter,!0);return;case"call":{e.add(l.fn);let c=(l.fn==="out"||l.fn==="in")&&l.args.length===2?l.args[1]:l.args[0],h=c?.t==="lit"&&typeof c.value=="string"?c.value:void 0;l.fn==="all"&&h&&r.push(h),(l.fn==="out"||l.fn==="in")&&h&&i.push(h),l.args.forEach((k,x)=>a(k,f||K(l,x)));return}}};return a(n,!1),{names:s,functions:e,unknownFunctions:[...e].filter(l=>!o.has(l)),sweeps:r,edges:i}}var p=class extends Error{constructor(e,r,i){super(`${e} (at character ${r+1} of "${i}")`);this.sentence=e;this.at=r;this.source=i}},q=["||","&&","==","!=","<=",">=","<",">","!","|","&","+","-","*","/","%","(",")","[","]",",","."],F={and:"&&",or:"||",not:"!"},M=2e3;function I(n){let s=[],e=0;for(;e<n.length;){let r=n[e];if(r===" "||r===" "||r===`
|
|
2
2
|
`||r==="\r"){e++;continue}if(r>="0"&&r<="9"){let o=e;for(;e<n.length&&/[0-9.]/.test(n[e]);)e++;let a=n.slice(o,e),l=Number(a);if(!Number.isFinite(l)||a.split(".").length>2)throw new p(`"${a}" is not a number`,o,n);s.push({k:"num",v:l,at:o});continue}if(r==="'"||r==='"'){let o=e++,a="";for(;e<n.length&&n[e]!==r;)n[e]==="\\"&&e+1<n.length&&e++,a+=n[e++];if(e>=n.length)throw new p("a quoted word is never closed",o,n);e++,s.push({k:"str",v:a,at:o});continue}if(/[A-Za-z_]/.test(r)){let o=e;for(;e<n.length&&/[A-Za-z0-9_]/.test(n[e]);)e++;let a=n.slice(o,e),l=Object.hasOwn(F,a)?F[a]:void 0;s.push(l?{k:"op",v:l,at:o}:{k:"id",v:a,at:o});continue}let i=q.find(o=>n.startsWith(o,e));if(!i)throw new p(`"${r}" is not part of the rule language`,e,n);s.push({k:"op",v:i,at:e}),e+=i.length}return s.push({k:"end",at:n.length}),s}function w(n){if(n.length>M)throw new p(`an expression may be at most ${M} characters`,0,n.slice(0,40));let s=I(n),e=0,r=()=>s[e],i=t=>{let d=r();return d.k==="op"&&d.v===t},o=t=>{let d=r();return d.k==="id"&&d.v===t},a=(t,d)=>{if(!i(t))throw new p(`expected ${d}`,r().at,n);e++},l=0,f=(t,d)=>{if(++l>64)throw new p("the expression nests too deeply",t,n);try{return d()}finally{l--}},c=(t,d)=>()=>{let u=d();for(;;){let y=r(),R=y.k==="op"?t.find(B=>B===y.v):y.k==="id"&&y.v==="in"&&t.includes("in")?"in":void 0;if(!R)return u;e++,u={t:"binary",op:R,left:u,right:d(),at:y.at}}},h=()=>{let t=r();if(t.k==="num")return e++,{t:"lit",value:t.v,at:t.at};if(t.k==="str")return e++,{t:"lit",value:t.v,at:t.at};if(t.k==="id"){if(e++,t.v==="true"||t.v==="false")return{t:"lit",value:t.v==="true",at:t.at};if(t.v==="null")return{t:"lit",value:null,at:t.at};if(i("(")){e++;let d=[];if(!i(")"))for(;;){if(d.push(m()),i(",")){e++;continue}break}return a(")",`")" to close ${t.v}(\u2026)`),{t:"call",fn:t.v,args:d,at:t.at}}return{t:"ident",name:t.v,at:t.at}}if(t.k==="op"&&t.v==="("){e++;let d=f(t.at,m);return a(")",'a ")"'),d}if(t.k==="op"&&t.v==="["){e++;let d=[];if(!i("]"))for(;;){if(d.push(m()),i(",")){e++;continue}break}return a("]",'a "]" to close the list'),{t:"list",items:d,at:t.at}}throw t.k==="end"?new p("the expression ends too soon",t.at,n):new p(`"${t.k==="op"?t.v:""}" cannot start a value here`,t.at,n)},k=()=>{let t=h();for(;;){if(i(".")){let d=r();e++;let u=r();if(u.k!=="id")throw new p('expected a field name after "."',u.at,n);e++,t={t:"member",object:t,name:u.v,at:d.at};continue}if(o("where")){let d=r().at;e++,t={t:"where",set:t,filter:f(d,m),at:d};continue}return t}},x=()=>{let t=r();return t.k==="op"&&(t.v==="!"||t.v==="-")?(e++,{t:"unary",op:t.v,operand:f(t.at,x),at:t.at}):k()},T=c(["*","/","%"],x),C=c(["+","-"],T),A=c(["&"],C),v=c(["|"],A),P=()=>{let t=v(),d=r(),u=d.k==="op"&&["==","!=","<","<=",">",">="].includes(d.v)?d.v:d.k==="id"&&d.v==="in"?"in":void 0;return u?(e++,{t:"binary",op:u,left:t,right:v(),at:d.at}):t},$=()=>{let t=r();return t.k==="op"&&t.v==="!"?(e++,{t:"unary",op:"!",operand:f(t.at,$),at:t.at}):P()},z=c(["&&"],$),_=c(["||"],z);function m(){return _()}let N=m();if(r().k!=="end")throw new p("there is more after the end of the expression",r().at,n);return N}function D(n){let s,e=-1,r=0;for(let i=0;i<n.length;i++){let o=n[i];if(s){o==="\\"?i++:o===s&&(s=void 0);continue}o==="'"||o==='"'?s=o:o==="("||o==="["?r++:o===")"||o==="]"?r--:o==="|"&&r===0&&(n[i+1]==="|"?i++:e=i)}return e}var E=/\s*(?:'((?:[^'\\]|\\.)*)'|"((?:[^"\\]|\\.)*)")\s*(,|$)/y;function H(n){let s=n.indexOf(":"),e=(s>=0?n.slice(0,s):n).trim();if(!b.includes(e))throw new g(`"${e}" is not a formatter; use one of ${b.join(", ")}`);let r=[];if(s>=0){let i=n.slice(s+1),o=0;for(;o<i.length;){E.lastIndex=o;let a=E.exec(i);if(!a)throw new g(`"${e}" is told quoted words, like ${e}: 'offer'`);if(r.push((a[1]??a[2]??"").replace(/\\(.)/g,"$1")),o=E.lastIndex,a[3]==="")break}}if(e==="plural"&&(r.length<1||r.length>2))throw new g("plural is told its noun, like {count | plural: 'offer'}, and its plural where English does not make it: plural: 'person', 'people'");if(e!=="plural"&&r.length>0)throw new g(`"${e}" takes nothing after it`);return{format:e,args:r}}var g=class extends Error{constructor(e){super(e);this.sentence=e}};function J(n){let s=[],e=0;for(;e<n.length;){let r=n.indexOf("{",e);if(r<0){s.push({text:n.slice(e)});break}r>e&&s.push({text:n.slice(e,r)});let i=n.indexOf("}",r);if(i<0)throw new g(`a "{" at character ${r+1} is never closed`);let o=n.slice(r+1,i),a=D(o),l=(a>=0?o.slice(0,a):o).trim(),f=a>=0?H(o.slice(a+1)):void 0;s.push({expr:w(l),source:l,...f?{format:f.format}:{},...f&&f.args.length>0?{formatArgs:f.args}:{}}),e=i+1}return s}function j(n){let s=new Map;for(let[e,r]of Object.entries(n?.computed??{}))s.set(e,typeof r=="string"?{expr:r}:r);return s}function te(n){let s=j(n);if(s.size===0)return;let e=new Map;for(let[r,i]of s)try{e.set(r,w(i.expr))}catch(o){if(!(o instanceof p))throw o}return e}function L(n,s,e=new Set){let r=j(n).get(s);if(!r||e.has(s))return!1;let i;try{i=w(r.expr)}catch{return!1}let o=S(i);if(o.edges.length>0||o.sweeps.length>0||[...o.functions].some(c=>c==="out"||c==="in"||c==="all"))return!1;let a=n.fields,l=c=>a instanceof Set?a.has(c):Object.hasOwn(a,c),f=new Set([...e,s]);return[...o.names].every(c=>l(c)||L(n,c,f))}export{S as a,p as b,w as c,g as d,J as e,j as f,te as g,L as h};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import{a as Y}from"./chunk.3O2QU7LU.js";import{a as E,c as H,e as V,f as _}from"./chunk.53RZI5PM.js";import"./chunk.NRWJ6PLU.js";import"./chunk.HAQ4KHRY.js";import"./chunk.PRXKRG6O.js";import"./chunk.AHDOKM4O.js";import{E as W,ca as w,d as M,ua as G,xa as B}from"./chunk.2VX6H2LL.js";import{I as L,L as O,P as T}from"./chunk.ZQ4HFIIS.js";import{a as U,b as k}from"./chunk.MRK6QJV5.js";import{b as y}from"./chunk.AJZBJBMO.js";function A(t){return{minHeight:24,padding:"3px 10px",borderRadius:6,fontSize:"0.875rem",borderWidth:1,borderStyle:"solid",borderColor:t?"transparent":"var(--graview-edge)",color:t?"var(--graview-ink)":"var(--graview-ink-muted)",fontWeight:t?600:400,background:t?"color-mix(in srgb, var(--graview-accent) 16%, transparent)":"transparent"}}var P=y(k(),1);function j(){let{seats:t,principal:r,takeSeat:i}=w();return t.length<2?null:(0,P.jsxs)("div",{role:"group","aria-label":"Seat","data-testid":"seats",style:{display:"flex",alignItems:"center",flexWrap:"wrap",gap:6,rowGap:4},children:[(0,P.jsx)("span",{style:{fontSize:"0.75rem",letterSpacing:"0.12em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},children:"As"}),t.map(a=>{let l=q(r,a.principal);return(0,P.jsx)("button",{type:"button","aria-pressed":l,"data-testid":`seat-${a.principal.id??a.label}`,title:`Sit down as ${a.label}: the acts, the kinds and the pages narrow to what this seat may do`,onClick:()=>i(a.principal),style:{...A(l),whiteSpace:"nowrap"},children:a.label},a.principal.id??a.label)})]})}function q(t,r){return t.kind===r.kind&&t.id===r.id}var z=y(U(),1),o=y(k(),1),J=`
|
|
2
|
+
.graview-here{display:flex;flex:none}
|
|
3
|
+
.graview-here>button{display:inline-flex;align-items:center;gap:4px;height:30px;margin:0;padding:0 4px;border:1px solid transparent;border-radius:8px;background:none;box-shadow:none;font:inherit;font-size:.75rem;color:var(--graview-ink-muted);cursor:pointer}
|
|
4
|
+
.graview-here-mark{display:inline-flex;align-items:center;justify-content:center;flex:none;box-sizing:border-box;width:24px;height:24px;border-radius:50%;border:1.5px solid hsl(var(--graview-hue) 50% 48%);background:var(--graview-panel-muted);color:var(--graview-ink);font-size:.75rem;font-weight:600;box-shadow:0 0 0 2px var(--graview-bar)}
|
|
5
|
+
.graview-here-mark+.graview-here-mark{margin-left:-10px}
|
|
6
|
+
.graview-here-mark[data-agent]{border-radius:5px}
|
|
7
|
+
.graview-here-mark[data-counted]{--graview-hue:0;border-color:var(--graview-edge)}
|
|
8
|
+
.graview-here small{display:block;font-size:.75rem;color:var(--graview-ink-muted)}
|
|
9
|
+
.graview-bar[data-finding] .graview-here{display:none}`,Q={position:"absolute",width:1,height:1,overflow:"hidden",clip:"rect(0 0 0 0)"};function X(t,r){let i=r.id===void 0?null:`${r.kind}:${r.id}`,a=new Map;for(let l of t.values()){let d=l.participant.slice(0,l.participant.lastIndexOf(":"));if(d===i)continue;let s=d.endsWith(":")?l.participant:d,h=a.get(s);(!h||h.at<l.at)&&a.set(s,l)}return[...a.values()]}var D=t=>t.name&&t.onBehalfOfName?`${t.name}, for ${t.onBehalfOfName}`:t.name??"",K=t=>t===1?"1 viewer":`${t} viewers`;function Z(t){let r=t.map(D).filter(Boolean),i=r.length<t.length?[...r,K(t.length-r.length)]:r,a=i.pop();return`${i.length>0?`${i.join(", ")} and ${a}`:a} ${t.length===1?"is":"are"} here`}function ee(t,r){let{store:i,hidden:a,pictures:l}=r,d=M(t),s=i.kindsKeptFrom(r.principal),h=p=>!a.has(p)&&!s.has(p)&&!i.modules.disabledKinds.has(p),u=l.find(p=>p.as===d.within?.view&&h(p.kind));if(u)return u.title;if(!d.focusId)return d.overview?"the whole thing":null;let g=W(d.focusId);if(g.length>0)return g.every(h)?g.map(p=>T(i.schema,p)).join(" and "):null;let m=i.graph.getNode(d.focusId);return m&&h(m.kind)?L(i.schema.tryDefinition(m.kind),m):null}function te({scene:t,compact:r}){let{who:i,principal:a,store:l,views:d,hiddenKinds:s,follow:h}=w(),u=B("here"),g=X(i,a),m=g.length===0?"":Z(g),[p,N]=(0,z.useState)("");if((0,z.useEffect)(()=>N(m),[m]),g.length===0)return null;let S=g.filter(c=>c.name),f=S.slice(0,r?2:3),v=g.length-f.length,b=g.length-S.length,n=d.places();return(0,o.jsxs)("div",{className:"graview-here","data-testid":"here",children:[(0,o.jsx)("style",{children:J}),(0,o.jsx)("span",{role:"status","aria-live":"polite",style:Q,children:p}),(0,o.jsxs)("button",{type:"button","data-testid":"here-open",...u.trigger,onClick:u.toggle,"aria-label":`${m} \u2014 who and where`,title:m,children:[f.length>0?(0,o.jsx)("span",{style:{display:"flex"},children:f.map(c=>(0,o.jsx)(R,{one:c},c.participant))}):(0,o.jsx)(R,{count:v}),f.length>0&&v>0?(0,o.jsxs)("span",{"aria-hidden":"true",children:["+",v]}):null]}),(0,o.jsxs)("ul",{...u.pane,"aria-label":"Who is here","data-testid":"here-list",hidden:!u.open,className:"graview-bar-list",style:G,children:[S.map(c=>{let x=ee(c.stop,{store:l,principal:a,hidden:s,pictures:n}),I=D(c);return(0,o.jsx)("li",{children:(0,o.jsxs)(t?"button":"span",{className:"graview-bar-item","data-testid":"here-one",...t?{type:"button",title:`Go where ${I} is`,onClick:()=>{u.setOpen(!1),h(c.participant)}}:{style:{cursor:"default"}},children:[(0,o.jsx)(R,{one:c}),(0,o.jsxs)("span",{children:[I,x?(0,o.jsxs)("small",{children:["On ",x]}):null]})]})},c.participant)}),b>0?(0,o.jsx)("li",{children:(0,o.jsxs)("span",{className:"graview-bar-item","data-testid":"here-viewers",style:{cursor:"default"},children:[(0,o.jsx)(R,{count:b}),(0,o.jsxs)("span",{children:[K(b),(0,o.jsx)("small",{children:"Not signed in"})]})]})}):null]})]})}function R({one:t,count:r}){return(0,o.jsx)("span",{className:"graview-here-mark","aria-hidden":"true",...t?{style:{"--graview-hue":Math.round(t.hue)}}:{"data-counted":""},...t?.kind==="agent"?{"data-agent":""}:{},children:t?(t.name??"").trim().charAt(0).toUpperCase():r})}var e=y(k(),1);function ye({violations:t,pick:r}){let{store:i,brand:a,setMenuAt:l}=w(),d=E(i,t);return(0,e.jsx)(e.Fragment,{children:d.map((s,h)=>{let u=_(s),g=s.repairs.length>0?`${s.repairs.length} ${s.repairs.length===1?"way":"ways"} to fix`:"";return(0,e.jsx)("li",{style:{borderTop:h===0?"none":"1px solid var(--graview-edge)"},children:(0,e.jsxs)("button",{type:"button",onClick:m=>{let p=m.currentTarget.closest("ol").getBoundingClientRect();r(s),l({x:p.left,y:p.top,on:s.subjectId})},...H(s)!==void 0?{title:H(s)}:{},style:{width:"100%",textAlign:"left",fontSize:"0.8125rem",lineHeight:1.4,padding:"7px 8px",border:"1px solid transparent",background:"none",boxShadow:"none",borderRadius:7},children:[s.line?(0,e.jsx)(V,{line:s.line,schema:i.schema,...a?{brand:a}:{},stacked:!0,style:{display:"block",color:"var(--graview-ink)"}}):(0,e.jsx)("span",{style:{display:"block",color:"var(--graview-ink)"},children:s.message}),u||g?(0,e.jsx)("span",{style:{color:"var(--graview-ink-faint)",fontSize:"0.75rem"},children:[u,g].filter(Boolean).join(" \xB7 ")}):null]})},`${s.invariant}:${h}`)})})}function we({name:t,me:r,scheme:i,onScheme:a,profileHref:l,hostActions:d,close:s,part:h,signature:u=!1}){let{principal:g,seats:m,settings:p,settingValues:N,chooseSetting:S,sharing:f}=w(),v=g.roles??[],b={setOpen:n=>s()};return(0,e.jsx)(e.Fragment,{children:h==="top"?(0,e.jsxs)(e.Fragment,{children:[(0,e.jsxs)("div",{style:{display:"grid",gap:3},children:[(0,e.jsx)("span",{style:C,children:"Signed in as"}),(0,e.jsx)("strong",{style:{fontSize:"1rem",fontWeight:550},children:t}),(0,e.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:v.length>0?v.map(n=>O(n)).join(", "):r===void 0?"This app has no sign-in; everything here is yours.":"No role in particular"}),r!==void 0&&l!==void 0?(0,e.jsx)("a",{href:l(r.id),"data-testid":"profile-record",style:{display:"inline-flex",alignItems:"center",minHeight:24,justifySelf:"start",fontSize:"0.875rem",color:"var(--graview-accent)"},children:"Your record \u2197"}):null,f?(0,e.jsxs)("span",{"data-testid":"profile-seen-as",style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:["Seen by others as ",f.name]}):null]}),d.length>0?(0,e.jsx)("ul",{role:"list","aria-label":"From the host","data-testid":"host-actions",style:{...$,margin:0,paddingLeft:0,listStyle:"none",display:"grid",gap:2},children:d.map(n=>(0,e.jsx)("li",{children:n.href!==void 0?(0,e.jsx)("a",{href:n.href,"data-testid":"host-action",className:"graview-host-action",...n.target?{target:n.target,rel:"noopener"}:{},onClick:()=>{n.onSelect?.(),b.setOpen(!1)},style:F,children:n.label}):(0,e.jsx)("button",{type:"button","data-testid":"host-action",className:"graview-host-action",onClick:()=>{b.setOpen(!1),n.onSelect?.()},style:{...F,width:"100%",textAlign:"left",border:"none",background:"none",boxShadow:"none",font:"inherit",cursor:"pointer"},children:n.label})},n.label))}):null]}):(0,e.jsxs)(e.Fragment,{children:[m.length>1?(0,e.jsxs)("div",{style:{display:"grid",gap:6,...$},children:[(0,e.jsx)("span",{style:C,children:"Sit as somebody else"}),(0,e.jsx)(j,{})]}):null,p.length>0?(0,e.jsx)("div",{style:{display:"grid",gap:10,...$},children:p.map(n=>(0,e.jsxs)("fieldset",{"data-testid":`setting-${n.name}`,style:{border:0,margin:0,padding:0,display:"grid",gap:5},children:[(0,e.jsx)("legend",{style:{...C,padding:0},children:n.title}),n.description?(0,e.jsx)("span",{style:{fontSize:"0.8125rem",color:"var(--graview-ink-muted)"},children:n.description}):null,(0,e.jsx)("div",{style:{display:"flex",flexWrap:"wrap",gap:4},children:n.options.map(c=>{let x=(N[n.name]??n.initial)===c.value;return(0,e.jsx)("button",{type:"button","aria-pressed":x,"data-testid":`setting-${n.name}-${c.value}`,onClick:()=>S(n.name,c.value),style:A(x),children:c.label},c.value)})})]},n.name))}):null,i!==void 0&&a!==void 0?(0,e.jsxs)("div",{style:{display:"grid",gap:5,...$},children:[(0,e.jsx)("span",{style:C,children:"Scheme"}),(0,e.jsx)("div",{style:{display:"flex",gap:4},children:["light","dark"].map(n=>(0,e.jsx)("button",{type:"button","aria-pressed":i===n,"data-testid":`profile-scheme-${n}`,onClick:()=>a(n),style:A(i===n),children:n==="light"?"\u2600 Light":"\u263E Dark"},n))})]}):null,u?(0,e.jsxs)("p",{"data-testid":"graview-signature",style:{...$,margin:0,display:"flex",alignItems:"center",gap:6,fontSize:"0.75rem",color:"var(--graview-ink-faint)"},children:["Built with",(0,e.jsxs)("a",{href:"https://graview.dev",target:"_blank",rel:"noopener",style:{display:"inline-flex",alignItems:"center",gap:4,minHeight:24,color:"var(--graview-ink-muted)",fontWeight:600,textDecoration:"none"},children:[(0,e.jsx)("span",{"data-testid":"graview-mark",style:{display:"inline-flex",lineHeight:0},dangerouslySetInnerHTML:{__html:ne}}),"Graview"]})]}):null]})})}var ne='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 32 32" width="14" height="14" aria-hidden="true" focusable="false"><g fill="none" stroke="currentColor" stroke-width="2.4" stroke-linejoin="round"><path d="M13 11 L3 8 L14 3 H29 L21 9"/><path d="M10 18 L3 23 L16.5 28 L29 21 L22 19"/><path d="M16.5 18.5 V23.5" stroke-linecap="round"/></g><circle cx="16.5" cy="13.5" r="2" fill="var(--graview-mark-point, currentColor)"/></svg>',F={display:"flex",alignItems:"center",minHeight:28,padding:"2px 8px",borderRadius:7,fontSize:"0.875rem",color:"var(--graview-ink)",textDecoration:"none"},C={fontSize:"0.75rem",letterSpacing:"0.14em",textTransform:"uppercase",color:"var(--graview-ink-faint)"},$={paddingTop:10,borderTop:"1px solid var(--graview-edge)"};export{Y as ActivityRail,te as Here,ye as ProblemRows,we as ProfilePane};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{a,b}from"./chunk.KKTHQJ6F.js";import"./chunk.BLAODPYJ.js";import"./chunk.HH6WIUK3.js";import"./chunk.GDIRDJF3.js";import"./chunk.Y4R77MKX.js";import"./chunk.FRNIWOKD.js";import"./chunk.42U4UBDE.js";import"./chunk.XJNXSQT4.js";import"./chunk.VTBAKTFP.js";import"./chunk.7U7Q3HIS.js";import"./chunk.6O67NOZR.js";import"./chunk.WWRWXFYR.js";import"./chunk.ISAMJ7AK.js";import"./chunk.54NSG7BX.js";import"./chunk.6KJSFIO7.js";import"./chunk.UM5IPM22.js";import"./chunk.6XBLDV4A.js";import"./chunk.WOTNMTIY.js";import"./chunk.HAQ4KHRY.js";import"./chunk.PRXKRG6O.js";import"./chunk.AHDOKM4O.js";import"./chunk.TDW6QEG4.js";import"./chunk.LW7KV5SL.js";import"./chunk.2VX6H2LL.js";import"./chunk.ZQ4HFIIS.js";import"./chunk.MRK6QJV5.js";import"./chunk.AJZBJBMO.js";export{b as declaredLensView,a as formatFor};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{wb as e}from"./chunk.ZQ4HFIIS.js";var a=`
|
|
2
2
|
.graview-spec { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--graview-ink); }
|
|
3
3
|
|
|
4
4
|
.graview-spec-row { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 4px 10px; box-sizing: border-box; max-width: 100%; padding: 5px 10px; border: 1px solid var(--graview-edge); border-radius: var(--graview-radius-sm, 8px); background: var(--graview-panel); font-size: 0.875rem; }
|