@kanonak-protocol/sdk 3.28.4 → 3.28.6

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,62 @@
1
+ import{a as F}from"./chunk-NIGFQYVA.js";import{a as w}from"./chunk-QIIQ4G2Q.js";import{c as K,d,g as $,j as h,k as E,l as m}from"./chunk-W6T7MOKY.js";function X(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 r=/^(\s*)```(\S*)\s*$/.exec(s);if(r){let c=r[2],i=[];for(n++;n<e.length&&!/^(\s*)```\s*$/.test(e[n]);)i.push(e[n]),n++;n++;let l=Z(i.join(`
4
+ `)),p=c?` class="language-${ee(c)}"`:"";t.push(`<pre><code${p}>${l}</code></pre>`);continue}let o=/^(#{1,6})\s+(.*)$/.exec(s);if(o){let c=o[1].length,i=I(o[2].trim());t.push(`<h${c}>${i}</h${c}>`),n++;continue}if(s.includes("|")&&n+1<e.length&&Q(e[n+1])){let c=B(s),i=fe(e[n+1]);n+=2;let l=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)l.push(B(e[n])),n++;t.push(pe(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>${I(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>${I(i.join(" ").trim())}</li>`)}t.push(`<ol>
8
+ ${c.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&&Q(e[n+1]));)a.push(e[n]),n++;t.push(`<p>${I(a.join(" "))}</p>`)}return t.join(`
11
+ `)}function Q(u){return u.includes("-")?/^[\s|:-]+$/.test(u):!1}function B(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 fe(u){return B(u).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function pe(u,e,t){let n=o=>{let a=e[o];return a?` style="text-align:${a}"`:""},s=u.map((o,a)=>`<th${n(a)}>${I(o)}</th>`).join(""),r=t.map(o=>`<tr>${o.map((c,i)=>`<td${n(i)}>${I(c)}</td>`).join("")}</tr>`).join(`
12
+ `);return`<table>
13
+ <thead><tr>${s}</tr></thead>
14
+ <tbody>
15
+ ${r}
16
+ </tbody>
17
+ </table>`}function I(u){let e=Z(u);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,s)=>`<a href="${ee(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 Z(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ee(u){return u.replace(/"/g,"&quot;").replace(/&/g,"&amp;")}var G={publisher:"kanonak.org",package_:"derivation",name:"look"},M={publisher:"kanonak.org",package_:"derivation",name:"tokens"},S={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},O={publisher:"kanonak.org",package_:"core-rdf",name:"label"},ne={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},de={publisher:"kanonak.org",package_:"look",name:"Hero"},ge={publisher:"kanonak.org",package_:"look",name:"PropertyList"},ke={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},he={publisher:"kanonak.org",package_:"look",name:"ChipRow"},me={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},te={publisher:"kanonak.org",package_:"look",name:"Markdown"},P={publisher:"kanonak.org",package_:"look",name:"NavGroup"},H={publisher:"kanonak.org",package_:"look",name:"NavLink"},se={publisher:"kanonak.org",package_:"look",name:"target"},be={publisher:"kanonak.org",package_:"look",name:"ResourceGrid"};var je={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},_e={publisher:"kanonak.org",package_:"look",name:"tierChip"},Re={publisher:"kanonak.org",package_:"look",name:"tierIcon"},ve={publisher:"kanonak.org",package_:"look",name:"tierCard"},Ke={publisher:"kanonak.org",package_:"look",name:"tierFull"};var D={publisher:"kanonak.org",package_:"look",name:"bands"},$e={publisher:"kanonak.org",package_:"look",name:"title"},Se={publisher:"kanonak.org",package_:"look",name:"eyebrow"},ye={publisher:"kanonak.org",package_:"look",name:"subtitle"},re={publisher:"kanonak.org",package_:"look",name:"badges"},y={publisher:"kanonak.org",package_:"look",name:"source"},Le={publisher:"kanonak.org",package_:"look",name:"chips"},W={publisher:"kanonak.org",package_:"look",name:"entries"},Ue={publisher:"kanonak.org",package_:"look",name:"urlForm"},z=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let t=Y(e);if(t)return{declaration:t,sourceClass:{publisher:C(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}};let n=new Set,s=v(e);for(;s.length>0;){let r=s.shift(),o=U(r.subject);if(n.has(o))continue;n.add(o);let a=j(this.catalog,r.subject);if(!a)continue;let c=Y(a);if(c)return{declaration:c,sourceClass:{publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name}};for(let i of N(a))s.push(i)}if(!n.has(U(S))){let r=j(this.catalog,S);if(r){let o=Y(r);if(o)return{declaration:o,sourceClass:{...S}}}}}findCascadedTokens(e){let t=new Map;for(let[r,o]of q(e))t.has(r)||t.set(r,o);let n=new Set,s=v(e);for(;s.length>0;){let r=s.shift(),o=U(r.subject);if(n.has(o))continue;n.add(o);let a=V(this.catalog,r.subject);if(a.length!==0)for(let c of a){for(let[i,l]of q(c))t.has(i)||t.set(i,l);for(let i of N(c))s.push(i)}}if(!n.has(U(S))){let r=V(this.catalog,S);for(let o of r)for(let[a,c]of q(o))t.has(a)||t.set(a,c)}return t}renderSvg(e){let t=k(e,O)??e.name,n=(t.trim().charAt(0)||"?").toUpperCase(),s=`${e.namespace??""}/${e.name}`,r={label:t,firstLetter:n,uri:s},o=this.collectCascadedSvgTiers(e),a=A(o.tierChip??"",r),c=A(o.tierIcon??"",r),i=A(o.tierCard??"",r),l=A(o.tierFull??"",r),g=[...this.findCascadedTokens(e)].map(([x,T])=>`--kan-${x}: ${T};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" width="400" height="400" style="${ce(g)}">
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">${a}</g>
26
+ <g class="tier-icon">${c}</g>
27
+ <g class="tier-card">${i}</g>
28
+ <g class="tier-full">${l}</g>
29
+ </svg>`}collectCascadedSvgTiers(e){let t={},n=o=>{let a=L(o,je);if(!(a instanceof E))return;let c=a.object,i=k(c,_e),l=k(c,Re),p=k(c,ve),g=k(c,Ke);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&&g!==void 0&&(t.tierFull=g)};n(e);let s=new Set,r=v(e);for(;r.length>0;){let o=r.shift(),a=U(o.subject);if(s.has(a))continue;s.add(a);let c=V(this.catalog,o.subject);for(let i of c){n(i);for(let l of N(i))r.push(l)}}if(!s.has(U(S)))for(let o of V(this.catalog,S))n(o);return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[o,a]of t)n.push(` --kan-${o}: ${a};`);let s=n.length>0?`:root {
30
+ ${n.join(`
31
+ `)}
32
+ }`:":root { /* no tokens resolved */ }",r=this.findBaseStylesheet(C(e))??"";return`${s}
33
+ ${r}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,s;for(let o of this.catalog){if(!(o instanceof K)||o.name!=="base-stylesheet")continue;let a=o.namespace||"";a.startsWith(`${e}/look-styles@`)?n=o:a.startsWith("kanonak.org/look-styles@")&&(s=o)}let r=n??s;if(r)for(let o of r.statement){let a=o.predicate?.subject;if(!a)continue;if(`${a.publisher}/${a.package_}/${a.name}`===t&&o instanceof $)return o.object}}renderHtml(e){let t=this.findCascadedLook(e);if(!t)return`<!-- LookRenderer: no derivation.look found for ${e.namespace}/${e.name} -->`;let n=oe(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let s=C(e),r=[];for(let o of n)r.push(this.renderBand(o,e,s));return r.join(`
34
+ `)}renderDocument(e){let t=this.renderHtml(e),n=this.readPropertyValueText(e,O)??e.name,s=`${e.name}.css`,r=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${f(e.name)}.svg" alt=""></figure>
35
+ `:"",o=C(e),a=this.renderNavGroup(e,o);return`<!doctype html>
36
+ <html lang="en">
37
+ <head>
38
+ <meta charset="utf-8">
39
+ <meta name="viewport" content="width=device-width, initial-scale=1">
40
+ <title>${f(n)}</title>
41
+ <link rel="stylesheet" href="${f(s)}">
42
+ </head>
43
+ <body>
44
+ ${a}
45
+ <main class="kan-main">
46
+ ${r}${t}
47
+ </main>
48
+ </body>
49
+ </html>
50
+ `}hasSvgDerivation(e){let t=new Set,n=v(e);for(;n.length>0;){let s=n.shift(),r=U(s.subject);if(t.has(r))continue;t.add(r);let o=j(this.catalog,s.subject);if(o){for(let a of o.statement)if(a instanceof m&&R(a,"kanonak.org","derivation","derivations")){for(let c of a.object??[])if(c instanceof w)for(let i of c.statement){if(!(i instanceof h)||!R(i,"kanonak.org","derivation","format")||!(i.object instanceof d))continue;let l=i.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let a of N(o))n.push(a)}}return!1}renderBand(e,t,n){let s=ae(e);return s?_(s,de)?this.renderHero(e,t,n):_(s,ge)?this.renderPropertyList(e,t,n):_(s,ke)?this.renderBadgeRow(e,t,n):_(s,he)?this.renderChipRow(e,t,n):_(s,me)?this.renderReferenceList(e,t,n):_(s,te)?this.renderMarkdown(e,t):_(s,P)?this.renderNavGroup(t,n):_(s,be)?this.renderResourceGrid(e,n,t):`<!-- LookRenderer: unsupported band ${s.publisher}/${s.package_}/${s.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}renderResourceGrid(e,t,n){let s=b(e,y);if(!s)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let r=j(this.catalog,s),o=r?v(r).some(i=>{let l=i.subject.name;return l==="ObjectProperty"||l==="DatatypeProperty"||l==="Property"}):!1,a=[];if(o&&n){let i=this.readPropertyValueReferences(n,s);for(let l of i){let p=j(this.catalog,{publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name,...l.subject.version?{version:l.subject.version}:{}});p&&a.push(p)}}else a=this.findInstancesOfClass(s);if(a.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${s.publisher}/${s.package_}/${s.name} -->`;let c=[];for(let i of a){let l=k(i,O)??i.name,p=k(i,ne),g=i.namespace||"",x=g.split("/")[1]?.split("@")[0]??"",T=g.split("@")[1]??"",J=T?this.parseVersion(T):void 0,ue=F.formatResourceUrl({publisher:C(i),package_:x,name:i.name,...J?{version:J}:{}},"=",{contextPublisher:t}),le=p?`<p class="kan-resource-card-subtitle">${f(p)}</p>`:"";c.push(`<a class="kan-resource-card" href="${f(ue)}"><h3 class="kan-resource-card-title">${f(l)}</h3>${le}</a>`)}return`<section class="kan-resource-grid">
51
+ ${c.join(`
52
+ `)}
53
+ </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 K))continue;v(n).map(o=>o.subject).some(o=>o.publisher===e.publisher&&o.package_===e.package_&&o.name===e.name)&&t.push(n)}return t}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let s=L(n,W);if(!(s instanceof m))return"";let r=s.object??[];if(r.length===0)return"";let o=[];for(let a of r){if(!(a instanceof d))continue;let c=j(this.catalog,{publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name}),{href:i,label:l}=this.resolveNavEntry(a,c,t),p=`/${e.namespace?.split("/")[1]?.split("@")[0]}/${(e.namespace||"").split("@")[1]}/${e.name}`,g=i===p?' aria-current="page"':"";o.push(`<li><a class="kan-nav-link" href="${f(i)}"${g}>${f(l)}</a></li>`)}return`<nav class="kan-site-nav"><ul>
54
+ ${o.join(`
55
+ `)}
56
+ </ul></nav>`}resolveNavEntry(e,t,n){if(t&&v(t).map(c=>c.subject).some(c=>c.publisher===H.publisher&&c.package_===H.package_&&c.name===H.name)){let c=k(t,O),i=L(t,se);if(i instanceof h&&i.object instanceof d){let l=i.object,p=this.readLabelForUri({publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name});return{href:this.urlForReference(l,se,n),label:c??p??l.subject.name}}}let s=F.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),r=t?k(t,O)??e.subject.name:e.subject.name;return{href:s,label:r}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof K)||!(t.namespace||"").startsWith(`${e}/`))continue;if(v(t).map(o=>o.subject).some(o=>o.publisher===P.publisher&&o.package_===P.package_&&o.name===P.name))return t}}renderMarkdown(e,t){let n=b(e,y);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let s=this.readPropertyValueText(t,n);return s?`<section class="kan-markdown">
57
+ ${X(s)}
58
+ </section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=oe(t.declaration),s=[];for(let r of n){let o=ae(r);if(!o||!_(o,te))continue;let a=b(r,y);if(!a)continue;let c=this.readPropertyValueText(e,a);c&&s.push(c)}return s.length>0?s.join(`
59
+
60
+ `):void 0}renderHero(e,t,n){let s=['<header class="kan-hero">'],r=b(e,Se);if(r){let l=this.readPropertyValueText(t,r);l&&s.push(`<span class="kan-hero-eyebrow">${f(l)}</span>`)}let o=b(e,$e),a="";o&&(a=this.readPropertyValueText(t,o)??""),a||(a=t.name),s.push(`<h1 class="kan-hero-title">${f(a)}</h1>`);let c=b(e,ye);if(c){let l=this.readPropertyValueText(t,c);l&&s.push(`<p class="kan-hero-subtitle">${f(l)}</p>`)}let i=b(e,re);if(i){let l=this.readPropertyValueReferences(t,i);if(l.length>0){let p=l.map(g=>this.renderBadge(g,re,n)).join("");s.push(`<div class="kan-hero-badges">${p}</div>`)}}return s.push("</header>"),s.join(`
61
+ `)}renderPropertyList(e,t,n){let s=b(e,y);if(!s)return"<!-- LookRenderer: PropertyList missing look.source -->";let r=this.readLabelForUri(s)??s.name,o=L(t,s),a=this.gatherValueItems(o),c=a.length>0?a.map(i=>`<li>${this.renderInlineValue(i,y,n)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${f(r)}</h3>`,`<ul class="kan-property-list-items">${c}</ul>`,"</section>"].join(`
62
+ `)}renderBadgeRow(e,t,n){let s=b(e,y);if(!s)return"<!-- LookRenderer: BadgeRow missing look.source -->";let r=this.readPropertyValueReferences(t,s);return r.length===0?"":`<div class="kan-badge-row">${r.map(a=>this.renderBadge(a,y,n)).join("")}</div>`}renderChipRow(e,t,n){let s=ie(e,Le);if(s.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let r=[];for(let o of s){let a=L(t,o);if(!a)continue;let c=this.readLabelForUri(o)??o.name,i=this.renderStatementInlineValue(a,o,n);i&&r.push(`<span class="kan-chip"><span class="kan-chip-key">${f(c)}</span> <span class="kan-chip-val">${i}</span></span>`)}return r.length===0?"":`<div class="kan-chip-row">${r.join("")}</div>`}renderReferenceList(e,t,n){let s=ie(e,W);if(s.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let r=[];for(let o of s){let a=this.readPropertyValueReferences(t,o);if(a.length===0)continue;let c=this.readLabelForUri(o)??o.name,i=a.map(l=>this.renderReferenceLink(l,W,n)).join(", ");r.push(`<dt>${f(c)}</dt><dd>${i}</dd>`)}return r.length===0?"":`<dl class="kan-reference-list">${r.join("")}</dl>`}readPropertyValueText(e,t){let n=L(e,t);if(n){if(n instanceof $)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 m)return(n.object??[]).map(r=>r instanceof d?this.readLabelForUri({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name})??r.subject.name:r instanceof w?r.name??"":String(r)).filter(r=>r).join(", ")}}readPropertyValueReferences(e,t){let n=L(e,t);if(!n)return[];if(n instanceof h)return[n.object];if(n instanceof m){let s=[];for(let r of n.object??[])r instanceof d&&s.push(r);return s}return[]}gatherValueItems(e){return e?e instanceof m?e.object??[]:e instanceof h?[e.object]:e instanceof E?[e.object]:e instanceof $?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof d?this.renderReferenceLink(e,t,n):e instanceof w?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 $?f(e.object):e instanceof h?this.renderReferenceLink(e.object,t,n):e instanceof m?(e.object??[]).map(r=>this.renderInlineValue(r,t,n)).filter(r=>r).join(", "):""}renderReferenceLink(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,r=this.urlForReference(e,t,n);return`<a class="kan-link" href="${f(r)}">${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,r=this.readCommentForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name}),o=this.urlForReference(e,t,n),a=r?` title="${f(r)}"`:"";return`<a class="kan-badge" href="${f(o)}"${a}>${f(s)}</a>`}urlForReference(e,t,n){let s=t?this.getUrlFormForProperty(t):"=";return F.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=j(this.catalog,e);if(!t)return"=";let n=k(t,Ue);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=j(this.catalog,e);if(t)return k(t,O)}readCommentForUri(e){let t=j(this.catalog,e);if(t)return k(t,ne)}};function q(u){let e=new Map;for(let t of u.statement){if(!(t instanceof E)||!R(t,M.publisher,M.package_,M.name))continue;let n=t.object;for(let s of n.statement){if(!(s instanceof $))continue;let r=s.predicate?.subject?.name;if(!r)continue;let o=s.object;e.has(r)||e.set(r,o)}}return e}function Y(u){for(let e of u.statement)if(e instanceof E&&R(e,G.publisher,G.package_,G.name))return e.object}function oe(u){for(let e of u.statement){if(!(e instanceof m)||!R(e,D.publisher,D.package_,D.name))continue;let t=[];for(let n of e.object??[])n instanceof w&&t.push(n);return t}return[]}function ae(u){for(let e of u.statement)if(e instanceof h&&e.predicate?.subject?.name==="type"&&e.object instanceof d){let t=e.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function b(u,e){for(let t of u.statement)if(t instanceof h&&R(t,e.publisher,e.package_,e.name)&&t.object instanceof d){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function ie(u,e){for(let t of u.statement){if(!(t instanceof m)||!R(t,e.publisher,e.package_,e.name))continue;let n=[];for(let s of t.object??[])s instanceof d&&n.push({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name});return n}return[]}function L(u,e){for(let t of u.statement)if(R(t,e.publisher,e.package_,e.name))return t}function k(u,e){for(let t of u.statement)if(t instanceof $&&R(t,e.publisher,e.package_,e.name))return t.object}function v(u){let e=[];for(let t of u.statement)if(t instanceof h){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof d&&e.push(t.object)}else if(t instanceof m){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof d&&e.push(n)}return e}function N(u){let e=[];for(let t of u.statement)if(t instanceof h){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof d&&e.push(t.object)}else if(t instanceof m){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof d&&e.push(n)}return e}function V(u,e){let t=[];for(let n of u){if(!(n instanceof K)||n.name!==e.name)continue;(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&t.push(n)}return t}function j(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 K&&s.name===e.name&&s.namespace===n)return s}for(let n of u){if(!(n instanceof K)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function R(u,e,t,n){let s=u.predicate?.subject;return s?s.publisher===e&&s.package_===t&&s.name===n:!1}function _(u,e){return u.publisher===e.publisher&&u.package_===e.package_&&u.name===e.name}function U(u){return`${u.publisher}/${u.package_}/${u.name}`}function C(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 A(u,e){return u.replace(/\{\{(\w+)\}\}/g,(t,n)=>{let s=e[n];return s===void 0?`{{${n}}}`:ce(s)})}function ce(u){return u.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}export{X as a,z 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-JLFC6WKB.js";import{b as Yt}from"./chunk-GHMIWHWF.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-POFL6NMI.js";import{a as qt}from"./chunk-BQOD26BC.js";import{a as Te,b as je,c as Le,d as Fe,e as Ne}from"./chunk-AZSZXLEH.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-AV4AVTI6.js";import{a as lt,b as dt,c as ut,d as pt}from"./chunk-TWIWVG7W.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-MV2LZFUK.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as Me,e as We}from"./chunk-QIIQ4G2Q.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-MYITGTGJ.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-JLFC6WKB.js";import{b as Yt}from"./chunk-6KHFD47C.js";import{a as qe,b as Ye,c as Xe,d as b,e as S,f as i}from"./chunk-POFL6NMI.js";import{a as qt}from"./chunk-BQOD26BC.js";import{a as Te,b as je,c as Le,d as Fe,e as Ne}from"./chunk-AZSZXLEH.js";import{a as Be,b as De,c as Oe,d as Ae}from"./chunk-AV4AVTI6.js";import{a as lt,b as dt,c as ut,d as pt}from"./chunk-TWIWVG7W.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-MV2LZFUK.js";import"./chunk-FJ35VIV6.js";import{a as F,b as D,c as Me,e as We}from"./chunk-QIIQ4G2Q.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-MYITGTGJ.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)}
@@ -42,8 +42,11 @@ export declare class LookRenderer {
42
42
  constructor(catalog: Kanonak[]);
43
43
  /**
44
44
  * Walk the instance's type chain (BFS) looking for the first class
45
- * that declares `derivation.look`. Falls through to `rdfs.Resource`
46
- * at the root.
45
+ * that declares `derivation.look`. Checks the instance itself first
46
+ * so instance-level look declarations override class-level ones —
47
+ * the same instance-replace semantics derivation.derivations uses.
48
+ * Falls through to `rdfs.Resource` at the root if nothing closer
49
+ * declares one.
47
50
  */
48
51
  findCascadedLook(instance: SubjectKanonak): ResolvedLook | undefined;
49
52
  /**
@@ -70,6 +73,29 @@ export declare class LookRenderer {
70
73
  * may resolve different accent colors etc.); the base rules are
71
74
  * shared across the universal-look layer.
72
75
  */
76
+ /**
77
+ * Render the instance as a 4-tier responsive SVG.
78
+ *
79
+ * Inside the SVG, four `<g class="tier-X">` groups (tier-chip <60px,
80
+ * tier-icon 60-160, tier-card 160-400, tier-full >=400) wrap the
81
+ * content for each scale. CSS media queries on the SVG's rendered
82
+ * width show exactly one tier — the same file works as a favicon,
83
+ * sidebar tile, ResourceGrid card, or hero figure.
84
+ *
85
+ * v1: defaults only. Reads cascaded `look.title` and `look.subtitle`
86
+ * (or falls back to `rdfs.label` / `rdfs.comment`), and the resource's
87
+ * accent token. tier-chip is the accent circle alone; tier-icon adds
88
+ * the first letter; tier-card adds the full label; tier-full adds
89
+ * the subtitle plus the canonical URI footer.
90
+ */
91
+ renderSvg(instance: SubjectKanonak): string;
92
+ /**
93
+ * Walk the instance's type chain (and rdfs.Resource floor), collecting
94
+ * the per-tier SVG fragment for each tier from the closest declarer.
95
+ * Each tier is filled independently — a class can override tierCard
96
+ * while inheriting tierChip from rdfs.Resource.
97
+ */
98
+ private collectCascadedSvgTiers;
73
99
  renderStylesheet(instance: SubjectKanonak): string;
74
100
  /**
75
101
  * Find the publisher-appropriate `base-stylesheet` Asset in the catalog
@@ -103,6 +129,25 @@ export declare class LookRenderer {
103
129
  */
104
130
  private hasSvgDerivation;
105
131
  private renderBand;
132
+ /**
133
+ * Render a ResourceGrid band — enumerates every instance of the class
134
+ * named by `look.source` and emits a grid of cards. Each card shows
135
+ * the instance's rdfs.label as title, rdfs.comment as subtitle, and
136
+ * links to the instance's canonical URL.
137
+ *
138
+ * This is the minimal viable implementation. The look vocabulary's
139
+ * stated full design ("renders the resource's own derivation.look in
140
+ * compact variant") is deferred — that requires a variant system.
141
+ */
142
+ private renderResourceGrid;
143
+ private parseVersion;
144
+ /**
145
+ * Find every SubjectKanonak in the catalog whose declared `rdf:type` set
146
+ * includes the given class URI (canonical, version-agnostic). Used by
147
+ * ResourceGrid to enumerate instances for the grid. Skips the class
148
+ * itself and other classes.
149
+ */
150
+ private findInstancesOfClass;
106
151
  /**
107
152
  * Render the publisher's site navigation. The instance is the page
108
153
  * the band is being rendered on; the NavGroup itself is discovered
@@ -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-GHMIWHWF.js";import{a as Oe}from"../chunk-BQOD26BC.js";import"../chunk-TWIWVG7W.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-QIIQ4G2Q.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-MYITGTGJ.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-6KHFD47C.js";import{a as Oe}from"../chunk-BQOD26BC.js";import"../chunk-TWIWVG7W.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-QIIQ4G2Q.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-MYITGTGJ.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.28.4",
3
+ "version": "3.28.6",
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.28.4",
116
+ "@kanonak-protocol/types": "^3.28.6",
117
117
  "ignore": "^7.0.5",
118
118
  "js-yaml": "^4.1.0",
119
119
  "yaml": "^2.7.0"
@@ -1,47 +0,0 @@
1
- import{a as F}from"./chunk-NIGFQYVA.js";import{a as S}from"./chunk-QIIQ4G2Q.js";import{c as R,d as p,g as j,j as d,k as w,l as g}from"./chunk-W6T7MOKY.js";function W(i){let e=i.replace(/\r\n/g,`
2
- `).split(`
3
- `),t=[],n=0;for(;n<e.length;){let s=e[n];if(s.trim()===""){n++;continue}let r=/^(\s*)```(\S*)\s*$/.exec(s);if(r){let c=r[2],u=[];for(n++;n<e.length&&!/^(\s*)```\s*$/.test(e[n]);)u.push(e[n]),n++;n++;let f=q(u.join(`
4
- `)),b=c?` class="language-${Y(c)}"`:"";t.push(`<pre><code${b}>${f}</code></pre>`);continue}let o=/^(#{1,6})\s+(.*)$/.exec(s);if(o){let c=o[1].length,u=K(o[2].trim());t.push(`<h${c}>${u}</h${c}>`),n++;continue}if(s.includes("|")&&n+1<e.length&&G(e[n+1])){let c=P(s),u=se(e[n+1]);n+=2;let f=[];for(;n<e.length&&e[n].trim()!==""&&e[n].includes("|");)f.push(P(e[n])),n++;t.push(re(c,u,f));continue}if(/^\s*[-*]\s+/.test(s)){let c=[];for(;n<e.length&&/^\s*[-*]\s+/.test(e[n]);){let u=[e[n].replace(/^\s*[-*]\s+/,"")];for(n++;n<e.length&&e[n].trim()!==""&&!/^\s*[-*]\s+/.test(e[n])&&!/^\s*\d+\.\s+/.test(e[n]);)u.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,c.push(`<li>${K(u.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 u=[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]);)u.push(e[n]),n++;n<e.length&&e[n].trim()===""&&n++,c.push(`<li>${K(u.join(" ").trim())}</li>`)}t.push(`<ol>
8
- ${c.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&&G(e[n+1]));)a.push(e[n]),n++;t.push(`<p>${K(a.join(" "))}</p>`)}return t.join(`
11
- `)}function G(i){return i.includes("-")?/^[\s|:-]+$/.test(i):!1}function P(i){let e=i.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|").map(t=>t.trim())}function se(i){return P(i).map(e=>{let t=e.startsWith(":"),n=e.endsWith(":");return t&&n?"center":n?"right":t?"left":null})}function re(i,e,t){let n=o=>{let a=e[o];return a?` style="text-align:${a}"`:""},s=i.map((o,a)=>`<th${n(a)}>${K(o)}</th>`).join(""),r=t.map(o=>`<tr>${o.map((c,u)=>`<td${n(u)}>${K(c)}</td>`).join("")}</tr>`).join(`
12
- `);return`<table>
13
- <thead><tr>${s}</tr></thead>
14
- <tbody>
15
- ${r}
16
- </tbody>
17
- </table>`}function K(i){let e=q(i);return e=e.replace(/`([^`\n]+)`/g,(t,n)=>`<code>${n}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(t,n,s)=>`<a href="${Y(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 q(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function Y(i){return i.replace(/"/g,"&quot;").replace(/&/g,"&amp;")}var N={publisher:"kanonak.org",package_:"derivation",name:"look"},C={publisher:"kanonak.org",package_:"derivation",name:"tokens"},L={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},E={publisher:"kanonak.org",package_:"core-rdf",name:"label"},oe={publisher:"kanonak.org",package_:"core-rdf",name:"comment"},ae={publisher:"kanonak.org",package_:"look",name:"Hero"},ie={publisher:"kanonak.org",package_:"look",name:"PropertyList"},ce={publisher:"kanonak.org",package_:"look",name:"BadgeRow"},ue={publisher:"kanonak.org",package_:"look",name:"ChipRow"},fe={publisher:"kanonak.org",package_:"look",name:"ReferenceList"},z={publisher:"kanonak.org",package_:"look",name:"Markdown"},T={publisher:"kanonak.org",package_:"look",name:"NavGroup"},V={publisher:"kanonak.org",package_:"look",name:"NavLink"},J={publisher:"kanonak.org",package_:"look",name:"target"},B={publisher:"kanonak.org",package_:"look",name:"bands"},le={publisher:"kanonak.org",package_:"look",name:"title"},pe={publisher:"kanonak.org",package_:"look",name:"eyebrow"},de={publisher:"kanonak.org",package_:"look",name:"subtitle"},Q={publisher:"kanonak.org",package_:"look",name:"badges"},v={publisher:"kanonak.org",package_:"look",name:"source"},ge={publisher:"kanonak.org",package_:"look",name:"chips"},A={publisher:"kanonak.org",package_:"look",name:"entries"},ke={publisher:"kanonak.org",package_:"look",name:"urlForm"},D=class{constructor(e){this.catalog=e}catalog;findCascadedLook(e){let t=new Set,n=U(e);for(;n.length>0;){let s=n.shift(),r=O(s.subject);if(t.has(r))continue;t.add(r);let o=_(this.catalog,s.subject);if(!o)continue;let a=X(o);if(a)return{declaration:a,sourceClass:{publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name}};for(let c of M(o))n.push(c)}if(!t.has(O(L))){let s=_(this.catalog,L);if(s){let r=X(s);if(r)return{declaration:r,sourceClass:{...L}}}}}findCascadedTokens(e){let t=new Map;for(let[r,o]of H(e))t.has(r)||t.set(r,o);let n=new Set,s=U(e);for(;s.length>0;){let r=s.shift(),o=O(r.subject);if(n.has(o))continue;n.add(o);let a=te(this.catalog,r.subject);if(a.length!==0)for(let c of a){for(let[u,f]of H(c))t.has(u)||t.set(u,f);for(let u of M(c))s.push(u)}}if(!n.has(O(L))){let r=te(this.catalog,L);for(let o of r)for(let[a,c]of H(o))t.has(a)||t.set(a,c)}return t}renderStylesheet(e){let t=this.findCascadedTokens(e),n=[];for(let[o,a]of t)n.push(` --kan-${o}: ${a};`);let s=n.length>0?`:root {
18
- ${n.join(`
19
- `)}
20
- }`:":root { /* no tokens resolved */ }",r=this.findBaseStylesheet(x(e))??"";return`${s}
21
- ${r}`}findBaseStylesheet(e){let t="kanonak.org/site/content",n,s;for(let o of this.catalog){if(!(o instanceof R)||o.name!=="base-stylesheet")continue;let a=o.namespace||"";a.startsWith(`${e}/look-styles@`)?n=o:a.startsWith("kanonak.org/look-styles@")&&(s=o)}let r=n??s;if(r)for(let o of r.statement){let a=o.predicate?.subject;if(!a)continue;if(`${a.publisher}/${a.package_}/${a.name}`===t&&o instanceof j)return o.object}}renderHtml(e){let t=this.findCascadedLook(e);if(!t)return`<!-- LookRenderer: no derivation.look found for ${e.namespace}/${e.name} -->`;let n=Z(t.declaration);if(n.length===0)return"<!-- LookRenderer: look declaration has no bands -->";let s=x(e),r=[];for(let o of n)r.push(this.renderBand(o,e,s));return r.join(`
22
- `)}renderDocument(e){let t=this.renderHtml(e),n=this.readPropertyValueText(e,E)??e.name,s=`${e.name}.css`,r=this.hasSvgDerivation(e)?`<figure class="kan-figure"><img src="${l(e.name)}.svg" alt=""></figure>
23
- `:"",o=x(e),a=this.renderNavGroup(e,o);return`<!doctype html>
24
- <html lang="en">
25
- <head>
26
- <meta charset="utf-8">
27
- <meta name="viewport" content="width=device-width, initial-scale=1">
28
- <title>${l(n)}</title>
29
- <link rel="stylesheet" href="${l(s)}">
30
- </head>
31
- <body>
32
- ${a}
33
- <main class="kan-main">
34
- ${r}${t}
35
- </main>
36
- </body>
37
- </html>
38
- `}hasSvgDerivation(e){let t=new Set,n=U(e);for(;n.length>0;){let s=n.shift(),r=O(s.subject);if(t.has(r))continue;t.add(r);let o=_(this.catalog,s.subject);if(o){for(let a of o.statement)if(a instanceof g&&k(a,"kanonak.org","derivation","derivations")){for(let c of a.object??[])if(c instanceof S)for(let u of c.statement){if(!(u instanceof d)||!k(u,"kanonak.org","derivation","format")||!(u.object instanceof p))continue;let f=u.object.subject;if(f.publisher==="kanonak.org"&&f.package_==="formats"&&f.name==="svg")return!0}}for(let a of M(o))n.push(a)}}return!1}renderBand(e,t,n){let s=ee(e);return s?m(s,ae)?this.renderHero(e,t,n):m(s,ie)?this.renderPropertyList(e,t,n):m(s,ce)?this.renderBadgeRow(e,t,n):m(s,ue)?this.renderChipRow(e,t,n):m(s,fe)?this.renderReferenceList(e,t,n):m(s,z)?this.renderMarkdown(e,t):m(s,T)?this.renderNavGroup(t,n):`<!-- LookRenderer: unsupported band ${s.publisher}/${s.package_}/${s.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}renderNavGroup(e,t){let n=this.findNavGroupForPublisher(t);if(!n)return"";let s=$(n,A);if(!(s instanceof g))return"";let r=s.object??[];if(r.length===0)return"";let o=[];for(let a of r){if(!(a instanceof p))continue;let c=_(this.catalog,{publisher:a.subject.publisher,package_:a.subject.package_,name:a.subject.name}),{href:u,label:f}=this.resolveNavEntry(a,c,t),b=`/${e.namespace?.split("/")[1]?.split("@")[0]}/${(e.namespace||"").split("@")[1]}/${e.name}`,I=u===b?' aria-current="page"':"";o.push(`<li><a class="kan-nav-link" href="${l(u)}"${I}>${l(f)}</a></li>`)}return`<nav class="kan-site-nav"><ul>
39
- ${o.join(`
40
- `)}
41
- </ul></nav>`}resolveNavEntry(e,t,n){if(t&&U(t).map(c=>c.subject).some(c=>c.publisher===V.publisher&&c.package_===V.package_&&c.name===V.name)){let c=y(t,E),u=$(t,J);if(u instanceof d&&u.object instanceof p){let f=u.object,b=this.readLabelForUri({publisher:f.subject.publisher,package_:f.subject.package_,name:f.subject.name});return{href:this.urlForReference(f,J,n),label:c??b??f.subject.name}}}let s=F.formatResourceUrl({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},"*",{contextPublisher:n}),r=t?y(t,E)??e.subject.name:e.subject.name;return{href:s,label:r}}findNavGroupForPublisher(e){for(let t of this.catalog){if(!(t instanceof R)||!(t.namespace||"").startsWith(`${e}/`))continue;if(U(t).map(o=>o.subject).some(o=>o.publisher===T.publisher&&o.package_===T.package_&&o.name===T.name))return t}}renderMarkdown(e,t){let n=h(e,v);if(!n)return"<!-- LookRenderer.Markdown: no look.source -->";let s=this.readPropertyValueText(t,n);return s?`<section class="kan-markdown">
42
- ${W(s)}
43
- </section>`:""}renderRawMarkdown(e){let t=this.findCascadedLook(e);if(!t)return;let n=Z(t.declaration),s=[];for(let r of n){let o=ee(r);if(!o||!m(o,z))continue;let a=h(r,v);if(!a)continue;let c=this.readPropertyValueText(e,a);c&&s.push(c)}return s.length>0?s.join(`
44
-
45
- `):void 0}renderHero(e,t,n){let s=['<header class="kan-hero">'],r=h(e,pe);if(r){let f=this.readPropertyValueText(t,r);f&&s.push(`<span class="kan-hero-eyebrow">${l(f)}</span>`)}let o=h(e,le),a="";o&&(a=this.readPropertyValueText(t,o)??""),a||(a=t.name),s.push(`<h1 class="kan-hero-title">${l(a)}</h1>`);let c=h(e,de);if(c){let f=this.readPropertyValueText(t,c);f&&s.push(`<p class="kan-hero-subtitle">${l(f)}</p>`)}let u=h(e,Q);if(u){let f=this.readPropertyValueReferences(t,u);if(f.length>0){let b=f.map(I=>this.renderBadge(I,Q,n)).join("");s.push(`<div class="kan-hero-badges">${b}</div>`)}}return s.push("</header>"),s.join(`
46
- `)}renderPropertyList(e,t,n){let s=h(e,v);if(!s)return"<!-- LookRenderer: PropertyList missing look.source -->";let r=this.readLabelForUri(s)??s.name,o=$(t,s),a=this.gatherValueItems(o),c=a.length>0?a.map(u=>`<li>${this.renderInlineValue(u,v,n)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${l(r)}</h3>`,`<ul class="kan-property-list-items">${c}</ul>`,"</section>"].join(`
47
- `)}renderBadgeRow(e,t,n){let s=h(e,v);if(!s)return"<!-- LookRenderer: BadgeRow missing look.source -->";let r=this.readPropertyValueReferences(t,s);return r.length===0?"":`<div class="kan-badge-row">${r.map(a=>this.renderBadge(a,v,n)).join("")}</div>`}renderChipRow(e,t,n){let s=ne(e,ge);if(s.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let r=[];for(let o of s){let a=$(t,o);if(!a)continue;let c=this.readLabelForUri(o)??o.name,u=this.renderStatementInlineValue(a,o,n);u&&r.push(`<span class="kan-chip"><span class="kan-chip-key">${l(c)}</span> <span class="kan-chip-val">${u}</span></span>`)}return r.length===0?"":`<div class="kan-chip-row">${r.join("")}</div>`}renderReferenceList(e,t,n){let s=ne(e,A);if(s.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let r=[];for(let o of s){let a=this.readPropertyValueReferences(t,o);if(a.length===0)continue;let c=this.readLabelForUri(o)??o.name,u=a.map(f=>this.renderReferenceLink(f,A,n)).join(", ");r.push(`<dt>${l(c)}</dt><dd>${u}</dd>`)}return r.length===0?"":`<dl class="kan-reference-list">${r.join("")}</dl>`}readPropertyValueText(e,t){let n=$(e,t);if(n){if(n instanceof j)return n.object;if(n instanceof d){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 g)return(n.object??[]).map(r=>r instanceof p?this.readLabelForUri({publisher:r.subject.publisher,package_:r.subject.package_,name:r.subject.name})??r.subject.name:r instanceof S?r.name??"":String(r)).filter(r=>r).join(", ")}}readPropertyValueReferences(e,t){let n=$(e,t);if(!n)return[];if(n instanceof d)return[n.object];if(n instanceof g){let s=[];for(let r of n.object??[])r instanceof p&&s.push(r);return s}return[]}gatherValueItems(e){return e?e instanceof g?e.object??[]:e instanceof d?[e.object]:e instanceof w?[e.object]:e instanceof j?[e.object]:[]:[]}renderInlineValue(e,t,n){return e instanceof p?this.renderReferenceLink(e,t,n):e instanceof S?l(e.name??"(embedded)"):typeof e=="string"?l(e):typeof e=="number"||typeof e=="boolean"?l(String(e)):""}renderStatementInlineValue(e,t,n){return e instanceof j?l(e.object):e instanceof d?this.renderReferenceLink(e.object,t,n):e instanceof g?(e.object??[]).map(r=>this.renderInlineValue(r,t,n)).filter(r=>r).join(", "):""}renderReferenceLink(e,t,n){let s=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name,r=this.urlForReference(e,t,n);return`<a class="kan-link" href="${l(r)}">${l(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,r=this.readCommentForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name}),o=this.urlForReference(e,t,n),a=r?` title="${l(r)}"`:"";return`<a class="kan-badge" href="${l(o)}"${a}>${l(s)}</a>`}urlForReference(e,t,n){let s=t?this.getUrlFormForProperty(t):"=";return F.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=_(this.catalog,e);if(!t)return"=";let n=y(t,ke);return n==="*"||n==="^"||n==="~"||n==="="?n:"="}readLabelForUri(e){let t=_(this.catalog,e);if(t)return y(t,E)}readCommentForUri(e){let t=_(this.catalog,e);if(t)return y(t,oe)}};function H(i){let e=new Map;for(let t of i.statement){if(!(t instanceof w)||!k(t,C.publisher,C.package_,C.name))continue;let n=t.object;for(let s of n.statement){if(!(s instanceof j))continue;let r=s.predicate?.subject?.name;if(!r)continue;let o=s.object;e.has(r)||e.set(r,o)}}return e}function X(i){for(let e of i.statement)if(e instanceof w&&k(e,N.publisher,N.package_,N.name))return e.object}function Z(i){for(let e of i.statement){if(!(e instanceof g)||!k(e,B.publisher,B.package_,B.name))continue;let t=[];for(let n of e.object??[])n instanceof S&&t.push(n);return t}return[]}function ee(i){for(let e of i.statement)if(e instanceof d&&e.predicate?.subject?.name==="type"&&e.object instanceof p){let t=e.object.subject;return{publisher:t.publisher,package_:t.package_,name:t.name}}}function h(i,e){for(let t of i.statement)if(t instanceof d&&k(t,e.publisher,e.package_,e.name)&&t.object instanceof p){let n=t.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function ne(i,e){for(let t of i.statement){if(!(t instanceof g)||!k(t,e.publisher,e.package_,e.name))continue;let n=[];for(let s of t.object??[])s instanceof p&&n.push({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name});return n}return[]}function $(i,e){for(let t of i.statement)if(k(t,e.publisher,e.package_,e.name))return t}function y(i,e){for(let t of i.statement)if(t instanceof j&&k(t,e.publisher,e.package_,e.name))return t.object}function U(i){let e=[];for(let t of i.statement)if(t instanceof d){if(t.predicate?.subject?.name!=="type")continue;t.object instanceof p&&e.push(t.object)}else if(t instanceof g){if(t.predicate?.subject?.name!=="type")continue;for(let n of t.object??[])n instanceof p&&e.push(n)}return e}function M(i){let e=[];for(let t of i.statement)if(t instanceof d){if(t.predicate?.subject?.name!=="subClassOf")continue;t.object instanceof p&&e.push(t.object)}else if(t instanceof g){if(t.predicate?.subject?.name!=="subClassOf")continue;for(let n of t.object??[])n instanceof p&&e.push(n)}return e}function te(i,e){let t=[];for(let n of i){if(!(n instanceof R)||n.name!==e.name)continue;(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&t.push(n)}return t}function _(i,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 i)if(s instanceof R&&s.name===e.name&&s.namespace===n)return s}for(let n of i){if(!(n instanceof R)||n.name!==e.name)continue;if((n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return n}}function k(i,e,t,n){let s=i.predicate?.subject;return s?s.publisher===e&&s.package_===t&&s.name===n:!1}function m(i,e){return i.publisher===e.publisher&&i.package_===e.package_&&i.name===e.name}function O(i){return`${i.publisher}/${i.package_}/${i.name}`}function x(i){let e=i.namespace||"",t=e.indexOf("/");return t>=0?e.substring(0,t):e}function l(i){return i.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}export{W as a,D as b};