@kanonak-protocol/sdk 3.65.0 → 3.66.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.
@@ -62,7 +62,7 @@ var b=document.createElement('button');b.type='button';b.className='kan-dgm-btn'
62
62
  b.style.cssText='position:absolute;top:6px;right:6px;z-index:3;border:1px solid var(--kan-border,#333);background:var(--kan-bg-card,#111);color:var(--kan-text,#ccc);border-radius:6px;width:28px;height:28px;cursor:pointer;font-size:15px;line-height:1;padding:0';
63
63
  b.addEventListener('click',function(ev){ev.preventDefault();ev.stopPropagation();open(c);});c.appendChild(b);})(cs[i]);}}
64
64
  if(document.readyState!=='loading')enhance();else document.addEventListener('DOMContentLoaded',enhance);
65
- })();`,Oe={chip:56,icon:120,card:240,full:420},Rt=["chip","icon","card","full"],yt={56:"chip",120:"icon",240:"card",420:"full"},pe=11,Kt={publisher:"kanonak.org",package_:"look",name:"placement"},xt={publisher:"kanonak.org",package_:"look",name:"width"},Lt=4,wt={publisher:"kanonak.org",package_:"look",name:"StatRow"},Ot={publisher:"kanonak.org",package_:"look",name:"Horizon"},Et={publisher:"kanonak.org",package_:"look",name:"PackageContents"},We={publisher:"kanonak.org",package_:"core-kanonak",name:"Package"},It={publisher:"kanonak.org",package_:"core-kanonak",name:"Publisher"},Ut={publisher:"kanonak.org",package_:"look",name:"FeaturedResource"},Ft={publisher:"kanonak.org",package_:"look",name:"PublisherPackages"},Tt={publisher:"kanonak.org",package_:"look",name:"packages"},Ct={publisher:"kanonak.org",package_:"code-grammars",name:"CodeGrammar"},At={publisher:"kanonak.org",package_:"code-grammars",name:"language"},Mt={publisher:"kanonak.org",package_:"code-grammars",name:"rule"},Dt={publisher:"kanonak.org",package_:"code-grammars",name:"tokenClass"},Nt={publisher:"kanonak.org",package_:"code-grammars",name:"pattern"},Pt={publisher:"kanonak.org",package_:"look",name:"Links"},Vt={publisher:"kanonak.org",package_:"link",name:"url"},Ht={publisher:"kanonak.org",package_:"link",name:"links"};var Bt={publisher:"kanonak.org",package_:"look",name:"Distribution"},Gt={publisher:"kanonak.org",package_:"look",name:"alphaPath"},zt={publisher:"kanonak.org",package_:"look",name:"betaPath"},Ye={publisher:"kanonak.org",package_:"look",name:"SectionHeading"},Wt={publisher:"kanonak.org",package_:"look",name:"SectionNav"},mn={publisher:"kanonak.org",package_:"look",name:"heading"},Yt={publisher:"kanonak.org",package_:"look",name:"note"},qt={publisher:"kanonak.org",package_:"look",name:"VersionDelta"},Xt={publisher:"kanonak.org",package_:"look",name:"TimePlot"},Zt={publisher:"kanonak.org",package_:"look",name:"Details"},Jt={publisher:"kanonak.org",package_:"look",name:"EmbeddedViews"},Qt={publisher:"kanonak.org",package_:"look",name:"skip"},ea={publisher:"kanonak.org",package_:"derivation",name:"derivations"},na={publisher:"kanonak.org",package_:"look",name:"laneBy"},ta={publisher:"kanonak.org",package_:"look",name:"stats"},aa={publisher:"kanonak.org",package_:"look",name:"statPath"},sa={publisher:"kanonak.org",package_:"look",name:"statLabel"},hn={publisher:"kanonak.org",package_:"look",name:"labelPath"},oa={publisher:"kanonak.org",package_:"look",name:"badgePath"},qe={publisher:"kanonak.org",package_:"look",name:"orderBy"},bn={publisher:"kanonak.org",package_:"look",name:"track"},Fe={publisher:"kanonak.org",package_:"look",name:"metricPath"},Xe={publisher:"kanonak.org",package_:"look",name:"hueBy"},vn={publisher:"kanonak.org",package_:"look",name:"lowerPath"},$n={publisher:"kanonak.org",package_:"look",name:"upperPath"},ra={publisher:"kanonak.org",package_:"look",name:"axisMin"},ia={publisher:"kanonak.org",package_:"look",name:"axisMax"},ca={publisher:"kanonak.org",package_:"look",name:"valueLabel"};var _n={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},la={publisher:"kanonak.org",package_:"look",name:"tierChip"},ua={publisher:"kanonak.org",package_:"look",name:"tierIcon"},da={publisher:"kanonak.org",package_:"look",name:"tierCard"},pa={publisher:"kanonak.org",package_:"look",name:"tierFull"},fa={publisher:"kanonak.org",package_:"core-rdf",name:"type"},jn=6,Ze={publisher:"kanonak.org",package_:"look",name:"bands"},ga={publisher:"kanonak.org",package_:"look",name:"title"},ka={publisher:"kanonak.org",package_:"look",name:"eyebrow"},ma={publisher:"kanonak.org",package_:"look",name:"subtitle"},Sn={publisher:"kanonak.org",package_:"look",name:"badges"},ae={publisher:"kanonak.org",package_:"look",name:"source"},ha={publisher:"kanonak.org",package_:"look",name:"via"},ba={publisher:"kanonak.org",package_:"look",name:"size"},va={publisher:"kanonak.org",package_:"look",name:"icon"},$a={publisher:"kanonak.org",package_:"look",name:"avatar"},_a={publisher:"kanonak.org",package_:"look",name:"contents"},ja={publisher:"kanonak.org",package_:"look",name:"transitive"},Sa={publisher:"kanonak.org",package_:"look",name:"chips"},Rn={publisher:"kanonak.org",package_:"look",name:"entries"},Ra={publisher:"kanonak.org",package_:"look",name:"urlForm"},tn=class{constructor(e){this.catalog=e}catalog;linkMode="single-publisher";setLinkMode(e){return this.linkMode=e,this}get publisherFirst(){return this.linkMode==="open-world"}linkBase(e){return this.publisherFirst?`/${e}`:""}resourceHref(e,n,a="="){return sn.formatResourceUrl(e,a,{contextPublisher:n,...this.publisherFirst?{publisherFirst:!0}:{}})}packageHref(e,n,a){return`${this.linkBase(e)}/${n}${a?`/${a}`:""}`}publisherHref(e){return`${this.linkBase(e)}/`}_codeHighlighter;findCascadedLook(e){let n=Ka(e)?void 0:Te(e);return n?{declaration:n,sourceClass:{publisher:B(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}}:this.lookFromTypeRefs(ce(e))}lookFromTypeRefs(e){let n=new Set,a=[...e];for(;a.length>0;){let o=a.shift().subject,s=z(o);if(n.has(s))continue;n.add(s);let r=fe(this.catalog,o);for(let i of r){let c=Te(i);if(c)return{declaration:c,sourceClass:{publisher:o.publisher,package_:o.package_,name:o.name}}}for(let i of r)for(let c of Ee(i))a.push(c)}if(!n.has(z(ke)))for(let t of fe(this.catalog,ke)){let o=Te(t);if(o)return{declaration:o,sourceClass:{...ke}}}}findCascadedTokens(e){let n=new Map;for(let[o,s]of Je(e))n.has(o)||n.set(o,s);let a=new Set,t=ce(e);for(;t.length>0;){let o=t.shift(),s=z(o.subject);if(a.has(s))continue;a.add(s);let r=fe(this.catalog,o.subject);if(r.length!==0)for(let i of r){for(let[c,l]of Je(i))n.has(c)||n.set(c,l);for(let c of Ee(i))t.push(c)}}if(!a.has(z(ke))){let o=fe(this.catalog,ke);for(let s of o)for(let[r,i]of Je(s))n.has(r)||n.set(r,i)}return n}renderSvg(e){let n=A(this.catalog,e).label,a=(n.trim().charAt(0)||"?").toUpperCase(),t=`${e.namespace??""}/${e.name}`,o={label:n,firstLetter:a,uri:t},s=this.collectCascadedSvgTiers(e),r=k=>this.applyPlaceholders(k,e,o),i=r(s.tierChip??""),c=r(s.tierIcon??""),l=r(s.tierCard??""),d=r(s.tierFull??""),g=[...this.findCascadedTokens(e)].map(([k,f])=>`--kan-${k}: ${f};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" style="${me(g)}">
65
+ })();`,Oe={chip:56,icon:120,card:240,full:420},Rt=["chip","icon","card","full"],yt={56:"chip",120:"icon",240:"card",420:"full"},fe=11,Kt={publisher:"kanonak.org",package_:"look",name:"placement"},xt={publisher:"kanonak.org",package_:"look",name:"width"},Lt=4,wt={publisher:"kanonak.org",package_:"look",name:"StatRow"},Ot={publisher:"kanonak.org",package_:"look",name:"Horizon"},Et={publisher:"kanonak.org",package_:"look",name:"PackageContents"},We={publisher:"kanonak.org",package_:"core-kanonak",name:"Package"},It={publisher:"kanonak.org",package_:"core-kanonak",name:"Publisher"},Ut={publisher:"kanonak.org",package_:"look",name:"FeaturedResource"},Ft={publisher:"kanonak.org",package_:"look",name:"PublisherPackages"},Tt={publisher:"kanonak.org",package_:"look",name:"packages"},Ct={publisher:"kanonak.org",package_:"code-grammars",name:"CodeGrammar"},At={publisher:"kanonak.org",package_:"code-grammars",name:"language"},Mt={publisher:"kanonak.org",package_:"code-grammars",name:"rule"},Dt={publisher:"kanonak.org",package_:"code-grammars",name:"tokenClass"},Nt={publisher:"kanonak.org",package_:"code-grammars",name:"pattern"},Pt={publisher:"kanonak.org",package_:"look",name:"Links"},Vt={publisher:"kanonak.org",package_:"link",name:"url"},Ht={publisher:"kanonak.org",package_:"link",name:"links"};var Bt={publisher:"kanonak.org",package_:"look",name:"Distribution"},Gt={publisher:"kanonak.org",package_:"look",name:"alphaPath"},zt={publisher:"kanonak.org",package_:"look",name:"betaPath"},Ye={publisher:"kanonak.org",package_:"look",name:"SectionHeading"},Wt={publisher:"kanonak.org",package_:"look",name:"SectionNav"},mn={publisher:"kanonak.org",package_:"look",name:"heading"},Yt={publisher:"kanonak.org",package_:"look",name:"note"},qt={publisher:"kanonak.org",package_:"look",name:"VersionDelta"},Xt={publisher:"kanonak.org",package_:"look",name:"TimePlot"},Zt={publisher:"kanonak.org",package_:"look",name:"Details"},Jt={publisher:"kanonak.org",package_:"look",name:"EmbeddedViews"},Qt={publisher:"kanonak.org",package_:"look",name:"skip"},ea={publisher:"kanonak.org",package_:"derivation",name:"derivations"},na={publisher:"kanonak.org",package_:"look",name:"laneBy"},ta={publisher:"kanonak.org",package_:"look",name:"stats"},aa={publisher:"kanonak.org",package_:"look",name:"statPath"},sa={publisher:"kanonak.org",package_:"look",name:"statLabel"},hn={publisher:"kanonak.org",package_:"look",name:"labelPath"},oa={publisher:"kanonak.org",package_:"look",name:"badgePath"},qe={publisher:"kanonak.org",package_:"look",name:"orderBy"},bn={publisher:"kanonak.org",package_:"look",name:"track"},Fe={publisher:"kanonak.org",package_:"look",name:"metricPath"},Xe={publisher:"kanonak.org",package_:"look",name:"hueBy"},vn={publisher:"kanonak.org",package_:"look",name:"lowerPath"},$n={publisher:"kanonak.org",package_:"look",name:"upperPath"},ra={publisher:"kanonak.org",package_:"look",name:"axisMin"},ia={publisher:"kanonak.org",package_:"look",name:"axisMax"},ca={publisher:"kanonak.org",package_:"look",name:"valueLabel"};var _n={publisher:"kanonak.org",package_:"look",name:"semanticSvg"},la={publisher:"kanonak.org",package_:"look",name:"tierChip"},ua={publisher:"kanonak.org",package_:"look",name:"tierIcon"},da={publisher:"kanonak.org",package_:"look",name:"tierCard"},pa={publisher:"kanonak.org",package_:"look",name:"tierFull"},fa={publisher:"kanonak.org",package_:"core-rdf",name:"type"},jn=6,Ze={publisher:"kanonak.org",package_:"look",name:"bands"},ga={publisher:"kanonak.org",package_:"look",name:"title"},ka={publisher:"kanonak.org",package_:"look",name:"eyebrow"},ma={publisher:"kanonak.org",package_:"look",name:"subtitle"},Sn={publisher:"kanonak.org",package_:"look",name:"badges"},ae={publisher:"kanonak.org",package_:"look",name:"source"},ha={publisher:"kanonak.org",package_:"look",name:"via"},ba={publisher:"kanonak.org",package_:"look",name:"size"},va={publisher:"kanonak.org",package_:"look",name:"icon"},$a={publisher:"kanonak.org",package_:"look",name:"avatar"},_a={publisher:"kanonak.org",package_:"look",name:"contents"},ja={publisher:"kanonak.org",package_:"look",name:"transitive"},Sa={publisher:"kanonak.org",package_:"look",name:"chips"},Rn={publisher:"kanonak.org",package_:"look",name:"entries"},Ra={publisher:"kanonak.org",package_:"look",name:"urlForm"},tn=class{constructor(e){this.catalog=e}catalog;linkMode="single-publisher";setLinkMode(e){return this.linkMode=e,this}get publisherFirst(){return this.linkMode==="open-world"}linkBase(e){return this.publisherFirst?`/${e}`:""}resourceHref(e,n,a="="){return sn.formatResourceUrl(e,a,{contextPublisher:n,...this.publisherFirst?{publisherFirst:!0}:{}})}packageHref(e,n,a){return`${this.linkBase(e)}/${n}${a?`/${a}`:""}`}publisherHref(e){return`${this.linkBase(e)}/`}_codeHighlighter;findCascadedLook(e){let n=Ka(e)?void 0:Te(e);return n?{declaration:n,sourceClass:{publisher:B(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name}}:this.lookFromTypeRefs(ce(e))}lookFromTypeRefs(e){let n=new Set,a=[...e];for(;a.length>0;){let o=a.shift().subject,s=z(o);if(n.has(s))continue;n.add(s);let r=de(this.catalog,o);for(let i of r){let c=Te(i);if(c)return{declaration:c,sourceClass:{publisher:o.publisher,package_:o.package_,name:o.name}}}for(let i of r)for(let c of Ee(i))a.push(c)}if(!n.has(z(ke)))for(let t of de(this.catalog,ke)){let o=Te(t);if(o)return{declaration:o,sourceClass:{...ke}}}}findCascadedTokens(e){let n=new Map;for(let[o,s]of Je(e))n.has(o)||n.set(o,s);let a=new Set,t=ce(e);for(;t.length>0;){let o=t.shift(),s=z(o.subject);if(a.has(s))continue;a.add(s);let r=de(this.catalog,o.subject);if(r.length!==0)for(let i of r){for(let[c,l]of Je(i))n.has(c)||n.set(c,l);for(let c of Ee(i))t.push(c)}}if(!a.has(z(ke))){let o=de(this.catalog,ke);for(let s of o)for(let[r,i]of Je(s))n.has(r)||n.set(r,i)}return n}renderSvg(e){let n=A(this.catalog,e).label,a=(n.trim().charAt(0)||"?").toUpperCase(),t=`${e.namespace??""}/${e.name}`,o={label:n,firstLetter:a,uri:t},s=this.collectCascadedSvgTiers(e),r=k=>this.applyPlaceholders(k,e,o),i=r(s.tierChip??""),c=r(s.tierIcon??""),l=r(s.tierCard??""),d=r(s.tierFull??""),g=[...this.findCascadedTokens(e)].map(([k,f])=>`--kan-${k}: ${f};`).join(" ");return`<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 400 400" style="${me(g)}">
66
66
  <style>
67
67
  .tier-chip,.tier-icon,.tier-card{display:none}
68
68
  .tier-full{display:block}
