graview 0.1.27 → 0.1.29
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.2643W7FT.js +1 -0
- package/dist/preview/chunk.2CLPRG3I.js +1 -0
- package/dist/preview/chunk.2IZFIORK.js +1 -0
- package/dist/preview/chunk.2NCTM5K2.js +2 -0
- package/dist/preview/{chunk.5BN2ARQ2.js → chunk.3G5MQFZK.js} +1 -1
- package/dist/preview/chunk.3JM2TNDD.js +2 -0
- package/dist/preview/chunk.44FVJOK4.js +28 -0
- package/dist/preview/chunk.4GGAPOMK.js +2 -0
- package/dist/preview/chunk.5AT4O4BN.js +1 -0
- package/dist/preview/chunk.5JXUAMKI.js +1 -0
- package/dist/preview/chunk.5R66YTET.js +2 -0
- package/dist/preview/chunk.64P76WK4.js +1 -0
- package/dist/preview/chunk.7D77HEIJ.js +1 -0
- package/dist/preview/chunk.7DNFXJH3.js +1 -0
- package/dist/preview/{chunk.HPD3DSTP.js → chunk.7PRFYYVM.js} +1 -1
- package/dist/preview/chunk.AE5GKL4C.js +1 -0
- package/dist/preview/chunk.ARR75WBP.js +35 -0
- package/dist/preview/chunk.AVUS5LMG.js +3 -0
- package/dist/preview/chunk.BKPGDEES.js +1 -0
- package/dist/preview/chunk.BZ5OJYHU.js +1 -0
- package/dist/preview/chunk.CK7QWLMX.js +1 -0
- package/dist/preview/chunk.COTG2IG5.js +1 -0
- package/dist/preview/chunk.D4GOVA25.js +1 -0
- package/dist/preview/chunk.DAA6XWLF.js +1 -0
- package/dist/preview/chunk.DKTCRFMS.js +1 -0
- package/dist/preview/chunk.DLGTFXGM.js +1 -0
- package/dist/preview/chunk.DN7SN6ZR.js +1 -0
- package/dist/preview/chunk.G4WQGTZR.js +3 -0
- package/dist/preview/chunk.GDA3G4U2.js +6 -0
- package/dist/preview/chunk.GS4T26WW.js +328 -0
- package/dist/preview/chunk.GZH6PTXN.js +1 -0
- package/dist/preview/chunk.HFKMHLJ3.js +1 -0
- package/dist/preview/chunk.HGAMNIST.js +1 -0
- package/dist/preview/chunk.HJCQ6I3S.js +1 -0
- package/dist/preview/chunk.HKBKH7EK.js +1 -0
- package/dist/preview/chunk.HLLWKSZB.js +5 -0
- package/dist/preview/chunk.HONUT6OG.js +1 -0
- package/dist/preview/chunk.HRWLR7T4.js +1 -0
- package/dist/preview/chunk.HV6I74DF.js +1 -0
- package/dist/preview/chunk.IPBXAAQV.js +17 -0
- package/dist/preview/chunk.IWYUFYDJ.js +1 -0
- package/dist/preview/chunk.IZW7DBK4.js +1 -0
- package/dist/preview/chunk.J46KDTEZ.js +10 -0
- package/dist/preview/chunk.JNGUSAWX.js +70 -0
- package/dist/preview/chunk.JU2ZVKMT.js +2 -0
- package/dist/preview/chunk.K4ZUVH2G.js +1 -0
- package/dist/preview/chunk.KC6UZHBM.js +1 -0
- package/dist/preview/chunk.KLITC55P.js +1 -0
- package/dist/preview/chunk.KZ2376BD.js +19 -0
- package/dist/preview/chunk.LYJAVUST.js +1 -0
- package/dist/preview/chunk.MB7LKKUD.js +1 -0
- package/dist/preview/chunk.MOUGB4H6.js +1 -0
- package/dist/preview/chunk.MYFWM572.js +1 -0
- package/dist/preview/chunk.N4FBDA2W.js +1 -0
- package/dist/preview/chunk.O42YET3W.js +1 -0
- package/dist/preview/chunk.O4QPITBD.js +9 -0
- package/dist/preview/{chunk.IXVSJJQH.js → chunk.OGXE2RHC.js} +4 -4
- package/dist/preview/chunk.OHE5AMHH.js +0 -0
- package/dist/preview/chunk.ONGVH3ZM.js +1076 -0
- package/dist/preview/chunk.OQDETV4X.js +1 -0
- package/dist/preview/chunk.OWBEV6FR.js +1 -0
- package/dist/preview/chunk.OWE6OJ4P.js +1 -0
- package/dist/preview/chunk.OYJSFO3A.js +1 -0
- package/dist/preview/chunk.P62SKNJS.js +27 -0
- package/dist/preview/chunk.PA5HYAEO.js +1 -0
- package/dist/preview/{chunk.OA5BVKJH.js → chunk.PMEDLEZY.js} +2 -2
- package/dist/preview/chunk.PTXQHHKF.js +1 -0
- package/dist/preview/chunk.Q5WEOX3Q.js +1 -0
- package/dist/preview/chunk.QNHECGMH.js +1 -0
- package/dist/preview/chunk.QSDT2RLY.js +1 -0
- package/dist/preview/chunk.R2D373VG.js +1 -0
- package/dist/preview/chunk.RB4RTBRZ.js +1 -0
- package/dist/preview/chunk.RCLJ4H52.js +116 -0
- package/dist/preview/chunk.RKRSRKF3.js +1 -0
- package/dist/preview/chunk.RWGLKDWH.js +1 -0
- package/dist/preview/chunk.SIL4KD3K.js +1 -0
- package/dist/preview/chunk.SS76EIMI.js +1 -0
- package/dist/preview/{chunk.IKT7JQUW.js → chunk.T4LY5QXO.js} +1 -1
- package/dist/preview/chunk.UIIVEQAT.js +1 -0
- package/dist/preview/chunk.UT6642FC.js +1 -0
- package/dist/preview/chunk.UTHHX2TJ.js +1 -0
- package/dist/preview/chunk.UWNYT7PF.js +1 -0
- package/dist/preview/chunk.V6TK4LHW.js +6 -0
- package/dist/preview/chunk.VNBO2RXD.js +1 -0
- package/dist/preview/chunk.VPPUTA74.js +1 -0
- package/dist/preview/chunk.WKXNBHTL.js +4 -0
- package/dist/preview/chunk.WLRTPFAC.js +1 -0
- package/dist/preview/chunk.X53HI436.js +1 -0
- package/dist/preview/chunk.XAXJHEMD.js +1 -0
- package/dist/preview/chunk.XDYAG276.js +1 -0
- package/dist/preview/chunk.XDZSTIS6.js +88 -0
- package/dist/preview/chunk.XXHNV24G.js +1 -0
- package/dist/preview/chunk.YCA7P5MK.js +1 -0
- package/dist/preview/chunk.YRQZZH5V.js +1 -0
- package/dist/preview/chunk.YUWRZWGX.js +1 -0
- package/dist/preview/chunk.Z2RGLFLS.js +1 -0
- package/dist/preview/chunk.Z56B2JR2.js +25 -0
- package/dist/preview/chunk.Z5V23DQN.js +3 -0
- package/dist/preview/chunk.ZBXOX3W3.js +1 -0
- package/dist/preview/chunk.ZEGSQCSD.js +1 -0
- package/dist/preview/chunk.ZEVVWWNA.js +44 -0
- package/dist/preview/chunk.ZS4DJ76C.js +1 -0
- package/dist/preview/chunk.ZSKP6UQS.js +3 -0
- package/dist/preview/page.js +6 -6
- package/package.json +6 -6
- package/dist/preview/chunk.4HGBVU5B.js +0 -1
- package/dist/preview/chunk.4JXWQO6Y.js +0 -1
- package/dist/preview/chunk.4R7LDCDO.js +0 -1
- package/dist/preview/chunk.4W24TPMR.js +0 -1
- package/dist/preview/chunk.6LJ66MB7.js +0 -1
- package/dist/preview/chunk.6R4EI47C.js +0 -1
- package/dist/preview/chunk.7CO6VP6F.js +0 -1
- package/dist/preview/chunk.7QTBDACG.js +0 -1
- package/dist/preview/chunk.7SVIRYBB.js +0 -1
- package/dist/preview/chunk.7THQFY52.js +0 -1
- package/dist/preview/chunk.AHDOKM4O.js +0 -1
- package/dist/preview/chunk.AS35X6KA.js +0 -1
- package/dist/preview/chunk.ATLUMYAJ.js +0 -23
- package/dist/preview/chunk.CW7BMVBG.js +0 -321
- package/dist/preview/chunk.DG2UE7PJ.js +0 -1
- package/dist/preview/chunk.DG2WKNMX.js +0 -1
- package/dist/preview/chunk.DQ5OWYLQ.js +0 -1
- package/dist/preview/chunk.DY2FFBWF.js +0 -1
- package/dist/preview/chunk.E3SZ7T75.js +0 -1
- package/dist/preview/chunk.EVTZE2OZ.js +0 -1
- package/dist/preview/chunk.FS5K4AVA.js +0 -8
- package/dist/preview/chunk.FTBKJ5RZ.js +0 -16
- package/dist/preview/chunk.GHMICJIB.js +0 -1
- package/dist/preview/chunk.HO6JR7VY.js +0 -1
- package/dist/preview/chunk.I5KD54S6.js +0 -1
- package/dist/preview/chunk.IZDKEFPJ.js +0 -1
- package/dist/preview/chunk.J36GTQTV.js +0 -1
- package/dist/preview/chunk.KAKX5TZN.js +0 -3
- package/dist/preview/chunk.LHAAZQNQ.js +0 -19
- package/dist/preview/chunk.LQZ2VQWN.js +0 -107
- package/dist/preview/chunk.MHJJEGQO.js +0 -1
- package/dist/preview/chunk.MNPNW4BQ.js +0 -1
- package/dist/preview/chunk.MRK6QJV5.js +0 -25
- package/dist/preview/chunk.NKIFVPS3.js +0 -1
- package/dist/preview/chunk.NQNQPPPM.js +0 -1
- package/dist/preview/chunk.OHGJ5BZ4.js +0 -2
- package/dist/preview/chunk.OYULDOQP.js +0 -1
- package/dist/preview/chunk.PHY3AH3L.js +0 -1
- package/dist/preview/chunk.Q7544RCB.js +0 -1
- package/dist/preview/chunk.QZWN46V6.js +0 -1
- package/dist/preview/chunk.RUC4HFVC.js +0 -1
- package/dist/preview/chunk.S5JWZIVE.js +0 -1
- package/dist/preview/chunk.SHDYLMZE.js +0 -2
- package/dist/preview/chunk.T2EZ5MTH.js +0 -1
- package/dist/preview/chunk.TMPV4HLQ.js +0 -1
- package/dist/preview/chunk.TX2GOL65.js +0 -29
- package/dist/preview/chunk.U5ZUXGWM.js +0 -1040
- package/dist/preview/chunk.UMMN5Z6V.js +0 -1
- package/dist/preview/chunk.UPGDSOBY.js +0 -1
- package/dist/preview/chunk.V57P4LIZ.js +0 -1
- package/dist/preview/chunk.VD6FJ6KJ.js +0 -2
- package/dist/preview/chunk.VFICMX5G.js +0 -61
- package/dist/preview/chunk.VMD4PDYJ.js +0 -1
- package/dist/preview/chunk.VMEX2KZ4.js +0 -8
- package/dist/preview/chunk.XDHBV5K5.js +0 -1
- package/dist/preview/chunk.YO7UFBJP.js +0 -1
- package/dist/preview/chunk.YSYT3ASK.js +0 -1
- package/dist/preview/chunk.YV2RTNPU.js +0 -6
- package/dist/preview/chunk.ZD5HGRPR.js +0 -1
- package/dist/preview/chunk.ZKM4P7US.js +0 -1
- package/dist/preview/chunk.ZMMMKTAG.js +0 -1
- package/dist/preview/chunk.ZNIJONZN.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as z,b as Z,c as X,d as G}from"./chunk.DG2WKNMX.js";import{a as q}from"./chunk.HPD3DSTP.js";import{c as R,e as K}from"./chunk.VD6FJ6KJ.js";import{a as j,b as $,c as U,e as O,l as W,m as g,n as H}from"./chunk.OHGJ5BZ4.js";import{B as v,C as _,E as I,G as L,I as A,J as k,K as b,P as D,T as x,Y as F}from"./chunk.VMEX2KZ4.js";var T=e=>e?._zod?.def,ie=/^\^\\d\{4\}-\\d\{2\}-\\d\{2\}\$$/;function se(e){let n=T(e),a=!0,r;for(let i=0;n&&i<4;i++){if(n.type==="optional"||n.type==="nullable")a=!1;else if(n.type==="default")a=!1,r=n.defaultValue;else break;n=T(n.innerType)}if(!n)return{why:"it is not a zod field"};let o=_(e),t={...a?{required:!0}:{},...r!==void 0?{default:r}:{},...o?{description:o}:{}},d=(n.checks??[]).map(i=>T(i)),l=b(e);if(l)return{spec:{type:l,...t}};switch(n.type){case"string":{let i=n.format;return i==="email"?{spec:{type:"email",...t}}:i==="url"?{spec:{type:"url",...t}}:i==="date"?{spec:{type:"date",...t}}:i==="datetime"?{spec:{type:"datetime",...t}}:d.some(s=>s?.format==="regex"&&ie.test(String(s?.pattern?.source??"")))?{spec:{type:"date",...t}}:{spec:{type:"string",...t}}}case"number":{let i={};for(let s of d){let u=s?.value;typeof u=="number"&&(s?.check==="greater_than"&&s.inclusive?i.min=Math.max(i.min??u,u):s?.check==="less_than"&&s.inclusive?i.max=Math.min(i.max??u,u):s?.check==="multiple_of"&&(i.step=u))}return{spec:{type:d.some(s=>s?.format==="safeint"||s?.format==="int")?"integer":"number",...i,...t}}}case"boolean":return{spec:{type:"boolean",...t}};case"enum":{let i=Object.keys(n.entries??{});return i.length>0?{spec:{type:"enum",options:i,...t}}:{why:"it is an enum with no options"}}case"array":{let i=T(n.element),s=b(n.element)??(i?.type==="number"?"number":i?.type==="string"?"string":void 0);return s?{spec:{type:"list",of:s,...t}}:{why:`it is a list of ${String(i?.type??"something")}, and a document lists words, numbers, dates, images or files`}}default:return{why:`it is a ${String(n.type)}, which a document has no field type for`}}}function N(e){let n=se(e);return"spec"in n?n.spec:void 0}var M=e=>e.caption?.trim()||e.name;function de(e){let n=e?.fields?.shape??{};return Object.keys(n).filter(a=>{let r=v(n[a]);for(;r?.innerType;)r=v(r.innerType);return b(n[a])!==void 0||r?.type==="array"&&b(r.element)!==void 0})}function Fe(e,n){for(let a of de(n)){let r=k(e[a]).find(A);if(r)return r}}var S=e=>{try{return e()}catch{return null}},ne=e=>typeof e=="string"&&z.includes(e);function le(e){if(e!==void 0)return ne(e)?e:e&&typeof e=="object"&&typeof e.expr=="string"?{expr:S(()=>R(e.expr))}:"neutral"}var ue=4;function ye(e){let n=typeof e.list=="string"?S(()=>R(e.list)):null,a=e.sort,r=typeof a=="string"?a:a&&typeof a=="object"&&typeof a.by=="string"?a.by:void 0,o=a&&typeof a=="object"?a.direction:void 0,t=n,d;if(n&&r!==void 0)if(o==="choices")d=r;else{let p=S(()=>R(r));t=p?{t:"call",fn:"sort",args:[n,p,{t:"lit",value:o==="desc"?"desc":"asc",at:0}],at:0}:null}let l=typeof e.limit=="number"&&Number.isInteger(e.limit)&&e.limit>=1?Math.min(e.limit,G):void 0,i=e.group,s=typeof i=="string"?i:i&&typeof i=="object"&&typeof i.by=="string"?i.by:void 0,u=i&&typeof i=="object"&&i.headings&&typeof i.headings=="object"?i.headings:{};return{t:"list",source:t,...d?{choiceOrder:d}:{},...l?{limit:l}:{},...s?{group:{by:s,headings:Object.fromEntries(Object.entries(u).filter(p=>typeof p[1]=="string"))}}:{},...typeof e.empty=="string"?{empty:e.empty}:{},as:e.as==="card"?"card":"row"}}function J(e,n=1,a=""){if(!Array.isArray(e)||n>ue)return[];let r={};return e.flatMap(o=>{if(!o||typeof o!="object"||Array.isArray(o))return[];let t=o,d=f=>typeof f=="string"?S(()=>K(f)):null,l=f=>typeof f=="string"?S(()=>R(f)):null,i=le(t.tone),s=typeof t.label=="string"?t.label:void 0,u=f=>Object.hasOwn(t,f),p=typeof t.currency=="string"&&/^[A-Z]{3}$/.test(t.currency)?t.currency:void 0,y=u("list")?"list":u("headline")?"headline":typeof t.figure=="string"?"number":fe.find(u);if(!y)return[];let B=r[y]=(r[y]??0)+1,E=t.key,P=typeof E=="string"&&E?E:`${a}${y}.${B}`;return[{...(()=>{switch(y){case"list":return ye(t);case"number":{let f=X.includes(t.as)?t.as:void 0;return{t:y,value:l(t.figure),...f?{as:f}:{},...p?{currency:p}:{},...s?{label:d(s)}:{}}}case"headline":case"title":return{t:y,parts:d(t[y])};case"text":case"badge":return{t:y,parts:d(t[y]),...i?{tone:i}:{}};case"field":{let f=Z.includes(t.as)?t.as:void 0;return{t:y,field:String(t.field),...f?{as:f}:{},...p?{currency:p}:{},...s?{label:s}:{}}}case"image":return{t:y,field:String(t.image),as:t.as==="gallery"?"gallery":"thumb",...s?{label:s}:{}};case"progress":{let f=t.progress??{};return{t:y,value:l(f.value),max:l(f.max),...s?{label:d(s)}:{}}}case"group":return{t:y,blocks:J(t.group,n+1,`${P}.`),direction:t.direction==="row"?"row":"column"};case"when":return{t:y,when:l(t.when),show:J(t.show,n+1,`${P}.`)};default:return{t:y}}})(),key:P}]})}var fe=["title","text","badge","field","image","progress","group","when","divider","figure"],m="\u2014",pe=500;function h(e,n){if(!e)return{ok:!1,problem:"an expression that does not parse"};try{return{ok:!0,value:O(e,{graph:n.graph??W,subject:n.node,kinds:n.kinds,today:n.today,budget:n.budget??pe})}}catch(a){return{ok:!1,problem:a instanceof Error?a.message:String(a)}}}function w(e,n){if(!e)return{text:m,problem:"a template that does not parse"};let a,r=e.map(o=>{if(o.text!==void 0)return o.text;let t=h(o.expr??null,n);return t.ok?g(t.value,o.format,n.today,o.formatArgs,n.money):(a??=`{${o.source??""}}: ${t.problem}`,m)}).join("");return a?{text:r,problem:a}:{text:r}}function Y(e,n){if(e===void 0)return;if(typeof e=="string")return e;let a=h(e.expr,n);return a.ok&&ne(a.value)?a.value:"neutral"}function ce(e){if(typeof e=="string")try{let n=new URL(e);return n.protocol==="http:"||n.protocol==="https:"?n.href:void 0}catch{return}}function me(e,n,a,r,o){if(n==null||n==="")return m;if(typeof n=="boolean")return n?"yes":"no";if(r)return g(n,r,a.today,[],o?{...a.money,currency:o}:a.money);let t=a.fields[e];if(a.definition?.display?.format?.[e])return x(a.definition,e,n);if(t?.type==="date")return g(n,"date",a.today);if(t?.type==="enum"&&typeof n=="string")return x(a.definition,e,n);if(typeof n=="number")return n.toLocaleString("en-US");let d=k(n);return d[0]?d.map(M).join(", "):Array.isArray(n)?n.map(l=>String(l)).join(", "):typeof n=="object"?m:String(n)}function ge(e,n,a,r,o){return typeof e!="number"?String(e):n==="money"?H(e,a?{...o,currency:a}:o):n==="percent"?g(e,n,r):e.toLocaleString("en-US",{maximumFractionDigits:2})}var c=(e,n)=>n?{...e,problem:n}:e;function he(e,n,a){switch(e.t){case"title":{let r=w(e.parts,n);return c({t:"title",text:r.text},r.problem)}case"text":{let r=w(e.parts,n),o=Y(e.tone,n);return c({t:"text",text:r.text,...o?{tone:o}:{}},r.problem)}case"badge":{let r=w(e.parts,n);return c({t:"badge",text:r.text,tone:Y(e.tone,n)??"neutral"},r.problem)}case"field":{let r=e.label??F(n.definition,e.field);if(!n.node)return{t:"field",field:e.field,label:r,text:m,problem:`"${e.field}" names a field, and these blocks are about no one record`};let o=n.kinds.get(n.node.kind)?.computed?.has(e.field),t,d;if(o){let s=h({t:"ident",name:e.field,at:0},n);s.ok?t=s.value!==null&&typeof s.value=="object"?g(s.value,void 0,n.today):s.value:d=s.problem}else t=Object.hasOwn(n.node,e.field)?n.node[e.field]:void 0;let l=n.fields[e.field]?.type==="url"&&e.as===void 0?ce(t):void 0,i=S(()=>me(e.field,t,n,e.as,e.currency))??m;return c({t:"field",field:e.field,label:r,text:i,...l?{href:l}:{}},d)}case"image":{let r=k(n.node&&Object.hasOwn(n.node,e.field)?n.node[e.field]:null),o=e.as==="gallery"?r:r.filter(A).slice(0,1);return{t:"image",field:e.field,label:e.label??F(n.definition,e.field),as:e.as,files:o,text:o.map(M).join(", ")||m}}case"progress":{let r=h(e.value,n),o=h(e.max,n),t=e.label?w(e.label,n):{text:"Progress"},d=t.text,l=r.ok?o.ok?t.problem:o.problem:r.problem;return r.ok&&o.ok&&typeof r.value=="number"&&typeof o.value=="number"&&Number.isFinite(r.value)&&Number.isFinite(o.value)&&o.value>0?c({t:"progress",label:d,value:r.value,max:o.value,text:`${g(r.value,void 0,n.today)} of ${g(o.value,void 0,n.today)}`},l):c({t:"progress",label:d,text:m},l)}case"group":return{t:"group",direction:e.direction,blocks:Q(e.blocks,n)};case"when":{let r=h(e.when,n),o=r.ok&&r.value===!0;return c({t:"when",shown:o,blocks:o?Q(e.show,n):[]},r.ok?void 0:r.problem)}case"divider":return{t:"divider"};case"figure":return{t:"figure"};case"headline":{let r=w(e.parts,n),o=Math.min(6,Math.max(1,(a?n.firstHeading:void 0)??n.heading??3));return c({t:"headline",level:o,text:r.text},r.problem)}case"number":{let r=h(e.value,n),o=!r.ok||r.value===null||typeof r.value=="object"?m:ge(r.value,e.as,e.currency,n.today,n.money),t=e.label?w(e.label,n):void 0;return c({t:"number",text:o,...t?{label:t.text}:{}},r.ok?t?.problem:r.problem)}case"list":return we(e,n)}}function Q(e,n){let a=e.findIndex(r=>r.t==="headline");return e.map((r,o)=>({...he(r,n,o===a),key:r.key}))}var be=new Set(["every","some","sum","min","max","sort"]);function He(e,n){let a=new Set,r=new Set,o=i=>{if(i)switch(i.t){case"ident":a.add(i.name);return;case"list":i.items.forEach(o);return;case"member":return o(i.object);case"unary":return o(i.operand);case"binary":return o(i.left),o(i.right);case"where":return o(i.set);case"call":i.args.forEach((s,u)=>{u===1&&be.has(i.fn)||o(s)});return;default:return}},t=i=>{for(let s of i??[])o(s.expr)},d=(i,s)=>{i.forEach((u,p)=>{let y=s[p];if(y)switch(u.t){case"field":case"image":a.add(u.field);return;case"title":case"text":case"badge":case"headline":t(u.parts);return;case"number":o(u.value),t(u.label);return;case"progress":o(u.value),o(u.max);return;case"group":y.t==="group"&&d(u.blocks,y.blocks);return;case"when":y.t==="when"&&y.shown&&d(u.show,y.blocks);return;case"list":if(y.t==="list")for(let B of y.members)r.add(B.id);return;default:return}})};d(e,n);let l=n[0];return{fields:a,records:r,...e[0]?.t==="title"&&l?.t==="title"?{title:l.text}:{}}}function we(e,n){let a=Math.min(6,(n.heading??3)+1),r=h(e.source,n);if(!r.ok)return{t:"list",as:e.as,failed:!0,members:[],headingLevel:a,more:0,problem:r.problem};let o=r.value,t=o instanceof j?o.nodes:o!==null&&typeof o=="object"&&!Array.isArray(o)?[o]:[];e.choiceOrder&&n.schema&&(t=Se(t,e.choiceOrder,n.schema));let d=t.length;t=t.slice(0,e.limit??G);let l=e.limit===void 0?d-t.length:0;return{t:"list",as:e.as,failed:!1,members:t,...e.group&&n.schema&&t.length>0?{groups:ke(t,e.group,n.schema)}:{},headingLevel:a,...t.length===0&&e.empty?{empty:e.empty}:{},more:l}}function re(e,n,a){let r=e.tryDefinition(n)?.fields?.shape,o=r&&Object.hasOwn(r,a)?N(r[a]):void 0;return o?.type==="enum"?o.options??[]:[]}var V=(e,n)=>Object.hasOwn(e,n)?e[n]:void 0;function Se(e,n,a){let r=o=>{let t=re(a,o.kind,n).indexOf(String(V(o,n)));return t<0?Number.MAX_SAFE_INTEGER:t};return e.map((o,t)=>({node:o,i:t,rank:r(o)})).sort((o,t)=>o.rank-t.rank||o.i-t.i).map(o=>o.node)}function ke(e,n,a){let r=[];for(let d of e)for(let l of re(a,d.kind,n.by))r.includes(l)||r.push(l);let o=[];for(let d of r){let l=e.filter(s=>V(s,n.by)===d);if(l.length===0)continue;let i=a.tryDefinition(l[0].kind);o.push({value:d,heading:n.headings[d]??L(x(i,n.by,d)),members:l})}let t=e.filter(d=>!r.includes(String(V(d,n.by))));return t.length>0&&o.push({value:null,members:t}),o}function ee(e){return e.t==="list"||e.t==="headline"||e.t==="number"||e.t==="image"&&e.as==="gallery"?!0:e.t==="group"?e.blocks.some(ee):e.t==="when"?e.show.some(ee):!1}function te(e,n){let a=e.tryDefinition(n)?.fields?.shape??{},r={};for(let[o,t]of Object.entries(a)){let d=N(t);d&&(r[o]=d)}return r}var oe=new WeakMap;function C(e){let n=oe.get(e);return n||oe.set(e,n=q(e)),n}function Re(e,n,a,r={}){let o=C(e),t={},d={},l=i=>{if(i instanceof j)return i.nodes.map(s=>l(s));if(Array.isArray(i))return i.map(s=>l(s));if(i!==null&&typeof i=="object"){let s=i;return{id:s.id,kind:s.kind,label:D(e.tryDefinition(s.kind),s)}}return i};for(let[i,s]of o.get(a?a.kind:$)?.computed??[])try{t[i]=l(O(s,{graph:n,subject:a,kinds:o,...r.today?{today:r.today}:{},...r.budget?{budget:r.budget}:{}}))}catch(u){if(!(u instanceof U))throw u;d[i]=u.sentence}return{values:t,refused:d}}function qe(e,n,a){let{values:r}=Re(e,n,a);if(Object.keys(r).length===0)return a;let o=t=>Array.isArray(t)?t.map(o):t!==null&&typeof t=="object"?t.label:t;return{...a,...Object.fromEntries(Object.entries(r).map(([t,d])=>[t,o(d)]))}}var Ae=500,xe=2e4,ae=new WeakMap;function je(e,n){let a=ae.get(e);a||ae.set(e,a=new Map);let r=a.get(n);return r||a.set(n,r=te(e,n)),r}function nn(e,n,a,r={}){if(n&&typeof e.seenBy!="function")throw new TypeError("blockContextFor: a seat is read from a store (its `seenBy`); a bare { graph, schema } is read as it is handed, with no principal");let o=n?e.seenBy(n):e,t=n&&a?o.graph.getNode(a.id)??null:a,d=o.schema,l=t&&d.tryDefinition(t.kind),i=!t||(r.slot??"page")==="page",{money:s,firstHeading:u}=r;return{node:t,graph:o.graph,schema:d,kinds:C(d),fields:t?je(d,t.kind):{},definition:l||void 0,today:r.today??o.today?.()??I(),money:s,heading:r.heading??(i?2:3),firstHeading:u,budget:r.budget??(i?xe:Ae)}}export{N as a,M as b,de as c,Fe as d,J as e,Q as f,He as g,ee as h,Re as i,qe as j,nn as k};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{d as te,e as ne,f as ie,g as oe}from"./chunk.7THQFY52.js";import{a as Q}from"./chunk.G4JJXA63.js";import{j as X,n as J,o as ee}from"./chunk.FS5K4AVA.js";import"./chunk.DY2FFBWF.js";import"./chunk.MNPNW4BQ.js";import"./chunk.I5KD54S6.js";import"./chunk.EVTZE2OZ.js";import"./chunk.NQNQPPPM.js";import"./chunk.ZMMMKTAG.js";import"./chunk.IZDKEFPJ.js";import"./chunk.XDHBV5K5.js";import{a as G}from"./chunk.TMPV4HLQ.js";import{a as q,d as B}from"./chunk.7QTBDACG.js";import"./chunk.5BN2ARQ2.js";import"./chunk.4W24TPMR.js";import"./chunk.AHDOKM4O.js";import"./chunk.6R4EI47C.js";import"./chunk.QZWN46V6.js";import{d as Z}from"./chunk.6LJ66MB7.js";import{V as U,da as C,i as F,l as _,q as Y,ra as V}from"./chunk.OYULDOQP.js";import{P as j,U as P,V as T,Z as N,_ as W,cb as z}from"./chunk.VMEX2KZ4.js";import{a as he,b as K}from"./chunk.MRK6QJV5.js";import{b as O}from"./chunk.AJZBJBMO.js";var M=3;function re(e,n){return n.id?e.graph.getNode(n.id):void 0}function ae(e){return e?/^(?:kind|aggregate):([^:]+)$/.exec(e)?.[1]:void 0}function le(e,n){if(n)return e.find(t=>t.nodeIds.includes(n)||t.subjectId===n)}var ye=e=>{let n=e.trim();if(!n)return n;let t=n.charAt(0).toUpperCase()+n.slice(1);return/[.!?…]$/.test(t)?t:`${t}.`};function de({store:e,subject:n,violations:t,place:i}){let r=re(e,n),o=le(t,r?.id??null);if(o)return ye(o.message);if(r){let l=r.kind;return`${j(e.schema.tryDefinition(l),r)}, ${N(W(e.schema.tryDefinition(l),l))}.`}let c=i?.kind??ae(n.id);if(c){let l=e.graph.nodesOfKind(c).length,g=i?.title??n.name,u=T(e.schema,c),f=P(e.schema,c,l);return g.toLowerCase()===u.toLowerCase()?`${l===1?"There is":"There are"} ${f} here.`:`${g}: ${f}.`}let a=e.schema.kinds.map(l=>({kind:l,count:e.graph.nodesOfKind(l).length})).filter(l=>l.count>0).sort((l,g)=>g.count-l.count).slice(0,3);if(a.length===0)return"Nothing here yet.";let s=a.map(l=>P(e.schema,l.kind,l.count));return`The whole thing: ${s.length===1?s[0]:`${s.slice(0,-1).join(", ")} and ${s[s.length-1]}`}.`}function ce(e){let{store:n,subject:t,violations:i}=e,r=re(n,t),o=[];r&&le(i,r.id)?o.push({ask:`What's wrong with ${t.name}?`,why:"problem"}):i.length>0&&o.push({ask:"What needs attention?",why:"problem"});let c=r?r.kind:e.place?.kind??ae(t.id),a=ve(e,c);if(a)o.push(a);else{let l=ke(e,c);l&&o.push(l)}let s=be(e,c);return s&&o.push(s),o.length<M&&(r?o.push({ask:`Tell me about ${t.name}`,why:"about"}):o.push({ask:"What is here?",why:"here"})),o.slice(0,M)}function ue(e,n){return e.schema.tryDefinition(n)?.fields?.shape??{}}function me(e){let n=e;for(let t=0;t<4&&n;t++){let i=n;if(Array.isArray(i.options)&&i.options.every(r=>typeof r=="string"))return i.options;n=typeof i.unwrap=="function"?i.unwrap():i._def?.innerType}}var se=/^\d{4}-\d{2}-\d{2}/,Se=["due","deadline","date","when"];function ve(e,n){let{store:t}=e,i=e.today;if(!i||!se.test(i))return;let r=new Date(`${i.slice(0,10)}T00:00:00Z`);r.setUTCDate(r.getUTCDate()+6);let o=r.toISOString().slice(0,10),c=[...new Set([...n?[n]:[],...t.schema.kinds])];for(let a of c){let s=Se.find(u=>u in ue(t,a));if(!s||!t.graph.nodesOfKind(a).some(u=>{let f=u[s],S=u.done;return typeof f=="string"&&se.test(f)&&f.slice(0,10)>=i.slice(0,10)&&f.slice(0,10)<=o&&S!==!0}))continue;let g=T(t.schema,a);return{ask:`${Q(g)} due this week`,why:"due"}}}function ke(e,n){let t=e.place?.title,i=(e.places??[]).find(r=>r.kind!==null&&r.picture===!0&&r.title!==t&&r.kind!==n);return i?{ask:`Go to ${i.title}`,why:"go"}:void 0}function be(e,n){let{store:t}=e,i=[...t.schema.kinds].sort((o,c)=>t.graph.nodesOfKind(c).length-t.graph.nodesOfKind(o).length),r=[...new Set([...n?[n]:[],...i])];for(let o of r){if(t.graph.nodesOfKind(o).length<2)continue;let c=ue(t,o),a=Object.keys(c).find(g=>(me(c[g])?.length??0)>=2);if(!a)continue;let s=T(t.schema,o).toLowerCase(),l=a.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").toLowerCase();return{ask:`Show ${s} as a board by ${l}`,why:"draw"}}}function pe(e,{store:n,subject:t}){let i=a=>t.id!==null&&(a.nodeIds.includes(t.id)||Object.values(a.args).includes(t.id)),r=e.filter(a=>a.provider==="invariant"&&i(a)),o=e.filter(a=>a.pinned==="user"&&!r.includes(a));return[...r,...o].sort((a,s)=>Number(a.destructive??!1)-Number(s.destructive??!1)).slice(0,M).map(a=>({affordance:a,label:Ae(a,{store:n,subject:t})}))}var we=e=>/^[a-z0-9]+(?:[-_][a-z0-9]+)+$|^[a-z]+[A-Z][A-Za-z0-9]*$/.test(e);function Ae(e,{store:n,subject:t}){let i=e.label,r=we(i)||i===e.mutation;if(r){let s=i.replace(/([a-z0-9])([A-Z])/g,"$1 $2").replace(/[_-]+/g," ").toLowerCase();i=s.charAt(0).toUpperCase()+s.slice(1)}let o=t.id?n.graph.getNode(t.id):void 0,c=o!==void 0&&e.nodeIds.length<=1&&(e.nodeIds[0]??o.id)===o.id;if(c&&/\bit\b/.test(i))return i.replace(/\bit\b/,t.name);let a=n.allMutations().find(s=>s.name===e.mutation);if(e.open.length===0&&a?.describe&&(r||c))try{let s=a.describe(e.args,n.graph);if(s.trim())return s.trim()}catch{}return i}var y=O(he(),1);var p=O(K(),1);function ze({phone:e,side:n,name:t,onClose:i,respond:r,onCall:o,onPick:c,onMove:a,place:s,onDraft:l}){let{seatTalk:g}=C(),u=U(g),f=xe(c),S=[...u.turns].reverse().find(h=>h.role==="seat"),m=e&&u.draft!==null,b=(0,y.useRef)(null),w=(0,y.useRef)(!0);return(0,y.useLayoutEffect)(()=>{let h=b.current;if(!h)return;let A=m?[...h.querySelectorAll("ol > li")].pop():void 0;if(A){let v=A.getBoundingClientRect().top-h.getBoundingClientRect().top+h.scrollTop;h.style.maxHeight=`min(${Math.ceil(h.scrollHeight-v)}px, ${ge})`}let k=w.current?fe.get(g):void 0;w.current=!1,h.scrollTop=k&&k.turns===u.turns.length&&!u.busy?k.top:h.scrollHeight},[u.turns.length,u.busy,m]),(0,p.jsxs)("div",{"data-testid":"seat-panel",...m?{"data-graview-seat-yields":""}:{},style:{display:"grid",gridTemplateRows:"auto minmax(0, 1fr)",gap:4,minHeight:0},children:[(0,p.jsxs)("div",{"data-testid":"seat-top",...e?{onPointerDown:h=>Ce(h,i)}:{},style:{display:"flex",alignItems:"center",justifyContent:e?"center":"flex-end",gap:2,position:"relative",minHeight:28,...e?{touchAction:"none"}:{}},children:[e?(0,p.jsx)("button",{type:"button","data-testid":"seat-grab","aria-label":`Close Ask ${t}`,title:"Close",onClick:i,style:{...E,width:64},children:(0,p.jsx)("span",{"aria-hidden":"true",style:{display:"block",width:36,height:4,margin:"0 auto",borderRadius:2,background:"var(--graview-edge-strong, var(--graview-ink-faint))"}})}):(0,p.jsx)("button",{type:"button","data-testid":"seat-side","aria-label":n==="left"?"Move to the right":"Move to the left",title:n==="left"?"Move to the right":"Move to the left",onClick:()=>g.setSide(n==="left"?"right":"left"),style:E,children:(0,p.jsx)("span",{"aria-hidden":"true",children:"\u21C4"})}),(0,p.jsx)("button",{type:"button","data-testid":"seat-close","aria-label":`Close Ask ${t}`,title:"Close",onClick:i,style:e?{...E,position:"absolute",top:0,right:0}:E,children:(0,p.jsx)("span",{"aria-hidden":"true",children:"\u2715"})})]}),(0,p.jsx)("div",{ref:b,"data-testid":"seat-body",onScroll:h=>void fe.set(g,{top:h.currentTarget.scrollTop,turns:u.turns.length}),style:{minHeight:0,maxHeight:m?ge:e?"calc(70cqh - 96px)":"min(520px, calc(100cqh - 112px))",overflowY:"auto",overflowX:"hidden",padding:"0 4px"},children:(0,p.jsx)(ne,{shared:!0,composer:!1,testId:"seat",onPick:f,...a?{onMove:a}:{},...s?{place:s}:{},...l?{onDraft:l}:{},empty:(0,p.jsx)(Te,{...s?{here:s}:{}}),...r?{respond:r}:{},...o?{onCall:o}:{}})}),(0,p.jsx)("p",{"aria-live":"polite","data-testid":"seat-said",style:Z,children:u.busy?"":S?.text??""})]})}function xe(e){let{setView:n}=C();return(0,y.useCallback)(t=>e?e(t):n(i=>Y(F(_(i,!1),t),[t])),[e,n])}function Te({here:e}){let{store:n,views:t,view:i,seatTalk:r}=C(),o=te({hover:!1}),c=q(n,V()),a=(0,y.useMemo)(()=>c.map(d=>d.line?{...d,message:B(d)}:d),[c]),s=o.id?n.graph.getNode(o.id):void 0,l=e??i.within?.view,g=o.because==="place"&&o.id===null?t.places().find(d=>d.title===o.name):l?t.places().find(d=>d.as===l):void 0,u=n.today(),f={store:n,subject:{id:o.id,name:o.name},violations:a,place:g?{title:g.title,kind:g.kind}:null,places:t.places().map(d=>({title:d.title,kind:d.kind,picture:!0})),...u?{today:u}:{}},S=de(f),m=ce(f),b=(0,y.useMemo)(()=>({pins:X(),...s?{focus:s.id,about:[s.id]}:{}}),[s?.id]),{affordances:w}=J(b),h=s?pe(w,{store:n,subject:{id:o.id,name:o.name}}):[],{apply:A,preview:k}=ee(),[v,$]=(0,y.useState)(null),[D,R]=(0,y.useState)(null),H=(d,x)=>{try{return k(d,x),A(d,x),R(null),!0}catch(I){return R(z(n.schema,n.allMutations(),I)),!1}};return(0,p.jsxs)("div",{"data-testid":"seat-here",style:{display:"grid",gap:10,padding:"2px 2px 6px"},children:[(0,p.jsx)("p",{"data-testid":"seat-where",style:{margin:0,fontSize:"0.9375rem",lineHeight:1.45,color:"var(--graview-ink)"},children:S}),h.length>0?(0,p.jsx)("ul",{"aria-label":"What you can do",style:{margin:0,padding:0,listStyle:"none",display:"flex",flexWrap:"wrap",gap:6},children:h.map(({affordance:d,label:x})=>(0,p.jsx)("li",{children:(0,p.jsx)("button",{type:"button","data-testid":"seat-act","data-affordance":d.id,"aria-pressed":v?.id===d.id,title:d.why,onClick:()=>d.open.length>0?$(I=>I?.id===d.id?null:d):void H(d),style:{...ie,minHeight:30,textAlign:"start",...d.destructive?{color:"var(--graview-warn)"}:{}},children:x})},d.id))}):null,v?(0,p.jsx)(G,{affordance:v,onApply:d=>{H(v,d)&&$(null)},onCancel:()=>$(null)}):null,D?(0,p.jsx)("p",{"data-testid":"seat-refused",style:{margin:0,fontSize:"0.8125rem",color:"var(--graview-warn)"},children:D}):null,m.length>0?(0,p.jsx)("ul",{"aria-label":"Things to ask",style:{margin:0,padding:0,listStyle:"none",display:"grid",gap:2,justifyItems:"start"},children:m.map(d=>(0,p.jsx)("li",{children:(0,p.jsx)("button",{type:"button","data-testid":"seat-suggestion","data-graview-why":d.why,onClick:()=>r.ask(d.ask),style:oe,children:d.ask})},d.ask))}):null]})}var ge="min(5.5em, 22cqh)",fe=new WeakMap,L={far:64,flick:.5,least:16,tap:6};function Ce(e,n){if(e.button!==0)return;let t=e.currentTarget,i=t.closest('[data-testid="seat"]');if(!i)return;let r=e.pointerId,o=e.clientY,c={y:o,at:e.timeStamp},a=0,s=0;try{t.setPointerCapture(r)}catch{}let l=u=>{if(u.pointerId!==r)return;s=Math.max(0,u.clientY-o);let f=u.timeStamp-c.at;f>0&&(a=(u.clientY-c.y)/f),c={y:u.clientY,at:u.timeStamp},i.style.transition="none",i.style.transform=s>0?`translateY(${s}px)`:""},g=u=>{if(u.pointerId!==r)return;t.removeEventListener("pointermove",l),t.removeEventListener("pointerup",g),t.removeEventListener("pointercancel",g);let f=u.type==="pointerup"&&(s>=L.far||s>=L.least&&a>=L.flick);if(i.style.transition=f?"":"transform 160ms ease-out",i.style.transform="",s>L.tap){let S=m=>{m.preventDefault(),m.stopPropagation()};t.addEventListener("click",S,{capture:!0,once:!0}),setTimeout(()=>t.removeEventListener("click",S,{capture:!0}),0)}f&&n()};t.addEventListener("pointermove",l),t.addEventListener("pointerup",g),t.addEventListener("pointercancel",g)}var E={display:"inline-grid",placeItems:"center",width:28,height:28,padding:0,font:"inherit",fontSize:"0.875rem",lineHeight:1,color:"var(--graview-ink-muted)",background:"transparent",border:"1px solid transparent",borderRadius:6,boxShadow:"none",cursor:"pointer"};export{ze as SeatPanel,xe as useSeatGo};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{A as l,H as p,O as k,P as y,c}from"./chunk.TX2GOL65.js";import"./chunk.T2EZ5MTH.js";import"./chunk.ONDILMIX.js";import{b as m}from"./chunk.AS35X6KA.js";import"./chunk.KAKX5TZN.js";import"./chunk.VFICMX5G.js";import"./chunk.IKT7JQUW.js";import"./chunk.CW7BMVBG.js";import"./chunk.IZDKEFPJ.js";import"./chunk.XDHBV5K5.js";import"./chunk.WVUJXDXZ.js";import"./chunk.UMMN5Z6V.js";import"./chunk.DG2WKNMX.js";import"./chunk.HPD3DSTP.js";import"./chunk.VD6FJ6KJ.js";import"./chunk.OHGJ5BZ4.js";import"./chunk.7QTBDACG.js";import"./chunk.5BN2ARQ2.js";import"./chunk.4W24TPMR.js";import"./chunk.AHDOKM4O.js";import"./chunk.6R4EI47C.js";import"./chunk.LHAAZQNQ.js";import"./chunk.PHY3AH3L.js";import"./chunk.QZWN46V6.js";import"./chunk.6LJ66MB7.js";import{T as s,V as d,ea as g}from"./chunk.OYULDOQP.js";import"./chunk.VMEX2KZ4.js";import{a as S,b as f}from"./chunk.MRK6QJV5.js";import{b as n}from"./chunk.AJZBJBMO.js";var u=n(S(),1);var t=n(f(),1);function D({context:a}){let r=l(),h=g(),[w]=(0,u.useState)(()=>s(null)),o=d(h?.seatTalk??w),P=()=>{(window.history.state?.idx??0)>0?r(-1):r("/")};return(0,t.jsxs)(k,{context:a,"data-testid":"draft-page",children:[(0,t.jsx)(y,{context:a,...o.draft?{"data-testid":"draft-title"}:{},children:o.draft?o.draft.title:"Nothing drawn"}),o.draft?(0,t.jsx)(m,{page:!0,go:e=>r(e.address),onPick:e=>{let i=a.store.graph.getNode(e);i&&r(c(a.store.schema,i.kind,e))},onDiscard:P}):(0,t.jsxs)("p",{style:{margin:0,color:"var(--graview-ink-muted)"},children:["Ask for a way of seeing \u2014 \u201Ca board of tasks by status\u201D \u2014 and it is drawn here."," ",(0,t.jsx)(p,{to:"/",style:{color:"var(--graview-accent)"},children:"Home \u2192"})]})]})}export{D as DraftPage};
|
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import{f as O,k as b}from"./chunk.OHGJ5BZ4.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
|
-
`||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};
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import{Fb as e}from"./chunk.VMEX2KZ4.js";var a=`
|
|
2
|
-
.graview-spec { display: flex; flex-direction: column; gap: 6px; min-width: 0; color: var(--graview-ink); }
|
|
3
|
-
|
|
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; }
|
|
5
|
-
.graview-spec-row[data-selected] { border-color: var(--graview-accent); }
|
|
6
|
-
.graview-spec-row > * { flex: 0 0 auto; min-width: 0; max-width: 100%; }
|
|
7
|
-
.graview-spec-row > .graview-spec-title, .graview-spec-row > .graview-spec-text { flex: 1 1 9rem; overflow-wrap: anywhere; }
|
|
8
|
-
.graview-spec-row > .graview-spec-title { font-size: 0.9375rem; }
|
|
9
|
-
.graview-spec-row > .graview-spec-progress { grid-template-columns: auto minmax(3rem, 5rem) auto; align-items: center; column-gap: 6px; }
|
|
10
|
-
.graview-spec-list[data-as="row"] .graview-spec-row { border-width: 0 0 1px; border-radius: 0; background: transparent; padding: 6px 2px; }
|
|
11
|
-
[data-graview-rows] .graview-spec-row { border-width: 0; border-radius: 0; background: transparent; padding: 2px 0; }
|
|
12
|
-
[data-graview-rows] .graview-spec-row > .graview-spec-title { font-size: 1.0625rem; font-weight: 600; }
|
|
13
|
-
.graview-spec-page { padding-bottom: 14px; margin-bottom: 14px; border-bottom: 1px solid var(--graview-edge); }
|
|
14
|
-
.graview-spec-title { font-family: var(--graview-font-display, inherit); font-weight: 600; font-size: 1rem; line-height: 1.3; overflow-wrap: anywhere; }
|
|
15
|
-
.graview-spec-text { margin: 0; font-size: 0.875rem; line-height: 1.45; overflow-wrap: anywhere; }
|
|
16
|
-
.graview-spec-text[data-graview-tone] { color: var(--graview-spec-tone); }
|
|
17
|
-
|
|
18
|
-
.graview-spec-badge { align-self: flex-start; display: inline-block; max-width: 100%; box-sizing: border-box; padding: 1px 8px; border: 1px solid currentColor; border-radius: 999px; background: var(--graview-panel); color: var(--graview-spec-tone, var(--graview-ink-muted)); font-size: 0.8125rem; font-weight: 600; line-height: 1.5; overflow-wrap: anywhere; }
|
|
19
|
-
.graview-spec-row .graview-spec-badge, .graview-spec-group[data-direction="row"] .graview-spec-badge { align-self: center; }
|
|
20
|
-
.graview-spec [data-graview-tone="good"] { --graview-spec-tone: var(--graview-good); }
|
|
21
|
-
.graview-spec [data-graview-tone="bad"] { --graview-spec-tone: var(--graview-bad); }
|
|
22
|
-
.graview-spec [data-graview-tone="warn"] { --graview-spec-tone: var(--graview-warn); }
|
|
23
|
-
.graview-spec [data-graview-tone="accent"] { --graview-spec-tone: var(--graview-accent); }
|
|
24
|
-
.graview-spec [data-graview-tone="neutral"] { --graview-spec-tone: var(--graview-ink-muted); }
|
|
25
|
-
.graview-spec-field { display: flex; flex-wrap: wrap; gap: 2px 8px; align-items: baseline; min-width: 0; font-size: 0.875rem; line-height: 1.4; }
|
|
26
|
-
.graview-spec-label { color: var(--graview-ink-muted); }
|
|
27
|
-
.graview-spec-value { min-width: 0; color: var(--graview-ink); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
|
|
28
|
-
.graview-spec-link { position: relative; z-index: ${e.raised}; color: var(--graview-accent); text-decoration: underline; }
|
|
29
|
-
.graview-spec-progress { display: grid; gap: 4px; font-size: 0.8125rem; }
|
|
30
|
-
.graview-spec-progress > .graview-spec-label, .graview-spec-progress > .graview-spec-value { white-space: nowrap; }
|
|
31
|
-
.graview-spec-track { display: block; height: 6px; border-radius: 999px; background: var(--graview-edge); overflow: hidden; }
|
|
32
|
-
.graview-spec-fill { display: block; height: 100%; background: var(--graview-accent); }
|
|
33
|
-
.graview-spec-group { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
|
|
34
|
-
.graview-spec-group[data-direction="row"] { flex-direction: row; flex-wrap: wrap; align-items: center; gap: 6px 10px; }
|
|
35
|
-
.graview-spec-row .graview-spec-group { flex: 1 1 9rem; }
|
|
36
|
-
.graview-spec-divider { width: 100%; margin: 2px 0; border: 0; border-top: 1px solid var(--graview-edge); }
|
|
37
|
-
.graview-spec-figure { display: inline-flex; width: 22px; height: 22px; }
|
|
38
|
-
.graview-spec-row[data-graview-tall] { flex-direction: column; flex-wrap: nowrap; align-items: stretch; border-radius: 10px; padding: 8px 12px; }
|
|
39
|
-
.graview-spec-row[data-graview-tall] .graview-spec-badge { align-self: flex-start; }
|
|
40
|
-
.graview-spec-home, .graview-spec-place { gap: 14px; }
|
|
41
|
-
.graview-spec-headline { margin: 0; font-family: var(--graview-font-display, inherit); font-weight: 600; letter-spacing: -0.01em; line-height: 1.15; overflow-wrap: anywhere; font-size: 1.125rem; }
|
|
42
|
-
.graview-spec-headline[data-level="1"] { font-size: clamp(1.75rem, 5vw, 2.75rem); line-height: 1.05; text-wrap: balance; }
|
|
43
|
-
.graview-spec-headline[data-level="2"] { font-size: clamp(1.25rem, 3vw, 1.625rem); margin-top: 8px; }
|
|
44
|
-
.graview-spec-number { display: grid; gap: 2px; justify-items: start; }
|
|
45
|
-
.graview-spec-number-value { font-family: var(--graview-font-display, inherit); font-weight: 600; font-size: 1.75rem; line-height: 1.05; letter-spacing: -0.015em; font-variant-numeric: tabular-nums; }
|
|
46
|
-
.graview-spec-card .graview-spec-number-value, .graview-spec-row .graview-spec-number-value { font-size: 1.25rem; }
|
|
47
|
-
.graview-spec-number .graview-spec-label { font-size: 0.8125rem; }
|
|
48
|
-
.graview-spec-listing { display: grid; gap: 10px; min-width: 0; position: relative; z-index: ${e.raised}; }
|
|
49
|
-
.graview-spec-list-group { display: grid; gap: 8px; min-width: 0; }
|
|
50
|
-
.graview-spec-list-heading { margin: 6px 0 0; font-family: var(--graview-font-display, inherit); font-size: 1rem; font-weight: 600; padding-bottom: 4px; border-bottom: 1px solid var(--graview-edge-bright, var(--graview-edge)); }
|
|
51
|
-
.graview-spec-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 6px; min-width: 0; }
|
|
52
|
-
.graview-spec-list[data-as="card"] { grid-template-columns: repeat(auto-fill, minmax(min(100%, 15rem), 1fr)); gap: 10px; }
|
|
53
|
-
.graview-spec-list[data-as="names"] { display: flex; flex-wrap: wrap; gap: 4px 12px; }
|
|
54
|
-
.graview-spec-item { position: relative; min-width: 0; }
|
|
55
|
-
.graview-spec-item-name { font-size: 0.875rem; font-weight: 600; }
|
|
56
|
-
.graview-spec-item-link { all: unset; position: absolute; inset: 0; min-height: 24px; border-radius: 10px; cursor: pointer; }
|
|
57
|
-
.graview-spec-item-link:hover { background: color-mix(in srgb, var(--graview-accent) 6%, transparent); }
|
|
58
|
-
.graview-spec-item-link:focus-visible { outline: 2px solid var(--graview-accent); outline-offset: 2px; }
|
|
59
|
-
.graview-spec-item .graview-spec-listing { z-index: ${e.raised}; }
|
|
60
|
-
.graview-spec-empty, .graview-spec-more { color: var(--graview-ink-muted); }
|
|
61
|
-
`;export{a};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{a as lt}from"./chunk.HPD3DSTP.js";import{f as it}from"./chunk.VD6FJ6KJ.js";import{a as M,e as q,n as st}from"./chunk.OHGJ5BZ4.js";import{D as Y,E as Q,F as G,Mb as at,Oa as ot,P as T,S as V,V as X,Y as k,_ as tt,fa as nt,ga as et,ja as rt}from"./chunk.VMEX2KZ4.js";import"./chunk.AJZBJBMO.js";function _(t){let e=[],n=!0;for(let r of t){if(r.text.length===0)continue;let a=r.as==="close"||r.text===","||r.text===":"||r.text.startsWith("'")||n;e.push({part:r,space:!a}),n=r.as==="open"}return e}function F(t,e){return _(t).map(({part:n,space:r})=>`${r?" ":""}${e?n.said??n.text:n.text}`).join("")}function xt(t){return F(t,!1)}function bt(t){return F(t,!0)}function ut(t,e=!1){let n=e?t.said:t.text;return t.record!==void 0?`${t.record} \u2014 ${n}`:n}function J(t){let e=u=>_(u).map(({part:o,space:s})=>({...o,space:s})),n=e(t.parts),r=t.when&&t.when.length>0?e(t.when):void 0,a=u=>`${F(n,u)}${r?`, when ${F(r,u)}`:""}`;return{...t,parts:n,...r?{when:r}:{},text:a(!1),said:a(!0)}}function Rt(t,e=!1){return t.line?ut(t.line,e):t.message}var ft=60,L=t=>({text:t,as:"name"}),d=(t,e)=>e===void 0?{text:t,as:"word"}:{text:t,as:"word",said:e},P=(t,e)=>e===void 0||e===t?{text:t,as:"value"}:{text:t,as:"value",said:e},b=(t,e)=>({text:t,as:"op",said:e}),R={text:"(",as:"open"},w={text:")",as:"close"},N={text:"\u2014",as:"value",said:"empty"},K={">=":["\u2265","at least"],"<=":["\u2264","at most"],"<":["<","less than"],">":[">","more than"],"==":["=","is"],"!=":["\u2260","is not"]},z={">=":"<","<=":">","<":">=",">":"<=","==":"!=","!=":"=="},wt={"+":["+","plus"],"-":["\u2212","minus"],"*":["\xD7","times"],"/":["\xF7","divided by"],"%":["mod","modulo"]},dt=t=>t.t==="binary"&&t.op in K;function D(t){return t.length>1&&t[1]===t[1].toUpperCase()&&/[A-Z]/.test(t[1])?t:t.charAt(0).toLowerCase()+t.slice(1)}function pt(t){let{schema:e}=t,n=i=>i===null?void 0:e.tryDefinition(i),r=(i,c)=>{let y=n(i)?.edges;return y&&Object.hasOwn(y,c)?y[c]:void 0},a=(i,c)=>{let y=r(i,c)?.to;return Array.isArray(y)&&y.length===1?y[0]:null},u=(i,c)=>{let y=(e.edge(c)?.from??[]).filter(A=>{let $=r(A,c)?.to;return i===null||$==="*"||Array.isArray($)&&$.includes(i)});return y.length===1?y[0]:null},o=(i,c)=>r(i,c)?V(c).toLowerCase():D(k(n(i),c)),s=i=>D(X(e,i)),p=i=>D(it(e).get(i)?.label??V(i)),x=i=>D(tt(n(i),i)),l=(i,c)=>{let y=i===null?void 0:t.formatOf?.(i,c);if(y?.format)return y;let A=t.said?.get(c);return A?{...y,format:A}:y},m=i=>T(e.tryDefinition(i.kind),i),g=(i,c)=>{if(i==null)return N;if(i instanceof M){if(i.nodes.length===0)return N;let v=i.nodes.slice(0,3).map(m),H=i.nodes.length-v.length;return P(H>0?`${v.join(", ")} and ${H} more`:v.length>1?`${v.slice(0,-1).join(", ")} and ${v[v.length-1]}`:v[0])}if(Array.isArray(i))return P(`{${i.map(v=>g(v,c).text).join(", ")}}`,i.map(v=>g(v,c).text).join(" or "));if(typeof i=="object")return P(m(i));if(typeof i=="boolean")return P(i?"yes":"no");let y=c?.format??(c?l(c.kind,c.key):void 0);if(typeof i=="number"){if(y?.format==="money")return P(st(i,{...t.money,...y.unit&&/^[A-Z]{3}$/.test(y.unit)?{currency:y.unit}:{}}));if(y?.format==="percent")return P(`${Math.round(i*100)}%`);let v=i.toLocaleString("en-US",{maximumFractionDigits:2});return P(y?.unit&&!/^[A-Z]{3}$/.test(y.unit)?`${v} ${y.unit}`:v)}if(Y.test(i)||y?.format==="date")return P(G(i.slice(0,10)));let A=c&&c.kind!==null?n(c.kind)?.display?.format?.[c.key]:void 0;if(A)return P(A(i));let $=i.length>ft?`${i.slice(0,ft-1).trimEnd()}\u2026`:i;return P(/^[a-z][a-z0-9]*([-_][a-z0-9]+)*$/.test($)?$.replace(/[-_]+/g," "):$)};return{definition:n,relation:r,farOf:a,nearOf:u,fieldName:o,plural:s,noun:x,factName:p,formatOf:l,valueWords:g}}function E(t,e,n){if(t.t==="ident")return{kind:e,key:t.name};if(t.t==="member")return{kind:O(t.object,e,n),key:t.name};if(t.t==="call"&&(t.fn==="sum"||t.fn==="min"||t.fn==="max")&&t.args.length===2){let r=O(t.args[0],e,n),a=t.args[1];if(a.t==="ident")return{kind:r,key:a.name};if(a.t==="lit"&&typeof a.value=="string")return{kind:r,key:a.value}}if(t.t==="binary"&&(t.op==="+"||t.op==="-"))return E(t.left,e,n)??E(t.right,e,n);if(t.t==="call"&&t.fn==="if"&&t.args.length===3)return E(t.args[1],e,n)??E(t.args[2],e,n)}function O(t,e,n){switch(t.t){case"ident":return n.relation(e,t.name)?n.farOf(e,t.name):null;case"member":return n.farOf(O(t.object,e,n),t.name);case"where":return O(t.set,e,n);case"binary":return t.op==="|"||t.op==="&"||t.op==="-"?O(t.left,e,n):null;case"call":{let r=a=>{let u=t.args[a];return u?.t==="lit"&&typeof u.value=="string"?u.value:void 0};return t.fn==="all"?r(0)??null:t.fn==="out"?t.args.length===2?n.farOf(O(t.args[0],e,n),r(1)??""):n.farOf(e,r(0)??""):t.fn==="in"?t.args.length===2?n.nearOf(O(t.args[0],e,n),r(1)??""):n.nearOf(e,r(0)??""):(t.fn==="first"||t.fn==="sort")&&t.args[0]?O(t.args[0],e,n):null}default:return null}}function S(t){return t.t==="binary"?t.op==="||"?B(t)?4:1:t.op==="&&"?2:t.op in K||t.op==="in"?4:t.op==="+"||t.op==="-"?5:t.op==="*"||t.op==="/"||t.op==="%"?6:4.5:t.t==="unary"&&t.op==="!"?3:t.t==="where"?3.5:9}var W=t=>t.t==="lit",h=(t,e)=>t.t==="call"&&t.fn===e;function C(t,e){return t.t==="binary"&&t.op===e?[...C(t.left,e),...C(t.right,e)]:[t]}function B(t){if(t.t!=="binary"||t.op!=="||")return;let e=[];e.push(...C(t,"||"));let n,r=[];for(let a of e){if(a.t!=="binary"||a.op!=="=="||!W(a.right)||typeof a.right.value!="string"||n&&JSON.stringify(ct(n))!==JSON.stringify(ct(a.left)))return;n=a.left,r.push(a.right)}return n?{subject:n,values:r}:void 0}var ct=t=>JSON.parse(JSON.stringify(t,(e,n)=>e==="at"?void 0:n));function f(t,e,n,r){let a=(u,o,s=e)=>S(u)<o?[R,...f(u,s,n),w]:f(u,s,n);switch(t.t){case"lit":return[n.valueWords(t.value,r)];case"list":return[n.valueWords(t.items.map(u=>u.t==="lit"?u.value:null),r)];case"ident":return[L(n.fieldName(e,t.name))];case"member":{let u=h(t.object,"first")&&t.object.args[0]&&h(t.object.args[0],"all"),o=O(t.object,e,n);if(u&&o)return e!==null&&n.fieldName(e,t.name)===n.fieldName(o,t.name)&&n.definition(e)?.fields?.shape&&Object.prototype.hasOwnProperty.call(n.definition(e).fields.shape,t.name)?[L(`${n.noun(o)}'s ${n.fieldName(o,t.name)}`)]:[L(n.fieldName(o,t.name))];let s=f(t.object,e,n),p=s[s.length-1];return s.length===1&&p?.as==="name"?[L(`${p.text}'s ${n.fieldName(o,t.name)}`)]:[...s,d("'s"),L(n.fieldName(o,t.name))]}case"unary":return t.op==="-"?[b("\u2212","minus"),...a(t.operand,7)]:I(t.operand,e,n);case"where":{let u=O(t.set,e,n),o=f(t.filter,u,n),s=o.every(p=>p.as==="name"||p.as==="word"&&p.text==="not");return[...a(t.set,4),...s?[]:[d("with")],...S(t.filter)<=2?[R,...o,w]:o]}case"binary":return mt(t,e,n);case"call":return vt(t,e,n)}}function I(t,e,n){return dt(t)?mt({...t,op:z[t.op]},e,n):h(t,"present")||h(t,"exists")?[...f(t.args[0],e,n),b("=","is"),N]:t.t==="ident"?[d("not"),L(n.fieldName(e,t.name))]:[d("not"),R,...f(t,e,n),w]}function mt(t,e,n){let r=(o,s)=>S(o)<s?[R,...f(o,e,n),w]:f(o,e,n);if(t.op==="&&"||t.op==="||"){let o=B(t);if(o){let p=E(o.subject,e,n);return[...f(o.subject,e,n),b("\u2208","is one of"),n.valueWords(o.values.map(x=>x.value),p)]}let s=t.op==="&&"?2:1;return[...r(t.left,s),d(t.op==="&&"?"and":"or"),...r(t.right,s+.5)]}if(t.op in K){if(W(t.right)&&typeof t.right.value=="boolean"&&(t.op==="=="||t.op==="!="))return t.op==="=="===t.right.value?f(t.left,e,n):I(t.left,e,n);let[o,s]=K[t.op],p=E(t.left,e,n),x=E(t.right,e,n);return[...j(t.left,e,n,x),b(o,s),...j(t.right,e,n,p)]}if(t.op==="in")return[...r(t.left,5),b("\u2208","is one of"),...j(t.right,e,n,E(t.left,e,n))];let a=wt[t.op];if(a){let o=S(t);return[...r(t.left,o),b(a[0],a[1]),...r(t.right,o+.5)]}let u={"|":"or","&":"and also","-":"except"};return[...r(t.left,5),d(u[t.op]??t.op),...r(t.right,5)]}function j(t,e,n,r){return t.t==="lit"||t.t==="list"?f(t,e,n,r):S(t)<5?[R,...f(t,e,n),w]:f(t,e,n)}function vt(t,e,n){let r=o=>t.args[o],a=o=>{let s=t.args[o];return s?.t==="lit"&&typeof s.value=="string"?s.value:void 0},u=o=>{let s=r(o);return S(s)<9&&s.t!=="where"?[R,...f(s,e,n),w]:f(s,e,n)};switch(t.fn){case"out":{let o=a(t.args.length-1)??"",s=L(V(o).toLowerCase());return t.args.length===2?[s,d("of"),...u(0)]:[s]}case"in":{let o=a(t.args.length-1)??"",s=t.args.length===2?n.nearOf(O(r(0),e,n),o):n.nearOf(e,o),p=L(s?n.plural(s):V(o).toLowerCase());return t.args.length===2?[p,d("of"),...u(0)]:[p]}case"all":{let o=a(0);return[L(o?n.plural(o):"everything")]}case"fact":{let o=a(0);return[L(o?n.factName(o):"fact")]}case"count":return[d("number of"),...u(0)];case"exists":return[...u(0),b("\u2260","is not"),N];case"present":return[...f(r(0),e,n),b("\u2260","is not"),N];case"some":case"every":{let o=O(r(0),e,n),s=r(1);return[...t.fn==="some"?[d("some")]:[],...u(0),d(t.fn==="some"?"with":"all with"),...S(s)<=2?[R,...f(s,o,n),w]:f(s,o,n)]}case"sum":case"min":case"max":{let o=O(r(0),e,n),s=r(1),p=s.t==="lit"&&typeof s.value=="string"?[L(n.fieldName(o,s.value))]:S(s)<9?[R,...f(s,o,n),w]:f(s,o,n);return[d(t.fn==="sum"?"total":t.fn==="min"?"least":"most"),...p,d("of"),...u(0)]}case"first":{let o=r(0);if(h(o,"all")){let s=o.args[0]?.value;if(typeof s=="string")return[L(`the ${n.noun(s)}`)]}return[d("first of"),...u(0)]}case"sort":return[...u(0),d("by"),...f(r(1),O(r(0),e,n),n)];case"len":return[d("length of"),...f(r(0),e,n)];case"lower":return f(r(0),e,n);case"contains":case"startsWith":return[...f(r(0),e,n),d(t.fn==="contains"?"contains":"starts with"),...j(r(1),e,n,E(r(0),e,n))];case"today":return[P("today")];case"now":return[P("now")];case"date":return W(r(0))&&typeof r(0).value=="string"?[P(G(String(r(0).value)))]:f(r(0),e,n);case"days":case"hours":{let o=t.fn,[s,p]=[r(0),r(1)];return h(p,"today")||h(p,"now")?[d(`${o} since`),...f(s,e,n)]:h(s,"today")||h(s,"now")?[d(`${o} until`),...f(p,e,n)]:[d(`${o} from`),...f(s,e,n),d("to"),...f(p,e,n)]}case"if":return[R,...f(r(1),e,n),d("if"),...f(r(0),e,n),d(","),d("else"),...f(r(2),e,n),w];case"either":return t.args.flatMap((o,s)=>s===0?f(o,e,n):[d(","),d("else"),...f(o,e,n)]);default:return[d(t.fn),R,...t.args.flatMap((o,s)=>s===0?f(o,e,n):[d(","),...f(o,e,n)]),w]}}function U(t,e){let n=pt(e),r=t.over==="graph"?null:t.over;return J({...r===null?{}:{kind:r},parts:f(t.require,r,n),...t.when?{when:f(t.when,r,n)}:{}})}function Z(t,e,n){let r=pt(e),a=t.over==="graph"?null:t.over,u=n.subject,o=l=>{try{return q(l,{...n,budget:2e3})}catch{return}},s=(l,m)=>{let g=j(l,a,r,m);if(l.t==="lit"||l.t==="list"||h(l,"today")||h(l,"now")||h(l,"date"))return g;let i=o(l);if(i===void 0)return g;let c=E(l,a,r),y=r.valueWords(i,c?{...c,format:r.formatOf(c.kind,c.key)??(m?r.formatOf(m.kind,m.key):void 0)}:m);return i instanceof M?[...g,d(":"),y]:[...g,y]},p=l=>{if(l.t==="binary"&&l.op==="&&"){let m=[];m.push(...C(l,"&&"));let g=m.filter(i=>o(i)!==!0);return(g.length>0?g:m).flatMap((i,c)=>[...c>0?[d("and")]:[],...S(i)<=2?[R,...p(i),w]:p(i)])}if(l.t==="binary"&&l.op==="||"){let m=B(l);if(m){let i=E(m.subject,a,r);return[...s(m.subject),b("\u2209","is not one of"),r.valueWords(m.values.map(c=>c.value),i)]}let g=[];return g.push(...C(l,"||")),g.flatMap((i,c)=>[...c>0?[d("and")]:[],...S(i)<=2?[R,...p(i),w]:p(i)])}if(l.t==="binary"&&l.op in K){if(W(l.right)&&typeof l.right.value=="boolean"&&(l.op==="=="||l.op==="!="))return l.op==="=="===l.right.value?I(l.left,a,r):f(l.left,a,r);let m=z[l.op],[g,i]=K[m],c=E(l.left,a,r),y=E(l.right,a,r);if(W(l.right)&&l.right.value===null)return[...m==="=="?j(l.left,a,r,y):s(l.left,y),b(g,i),N];let A=m==="=="&&(W(l.right)||W(l.left));return[...A?j(l.left,a,r,y):s(l.left,y),b(g,i),...A?j(l.right,a,r,c):s(l.right,c)]}if(l.t==="binary"&&l.op==="in")return[...s(l.left),b("\u2209","is not one of"),...j(l.right,a,r,E(l.left,a,r))];if(l.t==="unary"&&l.op==="!"){let m=l.operand;return dt(m)?p({...m,op:z[m.op]}):h(m,"present")||h(m,"exists")?[...s(m.args[0]),b("\u2260","is not"),N]:m.t==="ident"?f(m,a,r):[d("not"),R,...I(m,a,r),w]}if(h(l,"present")||h(l,"exists"))return[...f(l.args[0],a,r),b("=","is"),N];if(h(l,"some"))return[...f(l,a,r).slice(1),b("=","is"),N];if(h(l,"every")&&l.args.length===2){let m=o(l.args[0]);if(m instanceof M){let g=m.nodes.filter(i=>{try{return q(l.args[1],{...n,subject:i,budget:2e3})!==!0}catch{return!0}});return[...f(l,a,r),d(","),d("not"),r.valueWords(new M(g))]}}return l.t==="ident"?[d("not"),L(r.fieldName(a,l.name))]:[d("not"),R,...f(l,a,r),w]},x;try{x=p(t.require)}catch{x=[d("not"),R,...f(t.require,a,r),w]}return J({...a===null?{}:{kind:a},parts:x,...u?{record:T(e.schema.tryDefinition(u.kind),u)}:{}})}function yt(t){let e=new Map;for(let n of t??[])n.expr?.t==="ident"&&n.format&&(n.format==="money"||n.format==="percent"||n.format==="date")&&e.set(n.expr.name,n.format);return e}function Ot(t){return(e,n)=>{let r=t[e]?.fields?.[n],a=r?.format??(r?.type==="date"?"date":void 0);return a||r?.unit?{...a?{format:a}:{},...r?.unit?{unit:r.unit}:{}}:void 0}}function ht(t,e){return{schema:e,said:yt(t.says),...t.declared?{formatOf:Ot(t.declared)}:{},...t.money?{money:t.money}:{}}}function Jt(t,e){return t.shape?U(t.shape,ht(t.shape,e)):void 0}var gt=new WeakMap;function Et(t,e){let n=new Map(t.allInvariants().map(r=>[r.name,r]));return e.map(r=>{let a=At(r),u=n.get(a.invariant)?.shape;if(!u||a.status&&a.status!=="violated")return a;let o=a.subjectId?t.graph.getNode(a.subjectId):void 0;if(u.over!=="graph"&&!o)return a;let s=u.kinds;s||(s=gt.get(t.schema),s||gt.set(t.schema,s=lt(t.schema)));try{let p=u.today?.()??t.today?.()??Q(),x=Z(u,ht(u,t.schema),{graph:t.graph,subject:o??null,kinds:s,today:p});return{...a,line:x,...u.says?{}:{message:`${a.message} \u2014 ${x.text}`}}}catch{return a}})}function Pt(){rt((t,e,n)=>Et({graph:t,schema:t.schema,allInvariants:()=>e},n)),ot(Lt)}function Lt(t,e,n,r){let a=e.graph,u=et.from(t.schema,a.snapshot(),{validate:!1});for(let x of n?[...r].reverse().map(nt):r)try{u.applyPrimitives([x],{restoring:!0})}catch{}let o=x=>t.violations(void 0,x),s=o(n?u:a),p=o(n?a:u);return{...at(t.allInvariants(),s,p),violationsAfter:p}}function At(t){if(!t.line)return t;let{line:e,...n}=t,r=` \u2014 ${e.text}`;return n.message.endsWith(r)?{...n,message:n.message.slice(0,-r.length)}:n}Pt();export{Z as brokenLineOf,Pt as judgeWithLines,Lt as judgedForASeat,Rt as problemWords,Jt as ruleLine,U as ruleLineOf,ut as ruleLineWords,_ as ruleSpacing,bt as ruleSpoken,xt as ruleText,At as unlined,Et as withLines};
|