@kanonak-protocol/sdk 3.29.11 → 3.31.0

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.
@@ -0,0 +1,116 @@
1
+ import{a as ee}from"./chunk-NIGFQYVA.js";import{a as te}from"./chunk-4YHWMYAZ.js";import{c as J,d as R,g as B,h as fe,i as Ke,j as U,k as Z,l as F}from"./chunk-W6T7MOKY.js";function Le(u){let e=u.replace(/\r\n/g,`
2
+ `).split(`
3
+ `),t=[],n=0;for(;n<e.length;){let s=e[n];if(s.trim()===""){n++;continue}let o=/^(\s*)```(\S*)\s*$/.exec(s);if(o){let i=o[2],c=[];for(n++;n<e.length&&!/^(\s*)```\s*$/.test(e[n]);)c.push(e[n]),n++;n++;let l=we(c.join(`
4
+ `)),d=i?` class="language-${Oe(i)}"`:"";t.push(`<pre><code${d}>${l}</code></pre>`);continue}let r=/^(#{1,6})\s+(.*)$/.exec(s);if(r){let i=r[1].length,c=ne(r[2].trim());t.push(`<h${i}>${c}</h${i}>`),n++;continue}if(s.includes("|")&&n+1<e.length&&Se(e[n+1])){let i=de(s),c=Xe(e[n+1]);n+=2;let l=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)l.push(de(e[n])),n++;t.push(ze(i,c,l));continue}if(/^\s*[-*]\s+/.test(s)){let i=[];for(;n<e.length&&/^\s*[-*]\s+/.test(e[n]);){let c=[e[n].replace(/^\s*[-*]\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n]);)c.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,i.push(`<li>${ne(c.join(" ").trim())}</li>`)}t.push(`<ul>
5
+ ${i.join(`
6
+ `)}
7
+ </ul>`);continue}if(/^\s*\d+\.\s+/.test(s)){let i=[];for(;n<e.length&&/^\s*\d+\.\s+/.test(e[n]);){let c=[e[n].replace(/^\s*\d+\.\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*\d+\.\s+/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n]);)c.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,i.push(`<li>${ne(c.join(" ").trim())}</li>`)}t.push(`<ol>
8
+ ${i.join(`
9
+ `)}
10
+ </ol>`);continue}let a=[s];for(n++;n<e.length&&e[n].trim()!==""&&!/^(#{1,6})\s+/.test(e[n])&&!/^(\s*)```/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n])&&!(e[n].includes("|")&&n+1<e.length&&Se(e[n+1]));)a.push(e[n]),n++;t.push(`<p>${ne(a.join(" "))}</p>`)}return t.join(`
11
+ `)}function Se(u){return u.includes("-")?/^[\s|:-]+$/.test(u):!1}function de(u){let e=u.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|").map(t=>t.trim())}function Xe(u){return de(u).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function ze(u,e,t){let n=r=>{let a=e[r];return a?` style="text-align:${a}"`:""},s=u.map((r,a)=>`<th${n(a)}>${ne(r)}</th>`).join(""),o=t.map(r=>`<tr>${r.map((i,c)=>`<td${n(c)}>${ne(i)}</td>`).join("")}</tr>`).join(`
12
+ `);return`<table>
13
+ <thead><tr>${s}</tr></thead>
14
+ <tbody>
15
+ ${o}
16
+ </tbody>
17
+ </table>`}function ne(u){let e=we(u);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,s)=>`<a href="${Oe(s)}">${n}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(t,n)=>`<strong>${n}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(t,n,s)=>`${n}<em>${s}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(t,n,s)=>`${n}<em>${s}</em>`),e}function we(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Oe(u){return u.replace(/"/g,"&quot;").replace(/&/g,"&amp;")}var pe={publisher:"kanonak.org",package_:"derivation",name:"look"},he={publisher:"kanonak.org",package_:"derivation",name:"tokens"},N={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},H={publisher:"kanonak.org",package_:"core-rdf",name:"label"},Ie={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},Qe={publisher:"kanonak.org",package_:"look",name:"Hero"},Ze={publisher:"kanonak.org",package_:"look",name:"PropertyList"},en={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},nn={publisher:"kanonak.org",package_:"look",name:"ChipRow"},tn={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},Ue={publisher:"kanonak.org",package_:"look",name:"Markdown"},oe={publisher:"kanonak.org",package_:"look",name:"NavGroup"},ke={publisher:"kanonak.org",package_:"look",name:"NavLink"},xe={publisher:"kanonak.org",package_:"look",name:"target"},sn={publisher:"kanonak.org",package_:"look",name:"ResourceGrid"},rn={publisher:"kanonak.org",package_:"look",name:"Timeline"},an={publisher:"kanonak.org",package_:"look",name:"VersionDiff"},Fe={publisher:"kanonak.org",package_:"look",name:"orderBy"},Ee={publisher:"kanonak.org",package_:"look",name:"track"},Pe={publisher:"kanonak.org",package_:"look",name:"metricPath"},Te={publisher:"kanonak.org",package_:"look",name:"hueBy"},on={publisher:"kanonak.org",package_:"look",name:"lowerPath"},cn={publisher:"kanonak.org",package_:"look",name:"upperPath"},un={publisher:"kanonak.org",package_:"look",name:"axisMin"},ln={publisher:"kanonak.org",package_:"look",name:"axisMax"},fn={publisher:"kanonak.org",package_:"look",name:"valueLabel"};var dn={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},pn={publisher:"kanonak.org",package_:"look",name:"tierChip"},hn={publisher:"kanonak.org",package_:"look",name:"tierIcon"},kn={publisher:"kanonak.org",package_:"look",name:"tierCard"},gn={publisher:"kanonak.org",package_:"look",name:"tierFull"};var ge={publisher:"kanonak.org",package_:"look",name:"bands"},mn={publisher:"kanonak.org",package_:"look",name:"title"},bn={publisher:"kanonak.org",package_:"look",name:"eyebrow"},jn={publisher:"kanonak.org",package_:"look",name:"subtitle"},Ce={publisher:"kanonak.org",package_:"look",name:"badges"},A={publisher:"kanonak.org",package_:"look",name:"source"},$n={publisher:"kanonak.org",package_:"look",name:"chips"},me={publisher:"kanonak.org",package_:"look",name:"entries"},_n={publisher:"kanonak.org",package_:"look",name:"urlForm"},$e=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let t=je(e);if(t)return{declaration:t,sourceClass:{publisher:G(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}};let n=new Set,s=D(e);for(;s.length>0;){let o=s.shift(),r=z(o.subject);if(n.has(r))continue;n.add(r);let a=x(this.catalog,o.subject);if(!a)continue;let i=je(a);if(i)return{declaration:i,sourceClass:{publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name}};for(let c of ie(a))s.push(c)}if(!n.has(z(N))){let o=x(this.catalog,N);if(o){let r=je(o);if(r)return{declaration:r,sourceClass:{...N}}}}}findCascadedTokens(e){let t=new Map;for(let[o,r]of be(e))t.has(o)||t.set(o,r);let n=new Set,s=D(e);for(;s.length>0;){let o=s.shift(),r=z(o.subject);if(n.has(r))continue;n.add(r);let a=ce(this.catalog,o.subject);if(a.length!==0)for(let i of a){for(let[c,l]of be(i))t.has(c)||t.set(c,l);for(let c of ie(i))s.push(c)}}if(!n.has(z(N))){let o=ce(this.catalog,N);for(let r of o)for(let[a,i]of be(r))t.has(a)||t.set(a,i)}return t}renderSvg(e){let t=v(e,H)??e.name,n=(t.trim().charAt(0)||"?").toUpperCase(),s=`${e.namespace??""}/${e.name}`,o={label:t,firstLetter:n,uri:s},r=this.collectCascadedSvgTiers(e),a=m=>this.applyPlaceholders(m,e,o),i=a(r.tierChip??""),c=a(r.tierIcon??""),l=a(r.tierCard??""),d=a(r.tierFull??""),k=[...this.findCascadedTokens(e)].map(([m,b])=>`--kan-${m}: ${b};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400" style="${se(k)}">
18
+ <style>
19
+ .tier-chip,.tier-icon,.tier-card{display:none}
20
+ .tier-full{display:block}
21
+ @media (max-width:400px){.tier-full{display:none}.tier-card{display:block}}
22
+ @media (max-width:160px){.tier-card{display:none}.tier-icon{display:block}}
23
+ @media (max-width:60px){.tier-icon{display:none}.tier-chip{display:block}}
24
+ </style>
25
+ <g class="tier-chip">${i}</g>
26
+ <g class="tier-icon">${c}</g>
27
+ <g class="tier-card">${l}</g>
28
+ <g class="tier-full">${d}</g>
29
+ </svg>`}applyPlaceholders(e,t,n){return e.replace(/\{\{([^}]+)\}\}/g,(s,o)=>{let r=o.trim();if(n[r]!==void 0)return se(n[r]);let a=this.resolvePath(t,r);return a===void 0?`{{${r}}}`:se(a)})}resolvePath(e,t){let n=t.split("/").map(a=>a.trim()).filter(a=>a.length>0);if(n.length===0)return;let s=e;for(let a=0;a<n.length-1;a++){if(!s)return;let i=Be(n[a]),c=He(s,i);if(!c)return;if(c instanceof U&&c.object instanceof R){let l=x(this.catalog,c.object.subject);if(!l)return;s=l}else if(c instanceof Z)s=c.object;else return}if(!s)return;let o=Be(n[n.length-1]),r=He(s,o);if(r){if(r instanceof B||r instanceof fe||r instanceof Ke)return String(r.object);if(r instanceof U&&r.object instanceof R){let a=r.object,i=x(this.catalog,a.subject);return i?v(i,H)??a.subject.name:a.subject.name}}}collectCascadedSvgTiers(e){let t={},n=r=>{let a=X(r,dn);if(!(a instanceof Z))return;let i=a.object,c=v(i,pn),l=v(i,hn),d=v(i,kn),g=v(i,gn);t.tierChip===void 0&&c!==void 0&&(t.tierChip=c),t.tierIcon===void 0&&l!==void 0&&(t.tierIcon=l),t.tierCard===void 0&&d!==void 0&&(t.tierCard=d),t.tierFull===void 0&&g!==void 0&&(t.tierFull=g)};n(e);let s=new Set,o=D(e);for(;o.length>0;){let r=o.shift(),a=z(r.subject);if(s.has(a))continue;s.add(a);let i=ce(this.catalog,r.subject);for(let c of i){n(c);for(let l of ie(c))o.push(l)}}if(!s.has(z(N)))for(let r of ce(this.catalog,N))n(r);return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[r,a]of t)n.push(` --kan-${r}: ${a};`);let s=n.length>0?`:root {
30
+ ${n.join(`
31
+ `)}
32
+ }`:":root { /* no tokens resolved */ }",o=this.findBaseStylesheet(G(e))??"";return`${s}
33
+ ${o}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,s;for(let r of this.catalog){if(!(r instanceof J)||r.name!=="base-stylesheet")continue;let a=r.namespace||"";a.startsWith(`${e}/look-styles@`)?n=r:a.startsWith("kanonak.org/look-styles@")&&(s=r)}let o=n??s;if(o)for(let r of o.statement){let a=r.predicate?.subject;if(!a)continue;if(`${a.publisher}/${a.package_}/${a.name}`===t&&r instanceof B)return r.object}}renderHtml(e){let t=this.findCascadedLook(e);if(!t)return`<!-- LookRenderer: no derivation.look found for ${e.namespace}/${e.name} -->`;let n=Ne(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let s=G(e),o=[];for(let r of n)o.push(this.renderBand(r,e,s));return o.join(`
34
+ `)}renderPublisherIndex(e,t,n){let s=n?this.renderNavGroup(n,e):"",o=t.map(a=>{let i=a.comment?`<p class="kan-resource-card-subtitle">${f(a.comment)}</p>`:"";return`<a class="kan-resource-card" href="${f(a.href)}"><h3 class="kan-resource-card-title">${f(a.label)}</h3>${i}</a>`}).join(`
35
+ `),r=`<header class="kan-hero">
36
+ <h1 class="kan-hero-title">${f(e)}</h1>
37
+ </header>
38
+ <section class="kan-resource-grid">
39
+ ${o}
40
+ </section>`;return`<!doctype html>
41
+ <html lang="en">
42
+ <head>
43
+ <meta charset="utf-8">
44
+ <meta name="viewport" content="width=device-width, initial-scale=1">
45
+ <title>${f(e)}</title>
46
+ <link rel="stylesheet" href="index.css">
47
+ </head>
48
+ <body>
49
+ ${s}
50
+ <main class="kan-main">
51
+ ${r}
52
+ </main>
53
+ </body>
54
+ </html>
55
+ `}renderPublisherIndexStylesheet(e){return e?this.renderStylesheet(e):""}hasDeclaredView(e){let t=this.findCascadedLook(e);return t?!(t.sourceClass.publisher===N.publisher&&t.sourceClass.package_===N.package_&&t.sourceClass.name===N.name):!1}renderPackageVersionList(e,t,n){let s=G(n),o=this.renderNavGroup(n,s),r=this.renderBreadcrumb(n,s,{bareOverview:!0}),a=t.map(c=>`<a class="kan-resource-card" href="/${f(e)}/${f(c)}/"><h3 class="kan-resource-card-title">${f(c)}</h3></a>`).join(`
56
+ `),i=`<header class="kan-hero">
57
+ <span class="kan-hero-eyebrow">PACKAGE</span>
58
+ <h1 class="kan-hero-title">${f(e)}</h1>
59
+ </header>
60
+ <section class="kan-resource-grid">
61
+ ${a}
62
+ </section>`;return`<!doctype html>
63
+ <html lang="en">
64
+ <head>
65
+ <meta charset="utf-8">
66
+ <meta name="viewport" content="width=device-width, initial-scale=1">
67
+ <title>${f(e)}</title>
68
+ <link rel="stylesheet" href="${f(n.name)}.css">
69
+ </head>
70
+ <body>
71
+ ${o}
72
+ ${r}
73
+ <main class="kan-main">
74
+ ${i}
75
+ </main>
76
+ </body>
77
+ </html>
78
+ `}renderDocument(e,t){let n=this.renderHtml(e),s=this.readPropertyValueText(e,H)??e.name,o=`${e.name}.css`,r=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${f(e.name)}.svg" alt=""></figure>
79
+ `:"",a=G(e),i=this.renderNavGroup(e,a),c=this.renderBreadcrumb(e,a,t);return`<!doctype html>
80
+ <html lang="en">
81
+ <head>
82
+ <meta charset="utf-8">
83
+ <meta name="viewport" content="width=device-width, initial-scale=1">
84
+ <title>${f(s)}</title>
85
+ <link rel="stylesheet" href="${f(o)}">
86
+ </head>
87
+ <body>
88
+ ${i}
89
+ ${c}
90
+ <main class="kan-main">
91
+ ${r}${n}
92
+ </main>
93
+ </body>
94
+ </html>
95
+ `}hasSvgDerivation(e){let t=new Set,n=D(e);for(;n.length>0;){let s=n.shift(),o=z(s.subject);if(t.has(o))continue;t.add(o);let r=x(this.catalog,s.subject);if(r){for(let a of r.statement)if(a instanceof F&&V(a,"kanonak.org","derivation","derivations")){for(let i of a.object??[])if(i instanceof te)for(let c of i.statement){if(!(c instanceof U)||!V(c,"kanonak.org","derivation","format")||!(c.object instanceof R))continue;let l=c.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let a of ie(r))n.push(a)}}return!1}renderBand(e,t,n){let s=Ve(e);return s?E(s,Qe)?this.renderHero(e,t,n):E(s,Ze)?this.renderPropertyList(e,t,n):E(s,en)?this.renderBadgeRow(e,t,n):E(s,nn)?this.renderChipRow(e,t,n):E(s,tn)?this.renderReferenceList(e,t,n):E(s,Ue)?this.renderMarkdown(e,t):E(s,oe)?this.renderNavGroup(t,n):E(s,sn)?this.renderResourceGrid(e,n,t):E(s,rn)?this.renderTimeline(e,n):E(s,an)?this.renderVersionDiff(e,n):`<!-- LookRenderer: unsupported band ${s.publisher}/${s.package_}/${s.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}collectTrackedSeries(e,t,n,s){let{hueBy:o,lowerPath:r,upperPath:a}=s??{},i=new Map,c=e.length,l=(d,g)=>{let k=this.resolvePath(d,g);return k===void 0?NaN:parseFloat(k)};return e.forEach((d,g)=>{let k=this.readPropertyValueReferences(d,t);for(let m of k){let b=x(this.catalog,{publisher:m.subject.publisher,package_:m.subject.package_,name:m.subject.name,...m.subject.version?{version:m.subject.version}:{}});if(!b)continue;let h=m.subject.name,j=i.get(h);j||(j={key:h,label:v(b,H)??h,points:new Array(c).fill(null),...r?{lower:new Array(c).fill(null)}:{},...a?{upper:new Array(c).fill(null)}:{}},i.set(h,j));let y=l(b,n);if(Number.isFinite(y)&&(j.points[g]=y),r&&j.lower){let $=l(b,r);Number.isFinite($)&&(j.lower[g]=$)}if(a&&j.upper){let $=l(b,a);Number.isFinite($)&&(j.upper[g]=$)}if(o){let $=l(b,o);Number.isFinite($)&&(j.hue=$)}j.lastSubject=b}}),[...i.values()]}hrefForSubject(e,t,n="="){let s=e.namespace||"",o=s.split("/")[1]?.split("@")[0]??"",r=s.split("@")[1]??"",a=r?this.parseVersion(r):void 0;return ee.formatResourceUrl({publisher:G(e),package_:o,name:e.name,...a?{version:a}:{}},n,{contextPublisher:t})}renderVersionDiff(e,t){let n=K(e,A);if(!n)return"<!-- LookRenderer.VersionDiff: no look.source -->";let s=v(e,Pe),o=K(e,Ee);if(!o||!s)return"<!-- LookRenderer.VersionDiff: needs look.track + look.metricPath -->";let r=K(e,Fe),a=v(e,Te),i=this.findInstancesOfClass(n);if(i.length===0)return"<!-- LookRenderer.VersionDiff: no instances -->";let c=k=>r?this.readPropertyValueText(k,r)??"":"",l=i.slice().sort((k,m)=>c(k).localeCompare(c(m))),d=this.collectTrackedSeries(l,o,s,{hueBy:a});return d.length===0?"<!-- LookRenderer.VersionDiff: no tracked series -->":`<section class="kan-vdiff">${d.map((k,m)=>{let b=k.hue!==void 0?k.hue:Math.round(m*360/d.length),h=k.points.filter(W=>W!==null);if(h.length===0)return"";let j=h[0],y=h[h.length-1],$=y-j,P;if(Math.abs($)>=.005){let W=$>0?"up":"down",q=$>0?"\u25B2":"\u25BC";P=`<span class="kan-vdiff-delta ${W}">${$>0?"+":""}${$.toFixed(2)} ${q}</span>`}else P='<span class="kan-vdiff-delta flat">\u2014</span>';let Q=k.lastSubject?`<a href="${f(this.hrefForSubject(k.lastSubject,t))}">${f(k.label)}</a>`:f(k.label);return`<div class="kan-vdiff-row" style="--kan-vdiff-hue:${b}"><span class="kan-vdiff-label">${Q}</span><span class="kan-vdiff-start">${j.toFixed(2)}</span>`+this.sparkline(k.points,b)+`<span class="kan-vdiff-end">${y.toFixed(2)}</span>`+P+"</div>"}).join("")}</section>`}sparkline(e,t){let r=`hsl(${t},65%,60%)`,a=e.filter(h=>h!==null);if(a.length===0)return'<svg class="kan-vdiff-spark" viewBox="0 0 132 30" xmlns="http://www.w3.org/2000/svg"></svg>';let i=Math.min(...a),l=Math.max(...a)-i,d=e.length,g=h=>d<=1?132/2:4+h/(d-1)*124,k=h=>l<1e-9?30/2:26-(h-i)/l*22,m=[],b=[];return e.forEach((h,j)=>{if(h===null)return;let y=g(j),$=k(h);m.push(`${y.toFixed(1)},${$.toFixed(1)}`),b.push(`<circle cx="${y.toFixed(1)}" cy="${$.toFixed(1)}" r="2" fill="${r}"/>`)}),`<svg class="kan-vdiff-spark" viewBox="0 0 132 30" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" role="img"><polyline points="${m.join(" ")}" fill="none" stroke="${r}" stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round"/>`+b.join("")+"</svg>"}renderTimeline(e,t){let n=K(e,A);if(!n)return"<!-- LookRenderer.Timeline: no look.source -->";let s=K(e,Fe),o=this.findInstancesOfClass(n);if(o.length===0)return"<!-- LookRenderer.Timeline: no instances -->";let r=d=>s?this.readPropertyValueText(d,s)??"":"",a=o.slice().sort((d,g)=>r(d).localeCompare(r(g))),i=K(e,Ee),c=v(e,Pe);return i&&c?this.renderTrajectoryChart(a,i,c,e,t,r):`<section class="kan-timeline"><ol>
96
+ ${a.map(d=>{let g=d.namespace||"",k=g.split("/")[1]?.split("@")[0]??"",m=g.split("@")[1]??"",b=m?this.parseVersion(m):void 0,h=ee.formatResourceUrl({publisher:G(d),package_:k,name:d.name,...b?{version:b}:{}},"=",{contextPublisher:t}),j=r(d),y=j?`<span class="kan-timeline-date">${f(j)}</span>`:"",$=m||d.name;return`<li class="kan-timeline-node"><a href="${f(h)}"><span class="kan-timeline-key">${f($)}</span>${y}</a></li>`}).join(`
97
+ `)}
98
+ </ol></section>`}renderTrajectoryChart(e,t,n,s,o,r){let a=s,i=v(a,Te),c=v(a,on),l=v(a,cn),d=v(a,fn),g=Me(a,un),k=Me(a,ln),m=e.length,b=this.collectTrackedSeries(e,t,n,{hueBy:i,lowerPath:c,upperPath:l});if(b.length===0)return"<!-- LookRenderer.Timeline: no tracked series -->";let h=[];for(let p of b){for(let _ of p.points)_!==null&&h.push(_);for(let _ of p.lower??[])_!==null&&h.push(_);for(let _ of p.upper??[])_!==null&&h.push(_)}if(h.length===0)return"<!-- LookRenderer.Timeline: no metric values -->";let j=Math.min(...h),y=Math.max(...h);y-j<1e-9&&(j-=.5,y+=.5);let $=(y-j)*.08,P=g!==void 0?g:j-$,Q=k!==void 0?k:y+$;Q-P<1e-9&&(Q=P+1);let W=1e3,q=440,S={top:28,right:24,bottom:56,left:52},_e=W-S.left-S.right,De=q-S.top-S.bottom,re=p=>m<=1?S.left+_e/2:S.left+p/(m-1)*_e,ae=p=>S.top+(1-(p-P)/(Q-P))*De,ue=(p,_)=>p.hue!==void 0?p.hue:Math.round(_*360/b.length),le=[];for(let p=0;p<5;p++){let _=P+p*(Q-P)/4,T=ae(_);le.push(`<line x1="${S.left}" y1="${T.toFixed(1)}" x2="${(W-S.right).toFixed(1)}" y2="${T.toFixed(1)}" class="kan-fan-grid"/>`),le.push(`<text x="${(S.left-8).toFixed(1)}" y="${(T+4).toFixed(1)}" class="kan-fan-axis" text-anchor="end">${_.toFixed(2)}</text>`)}let ve=[];e.forEach((p,_)=>{let T=this.hrefForSubject(p,o),w=(p.namespace||"").split("@")[1]??"",L=re(_),O=vn(r(p));ve.push(`<a href="${f(T)}" class="kan-fan-xtick"><line x1="${L.toFixed(1)}" y1="${S.top}" x2="${L.toFixed(1)}" y2="${(q-S.bottom).toFixed(1)}" class="kan-fan-vline"/><text x="${L.toFixed(1)}" y="${(q-S.bottom+20).toFixed(1)}" class="kan-fan-xlabel" text-anchor="middle">${se(w||p.name)}</text>`+(O?`<text x="${L.toFixed(1)}" y="${(q-S.bottom+36).toFixed(1)}" class="kan-fan-xdate" text-anchor="middle">${se(O)}</text>`:"")+"</a>")});let Re=[];b.forEach((p,_)=>{if(!p.lower||!p.upper)return;let T=ue(p,_),w=[],L=[];for(let I=0;I<m;I++){let Y=p.upper[I],M=p.lower[I];Y==null||M===null||M===void 0||(w.push(`${re(I).toFixed(1)},${ae(Y).toFixed(1)}`),L.unshift(`${re(I).toFixed(1)},${ae(M).toFixed(1)}`))}let O=w.concat(L);O.length<3||Re.push(`<polygon class="kan-fan-band" points="${O.join(" ")}" fill="hsl(${T},65%,60%)"/>`)});let ye=[];b.forEach((p,_)=>{let w=`hsl(${ue(p,_)},65%,60%)`,L=[],O=[];p.points.forEach((I,Y)=>{if(I===null)return;let M=re(Y),C=ae(I);L.push(`${M.toFixed(1)},${C.toFixed(1)}`),O.push(`<circle cx="${M.toFixed(1)}" cy="${C.toFixed(1)}" r="3.5" fill="${w}"/>`)}),L.length!==0&&ye.push(`<g class="kan-fan-series" data-series="${f(p.key)}"><polyline points="${L.join(" ")}" fill="none" stroke="${w}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>`+O.join("")+"</g>")});let Ge=`<svg class="kan-fan-svg" viewBox="0 0 ${W} ${q}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">`+le.join("")+ve.join("")+Re.join("")+ye.join("")+"</svg>",We=d?`${f(d)}=`:"",qe=b.map((p,_)=>{let T=ue(p,_),w=p.points.filter(C=>C!==null),L=w.length?w[0]:void 0,O=w.length?w[w.length-1]:void 0,I="";if(O!==void 0&&L!==void 0){let C=O-L;if(Math.abs(C)>=.005){let Ye=C>0?"up":"down",Je=C>0?"\u25B2":"\u25BC";I=` <span class="kan-fan-delta ${Ye}">${C>0?"+":""}${C.toFixed(2)} ${Je}</span>`}else I=' <span class="kan-fan-delta flat">\u2014</span>'}let Y=O!==void 0?`${We}${O.toFixed(2)}`:"\u2014",M=p.lastSubject?`<a href="${f(this.hrefForSubject(p.lastSubject,o))}">${f(p.label)}</a>`:f(p.label);return`<div class="kan-fan-legend-item" style="--kan-fan-hue:${T}"><span class="kan-fan-swatch"></span><span class="kan-fan-legend-label">${M}</span><span class="kan-fan-legend-cur">${Y}${I}</span></div>`});return`<section class="kan-fan"><div class="kan-fan-chart">${Ge}</div><div class="kan-fan-legend">${qe.join("")}</div></section>`}renderResourceGrid(e,t,n){let s=K(e,A);if(!s)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let o=x(this.catalog,s),r=o?D(o).some(c=>{let l=c.subject.name;return l==="ObjectProperty"||l==="DatatypeProperty"||l==="Property"}):!1,a=[];if(r&&n){let c=this.readPropertyValueReferences(n,s);for(let l of c){let d=x(this.catalog,{publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name,...l.subject.version?{version:l.subject.version}:{}});d&&a.push(d)}}else a=this.findInstancesOfClass(s);if(a.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${s.publisher}/${s.package_}/${s.name} -->`;let i=[];for(let c of a){let l=v(c,H)??c.name,d=v(c,Ie),g=c.namespace||"",k=g.split("/")[1]?.split("@")[0]??"",m=g.split("@")[1]??"",b=m?this.parseVersion(m):void 0,h=ee.formatResourceUrl({publisher:G(c),package_:k,name:c.name,...b?{version:b}:{}},"=",{contextPublisher:t}),j=d?`<p class="kan-resource-card-subtitle">${f(d)}</p>`:"";i.push(`<a class="kan-resource-card" href="${f(h)}"><h3 class="kan-resource-card-title">${f(l)}</h3>${j}</a>`)}return`<section class="kan-resource-grid">
99
+ ${i.join(`
100
+ `)}
101
+ </section>`}parseVersion(e){let t=e.split(".").map(Number);if(!(t.length!==3||t.some(n=>Number.isNaN(n))))return{major:t[0],minor:t[1],patch:t[2]}}findInstancesOfClass(e){let t=[];for(let n of this.catalog){if(!(n instanceof J))continue;D(n).map(r=>r.subject).some(r=>r.publisher===e.publisher&&r.package_===e.package_&&r.name===e.name)&&t.push(n)}return t}renderBreadcrumb(e,t,n){let o=(e.namespace||"").split("/");if(o.length<2)return"";let r=o[0],a=o[1]??"",i=a.split("@")[0]??"",c=a.split("@")[1]??"";if(!r||!i)return"";if(n?.bareOverview)return`<nav class="kan-breadcrumb"><ol>
102
+ <li><a href="/">${f(r)}</a></li>
103
+ <li aria-current="page">${f(i)}</li>
104
+ </ol></nav>`;let l=e.name,g=!!x(this.catalog,{publisher:r,package_:i,name:i}),k=c?`${i}@${c}`:i,m=c?`/${i}/${c}/${i}`:`/${i}/${i}`,b=e.name===i,h=[];return h.push(`<li><a href="/">${f(r)}</a></li>`),b?h.push(`<li aria-current="page">${f(k)}</li>`):(h.push(g?`<li><a href="${f(m)}">${f(k)}</a></li>`:`<li>${f(k)}</li>`),h.push(`<li aria-current="page">${f(l)}</li>`)),`<nav class="kan-breadcrumb"><ol>
105
+ ${h.join(`
106
+ `)}
107
+ </ol></nav>`}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let s=X(n,me);if(!(s instanceof F))return"";let o=s.object??[];if(o.length===0)return"";let r=[];for(let a of o){if(!(a instanceof R))continue;let i=x(this.catalog,{publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name}),{href:c,label:l}=this.resolveNavEntry(a,i,t),d=`/${e.namespace?.split("/")[1]?.split("@")[0]}/${(e.namespace||"").split("@")[1]}/${e.name}`,g=c===d?' aria-current="page"':"";r.push(`<li><a class="kan-nav-link" href="${f(c)}"${g}>${f(l)}</a></li>`)}return`<nav class="kan-site-nav"><ul>
108
+ ${r.join(`
109
+ `)}
110
+ </ul></nav>`}resolveNavEntry(e,t,n){if(t&&D(t).map(i=>i.subject).some(i=>i.publisher===ke.publisher&&i.package_===ke.package_&&i.name===ke.name)){let i=v(t,H),c=X(t,xe);if(c instanceof U&&c.object instanceof R){let l=c.object,d=this.readLabelForUri({publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name});return{href:this.urlForReference(l,xe,n),label:i??d??l.subject.name}}}let s=ee.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),o=t?v(t,H)??e.subject.name:e.subject.name;return{href:s,label:o}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof J)||!(t.namespace||"").startsWith(`${e}/`))continue;if(D(t).map(r=>r.subject).some(r=>r.publisher===oe.publisher&&r.package_===oe.package_&&r.name===oe.name))return t}}renderMarkdown(e,t){let n=K(e,A);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let s=this.readPropertyValueText(t,n);return s?`<section class="kan-markdown">
111
+ ${Le(s)}
112
+ </section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=Ne(t.declaration),s=[];for(let o of n){let r=Ve(o);if(!r||!E(r,Ue))continue;let a=K(o,A);if(!a)continue;let i=this.readPropertyValueText(e,a);i&&s.push(i)}return s.length>0?s.join(`
113
+
114
+ `):void 0}renderHero(e,t,n){let s=['<header class="kan-hero">'],o=K(e,bn);if(o){let l=this.readPropertyValueText(t,o);l&&s.push(`<span class="kan-hero-eyebrow">${f(l)}</span>`)}let r=K(e,mn),a="";r&&(a=this.readPropertyValueText(t,r)??""),a||(a=t.name),s.push(`<h1 class="kan-hero-title">${f(a)}</h1>`);let i=K(e,jn);if(i){let l=this.readPropertyValueText(t,i);l&&s.push(`<p class="kan-hero-subtitle">${f(l)}</p>`)}let c=K(e,Ce);if(c){let l=this.readPropertyValueReferences(t,c);if(l.length>0){let d=l.map(g=>this.renderBadge(g,Ce,n)).join("");s.push(`<div class="kan-hero-badges">${d}</div>`)}}return s.push("</header>"),s.join(`
115
+ `)}renderPropertyList(e,t,n){let s=K(e,A);if(!s)return"<!-- LookRenderer: PropertyList missing look.source -->";let o=this.readLabelForUri(s)??s.name,r=X(t,s),a=this.gatherValueItems(r),i=a.length>0?a.map(c=>`<li>${this.renderInlineValue(c,A,n)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${f(o)}</h3>`,`<ul class="kan-property-list-items">${i}</ul>`,"</section>"].join(`
116
+ `)}renderBadgeRow(e,t,n){let s=K(e,A);if(!s)return"<!-- LookRenderer: BadgeRow missing look.source -->";let o=this.readPropertyValueReferences(t,s);return o.length===0?"":`<div class="kan-badge-row">${o.map(a=>this.renderBadge(a,A,n)).join("")}</div>`}renderChipRow(e,t,n){let s=Ae(e,$n);if(s.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let o=[];for(let r of s){let a=X(t,r);if(!a)continue;let i=this.readLabelForUri(r)??r.name,c=this.renderStatementInlineValue(a,r,n);c&&o.push(`<span class="kan-chip"><span class="kan-chip-key">${f(i)}</span> <span class="kan-chip-val">${c}</span></span>`)}return o.length===0?"":`<div class="kan-chip-row">${o.join("")}</div>`}renderReferenceList(e,t,n){let s=Ae(e,me);if(s.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let o=[];for(let r of s){let a=this.readPropertyValueReferences(t,r);if(a.length===0)continue;let i=this.readLabelForUri(r)??r.name,c=a.map(l=>this.renderReferenceLink(l,me,n)).join(", ");o.push(`<dt>${f(i)}</dt><dd>${c}</dd>`)}return o.length===0?"":`<dl class="kan-reference-list">${o.join("")}</dl>`}readPropertyValueText(e,t){let n=X(e,t);if(n){if(n instanceof B)return n.object;if(n instanceof U){let s=n.object;return this.readLabelForUri({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name})??s.subject.name}if(n instanceof F)return(n.object??[]).map(o=>o instanceof R?this.readLabelForUri({publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name})??o.subject.name:o instanceof te?o.name??"":String(o)).filter(o=>o).join(", ")}}readPropertyValueReferences(e,t){let n=X(e,t);if(!n)return[];if(n instanceof U)return[n.object];if(n instanceof F){let s=[];for(let o of n.object??[])o instanceof R&&s.push(o);return s}return[]}gatherValueItems(e){return e?e instanceof F?e.object??[]:e instanceof U?[e.object]:e instanceof Z?[e.object]:e instanceof B?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof R?this.renderReferenceLink(e,t,n):e instanceof te?f(e.name??"(embedded)"):typeof e=="string"?f(e):typeof e=="number"||typeof e=="boolean"?f(String(e)):""}renderStatementInlineValue(e,t,n){return e instanceof B?f(e.object):e instanceof U?this.renderReferenceLink(e.object,t,n):e instanceof F?(e.object??[]).map(o=>this.renderInlineValue(o,t,n)).filter(o=>o).join(", "):""}renderReferenceLink(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,o=this.urlForReference(e,t,n);return`<a class="kan-link" href="${f(o)}">${f(s)}</a>`}renderBadge(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,o=this.readCommentForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name}),r=this.urlForReference(e,t,n),a=o?` title="${f(o)}"`:"";return`<a class="kan-badge" href="${f(r)}"${a}>${f(s)}</a>`}urlForReference(e,t,n){let s=t?this.getUrlFormForProperty(t):"=";return ee.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},s,{contextPublisher:n})}getUrlFormForProperty(e){let t=x(this.catalog,e);if(!t)return"=";let n=v(t,_n);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=x(this.catalog,e);if(t)return v(t,H)}readCommentForUri(e){let t=x(this.catalog,e);if(t)return v(t,Ie)}};function be(u){let e=new Map;for(let t of u.statement){if(!(t instanceof Z)||!V(t,he.publisher,he.package_,he.name))continue;let n=t.object;for(let s of n.statement){if(!(s instanceof B))continue;let o=s.predicate?.subject?.name;if(!o)continue;let r=s.object;e.has(o)||e.set(o,r)}}return e}function je(u){for(let e of u.statement)if(e instanceof Z&&V(e,pe.publisher,pe.package_,pe.name))return e.object}function Ne(u){for(let e of u.statement){if(!(e instanceof F)||!V(e,ge.publisher,ge.package_,ge.name))continue;let t=[];for(let n of e.object??[])n instanceof te&&t.push(n);return t}return[]}function Ve(u){for(let e of u.statement)if(e instanceof U&&e.predicate?.subject?.name==="type"&&e.object instanceof R){let t=e.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function K(u,e){for(let t of u.statement)if(t instanceof U&&V(t,e.publisher,e.package_,e.name)&&t.object instanceof R){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function Ae(u,e){for(let t of u.statement){if(!(t instanceof F)||!V(t,e.publisher,e.package_,e.name))continue;let n=[];for(let s of t.object??[])s instanceof R&&n.push({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name});return n}return[]}function X(u,e){for(let t of u.statement)if(V(t,e.publisher,e.package_,e.name))return t}function v(u,e){for(let t of u.statement)if(t instanceof B&&V(t,e.publisher,e.package_,e.name))return t.object}function Me(u,e){for(let t of u.statement)if(t instanceof fe&&V(t,e.publisher,e.package_,e.name))return t.object}function D(u){let e=[];for(let t of u.statement)if(t instanceof U){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof R&&e.push(t.object)}else if(t instanceof F){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof R&&e.push(n)}return e}function ie(u){let e=[];for(let t of u.statement)if(t instanceof U){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof R&&e.push(t.object)}else if(t instanceof F){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof R&&e.push(n)}return e}function ce(u,e){let t=[];for(let n of u){if(!(n instanceof J)||n.name!==e.name)continue;(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&t.push(n)}return t}function x(u,e){let t="version"in e?e.version:void 0;if(t){let n=`${e.publisher}/${e.package_}@${t.major}.${t.minor}.${t.patch}`;for(let s of u)if(s instanceof J&&s.name===e.name&&s.namespace===n)return s}for(let n of u){if(!(n instanceof J)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function V(u,e,t,n){let s=u.predicate?.subject;return s?s.publisher===e&&s.package_===t&&s.name===n:!1}function E(u,e){return u.publisher===e.publisher&&u.package_===e.package_&&u.name===e.name}function z(u){return`${u.publisher}/${u.package_}/${u.name}`}function G(u){let e=u.namespace||"",t=e.indexOf("/");return t>=0?e.substring(0,t):e}function f(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Be(u){let e=u.lastIndexOf(".");return e>=0?u.substring(e+1):u}function He(u,e){for(let t of u.statement)if(t.predicate?.subject?.name===e)return t}function se(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function vn(u){if(!u)return"";let e=/^(\d{4})-(\d{2})-(\d{2})/.exec(u);return e?`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][parseInt(e[2],10)-1]??e[2]} ${parseInt(e[3],10)}`:u}export{Le as a,$e as b};
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as Ze,b as Qe,c as et,d as tt,e as rt,f as nt,g as ot,h as at,i as it,j as st}from"./chunk-2BQ6SOU6.js";import{b as Yt}from"./chunk-Q7OC6YWM.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-REH5YNFQ.js";import{a as qt}from"./chunk-2VCFHCFN.js";import{a as Te,b as je,c as Le,d as Fe,e as Ne}from"./chunk-5AH6GIPO.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-VQFL5C7Q.js";import{a as lt,b as dt,c as ut,d as pt}from"./chunk-IIP6J4EP.js";import{a as Je,b as mt,c as ft,d as yt,e as ht}from"./chunk-4TJZIM7A.js";import{a as gt}from"./chunk-NIGFQYVA.js";import{A as Mt,B as zt,C as Gt,D as Wt,E as Jt,a as kt,b as bt,c as St,d as Ct,e as Pt,f as Rt,g as wt,h as xt,i as $t,j as vt,k as Et,l as Kt,m as Bt,n as It,o as Tt,p as jt,q as Lt,r as Ft,s as Nt,t as Dt,u as Ot,v as At,w as Ut,x as Vt,y as Ht,z as _t}from"./chunk-A2JTW3ON.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as Me,e as We}from"./chunk-4YHWMYAZ.js";import{a as Ue,b as j,c as L,d as N,e as He,f as _e,g as O,h as A,i as U,j as V,k as H,l as _}from"./chunk-W6T7MOKY.js";import{a as Ie}from"./chunk-7CUTGGH3.js";import{a as Pe,b as Re,c as we,d as xe,e as $e,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{b as ze,c as Ge}from"./chunk-5ILSX24H.js";import{a as Ve}from"./chunk-FUUTGGJS.js";import{a as ct}from"./chunk-ODIECDN7.js";import{VersionOperator as oo}from"@kanonak-protocol/types/document/models/enums";import{existsSync as fr,readFileSync as yr}from"fs";import{homedir as gr}from"os";import{join as hr}from"path";import{execFile as Xt}from"child_process";import{promisify as Zt}from"util";var C=Zt(Xt),P="kanonak",R="/usr/bin/security",p=class{async get(e){let r=i(e);try{let{stdout:n}=await C(R,["find-generic-password","-s",P,"-a",r,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${r}' is corrupted (not valid JSON).
1
+ import{a as Ze,b as Qe,c as et,d as tt,e as rt,f as nt,g as ot,h as at,i as it,j as st}from"./chunk-2BQ6SOU6.js";import{b as Yt}from"./chunk-DNV7ES5F.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-REH5YNFQ.js";import{a as qt}from"./chunk-2VCFHCFN.js";import{a as Te,b as je,c as Le,d as Fe,e as Ne}from"./chunk-5AH6GIPO.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-VQFL5C7Q.js";import{a as lt,b as dt,c as ut,d as pt}from"./chunk-IIP6J4EP.js";import{a as Je,b as mt,c as ft,d as yt,e as ht}from"./chunk-4TJZIM7A.js";import{a as gt}from"./chunk-NIGFQYVA.js";import{A as Mt,B as zt,C as Gt,D as Wt,E as Jt,a as kt,b as bt,c as St,d as Ct,e as Pt,f as Rt,g as wt,h as xt,i as $t,j as vt,k as Et,l as Kt,m as Bt,n as It,o as Tt,p as jt,q as Lt,r as Ft,s as Nt,t as Dt,u as Ot,v as At,w as Ut,x as Vt,y as Ht,z as _t}from"./chunk-A2JTW3ON.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as Me,e as We}from"./chunk-4YHWMYAZ.js";import{a as Ue,b as j,c as L,d as N,e as He,f as _e,g as O,h as A,i as U,j as V,k as H,l as _}from"./chunk-W6T7MOKY.js";import{a as Ie}from"./chunk-7CUTGGH3.js";import{a as Pe,b as Re,c as we,d as xe,e as $e,f as ve,g as Ee,h as Ke}from"./chunk-FQHALFRR.js";import{b as ze,c as Ge}from"./chunk-5ILSX24H.js";import{a as Ve}from"./chunk-FUUTGGJS.js";import{a as ct}from"./chunk-ODIECDN7.js";import{VersionOperator as oo}from"@kanonak-protocol/types/document/models/enums";import{existsSync as fr,readFileSync as yr}from"fs";import{homedir as gr}from"os";import{join as hr}from"path";import{execFile as Xt}from"child_process";import{promisify as Zt}from"util";var C=Zt(Xt),P="kanonak",R="/usr/bin/security",p=class{async get(e){let r=i(e);try{let{stdout:n}=await C(R,["find-generic-password","-s",P,"-a",r,"-w"],{timeout:1e4});try{return JSON.parse(n.trim())}catch{throw new Error(`Stored credential for '${r}' is corrupted (not valid JSON).
2
2
  Run 'kanonak logout ${r}' then 'kanonak login ${r}' to fix.`)}}catch(n){if(X(n,44))return null;throw new Error(`macOS Keychain read failed for '${r}': ${w(n)}
3
3
  The Keychain may be locked or inaccessible.
4
4
  Try unlocking it via Keychain Access.app or running 'security unlock-keychain'.`)}}async store(e,r){let n=i(e),o=JSON.stringify(r);try{await C(R,["add-generic-password","-s",P,"-a",n,"-U","-w",o],{timeout:1e4})}catch(a){throw new Error(`macOS Keychain write failed for '${n}': ${w(a)}
@@ -190,7 +190,49 @@ export declare class LookRenderer {
190
190
  * chronological sequence of clickable nodes. Each node links to the
191
191
  * instance's exact-version URL and shows its order value + key.
192
192
  */
193
+ /**
194
+ * Follow a `track` property's referenced sub-resources across a sorted
195
+ * sequence of source instances, aligning them by stable resource key.
196
+ * Returns one TrackedSeries per distinct key, with `points[i]` set to
197
+ * the `metricPath` value resolved on that key's sub-resource in the
198
+ * i-th instance (null when absent / unresolvable). The optional `hueBy`
199
+ * path supplies each series' hue. Shared by the Timeline trajectory
200
+ * chart and the VersionDiff trend rows.
201
+ */
202
+ private collectTrackedSeries;
203
+ /**
204
+ * Build a resource URL from a parsed SubjectKanonak (namespace
205
+ * `publisher/package@version`), applying the given URL form.
206
+ */
207
+ private hrefForSubject;
208
+ /**
209
+ * Render a VersionDiff band — the "Changes" trend rows. Same inputs as
210
+ * the Timeline trajectory mode (`source` + `orderBy` + `track` +
211
+ * `metricPath`, optional `hueBy`), but one compact row per tracked key:
212
+ * the (linked) label, the first value, a small autoscaled sparkline of
213
+ * the metric across the version sequence, the latest value, and a
214
+ * total-change delta badge (latest − first).
215
+ */
216
+ private renderVersionDiff;
217
+ /**
218
+ * A small inline-SVG sparkline for one series, autoscaled to the
219
+ * series' own [min,max] so small moves are visible. Flat series render
220
+ * a centered baseline. Nulls break the line.
221
+ */
222
+ private sparkline;
193
223
  private renderTimeline;
224
+ /**
225
+ * Render the Timeline trajectory chart — a server-rendered inline SVG with
226
+ * one line per tracked sub-resource (aligned by stable key) across the
227
+ * version sequence, plus an HTML legend reporting each series' latest
228
+ * value and its change from the first version. Ontology-neutral: the Y
229
+ * axis autoscales to the data unless the band declares `axisMin`/
230
+ * `axisMax`; the legend value carries an optional `valueLabel` prefix;
231
+ * and when the band declares `lowerPath`/`upperPath`, a shaded envelope
232
+ * is drawn between those two metric paths per series. Each series is
233
+ * themed by `hueBy` when present, else by an evenly spaced palette.
234
+ */
235
+ private renderTrajectoryChart;
194
236
  /**
195
237
  * Render a ResourceGrid band — enumerates every instance of the class
196
238
  * named by `look.source` and emits a grid of cards. Each card shows
@@ -1,4 +1,4 @@
1
- import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as X,b as ye}from"../chunk-Q7OC6YWM.js";import{a as Oe}from"../chunk-2VCFHCFN.js";import"../chunk-IIP6J4EP.js";import"../chunk-NIGFQYVA.js";import{a as Ue}from"../chunk-FJ35VIV6.js";import{a as C,c as Re,e as Ce}from"../chunk-4YHWMYAZ.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import{a as Le}from"../chunk-7CUTGGH3.js";import"../chunk-5ILSX24H.js";import"../chunk-FUUTGGJS.js";var gt="kanonak.org",yt="document-ast",m=t=>({publisher:gt,package_:yt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ne(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=kt(e.metadata,n),a=wt(e.children),u=["---",...r,"---","",a].join(`
1
+ import{b as E,c as F,d as f,f as M}from"../chunk-2JQMUZWN.js";import{a as X,b as ye}from"../chunk-DNV7ES5F.js";import{a as Oe}from"../chunk-2VCFHCFN.js";import"../chunk-IIP6J4EP.js";import"../chunk-NIGFQYVA.js";import{a as Ue}from"../chunk-FJ35VIV6.js";import{a as C,c as Re,e as Ce}from"../chunk-4YHWMYAZ.js";import{b as K,c as w,d as b,g as L,h as U,i as O,j,k as T,l as S}from"../chunk-W6T7MOKY.js";import{a as Le}from"../chunk-7CUTGGH3.js";import"../chunk-5ILSX24H.js";import"../chunk-FUUTGGJS.js";var gt="kanonak.org",yt="document-ast",m=t=>({publisher:gt,package_:yt,name:t}),k={Document:m("Document"),Block:m("Block"),Inline:m("Inline"),StructuredValue:m("StructuredValue"),Heading:m("Heading"),Paragraph:m("Paragraph"),RawBlock:m("RawBlock"),Text:m("Text"),StructuredMap:m("StructuredMap"),StructuredEntry:m("StructuredEntry"),StructuredList:m("StructuredList"),StringScalar:m("StringScalar"),IntegerScalar:m("IntegerScalar"),EscapeHint:m("EscapeHint"),MediaType:m("MediaType"),metadata:m("metadata"),children:m("children"),level:m("level"),inlines:m("inlines"),text:m("text"),entries:m("entries"),key:m("key"),value:m("value"),escapeHint:m("escapeHint"),items:m("items"),stringValue:m("stringValue"),integerValue:m("integerValue"),rawContent:m("rawContent"),mediaType:m("mediaType"),mimeType:m("mimeType"),ESC_RAW:m("esc-raw"),ESC_YAML_SAFE:m("esc-yaml-safe"),ESC_TOML_STRING:m("esc-toml-string"),ESC_TOML_MULTILINE:m("esc-toml-multiline"),ESC_JSON:m("esc-json"),ESC_DYNAMODB_BOOL:m("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:m("esc-dynamodb-number"),ESC_DYNAMODB_NULL:m("esc-dynamodb-null"),TEXT_PLAIN:m("text-plain"),TEXT_MARKDOWN:m("text-markdown"),TEXT_HTML:m("text-html"),TEXT_CSS:m("text-css"),APPLICATION_JSON:m("application-json"),TEXT_YAML:m("text-yaml"),IMAGE_SVG_XML:m("image-svg-xml"),ResourceLink:m("ResourceLink"),target:m("target"),linkLabel:m("linkLabel"),PropertyList:m("PropertyList"),propertyEntries:m("propertyEntries"),PropertyEntry:m("PropertyEntry"),propertyKey:m("propertyKey"),propertyValue:m("propertyValue"),Table:m("Table"),tableColumnLabels:m("tableColumnLabels"),tableRows:m("tableRows"),TableRow:m("TableRow"),tableCells:m("tableCells")};function Ne(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=kt(e.metadata,n),a=wt(e.children),u=["---",...r,"---","",a].join(`
2
2
  `);return n?.trailingNewline&&(u.endsWith(`
3
3
  `)||(u+=`
4
4
  `)),u}};function kt(t,e){if(!t)return[];let n=new Map;for(let c of t.entries)n.set(ue(c.key),c);let r=new Map;if(e?.metadataRenames)for(let[c,l]of e.metadataRenames)r.set(ue(c),l);let i=(e?.metadataKeys??t.entries.map(c=>c.key)).map(ue),u=[];for(let c of i){let l=n.get(c);if(!l)continue;let p=r.get(c),y=ue(p??c),h=Ie(l.value,l.escapeHint);h!==void 0&&u.push(`${y}: ${h}`)}return u}function ue(t){let e=t.lastIndexOf(".");return e===-1?t:t.substring(e+1)||t}function Ie(t,e){switch(t.kind){case"StringScalar":return ht(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let a=Ie(r,e);a!==void 0&&n.push(a)}return n.join(", ")}case"StructuredMap":return;default:return}}function ht(t,e){return!e||Ne(e,k.ESC_RAW)?t:Ne(e,k.ESC_YAML_SAFE)?bt(t):t}function bt(t){return t.includes(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/sdk",
3
- "version": "3.29.11",
3
+ "version": "3.31.0",
4
4
  "description": "Kanonak Protocol SDK - Document repository and parsing implementations for TypeScript",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -113,7 +113,7 @@
113
113
  "yaml-parser"
114
114
  ],
115
115
  "dependencies": {
116
- "@kanonak-protocol/types": "^3.29.11",
116
+ "@kanonak-protocol/types": "^3.31.0",
117
117
  "ignore": "^7.0.5",
118
118
  "js-yaml": "^4.1.0",
119
119
  "yaml": "^2.7.0"
@@ -1,116 +0,0 @@
1
- import{a as V}from"./chunk-NIGFQYVA.js";import{a as N}from"./chunk-4YHWMYAZ.js";import{c as U,d as g,g as L,h as Z,i as ee,j as h,k as P,l as b}from"./chunk-W6T7MOKY.js";function te(u){let e=u.replace(/\r\n/g,`
2
- `).split(`
3
- `),t=[],n=0;for(;n<e.length;){let s=e[n];if(s.trim()===""){n++;continue}let a=/^(\s*)```(\S*)\s*$/.exec(s);if(a){let c=a[2],i=[];for(n++;n<e.length&&!/^(\s*)```\s*$/.test(e[n]);)i.push(e[n]),n++;n++;let l=se(i.join(`
4
- `)),p=c?` class="language-${re(c)}"`:"";t.push(`<pre><code${p}>${l}</code></pre>`);continue}let r=/^(#{1,6})\s+(.*)$/.exec(s);if(r){let c=r[1].length,i=F(r[2].trim());t.push(`<h${c}>${i}</h${c}>`),n++;continue}if(s.includes("|")&&n+1<e.length&&ne(e[n+1])){let c=H(s),i=ge(e[n+1]);n+=2;let l=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)l.push(H(e[n])),n++;t.push(he(c,i,l));continue}if(/^\s*[-*]\s+/.test(s)){let c=[];for(;n<e.length&&/^\s*[-*]\s+/.test(e[n]);){let i=[e[n].replace(/^\s*[-*]\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n]);)i.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,c.push(`<li>${F(i.join(" ").trim())}</li>`)}t.push(`<ul>
5
- ${c.join(`
6
- `)}
7
- </ul>`);continue}if(/^\s*\d+\.\s+/.test(s)){let c=[];for(;n<e.length&&/^\s*\d+\.\s+/.test(e[n]);){let i=[e[n].replace(/^\s*\d+\.\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*\d+\.\s+/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n]);)i.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,c.push(`<li>${F(i.join(" ").trim())}</li>`)}t.push(`<ol>
8
- ${c.join(`
9
- `)}
10
- </ol>`);continue}let o=[s];for(n++;n<e.length&&e[n].trim()!==""&&!/^(#{1,6})\s+/.test(e[n])&&!/^(\s*)```/.test(e[n])&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n])&&!(e[n].includes("|")&&n+1<e.length&&ne(e[n+1]));)o.push(e[n]),n++;t.push(`<p>${F(o.join(" "))}</p>`)}return t.join(`
11
- `)}function ne(u){return u.includes("-")?/^[\s|:-]+$/.test(u):!1}function H(u){let e=u.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|").map(t=>t.trim())}function ge(u){return H(u).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function he(u,e,t){let n=r=>{let o=e[r];return o?` style="text-align:${o}"`:""},s=u.map((r,o)=>`<th${n(o)}>${F(r)}</th>`).join(""),a=t.map(r=>`<tr>${r.map((c,i)=>`<td${n(i)}>${F(c)}</td>`).join("")}</tr>`).join(`
12
- `);return`<table>
13
- <thead><tr>${s}</tr></thead>
14
- <tbody>
15
- ${a}
16
- </tbody>
17
- </table>`}function F(u){let e=se(u);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,s)=>`<a href="${re(s)}">${n}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(t,n)=>`<strong>${n}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(t,n,s)=>`${n}<em>${s}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(t,n,s)=>`${n}<em>${s}</em>`),e}function se(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function re(u){return u.replace(/"/g,"&quot;").replace(/&/g,"&amp;")}var M={publisher:"kanonak.org",package_:"derivation",name:"look"},D={publisher:"kanonak.org",package_:"derivation",name:"tokens"},$={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},w={publisher:"kanonak.org",package_:"core-rdf",name:"label"},ae={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},ke={publisher:"kanonak.org",package_:"look",name:"Hero"},me={publisher:"kanonak.org",package_:"look",name:"PropertyList"},be={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},je={publisher:"kanonak.org",package_:"look",name:"ChipRow"},_e={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},oe={publisher:"kanonak.org",package_:"look",name:"Markdown"},B={publisher:"kanonak.org",package_:"look",name:"NavGroup"},W={publisher:"kanonak.org",package_:"look",name:"NavLink"},ie={publisher:"kanonak.org",package_:"look",name:"target"},Re={publisher:"kanonak.org",package_:"look",name:"ResourceGrid"},$e={publisher:"kanonak.org",package_:"look",name:"Timeline"},ve={publisher:"kanonak.org",package_:"look",name:"orderBy"};var Ke={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},ye={publisher:"kanonak.org",package_:"look",name:"tierChip"},Se={publisher:"kanonak.org",package_:"look",name:"tierIcon"},Le={publisher:"kanonak.org",package_:"look",name:"tierCard"},Oe={publisher:"kanonak.org",package_:"look",name:"tierFull"};var q={publisher:"kanonak.org",package_:"look",name:"bands"},Ie={publisher:"kanonak.org",package_:"look",name:"title"},Ue={publisher:"kanonak.org",package_:"look",name:"eyebrow"},we={publisher:"kanonak.org",package_:"look",name:"subtitle"},ce={publisher:"kanonak.org",package_:"look",name:"badges"},O={publisher:"kanonak.org",package_:"look",name:"source"},Ee={publisher:"kanonak.org",package_:"look",name:"chips"},Y={publisher:"kanonak.org",package_:"look",name:"entries"},Ce={publisher:"kanonak.org",package_:"look",name:"urlForm"},X=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let t=J(e);if(t)return{declaration:t,sourceClass:{publisher:T(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}};let n=new Set,s=I(e);for(;s.length>0;){let a=s.shift(),r=C(a.subject);if(n.has(r))continue;n.add(r);let o=m(this.catalog,a.subject);if(!o)continue;let c=J(o);if(c)return{declaration:c,sourceClass:{publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name}};for(let i of x(o))s.push(i)}if(!n.has(C($))){let a=m(this.catalog,$);if(a){let r=J(a);if(r)return{declaration:r,sourceClass:{...$}}}}}findCascadedTokens(e){let t=new Map;for(let[a,r]of z(e))t.has(a)||t.set(a,r);let n=new Set,s=I(e);for(;s.length>0;){let a=s.shift(),r=C(a.subject);if(n.has(r))continue;n.add(r);let o=A(this.catalog,a.subject);if(o.length!==0)for(let c of o){for(let[i,l]of z(c))t.has(i)||t.set(i,l);for(let i of x(c))s.push(i)}}if(!n.has(C($))){let a=A(this.catalog,$);for(let r of a)for(let[o,c]of z(r))t.has(o)||t.set(o,c)}return t}renderSvg(e){let t=k(e,w)??e.name,n=(t.trim().charAt(0)||"?").toUpperCase(),s=`${e.namespace??""}/${e.name}`,a={label:t,firstLetter:n,uri:s},r=this.collectCascadedSvgTiers(e),o=R=>this.applyPlaceholders(R,e,a),c=o(r.tierChip??""),i=o(r.tierIcon??""),l=o(r.tierCard??""),p=o(r.tierFull??""),_=[...this.findCascadedTokens(e)].map(([R,K])=>`--kan-${R}: ${K};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400" style="${Q(_)}">
18
- <style>
19
- .tier-chip,.tier-icon,.tier-card{display:none}
20
- .tier-full{display:block}
21
- @media (max-width:400px){.tier-full{display:none}.tier-card{display:block}}
22
- @media (max-width:160px){.tier-card{display:none}.tier-icon{display:block}}
23
- @media (max-width:60px){.tier-icon{display:none}.tier-chip{display:block}}
24
- </style>
25
- <g class="tier-chip">${c}</g>
26
- <g class="tier-icon">${i}</g>
27
- <g class="tier-card">${l}</g>
28
- <g class="tier-full">${p}</g>
29
- </svg>`}applyPlaceholders(e,t,n){return e.replace(/\{\{([^}]+)\}\}/g,(s,a)=>{let r=a.trim();if(n[r]!==void 0)return Q(n[r]);let o=this.resolvePath(t,r);return o===void 0?`{{${r}}}`:Q(o)})}resolvePath(e,t){let n=t.split("/").map(o=>o.trim()).filter(o=>o.length>0);if(n.length===0)return;let s=e;for(let o=0;o<n.length-1;o++){if(!s)return;let c=pe(n[o]),i=de(s,c);if(!i)return;if(i instanceof h&&i.object instanceof g){let l=m(this.catalog,i.object.subject);if(!l)return;s=l}else if(i instanceof P)s=i.object;else return}if(!s)return;let a=pe(n[n.length-1]),r=de(s,a);if(r){if(r instanceof L||r instanceof Z||r instanceof ee)return String(r.object);if(r instanceof h&&r.object instanceof g){let o=r.object,c=m(this.catalog,o.subject);return c?k(c,w)??o.subject.name:o.subject.name}}}collectCascadedSvgTiers(e){let t={},n=r=>{let o=E(r,Ke);if(!(o instanceof P))return;let c=o.object,i=k(c,ye),l=k(c,Se),p=k(c,Le),d=k(c,Oe);t.tierChip===void 0&&i!==void 0&&(t.tierChip=i),t.tierIcon===void 0&&l!==void 0&&(t.tierIcon=l),t.tierCard===void 0&&p!==void 0&&(t.tierCard=p),t.tierFull===void 0&&d!==void 0&&(t.tierFull=d)};n(e);let s=new Set,a=I(e);for(;a.length>0;){let r=a.shift(),o=C(r.subject);if(s.has(o))continue;s.add(o);let c=A(this.catalog,r.subject);for(let i of c){n(i);for(let l of x(i))a.push(l)}}if(!s.has(C($)))for(let r of A(this.catalog,$))n(r);return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[r,o]of t)n.push(` --kan-${r}: ${o};`);let s=n.length>0?`:root {
30
- ${n.join(`
31
- `)}
32
- }`:":root { /* no tokens resolved */ }",a=this.findBaseStylesheet(T(e))??"";return`${s}
33
- ${a}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,s;for(let r of this.catalog){if(!(r instanceof U)||r.name!=="base-stylesheet")continue;let o=r.namespace||"";o.startsWith(`${e}/look-styles@`)?n=r:o.startsWith("kanonak.org/look-styles@")&&(s=r)}let a=n??s;if(a)for(let r of a.statement){let o=r.predicate?.subject;if(!o)continue;if(`${o.publisher}/${o.package_}/${o.name}`===t&&r instanceof L)return r.object}}renderHtml(e){let t=this.findCascadedLook(e);if(!t)return`<!-- LookRenderer: no derivation.look found for ${e.namespace}/${e.name} -->`;let n=ue(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let s=T(e),a=[];for(let r of n)a.push(this.renderBand(r,e,s));return a.join(`
34
- `)}renderPublisherIndex(e,t,n){let s=n?this.renderNavGroup(n,e):"",a=t.map(o=>{let c=o.comment?`<p class="kan-resource-card-subtitle">${f(o.comment)}</p>`:"";return`<a class="kan-resource-card" href="${f(o.href)}"><h3 class="kan-resource-card-title">${f(o.label)}</h3>${c}</a>`}).join(`
35
- `),r=`<header class="kan-hero">
36
- <h1 class="kan-hero-title">${f(e)}</h1>
37
- </header>
38
- <section class="kan-resource-grid">
39
- ${a}
40
- </section>`;return`<!doctype html>
41
- <html lang="en">
42
- <head>
43
- <meta charset="utf-8">
44
- <meta name="viewport" content="width=device-width, initial-scale=1">
45
- <title>${f(e)}</title>
46
- <link rel="stylesheet" href="index.css">
47
- </head>
48
- <body>
49
- ${s}
50
- <main class="kan-main">
51
- ${r}
52
- </main>
53
- </body>
54
- </html>
55
- `}renderPublisherIndexStylesheet(e){return e?this.renderStylesheet(e):""}hasDeclaredView(e){let t=this.findCascadedLook(e);return t?!(t.sourceClass.publisher===$.publisher&&t.sourceClass.package_===$.package_&&t.sourceClass.name===$.name):!1}renderPackageVersionList(e,t,n){let s=T(n),a=this.renderNavGroup(n,s),r=this.renderBreadcrumb(n,s,{bareOverview:!0}),o=t.map(i=>`<a class="kan-resource-card" href="/${f(e)}/${f(i)}/"><h3 class="kan-resource-card-title">${f(i)}</h3></a>`).join(`
56
- `),c=`<header class="kan-hero">
57
- <span class="kan-hero-eyebrow">PACKAGE</span>
58
- <h1 class="kan-hero-title">${f(e)}</h1>
59
- </header>
60
- <section class="kan-resource-grid">
61
- ${o}
62
- </section>`;return`<!doctype html>
63
- <html lang="en">
64
- <head>
65
- <meta charset="utf-8">
66
- <meta name="viewport" content="width=device-width, initial-scale=1">
67
- <title>${f(e)}</title>
68
- <link rel="stylesheet" href="${f(n.name)}.css">
69
- </head>
70
- <body>
71
- ${a}
72
- ${r}
73
- <main class="kan-main">
74
- ${c}
75
- </main>
76
- </body>
77
- </html>
78
- `}renderDocument(e,t){let n=this.renderHtml(e),s=this.readPropertyValueText(e,w)??e.name,a=`${e.name}.css`,r=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${f(e.name)}.svg" alt=""></figure>
79
- `:"",o=T(e),c=this.renderNavGroup(e,o),i=this.renderBreadcrumb(e,o,t);return`<!doctype html>
80
- <html lang="en">
81
- <head>
82
- <meta charset="utf-8">
83
- <meta name="viewport" content="width=device-width, initial-scale=1">
84
- <title>${f(s)}</title>
85
- <link rel="stylesheet" href="${f(a)}">
86
- </head>
87
- <body>
88
- ${c}
89
- ${i}
90
- <main class="kan-main">
91
- ${r}${n}
92
- </main>
93
- </body>
94
- </html>
95
- `}hasSvgDerivation(e){let t=new Set,n=I(e);for(;n.length>0;){let s=n.shift(),a=C(s.subject);if(t.has(a))continue;t.add(a);let r=m(this.catalog,s.subject);if(r){for(let o of r.statement)if(o instanceof b&&S(o,"kanonak.org","derivation","derivations")){for(let c of o.object??[])if(c instanceof N)for(let i of c.statement){if(!(i instanceof h)||!S(i,"kanonak.org","derivation","format")||!(i.object instanceof g))continue;let l=i.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let o of x(r))n.push(o)}}return!1}renderBand(e,t,n){let s=le(e);return s?v(s,ke)?this.renderHero(e,t,n):v(s,me)?this.renderPropertyList(e,t,n):v(s,be)?this.renderBadgeRow(e,t,n):v(s,je)?this.renderChipRow(e,t,n):v(s,_e)?this.renderReferenceList(e,t,n):v(s,oe)?this.renderMarkdown(e,t):v(s,B)?this.renderNavGroup(t,n):v(s,Re)?this.renderResourceGrid(e,n,t):v(s,$e)?this.renderTimeline(e,n):`<!-- LookRenderer: unsupported band ${s.publisher}/${s.package_}/${s.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}renderTimeline(e,t){let n=j(e,O);if(!n)return"<!-- LookRenderer.Timeline: no look.source -->";let s=j(e,ve),a=this.findInstancesOfClass(n);if(a.length===0)return"<!-- LookRenderer.Timeline: no instances -->";let r=i=>s?this.readPropertyValueText(i,s)??"":"";return`<section class="kan-timeline"><ol>
96
- ${a.slice().sort((i,l)=>r(i).localeCompare(r(l))).map(i=>{let l=i.namespace||"",p=l.split("/")[1]?.split("@")[0]??"",d=l.split("@")[1]??"",_=d?this.parseVersion(d):void 0,R=V.formatResourceUrl({publisher:T(i),package_:p,name:i.name,..._?{version:_}:{}},"=",{contextPublisher:t}),K=r(i),y=K?`<span class="kan-timeline-date">${f(K)}</span>`:"",G=d||i.name;return`<li class="kan-timeline-node"><a href="${f(R)}"><span class="kan-timeline-key">${f(G)}</span>${y}</a></li>`}).join(`
97
- `)}
98
- </ol></section>`}renderResourceGrid(e,t,n){let s=j(e,O);if(!s)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let a=m(this.catalog,s),r=a?I(a).some(i=>{let l=i.subject.name;return l==="ObjectProperty"||l==="DatatypeProperty"||l==="Property"}):!1,o=[];if(r&&n){let i=this.readPropertyValueReferences(n,s);for(let l of i){let p=m(this.catalog,{publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name,...l.subject.version?{version:l.subject.version}:{}});p&&o.push(p)}}else o=this.findInstancesOfClass(s);if(o.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${s.publisher}/${s.package_}/${s.name} -->`;let c=[];for(let i of o){let l=k(i,w)??i.name,p=k(i,ae),d=i.namespace||"",_=d.split("/")[1]?.split("@")[0]??"",R=d.split("@")[1]??"",K=R?this.parseVersion(R):void 0,y=V.formatResourceUrl({publisher:T(i),package_:_,name:i.name,...K?{version:K}:{}},"=",{contextPublisher:t}),G=p?`<p class="kan-resource-card-subtitle">${f(p)}</p>`:"";c.push(`<a class="kan-resource-card" href="${f(y)}"><h3 class="kan-resource-card-title">${f(l)}</h3>${G}</a>`)}return`<section class="kan-resource-grid">
99
- ${c.join(`
100
- `)}
101
- </section>`}parseVersion(e){let t=e.split(".").map(Number);if(!(t.length!==3||t.some(n=>Number.isNaN(n))))return{major:t[0],minor:t[1],patch:t[2]}}findInstancesOfClass(e){let t=[];for(let n of this.catalog){if(!(n instanceof U))continue;I(n).map(r=>r.subject).some(r=>r.publisher===e.publisher&&r.package_===e.package_&&r.name===e.name)&&t.push(n)}return t}renderBreadcrumb(e,t,n){let a=(e.namespace||"").split("/");if(a.length<2)return"";let r=a[0],o=a[1]??"",c=o.split("@")[0]??"",i=o.split("@")[1]??"";if(!r||!c)return"";if(n?.bareOverview)return`<nav class="kan-breadcrumb"><ol>
102
- <li><a href="/">${f(r)}</a></li>
103
- <li aria-current="page">${f(c)}</li>
104
- </ol></nav>`;let l=e.name,d=!!m(this.catalog,{publisher:r,package_:c,name:c}),_=i?`${c}@${i}`:c,R=i?`/${c}/${i}/${c}`:`/${c}/${c}`,K=e.name===c,y=[];return y.push(`<li><a href="/">${f(r)}</a></li>`),K?y.push(`<li aria-current="page">${f(_)}</li>`):(y.push(d?`<li><a href="${f(R)}">${f(_)}</a></li>`:`<li>${f(_)}</li>`),y.push(`<li aria-current="page">${f(l)}</li>`)),`<nav class="kan-breadcrumb"><ol>
105
- ${y.join(`
106
- `)}
107
- </ol></nav>`}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let s=E(n,Y);if(!(s instanceof b))return"";let a=s.object??[];if(a.length===0)return"";let r=[];for(let o of a){if(!(o instanceof g))continue;let c=m(this.catalog,{publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name}),{href:i,label:l}=this.resolveNavEntry(o,c,t),p=`/${e.namespace?.split("/")[1]?.split("@")[0]}/${(e.namespace||"").split("@")[1]}/${e.name}`,d=i===p?' aria-current="page"':"";r.push(`<li><a class="kan-nav-link" href="${f(i)}"${d}>${f(l)}</a></li>`)}return`<nav class="kan-site-nav"><ul>
108
- ${r.join(`
109
- `)}
110
- </ul></nav>`}resolveNavEntry(e,t,n){if(t&&I(t).map(c=>c.subject).some(c=>c.publisher===W.publisher&&c.package_===W.package_&&c.name===W.name)){let c=k(t,w),i=E(t,ie);if(i instanceof h&&i.object instanceof g){let l=i.object,p=this.readLabelForUri({publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name});return{href:this.urlForReference(l,ie,n),label:c??p??l.subject.name}}}let s=V.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),a=t?k(t,w)??e.subject.name:e.subject.name;return{href:s,label:a}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof U)||!(t.namespace||"").startsWith(`${e}/`))continue;if(I(t).map(r=>r.subject).some(r=>r.publisher===B.publisher&&r.package_===B.package_&&r.name===B.name))return t}}renderMarkdown(e,t){let n=j(e,O);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let s=this.readPropertyValueText(t,n);return s?`<section class="kan-markdown">
111
- ${te(s)}
112
- </section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=ue(t.declaration),s=[];for(let a of n){let r=le(a);if(!r||!v(r,oe))continue;let o=j(a,O);if(!o)continue;let c=this.readPropertyValueText(e,o);c&&s.push(c)}return s.length>0?s.join(`
113
-
114
- `):void 0}renderHero(e,t,n){let s=['<header class="kan-hero">'],a=j(e,Ue);if(a){let l=this.readPropertyValueText(t,a);l&&s.push(`<span class="kan-hero-eyebrow">${f(l)}</span>`)}let r=j(e,Ie),o="";r&&(o=this.readPropertyValueText(t,r)??""),o||(o=t.name),s.push(`<h1 class="kan-hero-title">${f(o)}</h1>`);let c=j(e,we);if(c){let l=this.readPropertyValueText(t,c);l&&s.push(`<p class="kan-hero-subtitle">${f(l)}</p>`)}let i=j(e,ce);if(i){let l=this.readPropertyValueReferences(t,i);if(l.length>0){let p=l.map(d=>this.renderBadge(d,ce,n)).join("");s.push(`<div class="kan-hero-badges">${p}</div>`)}}return s.push("</header>"),s.join(`
115
- `)}renderPropertyList(e,t,n){let s=j(e,O);if(!s)return"<!-- LookRenderer: PropertyList missing look.source -->";let a=this.readLabelForUri(s)??s.name,r=E(t,s),o=this.gatherValueItems(r),c=o.length>0?o.map(i=>`<li>${this.renderInlineValue(i,O,n)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${f(a)}</h3>`,`<ul class="kan-property-list-items">${c}</ul>`,"</section>"].join(`
116
- `)}renderBadgeRow(e,t,n){let s=j(e,O);if(!s)return"<!-- LookRenderer: BadgeRow missing look.source -->";let a=this.readPropertyValueReferences(t,s);return a.length===0?"":`<div class="kan-badge-row">${a.map(o=>this.renderBadge(o,O,n)).join("")}</div>`}renderChipRow(e,t,n){let s=fe(e,Ee);if(s.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let a=[];for(let r of s){let o=E(t,r);if(!o)continue;let c=this.readLabelForUri(r)??r.name,i=this.renderStatementInlineValue(o,r,n);i&&a.push(`<span class="kan-chip"><span class="kan-chip-key">${f(c)}</span> <span class="kan-chip-val">${i}</span></span>`)}return a.length===0?"":`<div class="kan-chip-row">${a.join("")}</div>`}renderReferenceList(e,t,n){let s=fe(e,Y);if(s.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let a=[];for(let r of s){let o=this.readPropertyValueReferences(t,r);if(o.length===0)continue;let c=this.readLabelForUri(r)??r.name,i=o.map(l=>this.renderReferenceLink(l,Y,n)).join(", ");a.push(`<dt>${f(c)}</dt><dd>${i}</dd>`)}return a.length===0?"":`<dl class="kan-reference-list">${a.join("")}</dl>`}readPropertyValueText(e,t){let n=E(e,t);if(n){if(n instanceof L)return n.object;if(n instanceof h){let s=n.object;return this.readLabelForUri({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name})??s.subject.name}if(n instanceof b)return(n.object??[]).map(a=>a instanceof g?this.readLabelForUri({publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name})??a.subject.name:a instanceof N?a.name??"":String(a)).filter(a=>a).join(", ")}}readPropertyValueReferences(e,t){let n=E(e,t);if(!n)return[];if(n instanceof h)return[n.object];if(n instanceof b){let s=[];for(let a of n.object??[])a instanceof g&&s.push(a);return s}return[]}gatherValueItems(e){return e?e instanceof b?e.object??[]:e instanceof h?[e.object]:e instanceof P?[e.object]:e instanceof L?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof g?this.renderReferenceLink(e,t,n):e instanceof N?f(e.name??"(embedded)"):typeof e=="string"?f(e):typeof e=="number"||typeof e=="boolean"?f(String(e)):""}renderStatementInlineValue(e,t,n){return e instanceof L?f(e.object):e instanceof h?this.renderReferenceLink(e.object,t,n):e instanceof b?(e.object??[]).map(a=>this.renderInlineValue(a,t,n)).filter(a=>a).join(", "):""}renderReferenceLink(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,a=this.urlForReference(e,t,n);return`<a class="kan-link" href="${f(a)}">${f(s)}</a>`}renderBadge(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,a=this.readCommentForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name}),r=this.urlForReference(e,t,n),o=a?` title="${f(a)}"`:"";return`<a class="kan-badge" href="${f(r)}"${o}>${f(s)}</a>`}urlForReference(e,t,n){let s=t?this.getUrlFormForProperty(t):"=";return V.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},s,{contextPublisher:n})}getUrlFormForProperty(e){let t=m(this.catalog,e);if(!t)return"=";let n=k(t,Ce);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=m(this.catalog,e);if(t)return k(t,w)}readCommentForUri(e){let t=m(this.catalog,e);if(t)return k(t,ae)}};function z(u){let e=new Map;for(let t of u.statement){if(!(t instanceof P)||!S(t,D.publisher,D.package_,D.name))continue;let n=t.object;for(let s of n.statement){if(!(s instanceof L))continue;let a=s.predicate?.subject?.name;if(!a)continue;let r=s.object;e.has(a)||e.set(a,r)}}return e}function J(u){for(let e of u.statement)if(e instanceof P&&S(e,M.publisher,M.package_,M.name))return e.object}function ue(u){for(let e of u.statement){if(!(e instanceof b)||!S(e,q.publisher,q.package_,q.name))continue;let t=[];for(let n of e.object??[])n instanceof N&&t.push(n);return t}return[]}function le(u){for(let e of u.statement)if(e instanceof h&&e.predicate?.subject?.name==="type"&&e.object instanceof g){let t=e.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function j(u,e){for(let t of u.statement)if(t instanceof h&&S(t,e.publisher,e.package_,e.name)&&t.object instanceof g){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function fe(u,e){for(let t of u.statement){if(!(t instanceof b)||!S(t,e.publisher,e.package_,e.name))continue;let n=[];for(let s of t.object??[])s instanceof g&&n.push({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name});return n}return[]}function E(u,e){for(let t of u.statement)if(S(t,e.publisher,e.package_,e.name))return t}function k(u,e){for(let t of u.statement)if(t instanceof L&&S(t,e.publisher,e.package_,e.name))return t.object}function I(u){let e=[];for(let t of u.statement)if(t instanceof h){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof g&&e.push(t.object)}else if(t instanceof b){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof g&&e.push(n)}return e}function x(u){let e=[];for(let t of u.statement)if(t instanceof h){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof g&&e.push(t.object)}else if(t instanceof b){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof g&&e.push(n)}return e}function A(u,e){let t=[];for(let n of u){if(!(n instanceof U)||n.name!==e.name)continue;(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&t.push(n)}return t}function m(u,e){let t="version"in e?e.version:void 0;if(t){let n=`${e.publisher}/${e.package_}@${t.major}.${t.minor}.${t.patch}`;for(let s of u)if(s instanceof U&&s.name===e.name&&s.namespace===n)return s}for(let n of u){if(!(n instanceof U)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function S(u,e,t,n){let s=u.predicate?.subject;return s?s.publisher===e&&s.package_===t&&s.name===n:!1}function v(u,e){return u.publisher===e.publisher&&u.package_===e.package_&&u.name===e.name}function C(u){return`${u.publisher}/${u.package_}/${u.name}`}function T(u){let e=u.namespace||"",t=e.indexOf("/");return t>=0?e.substring(0,t):e}function f(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function pe(u){let e=u.lastIndexOf(".");return e>=0?u.substring(e+1):u}function de(u,e){for(let t of u.statement)if(t.predicate?.subject?.name===e)return t}function Q(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}export{te as a,X as b};