@@ -74,7 +74,7 @@ if(document.readyState!=='loading')enhance();else document.addEventListener('DOM
74
74
  <g class="tier-icon">${c}</g>
75
75
  <g class="tier-card">${l}</g>
76
76
  <g class="tier-full">${d}</g>
77
- </svg>`}applyPlaceholders(e,n,a){return e.replace(/\{\{#([^}]+)\}\}([\s\S]*?)\{\{\/\1\}\}/g,(o,s,r)=>this.placeholderResolves(String(s).trim(),n,a)?r:"").replace(/\{\{([^}]+)\}\}/g,(o,s)=>{let r=s.trim();if(a[r]!==void 0)return me(a[r]);let i=r.indexOf(":");if(i>0){let l=r.slice(0,i),d=r.slice(i+1).trim();if(l==="delta"||l==="deltaArrow"||l==="deltaColor"||l==="deltaDir"){let u=this.metricDelta(n,d);return l==="deltaColor"?u?u.dir==="up"?"#34d399":u.dir==="down"?"#f87171":"#9aa5b8":"#9aa5b8":l==="deltaDir"?u?u.dir:"new":u?l==="deltaArrow"?u.dir==="up"?"\u25B2":u.dir==="down"?"\u25BC":"\u2014":me(`${u.delta>0?"+":""}${u.delta.toFixed(2)}`):""}if(l==="svg")return this.resolvePath(n,d)??""}let c=this.resolvePath(n,r);return c===void 0?`{{${r}}}`:me(c)})}placeholderResolves(e,n,a){if(a[e]!==void 0)return a[e]!=="";let t=e.indexOf(":");if(t>0){let s=e.slice(0,t),r=e.slice(t+1).trim();if(s==="delta"||s==="deltaArrow")return this.metricDelta(n,r)!==void 0;if(s==="deltaColor"||s==="deltaDir")return!0;if(s==="svg"){let i=this.resolvePath(n,r);return i!==void 0&&i!==""}}let o=this.resolvePath(n,e);return o!==void 0&&o!==""}metricDelta(e,n){let a=g=>{let k=this.resolvePath(g,n),f=k===void 0?NaN:parseFloat(k);return Number.isFinite(f)?f:void 0},t=a(e);if(t===void 0)return;let o=g=>oe((g.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},s=(g,k)=>g.major-k.major||g.minor-k.minor||g.patch-k.patch,r={publisher:B(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name},i=o(e),c,l;for(let g of fe(this.catalog,r)){let k=o(g);s(k,i)<0&&(!l||s(k,l)>0)&&(c=g,l=k)}if(!c)return;let d=a(c);if(d===void 0)return;let u=t-d;return{delta:u,dir:Math.abs(u)<.005?"flat":u>0?"up":"down"}}resolvePath(e,n){let a=n.split("/").map(t=>t.trim()).filter(t=>t.length>0);if(a.length!==0)return this.resolvePathSteps(e,a)}resolvePathSteps(e,n){let a=xa(n[0]);if(n.length===1){let s=[];for(let r of wa(e,a))for(let i of this.finalStatementTexts(r))i!==""&&s.push(i);return s.length>0?s.join(", "):void 0}let o=La(e,a);if(o){if(o instanceof re)return this.resolvePathSteps(o.object,n.slice(1));if(o instanceof N&&o.object instanceof O){let s=o.object.subject,r=fe(this.catalog,s);if(r.length===0){let c=H(this.catalog,s);c&&r.push(c)}let i=n.slice(1);for(let c of r){let l=this.resolvePathSteps(c,i);if(l!==void 0)return l}return}}}finalStatementTexts(e){if(e instanceof N&&e.object instanceof O)return[this.referenceLabel(e.object)];if(e instanceof Q)return[String(e.object)];if(e instanceof ve)return[String(e.object)];if(e instanceof ue)return[String(e.object)];if(e instanceof W){let n=[];for(let a of e.object??[]){if(a instanceof O){n.push(this.referenceLabel(a));continue}let t=a.value;(typeof t=="string"||typeof t=="number"||typeof t=="boolean")&&n.push(String(t))}return n}return[]}referenceLabel(e){let n=e.subject,a=fe(this.catalog,n);if(a.length===0){let t=H(this.catalog,n);t&&a.push(t)}for(let t of a){let o=A(this.catalog,t);if(o.label!==t.name)return o.label}return n.name}collectCascadedSvgTiers(e){let n={},a=s=>{let r=P(s,_n);if(!(r instanceof re))return;let i=r.object,c=L(i,la),l=L(i,ua),d=L(i,da),u=L(i,pa);n.tierChip===void 0&&c!==void 0&&(n.tierChip=c),n.tierIcon===void 0&&l!==void 0&&(n.tierIcon=l),n.tierCard===void 0&&d!==void 0&&(n.tierCard=d),n.tierFull===void 0&&u!==void 0&&(n.tierFull=u)};a(e);let t=new Set,o=ce(e);for(;o.length>0;){let s=o.shift(),r=z(s.subject);if(t.has(r))continue;t.add(r);let i=fe(this.catalog,s.subject);for(let c of i){a(c);for(let l of Ee(c))o.push(l)}}if(!t.has(z(ke)))for(let s of fe(this.catalog,ke))a(s);return n}renderStylesheet(e){let n=this.findCascadedTokens(e),a=[];for(let[s,r]of n)a.push(` --kan-${s}: ${r};`);let t=a.length>0?`:root {
77
+ </svg>`}applyPlaceholders(e,n,a){return e.replace(/\{\{#([^}]+)\}\}([\s\S]*?)\{\{\/\1\}\}/g,(o,s,r)=>this.placeholderResolves(String(s).trim(),n,a)?r:"").replace(/\{\{([^}]+)\}\}/g,(o,s)=>{let r=s.trim();if(a[r]!==void 0)return me(a[r]);let i=r.indexOf(":");if(i>0){let l=r.slice(0,i),d=r.slice(i+1).trim();if(l==="delta"||l==="deltaArrow"||l==="deltaColor"||l==="deltaDir"){let u=this.metricDelta(n,d);return l==="deltaColor"?u?u.dir==="up"?"#34d399":u.dir==="down"?"#f87171":"#9aa5b8":"#9aa5b8":l==="deltaDir"?u?u.dir:"new":u?l==="deltaArrow"?u.dir==="up"?"\u25B2":u.dir==="down"?"\u25BC":"\u2014":me(`${u.delta>0?"+":""}${u.delta.toFixed(2)}`):""}if(l==="svg")return this.resolvePath(n,d)??""}let c=this.resolvePath(n,r);return c===void 0?`{{${r}}}`:me(c)})}placeholderResolves(e,n,a){if(a[e]!==void 0)return a[e]!=="";let t=e.indexOf(":");if(t>0){let s=e.slice(0,t),r=e.slice(t+1).trim();if(s==="delta"||s==="deltaArrow")return this.metricDelta(n,r)!==void 0;if(s==="deltaColor"||s==="deltaDir")return!0;if(s==="svg"){let i=this.resolvePath(n,r);return i!==void 0&&i!==""}}let o=this.resolvePath(n,e);return o!==void 0&&o!==""}metricDelta(e,n){let a=g=>{let k=this.resolvePath(g,n),f=k===void 0?NaN:parseFloat(k);return Number.isFinite(f)?f:void 0},t=a(e);if(t===void 0)return;let o=g=>oe((g.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},s=(g,k)=>g.major-k.major||g.minor-k.minor||g.patch-k.patch,r={publisher:B(e),package_:(e.namespace||"").split("/")[1]?.split("@")[0]??"",name:e.name},i=o(e),c,l;for(let g of de(this.catalog,r)){let k=o(g);s(k,i)<0&&(!l||s(k,l)>0)&&(c=g,l=k)}if(!c)return;let d=a(c);if(d===void 0)return;let u=t-d;return{delta:u,dir:Math.abs(u)<.005?"flat":u>0?"up":"down"}}resolvePath(e,n){let a=n.split("/").map(t=>t.trim()).filter(t=>t.length>0);if(a.length!==0)return this.resolvePathSteps(e,a)}resolvePathSteps(e,n){let a=xa(n[0]);if(n.length===1){let s=[];for(let r of wa(e,a))for(let i of this.finalStatementTexts(r))i!==""&&s.push(i);return s.length>0?s.join(", "):void 0}let o=La(e,a);if(o){if(o instanceof re)return this.resolvePathSteps(o.object,n.slice(1));if(o instanceof N&&o.object instanceof O){let s=o.object.subject,r=de(this.catalog,s);if(r.length===0){let c=H(this.catalog,s);c&&r.push(c)}let i=n.slice(1);for(let c of r){let l=this.resolvePathSteps(c,i);if(l!==void 0)return l}return}}}finalStatementTexts(e){if(e instanceof N&&e.object instanceof O)return[this.referenceLabel(e.object)];if(e instanceof Q)return[String(e.object)];if(e instanceof ve)return[String(e.object)];if(e instanceof ue)return[String(e.object)];if(e instanceof W){let n=[];for(let a of e.object??[]){if(a instanceof O){n.push(this.referenceLabel(a));continue}let t=a.value;(typeof t=="string"||typeof t=="number"||typeof t=="boolean")&&n.push(String(t))}return n}return[]}referenceLabel(e){let n=e.subject,a=de(this.catalog,n);if(a.length===0){let t=H(this.catalog,n);t&&a.push(t)}for(let t of a){let o=A(this.catalog,t);if(o.label!==t.name)return o.label}return n.name}collectCascadedSvgTiers(e){let n={},a=i=>{let c=P(i,_n);if(!(c instanceof re))return;let l=c.object,d=L(l,la),u=L(l,ua),g=L(l,da),k=L(l,pa);n.tierChip===void 0&&d!==void 0&&(n.tierChip=d),n.tierIcon===void 0&&u!==void 0&&(n.tierIcon=u),n.tierCard===void 0&&g!==void 0&&(n.tierCard=g),n.tierFull===void 0&&k!==void 0&&(n.tierFull=k)};a(e);let t=e.namespace||"",o=t.indexOf("/");if(o>=0){let i=t.indexOf("@"),c={publisher:t.slice(0,o),package_:t.slice(o+1,i>=0?i:t.length),name:e.name};for(let l of de(this.catalog,c))a(l)}let s=new Set,r=ce(e);for(;r.length>0;){let i=r.shift(),c=z(i.subject);if(s.has(c))continue;s.add(c);let l=de(this.catalog,i.subject);for(let d of l){a(d);for(let u of Ee(d))r.push(u)}}if(!s.has(z(ke)))for(let i of de(this.catalog,ke))a(i);return n}renderStylesheet(e){let n=this.findCascadedTokens(e),a=[];for(let[s,r]of n)a.push(` --kan-${s}: ${r};`);let t=a.length>0?`:root {
78
78
  ${a.join(`
79
79
  `)}
80
80
  }`:":root { /* no tokens resolved */ }",o=this.findBaseStylesheet(B(e))??"";return`${t}
@@ -120,13 +120,13 @@ ${s}${a}
120
120
  ${c}
121
121
  </body>
122
122
  </html>
123
- `}hasSvgDerivation(e){let n=new Set,a=ce(e);for(;a.length>0;){let t=a.shift(),o=z(t.subject);if(n.has(o))continue;n.add(o);let s=H(this.catalog,t.subject);if(s){for(let r of s.statement)if(r instanceof W&&ge(r,"kanonak.org","derivation","derivations")){for(let i of r.object??[])if(i instanceof q)for(let c of i.statement){if(!(c instanceof N)||!ge(c,"kanonak.org","derivation","format")||!(c.object instanceof O))continue;let l=c.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let r of Ee(s))a.push(r)}}return!1}renderBand(e,n,a,t=[],o=""){let s=ye(e);return s?R(s,Wt)?this.renderSectionNav(t):R(s,Nn)?this.renderHero(e,n,a):R(s,Pn)?this.renderPropertyList(e,n,a):R(s,Vn)?this.renderPropertyTable(e,n,a,o):R(s,Hn)?this.renderBadgeRow(e,n,a):R(s,Bn)?this.renderChipRow(e,n,a):R(s,Gn)?this.renderReferenceList(e,n,a):R(s,zn)?this.renderReferencedBy(e,n,a):R(s,Wn)?this.renderInstances(e,n,a):R(s,gn)?this.renderMarkdown(e,n,a):R(s,Pt)?this.renderLinks(e,n):R(s,Yn)?this.renderNavGroup(n,a):R(s,Qn)?this.renderResourceGrid(e,a,n):R(s,et)?this.renderTimeline(e,a):R(s,nt)?this.renderVersionDiff(e,a):R(s,tt)?this.renderFigure(e,n,a):R(s,at)?this.renderDiagram(e,n,a):R(s,wt)?this.renderStatRow(e,n):R(s,Ot)?this.renderHorizon(e,n,a):R(s,Et)?this.renderPackageContents(n,a):R(s,Ut)?this.renderFeaturedResource(e,a):R(s,Ft)?this.renderPublisherPackages(e,a):R(s,Bt)?this.renderDistribution(e,n):R(s,Ye)?this.renderSectionHeading(e):R(s,qt)?this.renderVersionDelta(e,n):R(s,Xt)?this.renderTimePlot(e,n,a):R(s,Zt)?this.renderDetails(e,n,a):R(s,Jt)?this.renderEmbeddedViews(e,n,a,o):`<!-- LookRenderer: unsupported band ${s.publisher}/${s.package_}/${s.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}collectTrackedSeries(e,n,a,t){let{hueBy:o,lowerPath:s,upperPath:r}=t??{},i=new Map,c=e.length,l=(d,u)=>{let g=this.resolvePath(d,u);return g===void 0?NaN:parseFloat(g)};return e.forEach((d,u)=>{let g=this.readPropertyValueReferences(d,n);for(let k of g){let f=H(this.catalog,{publisher:k.subject.publisher,package_:k.subject.package_,name:k.subject.name,...k.subject.version?{version:k.subject.version}:{}});if(!f)continue;let m=k.subject.name,b=i.get(m);b||(b={key:m,label:A(this.catalog,f).label,points:new Array(c).fill(null),...s?{lower:new Array(c).fill(null)}:{},...r?{upper:new Array(c).fill(null)}:{}},i.set(m,b));let _=l(f,a);if(Number.isFinite(_)&&(b.points[u]=_),s&&b.lower){let $=l(f,s);Number.isFinite($)&&(b.lower[u]=$)}if(r&&b.upper){let $=l(f,r);Number.isFinite($)&&(b.upper[u]=$)}if(o){let $=l(f,o);Number.isFinite($)&&(b.hue=$)}b.lastSubject=f}}),[...i.values()]}hrefForSubject(e,n,a="="){let t=e.namespace||"",o=t.split("/")[1]?.split("@")[0]??"",s=t.split("@")[1]??"",r=s?oe(s):void 0;return this.resourceHref({publisher:B(e),package_:o,name:e.name,...r?{version:r}:{}},n,a)}renderVersionDiff(e,n){let a=M(e,ae);if(!a)return"<!-- LookRenderer.VersionDiff: no look.source -->";let t=L(e,Fe),o=M(e,bn);if(!o||!t)return"<!-- LookRenderer.VersionDiff: needs look.track + look.metricPath -->";let s=M(e,qe),r=L(e,Xe),i=this.findInstancesOfClass(a);if(i.length===0)return"<!-- LookRenderer.VersionDiff: no instances -->";let c=g=>s?this.readPropertyValueText(g,s)??"":"",l=i.slice().sort((g,k)=>c(g).localeCompare(c(k))),d=this.collectTrackedSeries(l,o,t,{hueBy:r});return d.length===0?"<!-- LookRenderer.VersionDiff: no tracked series -->":`<section class="kan-vdiff">${d.map((g,k)=>{let f=g.hue!==void 0?g.hue:Math.round(k*360/d.length),m=g.points.filter(x=>x!==null);if(m.length===0)return"";let b=m[0],_=m[m.length-1],$=_-b,S;if(Math.abs($)>=.005){let x=$>0?"up":"down",I=$>0?"\u25B2":"\u25BC";S=`<span class="kan-vdiff-delta ${x}">${$>0?"+":""}${$.toFixed(2)} ${I}</span>`}else S='<span class="kan-vdiff-delta flat">\u2014</span>';let w=g.lastSubject&&this.isLinkable(B(g.lastSubject),n)?`<a href="${p(this.hrefForSubject(g.lastSubject,n))}">${p(g.label)}</a>`:p(g.label);return`<div class="kan-vdiff-row" style="--kan-vdiff-hue:${f}"><span class="kan-vdiff-label">${w}</span><span class="kan-vdiff-start">${b.toFixed(2)}</span>`+this.sparkline(g.points,f)+`<span class="kan-vdiff-end">${_.toFixed(2)}</span>`+S+"</div>"}).join("")}</section>`}sparkline(e,n){let s=`hsl(${n},65%,60%)`,r=e.filter(m=>m!==null);if(r.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(...r),l=Math.max(...r)-i,d=e.length,u=m=>d<=1?132/2:4+m/(d-1)*124,g=m=>l<1e-9?30/2:26-(m-i)/l*22,k=[],f=[];return e.forEach((m,b)=>{if(m===null)return;let _=u(b),$=g(m);k.push(`${_.toFixed(1)},${$.toFixed(1)}`),f.push(`<circle cx="${_.toFixed(1)}" cy="${$.toFixed(1)}" r="2" fill="${s}"/>`)}),`<svg class="kan-vdiff-spark" viewBox="0 0 132 30" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" role="img"><polyline points="${k.join(" ")}" fill="none" stroke="${s}" stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round"/>`+f.join("")+"</svg>"}svgUrlForSubject(e,n,a="="){return`${this.hrefForSubject(e,n,a)}.svg`}renderFigure(e,n,a){let t=n,o=M(e,ae);if(o){let l=H(this.catalog,o);l&&(t=l)}let s=this.svgUrlForSubject(t,a),r=A(this.catalog,t).label,i=L(e,ba);return`<figure class="kan-figure${i==="small"||i==="medium"||i==="large"?` kan-figure-${i}`:""}"><img class="kan-figure-img" src="${p(s)}" alt="${p(r)}" loading="lazy"/></figure>`}diagramArrowSeq=0;diagramScriptEmitted=!1;renderDiagram(e,n,a,t=0,o=new Set){let s=this.gatherValueItems(P(e,st)).filter(k=>k instanceof q);if(s.length===0)return"<!-- LookRenderer.Diagram: no look.facets -->";let r=[];for(let k of s){let f=M(k,ot);if(!f){r.push("<!-- LookRenderer.Diagram: facet has no resolvable look.relation -->");continue}let m=M(k,rt),b=this.resolveFacetNodes(n,f);if(b.length===0){r.push(`<!-- LookRenderer.Diagram: relation ${f.publisher}/${f.package_}/${f.name} resolved to 0 instances -->`);continue}let _=this.resolveFacetChannels(k,b),$=P(k,pt),S=$ instanceof re&&$.object instanceof q?$.object:void 0,w=L(k,kt),x=w&&Oe[w]!==void 0?Oe[w]:void 0,I=x??this.classTierSize(b),F=yt[I??Oe.icon]??"icon",D=L(k,ht),Y=M(k,ft),T=Y?H(this.catalog,Y):void 0;if(T){r.push(this.renderDiagramExpand(b,T,a,t,o,D,x));continue}if(m&&R(m,ct)){let E=M(k,gt),V=this.facetEdgeLabel(k,E??f),ee=L(k,$t);r.push(this.embedTiers(F,le=>E?this.renderDiagramDag(b,E,_,a,le,V,ee):this.renderDiagramConnector(n,b,_,a,le,V,ee)));continue}if(m&&!R(m,it)){r.push(`<!-- LookRenderer.Diagram: unknown encode role ${m.publisher}/${m.package_}/${m.name} -->`);continue}r.push(S?`<div class="kan-dgm-tiers" data-geo="1"><div class="kan-dgm-tier" data-tier="card">${this.renderDiagramCluster(b,_,S,a,I)}</div></div>`:this.embedTiers(F,E=>this.renderDiagramCluster(b,_,void 0,a,E)))}let i=L(e,_t),c=L(e,jt),l=k=>`<div class="kan-diagram-title" style="font-weight:600;font-size:0.95rem;color:var(--kan-text);${k}">${p(i)}</div>`,d=i&&c!=="bottom"?l("margin:0 0 .5rem"):"",u=i&&c==="bottom"?l("margin:.5rem 0 0"):"",g="";return t===0&&!this.diagramScriptEmitted&&(this.diagramScriptEmitted=!0,g=`<script>${St}</script>`),`<section class="kan-diagram">${d}${r.join("")}${u}${g}</section>`}embedTiers(e,n){return`<div class="kan-dgm-tiers">${Rt.map(t=>`<div class="kan-dgm-tier" data-tier="${t}"${t===e?"":" hidden"}>${n(Oe[t])}</div>`).join("")}</div>`}renderDiagramExpand(e,n,a,t,o,s,r){return`<figure class="kan-diagram-figure"><div class="kan-diagram-tree">${e.map(c=>{let l=`${c.namespace??""}/${c.name}`,d=this.diagramNodeRow(c,a,r??56,s),g=t<Lt&&!o.has(l)?this.renderDiagram(n,c,a,t+1,new Set([...o,l])):"",k=g?`<div style="margin-left:30px;border-left:2px solid var(--kan-border);padding-left:14px;margin-top:6px">${g}</div>`:"";return`<div class="kan-diagram-node" style="margin:6px 0">${d}${k}</div>`}).join("")}</div></figure>`}diagramNodeRow(e,n,a=56,t){let o=this.hrefForSubject(e,n),s=this.svgUrlForSubject(e,n),r=A(this.catalog,e).label,i=t?this.resolvePath(e,t):void 0,c=i!==void 0?`<span class="kan-diagram-node-note" style="display:block;font-size:0.8em;color:var(--kan-text-dim)">${p(i)}</span>`:"";return`<a href="${p(o)}" style="display:inline-flex;align-items:center;gap:10px;text-decoration:none"><img src="${p(s)}" width="${a}" height="${a}" alt="" loading="lazy"/><span><span class="kan-diagram-node-label">${p(r)}</span>${c}</span></a>`}classTierSize(e){let n;for(let a of e)for(let t of ce(a)){let o=H(this.catalog,t.subject);if(!o)continue;let s=L(o,mt),r=s?Oe[s]:void 0;r!==void 0&&(n=n===void 0?r:Math.max(n,r))}return n}resolveFacetNodes(e,n){let a=[];for(let t of this.readPropertyValueReferences(e,n)){let o=t.subject,s=H(this.catalog,{publisher:o.publisher,package_:o.package_,name:o.name,...o.version?{version:o.version}:{}});s&&a.push(s)}return a}resolveFacetChannels(e,n){let a=this.gatherValueItems(P(e,lt)).filter(o=>o instanceof q),t=[];for(let o of a){let s=L(o,ut),r=L(o,dt);if(!s||!r)continue;let i=n.map(k=>{let f=this.resolvePath(k,s),m=f===void 0?NaN:parseFloat(f);return Number.isFinite(m)?m:NaN}),c=i.filter(k=>Number.isFinite(k)),l=c.length?Math.min(...c):0,u=(c.length?Math.max(...c):0)-l,g=i.map(k=>Number.isFinite(k)&&u>0?(k-l)/u:.5);t.push({to:r,norm:g})}return t}facetEdgeLabel(e,n){let a=L(e,bt);if(a)return a;if(ya(e,vt)&&n){let o=H(this.catalog,n);if(o)return A(this.catalog,o).label}}edgeText(e,n,a){let t=a&&n?this.resolvePath(n,a):void 0,o=[e,t].filter(s=>!!s);return o.length?o.join(" "):void 0}edgeLabelEl(e,n,a){return`<text x="${e.toFixed(1)}" y="${n.toFixed(1)}" text-anchor="middle" class="kan-diagram-edge-label" style="font-size:11px;paint-order:stroke;stroke:var(--kan-bg);stroke-width:3px;fill:var(--kan-text-dim)">${p(a)}</text>`}renderDiagramCluster(e,n,a,t,o){let s=o??132,r=18,i=18,c=n.find(f=>f.to==="opacity");if(a)return`<figure class="kan-diagram-figure"><div class="kan-diagram-marks" style="display:flex;flex-wrap:wrap;gap:18px;align-items:flex-start">${e.map((m,b)=>{let _=this.renderBand(a,m,t),$=this.hrefForSubject(m,t),S=A(this.catalog,m).label,w=c?`opacity:${(.4+c.norm[b]*.6).toFixed(2)};`:"";return`<a class="kan-diagram-mark" href="${p($)}" style="display:block;text-decoration:none;${w}">${_}<span class="kan-diagram-mark-label">${p(S)}</span></a>`}).join("")}</div></figure>`;let l=Math.min(e.length,4),d=Math.ceil(e.length/l),u=i*2+l*s+(l-1)*r,g=i*2+d*s+(d-1)*r,k=e.map((f,m)=>{let b=m%l,_=Math.floor(m/l),$=i+b*(s+r),S=i+_*(s+r),w=c?.4+c.norm[m]*.6:1;return this.diagramTile(f,$,S,s,t,w)}).join("");return`<figure class="kan-diagram-figure"><svg class="kan-diagram-svg" viewBox="0 0 ${u} ${g}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">${k}</svg></figure>`}renderDiagramConnector(e,n,a,t,o,s,r){let i=o??120,c=24,l=130,d=18,u=a.find(Y=>Y.to==="thickness"),g=a.find(Y=>Y.to==="opacity"),k=n.length,f=k*i+(k-1)*c,m=d*2+f,b=d*2+i+l+i,_=d,$=d+(f-i)/2,S=d+i+l,w=`kan-arrow-${this.diagramArrowSeq++}`,x=[],I=[],F=[];n.forEach((Y,T)=>{let E=d+T*(i+c),V=_+i,ee=$+i/2,le=S-pe,K=E+i/2,G=(V+S)/2,v=u?1.5+u.norm[T]*5.5:2,y=g?.4+g.norm[T]*.6:1,U=g?` stroke-opacity="${y.toFixed(2)}"`:"";x.push(`<path d="M${V.toFixed(1)},${ee.toFixed(1)} C${G.toFixed(1)},${ee.toFixed(1)} ${G.toFixed(1)},${K.toFixed(1)} ${le.toFixed(1)},${K.toFixed(1)}" class="kan-diagram-edge" fill="none" stroke="var(--kan-border)" stroke-width="${v.toFixed(1)}"${U} marker-end="url(#${w})"/>`);let j=this.edgeText(s,Y,r);j&&I.push(this.edgeLabelEl((V+S)/2,(ee+K)/2-5,j)),F.push(this.diagramTile(Y,S,E,i,t,g?y:1))});let D=this.diagramTile(e,_,$,i,t);return`<figure class="kan-diagram-figure"><svg class="kan-diagram-svg" viewBox="0 0 ${b.toFixed(0)} ${m.toFixed(0)}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">${this.arrowMarkerDef(w,"var(--kan-border)")}${x.join("")}${I.join("")}${D}${F.join("")}</svg></figure>`}arrowMarkerDef(e,n){return`<defs><marker id="${e}" viewBox="0 0 ${pe} ${pe}" refX="0" refY="${(pe/2).toFixed(1)}" markerWidth="${pe}" markerHeight="${pe}" markerUnits="userSpaceOnUse" orient="auto"><path d="M0,1 L${pe},${(pe/2).toFixed(1)} L0,${pe-1}" fill="${n}"/></marker></defs>`}renderDiagramDag(e,n,a,t,o,s,r){let i=o??110,c=110,l=22,d=18,u=new Map(e.map((v,y)=>[v.name,y])),g=new Set(e.map(v=>v.name)),k=new Map(e.map(v=>[v.name,[]])),f=new Map(e.map(v=>[v.name,[]]));for(let v of e)for(let y of this.readPropertyValueReferences(v,n)){let U=y.subject.name;U!==v.name&&g.has(U)&&(k.get(v.name).push(U),f.get(U).push(v.name))}let m=new Map,b=new Set,_=v=>{let y=m.get(v);if(y!==void 0)return y;if(b.has(v))return 0;b.add(v);let U=0;for(let j of f.get(v)??[])U=Math.max(U,_(j)+1);return b.delete(v),m.set(v,U),U};for(let v of e)_(v.name);let $=Math.min(...m.values());if($>0)for(let v of[...m.keys()])m.set(v,m.get(v)-$);let S=Math.max(0,...m.values()),w=Array.from({length:S+1},()=>[]);for(let v of e)w[m.get(v.name)].push(v);let x=Math.max(1,...w.map(v=>v.length)),I=!1;for(let[v,y]of k)for(let U of y)m.get(U)<=m.get(v)&&(I=!0);let F=I?84:0,D=x*i+(x-1)*l,Y=d*2+(S+1)*i+S*c,T=d*2+F+D,E=new Map;w.forEach((v,y)=>{let U=v.length*i+(v.length-1)*l,j=d+F+(D-U)/2;v.forEach((C,X)=>E.set(C.name,{x:d+y*(i+c),y:j+X*(i+l)}))});let V=a.find(v=>v.to==="thickness"),ee=`kan-arrow-${this.diagramArrowSeq++}`,le=[],K=[];for(let[v,y]of k){let U=E.get(v);for(let j of y){let C=E.get(j),X=C.x>=U.x,se=V?1.5+V.norm[u.get(v)]*4.5:2,Z,ne,te;if(X){let J=U.x+i,$e=U.y+i/2,be=C.x-pe,Ke=C.y+i/2,je=(J+be)/2;Z=`M${J.toFixed(1)},${$e.toFixed(1)} C${je.toFixed(1)},${$e.toFixed(1)} ${je.toFixed(1)},${Ke.toFixed(1)} ${be.toFixed(1)},${Ke.toFixed(1)}`,ne=(J+be)/2,te=($e+Ke)/2-5}else{let J=U.x+i/2,$e=U.y,be=C.x+i/2,Ke=C.y-pe,je=d+F*.2;Z=`M${J.toFixed(1)},${$e.toFixed(1)} C${J.toFixed(1)},${je.toFixed(1)} ${be.toFixed(1)},${je.toFixed(1)} ${be.toFixed(1)},${Ke.toFixed(1)}`,ne=(J+be)/2,te=je+4}let he=X?"":' stroke-dasharray="6 4"';le.push(`<path d="${Z}" class="kan-diagram-edge" fill="none" stroke="var(--kan-accent)" stroke-width="${se.toFixed(1)}" stroke-opacity="0.75"${he} marker-end="url(#${ee})"/>`);let de=this.edgeText(s,e[u.get(v)],r);de&&K.push(this.edgeLabelEl(ne,te,de))}}let G=e.map(v=>{let y=E.get(v.name);return this.diagramTile(v,y.x,y.y,i,t)}).join("");return`<figure class="kan-diagram-figure"><svg class="kan-diagram-svg" viewBox="0 0 ${Y.toFixed(0)} ${T.toFixed(0)}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">${this.arrowMarkerDef(ee,"var(--kan-accent)")}${le.join("")}${K.join("")}${G}</svg></figure>`}diagramTile(e,n,a,t,o,s=1){let r=this.hrefForSubject(e,o),i=this.svgUrlForSubject(e,o),c=A(this.catalog,e).label,l=s<1?` opacity="${s.toFixed(2)}"`:"";return`<a href="${p(r)}"><image href="${p(i)}" x="${n}" y="${a}" width="${t}" height="${t}"${l}><title>${p(c)}</title></image></a>`}renderStatRow(e,n){let a=P(e,ta),t=this.gatherValueItems(a).filter(s=>s instanceof q);if(t.length===0)return"<!-- LookRenderer.StatRow: no look.stats -->";let o=[];for(let s of t){let r=L(s,aa);if(!r)continue;let i=this.resolvePath(n,r);if(i===void 0)continue;let c=L(s,sa)??"";o.push('<div class="kan-stat">'+(c?`<span class="kan-stat-label">${p(c)}</span>`:"")+`<span class="kan-stat-val">${p(i)}</span></div>`)}return o.length===0?"":`<div class="kan-stat-row">${o.join("")}</div>`}renderHorizon(e,n,a){let t=M(e,ae);if(!t)return"<!-- LookRenderer.Horizon: no look.source -->";let o=this.gatherValueItems(P(n,t)).filter(r=>r instanceof q);return o.length===0?"":`<section class="kan-horizon">${o.map(r=>this.renderConditionNode(r,a,0)).join("")}</section>`}renderConditionNode(e,n,a){let t=ye(e),o=t?this.readLabelForUri({publisher:t.publisher,package_:t.package_,name:t.name})??t.name:"Condition",s=[],r=[];for(let u of e.statement){let g=u.predicate?.subject;if(!g||g.name==="type")continue;let k=this.readLabelForUri({publisher:g.publisher,package_:g.package_,name:g.name})??g.name;if(u instanceof Q||u instanceof ve||u instanceof ue)s.push(`<div class="kan-cond-field"><span class="kan-cond-key">${p(k)}</span><span class="kan-cond-v">${p(String(u.object))}</span></div>`);else if(u instanceof N&&u.object instanceof O){let f=u.object.subject,m=this.readLabelForUri({publisher:f.publisher,package_:f.package_,name:f.name})??f.name;s.push(`<div class="kan-cond-field"><span class="kan-cond-key">${p(k)}</span><span class="kan-cond-v">${p(m)}</span></div>`)}else if(u instanceof re)r.push(this.renderConditionNode(u.object,n,a+1));else if(u instanceof W)for(let f of u.object??[])f instanceof q&&r.push(this.renderConditionNode(f,n,a+1))}let i=s.length?`<div class="kan-cond-fields">${s.join("")}</div>`:"",c=r.length?`<div class="kan-cond-children">${r.join("")}</div>`:"",l=r.length>0,d=l?`<span class="kan-cond-op">${p(o)}</span>`:`<div class="kan-cond-type">${p(o)}</div>`;return`<div class="kan-cond ${l?"kan-cond-branch":"kan-cond-leaf"}">${d}${i}${c}</div>`}renderSectionHeading(e){let n=e,a=L(n,mn);if(!a)return"<!-- LookRenderer.SectionHeading: no look.heading -->";let t=L(n,Yt);return`<div class="kan-section" id="${Kn(a)}"><h2 class="kan-section-title">${p(a)}</h2>`+(t?`<p class="kan-section-note">${p(t)}</p>`:"")+"</div>"}renderSectionNav(e){return e.length===0?"<!-- LookRenderer.SectionNav: no section headings in this view -->":`<nav class="kan-section-nav" aria-label="On this page">${e.map(a=>`<a class="kan-section-nav-link" href="#${p(a.slug)}">${p(a.label)}</a>`).join("")}</nav>`}renderVersionDelta(e,n){let t=L(e,Fe);if(!t)return"<!-- LookRenderer.VersionDelta: no look.metricPath -->";let o=T=>{let E=this.resolvePath(T,t),V=E===void 0?NaN:parseFloat(E);return Number.isFinite(V)?V:void 0},s=o(n);if(s===void 0)return"";let r=T=>oe((T.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},i=(T,E)=>T.major-E.major||T.minor-E.minor||T.patch-E.patch,c={publisher:B(n),package_:(n.namespace||"").split("/")[1]?.split("@")[0]??"",name:n.name},l=r(n),d,u;for(let T of fe(this.catalog,c)){let E=r(T);i(E,l)<0&&(!u||i(E,u)>0)&&(d=T,u=E)}if(!d||!u)return'<div class="kan-delta kan-delta-first">First tracked in this version</div>';let g=o(d);if(g===void 0)return"";let k=s-g,f=Math.abs(k)<.005?"flat":k>0?"up":"down",m=f==="up"?"\u25B2":f==="down"?"\u25BC":"\u2014",b=f==="up"?"#34d399":f==="down"?"#f87171":"var(--kan-text-faint)",_=`${u.major}.${u.minor}.${u.patch}`,$=320,S=46,w=14,x=30,I=T=>w+Math.min(1,Math.max(0,T))*($-2*w),F=I(g),D=I(s),Y=`<svg class="kan-delta-track" viewBox="0 0 ${$} ${S}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img"><line x1="${w}" y1="${x}" x2="${$-w}" y2="${x}" class="kan-delta-base"/><line x1="${F.toFixed(1)}" y1="${x}" x2="${D.toFixed(1)}" y2="${x}" stroke="${b}" stroke-width="3"/><circle cx="${F.toFixed(1)}" cy="${x}" r="4" class="kan-delta-prev"/><circle cx="${D.toFixed(1)}" cy="${x}" r="5.5" fill="${b}"/><text x="${F.toFixed(1)}" y="${x-9}" text-anchor="middle" class="kan-delta-tick kan-delta-tick-prev">${g.toFixed(2)}</text><text x="${D.toFixed(1)}" y="${x+17}" text-anchor="middle" class="kan-delta-tick">${s.toFixed(2)}</text></svg>`;return`<div class="kan-delta"><div class="kan-delta-head"><span class="kan-delta-vs">vs ${p(_)}</span><span class="kan-delta-badge ${f}">${k>0?"+":""}${k.toFixed(2)} ${m}</span></div>`+Y+"</div>"}renderTimePlot(e,n,a){let t=M(e,ae),o=M(e,qe);if(!t||!o)return"<!-- LookRenderer.TimePlot: needs look.source + look.orderBy -->";let s=e,r=L(s,na),i=L(s,hn),c=[];for(let K of this.readPropertyValueReferences(n,t)){let G=H(this.catalog,{publisher:K.subject.publisher,package_:K.subject.package_,name:K.subject.name,...K.subject.version?{version:K.subject.version}:{}});if(!G)continue;let v=this.readPropertyValueText(G,o)??"",y=Date.parse(v);if(!Number.isFinite(y))continue;let U=r?this.resolvePath(G,r)??"":"",j=(i?this.resolvePath(G,i):void 0)??A(this.catalog,G).label;c.push({t:y,dateStr:v,lane:U,label:j,href:this.hrefForSubject(G,a),linkable:this.isLinkable(B(G),a)})}if(c.length===0)return"<!-- LookRenderer.TimePlot: no dated points -->";let l=[];for(let K of c)l.includes(K.lane)||l.push(K.lane);let d=Math.min(...c.map(K=>K.t)),u=Math.max(...c.map(K=>K.t));u===d&&(u=d+1);let g=l.some(K=>K),k=720,f=g?96:16,m=18,b=12,_=24,$=36,S=b+l.length*$+_,w=f,x=k-m,I=x-w,F=K=>w+(K-d)/(u-d)*I,D=K=>b+K*$+$/2,Y=K=>Math.round(K*360/Math.max(1,l.length)),T=[];l.forEach((K,G)=>{let v=D(G);T.push(`<line x1="${w}" y1="${v.toFixed(1)}" x2="${x}" y2="${v.toFixed(1)}" class="kan-plot-guide"/>`),K&&T.push(`<text x="${(f-8).toFixed(1)}" y="${(v+4).toFixed(1)}" text-anchor="end" class="kan-plot-lane">${me(K)}</text>`)});let E={},V=[];for(let K of c){let G=l.indexOf(K.lane),y=((E[K.lane]=(E[K.lane]??0)+1)%3-1)*7,U=F(K.t),j=D(G)+y,C=`${Ce(K.dateStr)} \xB7 ${K.label}`,X=`<circle cx="${U.toFixed(1)}" cy="${j.toFixed(1)}" r="5" fill="hsl(${Y(G)},65%,60%)" class="kan-plot-pt"><title>${me(C)}</title></circle>`;V.push(K.linkable?`<a href="${p(K.href)}" class="kan-plot-link">${X}</a>`:X)}let ee=`<text x="${w}" y="${(S-6).toFixed(1)}" text-anchor="start" class="kan-plot-axis">${me(Ce(new Date(d).toISOString()))}</text><text x="${x}" y="${(S-6).toFixed(1)}" text-anchor="end" class="kan-plot-axis">${me(Ce(new Date(u).toISOString()))}</text>`;return`<section class="kan-plot">${`<svg class="kan-plot-svg" viewBox="0 0 ${k} ${S}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">`+T.join("")+V.join("")+ee+"</svg>"}</section>`}renderDetails(e,n,a){let t=en(e,Qt),o=this.detailRows(n,a,t);return o?`<dl class="kan-details">${o}</dl>`:"<!-- LookRenderer.Details: no properties -->"}detailRows(e,n,a){let t=[];for(let o of e.statement){let s=o.predicate?.subject;if(!s||this.isMetaPredicate(s)||a.some(c=>R(c,s)))continue;let r=this.readLabelForUri({publisher:s.publisher,package_:s.package_,name:s.name})??s.name,i=this.detailValue(o,n,a);i&&t.push(`<dt class="kan-details-key">${p(r)}</dt><dd class="kan-details-val">${i}</dd>`)}return t.join("")}detailValue(e,n,a){if(e instanceof Q)return Ln(e.object);if(e instanceof ve||e instanceof ue)return p(String(e.object));if(e instanceof N&&e.object instanceof O)return this.detailReferenceLink(e.object,n);if(e instanceof re)return this.detailEmbedded(e.object,n,a);if(e instanceof W){let t=e.object??[];return t.length>0&&t.every(o=>o instanceof q)?t.map(o=>this.detailEmbedded(o,n,a)).join(""):t.map(o=>o instanceof O?this.detailReferenceLink(o,n):o instanceof q?this.detailEmbedded(o,n,a):p(String(o))).filter(o=>o).join(", ")}return""}detailReferenceLink(e,n){let a=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name;if(!this.isLinkable(e.subject.publisher,n))return`<span class="kan-link-plain">${p(a)}</span>`;let t=this.urlForReference(e,void 0,n);return`<img class="kan-md-chip" src="${p(`${t}.svg`)}" alt="" loading="lazy"><a class="kan-link" href="${p(t)}">${p(a)}</a>`}detailEmbedded(e,n,a){let t=ye(e),o=t?this.readLabelForUri({publisher:t.publisher,package_:t.package_,name:t.name})??t.name:"",s=this.detailRows(e,n,a);return'<div class="kan-details-embed">'+(o?`<span class="kan-details-type">${p(o)}</span>`:"")+(s?`<dl class="kan-details">${s}</dl>`:"")+"</div>"}rangeTypeRefs(e){let n=H(this.catalog,e);if(!n)return[];let a=P(n,An);return a instanceof N&&a.object instanceof O?[a.object]:[]}renderEmbeddedViews(e,n,a,t=""){let o=M(e,ae);if(!o)return"<!-- LookRenderer: EmbeddedViews missing look.source -->";let s=this.gatherValueItems(P(n,o)).filter(g=>g instanceof q);if(s.length===0)return"";let r=t?`${t}.${o.name}`:o.name,i=P(e,_a),c=i instanceof ue?i.object===!0:i instanceof Q&&i.object==="true",l=[],d=s.map(g=>{let k=g,f=g.name?`${r}.${g.name}`:"";if(c&&f){let x=A(this.catalog,k).label||g.name||f;l.push(`<a class="kan-section-nav-link" href="#${p(f)}">${p(x)}</a>`)}let m=ce(k),b=m.length>0?m:this.rangeTypeRefs(o),_=Te(k)?this.findCascadedLook(k):this.lookFromTypeRefs(b),$="";if(_)$=Qe(_.declaration).map(x=>this.renderBand(x,k,a,[],f)).join(`
123
+ `}hasSvgDerivation(e){let n=new Set,a=ce(e);for(;a.length>0;){let t=a.shift(),o=z(t.subject);if(n.has(o))continue;n.add(o);let s=H(this.catalog,t.subject);if(s){for(let r of s.statement)if(r instanceof W&&ge(r,"kanonak.org","derivation","derivations")){for(let i of r.object??[])if(i instanceof q)for(let c of i.statement){if(!(c instanceof N)||!ge(c,"kanonak.org","derivation","format")||!(c.object instanceof O))continue;let l=c.object.subject;if(l.publisher==="kanonak.org"&&l.package_==="formats"&&l.name==="svg")return!0}}for(let r of Ee(s))a.push(r)}}return!1}renderBand(e,n,a,t=[],o=""){let s=ye(e);return s?R(s,Wt)?this.renderSectionNav(t):R(s,Nn)?this.renderHero(e,n,a):R(s,Pn)?this.renderPropertyList(e,n,a):R(s,Vn)?this.renderPropertyTable(e,n,a,o):R(s,Hn)?this.renderBadgeRow(e,n,a):R(s,Bn)?this.renderChipRow(e,n,a):R(s,Gn)?this.renderReferenceList(e,n,a):R(s,zn)?this.renderReferencedBy(e,n,a):R(s,Wn)?this.renderInstances(e,n,a):R(s,gn)?this.renderMarkdown(e,n,a):R(s,Pt)?this.renderLinks(e,n):R(s,Yn)?this.renderNavGroup(n,a):R(s,Qn)?this.renderResourceGrid(e,a,n):R(s,et)?this.renderTimeline(e,a):R(s,nt)?this.renderVersionDiff(e,a):R(s,tt)?this.renderFigure(e,n,a):R(s,at)?this.renderDiagram(e,n,a):R(s,wt)?this.renderStatRow(e,n):R(s,Ot)?this.renderHorizon(e,n,a):R(s,Et)?this.renderPackageContents(n,a):R(s,Ut)?this.renderFeaturedResource(e,a):R(s,Ft)?this.renderPublisherPackages(e,a):R(s,Bt)?this.renderDistribution(e,n):R(s,Ye)?this.renderSectionHeading(e):R(s,qt)?this.renderVersionDelta(e,n):R(s,Xt)?this.renderTimePlot(e,n,a):R(s,Zt)?this.renderDetails(e,n,a):R(s,Jt)?this.renderEmbeddedViews(e,n,a,o):`<!-- LookRenderer: unsupported band ${s.publisher}/${s.package_}/${s.name} -->`:"<!-- LookRenderer: band has no rdf:type -->"}collectTrackedSeries(e,n,a,t){let{hueBy:o,lowerPath:s,upperPath:r}=t??{},i=new Map,c=e.length,l=(d,u)=>{let g=this.resolvePath(d,u);return g===void 0?NaN:parseFloat(g)};return e.forEach((d,u)=>{let g=this.readPropertyValueReferences(d,n);for(let k of g){let f=H(this.catalog,{publisher:k.subject.publisher,package_:k.subject.package_,name:k.subject.name,...k.subject.version?{version:k.subject.version}:{}});if(!f)continue;let m=k.subject.name,b=i.get(m);b||(b={key:m,label:A(this.catalog,f).label,points:new Array(c).fill(null),...s?{lower:new Array(c).fill(null)}:{},...r?{upper:new Array(c).fill(null)}:{}},i.set(m,b));let _=l(f,a);if(Number.isFinite(_)&&(b.points[u]=_),s&&b.lower){let $=l(f,s);Number.isFinite($)&&(b.lower[u]=$)}if(r&&b.upper){let $=l(f,r);Number.isFinite($)&&(b.upper[u]=$)}if(o){let $=l(f,o);Number.isFinite($)&&(b.hue=$)}b.lastSubject=f}}),[...i.values()]}hrefForSubject(e,n,a="="){let t=e.namespace||"",o=t.split("/")[1]?.split("@")[0]??"",s=t.split("@")[1]??"",r=s?oe(s):void 0;return this.resourceHref({publisher:B(e),package_:o,name:e.name,...r?{version:r}:{}},n,a)}renderVersionDiff(e,n){let a=M(e,ae);if(!a)return"<!-- LookRenderer.VersionDiff: no look.source -->";let t=L(e,Fe),o=M(e,bn);if(!o||!t)return"<!-- LookRenderer.VersionDiff: needs look.track + look.metricPath -->";let s=M(e,qe),r=L(e,Xe),i=this.findInstancesOfClass(a);if(i.length===0)return"<!-- LookRenderer.VersionDiff: no instances -->";let c=g=>s?this.readPropertyValueText(g,s)??"":"",l=i.slice().sort((g,k)=>c(g).localeCompare(c(k))),d=this.collectTrackedSeries(l,o,t,{hueBy:r});return d.length===0?"<!-- LookRenderer.VersionDiff: no tracked series -->":`<section class="kan-vdiff">${d.map((g,k)=>{let f=g.hue!==void 0?g.hue:Math.round(k*360/d.length),m=g.points.filter(x=>x!==null);if(m.length===0)return"";let b=m[0],_=m[m.length-1],$=_-b,S;if(Math.abs($)>=.005){let x=$>0?"up":"down",I=$>0?"\u25B2":"\u25BC";S=`<span class="kan-vdiff-delta ${x}">${$>0?"+":""}${$.toFixed(2)} ${I}</span>`}else S='<span class="kan-vdiff-delta flat">\u2014</span>';let w=g.lastSubject&&this.isLinkable(B(g.lastSubject),n)?`<a href="${p(this.hrefForSubject(g.lastSubject,n))}">${p(g.label)}</a>`:p(g.label);return`<div class="kan-vdiff-row" style="--kan-vdiff-hue:${f}"><span class="kan-vdiff-label">${w}</span><span class="kan-vdiff-start">${b.toFixed(2)}</span>`+this.sparkline(g.points,f)+`<span class="kan-vdiff-end">${_.toFixed(2)}</span>`+S+"</div>"}).join("")}</section>`}sparkline(e,n){let s=`hsl(${n},65%,60%)`,r=e.filter(m=>m!==null);if(r.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(...r),l=Math.max(...r)-i,d=e.length,u=m=>d<=1?132/2:4+m/(d-1)*124,g=m=>l<1e-9?30/2:26-(m-i)/l*22,k=[],f=[];return e.forEach((m,b)=>{if(m===null)return;let _=u(b),$=g(m);k.push(`${_.toFixed(1)},${$.toFixed(1)}`),f.push(`<circle cx="${_.toFixed(1)}" cy="${$.toFixed(1)}" r="2" fill="${s}"/>`)}),`<svg class="kan-vdiff-spark" viewBox="0 0 132 30" preserveAspectRatio="none" xmlns="http://www.w3.org/2000/svg" role="img"><polyline points="${k.join(" ")}" fill="none" stroke="${s}" stroke-width="1.5" stroke-linejoin="round" stroke-linecap="round"/>`+f.join("")+"</svg>"}svgUrlForSubject(e,n,a="="){return`${this.hrefForSubject(e,n,a)}.svg`}renderFigure(e,n,a){let t=n,o=M(e,ae);if(o){let l=H(this.catalog,o);l&&(t=l)}let s=this.svgUrlForSubject(t,a),r=A(this.catalog,t).label,i=L(e,ba);return`<figure class="kan-figure${i==="small"||i==="medium"||i==="large"?` kan-figure-${i}`:""}"><img class="kan-figure-img" src="${p(s)}" alt="${p(r)}" loading="lazy"/></figure>`}diagramArrowSeq=0;diagramScriptEmitted=!1;renderDiagram(e,n,a,t=0,o=new Set){let s=this.gatherValueItems(P(e,st)).filter(k=>k instanceof q);if(s.length===0)return"<!-- LookRenderer.Diagram: no look.facets -->";let r=[];for(let k of s){let f=M(k,ot);if(!f){r.push("<!-- LookRenderer.Diagram: facet has no resolvable look.relation -->");continue}let m=M(k,rt),b=this.resolveFacetNodes(n,f);if(b.length===0){r.push(`<!-- LookRenderer.Diagram: relation ${f.publisher}/${f.package_}/${f.name} resolved to 0 instances -->`);continue}let _=this.resolveFacetChannels(k,b),$=P(k,pt),S=$ instanceof re&&$.object instanceof q?$.object:void 0,w=L(k,kt),x=w&&Oe[w]!==void 0?Oe[w]:void 0,I=x??this.classTierSize(b),F=yt[I??Oe.icon]??"icon",D=L(k,ht),Y=M(k,ft),T=Y?H(this.catalog,Y):void 0;if(T){r.push(this.renderDiagramExpand(b,T,a,t,o,D,x));continue}if(m&&R(m,ct)){let E=M(k,gt),V=this.facetEdgeLabel(k,E??f),ee=L(k,$t);r.push(this.embedTiers(F,le=>E?this.renderDiagramDag(b,E,_,a,le,V,ee):this.renderDiagramConnector(n,b,_,a,le,V,ee)));continue}if(m&&!R(m,it)){r.push(`<!-- LookRenderer.Diagram: unknown encode role ${m.publisher}/${m.package_}/${m.name} -->`);continue}r.push(S?`<div class="kan-dgm-tiers" data-geo="1"><div class="kan-dgm-tier" data-tier="card">${this.renderDiagramCluster(b,_,S,a,I)}</div></div>`:this.embedTiers(F,E=>this.renderDiagramCluster(b,_,void 0,a,E)))}let i=L(e,_t),c=L(e,jt),l=k=>`<div class="kan-diagram-title" style="font-weight:600;font-size:0.95rem;color:var(--kan-text);${k}">${p(i)}</div>`,d=i&&c!=="bottom"?l("margin:0 0 .5rem"):"",u=i&&c==="bottom"?l("margin:.5rem 0 0"):"",g="";return t===0&&!this.diagramScriptEmitted&&(this.diagramScriptEmitted=!0,g=`<script>${St}</script>`),`<section class="kan-diagram">${d}${r.join("")}${u}${g}</section>`}embedTiers(e,n){return`<div class="kan-dgm-tiers">${Rt.map(t=>`<div class="kan-dgm-tier" data-tier="${t}"${t===e?"":" hidden"}>${n(Oe[t])}</div>`).join("")}</div>`}renderDiagramExpand(e,n,a,t,o,s,r){return`<figure class="kan-diagram-figure"><div class="kan-diagram-tree">${e.map(c=>{let l=`${c.namespace??""}/${c.name}`,d=this.diagramNodeRow(c,a,r??56,s),g=t<Lt&&!o.has(l)?this.renderDiagram(n,c,a,t+1,new Set([...o,l])):"",k=g?`<div style="margin-left:30px;border-left:2px solid var(--kan-border);padding-left:14px;margin-top:6px">${g}</div>`:"";return`<div class="kan-diagram-node" style="margin:6px 0">${d}${k}</div>`}).join("")}</div></figure>`}diagramNodeRow(e,n,a=56,t){let o=this.hrefForSubject(e,n),s=this.svgUrlForSubject(e,n),r=A(this.catalog,e).label,i=t?this.resolvePath(e,t):void 0,c=i!==void 0?`<span class="kan-diagram-node-note" style="display:block;font-size:0.8em;color:var(--kan-text-dim)">${p(i)}</span>`:"";return`<a href="${p(o)}" style="display:inline-flex;align-items:center;gap:10px;text-decoration:none"><img src="${p(s)}" width="${a}" height="${a}" alt="" loading="lazy"/><span><span class="kan-diagram-node-label">${p(r)}</span>${c}</span></a>`}classTierSize(e){let n;for(let a of e)for(let t of ce(a)){let o=H(this.catalog,t.subject);if(!o)continue;let s=L(o,mt),r=s?Oe[s]:void 0;r!==void 0&&(n=n===void 0?r:Math.max(n,r))}return n}resolveFacetNodes(e,n){let a=[];for(let t of this.readPropertyValueReferences(e,n)){let o=t.subject,s=H(this.catalog,{publisher:o.publisher,package_:o.package_,name:o.name,...o.version?{version:o.version}:{}});s&&a.push(s)}return a}resolveFacetChannels(e,n){let a=this.gatherValueItems(P(e,lt)).filter(o=>o instanceof q),t=[];for(let o of a){let s=L(o,ut),r=L(o,dt);if(!s||!r)continue;let i=n.map(k=>{let f=this.resolvePath(k,s),m=f===void 0?NaN:parseFloat(f);return Number.isFinite(m)?m:NaN}),c=i.filter(k=>Number.isFinite(k)),l=c.length?Math.min(...c):0,u=(c.length?Math.max(...c):0)-l,g=i.map(k=>Number.isFinite(k)&&u>0?(k-l)/u:.5);t.push({to:r,norm:g})}return t}facetEdgeLabel(e,n){let a=L(e,bt);if(a)return a;if(ya(e,vt)&&n){let o=H(this.catalog,n);if(o)return A(this.catalog,o).label}}edgeText(e,n,a){let t=a&&n?this.resolvePath(n,a):void 0,o=[e,t].filter(s=>!!s);return o.length?o.join(" "):void 0}edgeLabelEl(e,n,a){return`<text x="${e.toFixed(1)}" y="${n.toFixed(1)}" text-anchor="middle" class="kan-diagram-edge-label" style="font-size:11px;paint-order:stroke;stroke:var(--kan-bg);stroke-width:3px;fill:var(--kan-text-dim)">${p(a)}</text>`}renderDiagramCluster(e,n,a,t,o){let s=o??132,r=18,i=18,c=n.find(f=>f.to==="opacity");if(a)return`<figure class="kan-diagram-figure"><div class="kan-diagram-marks" style="display:flex;flex-wrap:wrap;gap:18px;align-items:flex-start">${e.map((m,b)=>{let _=this.renderBand(a,m,t),$=this.hrefForSubject(m,t),S=A(this.catalog,m).label,w=c?`opacity:${(.4+c.norm[b]*.6).toFixed(2)};`:"";return`<a class="kan-diagram-mark" href="${p($)}" style="display:block;text-decoration:none;${w}">${_}<span class="kan-diagram-mark-label">${p(S)}</span></a>`}).join("")}</div></figure>`;let l=Math.min(e.length,4),d=Math.ceil(e.length/l),u=i*2+l*s+(l-1)*r,g=i*2+d*s+(d-1)*r,k=e.map((f,m)=>{let b=m%l,_=Math.floor(m/l),$=i+b*(s+r),S=i+_*(s+r),w=c?.4+c.norm[m]*.6:1;return this.diagramTile(f,$,S,s,t,w)}).join("");return`<figure class="kan-diagram-figure"><svg class="kan-diagram-svg" viewBox="0 0 ${u} ${g}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">${k}</svg></figure>`}renderDiagramConnector(e,n,a,t,o,s,r){let i=o??120,c=24,l=130,d=18,u=a.find(Y=>Y.to==="thickness"),g=a.find(Y=>Y.to==="opacity"),k=n.length,f=k*i+(k-1)*c,m=d*2+f,b=d*2+i+l+i,_=d,$=d+(f-i)/2,S=d+i+l,w=`kan-arrow-${this.diagramArrowSeq++}`,x=[],I=[],F=[];n.forEach((Y,T)=>{let E=d+T*(i+c),V=_+i,ee=$+i/2,le=S-fe,K=E+i/2,G=(V+S)/2,v=u?1.5+u.norm[T]*5.5:2,y=g?.4+g.norm[T]*.6:1,U=g?` stroke-opacity="${y.toFixed(2)}"`:"";x.push(`<path d="M${V.toFixed(1)},${ee.toFixed(1)} C${G.toFixed(1)},${ee.toFixed(1)} ${G.toFixed(1)},${K.toFixed(1)} ${le.toFixed(1)},${K.toFixed(1)}" class="kan-diagram-edge" fill="none" stroke="var(--kan-border)" stroke-width="${v.toFixed(1)}"${U} marker-end="url(#${w})"/>`);let j=this.edgeText(s,Y,r);j&&I.push(this.edgeLabelEl((V+S)/2,(ee+K)/2-5,j)),F.push(this.diagramTile(Y,S,E,i,t,g?y:1))});let D=this.diagramTile(e,_,$,i,t);return`<figure class="kan-diagram-figure"><svg class="kan-diagram-svg" viewBox="0 0 ${b.toFixed(0)} ${m.toFixed(0)}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">${this.arrowMarkerDef(w,"var(--kan-border)")}${x.join("")}${I.join("")}${D}${F.join("")}</svg></figure>`}arrowMarkerDef(e,n){return`<defs><marker id="${e}" viewBox="0 0 ${fe} ${fe}" refX="0" refY="${(fe/2).toFixed(1)}" markerWidth="${fe}" markerHeight="${fe}" markerUnits="userSpaceOnUse" orient="auto"><path d="M0,1 L${fe},${(fe/2).toFixed(1)} L0,${fe-1}" fill="${n}"/></marker></defs>`}renderDiagramDag(e,n,a,t,o,s,r){let i=o??110,c=110,l=22,d=18,u=new Map(e.map((v,y)=>[v.name,y])),g=new Set(e.map(v=>v.name)),k=new Map(e.map(v=>[v.name,[]])),f=new Map(e.map(v=>[v.name,[]]));for(let v of e)for(let y of this.readPropertyValueReferences(v,n)){let U=y.subject.name;U!==v.name&&g.has(U)&&(k.get(v.name).push(U),f.get(U).push(v.name))}let m=new Map,b=new Set,_=v=>{let y=m.get(v);if(y!==void 0)return y;if(b.has(v))return 0;b.add(v);let U=0;for(let j of f.get(v)??[])U=Math.max(U,_(j)+1);return b.delete(v),m.set(v,U),U};for(let v of e)_(v.name);let $=Math.min(...m.values());if($>0)for(let v of[...m.keys()])m.set(v,m.get(v)-$);let S=Math.max(0,...m.values()),w=Array.from({length:S+1},()=>[]);for(let v of e)w[m.get(v.name)].push(v);let x=Math.max(1,...w.map(v=>v.length)),I=!1;for(let[v,y]of k)for(let U of y)m.get(U)<=m.get(v)&&(I=!0);let F=I?84:0,D=x*i+(x-1)*l,Y=d*2+(S+1)*i+S*c,T=d*2+F+D,E=new Map;w.forEach((v,y)=>{let U=v.length*i+(v.length-1)*l,j=d+F+(D-U)/2;v.forEach((C,X)=>E.set(C.name,{x:d+y*(i+c),y:j+X*(i+l)}))});let V=a.find(v=>v.to==="thickness"),ee=`kan-arrow-${this.diagramArrowSeq++}`,le=[],K=[];for(let[v,y]of k){let U=E.get(v);for(let j of y){let C=E.get(j),X=C.x>=U.x,se=V?1.5+V.norm[u.get(v)]*4.5:2,Z,ne,te;if(X){let J=U.x+i,$e=U.y+i/2,be=C.x-fe,Ke=C.y+i/2,je=(J+be)/2;Z=`M${J.toFixed(1)},${$e.toFixed(1)} C${je.toFixed(1)},${$e.toFixed(1)} ${je.toFixed(1)},${Ke.toFixed(1)} ${be.toFixed(1)},${Ke.toFixed(1)}`,ne=(J+be)/2,te=($e+Ke)/2-5}else{let J=U.x+i/2,$e=U.y,be=C.x+i/2,Ke=C.y-fe,je=d+F*.2;Z=`M${J.toFixed(1)},${$e.toFixed(1)} C${J.toFixed(1)},${je.toFixed(1)} ${be.toFixed(1)},${je.toFixed(1)} ${be.toFixed(1)},${Ke.toFixed(1)}`,ne=(J+be)/2,te=je+4}let he=X?"":' stroke-dasharray="6 4"';le.push(`<path d="${Z}" class="kan-diagram-edge" fill="none" stroke="var(--kan-accent)" stroke-width="${se.toFixed(1)}" stroke-opacity="0.75"${he} marker-end="url(#${ee})"/>`);let pe=this.edgeText(s,e[u.get(v)],r);pe&&K.push(this.edgeLabelEl(ne,te,pe))}}let G=e.map(v=>{let y=E.get(v.name);return this.diagramTile(v,y.x,y.y,i,t)}).join("");return`<figure class="kan-diagram-figure"><svg class="kan-diagram-svg" viewBox="0 0 ${Y.toFixed(0)} ${T.toFixed(0)}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">${this.arrowMarkerDef(ee,"var(--kan-accent)")}${le.join("")}${K.join("")}${G}</svg></figure>`}diagramTile(e,n,a,t,o,s=1){let r=this.hrefForSubject(e,o),i=this.svgUrlForSubject(e,o),c=A(this.catalog,e).label,l=s<1?` opacity="${s.toFixed(2)}"`:"";return`<a href="${p(r)}"><image href="${p(i)}" x="${n}" y="${a}" width="${t}" height="${t}"${l}><title>${p(c)}</title></image></a>`}renderStatRow(e,n){let a=P(e,ta),t=this.gatherValueItems(a).filter(s=>s instanceof q);if(t.length===0)return"<!-- LookRenderer.StatRow: no look.stats -->";let o=[];for(let s of t){let r=L(s,aa);if(!r)continue;let i=this.resolvePath(n,r);if(i===void 0)continue;let c=L(s,sa)??"";o.push('<div class="kan-stat">'+(c?`<span class="kan-stat-label">${p(c)}</span>`:"")+`<span class="kan-stat-val">${p(i)}</span></div>`)}return o.length===0?"":`<div class="kan-stat-row">${o.join("")}</div>`}renderHorizon(e,n,a){let t=M(e,ae);if(!t)return"<!-- LookRenderer.Horizon: no look.source -->";let o=this.gatherValueItems(P(n,t)).filter(r=>r instanceof q);return o.length===0?"":`<section class="kan-horizon">${o.map(r=>this.renderConditionNode(r,a,0)).join("")}</section>`}renderConditionNode(e,n,a){let t=ye(e),o=t?this.readLabelForUri({publisher:t.publisher,package_:t.package_,name:t.name})??t.name:"Condition",s=[],r=[];for(let u of e.statement){let g=u.predicate?.subject;if(!g||g.name==="type")continue;let k=this.readLabelForUri({publisher:g.publisher,package_:g.package_,name:g.name})??g.name;if(u instanceof Q||u instanceof ve||u instanceof ue)s.push(`<div class="kan-cond-field"><span class="kan-cond-key">${p(k)}</span><span class="kan-cond-v">${p(String(u.object))}</span></div>`);else if(u instanceof N&&u.object instanceof O){let f=u.object.subject,m=this.readLabelForUri({publisher:f.publisher,package_:f.package_,name:f.name})??f.name;s.push(`<div class="kan-cond-field"><span class="kan-cond-key">${p(k)}</span><span class="kan-cond-v">${p(m)}</span></div>`)}else if(u instanceof re)r.push(this.renderConditionNode(u.object,n,a+1));else if(u instanceof W)for(let f of u.object??[])f instanceof q&&r.push(this.renderConditionNode(f,n,a+1))}let i=s.length?`<div class="kan-cond-fields">${s.join("")}</div>`:"",c=r.length?`<div class="kan-cond-children">${r.join("")}</div>`:"",l=r.length>0,d=l?`<span class="kan-cond-op">${p(o)}</span>`:`<div class="kan-cond-type">${p(o)}</div>`;return`<div class="kan-cond ${l?"kan-cond-branch":"kan-cond-leaf"}">${d}${i}${c}</div>`}renderSectionHeading(e){let n=e,a=L(n,mn);if(!a)return"<!-- LookRenderer.SectionHeading: no look.heading -->";let t=L(n,Yt);return`<div class="kan-section" id="${Kn(a)}"><h2 class="kan-section-title">${p(a)}</h2>`+(t?`<p class="kan-section-note">${p(t)}</p>`:"")+"</div>"}renderSectionNav(e){return e.length===0?"<!-- LookRenderer.SectionNav: no section headings in this view -->":`<nav class="kan-section-nav" aria-label="On this page">${e.map(a=>`<a class="kan-section-nav-link" href="#${p(a.slug)}">${p(a.label)}</a>`).join("")}</nav>`}renderVersionDelta(e,n){let t=L(e,Fe);if(!t)return"<!-- LookRenderer.VersionDelta: no look.metricPath -->";let o=T=>{let E=this.resolvePath(T,t),V=E===void 0?NaN:parseFloat(E);return Number.isFinite(V)?V:void 0},s=o(n);if(s===void 0)return"";let r=T=>oe((T.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},i=(T,E)=>T.major-E.major||T.minor-E.minor||T.patch-E.patch,c={publisher:B(n),package_:(n.namespace||"").split("/")[1]?.split("@")[0]??"",name:n.name},l=r(n),d,u;for(let T of de(this.catalog,c)){let E=r(T);i(E,l)<0&&(!u||i(E,u)>0)&&(d=T,u=E)}if(!d||!u)return'<div class="kan-delta kan-delta-first">First tracked in this version</div>';let g=o(d);if(g===void 0)return"";let k=s-g,f=Math.abs(k)<.005?"flat":k>0?"up":"down",m=f==="up"?"\u25B2":f==="down"?"\u25BC":"\u2014",b=f==="up"?"#34d399":f==="down"?"#f87171":"var(--kan-text-faint)",_=`${u.major}.${u.minor}.${u.patch}`,$=320,S=46,w=14,x=30,I=T=>w+Math.min(1,Math.max(0,T))*($-2*w),F=I(g),D=I(s),Y=`<svg class="kan-delta-track" viewBox="0 0 ${$} ${S}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img"><line x1="${w}" y1="${x}" x2="${$-w}" y2="${x}" class="kan-delta-base"/><line x1="${F.toFixed(1)}" y1="${x}" x2="${D.toFixed(1)}" y2="${x}" stroke="${b}" stroke-width="3"/><circle cx="${F.toFixed(1)}" cy="${x}" r="4" class="kan-delta-prev"/><circle cx="${D.toFixed(1)}" cy="${x}" r="5.5" fill="${b}"/><text x="${F.toFixed(1)}" y="${x-9}" text-anchor="middle" class="kan-delta-tick kan-delta-tick-prev">${g.toFixed(2)}</text><text x="${D.toFixed(1)}" y="${x+17}" text-anchor="middle" class="kan-delta-tick">${s.toFixed(2)}</text></svg>`;return`<div class="kan-delta"><div class="kan-delta-head"><span class="kan-delta-vs">vs ${p(_)}</span><span class="kan-delta-badge ${f}">${k>0?"+":""}${k.toFixed(2)} ${m}</span></div>`+Y+"</div>"}renderTimePlot(e,n,a){let t=M(e,ae),o=M(e,qe);if(!t||!o)return"<!-- LookRenderer.TimePlot: needs look.source + look.orderBy -->";let s=e,r=L(s,na),i=L(s,hn),c=[];for(let K of this.readPropertyValueReferences(n,t)){let G=H(this.catalog,{publisher:K.subject.publisher,package_:K.subject.package_,name:K.subject.name,...K.subject.version?{version:K.subject.version}:{}});if(!G)continue;let v=this.readPropertyValueText(G,o)??"",y=Date.parse(v);if(!Number.isFinite(y))continue;let U=r?this.resolvePath(G,r)??"":"",j=(i?this.resolvePath(G,i):void 0)??A(this.catalog,G).label;c.push({t:y,dateStr:v,lane:U,label:j,href:this.hrefForSubject(G,a),linkable:this.isLinkable(B(G),a)})}if(c.length===0)return"<!-- LookRenderer.TimePlot: no dated points -->";let l=[];for(let K of c)l.includes(K.lane)||l.push(K.lane);let d=Math.min(...c.map(K=>K.t)),u=Math.max(...c.map(K=>K.t));u===d&&(u=d+1);let g=l.some(K=>K),k=720,f=g?96:16,m=18,b=12,_=24,$=36,S=b+l.length*$+_,w=f,x=k-m,I=x-w,F=K=>w+(K-d)/(u-d)*I,D=K=>b+K*$+$/2,Y=K=>Math.round(K*360/Math.max(1,l.length)),T=[];l.forEach((K,G)=>{let v=D(G);T.push(`<line x1="${w}" y1="${v.toFixed(1)}" x2="${x}" y2="${v.toFixed(1)}" class="kan-plot-guide"/>`),K&&T.push(`<text x="${(f-8).toFixed(1)}" y="${(v+4).toFixed(1)}" text-anchor="end" class="kan-plot-lane">${me(K)}</text>`)});let E={},V=[];for(let K of c){let G=l.indexOf(K.lane),y=((E[K.lane]=(E[K.lane]??0)+1)%3-1)*7,U=F(K.t),j=D(G)+y,C=`${Ce(K.dateStr)} \xB7 ${K.label}`,X=`<circle cx="${U.toFixed(1)}" cy="${j.toFixed(1)}" r="5" fill="hsl(${Y(G)},65%,60%)" class="kan-plot-pt"><title>${me(C)}</title></circle>`;V.push(K.linkable?`<a href="${p(K.href)}" class="kan-plot-link">${X}</a>`:X)}let ee=`<text x="${w}" y="${(S-6).toFixed(1)}" text-anchor="start" class="kan-plot-axis">${me(Ce(new Date(d).toISOString()))}</text><text x="${x}" y="${(S-6).toFixed(1)}" text-anchor="end" class="kan-plot-axis">${me(Ce(new Date(u).toISOString()))}</text>`;return`<section class="kan-plot">${`<svg class="kan-plot-svg" viewBox="0 0 ${k} ${S}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">`+T.join("")+V.join("")+ee+"</svg>"}</section>`}renderDetails(e,n,a){let t=en(e,Qt),o=this.detailRows(n,a,t);return o?`<dl class="kan-details">${o}</dl>`:"<!-- LookRenderer.Details: no properties -->"}detailRows(e,n,a){let t=[];for(let o of e.statement){let s=o.predicate?.subject;if(!s||this.isMetaPredicate(s)||a.some(c=>R(c,s)))continue;let r=this.readLabelForUri({publisher:s.publisher,package_:s.package_,name:s.name})??s.name,i=this.detailValue(o,n,a);i&&t.push(`<dt class="kan-details-key">${p(r)}</dt><dd class="kan-details-val">${i}</dd>`)}return t.join("")}detailValue(e,n,a){if(e instanceof Q)return Ln(e.object);if(e instanceof ve||e instanceof ue)return p(String(e.object));if(e instanceof N&&e.object instanceof O)return this.detailReferenceLink(e.object,n);if(e instanceof re)return this.detailEmbedded(e.object,n,a);if(e instanceof W){let t=e.object??[];return t.length>0&&t.every(o=>o instanceof q)?t.map(o=>this.detailEmbedded(o,n,a)).join(""):t.map(o=>o instanceof O?this.detailReferenceLink(o,n):o instanceof q?this.detailEmbedded(o,n,a):p(String(o))).filter(o=>o).join(", ")}return""}detailReferenceLink(e,n){let a=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name;if(!this.isLinkable(e.subject.publisher,n))return`<span class="kan-link-plain">${p(a)}</span>`;let t=this.urlForReference(e,void 0,n);return`<img class="kan-md-chip" src="${p(`${t}.svg`)}" alt="" loading="lazy"><a class="kan-link" href="${p(t)}">${p(a)}</a>`}detailEmbedded(e,n,a){let t=ye(e),o=t?this.readLabelForUri({publisher:t.publisher,package_:t.package_,name:t.name})??t.name:"",s=this.detailRows(e,n,a);return'<div class="kan-details-embed">'+(o?`<span class="kan-details-type">${p(o)}</span>`:"")+(s?`<dl class="kan-details">${s}</dl>`:"")+"</div>"}rangeTypeRefs(e){let n=H(this.catalog,e);if(!n)return[];let a=P(n,An);return a instanceof N&&a.object instanceof O?[a.object]:[]}renderEmbeddedViews(e,n,a,t=""){let o=M(e,ae);if(!o)return"<!-- LookRenderer: EmbeddedViews missing look.source -->";let s=this.gatherValueItems(P(n,o)).filter(g=>g instanceof q);if(s.length===0)return"";let r=t?`${t}.${o.name}`:o.name,i=P(e,_a),c=i instanceof ue?i.object===!0:i instanceof Q&&i.object==="true",l=[],d=s.map(g=>{let k=g,f=g.name?`${r}.${g.name}`:"";if(c&&f){let x=A(this.catalog,k).label||g.name||f;l.push(`<a class="kan-section-nav-link" href="#${p(f)}">${p(x)}</a>`)}let m=ce(k),b=m.length>0?m:this.rangeTypeRefs(o),_=Te(k)?this.findCascadedLook(k):this.lookFromTypeRefs(b),$="";if(_)$=Qe(_.declaration).map(x=>this.renderBand(x,k,a,[],f)).join(`
124
124
  `);else{let x=this.detailRows(g,a,[]);$=x?`<dl class="kan-details">${x}</dl>`:""}let S=f?` id="${p(f)}"`:"",w=f?this.anchorLink(f):"";return`<section class="kan-embedded-view"${S}>${w}${$}</section>`});return`<div class="kan-embedded-views">${l.length>0?`<nav class="kan-section-nav" aria-label="On this page">${l.join("")}</nav>
125
125
  `:""}${d.join(`
126
- `)}</div>`}anchorLink(e){return`<a class="kan-anchor" href="#${p(e)}" title="${p(e)}" aria-label="Link to this resource">#</a>`}isMetaPredicate(e){return R(e,fa)||R(e,Ge)||R(e,fn)||R(e,Ae)||R(e,Me)||R(e,ea)||R(e,_n)||R(e,Ht)}renderPackageContents(e,n){let a=e.namespace||"";if(!a)return"";let t=this.catalog.filter(s=>s instanceof ie&&s.namespace===a&&s.name!==e.name);return t.length===0?`<!-- LookRenderer.PackageContents: no members in ${a} -->`:(t.sort((s,r)=>{let i=A(this.catalog,s).label,c=A(this.catalog,r).label;return i.localeCompare(c)}),`<section class="kan-pkg-grid">${t.map(s=>{let r=A(this.catalog,s),i=r.label,c=r.summary,l=c?nn(c,160):"",d=this.hrefForSubject(s,n),u=this.svgUrlForSubject(s,n);return`<a class="kan-pkg-card" href="${p(d)}"><img class="kan-pkg-card-svg" src="${p(u)}" alt="" loading="lazy"/><span class="kan-pkg-card-body"><span class="kan-pkg-card-title">${p(i)}</span>`+(l?`<span class="kan-pkg-card-comment">${p(l)}</span>`:"")+"</span></a>"}).join("")}</section>`)}renderReferencedBy(e,n,a){let t=M(e,ha),o={publisher:B(n),package_:(n.namespace||"").split("/")[1]?.split("@")[0]??"",name:n.name},s=z(o),r=u=>oe((u.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},i=(u,g)=>u.major-g.major||u.minor-g.minor||u.patch-g.patch,c=new Map;for(let u of this.catalog){if(!(u instanceof ie))continue;let g=z({publisher:B(u),package_:(u.namespace||"").split("/")[1]?.split("@")[0]??"",name:u.name});if(g!==s)for(let k of u.statement){let f=k.predicate?.subject;if(!f||f.name==="type"||t&&z(f)!==z(t))continue;let m=[];if(k instanceof N&&k.object instanceof O)m.push(k.object);else if(k instanceof W)for(let S of k.object??[])S instanceof O&&m.push(S);if(!m.some(S=>z(S.subject)===s))continue;let b=z(f),_=c.get(b);_||(_={label:this.readLabelForUri(f)??f.name,best:new Map},c.set(b,_));let $=_.best.get(g);(!$||i(r(u),r($))>0)&&_.best.set(g,u)}}return c.size===0?"<!-- LookRenderer.ReferencedBy: no incoming references -->":`<div class="kan-section"><h2 class="kan-section-title">Referenced by</h2></div>${[...c.values()].sort((u,g)=>u.label.localeCompare(g.label)).map(u=>{let k=[...u.best.values()].sort((f,m)=>A(this.catalog,f).label.localeCompare(A(this.catalog,m).label)).map(f=>this.resourceCard(f,a,n.namespace??void 0)).join("");return`<div class="kan-rel-group"><h3 class="kan-rel-prop"><span class="kan-rel-dir" title="incoming \u2014 references this resource">\u2190</span> ${p(u.label)}</h3><section class="kan-pkg-grid">${k}</section></div>`}).join("")}`}resourceCard(e,n,a){let t=A(this.catalog,e),o=t.summary?nn(t.summary,160):"",s=ce(e).map(m=>this.readLabelForUri({publisher:m.subject.publisher,package_:m.subject.package_,name:m.subject.name})??m.subject.name),i='<span class="kan-pkg-card-body">'+(s.length>0?`<span class="kan-card-types">${s.map(m=>`<span class="kan-card-type">${p(m)}</span>`).join("")}</span>`:"")+`<span class="kan-pkg-card-title">${p(t.label)}</span>`+(o?`<span class="kan-pkg-card-comment">${p(o)}</span>`:"")+"</span>",c=this.isLinkable(B(e),n),l=c?`<a class="kan-pkg-card-link" href="${p(this.hrefForSubject(e,n))}"><img class="kan-pkg-card-svg" src="${p(this.svgUrlForSubject(e,n))}" alt="" loading="lazy"/>`+i+"</a>":`<span class="kan-pkg-card-link">${i}</span>`,d=e.namespace||"",u=d.split("/")[0]??"",[g,k]=(d.split("/")[1]??"").split("@"),f="";if(g&&d!==a){let m=k?`<span class="kan-card-at">@</span><span class="kan-card-ver">${p(k)}</span>`:"";if(c){let b=`<span class="kan-card-pkg">${p(g)}</span>${m}`;f=`<a class="kan-pkg-card-foot" href="${p(this.packageHref(u,g,k||void 0))}" title="${p(k?`${g}@${k}`:g)}">${b}</a>`}else{let b=`<span class="kan-card-pub">${p(u)}/</span><span class="kan-card-pkg">${p(g)}</span>${m}`;f=`<span class="kan-pkg-card-foot" title="${p(k?`${u}/${g}@${k}`:`${u}/${g}`)}">${b}</span>`}}return`<div class="kan-pkg-card kan-pkg-card--foot">${l}${f}</div>`}renderInstances(e,n,a){let t={publisher:B(n),package_:(n.namespace||"").split("/")[1]?.split("@")[0]??"",name:n.name},o=P(e,ja),s=o instanceof ue?o.object===!0:o instanceof Q&&o.object==="true",r=s?this.subclassClosure(t):new Set([z(t)]),i=b=>oe((b.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},c=(b,_)=>b.major-_.major||b.minor-_.minor||b.patch-_.patch,l=new Map;for(let b of this.catalog){if(!(b instanceof ie)||!ce(b).some(w=>r.has(z(w.subject))))continue;let $=z({publisher:B(b),package_:(b.namespace||"").split("/")[1]?.split("@")[0]??"",name:b.name}),S=l.get($);(!S||c(i(b),i(S))>0)&&l.set($,b)}let d=[...l.values()];if(d.length===0)return"<!-- LookRenderer.Instances: none -->";d.sort((b,_)=>A(this.catalog,b).label.localeCompare(A(this.catalog,_).label));let u=48,g=d.slice(0,u),k=g.map(b=>this.resourceCard(b,a,n.namespace??void 0)),f=d.length>u?` <span class="kan-count">${g.length} of ${d.length}</span>`:` <span class="kan-count">${d.length}</span>`;return`<div class="kan-section"><h2 class="kan-section-title">${s?"Instances (including subtypes)":"Instances"}${f}</h2></div><section class="kan-pkg-grid">${k.join("")}</section>`}subclassClosure(e){let n=new Set([z(e)]),a=!0;for(;a;){a=!1;for(let t of this.catalog){if(!(t instanceof ie))continue;let o=z({publisher:B(t),package_:(t.namespace||"").split("/")[1]?.split("@")[0]??"",name:t.name});if(!n.has(o)){for(let s of Ee(t))if(n.has(z(s.subject))){n.add(o),a=!0;break}}}}return n}referencesTarget(e,n,a){for(let t of e.statement){let o=t.predicate?.subject;if(o?.name==="type"||a&&!(o&&z(o)===z(a)))continue;let s=[];if(t instanceof N&&t.object instanceof O)s.push(t.object);else if(t instanceof W)for(let r of t.object??[])r instanceof O&&s.push(r);for(let r of s)if(z(r.subject)===n)return!0}return!1}renderFeaturedResource(e,n){let a=M(e,ae);if(!a)return"<!-- LookRenderer.FeaturedResource: no look.source -->";let t=fe(this.catalog,a),o=c=>oe((c.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},s=t.length>0?t.slice().sort((c,l)=>{let d=o(c),u=o(l);return u.major-d.major||u.minor-d.minor||u.patch-d.patch})[0]:H(this.catalog,a);if(!s)return`<!-- LookRenderer.FeaturedResource: ${a.publisher}/${a.package_}/${a.name} not found -->`;let r=this.renderHtml(s),i=this.hrefForSubject(s,n);return`<section class="kan-featured"><a class="kan-featured-permalink" href="${p(i)}">View full resource \u2192</a>`+r+"</section>"}renderDistribution(e,n){let a=e,t=v=>{let y=L(a,v);if(!y)return;let U=this.resolvePath(n,y),j=U===void 0?NaN:parseFloat(U);return Number.isFinite(j)?j:void 0},o=t(Gt),s=t(zt);if(o===void 0||s===void 0||o<=0||s<=0)return"<!-- LookRenderer.Distribution: needs resolvable alphaPath + betaPath (> 0) -->";let r=t(Fe)??o/(o+s),i=t(vn),c=t($n),l=t(Xe),d=l!==void 0?`hsl(${l},65%,60%)`:"var(--kan-accent)",u=v=>Number.isInteger(v)?String(v):v.toFixed(1),g=280,k=168,f={top:14,right:14,bottom:24,left:14},m=g-f.left-f.right,b=k-f.top-f.bottom,_=120,$=1e-4,S=[],w=[],x=0;for(let v=0;v<=_;v++){let y=v/_;y<$?y=$:y>1-$&&(y=1-$);let U=Math.exp((o-1)*Math.log(y)+(s-1)*Math.log(1-y));S.push(y),w.push(U),U>x&&(x=U)}let I=v=>f.left+Math.min(1,Math.max(0,v))*m,F=v=>f.top+(1-(x>0?v/x:0))*b,D=f.top+b,Y=S.map((v,y)=>`${I(v).toFixed(1)},${F(w[y]).toFixed(1)}`),T=`M${I(0).toFixed(1)},${D.toFixed(1)} L${Y.join(" L")} L${I(1).toFixed(1)},${D.toFixed(1)} Z`,E="";if(i!==void 0&&c!==void 0&&c>i){let v=[`${I(i).toFixed(1)},${D.toFixed(1)}`];for(let y=0;y<=_;y++)S[y]>=i&&S[y]<=c&&v.push(`${I(S[y]).toFixed(1)},${F(w[y]).toFixed(1)}`);v.push(`${I(c).toFixed(1)},${D.toFixed(1)}`),E=`<path d="M${v.join(" L")} Z" fill="${d}" fill-opacity="0.3"/>`}let V=I(r),ee=`<line x1="${V.toFixed(1)}" y1="${f.top.toFixed(1)}" x2="${V.toFixed(1)}" y2="${D.toFixed(1)}" stroke="${d}" stroke-width="1.5" stroke-dasharray="3 3"/><text x="${V.toFixed(1)}" y="${(f.top-3).toFixed(1)}" text-anchor="middle" class="kan-dist-mean">\u03BC ${r.toFixed(2)}</text>`,le=`<text x="${I(0).toFixed(1)}" y="${(D+15).toFixed(1)}" text-anchor="start" class="kan-dist-axis">0</text><text x="${I(1).toFixed(1)}" y="${(D+15).toFixed(1)}" text-anchor="end" class="kan-dist-axis">1</text>`,K=`<svg class="kan-dist-svg" viewBox="0 0 ${g} ${k}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img"><line x1="${f.left}" y1="${D.toFixed(1)}" x2="${(g-f.right).toFixed(1)}" y2="${D.toFixed(1)}" class="kan-dist-base"/><path d="${T}" fill="${d}" fill-opacity="0.12"/>`+E+`<polyline points="${Y.join(" ")}" fill="none" stroke="${d}" stroke-width="2"/>`+ee+le+"</svg>",G=i!==void 0&&c!==void 0?` \xB7 95% CI [${i.toFixed(2)}\u2013${c.toFixed(2)}]`:"";return`<figure class="kan-dist">${K}<figcaption class="kan-dist-caption">Beta(${u(o)}, ${u(s)})${G}</figcaption></figure>`}renderPublisherPackages(e,n){let a=new Map;for(let i of this.catalog){if(!(i instanceof ie)||B(i)!==n)continue;let c=(i.namespace||"").split("/")[1]?.split("@")[0]??"";if(!c||i.name!==c)continue;let l=a.get(c),d=oe((i.namespace||"").split("@")[1]??""),u=l?oe((l.namespace||"").split("@")[1]??""):void 0;(!l||d&&(!u||xe(d,u)>0))&&a.set(c,i)}let t,o=P(e,Tt),s=o instanceof W?o.object??[]:o instanceof N&&o.object instanceof O?[o.object]:[];if(s.length>0){t=[];for(let i of s){if(!(i instanceof O))continue;let c=i.subject.package_,l=a.get(c);l&&t.push([c,l])}}else t=[...a.entries()].sort((i,c)=>i[0].localeCompare(c[0]));return t.length===0?"":`<section class="kan-pkg-grid">${t.map(([i,c])=>{let l=A(this.catalog,c),d=l.label,u=l.summary,g=u?nn(u,160):"",k=this.svgUrlForSubject(c,n);return`<a class="kan-pkg-card" href="${p(this.packageHref(n,i))}"><img class="kan-pkg-card-svg" src="${p(k)}" alt="" loading="lazy"/><span class="kan-pkg-card-body"><span class="kan-pkg-card-title">${p(d)}</span>`+(g?`<span class="kan-pkg-card-comment">${p(g)}</span>`:"")+"</span></a>"}).join("")}</section>`}renderTimeline(e,n){let a=M(e,ae);if(!a)return"<!-- LookRenderer.Timeline: no look.source -->";let t=M(e,qe),o=this.findInstancesOfClass(a);if(o.length===0)return"<!-- LookRenderer.Timeline: no instances -->";let s=d=>t?this.readPropertyValueText(d,t)??"":"",r=o.slice().sort((d,u)=>s(d).localeCompare(s(u))),i=M(e,bn),c=L(e,Fe);return i&&c?this.renderTrajectoryChart(r,i,c,e,n,s):`<section class="kan-timeline"><ol>
126
+ `)}</div>`}anchorLink(e){return`<a class="kan-anchor" href="#${p(e)}" title="${p(e)}" aria-label="Link to this resource">#</a>`}isMetaPredicate(e){return R(e,fa)||R(e,Ge)||R(e,fn)||R(e,Ae)||R(e,Me)||R(e,ea)||R(e,_n)||R(e,Ht)}renderPackageContents(e,n){let a=e.namespace||"";if(!a)return"";let t=this.catalog.filter(s=>s instanceof ie&&s.namespace===a&&s.name!==e.name);return t.length===0?`<!-- LookRenderer.PackageContents: no members in ${a} -->`:(t.sort((s,r)=>{let i=A(this.catalog,s).label,c=A(this.catalog,r).label;return i.localeCompare(c)}),`<section class="kan-pkg-grid">${t.map(s=>{let r=A(this.catalog,s),i=r.label,c=r.summary,l=c?nn(c,160):"",d=this.hrefForSubject(s,n),u=this.svgUrlForSubject(s,n);return`<a class="kan-pkg-card" href="${p(d)}"><img class="kan-pkg-card-svg" src="${p(u)}" alt="" loading="lazy"/><span class="kan-pkg-card-body"><span class="kan-pkg-card-title">${p(i)}</span>`+(l?`<span class="kan-pkg-card-comment">${p(l)}</span>`:"")+"</span></a>"}).join("")}</section>`)}renderReferencedBy(e,n,a){let t=M(e,ha),o={publisher:B(n),package_:(n.namespace||"").split("/")[1]?.split("@")[0]??"",name:n.name},s=z(o),r=u=>oe((u.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},i=(u,g)=>u.major-g.major||u.minor-g.minor||u.patch-g.patch,c=new Map;for(let u of this.catalog){if(!(u instanceof ie))continue;let g=z({publisher:B(u),package_:(u.namespace||"").split("/")[1]?.split("@")[0]??"",name:u.name});if(g!==s)for(let k of u.statement){let f=k.predicate?.subject;if(!f||f.name==="type"||t&&z(f)!==z(t))continue;let m=[];if(k instanceof N&&k.object instanceof O)m.push(k.object);else if(k instanceof W)for(let S of k.object??[])S instanceof O&&m.push(S);if(!m.some(S=>z(S.subject)===s))continue;let b=z(f),_=c.get(b);_||(_={label:this.readLabelForUri(f)??f.name,best:new Map},c.set(b,_));let $=_.best.get(g);(!$||i(r(u),r($))>0)&&_.best.set(g,u)}}return c.size===0?"<!-- LookRenderer.ReferencedBy: no incoming references -->":`<div class="kan-section"><h2 class="kan-section-title">Referenced by</h2></div>${[...c.values()].sort((u,g)=>u.label.localeCompare(g.label)).map(u=>{let k=[...u.best.values()].sort((f,m)=>A(this.catalog,f).label.localeCompare(A(this.catalog,m).label)).map(f=>this.resourceCard(f,a,n.namespace??void 0)).join("");return`<div class="kan-rel-group"><h3 class="kan-rel-prop"><span class="kan-rel-dir" title="incoming \u2014 references this resource">\u2190</span> ${p(u.label)}</h3><section class="kan-pkg-grid">${k}</section></div>`}).join("")}`}resourceCard(e,n,a){let t=A(this.catalog,e),o=t.summary?nn(t.summary,160):"",s=ce(e).map(m=>this.readLabelForUri({publisher:m.subject.publisher,package_:m.subject.package_,name:m.subject.name})??m.subject.name),i='<span class="kan-pkg-card-body">'+(s.length>0?`<span class="kan-card-types">${s.map(m=>`<span class="kan-card-type">${p(m)}</span>`).join("")}</span>`:"")+`<span class="kan-pkg-card-title">${p(t.label)}</span>`+(o?`<span class="kan-pkg-card-comment">${p(o)}</span>`:"")+"</span>",c=this.isLinkable(B(e),n),l=c?`<a class="kan-pkg-card-link" href="${p(this.hrefForSubject(e,n))}"><img class="kan-pkg-card-svg" src="${p(this.svgUrlForSubject(e,n))}" alt="" loading="lazy"/>`+i+"</a>":`<span class="kan-pkg-card-link">${i}</span>`,d=e.namespace||"",u=d.split("/")[0]??"",[g,k]=(d.split("/")[1]??"").split("@"),f="";if(g&&d!==a){let m=k?`<span class="kan-card-at">@</span><span class="kan-card-ver">${p(k)}</span>`:"";if(c){let b=`<span class="kan-card-pkg">${p(g)}</span>${m}`;f=`<a class="kan-pkg-card-foot" href="${p(this.packageHref(u,g,k||void 0))}" title="${p(k?`${g}@${k}`:g)}">${b}</a>`}else{let b=`<span class="kan-card-pub">${p(u)}/</span><span class="kan-card-pkg">${p(g)}</span>${m}`;f=`<span class="kan-pkg-card-foot" title="${p(k?`${u}/${g}@${k}`:`${u}/${g}`)}">${b}</span>`}}return`<div class="kan-pkg-card kan-pkg-card--foot">${l}${f}</div>`}renderInstances(e,n,a){let t={publisher:B(n),package_:(n.namespace||"").split("/")[1]?.split("@")[0]??"",name:n.name},o=P(e,ja),s=o instanceof ue?o.object===!0:o instanceof Q&&o.object==="true",r=s?this.subclassClosure(t):new Set([z(t)]),i=b=>oe((b.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},c=(b,_)=>b.major-_.major||b.minor-_.minor||b.patch-_.patch,l=new Map;for(let b of this.catalog){if(!(b instanceof ie)||!ce(b).some(w=>r.has(z(w.subject))))continue;let $=z({publisher:B(b),package_:(b.namespace||"").split("/")[1]?.split("@")[0]??"",name:b.name}),S=l.get($);(!S||c(i(b),i(S))>0)&&l.set($,b)}let d=[...l.values()];if(d.length===0)return"<!-- LookRenderer.Instances: none -->";d.sort((b,_)=>A(this.catalog,b).label.localeCompare(A(this.catalog,_).label));let u=48,g=d.slice(0,u),k=g.map(b=>this.resourceCard(b,a,n.namespace??void 0)),f=d.length>u?` <span class="kan-count">${g.length} of ${d.length}</span>`:` <span class="kan-count">${d.length}</span>`;return`<div class="kan-section"><h2 class="kan-section-title">${s?"Instances (including subtypes)":"Instances"}${f}</h2></div><section class="kan-pkg-grid">${k.join("")}</section>`}subclassClosure(e){let n=new Set([z(e)]),a=!0;for(;a;){a=!1;for(let t of this.catalog){if(!(t instanceof ie))continue;let o=z({publisher:B(t),package_:(t.namespace||"").split("/")[1]?.split("@")[0]??"",name:t.name});if(!n.has(o)){for(let s of Ee(t))if(n.has(z(s.subject))){n.add(o),a=!0;break}}}}return n}referencesTarget(e,n,a){for(let t of e.statement){let o=t.predicate?.subject;if(o?.name==="type"||a&&!(o&&z(o)===z(a)))continue;let s=[];if(t instanceof N&&t.object instanceof O)s.push(t.object);else if(t instanceof W)for(let r of t.object??[])r instanceof O&&s.push(r);for(let r of s)if(z(r.subject)===n)return!0}return!1}renderFeaturedResource(e,n){let a=M(e,ae);if(!a)return"<!-- LookRenderer.FeaturedResource: no look.source -->";let t=de(this.catalog,a),o=c=>oe((c.namespace||"").split("@")[1]??"")??{major:0,minor:0,patch:0},s=t.length>0?t.slice().sort((c,l)=>{let d=o(c),u=o(l);return u.major-d.major||u.minor-d.minor||u.patch-d.patch})[0]:H(this.catalog,a);if(!s)return`<!-- LookRenderer.FeaturedResource: ${a.publisher}/${a.package_}/${a.name} not found -->`;let r=this.renderHtml(s),i=this.hrefForSubject(s,n);return`<section class="kan-featured"><a class="kan-featured-permalink" href="${p(i)}">View full resource \u2192</a>`+r+"</section>"}renderDistribution(e,n){let a=e,t=v=>{let y=L(a,v);if(!y)return;let U=this.resolvePath(n,y),j=U===void 0?NaN:parseFloat(U);return Number.isFinite(j)?j:void 0},o=t(Gt),s=t(zt);if(o===void 0||s===void 0||o<=0||s<=0)return"<!-- LookRenderer.Distribution: needs resolvable alphaPath + betaPath (> 0) -->";let r=t(Fe)??o/(o+s),i=t(vn),c=t($n),l=t(Xe),d=l!==void 0?`hsl(${l},65%,60%)`:"var(--kan-accent)",u=v=>Number.isInteger(v)?String(v):v.toFixed(1),g=280,k=168,f={top:14,right:14,bottom:24,left:14},m=g-f.left-f.right,b=k-f.top-f.bottom,_=120,$=1e-4,S=[],w=[],x=0;for(let v=0;v<=_;v++){let y=v/_;y<$?y=$:y>1-$&&(y=1-$);let U=Math.exp((o-1)*Math.log(y)+(s-1)*Math.log(1-y));S.push(y),w.push(U),U>x&&(x=U)}let I=v=>f.left+Math.min(1,Math.max(0,v))*m,F=v=>f.top+(1-(x>0?v/x:0))*b,D=f.top+b,Y=S.map((v,y)=>`${I(v).toFixed(1)},${F(w[y]).toFixed(1)}`),T=`M${I(0).toFixed(1)},${D.toFixed(1)} L${Y.join(" L")} L${I(1).toFixed(1)},${D.toFixed(1)} Z`,E="";if(i!==void 0&&c!==void 0&&c>i){let v=[`${I(i).toFixed(1)},${D.toFixed(1)}`];for(let y=0;y<=_;y++)S[y]>=i&&S[y]<=c&&v.push(`${I(S[y]).toFixed(1)},${F(w[y]).toFixed(1)}`);v.push(`${I(c).toFixed(1)},${D.toFixed(1)}`),E=`<path d="M${v.join(" L")} Z" fill="${d}" fill-opacity="0.3"/>`}let V=I(r),ee=`<line x1="${V.toFixed(1)}" y1="${f.top.toFixed(1)}" x2="${V.toFixed(1)}" y2="${D.toFixed(1)}" stroke="${d}" stroke-width="1.5" stroke-dasharray="3 3"/><text x="${V.toFixed(1)}" y="${(f.top-3).toFixed(1)}" text-anchor="middle" class="kan-dist-mean">\u03BC ${r.toFixed(2)}</text>`,le=`<text x="${I(0).toFixed(1)}" y="${(D+15).toFixed(1)}" text-anchor="start" class="kan-dist-axis">0</text><text x="${I(1).toFixed(1)}" y="${(D+15).toFixed(1)}" text-anchor="end" class="kan-dist-axis">1</text>`,K=`<svg class="kan-dist-svg" viewBox="0 0 ${g} ${k}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img"><line x1="${f.left}" y1="${D.toFixed(1)}" x2="${(g-f.right).toFixed(1)}" y2="${D.toFixed(1)}" class="kan-dist-base"/><path d="${T}" fill="${d}" fill-opacity="0.12"/>`+E+`<polyline points="${Y.join(" ")}" fill="none" stroke="${d}" stroke-width="2"/>`+ee+le+"</svg>",G=i!==void 0&&c!==void 0?` \xB7 95% CI [${i.toFixed(2)}\u2013${c.toFixed(2)}]`:"";return`<figure class="kan-dist">${K}<figcaption class="kan-dist-caption">Beta(${u(o)}, ${u(s)})${G}</figcaption></figure>`}renderPublisherPackages(e,n){let a=new Map;for(let i of this.catalog){if(!(i instanceof ie)||B(i)!==n)continue;let c=(i.namespace||"").split("/")[1]?.split("@")[0]??"";if(!c||i.name!==c)continue;let l=a.get(c),d=oe((i.namespace||"").split("@")[1]??""),u=l?oe((l.namespace||"").split("@")[1]??""):void 0;(!l||d&&(!u||xe(d,u)>0))&&a.set(c,i)}let t,o=P(e,Tt),s=o instanceof W?o.object??[]:o instanceof N&&o.object instanceof O?[o.object]:[];if(s.length>0){t=[];for(let i of s){if(!(i instanceof O))continue;let c=i.subject.package_,l=a.get(c);l&&t.push([c,l])}}else t=[...a.entries()].sort((i,c)=>i[0].localeCompare(c[0]));return t.length===0?"":`<section class="kan-pkg-grid">${t.map(([i,c])=>{let l=A(this.catalog,c),d=l.label,u=l.summary,g=u?nn(u,160):"",k=this.svgUrlForSubject(c,n);return`<a class="kan-pkg-card" href="${p(this.packageHref(n,i))}"><img class="kan-pkg-card-svg" src="${p(k)}" alt="" loading="lazy"/><span class="kan-pkg-card-body"><span class="kan-pkg-card-title">${p(d)}</span>`+(g?`<span class="kan-pkg-card-comment">${p(g)}</span>`:"")+"</span></a>"}).join("")}</section>`}renderTimeline(e,n){let a=M(e,ae);if(!a)return"<!-- LookRenderer.Timeline: no look.source -->";let t=M(e,qe),o=this.findInstancesOfClass(a);if(o.length===0)return"<!-- LookRenderer.Timeline: no instances -->";let s=d=>t?this.readPropertyValueText(d,t)??"":"",r=o.slice().sort((d,u)=>s(d).localeCompare(s(u))),i=M(e,bn),c=L(e,Fe);return i&&c?this.renderTrajectoryChart(r,i,c,e,n,s):`<section class="kan-timeline"><ol>
127
127
  ${r.map(d=>{let u=d.namespace||"",g=u.split("/")[1]?.split("@")[0]??"",k=u.split("@")[1]??"",f=k?oe(k):void 0,m=this.resourceHref({publisher:B(d),package_:g,name:d.name,...f?{version:f}:{}},n),b=s(d),_=b?`<span class="kan-timeline-date">${p(b)}</span>`:"",$=k||d.name;return`<li class="kan-timeline-node"><a href="${p(m)}"><span class="kan-timeline-key">${p($)}</span>${_}</a></li>`}).join(`
128
128
  `)}
129
- </ol></section>`}renderTrajectoryChart(e,n,a,t,o,s){let r=t,i=L(r,Xe),c=L(r,vn),l=L(r,$n),d=L(r,ca),u=yn(r,ra),g=yn(r,ia),k=e.length,f=this.collectTrackedSeries(e,n,a,{hueBy:i,lowerPath:c,upperPath:l});if(f.length===0)return"<!-- LookRenderer.Timeline: no tracked series -->";let m=[];for(let j of f){for(let C of j.points)C!==null&&m.push(C);for(let C of j.lower??[])C!==null&&m.push(C);for(let C of j.upper??[])C!==null&&m.push(C)}if(m.length===0)return"<!-- LookRenderer.Timeline: no metric values -->";let b=Math.min(...m),_=Math.max(...m);_-b<1e-9&&(b-=.5,_+=.5);let $=(_-b)*.08,S=u!==void 0?u:b-$,w=g!==void 0?g:_+$;w-S<1e-9&&(w=S+1);let x=1e3,I=440,F={top:28,right:24,bottom:56,left:52},D=x-F.left-F.right,Y=I-F.top-F.bottom,T=j=>k<=1?F.left+D/2:F.left+j/(k-1)*D,E=j=>F.top+(1-(j-S)/(w-S))*Y,V=(j,C)=>j.hue!==void 0?j.hue:Math.round(C*360/f.length),ee=[];for(let j=0;j<5;j++){let C=S+j*(w-S)/4,X=E(C);ee.push(`<line x1="${F.left}" y1="${X.toFixed(1)}" x2="${(x-F.right).toFixed(1)}" y2="${X.toFixed(1)}" class="kan-fan-grid"/>`),ee.push(`<text x="${(F.left-8).toFixed(1)}" y="${(X+4).toFixed(1)}" class="kan-fan-axis" text-anchor="end">${C.toFixed(2)}</text>`)}let le=[];e.forEach((j,C)=>{let X=this.hrefForSubject(j,o),se=(j.namespace||"").split("@")[1]??"",Z=T(C),ne=Ce(s(j));le.push(`<a href="${p(X)}" class="kan-fan-xtick"><line x1="${Z.toFixed(1)}" y1="${F.top}" x2="${Z.toFixed(1)}" y2="${(I-F.bottom).toFixed(1)}" class="kan-fan-vline"/><text x="${Z.toFixed(1)}" y="${(I-F.bottom+20).toFixed(1)}" class="kan-fan-xlabel" text-anchor="middle">${me(se||j.name)}</text>`+(ne?`<text x="${Z.toFixed(1)}" y="${(I-F.bottom+36).toFixed(1)}" class="kan-fan-xdate" text-anchor="middle">${me(ne)}</text>`:"")+"</a>")});let K=[];f.forEach((j,C)=>{if(!j.lower||!j.upper)return;let X=V(j,C),se=[],Z=[];for(let te=0;te<k;te++){let he=j.upper[te],de=j.lower[te];he==null||de===null||de===void 0||(se.push(`${T(te).toFixed(1)},${E(he).toFixed(1)}`),Z.unshift(`${T(te).toFixed(1)},${E(de).toFixed(1)}`))}let ne=se.concat(Z);ne.length<3||K.push(`<polygon class="kan-fan-band" points="${ne.join(" ")}" fill="hsl(${X},65%,60%)"/>`)});let G=[];f.forEach((j,C)=>{let se=`hsl(${V(j,C)},65%,60%)`,Z=[],ne=[];j.points.forEach((te,he)=>{if(te===null)return;let de=T(he),J=E(te);Z.push(`${de.toFixed(1)},${J.toFixed(1)}`),ne.push(`<circle cx="${de.toFixed(1)}" cy="${J.toFixed(1)}" r="3.5" fill="${se}"/>`)}),Z.length!==0&&G.push(`<g class="kan-fan-series" data-series="${p(j.key)}"><polyline points="${Z.join(" ")}" fill="none" stroke="${se}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>`+ne.join("")+"</g>")});let v=`<svg class="kan-fan-svg" viewBox="0 0 ${x} ${I}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">`+ee.join("")+le.join("")+K.join("")+G.join("")+"</svg>",y=d?`${p(d)}=`:"",U=f.map((j,C)=>{let X=V(j,C),se=j.points.filter(J=>J!==null),Z=se.length?se[0]:void 0,ne=se.length?se[se.length-1]:void 0,te="";if(ne!==void 0&&Z!==void 0){let J=ne-Z;if(Math.abs(J)>=.005){let $e=J>0?"up":"down",be=J>0?"\u25B2":"\u25BC";te=` <span class="kan-fan-delta ${$e}">${J>0?"+":""}${J.toFixed(2)} ${be}</span>`}else te=' <span class="kan-fan-delta flat">\u2014</span>'}let he=ne!==void 0?`${y}${ne.toFixed(2)}`:"\u2014",de=j.lastSubject&&this.isLinkable(B(j.lastSubject),o)?`<a href="${p(this.hrefForSubject(j.lastSubject,o))}">${p(j.label)}</a>`:p(j.label);return`<div class="kan-fan-legend-item" style="--kan-fan-hue:${X}"><span class="kan-fan-swatch"></span><span class="kan-fan-legend-label">${de}</span><span class="kan-fan-legend-cur">${he}${te}</span></div>`});return`<section class="kan-fan"><div class="kan-fan-chart">${v}</div><div class="kan-fan-legend">${U.join("")}</div></section>`}renderResourceGrid(e,n,a){let t=M(e,ae);if(!t)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let o=H(this.catalog,t),s=o?ce(o).some(c=>{let l=c.subject.name;return l==="ObjectProperty"||l==="DatatypeProperty"||l==="Property"}):!1,r=[];if(s&&a){let c=this.readPropertyValueReferences(a,t);for(let l of c){let d=H(this.catalog,{publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name,...l.subject.version?{version:l.subject.version}:{}});d&&r.push(d)}}else r=this.findInstancesOfClass(t);if(r.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${t.publisher}/${t.package_}/${t.name} -->`;let i=[];for(let c of r){let l=A(this.catalog,c),d=l.label,u=l.summary,g=c.namespace||"",k=g.split("/")[1]?.split("@")[0]??"",f=g.split("@")[1]??"",m=f?oe(f):void 0,b=this.resourceHref({publisher:B(c),package_:k,name:c.name,...m?{version:m}:{}},n),_=u?`<p class="kan-resource-card-subtitle">${p(u)}</p>`:"",$=`<h3 class="kan-resource-card-title">${p(d)}</h3>${_}`;i.push(this.isLinkable(B(c),n)?`<a class="kan-resource-card" href="${p(b)}">${$}</a>`:`<span class="kan-resource-card">${$}</span>`)}return`<section class="kan-resource-grid">
129
+ </ol></section>`}renderTrajectoryChart(e,n,a,t,o,s){let r=t,i=L(r,Xe),c=L(r,vn),l=L(r,$n),d=L(r,ca),u=yn(r,ra),g=yn(r,ia),k=e.length,f=this.collectTrackedSeries(e,n,a,{hueBy:i,lowerPath:c,upperPath:l});if(f.length===0)return"<!-- LookRenderer.Timeline: no tracked series -->";let m=[];for(let j of f){for(let C of j.points)C!==null&&m.push(C);for(let C of j.lower??[])C!==null&&m.push(C);for(let C of j.upper??[])C!==null&&m.push(C)}if(m.length===0)return"<!-- LookRenderer.Timeline: no metric values -->";let b=Math.min(...m),_=Math.max(...m);_-b<1e-9&&(b-=.5,_+=.5);let $=(_-b)*.08,S=u!==void 0?u:b-$,w=g!==void 0?g:_+$;w-S<1e-9&&(w=S+1);let x=1e3,I=440,F={top:28,right:24,bottom:56,left:52},D=x-F.left-F.right,Y=I-F.top-F.bottom,T=j=>k<=1?F.left+D/2:F.left+j/(k-1)*D,E=j=>F.top+(1-(j-S)/(w-S))*Y,V=(j,C)=>j.hue!==void 0?j.hue:Math.round(C*360/f.length),ee=[];for(let j=0;j<5;j++){let C=S+j*(w-S)/4,X=E(C);ee.push(`<line x1="${F.left}" y1="${X.toFixed(1)}" x2="${(x-F.right).toFixed(1)}" y2="${X.toFixed(1)}" class="kan-fan-grid"/>`),ee.push(`<text x="${(F.left-8).toFixed(1)}" y="${(X+4).toFixed(1)}" class="kan-fan-axis" text-anchor="end">${C.toFixed(2)}</text>`)}let le=[];e.forEach((j,C)=>{let X=this.hrefForSubject(j,o),se=(j.namespace||"").split("@")[1]??"",Z=T(C),ne=Ce(s(j));le.push(`<a href="${p(X)}" class="kan-fan-xtick"><line x1="${Z.toFixed(1)}" y1="${F.top}" x2="${Z.toFixed(1)}" y2="${(I-F.bottom).toFixed(1)}" class="kan-fan-vline"/><text x="${Z.toFixed(1)}" y="${(I-F.bottom+20).toFixed(1)}" class="kan-fan-xlabel" text-anchor="middle">${me(se||j.name)}</text>`+(ne?`<text x="${Z.toFixed(1)}" y="${(I-F.bottom+36).toFixed(1)}" class="kan-fan-xdate" text-anchor="middle">${me(ne)}</text>`:"")+"</a>")});let K=[];f.forEach((j,C)=>{if(!j.lower||!j.upper)return;let X=V(j,C),se=[],Z=[];for(let te=0;te<k;te++){let he=j.upper[te],pe=j.lower[te];he==null||pe===null||pe===void 0||(se.push(`${T(te).toFixed(1)},${E(he).toFixed(1)}`),Z.unshift(`${T(te).toFixed(1)},${E(pe).toFixed(1)}`))}let ne=se.concat(Z);ne.length<3||K.push(`<polygon class="kan-fan-band" points="${ne.join(" ")}" fill="hsl(${X},65%,60%)"/>`)});let G=[];f.forEach((j,C)=>{let se=`hsl(${V(j,C)},65%,60%)`,Z=[],ne=[];j.points.forEach((te,he)=>{if(te===null)return;let pe=T(he),J=E(te);Z.push(`${pe.toFixed(1)},${J.toFixed(1)}`),ne.push(`<circle cx="${pe.toFixed(1)}" cy="${J.toFixed(1)}" r="3.5" fill="${se}"/>`)}),Z.length!==0&&G.push(`<g class="kan-fan-series" data-series="${p(j.key)}"><polyline points="${Z.join(" ")}" fill="none" stroke="${se}" stroke-width="2" stroke-linejoin="round" stroke-linecap="round"/>`+ne.join("")+"</g>")});let v=`<svg class="kan-fan-svg" viewBox="0 0 ${x} ${I}" preserveAspectRatio="xMidYMid meet" xmlns="http://www.w3.org/2000/svg" role="img">`+ee.join("")+le.join("")+K.join("")+G.join("")+"</svg>",y=d?`${p(d)}=`:"",U=f.map((j,C)=>{let X=V(j,C),se=j.points.filter(J=>J!==null),Z=se.length?se[0]:void 0,ne=se.length?se[se.length-1]:void 0,te="";if(ne!==void 0&&Z!==void 0){let J=ne-Z;if(Math.abs(J)>=.005){let $e=J>0?"up":"down",be=J>0?"\u25B2":"\u25BC";te=` <span class="kan-fan-delta ${$e}">${J>0?"+":""}${J.toFixed(2)} ${be}</span>`}else te=' <span class="kan-fan-delta flat">\u2014</span>'}let he=ne!==void 0?`${y}${ne.toFixed(2)}`:"\u2014",pe=j.lastSubject&&this.isLinkable(B(j.lastSubject),o)?`<a href="${p(this.hrefForSubject(j.lastSubject,o))}">${p(j.label)}</a>`:p(j.label);return`<div class="kan-fan-legend-item" style="--kan-fan-hue:${X}"><span class="kan-fan-swatch"></span><span class="kan-fan-legend-label">${pe}</span><span class="kan-fan-legend-cur">${he}${te}</span></div>`});return`<section class="kan-fan"><div class="kan-fan-chart">${v}</div><div class="kan-fan-legend">${U.join("")}</div></section>`}renderResourceGrid(e,n,a){let t=M(e,ae);if(!t)return"<!-- LookRenderer.ResourceGrid: no look.source -->";let o=H(this.catalog,t),s=o?ce(o).some(c=>{let l=c.subject.name;return l==="ObjectProperty"||l==="DatatypeProperty"||l==="Property"}):!1,r=[];if(s&&a){let c=this.readPropertyValueReferences(a,t);for(let l of c){let d=H(this.catalog,{publisher:l.subject.publisher,package_:l.subject.package_,name:l.subject.name,...l.subject.version?{version:l.subject.version}:{}});d&&r.push(d)}}else r=this.findInstancesOfClass(t);if(r.length===0)return`<!-- LookRenderer.ResourceGrid: no resources for ${t.publisher}/${t.package_}/${t.name} -->`;let i=[];for(let c of r){let l=A(this.catalog,c),d=l.label,u=l.summary,g=c.namespace||"",k=g.split("/")[1]?.split("@")[0]??"",f=g.split("@")[1]??"",m=f?oe(f):void 0,b=this.resourceHref({publisher:B(c),package_:k,name:c.name,...m?{version:m}:{}},n),_=u?`<p class="kan-resource-card-subtitle">${p(u)}</p>`:"",$=`<h3 class="kan-resource-card-title">${p(d)}</h3>${_}`;i.push(this.isLinkable(B(c),n)?`<a class="kan-resource-card" href="${p(b)}">${$}</a>`:`<span class="kan-resource-card">${$}</span>`)}return`<section class="kan-resource-grid">
130
130
  ${i.join(`
131
131
  `)}
132
132
  </section>`}findInstancesOfClass(e){let n=[];for(let a of this.catalog){if(!(a instanceof ie))continue;ce(a).map(s=>s.subject).some(s=>s.publisher===e.publisher&&s.package_===e.package_&&s.name===e.name)&&n.push(a)}return n}renderBreadcrumb(e,n,a){let o=(e.namespace||"").split("/");if(o.length<2)return"";let s=o[0],r=o[1]??"",i=r.split("@")[0]??"",c=r.split("@")[1]??"";if(!s||!i)return"";if(a?.bareOverview)return`<nav class="kan-breadcrumb"><ol>
@@ -145,4 +145,4 @@ ${c}
145
145
 
146
146
  `):void 0}renderHero(e,n,a){let t=f=>{let m=P(e,f);return m instanceof ue?m.object===!0:m instanceof Q&&m.object==="true"},o=t($a),s=!o&&t(va),r=o||s,c=[`<header class="${o?"kan-hero kan-hero-has-avatar":s?"kan-hero kan-hero-has-icon":"kan-hero"}">`];if(r){let f=this.svgUrlForSubject(n,a),m=o?"kan-hero-avatar":"kan-hero-icon";c.push(`<img class="${m}" src="${p(f)}" alt="" loading="lazy"/>`),c.push('<div class="kan-hero-text">')}let l=M(e,ka);if(l){let f=this.readPropertyValueText(n,l);f&&c.push(`<span class="kan-hero-eyebrow">${p(De(f)??f)}</span>`)}let d=M(e,ga),u="";d&&(u=this.readPropertyValueText(n,d)??""),u||(u=A(this.catalog,n).label),c.push(`<h1 class="kan-hero-title">${p(De(u)??u)}</h1>`);let g=M(e,ma);if(g){let f=this.readPropertyValueText(n,g);f&&c.push(`<p class="kan-hero-subtitle">${p(De(f)??f)}</p>`)}let k=M(e,Sn);if(k){let f=this.readPropertyValueReferences(n,k);if(f.length>0){let m=f.map(b=>this.renderBadge(b,Sn,a)).join("");c.push(`<div class="kan-hero-badges">${m}</div>`)}}return r&&c.push("</div>"),c.push("</header>"),c.join(`
147
147
  `)}renderPropertyList(e,n,a){let t=M(e,ae);if(!t)return"<!-- LookRenderer: PropertyList missing look.source -->";let o=this.readLabelForUri(t)??t.name,s=P(n,t),r=this.gatherValueItems(s),i=r.length>0?r.map(c=>`<li>${this.renderInlineValue(c,ae,a)}</li>`).join(""):'<li class="kan-empty">(no values)</li>';return['<section class="kan-property-list">',`<h3 class="kan-property-list-title">${p(o)}</h3>`,`<ul class="kan-property-list-items">${i}</ul>`,"</section>"].join(`
148
- `)}renderPropertyTable(e,n,a,t=""){let o=M(e,ae);if(!o)return"<!-- LookRenderer: PropertyTable missing look.source -->";let s=this.gatherValueItems(P(n,o)).filter(c=>c instanceof q);if(s.length===0)return"";let r=this.readLabelForUri(o)??o.name,i=t?`${t}.${o.name}`:o.name;return this.renderEmbeddedTable(s,a,r,i)}renderEmbeddedTable(e,n,a,t){let o=[],s=new Set;for(let f of e)for(let m of f.statement){let b=m.predicate?.subject;if(!b||this.isMetaPredicate(b))continue;let _=`${b.publisher}/${b.package_}/${b.name}`;s.has(_)||(s.add(_),o.push({uri:{publisher:b.publisher,package_:b.package_,name:b.name},label:this.readLabelForUri(b)??b.name}))}if(o.length===0)return"";let r=e.map(f=>A(this.catalog,f).label),i=e.some((f,m)=>r[m]!==""&&r[m]!==f.name),c=!!t,l=(c?'<th class="kan-anchor-col"></th>':"")+(i?"<th></th>":"")+o.map(f=>`<th>${p(f.label)}</th>`).join(""),d=e.map((f,m)=>{let b=c&&f.name?`${t}.${f.name}`:"",_=b?` id="${p(b)}"`:"",$=c?`<td class="kan-anchor-col">${b?this.anchorLink(b):""}</td>`:"",S=i?`<th scope="row">${p(r[m]??"")}</th>`:"",w=o.map(x=>{let I=P(f,x.uri);return`<td>${I?this.tableCellValue(I,n):""}</td>`}).join("");return`<tr${_}>${$}${S}${w}</tr>`}).join(""),u=c&&t?` id="${p(t)}"`:"",g=c&&t?this.anchorLink(t):"",k=a?`<caption>${p(a)}${g}</caption>`:"";return`<table class="kan-property-table"${u}>${k}<thead><tr>${l}</tr></thead><tbody>${d}</tbody></table>`}tableCellValue(e,n){if(e instanceof Ie)return this.statementToMarkdownHtml(e,n);if(e instanceof Q)return Ln(e.object);if(e instanceof ve||e instanceof ue)return p(String(e.object));if(e instanceof N&&e.object instanceof O)return this.detailReferenceLink(e.object,n);if(e instanceof re)return this.renderEmbeddedTable([e.object],n);if(e instanceof W){let a=e.object??[],t=a.filter(o=>o instanceof q);return t.length>0&&t.length===a.length?this.renderEmbeddedTable(t,n):a.map(o=>o instanceof O?this.detailReferenceLink(o,n):o instanceof q?this.renderEmbeddedTable([o],n):p(String(o))).filter(o=>o).join(", ")}return""}statementToMarkdownHtml(e,n){let a=new Map,t;if(e instanceof Ie?t=this.resolveMarkdownLinks(e,n,a):e instanceof Q&&(t=e.object),!t)return"";let o=this.codeHighlighter(),s=Be(t,{highlight:(r,i)=>o.highlight(r,i)});for(let[r,i]of a){let c=new RegExp('(<a href="'+xn(r)+'">)([^<]*)(</a>)',"g");s=s.replace(c,`$1<img class="kan-md-chip" src="${p(i)}" alt="" loading="lazy">$2$3`)}return s}renderBadgeRow(e,n,a){let t=M(e,ae);if(!t)return"<!-- LookRenderer: BadgeRow missing look.source -->";let o=this.readPropertyValueReferences(n,t);return o.length===0?"":`<div class="kan-badge-row">${o.map(r=>this.renderBadge(r,ae,a)).join("")}</div>`}renderChipRow(e,n,a){let t=en(e,Sa);if(t.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let o=[];for(let s of t){let r=P(n,s);if(!r)continue;let i=this.readLabelForUri(s)??s.name,c=this.renderStatementInlineValue(r,s,a);c&&o.push(`<span class="kan-chip"><span class="kan-chip-key">${p(i)}</span> <span class="kan-chip-val">${c}</span></span>`)}return o.length===0?"":`<div class="kan-chip-row">${o.join("")}</div>`}renderReferenceList(e,n,a){let t=en(e,Rn);if(t.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let o=L(e,hn),s=L(e,oa),r=[];for(let i of t){let c=this.readPropertyValueReferences(n,i);if(c.length===0)continue;let l=this.readLabelForUri(i)??i.name;if(o){let d=c.map(u=>this.renderDetailRow(u,o,s,a)).filter(u=>u).join("");d&&r.push(`<dt>${p(l)}</dt><dd><ul class="kan-ref-rows">${d}</ul></dd>`)}else{let d=c.map(u=>this.renderReferenceLink(u,Rn,a)).join(", ");r.push(`<dt>${p(l)}</dt><dd>${d}</dd>`)}}return r.length===0?"":`<dl class="kan-reference-list">${r.join("")}</dl>`}renderDetailRow(e,n,a,t){let o=H(this.catalog,{publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name,...e.subject.version?{version:e.subject.version}:{}});if(!o)return"";let s=this.resolvePath(o,n)??A(this.catalog,o).label,r="";if(a){let d=this.resolvePath(o,a);d&&(r=`<span class="kan-ref-badge">${p(d)}</span>`)}let i=`<span class="kan-ref-text">${p(s)}</span>${r}`;if(!this.isLinkable(B(o),t))return`<li class="kan-ref-row"><span class="kan-ref-rowlink">${i}</span></li>`;let c=this.hrefForSubject(o,t),l=this.svgUrlForSubject(o,t);return`<li class="kan-ref-row"><a class="kan-ref-rowlink" href="${p(c)}"><img class="kan-ref-icon" src="${p(l)}" alt="" loading="lazy"/>`+i+"</a></li>"}readPropertyValueText(e,n){let a=P(e,n);if(a){if(a instanceof Q)return a.object;if(a instanceof N){let t=a.object;return this.readLabelForUri({publisher:t.subject.publisher,package_:t.subject.package_,name:t.subject.name})??t.subject.name}if(a instanceof re)return this.readEmbeddedText(a.object,0)||void 0;if(a instanceof W)return(a.object??[]).map(o=>o instanceof O?this.readLabelForUri({publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name})??o.subject.name:o instanceof q?this.readEmbeddedText(o,0):String(o)).filter(o=>o).join(", ")}}readEmbeddedText(e,n){if(n>=jn)return"\u2026";let a=[];for(let t of e.statement)if(t.predicate?.subject?.name!=="type")if(t instanceof Q)a.push(t.object);else if(t instanceof ve||t instanceof ue)a.push(String(t.object));else if(t instanceof N){let s=t.object;a.push(this.readLabelForUri({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name})??s.subject.name)}else t instanceof re&&a.push(this.readEmbeddedText(t.object,n+1));return a.filter(t=>t).join(", ")}readPropertyValueReferences(e,n){let a=P(e,n);if(!a)return[];if(a instanceof N)return[a.object];if(a instanceof W){let t=[];for(let o of a.object??[])o instanceof O&&t.push(o);return t}return[]}gatherValueItems(e){return e?e instanceof W?e.object??[]:e instanceof N?[e.object]:e instanceof re?[e.object]:e instanceof Q?[e.object]:e instanceof ve||e instanceof ue?[e.object]:[]:[]}renderInlineValue(e,n,a,t=0){return e instanceof O?this.renderReferenceLink(e,n,a):e instanceof q?this.renderEmbeddedInline(e,a,t):typeof e=="string"?p(e):typeof e=="number"||typeof e=="boolean"?p(String(e)):""}renderStatementInlineValue(e,n,a,t=0){return e instanceof Q?p(e.object):e instanceof ve||e instanceof ue?p(String(e.object)):e instanceof N?this.renderReferenceLink(e.object,n,a):e instanceof re?this.renderEmbeddedInline(e.object,a,t):e instanceof W?(e.object??[]).map(s=>this.renderInlineValue(s,n,a,t)).filter(s=>s).join(", "):""}renderEmbeddedInline(e,n,a=0){if(a>=jn)return"\u2026";let t=[];for(let o of e.statement){let s=o.predicate?.subject;if(!s||s.name==="type")continue;let r=this.readLabelForUri({publisher:s.publisher,package_:s.package_,name:s.name})??s.name,i=this.renderStatementInlineValue(o,s,n,a+1);i&&t.push(`<dt>${p(r)}</dt><dd>${i}</dd>`)}return t.length?`<dl class="kan-embedded">${t.join("")}</dl>`:""}renderReferenceLink(e,n,a){let t=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name;if(!this.isLinkable(e.subject.publisher,a))return`<span class="kan-link-plain">${p(t)}</span>`;let o=this.urlForReference(e,n,a);return`<a class="kan-link" href="${p(o)}">${p(t)}</a>`}isLinkable(e,n){return this.publisherFirst||e===n}renderBadge(e,n,a){let t=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}),s=o?` title="${p(o)}"`:"";if(!this.isLinkable(e.subject.publisher,a))return`<span class="kan-badge"${s}>${p(t)}</span>`;let r=this.urlForReference(e,n,a);return`<a class="kan-badge" href="${p(r)}"${s}>${p(t)}</a>`}urlForReference(e,n,a){let t=n?this.getUrlFormForProperty(n):"=";return this.resourceHref({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},a,t)}getUrlFormForProperty(e){let n=H(this.catalog,e);if(!n)return"=";let a=L(n,Ra);return a==="*"||a==="^"||a==="~"||a==="="?a:"="}readLabelForUri(e){let n=H(this.catalog,e);if(n)return A(this.catalog,n).label}readCommentForUri(e){let n=H(this.catalog,e);if(n)return A(this.catalog,n).summary}};function Je(h){let e=new Map;for(let n of h.statement){if(!(n instanceof re)||!ge(n,Me.publisher,Me.package_,Me.name))continue;let a=n.object;for(let t of a.statement){if(!(t instanceof Q))continue;let o=t.predicate?.subject?.name;if(!o)continue;let s=t.object;e.has(o)||e.set(o,s)}}return e}function Te(h){for(let e of h.statement)if(e instanceof re&&ge(e,Ae.publisher,Ae.package_,Ae.name))return e.object}function Qe(h){for(let e of h.statement){if(!(e instanceof W)||!ge(e,Ze.publisher,Ze.package_,Ze.name))continue;let n=[];for(let a of e.object??[])a instanceof q&&n.push(a);return n}return[]}function ye(h){for(let e of h.statement)if(e instanceof N&&e.predicate?.subject?.name==="type"&&e.object instanceof O){let n=e.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function M(h,e){for(let n of h.statement)if(n instanceof N&&ge(n,e.publisher,e.package_,e.name)&&n.object instanceof O){let a=n.object.subject;return{publisher:a.publisher,package_:a.package_,name:a.name}}}function en(h,e){for(let n of h.statement){if(!(n instanceof W)||!ge(n,e.publisher,e.package_,e.name))continue;let a=[];for(let t of n.object??[])t instanceof O&&a.push({publisher:t.subject.publisher,package_:t.subject.package_,name:t.subject.name});return a}return[]}function P(h,e){for(let n of h.statement)if(ge(n,e.publisher,e.package_,e.name))return n}function L(h,e){for(let n of h.statement)if(n instanceof Q&&ge(n,e.publisher,e.package_,e.name))return n.object}function yn(h,e){for(let n of h.statement)if(n instanceof ve&&ge(n,e.publisher,e.package_,e.name))return n.object}function ya(h,e){for(let n of h.statement)if(n instanceof ue&&ge(n,e.publisher,e.package_,e.name))return n.object===!0;return!1}function Ka(h){for(let e of ce(h))if(R(e.subject,Mn)||R(e.subject,Dn))return!0;return!1}function ce(h){let e=[];for(let n of h.statement)if(n instanceof N){if(n.predicate?.subject?.name!=="type")continue;n.object instanceof O&&e.push(n.object)}else if(n instanceof W){if(n.predicate?.subject?.name!=="type")continue;for(let a of n.object??[])a instanceof O&&e.push(a)}return e}function Ee(h){let e=[];for(let n of h.statement)if(n instanceof N){if(n.predicate?.subject?.name!=="subClassOf")continue;n.object instanceof O&&e.push(n.object)}else if(n instanceof W){if(n.predicate?.subject?.name!=="subClassOf")continue;for(let a of n.object??[])a instanceof O&&e.push(a)}return e}function fe(h,e){let n=[];for(let a of h){if(!(a instanceof ie)||a.name!==e.name)continue;(a.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(a)}return n.sort((a,t)=>{let o=oe((a.namespace||"").split("@")[1]??""),s=oe((t.namespace||"").split("@")[1]??"");return o?s?xe(s,o):-1:s?1:0}),n}function H(h,e){let n="version"in e?e.version:void 0;if(n){let a=`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}`;for(let t of h)if(t instanceof ie&&t.name===e.name&&t.namespace===a)return t}for(let a of h){if(!(a instanceof ie)||a.name!==e.name)continue;if((a.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return a}}function ge(h,e,n,a){let t=h.predicate?.subject;return t?t.publisher===e&&t.package_===n&&t.name===a:!1}function R(h,e){return h.publisher===e.publisher&&h.package_===e.package_&&h.name===e.name}function z(h){return`${h.publisher}/${h.package_}/${h.name}`}function B(h){let e=h.namespace||"",n=e.indexOf("/");return n>=0?e.substring(0,n):e}function p(h){return h.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function xa(h){let e=h.lastIndexOf(".");return e>=0?h.substring(e+1):h}function La(h,e){for(let n of h.statement)if(n.predicate?.subject?.name===e)return n}function wa(h,e){let n=[];for(let a of h.statement)a.predicate?.subject?.name===e&&n.push(a);return n}function me(h){return h.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function nn(h,e){return h.length<=e?h:h.slice(0,e).replace(/\s+\S*$/,"")+"\u2026"}function Kn(h){return h.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function xn(h){return h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ln(h){let e=De(h);return p(e||h)}function De(h){let e=/^(\d{4})-(\d{2})-(\d{2})([T ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?)?$/.exec(h.trim());if(!e)return;let n=Date.parse(h);if(!Number.isFinite(n))return;let a=new Date(n),o=`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][a.getUTCMonth()]} ${a.getUTCDate()}, ${a.getUTCFullYear()}`;if(!e[4])return o;let s=a.getUTCHours(),r=(s+11)%12+1,i=s>=12?"PM":"AM";return`${o} \xB7 ${r}:${String(a.getUTCMinutes()).padStart(2,"0")} ${i} UTC`}function Ce(h){if(!h)return"";let e=/^(\d{4})-(\d{2})-(\d{2})/.exec(h);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)}`:h}export{A as a,Be as b,tn as c};
148
+ `)}renderPropertyTable(e,n,a,t=""){let o=M(e,ae);if(!o)return"<!-- LookRenderer: PropertyTable missing look.source -->";let s=this.gatherValueItems(P(n,o)).filter(c=>c instanceof q);if(s.length===0)return"";let r=this.readLabelForUri(o)??o.name,i=t?`${t}.${o.name}`:o.name;return this.renderEmbeddedTable(s,a,r,i)}renderEmbeddedTable(e,n,a,t){let o=[],s=new Set;for(let f of e)for(let m of f.statement){let b=m.predicate?.subject;if(!b||this.isMetaPredicate(b))continue;let _=`${b.publisher}/${b.package_}/${b.name}`;s.has(_)||(s.add(_),o.push({uri:{publisher:b.publisher,package_:b.package_,name:b.name},label:this.readLabelForUri(b)??b.name}))}if(o.length===0)return"";let r=e.map(f=>A(this.catalog,f).label),i=e.some((f,m)=>r[m]!==""&&r[m]!==f.name),c=!!t,l=(c?'<th class="kan-anchor-col"></th>':"")+(i?"<th></th>":"")+o.map(f=>`<th>${p(f.label)}</th>`).join(""),d=e.map((f,m)=>{let b=c&&f.name?`${t}.${f.name}`:"",_=b?` id="${p(b)}"`:"",$=c?`<td class="kan-anchor-col">${b?this.anchorLink(b):""}</td>`:"",S=i?`<th scope="row">${p(r[m]??"")}</th>`:"",w=o.map(x=>{let I=P(f,x.uri);return`<td>${I?this.tableCellValue(I,n):""}</td>`}).join("");return`<tr${_}>${$}${S}${w}</tr>`}).join(""),u=c&&t?` id="${p(t)}"`:"",g=c&&t?this.anchorLink(t):"",k=a?`<caption>${p(a)}${g}</caption>`:"";return`<table class="kan-property-table"${u}>${k}<thead><tr>${l}</tr></thead><tbody>${d}</tbody></table>`}tableCellValue(e,n){if(e instanceof Ie)return this.statementToMarkdownHtml(e,n);if(e instanceof Q)return Ln(e.object);if(e instanceof ve||e instanceof ue)return p(String(e.object));if(e instanceof N&&e.object instanceof O)return this.detailReferenceLink(e.object,n);if(e instanceof re)return this.renderEmbeddedTable([e.object],n);if(e instanceof W){let a=e.object??[],t=a.filter(o=>o instanceof q);return t.length>0&&t.length===a.length?this.renderEmbeddedTable(t,n):a.map(o=>o instanceof O?this.detailReferenceLink(o,n):o instanceof q?this.renderEmbeddedTable([o],n):p(String(o))).filter(o=>o).join(", ")}return""}statementToMarkdownHtml(e,n){let a=new Map,t;if(e instanceof Ie?t=this.resolveMarkdownLinks(e,n,a):e instanceof Q&&(t=e.object),!t)return"";let o=this.codeHighlighter(),s=Be(t,{highlight:(r,i)=>o.highlight(r,i)});for(let[r,i]of a){let c=new RegExp('(<a href="'+xn(r)+'">)([^<]*)(</a>)',"g");s=s.replace(c,`$1<img class="kan-md-chip" src="${p(i)}" alt="" loading="lazy">$2$3`)}return s}renderBadgeRow(e,n,a){let t=M(e,ae);if(!t)return"<!-- LookRenderer: BadgeRow missing look.source -->";let o=this.readPropertyValueReferences(n,t);return o.length===0?"":`<div class="kan-badge-row">${o.map(r=>this.renderBadge(r,ae,a)).join("")}</div>`}renderChipRow(e,n,a){let t=en(e,Sa);if(t.length===0)return"<!-- LookRenderer: ChipRow has no look.chips -->";let o=[];for(let s of t){let r=P(n,s);if(!r)continue;let i=this.readLabelForUri(s)??s.name,c=this.renderStatementInlineValue(r,s,a);c&&o.push(`<span class="kan-chip"><span class="kan-chip-key">${p(i)}</span> <span class="kan-chip-val">${c}</span></span>`)}return o.length===0?"":`<div class="kan-chip-row">${o.join("")}</div>`}renderReferenceList(e,n,a){let t=en(e,Rn);if(t.length===0)return"<!-- LookRenderer: ReferenceList has no look.entries -->";let o=L(e,hn),s=L(e,oa),r=[];for(let i of t){let c=this.readPropertyValueReferences(n,i);if(c.length===0)continue;let l=this.readLabelForUri(i)??i.name;if(o){let d=c.map(u=>this.renderDetailRow(u,o,s,a)).filter(u=>u).join("");d&&r.push(`<dt>${p(l)}</dt><dd><ul class="kan-ref-rows">${d}</ul></dd>`)}else{let d=c.map(u=>this.renderReferenceLink(u,Rn,a)).join(", ");r.push(`<dt>${p(l)}</dt><dd>${d}</dd>`)}}return r.length===0?"":`<dl class="kan-reference-list">${r.join("")}</dl>`}renderDetailRow(e,n,a,t){let o=H(this.catalog,{publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name,...e.subject.version?{version:e.subject.version}:{}});if(!o)return"";let s=this.resolvePath(o,n)??A(this.catalog,o).label,r="";if(a){let d=this.resolvePath(o,a);d&&(r=`<span class="kan-ref-badge">${p(d)}</span>`)}let i=`<span class="kan-ref-text">${p(s)}</span>${r}`;if(!this.isLinkable(B(o),t))return`<li class="kan-ref-row"><span class="kan-ref-rowlink">${i}</span></li>`;let c=this.hrefForSubject(o,t),l=this.svgUrlForSubject(o,t);return`<li class="kan-ref-row"><a class="kan-ref-rowlink" href="${p(c)}"><img class="kan-ref-icon" src="${p(l)}" alt="" loading="lazy"/>`+i+"</a></li>"}readPropertyValueText(e,n){let a=P(e,n);if(a){if(a instanceof Q)return a.object;if(a instanceof N){let t=a.object;return this.readLabelForUri({publisher:t.subject.publisher,package_:t.subject.package_,name:t.subject.name})??t.subject.name}if(a instanceof re)return this.readEmbeddedText(a.object,0)||void 0;if(a instanceof W)return(a.object??[]).map(o=>o instanceof O?this.readLabelForUri({publisher:o.subject.publisher,package_:o.subject.package_,name:o.subject.name})??o.subject.name:o instanceof q?this.readEmbeddedText(o,0):String(o)).filter(o=>o).join(", ")}}readEmbeddedText(e,n){if(n>=jn)return"\u2026";let a=[];for(let t of e.statement)if(t.predicate?.subject?.name!=="type")if(t instanceof Q)a.push(t.object);else if(t instanceof ve||t instanceof ue)a.push(String(t.object));else if(t instanceof N){let s=t.object;a.push(this.readLabelForUri({publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name})??s.subject.name)}else t instanceof re&&a.push(this.readEmbeddedText(t.object,n+1));return a.filter(t=>t).join(", ")}readPropertyValueReferences(e,n){let a=P(e,n);if(!a)return[];if(a instanceof N)return[a.object];if(a instanceof W){let t=[];for(let o of a.object??[])o instanceof O&&t.push(o);return t}return[]}gatherValueItems(e){return e?e instanceof W?e.object??[]:e instanceof N?[e.object]:e instanceof re?[e.object]:e instanceof Q?[e.object]:e instanceof ve||e instanceof ue?[e.object]:[]:[]}renderInlineValue(e,n,a,t=0){return e instanceof O?this.renderReferenceLink(e,n,a):e instanceof q?this.renderEmbeddedInline(e,a,t):typeof e=="string"?p(e):typeof e=="number"||typeof e=="boolean"?p(String(e)):""}renderStatementInlineValue(e,n,a,t=0){return e instanceof Q?p(e.object):e instanceof ve||e instanceof ue?p(String(e.object)):e instanceof N?this.renderReferenceLink(e.object,n,a):e instanceof re?this.renderEmbeddedInline(e.object,a,t):e instanceof W?(e.object??[]).map(s=>this.renderInlineValue(s,n,a,t)).filter(s=>s).join(", "):""}renderEmbeddedInline(e,n,a=0){if(a>=jn)return"\u2026";let t=[];for(let o of e.statement){let s=o.predicate?.subject;if(!s||s.name==="type")continue;let r=this.readLabelForUri({publisher:s.publisher,package_:s.package_,name:s.name})??s.name,i=this.renderStatementInlineValue(o,s,n,a+1);i&&t.push(`<dt>${p(r)}</dt><dd>${i}</dd>`)}return t.length?`<dl class="kan-embedded">${t.join("")}</dl>`:""}renderReferenceLink(e,n,a){let t=this.readLabelForUri({publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name})??e.subject.name;if(!this.isLinkable(e.subject.publisher,a))return`<span class="kan-link-plain">${p(t)}</span>`;let o=this.urlForReference(e,n,a);return`<a class="kan-link" href="${p(o)}">${p(t)}</a>`}isLinkable(e,n){return this.publisherFirst||e===n}renderBadge(e,n,a){let t=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}),s=o?` title="${p(o)}"`:"";if(!this.isLinkable(e.subject.publisher,a))return`<span class="kan-badge"${s}>${p(t)}</span>`;let r=this.urlForReference(e,n,a);return`<a class="kan-badge" href="${p(r)}"${s}>${p(t)}</a>`}urlForReference(e,n,a){let t=n?this.getUrlFormForProperty(n):"=";return this.resourceHref({publisher:e.subject.publisher,package_:e.subject.package_,...e.subject.version?{version:e.subject.version}:{},name:e.subject.name},a,t)}getUrlFormForProperty(e){let n=H(this.catalog,e);if(!n)return"=";let a=L(n,Ra);return a==="*"||a==="^"||a==="~"||a==="="?a:"="}readLabelForUri(e){let n=H(this.catalog,e);if(n)return A(this.catalog,n).label}readCommentForUri(e){let n=H(this.catalog,e);if(n)return A(this.catalog,n).summary}};function Je(h){let e=new Map;for(let n of h.statement){if(!(n instanceof re)||!ge(n,Me.publisher,Me.package_,Me.name))continue;let a=n.object;for(let t of a.statement){if(!(t instanceof Q))continue;let o=t.predicate?.subject?.name;if(!o)continue;let s=t.object;e.has(o)||e.set(o,s)}}return e}function Te(h){for(let e of h.statement)if(e instanceof re&&ge(e,Ae.publisher,Ae.package_,Ae.name))return e.object}function Qe(h){for(let e of h.statement){if(!(e instanceof W)||!ge(e,Ze.publisher,Ze.package_,Ze.name))continue;let n=[];for(let a of e.object??[])a instanceof q&&n.push(a);return n}return[]}function ye(h){for(let e of h.statement)if(e instanceof N&&e.predicate?.subject?.name==="type"&&e.object instanceof O){let n=e.object.subject;return{publisher:n.publisher,package_:n.package_,name:n.name}}}function M(h,e){for(let n of h.statement)if(n instanceof N&&ge(n,e.publisher,e.package_,e.name)&&n.object instanceof O){let a=n.object.subject;return{publisher:a.publisher,package_:a.package_,name:a.name}}}function en(h,e){for(let n of h.statement){if(!(n instanceof W)||!ge(n,e.publisher,e.package_,e.name))continue;let a=[];for(let t of n.object??[])t instanceof O&&a.push({publisher:t.subject.publisher,package_:t.subject.package_,name:t.subject.name});return a}return[]}function P(h,e){for(let n of h.statement)if(ge(n,e.publisher,e.package_,e.name))return n}function L(h,e){for(let n of h.statement)if(n instanceof Q&&ge(n,e.publisher,e.package_,e.name))return n.object}function yn(h,e){for(let n of h.statement)if(n instanceof ve&&ge(n,e.publisher,e.package_,e.name))return n.object}function ya(h,e){for(let n of h.statement)if(n instanceof ue&&ge(n,e.publisher,e.package_,e.name))return n.object===!0;return!1}function Ka(h){for(let e of ce(h))if(R(e.subject,Mn)||R(e.subject,Dn))return!0;return!1}function ce(h){let e=[];for(let n of h.statement)if(n instanceof N){if(n.predicate?.subject?.name!=="type")continue;n.object instanceof O&&e.push(n.object)}else if(n instanceof W){if(n.predicate?.subject?.name!=="type")continue;for(let a of n.object??[])a instanceof O&&e.push(a)}return e}function Ee(h){let e=[];for(let n of h.statement)if(n instanceof N){if(n.predicate?.subject?.name!=="subClassOf")continue;n.object instanceof O&&e.push(n.object)}else if(n instanceof W){if(n.predicate?.subject?.name!=="subClassOf")continue;for(let a of n.object??[])a instanceof O&&e.push(a)}return e}function de(h,e){let n=[];for(let a of h){if(!(a instanceof ie)||a.name!==e.name)continue;(a.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(a)}return n.sort((a,t)=>{let o=oe((a.namespace||"").split("@")[1]??""),s=oe((t.namespace||"").split("@")[1]??"");return o?s?xe(s,o):-1:s?1:0}),n}function H(h,e){let n="version"in e?e.version:void 0;if(n){let a=`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}`;for(let t of h)if(t instanceof ie&&t.name===e.name&&t.namespace===a)return t}for(let a of h){if(!(a instanceof ie)||a.name!==e.name)continue;if((a.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))return a}}function ge(h,e,n,a){let t=h.predicate?.subject;return t?t.publisher===e&&t.package_===n&&t.name===a:!1}function R(h,e){return h.publisher===e.publisher&&h.package_===e.package_&&h.name===e.name}function z(h){return`${h.publisher}/${h.package_}/${h.name}`}function B(h){let e=h.namespace||"",n=e.indexOf("/");return n>=0?e.substring(0,n):e}function p(h){return h.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function xa(h){let e=h.lastIndexOf(".");return e>=0?h.substring(e+1):h}function La(h,e){for(let n of h.statement)if(n.predicate?.subject?.name===e)return n}function wa(h,e){let n=[];for(let a of h.statement)a.predicate?.subject?.name===e&&n.push(a);return n}function me(h){return h.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")}function nn(h,e){return h.length<=e?h:h.slice(0,e).replace(/\s+\S*$/,"")+"\u2026"}function Kn(h){return h.toLowerCase().trim().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}function xn(h){return h.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function Ln(h){let e=De(h);return p(e||h)}function De(h){let e=/^(\d{4})-(\d{2})-(\d{2})([T ]\d{2}:\d{2}(?::\d{2})?(?:\.\d+)?(?:Z|[+-]\d{2}:?\d{2})?)?$/.exec(h.trim());if(!e)return;let n=Date.parse(h);if(!Number.isFinite(n))return;let a=new Date(n),o=`${["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][a.getUTCMonth()]} ${a.getUTCDate()}, ${a.getUTCFullYear()}`;if(!e[4])return o;let s=a.getUTCHours(),r=(s+11)%12+1,i=s>=12?"PM":"AM";return`${o} \xB7 ${r}:${String(a.getUTCMinutes()).padStart(2,"0")} ${i} UTC`}function Ce(h){if(!h)return"";let e=/^(\d{4})-(\d{2})-(\d{2})/.exec(h);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)}`:h}export{A as a,Be as b,tn as c};
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import{a as ut,b as pt,c as mt,d as ft,e as yt}from"./chunk-QHJ6EY3Y.js";import{a as sr,c as cr}from"./chunk-IL6VHYRU.js";import{a as ct,b as lt,c as dt,d as b,e as S,f as i}from"./chunk-KSTGTV35.js";import{a as ir}from"./chunk-IUCHSPLQ.js";import"./chunk-3NEUHF7E.js";import{a as Le,b as Fe,c as De,d as Ne,e as Oe,f as Me,g as _e,h as ze}from"./chunk-CA2EATJR.js";import{a as Te,c as Ae,d as Ue,e as He}from"./chunk-RSIZQAFL.js";import{a as ht,b as kt,c as bt,d as St}from"./chunk-7JZUJ2K4.js";import{a as Ct,b as Kt}from"./chunk-PEUTCG3B.js";import{a as wt}from"./chunk-PEJALHXK.js";import{a as Ve}from"./chunk-SC5M74NM.js";import{A as rr,B as nr,C as or,E as ar,a as It,b as Bt,c as Tt,d as jt,e as Lt,f as Ft,g as Dt,h as Nt,i as Ot,j as At,k as Ut,l as Vt,m as Ht,n as Mt,o as _t,p as zt,q as Gt,r as Wt,s as Jt,t as qt,u as Yt,v as Xt,w as Zt,x as Qt,y as er,z as tr}from"./chunk-OIVACCMQ.js";import{a as ot,b as at,c as it}from"./chunk-Q6QTQWR2.js";import{a as F,b as N,c as Ye}from"./chunk-H2LEQLVD.js";import{a as je}from"./chunk-ORFSMEMM.js";import{a as st,b as Pt,c as Rt,d as xt,e as vt,f as $t,g as Et}from"./chunk-N224PFBI.js";import"./chunk-Q4DKP5DO.js";import{b as Xe,c as Ze,d as Qe,e as et,f as tt,h as rt,j as nt}from"./chunk-64TVBQFR.js";import{a as Ge,b as j,c as L,d as D,e as Je,f as qe,g as O,h as A,i as U,j as V,k as H,l as M}from"./chunk-W6T7MOKY.js";import{a as We}from"./chunk-FUUTGGJS.js";import{a as Pe,b as Re,c as we,d as xe,e as ve,f as $e,g as Ee,h as Ke,i as Ie,j as Be}from"./chunk-2ACBWC7K.js";import{a as gt}from"./chunk-ODIECDN7.js";import{VersionOperator as ko}from"@kanonak-protocol/types/document/models/enums";import{existsSync as vr,readFileSync as $r}from"fs";import{homedir as Er}from"os";import{join as Kr}from"path";import{execFile as lr}from"child_process";import{promisify as dr}from"util";var C=dr(lr),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 ut,b as pt,c as mt,d as ft,e as yt}from"./chunk-QHJ6EY3Y.js";import{a as sr,c as cr}from"./chunk-6HRLK46T.js";import{a as ct,b as lt,c as dt,d as b,e as S,f as i}from"./chunk-KSTGTV35.js";import{a as ir}from"./chunk-IUCHSPLQ.js";import"./chunk-3NEUHF7E.js";import{a as Le,b as Fe,c as De,d as Ne,e as Oe,f as Me,g as _e,h as ze}from"./chunk-CA2EATJR.js";import{a as Te,c as Ae,d as Ue,e as He}from"./chunk-RSIZQAFL.js";import{a as ht,b as kt,c as bt,d as St}from"./chunk-7JZUJ2K4.js";import{a as Ct,b as Kt}from"./chunk-PEUTCG3B.js";import{a as wt}from"./chunk-PEJALHXK.js";import{a as Ve}from"./chunk-SC5M74NM.js";import{A as rr,B as nr,C as or,E as ar,a as It,b as Bt,c as Tt,d as jt,e as Lt,f as Ft,g as Dt,h as Nt,i as Ot,j as At,k as Ut,l as Vt,m as Ht,n as Mt,o as _t,p as zt,q as Gt,r as Wt,s as Jt,t as qt,u as Yt,v as Xt,w as Zt,x as Qt,y as er,z as tr}from"./chunk-OIVACCMQ.js";import{a as ot,b as at,c as it}from"./chunk-Q6QTQWR2.js";import{a as F,b as N,c as Ye}from"./chunk-H2LEQLVD.js";import{a as je}from"./chunk-ORFSMEMM.js";import{a as st,b as Pt,c as Rt,d as xt,e as vt,f as $t,g as Et}from"./chunk-N224PFBI.js";import"./chunk-Q4DKP5DO.js";import{b as Xe,c as Ze,d as Qe,e as et,f as tt,h as rt,j as nt}from"./chunk-64TVBQFR.js";import{a as Ge,b as j,c as L,d as D,e as Je,f as qe,g as O,h as A,i as U,j as V,k as H,l as M}from"./chunk-W6T7MOKY.js";import{a as We}from"./chunk-FUUTGGJS.js";import{a as Pe,b as Re,c as we,d as xe,e as ve,f as $e,g as Ee,h as Ke,i as Ie,j as Be}from"./chunk-2ACBWC7K.js";import{a as gt}from"./chunk-ODIECDN7.js";import{VersionOperator as ko}from"@kanonak-protocol/types/document/models/enums";import{existsSync as vr,readFileSync as $r}from"fs";import{homedir as Er}from"os";import{join as Kr}from"path";import{execFile as lr}from"child_process";import{promisify as dr}from"util";var C=dr(lr),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)}
@@ -1,4 +1,4 @@
1
- import{a as p}from"../chunk-IL6VHYRU.js";import"../chunk-3NEUHF7E.js";import"../chunk-PEUTCG3B.js";import"../chunk-PEJALHXK.js";import"../chunk-SC5M74NM.js";import"../chunk-H2LEQLVD.js";import{d as m,g as x}from"../chunk-N224PFBI.js";import{a as d,f as S}from"../chunk-Q4DKP5DO.js";import"../chunk-64TVBQFR.js";import{c as j}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{c as v}from"../chunk-2ACBWC7K.js";import{homedir as P}from"os";import{join as k}from"path";import{existsSync as B,mkdirSync as C,readFileSync as D,writeFileSync as O}from"fs";import{createHash as z}from"crypto";var f="Xenova/all-MiniLM-L6-v2",w="q8",b=32,g=null;async function K(){return g||(g=(async()=>{let t;try{t=await import("@huggingface/transformers")}catch(i){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
1
+ import{a as p}from"../chunk-6HRLK46T.js";import"../chunk-3NEUHF7E.js";import"../chunk-PEUTCG3B.js";import"../chunk-PEJALHXK.js";import"../chunk-SC5M74NM.js";import"../chunk-H2LEQLVD.js";import{d as m,g as x}from"../chunk-N224PFBI.js";import{a as d,f as S}from"../chunk-Q4DKP5DO.js";import"../chunk-64TVBQFR.js";import{c as j}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{c as v}from"../chunk-2ACBWC7K.js";import{homedir as P}from"os";import{join as k}from"path";import{existsSync as B,mkdirSync as C,readFileSync as D,writeFileSync as O}from"fs";import{createHash as z}from"crypto";var f="Xenova/all-MiniLM-L6-v2",w="q8",b=32,g=null;async function K(){return g||(g=(async()=>{let t;try{t=await import("@huggingface/transformers")}catch(i){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
2
2
  Install it with:
3
3
  npm install @huggingface/transformers
4
4
  (underlying import error: ${i.message})`)}let{pipeline:r,env:n}=t;n.cacheDir=k(P(),".kanonak","models");let e=await r("feature-extraction",f,{dtype:w});return async i=>(await e(i,{pooling:"mean",normalize:!0})).tolist()})()),g}function H(t,r){let n=0;for(let e=0;e<t.length;e++)n+=t[e]*r[e];return n}function U(t,r){return r?t.version?r.version?v(t.version,r.version)>0:!0:!1:!0}function F(t,r){let n=p(t,r),e=[n.label],i=x(r);if(i.length>0){let s=S(t,i[0]),c=s?p(t,s).label:i[0].name;c&&e.push(`\u2014 a ${c}.`)}return n.summary&&e.push(n.summary),e.join(" ")}function M(t){let r=new Map;for(let n of t){if(!(n instanceof j))continue;let e=m(n);if(!e)continue;let i=d(e),s=r.get(i);(!s||U(e,m(s)))&&r.set(i,n)}return[...r.values()].sort((n,e)=>{let i=m(n)?d(m(n)):n.name,s=m(e)?d(m(e)):e.name;return i.localeCompare(s)})}var y=class{entries=[];get size(){return this.entries.length}async build(r,n={}){let e=M(r);if(n.include&&(e=e.filter(n.include)),e.length===0)return this.entries=[],{size:0,cached:!1};let i=e.map(o=>F(r,o)),s=n.cacheDir,c;if(s){let o=z("sha256").update(f+"|"+w+`
@@ -1,3 +1,3 @@
1
- import{c as O}from"../chunk-IL6VHYRU.js";import"../chunk-3NEUHF7E.js";import{a as z,d as j,f as Z,g as V}from"../chunk-CA2EATJR.js";import{a as J,b as Q,c as X,d as F,e as I}from"../chunk-RSIZQAFL.js";import"../chunk-PEUTCG3B.js";import{a as te}from"../chunk-PEJALHXK.js";import"../chunk-SC5M74NM.js";import{c as N}from"../chunk-Q6QTQWR2.js";import"../chunk-H2LEQLVD.js";import{a as K}from"../chunk-ORFSMEMM.js";import{b as L}from"../chunk-N224PFBI.js";import"../chunk-Q4DKP5DO.js";import"../chunk-64TVBQFR.js";import{c as ee}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{c as C,g as Y}from"../chunk-2ACBWC7K.js";import{readFileSync as ce,existsSync as le,readdirSync as pe,writeFileSync as ue,mkdirSync as de}from"fs";import{join as W}from"path";function re(a){let e=a.metadata?.namespace_;return e?`${e.publisher}/${e.package_}`:void 0}async function A(a,e){let r=new Set,t=[...a];for(;t.length>0;){let n=t.shift(),u=re(n);if(!u||r.has(u))continue;r.add(u);let d=n.metadata?.imports;if(d)for(let[i,g]of Object.entries(d))for(let f of g)try{let p=await e.getHighestCompatibleVersionAsync(i,f);p&&t.push(p)}catch{}}return r}var D=class{constructor(e,r){this.inner=e;this.scope=r}inner;scope;async getAllDocumentsAsync(){return(await this.inner.getAllDocumentsAsync()).filter(r=>{let t=re(r);return t!==void 0&&this.scope.has(t)})}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,r){return this.inner.getDocumentsByNamespaceAsync(e,r)}getHighestCompatibleVersionAsync(e,r){return this.inner.getHighestCompatibleVersionAsync(e,r)}saveDocumentAsync(e,r){return this.inner.saveDocumentAsync(e,r)}deleteDocumentAsync(e){return this.inner.deleteDocumentAsync(e)}clearNamespaceAsync(e,r){return this.inner.clearNamespaceAsync(e,r)}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var ne=[{publisher:"kanonak.org",package_:"core-kanonak"},{publisher:"kanonak.org",package_:"site"},{publisher:"kanonak.org",package_:"link"},{publisher:"kanonak.org",package_:"look-tokens"},{publisher:"kanonak.org",package_:"look-styles"},{publisher:"kanonak.org",package_:"look"},{publisher:"kanonak.org",package_:"universal-look"}];function M(a){let e=a?.render;if(e&&e.length>0){let r=[];for(let t of e)try{let n=L(t);n.kind==="package"?r.push({publisher:n.publisher,package_:n.package_}):n.kind==="resource"&&r.push({publisher:n.uri.publisher,package_:n.uri.package_})}catch{}if(r.length>0)return r}return ne}function B(a){return`${a.publisher}/${a.package_}`}function E(a){let{publisher:e,availablePublishers:r,catalog:t,lookRenderer:n,localNamespaces:u,rawByNsKey:d}=a,i=new Map,g=new Map,f=new Map,p=new Set;for(let o of t){if(!(o instanceof ee))continue;let m=o.namespace||"";if(!u.has(m))continue;i.set(`${m}/${o.name}`,o);let k=m.split("/")[1]??"",[v,$]=k.split("@");if(!v||!$)continue;let c=Y($);c&&(p.has(k)||(p.add(k),g.has(v)||g.set(v,[]),g.get(v).push({verStr:$,version:c})),o.name===v&&f.set(k,o))}for(let o of g.values())o.sort((m,k)=>C(k.version,m.version));return{publisher:e,availablePublishers:r,catalog:t,lookRenderer:n,localNamespaces:u,rawByNsKey:d,bySubject:i,pkgVersions:g,pkgSelfByVer:f}}async function H(a,e={}){let r=new K,t=new J(r),n=[],u=[];for(let c of V(a)){let R;try{R=ce(c,"utf-8")}catch{continue}let b;try{b=r.parse(R).metadata?.namespace_}catch{continue}if(!b?.version)continue;let x=b.version;u.push({publisher:b.publisher,package_:b.package_,verStr:`${x.major}.${x.minor}.${x.patch}`,version:x,source:R})}u.sort((c,R)=>C(R.version,c.version));for(let c of u)await t.saveDocumentAsync(r.parse(c.source),`${c.publisher}/${c.package_}@${c.verStr}`),n.push({publisher:c.publisher,package_:c.package_,verStr:c.verStr,source:c.source});let d=[...new Set(n.map(c=>c.publisher))].sort(),i=e.publisher;if(i){if(!d.includes(i))throw new Error(`Publisher "${i}" not found in workspace. Available: ${d.join(", ")||"(none)"}`)}else if(d.length===1)i=d[0];else throw d.length===0?new Error(`No Kanonak packages found under ${a}`):new Error(`Workspace has multiple publishers (${d.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let g=new Set,f=new Map;for(let c of n)c.publisher===i&&(g.add(`${c.publisher}/${c.package_}@${c.verStr}`),f.set(`${c.package_}@${c.verStr}`,c.source));let p=new z(j(),!0,r),o=e.repository??new Z(t,p,new I(e.httpCache?{getFromCache:e.httpCache.getFromCache,onFetch:e.httpCache.onFetch}:void 0)),m=M(void 0);if(!e.repository){let c=j(),R=s=>{let h=W(c,s);return le(h)?new Set(pe(h).filter(y=>y.endsWith(".kan.yml")).map(y=>y.split("@")[0])):new Set},b=(s,h)=>n.some(y=>y.publisher===s&&y.package_===h),x=new F,l=new Map;for(let s of m)if(l.has(s.publisher)||l.set(s.publisher,R(s.publisher)),!(l.get(s.publisher).has(s.package_)||b(s.publisher,s.package_)))try{let h=await x.getHighestVersion(s.publisher,s.package_);if(!h)continue;let y=await x.getPackageUrl(s.publisher,s.package_,h),P=await fetch(y);if(!P.ok)continue;let ie=await P.text(),G=W(c,s.publisher);de(G,{recursive:!0}),ue(W(G,`${s.package_}@${h}.kan.yml`),ie,"utf-8")}catch{}}let k=o;if(!e.repository){let c=(await t.getAllDocumentsAsync()).filter(b=>b.metadata.namespace_?.publisher===i),R=await A(c,o);for(let b of m)R.add(B(b));k=new D(o,R)}let v=await new N(r).parseKanonaks(k),$=new O(v);return E({publisher:i,availablePublishers:d,catalog:v,lookRenderer:$,localNamespaces:g,rawByNsKey:f})}import{existsSync as me,readFileSync as ge,writeFileSync as fe,mkdirSync as he}from"fs";import{join as oe}from"path";async function q(a,e={}){let r=new K,t=L(a),n=t.kind==="resource"?t.uri.publisher:t.publisher,u=e.cacheRoot??j(),d=(l,s,h)=>oe(u,l,`${s}@${h}.kan.yml`),i=new I({getFromCache:(l,s,h)=>{let y=d(l,s,h);return me(y)?ge(y,"utf-8"):null},onFetch:(l,s,h,y)=>{let P=oe(u,l);he(P,{recursive:!0}),fe(d(l,s,h),y,"utf-8")},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),g=new F(e.fetchFn?{fetchFn:e.fetchFn}:void 0),f;if(t.kind==="resource"){let l=t.uri.version;f=[l?{package_:t.uri.package_,version:`${l.major}.${l.minor}.${l.patch}`}:{package_:t.uri.package_}]}else if(t.kind==="package"){let l=t.version;f=[l?{package_:t.package_,version:`${l.major}.${l.minor}.${l.patch}`}:{package_:t.package_}]}else f=(await g.listLatestPackages(n)).map(s=>({package_:s.packageName}));let p=async(l,s,h)=>{try{let y=h?r.buildImport(s,"=",h,l):r.buildImport(s,"*","0.0.0",l);return await i.getHighestCompatibleVersionAsync(l,y)}catch{return null}},o=[];for(let l of f){let s=await p(n,l.package_,l.version);s&&o.push(s)}if(o.length===0)throw new Error(`Could not fetch any package for address "${a}" from publisher "${n}".`);let m=await new X().getConfig(n).catch(()=>{}),k=[];for(let l of M(m)){let s=await p(l.publisher,l.package_,void 0);s&&k.push(s)}let v=await A([...o,...k],i),$=new D(i,v),c=await new N(r).parseKanonaks($),R=new O(c),b=new Set,x=new Map;for(let l of await i.getAllDocumentsAsync()){let s=l.metadata.namespace_;if(!s||s.publisher!==n)continue;let h=`${s.version.major}.${s.version.minor}.${s.version.patch}`,y=`${s.publisher}/${s.package_}@${h}`;b.add(y);let P=await i.getDocumentContentAsync(y);P!==null&&x.set(`${s.package_}@${h}`,P)}return E({publisher:n,availablePublishers:[n],catalog:c,lookRenderer:R,localNamespaces:b,rawByNsKey:x})}var S={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".svg":"image/svg+xml",".md":"text/markdown; charset=utf-8",".kan.yml":"application/yaml; charset=utf-8",".txt":"text/plain; charset=utf-8",".json":"application/json; charset=utf-8"},w=(a,e,r,t)=>({status:a,headers:{"Content-Type":e,...t||{}},body:r}),_=a=>w(404,S[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${a}</p>`),ke=a=>({status:301,headers:{Location:a},body:""});function se(a,e,r){let t=a.pkgVersions.get(e);if(!t||t.length===0)return null;switch(r.kind){case"any":return t[0].verStr;case"major-pin":return t.find(n=>n.version.major===r.major)?.verStr??null;case"minor-pin":return t.find(n=>n.version.major===r.major&&n.version.minor===r.minor)?.verStr??null;case"exact":return t.find(n=>n.version.major===r.major&&n.version.minor===r.minor&&n.version.patch===r.patch)?.verStr??null;default:return null}}function T(a,e,r=""){let{lookRenderer:t,publisher:n}=a;if(e==="/.well-known/kanonak.json")return w(200,S[".json"],JSON.stringify(Q(n),null,2));if(e==="/index.txt"){let o=[...a.localNamespaces].map(m=>m.split("/")[1].replace("@","/")).sort();return w(200,S[".txt"],o.join(`
1
+ import{c as O}from"../chunk-6HRLK46T.js";import"../chunk-3NEUHF7E.js";import{a as z,d as j,f as Z,g as V}from"../chunk-CA2EATJR.js";import{a as J,b as Q,c as X,d as F,e as I}from"../chunk-RSIZQAFL.js";import"../chunk-PEUTCG3B.js";import{a as te}from"../chunk-PEJALHXK.js";import"../chunk-SC5M74NM.js";import{c as N}from"../chunk-Q6QTQWR2.js";import"../chunk-H2LEQLVD.js";import{a as K}from"../chunk-ORFSMEMM.js";import{b as L}from"../chunk-N224PFBI.js";import"../chunk-Q4DKP5DO.js";import"../chunk-64TVBQFR.js";import{c as ee}from"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";import{c as C,g as Y}from"../chunk-2ACBWC7K.js";import{readFileSync as ce,existsSync as le,readdirSync as pe,writeFileSync as ue,mkdirSync as de}from"fs";import{join as W}from"path";function re(a){let e=a.metadata?.namespace_;return e?`${e.publisher}/${e.package_}`:void 0}async function A(a,e){let r=new Set,t=[...a];for(;t.length>0;){let n=t.shift(),u=re(n);if(!u||r.has(u))continue;r.add(u);let d=n.metadata?.imports;if(d)for(let[i,g]of Object.entries(d))for(let f of g)try{let p=await e.getHighestCompatibleVersionAsync(i,f);p&&t.push(p)}catch{}}return r}var D=class{constructor(e,r){this.inner=e;this.scope=r}inner;scope;async getAllDocumentsAsync(){return(await this.inner.getAllDocumentsAsync()).filter(r=>{let t=re(r);return t!==void 0&&this.scope.has(t)})}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,r){return this.inner.getDocumentsByNamespaceAsync(e,r)}getHighestCompatibleVersionAsync(e,r){return this.inner.getHighestCompatibleVersionAsync(e,r)}saveDocumentAsync(e,r){return this.inner.saveDocumentAsync(e,r)}deleteDocumentAsync(e){return this.inner.deleteDocumentAsync(e)}clearNamespaceAsync(e,r){return this.inner.clearNamespaceAsync(e,r)}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};var ne=[{publisher:"kanonak.org",package_:"core-kanonak"},{publisher:"kanonak.org",package_:"site"},{publisher:"kanonak.org",package_:"link"},{publisher:"kanonak.org",package_:"look-tokens"},{publisher:"kanonak.org",package_:"look-styles"},{publisher:"kanonak.org",package_:"look"},{publisher:"kanonak.org",package_:"universal-look"}];function M(a){let e=a?.render;if(e&&e.length>0){let r=[];for(let t of e)try{let n=L(t);n.kind==="package"?r.push({publisher:n.publisher,package_:n.package_}):n.kind==="resource"&&r.push({publisher:n.uri.publisher,package_:n.uri.package_})}catch{}if(r.length>0)return r}return ne}function B(a){return`${a.publisher}/${a.package_}`}function E(a){let{publisher:e,availablePublishers:r,catalog:t,lookRenderer:n,localNamespaces:u,rawByNsKey:d}=a,i=new Map,g=new Map,f=new Map,p=new Set;for(let o of t){if(!(o instanceof ee))continue;let m=o.namespace||"";if(!u.has(m))continue;i.set(`${m}/${o.name}`,o);let k=m.split("/")[1]??"",[v,$]=k.split("@");if(!v||!$)continue;let c=Y($);c&&(p.has(k)||(p.add(k),g.has(v)||g.set(v,[]),g.get(v).push({verStr:$,version:c})),o.name===v&&f.set(k,o))}for(let o of g.values())o.sort((m,k)=>C(k.version,m.version));return{publisher:e,availablePublishers:r,catalog:t,lookRenderer:n,localNamespaces:u,rawByNsKey:d,bySubject:i,pkgVersions:g,pkgSelfByVer:f}}async function H(a,e={}){let r=new K,t=new J(r),n=[],u=[];for(let c of V(a)){let R;try{R=ce(c,"utf-8")}catch{continue}let b;try{b=r.parse(R).metadata?.namespace_}catch{continue}if(!b?.version)continue;let x=b.version;u.push({publisher:b.publisher,package_:b.package_,verStr:`${x.major}.${x.minor}.${x.patch}`,version:x,source:R})}u.sort((c,R)=>C(R.version,c.version));for(let c of u)await t.saveDocumentAsync(r.parse(c.source),`${c.publisher}/${c.package_}@${c.verStr}`),n.push({publisher:c.publisher,package_:c.package_,verStr:c.verStr,source:c.source});let d=[...new Set(n.map(c=>c.publisher))].sort(),i=e.publisher;if(i){if(!d.includes(i))throw new Error(`Publisher "${i}" not found in workspace. Available: ${d.join(", ")||"(none)"}`)}else if(d.length===1)i=d[0];else throw d.length===0?new Error(`No Kanonak packages found under ${a}`):new Error(`Workspace has multiple publishers (${d.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let g=new Set,f=new Map;for(let c of n)c.publisher===i&&(g.add(`${c.publisher}/${c.package_}@${c.verStr}`),f.set(`${c.package_}@${c.verStr}`,c.source));let p=new z(j(),!0,r),o=e.repository??new Z(t,p,new I(e.httpCache?{getFromCache:e.httpCache.getFromCache,onFetch:e.httpCache.onFetch}:void 0)),m=M(void 0);if(!e.repository){let c=j(),R=s=>{let h=W(c,s);return le(h)?new Set(pe(h).filter(y=>y.endsWith(".kan.yml")).map(y=>y.split("@")[0])):new Set},b=(s,h)=>n.some(y=>y.publisher===s&&y.package_===h),x=new F,l=new Map;for(let s of m)if(l.has(s.publisher)||l.set(s.publisher,R(s.publisher)),!(l.get(s.publisher).has(s.package_)||b(s.publisher,s.package_)))try{let h=await x.getHighestVersion(s.publisher,s.package_);if(!h)continue;let y=await x.getPackageUrl(s.publisher,s.package_,h),P=await fetch(y);if(!P.ok)continue;let ie=await P.text(),G=W(c,s.publisher);de(G,{recursive:!0}),ue(W(G,`${s.package_}@${h}.kan.yml`),ie,"utf-8")}catch{}}let k=o;if(!e.repository){let c=(await t.getAllDocumentsAsync()).filter(b=>b.metadata.namespace_?.publisher===i),R=await A(c,o);for(let b of m)R.add(B(b));k=new D(o,R)}let v=await new N(r).parseKanonaks(k),$=new O(v);return E({publisher:i,availablePublishers:d,catalog:v,lookRenderer:$,localNamespaces:g,rawByNsKey:f})}import{existsSync as me,readFileSync as ge,writeFileSync as fe,mkdirSync as he}from"fs";import{join as oe}from"path";async function q(a,e={}){let r=new K,t=L(a),n=t.kind==="resource"?t.uri.publisher:t.publisher,u=e.cacheRoot??j(),d=(l,s,h)=>oe(u,l,`${s}@${h}.kan.yml`),i=new I({getFromCache:(l,s,h)=>{let y=d(l,s,h);return me(y)?ge(y,"utf-8"):null},onFetch:(l,s,h,y)=>{let P=oe(u,l);he(P,{recursive:!0}),fe(d(l,s,h),y,"utf-8")},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),g=new F(e.fetchFn?{fetchFn:e.fetchFn}:void 0),f;if(t.kind==="resource"){let l=t.uri.version;f=[l?{package_:t.uri.package_,version:`${l.major}.${l.minor}.${l.patch}`}:{package_:t.uri.package_}]}else if(t.kind==="package"){let l=t.version;f=[l?{package_:t.package_,version:`${l.major}.${l.minor}.${l.patch}`}:{package_:t.package_}]}else f=(await g.listLatestPackages(n)).map(s=>({package_:s.packageName}));let p=async(l,s,h)=>{try{let y=h?r.buildImport(s,"=",h,l):r.buildImport(s,"*","0.0.0",l);return await i.getHighestCompatibleVersionAsync(l,y)}catch{return null}},o=[];for(let l of f){let s=await p(n,l.package_,l.version);s&&o.push(s)}if(o.length===0)throw new Error(`Could not fetch any package for address "${a}" from publisher "${n}".`);let m=await new X().getConfig(n).catch(()=>{}),k=[];for(let l of M(m)){let s=await p(l.publisher,l.package_,void 0);s&&k.push(s)}let v=await A([...o,...k],i),$=new D(i,v),c=await new N(r).parseKanonaks($),R=new O(c),b=new Set,x=new Map;for(let l of await i.getAllDocumentsAsync()){let s=l.metadata.namespace_;if(!s||s.publisher!==n)continue;let h=`${s.version.major}.${s.version.minor}.${s.version.patch}`,y=`${s.publisher}/${s.package_}@${h}`;b.add(y);let P=await i.getDocumentContentAsync(y);P!==null&&x.set(`${s.package_}@${h}`,P)}return E({publisher:n,availablePublishers:[n],catalog:c,lookRenderer:R,localNamespaces:b,rawByNsKey:x})}var S={".html":"text/html; charset=utf-8",".css":"text/css; charset=utf-8",".svg":"image/svg+xml",".md":"text/markdown; charset=utf-8",".kan.yml":"application/yaml; charset=utf-8",".txt":"text/plain; charset=utf-8",".json":"application/json; charset=utf-8"},w=(a,e,r,t)=>({status:a,headers:{"Content-Type":e,...t||{}},body:r}),_=a=>w(404,S[".html"],`<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Not found: ${a}</p>`),ke=a=>({status:301,headers:{Location:a},body:""});function se(a,e,r){let t=a.pkgVersions.get(e);if(!t||t.length===0)return null;switch(r.kind){case"any":return t[0].verStr;case"major-pin":return t.find(n=>n.version.major===r.major)?.verStr??null;case"minor-pin":return t.find(n=>n.version.major===r.major&&n.version.minor===r.minor)?.verStr??null;case"exact":return t.find(n=>n.version.major===r.major&&n.version.minor===r.minor&&n.version.patch===r.patch)?.verStr??null;default:return null}}function T(a,e,r=""){let{lookRenderer:t,publisher:n}=a;if(e==="/.well-known/kanonak.json")return w(200,S[".json"],JSON.stringify(Q(n),null,2));if(e==="/index.txt"){let o=[...a.localNamespaces].map(m=>m.split("/")[1].replace("@","/")).sort();return w(200,S[".txt"],o.join(`
2
2
  `)+`
3
3
  `)}if(e==="/"||e==="/index.html"||e==="/index.css"){let o=t.publisherSubject(n);return e==="/index.css"?w(200,S[".css"],t.renderStylesheet(o)):w(200,S[".html"],t.renderDocument(o,{rootIndex:!0}))}let u=".html",d=!1,i=e;for(let o of[".kan.yml",".css",".svg",".md",".html"])if(e.endsWith(o)){u=o,d=!0,i=e.slice(0,-o.length);break}let g=!d&&/application\/yaml|text\/yaml/i.test(r),f=i.endsWith("/");f&&i!=="/"&&(i=i.slice(0,-1));let p=te.parse(i,n);if(!p)return _(e);if(p.kind==="package"){let o=se(a,p.package_,p.versionSpec);if(!o)return _(e);if(u===".kan.yml"||g){let v=a.rawByNsKey.get(`${p.package_}@${o}`);return v!==void 0?w(200,S[".kan.yml"],v):_(e)}let m=a.pkgSelfByVer.get(`${p.package_}@${o}`);if(!m)return _(e);if(u===".css")return w(200,S[".css"],t.renderStylesheet(m));if(!f)return ke(i+"/");let k=p.versionSpec.kind==="any";if(k&&!t.hasDeclaredView(m)){let v=(a.pkgVersions.get(p.package_)||[]).map($=>$.verStr);return w(200,S[".html"],t.renderPackageVersionList(p.package_,v,m))}return w(200,S[".html"],t.renderDocument(m,k?{bareOverview:!0}:void 0))}if(p.kind==="resource"){let o=se(a,p.package_,p.versionSpec);if(!o)return _(e);let m=a.bySubject.get(`${n}/${p.package_}@${o}/${p.name}`);if(!m)return _(e);switch(u){case".css":return w(200,S[".css"],t.renderStylesheet(m));case".svg":return w(200,S[".svg"],t.renderSvg(m));case".md":{let k=t.renderRawMarkdown(m);return k===void 0?_(e):w(200,S[".md"],k)}default:return w(200,S[".html"],t.renderDocument(m))}}return _(e)}import{readFileSync as ye}from"fs";var U=class{constructor(e={}){this.options=e}options;models=new Map;workspaceIndex;clearCache(){this.models.clear(),this.workspaceIndex=void 0}getWorkspaceIndex(){if(this.workspaceIndex)return this.workspaceIndex;let e=new Set,r=new Set;if(this.options.root!==void 0){let t=new K;for(let n of V(this.options.root))try{let u=t.parse(ye(n,"utf-8")).metadata?.namespace_;if(!u?.version)continue;let d=u.version;e.add(`${u.publisher}/${u.package_}@${d.major}.${d.minor}.${d.patch}`),r.add(`${u.publisher}/${u.package_}`)}catch{}}return this.workspaceIndex={exact:e,pkgs:r},this.workspaceIndex}async modelFor(e,r,t){let n=this.getWorkspaceIndex(),u=this.options.fetchFn?{fetchFn:this.options.fetchFn}:{},d=r?t?n.exact.has(`${e}/${r}@${t}`):n.pkgs.has(`${e}/${r}`):[...n.pkgs].some(o=>o.startsWith(`${e}/`)),i,g;if(d&&this.options.root!==void 0){let o=this.options.root;i=`ws:${e}`,g=()=>H(o,{publisher:e})}else{let o=r?t?`${e}/${r}@${t}`:`${e}/${r}`:e;i=`rm:${o}`,g=()=>q(o,u)}let f=this.models.get(i);if(f)return f;let p=await g();return p.lookRenderer.setLinkMode("open-world"),this.models.set(i,p),p}async handle(e,r=""){let t=e.split("/").filter(Boolean);if(t.length===0)return{status:200,headers:{"Content-Type":"text/html; charset=utf-8"},body:ae()};let n=t[0];if(!n.includes("."))return{status:404,headers:{"Content-Type":"text/html; charset=utf-8"},body:"<!doctype html><meta charset=utf-8><title>404</title><h1>404</h1><p>Expected a publisher domain as the first path segment: <code>/{publisher}/{package}/{version}/{resource}</code></p>"};let u=t.length>=2&&(t[1]==="index.html"||t[1]==="index.css"||t[1]==="index.txt"||t[1]===".well-known"),d=!u&&t.length>=2?t[1]:void 0,i=!u&&t.length>=3&&/^\d+\.\d+\.\d+$/.test(t[2])?t[2]:void 0,g=await this.modelFor(n,d,i),f=e.endsWith("/")&&t.length>1?"/":"",p="/"+t.slice(1).join("/")+f,o=T(g,p,r);return o.headers.Location?{...o,headers:{...o.headers,Location:`/${n}${o.headers.Location}`}}:o}};function ae(){return'<!doctype html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><title>Kanonak origin</title></head><body style="font-family:system-ui;max-width:40rem;margin:4rem auto;padding:0 1rem"><h1>Kanonak request-driven origin</h1><p>Open a resource by its address:</p><p><code>/{publisher}/{package}/{version}/{resource}</code></p><p>e.g. <code>/kanonak.org/capabilities/2.0.0/Capability</code></p></body></html>'}export{D as ClosureScopedRepository,U as RequestRouter,ne as UNIVERSAL_RENDER_BASE,A as deriveImportClosure,ae as landingPage,q as loadResourceModel,H as loadServerModel,B as renderRefKey,M as resolveRenderContract,T as route};
@@ -1,4 +1,4 @@
1
- import{b as X,c as ye}from"../chunk-IL6VHYRU.js";import{a as Ne}from"../chunk-IUCHSPLQ.js";import"../chunk-3NEUHF7E.js";import"../chunk-7JZUJ2K4.js";import"../chunk-PEJALHXK.js";import{c as Ue}from"../chunk-Q6QTQWR2.js";import{a as C,c as Ce}from"../chunk-H2LEQLVD.js";import{a as Re}from"../chunk-ORFSMEMM.js";import{b as E,c as F,d as f,f as M,l as Oe}from"../chunk-Q4DKP5DO.js";import"../chunk-64TVBQFR.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"../chunk-FUUTGGJS.js";import{g as Le}from"../chunk-2ACBWC7K.js";var yt="kanonak.org",kt="document-ast",m=t=>({publisher:yt,package_:kt,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 Ie(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=ht(e.metadata,n),a=St(e.children),u=["---",...r,"---","",a].join(`
1
+ import{b as X,c as ye}from"../chunk-6HRLK46T.js";import{a as Ne}from"../chunk-IUCHSPLQ.js";import"../chunk-3NEUHF7E.js";import"../chunk-7JZUJ2K4.js";import"../chunk-PEJALHXK.js";import{c as Ue}from"../chunk-Q6QTQWR2.js";import{a as C,c as Ce}from"../chunk-H2LEQLVD.js";import{a as Re}from"../chunk-ORFSMEMM.js";import{b as E,c as F,d as f,f as M,l as Oe}from"../chunk-Q4DKP5DO.js";import"../chunk-64TVBQFR.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"../chunk-FUUTGGJS.js";import{g as Le}from"../chunk-2ACBWC7K.js";var yt="kanonak.org",kt="document-ast",m=t=>({publisher:yt,package_:kt,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 Ie(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=ht(e.metadata,n),a=St(e.children),u=["---",...r,"---","",a].join(`
2
2
  `);return n?.trailingNewline&&(u.endsWith(`
3
3
  `)||(u+=`
4
4
  `)),u}};function ht(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=Me(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 Me(t,e){switch(t.kind){case"StringScalar":return bt(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let a=Me(r,e);a!==void 0&&n.push(a)}return n.join(", ")}case"StructuredMap":return;default:return}}function bt(t,e){return!e||Ie(e,k.ESC_RAW)?t:Ie(e,k.ESC_YAML_SAFE)?wt(t):t}function wt(t){return t.includes(`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/sdk",
3
- "version": "3.65.0",
3
+ "version": "3.66.0",
4
4
  "description": "TypeScript SDK for the Kanonak Protocol — parse, resolve, validate, reason over, and render .kan.yml packages.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -122,7 +122,7 @@
122
122
  "yaml-parser"
123
123
  ],
124
124
  "dependencies": {
125
- "@kanonak-protocol/types": "^3.65.0",
125
+ "@kanonak-protocol/types": "^3.66.0",
126
126
  "ignore": "^7.0.5",
127
127
  "js-yaml": "^4.1.0",
128
128
  "yaml": "^2.7.0"