@kanonak-protocol/sdk 5.32.0 → 5.33.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.
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as Do,b as Ho,c as To,d as Fo,e as D}from"./chunk-EVMSO7HJ.js";import{a as Kn,b as xn,c as Cn}from"./chunk-V3DH67P3.js";import{a as Ao,b as $o,c as Mo,d as qt,e as Xt,f as Yt,g as Jt,h as Qt,i as Zt}from"./chunk-PXS6XZ3V.js";import{a as er}from"./chunk-L2J7WD7E.js";import{a as Ft,b as Bt,c as Wt,d as H,e as Gt,f as zt,g as ge,h as nr,i as or,j as tr,k as rr,l as ar}from"./chunk-PRXC2HZ3.js";import{a as Zn,b as eo,c as no,d as oo,e as to,f as ko,g as ho,h as So,i as go}from"./chunk-IS3AQKB4.js";import{a as ro,b as ao,c as io,d as so,e as co,f as uo,h as lo,i as ve,j as Le,k as _e,l as Ie,m as po,n as mo}from"./chunk-BZ3YTI3C.js";import{a as Wo,b as Go,c as zo,d as qo}from"./chunk-BS7RRG7D.js";import{a as Xo}from"./chunk-XK24CN3C.js";import{a as fo}from"./chunk-SC5M74NM.js";import{A as Kt,B as xt,C as Ct,D as Pt,E as vt,F as Lt,G as Ut,H as At,I as $t,J as Mt,K as Dt,L as Ht,M as Tt,a as Jo,b as Qo,c as Zo,d as et,e as nt,f as ot,g as tt,h as rt,i as at,j as it,k as st,l as ct,m as ut,n as lt,o as pt,p as dt,q as ft,r as mt,s as kt,t as ht,u as St,v as gt,w as yt,x as bt,y as Rt,z as Et}from"./chunk-LRVOGQI5.js";import"./chunk-KIBR3HAT.js";import{c as bn,d as _t,e as It,g as wt,h as Vt,k as Nt,m as Se,o as Rn,p as En,r as jt,s as Ot}from"./chunk-DD3TCFBT.js";import"./chunk-QHABFCRC.js";import{a as ie}from"./chunk-6VIUXP4N.js";import{a as v,b as $,c as pe,i as I,j as he,k as Oo,l as Uo,m as N}from"./chunk-PVUBHIU2.js";import{a as A}from"./chunk-HF5FJBS2.js";import{a as Yo}from"./chunk-PEJALHXK.js";import{$ as ke,A as Ge,B as ze,C as qe,D as Xe,E as Ye,F as Je,G as Qe,H as Ze,I as en,J as nn,K as on,L as tn,M as me,N as rn,O as an,P as sn,Q as cn,R as un,S as ln,T as pn,U as dn,V as fn,W as mn,X as kn,Y as hn,Z as Sn,_ as gn,a as xo,b as Co,c as Po,d as vo,da as wo,e as M,f as Lo,fa as Vo,g as _o,ga as h,ha as Y,i as Io,j as z,k as q,l as Ne,m as X,ma as No,n as je,na as jo,o as Oe,oa as J,p as Ue,q as Ae,r as $e,s as Me,t as De,u as He,v as fe,w as Te,x as Fe,y as Be,z as We}from"./chunk-7UYXTYXC.js";import{A as de,B as _,C as yn,a as yo,b as bo,c as R,d as g,e as Eo,f as Ko,g as se,h as ce,i as ue,j as B,k as le,l as W,m as c,r as we,t as K,w as Ve,x as L,y as G,z as k}from"./chunk-CJMVIOZX.js";import{a as Ro}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{a as Bn,b as Wn,c as F,d as Gn,e as U,f as zn,g as qn,h as Xn,i as Yn,j as Jn,k as Qn}from"./chunk-QILEJIFU.js";import{a as Bo}from"./chunk-ODIECDN7.js";async function Pn(e){let n=await new N().parseKanonaks(e),r=await new D().reason(e);return{kind:"merged",catalog:n,reasoning:r}}function vn(e,n){return{kind:"merged",catalog:e,reasoning:n}}async function Ln(e,n){let r=n??new ie(new A);return{kind:"standalone",catalog:await new N().parseKanonaks(new yn(e,r))}}function j(e){return typeof e=="number"?e:void 0}function ir(e){if(!e)return;let n=c(e);if(n===c(nn))return"IRI";if(n===c(on))return"BlankNode";if(n===c(tn))return"Literal"}function _n(e){if(!e)return;let n=c(e);if(n===c(rn))return"Violation";if(n===c(an))return"Warning";if(n===c(sn))return"Info"}function ye(e,n){let r=k(e,n);if(r)return[r];let o=[];for(let t of _(e,n))t instanceof g&&o.push(t.subject);return o}function sr(e,n){let r=k(e,Ae);if(!r)return;let o={path:r},t=j(L(e,$e)),a=j(L(e,Me));t!==void 0&&(o.minCount=t),a!==void 0&&(o.maxCount=a);let s=j(L(e,Be)),i=j(L(e,We));s!==void 0&&(o.minLength=s),i!==void 0&&(o.maxLength=i);let u=j(L(e,Ge)),d=j(L(e,ze));u!==void 0&&(o.minInclusive=u),d!==void 0&&(o.maxInclusive=d);let p=G(e,Te);if(p!==void 0){let b=G(e,Fe);o.pattern=b!==void 0?{regex:p,flags:b}:{regex:p}}if(Ve(e,fe)){let b=[],w=[];for(let V of _(e,fe))V instanceof $?b.push(V.value):V instanceof g&&w.push(V.subject);b.length>0&&(o.inValues=b),w.length>0&&(o.inRefs=w)}let S=k(e,De);S&&(o.datatype=S);let y=k(e,He);y&&(o.classRef=y);let l=ir(k(e,en));l&&(o.nodeKind=l);let f=G(e,qe);f!==void 0&&(o.message=f);let m=_n(k(e,me))??n;return m&&(o.severity=m),o}function Q(e){let n=[];for(let r of e){if(!(r instanceof R)||!we(r,X))continue;let o=_n(k(r,me)),t={name:r.name,uri:h(r),targetClass:k(r,Oe),targetNodes:ye(r,Xe),targetSubjectsOf:ye(r,Ye),targetObjectsOf:ye(r,Je),closed:L(r,Qe)===!0,ignoredProperties:[],severity:o,properties:[]};for(let a of _(r,Ze))a instanceof g&&t.ignoredProperties.push(a.subject);for(let a of _(r,Ue)){let s;if(a instanceof v?s=a:a instanceof g&&(s=K(e,a.subject)),!s)continue;let i=sr(s,o);i&&t.properties.push(i)}n.push(t)}return n}var x="kanonak.org/transformations",Z="values";var ee="allowed",C=e=>({type:`${x}/VarRef`,varName:e}),be=e=>({type:`${x}/IntegerLiteral`,integerLiteral:e}),cr=e=>({type:`${x}/DecimalLiteral`,decimalLiteral:e}),In=e=>Number.isInteger(e)?be(e):cr(e),wn=e=>({type:`${x}/Count`,source:e}),Vn=(e,n)=>({type:`${x}/GreaterThanOrEqual`,compareLeft:e,compareRight:n}),Nn=(e,n)=>({type:`${x}/LessThanOrEqual`,compareLeft:e,compareRight:n});function Re(e,n){if(!n||n.length===0)return e;let r=new Set(["i","m","s"]),o=[...new Set(n.split(""))];if(o.filter(a=>!r.has(a)).length>0)throw new Error(`sh:flags '${n}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${e}`}function ne(e){let n=[];return e.minCount!==void 0&&n.push({component:"minCount",per:"node",expr:Vn(wn(C(Z)),be(e.minCount))}),e.maxCount!==void 0&&n.push({component:"maxCount",per:"node",expr:Nn(wn(C(Z)),be(e.maxCount))}),(e.inValues!==void 0||e.inRefs!==void 0)&&n.push({component:"in",per:"value",expr:{type:`${x}/Contains`,haystack:C(ee),needle:C("v")}}),e.pattern!==void 0&&n.push({component:"pattern",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:Re(e.pattern.regex,e.pattern.flags)}}),e.minLength!==void 0&&n.push({component:"minLength",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:`(?s)^.{${e.minLength},}$`}}),e.maxLength!==void 0&&n.push({component:"maxLength",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:`(?s)^.{0,${e.maxLength}}$`}}),e.minInclusive!==void 0&&n.push({component:"minInclusive",per:"value",expr:Vn(C("v"),In(e.minInclusive))}),e.maxInclusive!==void 0&&n.push({component:"maxInclusive",per:"value",expr:Nn(C("v"),In(e.maxInclusive))}),n}import{evaluate as lr,ExpressionError as pr}from"@kanonak-protocol/expression";function Un(e,n){let r=dr(n)?n:Q(n),o=[];for(let t of r)for(let a of fr(e,t))hr(e,t,a,o);return{conforms:!o.some(t=>t.severity==="Violation"),results:o}}function dr(e){return e.length>0&&!(e[0]instanceof Object&&"statement"in e[0])&&typeof e[0].name=="string"&&"properties"in e[0]}function oe(e){let n=e.predicate;return n instanceof g?n:void 0}function fr(e,n){let r=new Map,o=e.catalog.filter(a=>a instanceof R),t=a=>{let s=h(a);r.set(s?c(s):`${a.namespace}/${a.name}`,a)};if(n.targetClass){let a=c(n.targetClass);if(e.reasoning){let s=new Set(e.reasoning.getInstancesOfClass(n.targetClass));for(let i of o){let u=h(i);u&&s.has(c(u))&&t(i)}}else for(let s of o)J(s).some(u=>c(u)===a||Y(e.catalog,u).some(d=>c(d)===a))&&t(s)}for(let a of n.targetNodes){let s=K(e.catalog,a);s instanceof R&&t(s)}for(let a of n.targetSubjectsOf){let s=c(a);for(let i of o)i.statement.some(u=>{let d=oe(u);return d&&c(d.subject)===s})&&t(i)}for(let a of n.targetObjectsOf){let s=c(a);for(let i of o)for(let u of i.statement){let d=oe(u);if(!(!d||c(d.subject)!==s))for(let p of mr(u)){let S=K(e.catalog,p);S instanceof R&&t(S)}}}return[...r.values()]}function mr(e){return e instanceof B?[e.object.subject]:e instanceof W?(e.object??[]).filter(n=>n instanceof g).map(n=>n.subject):[]}function kr(e,n,r){let o=[];for(let t of e.statement){let a=oe(t);if(!(!a||c(a.subject)!==n)){if(t instanceof se||t instanceof pe)o.push({kernel:t.object,kind:"string",literal:t.object});else if(t instanceof ce)o.push({kernel:t.object,kind:"number",literal:t.object});else if(t instanceof ue)o.push({kernel:t.object?1:0,kind:"boolean",literal:t.object});else if(t instanceof B)o.push({kernel:{ref:c(t.object.subject)},kind:"reference",ref:t.object.subject});else if(t instanceof le)o.push(jn(t.object,r,o.length));else if(t instanceof W){for(let s of t.object??[])if(s instanceof g)o.push({kernel:{ref:c(s.subject)},kind:"reference",ref:s.subject});else if(s instanceof v)o.push(jn(s,r,o.length));else if(s instanceof $){let i=s.value;typeof i=="boolean"?o.push({kernel:i?1:0,kind:"boolean",literal:i}):o.push({kernel:i,kind:typeof i=="number"?"number":"string",literal:i})}}}}return o}function jn(e,n,r){let o=e.name&&e.name.length>0?e.name:String(r);return{kernel:{ref:`${n}#${o}`},kind:"embedded"}}function hr(e,n,r,o){let t=h(r),a=t?c(t):`${r.namespace}/${r.name}`;for(let s of n.properties)gr(e,n,r,a,t,s,o);n.closed&&Kr(n,r,a,t,o)}function Ee(e,n,r,o,t,a={},s){return{focusNode:n,focusUri:r,constraintComponent:o,severity:s??An(e),message:t,sourceShape:e.name,sourceShapeUri:e.uri,...a}}function An(e){return e.severity??"Violation"}var Sr={minCount:cn,maxCount:un,in:dn,pattern:fn,minLength:mn,maxLength:kn,minInclusive:hn,maxInclusive:Sn};function gr(e,n,r,o,t,a,s){let i=c(a.path),u=kr(r,i,o),d=a.severity??An(n),p=a.path.name,S=[...(a.inValues??[]).map(l=>typeof l=="boolean"?l?1:0:l),...(a.inRefs??[]).map(l=>({ref:c(l)}))],y=(l,f,m)=>{s.push(Ee(n,o,t,l,a.message??f,{resultPath:a.path,value:m?.literal,valueRef:m?.ref},d))};for(let l of ne(a)){let f=Sr[l.component];if(l.per==="node"){On(l,{[Z]:u.map(b=>b.kernel),[ee]:S})||y(f,l.component==="minCount"?`'${p}' has ${u.length} value(s); minCount is ${a.minCount}.`:`'${p}' has ${u.length} value(s); maxCount is ${a.maxCount}.`);continue}for(let m of u){if((l.component==="pattern"||l.component==="minLength"||l.component==="maxLength")&&m.kind!=="string"){y(f,`'${p}' value is not a string; ${l.component} applies to string values.`,m);continue}On(l,{v:m.kernel,[ee]:S})||y(f,yr(l,p,a,m),m)}}if(a.nodeKind)for(let l of u)br(a.nodeKind,l)||y(gn,`'${p}' value is ${l.kind}; nodeKind requires ${a.nodeKind}.`,l);if(a.datatype)for(let l of u){let f=Rr(a.datatype,l);f&&y(ln,`'${p}' ${f}`,l)}if(a.classRef)for(let l of u){let f=Er(e,a.classRef,l);f&&y(pn,`'${p}' ${f}`,l)}}function yr(e,n,r,o){let t=o.ref?c(o.ref):JSON.stringify(o.literal);switch(e.component){case"in":return`'${n}' value ${t} is not in the permitted set.`;case"pattern":return`'${n}' value ${t} does not match pattern ${r.pattern?.regex}.`;case"minLength":return`'${n}' value ${t} is shorter than minLength ${r.minLength}.`;case"maxLength":return`'${n}' value ${t} is longer than maxLength ${r.maxLength}.`;case"minInclusive":return`'${n}' value ${t} is below minInclusive ${r.minInclusive} (or not numeric).`;case"maxInclusive":return`'${n}' value ${t} is above maxInclusive ${r.maxInclusive} (or not numeric).`;default:return`'${n}' value ${t} violates ${e.component}.`}}function On(e,n){let r=o=>{let t=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof t=="string"&&t in n)return n[t];throw new pr(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return lr(e.expr,void 0,r)===1}function br(e,n){switch(e){case"IRI":return n.kind==="reference";case"BlankNode":return n.kind==="embedded";case"Literal":return n.kind==="string"||n.kind==="number"||n.kind==="boolean"}}function Rr(e,n){if(n.kind==="reference"||n.kind==="embedded")return`value is a ${n.kind}; sh:datatype requires a literal of ${e.name}.`;let r=he(e);if(r!==void 0)switch(r){case I.Boolean:return n.kind==="boolean"?void 0:`value is not a boolean (${e.name}).`;case I.Integer:return n.kind!=="number"?`value is not a number (${e.name}).`:Number.isInteger(n.literal)?void 0:`value is not an integer (${e.name}).`;case I.Decimal:case I.Double:case I.Float:return n.kind==="number"?void 0:`value is not a number (${e.name}).`;default:return n.kind==="string"?void 0:`value is not a string-carried literal (${e.name}).`}}function Er(e,n,r){if(r.kind!=="reference"||!r.ref)return`value is not a reference; sh:class requires an instance of ${n.name}.`;let o=c(n);if(e.reasoning)return e.reasoning.isInstanceOf(r.ref,n)?void 0:`value ${c(r.ref)} is not an instance of ${n.name}.`;let t=K(e.catalog,r.ref);return t instanceof R?J(t).some(s=>c(s)===o||Y(e.catalog,s).some(i=>c(i)===o))?void 0:`value ${c(r.ref)} is not an instance of ${n.name}.`:`value ${c(r.ref)} does not resolve in this scope (sh:class ${n.name}).`}function Kr(e,n,r,o,t){let a=new Set([...e.properties.map(i=>c(i.path)),...e.ignoredProperties.map(i=>c(i))]),s=new Set;for(let i of n.statement){let u=oe(i);if(!u)continue;let d=c(u.subject);a.has(d)||s.has(d)||(s.add(d),t.push(Ee(e,r,o,ke,`'${n.name}' carries undeclared property '${u.subject.name}' (closed shape).`,{resultPath:u.subject})))}for(let i of n.unresolvedPredicates)s.has(i.key)||(s.add(i.key),t.push(Ee(e,r,o,ke,`'${n.name}' carries unresolvable property '${i.key}' (closed shape).`,{value:i.key})))}var xr="1.1.0";async function $n(e){let n=new H(e.repository),r=n.imports(),o=r.ensure(z,q,xr,"sh"),t=(i,u)=>i&&i.version&&typeof i.version.major=="number"?`${r.ensure(i.publisher,i.package_,U(i.version),i.package_)}.${i.name}`:u,a={},s=[];return e.result.results.forEach((i,u)=>{let d=`result-${u+1}`;s.push(d);let p={type:`${o}.ValidationResult`,[`${o}.focusNode`]:t(i.focusUri,i.focusNode),[`${o}.resultMessage`]:i.message,[`${o}.resultSeverity`]:`${o}.${i.severity}`,[`${o}.sourceConstraintComponent`]:`${o}.${i.constraintComponent.name}`};i.resultPath&&(p[`${o}.resultPath`]=t(i.resultPath,c(i.resultPath))),i.sourceShapeUri&&(p[`${o}.sourceShape`]=t(i.sourceShapeUri,i.sourceShape)),i.valueRef?p[`${o}.value`]=t(i.valueRef,c(i.valueRef)):i.value!==void 0&&(p[`${o}.value`]=i.value),a[d]=p}),a.report={type:`${o}.ValidationReport`,[`${o}.conforms`]:e.result.conforms,...s.length>0?{[`${o}.result`]:s}:{}},n.buildContentAddressed({publisher:e.publisher,book:r,body:a,...e.header!==void 0?{header:e.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as ci}from"@kanonak-protocol/types/document/models/enums";var E="kanonak.org",P="view",Mn="core-kanonak",Cr={publisher:E,package_:P,name:"rootView"},Pr={publisher:E,package_:P,name:"bind"},vr={publisher:E,package_:P,name:"produces"},Lr={publisher:E,package_:P,name:"projections"},_r={publisher:E,package_:P,name:"where"},Ir={publisher:E,package_:P,name:"value"},wr={publisher:E,package_:P,name:"as"},te=class{constructor(n,r=new A){this.repository=n;this.parser=r;this.objectParser=new N(this.parser),this.builder=new H(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(n,r={}){let o=await this.objectParser.parseKanonaks(this.repository),t=this.resolveView(o,n),a=k(t,Pr);if(!a)throw new Error(`View ${t.namespace}/${t.name} declares no view.bind; cannot materialize.`);let s=k(t,vr);if(!s)throw new Error(`View ${t.namespace}/${t.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let i=Vr(t),u=Dn(o,E,Mn),d=Dn(o,E,P),p=this.builder.imports(),S=p.ensure(E,Mn,u,"ck"),y=p.ensure(E,P,d,"v"),l=p.ref(s),f=new En(this.repository,this.parser,this.objectParser),m=new Rn(f,o),b=this.readProjections(o,t),w=Or(t,_r),V=this.findInstances(o,a,await this.reason(r)),Ke={},Tn=new Set;for(let T of V){if(!await this.passesWhere(m,o,w,T))continue;let ae={type:l};for(let Ce of b){let Fn=await this.evaluateValue(m,o,Ce.value,T),Pe=this.builder.serializeValue(Hn(Fn),p);Pe!==void 0&&(ae[p.ref(Ce.as)]=Pe)}let xe=h(T);xe&&(ae[`${y}.derivedFrom`]=p.ref(xe)),Ke[this.rowName(T,Tn)]=ae}let re={};r.resolvedAt&&(re[`${S}.resolvedAt`]=r.resolvedAt),r.invocationId&&(re[`${S}.id`]=r.invocationId);let O=await this.builder.buildContentAddressed({publisher:i,book:p,body:Ke,contentHashProperty:`${S}.contentHash`,header:re});return{yaml:O.yaml,contentHash:O.contentHash,packageName:O.packageName,publisher:O.publisher,rowCount:O.resourceCount}}resolveView(n,r){let o=K(n,r);if(!o)throw new Error(`View ${r.publisher}/${r.package_}/${r.name} not found in the catalog.`);let t=k(o,Cr);if(t){let a=K(n,t);if(!a)throw new Error(`ViewPackage ${r.name} names rootView ${t.name}, which is not in the catalog.`);return a}return o}readProjections(n,r){let o=[];for(let t of _(r,Lr)){let a=t instanceof v?t:t instanceof g?K(n,t.subject):void 0;if(!a)continue;let s=de(a,Ir),i=k(a,wr);s&&i&&o.push({value:s,as:i})}return o}async reason(n){return new D({profile:n.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(n,r,o){let t=jr(n),a=[],s=new Set;for(let i of o.getInstancesOfClass(r)){if(s.has(i))continue;s.add(i);let u=t.get(i);u&&a.push(u)}return a.sort((i,u)=>{let d=M(h(i)),p=M(h(u));return d<p?-1:d>p?1:0}),a}async passesWhere(n,r,o,t){for(let a of o){let s=await this.evaluateValue(n,r,a,t);if(!Ur(s))return!1}return!0}async evaluateValue(n,r,o,t){let a=bn(o,"view-projection",{catalog:r,depth:0}),s=new Map([["input",t]]);return n.evaluate(a,s)}rowName(n,r){let o=ge(n.name)||"row",t=o,a=2;for(;r.has(t);)t=`${o}-${a++}`;return r.add(t),t}};function Hn(e){return Se(e)?e.value:Array.isArray(e)?e.map(Hn):e}function Vr(e){let n=h(e);if(!n)throw new Error(`Could not derive a publisher from view ${e.namespace}/${e.name}.`);return n.publisher}function Dn(e,n,r){let o=Nr(e,n,r);if(!o)throw new Error(`Package ${n}/${r} is not in the catalog; it must be importable to materialize a view.`);return o}function Nr(e,n,r){let o;for(let t of e){if(!(t instanceof R))continue;let a=h(t);!a||a.publisher!==n||a.package_!==r||!a.version||(!o||F(a.version,o)>0)&&(o=a.version)}return o?U(o):void 0}function jr(e){let n=new Map,r=new Map;for(let o of e){if(!(o instanceof R))continue;let t=h(o);if(!t||!t.version)continue;let a=M(t),s=r.get(a);(!s||F(t.version,s)>0)&&(r.set(a,t.version),n.set(a,o))}return n}function Or(e,n){let r=de(e,n);return r?[r]:_(e,n).filter(o=>o instanceof v)}function Ur(e){return e===!0?!0:e===!1||e===void 0||e===null?!1:typeof e=="string"?e.length>0:typeof e=="number"?e!==0:Se(e)?e.value.length>0:Array.isArray(e)?e.length>0:!!e}export{gt as AmbiguousReferenceRule,ue as BooleanStatement,Wt as CANONICAL_FORM_VERSION,I as Carrier,xt as ClassDefinitionRule,pt as ClassHierarchyCycleRule,no as CompositeKanonakDocumentRepository,Xt as DEFAULT_CONSENT_BINDING_PARAM,bo as DefinedKanonak,Ht as DiamondNameClashRule,Pt as DisplayLensScopeRule,eo as DocumentLocation,$o as EdgeType,v as EmbeddedKanonak,ct as EmbeddedKanonakTypeRule,le as EmbeddedStatement,rr as EntitlementDeniedError,ar as EntitlementProducer,Zn as FileSystemKanonakDocumentRepository,Bo as GitIgnoreFilter,Mo as GraphBuilder,mo as HttpKanonakDocumentRepository,ve as INTEGRITY_PREFIX,zt as ImportBook,ut as ImportExistenceRule,ie as InMemoryKanonakDocumentRepository,ro as KANONAK_USER_AGENT,yo as Kanonak,Go as KanonakDocumentPositions,N as KanonakObjectParser,Tt as KanonakObjectValidator,A as KanonakParser,Ro as KanonakUri,Xo as KanonakUriBuilder,Yo as KanonakUrlResolver,wo as KanonakVocabulary,It as LINE_STYLES,ot as LinkTargetRule,W as ListStatement,$ as LiteralKanonak,ko as LocalFirstRepository,ho as LockAwareRepository,At as LookBandPathRule,jt as LookRenderer,vt as LookSemanticSvgPathRule,Ct as MarkdownLinkRule,pe as MarkdownStatement,ht as NamespaceImportCycleRule,tt as NamespacePrefixRule,Ao as NodeType,ce as NumberStatement,Yt as OAuthDiscovery,To as OWL_RL_CLASSIFICATION_RULES,bt as ObjectPropertyValueValidationRule,Zo as OntologyValidationError,Jo as OntologyValidationResult,Dt as OwlOneOfRule,H as PackageBuilder,st as PackageHeaderRule,nr as ProducerRepository,Rt as PropertyDomainRule,dt as PropertyHierarchyCycleRule,Et as PropertyKindRangeConsistencyRule,Wo as PropertyMetadata,yt as PropertyRangeReferenceRule,ft as PropertyRangeRequiredRule,at as PropertyTypeSpecificityRule,lo as PublisherConfigResolver,po as PublisherIndex,Ho as RDFS_RULES,D as Reasoner,Fo as ReasoningResult,g as ReferenceKanonak,B as ReferenceStatement,to as RepositoryFactory,Kt as ReservedNameShadowRule,rt as ResourceNamingRule,xo as ResourceResolver,Vo as ResourceTypeClassifier,q as SHACL_PACKAGE,z as SHACL_PUBLISHER,X as SH_NODE_SHAPE,je as SH_PROPERTY_SHAPE,Ne as SH_SHAPE,Ko as ScalarStatement,Ut as SequenceNarrativeRule,Mt as ShaclShapeRule,Eo as Statement,se as StringStatement,mt as SubClassOfReferenceRule,kt as SubPropertyOfReferenceRule,R as SubjectKanonak,it as SubjectKanonakTypeRequiredRule,Zt as TokenCredentialProvider,Do as TripleStore,Lt as TxExpressionCompilesRule,$t as TxExpressionPathRule,Co as TypeResolver,St as UnresolvedPredicateRule,lt as UnresolvedReferenceRule,nt as ValidationCache,et as ValidationContext,Qo as ValidationSeverity,ci as VersionOperator,te as ViewMaterializer,or as allowAllPolicy,so as assertHttpsUrl,fo as assertPackageIdentity,go as buildLocalFirstRepository,Nt as buildOntologyModel,$n as buildReportPackageAsync,Q as buildShapesModel,Ft as canonicalForm,Bt as canonicalHash,he as carrierOf,So as collectKanonakFiles,F as compareVersions,Cn as computeIntegrity,Ie as computeIntegrityAsync,Gt as contentAddressedName,J as contextTypesOf,Qt as createCredentialedFetch,zn as createVersion,Un as evaluateConformance,Uo as extractMarkdownLinks,er as findDerivation,Oo as findMalformedReferences,qo as findMarkdownLinkAt,Re as foldFlagsIntoPattern,vo as formatKanonakAddress,U as formatVersion,oo as getGlobalCachePath,io as getKanonakUserAgent,Xn as isCompatibleVersion,Yn as isMajorCompatible,co as kanonakFetch,Kn as loadLockFile,ne as lowerConstraint,Lo as makeUriKey,tr as noopMeter,qt as normalizeHost,Jt as parseAuthChallenge,Po as parseKanonakAddress,Le as parseLockFile,qn as parseVersionString,zo as parseWithPositions,Qn as pickHighestDocument,No as propertiesInScope,wt as readSequenceConnectors,_t as resolveDisplayValue,jo as resolvePropertyStep,ge as sanitizeName,Jn as satisfiesVersionOperator,xn as saveLockFile,vn as scopeFromCatalog,Ln as scopeFromDocumentAsync,Pn as scopeFromRepositoryAsync,_e as serializeLockFile,uo as setKanonakFetchRetries,ao as setKanonakUserAgent,h as subjectUri,Y as superClassChain,Ot as supportedBandKeys,_o as tripleKey,M as uriKey,Io as uriTriple,Bn as versionOperatorFromChar,Wn as versionOperatorToChar,Gn as versionsEqual,Vt as walkSequence};
1
+ import{a as Do,b as Ho,c as To,d as Fo,e as D}from"./chunk-EVMSO7HJ.js";import{a as Kn,b as xn,c as Cn}from"./chunk-V3DH67P3.js";import{a as Ao,b as $o,c as Mo,d as qt,e as Xt,f as Yt,g as Jt,h as Qt,i as Zt}from"./chunk-PXS6XZ3V.js";import{a as er}from"./chunk-L2J7WD7E.js";import{a as Ft,b as Bt,c as Wt,d as H,e as Gt,f as zt,g as ge,h as nr,i as or,j as tr,k as rr,l as ar}from"./chunk-PRXC2HZ3.js";import{a as Zn,b as eo,c as no,d as oo,e as to,f as ko,g as ho,h as So,i as go}from"./chunk-IS3AQKB4.js";import{a as ro,b as ao,c as io,d as so,e as co,f as uo,h as lo,i as ve,j as Le,k as _e,l as Ie,m as po,n as mo}from"./chunk-BZ3YTI3C.js";import{a as Wo,b as Go,c as zo,d as qo}from"./chunk-BS7RRG7D.js";import{a as Xo}from"./chunk-XK24CN3C.js";import{a as fo}from"./chunk-SC5M74NM.js";import{A as Kt,B as xt,C as Ct,D as Pt,E as vt,F as Lt,G as Ut,H as At,I as $t,J as Mt,K as Dt,L as Ht,M as Tt,a as Jo,b as Qo,c as Zo,d as et,e as nt,f as ot,g as tt,h as rt,i as at,j as it,k as st,l as ct,m as ut,n as lt,o as pt,p as dt,q as ft,r as mt,s as kt,t as ht,u as St,v as gt,w as yt,x as bt,y as Rt,z as Et}from"./chunk-C63WFML4.js";import"./chunk-KIBR3HAT.js";import{c as bn,d as _t,e as It,g as wt,h as Vt,k as Nt,m as Se,o as Rn,p as En,r as jt,s as Ot}from"./chunk-HENE47QG.js";import"./chunk-QHABFCRC.js";import{a as ie}from"./chunk-6VIUXP4N.js";import{a as v,b as $,c as pe,i as I,j as he,k as Oo,l as Uo,m as N}from"./chunk-PVUBHIU2.js";import{a as A}from"./chunk-HF5FJBS2.js";import{a as Yo}from"./chunk-PEJALHXK.js";import{$ as ke,A as Ge,B as ze,C as qe,D as Xe,E as Ye,F as Je,G as Qe,H as Ze,I as en,J as nn,K as on,L as tn,M as me,N as rn,O as an,P as sn,Q as cn,R as un,S as ln,T as pn,U as dn,V as fn,W as mn,X as kn,Y as hn,Z as Sn,_ as gn,a as xo,b as Co,c as Po,d as vo,da as wo,e as M,f as Lo,fa as Vo,g as _o,ga as h,ha as Y,i as Io,j as z,k as q,l as Ne,m as X,ma as No,n as je,na as jo,o as Oe,oa as J,p as Ue,q as Ae,r as $e,s as Me,t as De,u as He,v as fe,w as Te,x as Fe,y as Be,z as We}from"./chunk-7UYXTYXC.js";import{A as de,B as _,C as yn,a as yo,b as bo,c as R,d as g,e as Eo,f as Ko,g as se,h as ce,i as ue,j as B,k as le,l as W,m as c,r as we,t as K,w as Ve,x as L,y as G,z as k}from"./chunk-CJMVIOZX.js";import{a as Ro}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{a as Bn,b as Wn,c as F,d as Gn,e as U,f as zn,g as qn,h as Xn,i as Yn,j as Jn,k as Qn}from"./chunk-QILEJIFU.js";import{a as Bo}from"./chunk-ODIECDN7.js";async function Pn(e){let n=await new N().parseKanonaks(e),r=await new D().reason(e);return{kind:"merged",catalog:n,reasoning:r}}function vn(e,n){return{kind:"merged",catalog:e,reasoning:n}}async function Ln(e,n){let r=n??new ie(new A);return{kind:"standalone",catalog:await new N().parseKanonaks(new yn(e,r))}}function j(e){return typeof e=="number"?e:void 0}function ir(e){if(!e)return;let n=c(e);if(n===c(nn))return"IRI";if(n===c(on))return"BlankNode";if(n===c(tn))return"Literal"}function _n(e){if(!e)return;let n=c(e);if(n===c(rn))return"Violation";if(n===c(an))return"Warning";if(n===c(sn))return"Info"}function ye(e,n){let r=k(e,n);if(r)return[r];let o=[];for(let t of _(e,n))t instanceof g&&o.push(t.subject);return o}function sr(e,n){let r=k(e,Ae);if(!r)return;let o={path:r},t=j(L(e,$e)),a=j(L(e,Me));t!==void 0&&(o.minCount=t),a!==void 0&&(o.maxCount=a);let s=j(L(e,Be)),i=j(L(e,We));s!==void 0&&(o.minLength=s),i!==void 0&&(o.maxLength=i);let u=j(L(e,Ge)),d=j(L(e,ze));u!==void 0&&(o.minInclusive=u),d!==void 0&&(o.maxInclusive=d);let p=G(e,Te);if(p!==void 0){let b=G(e,Fe);o.pattern=b!==void 0?{regex:p,flags:b}:{regex:p}}if(Ve(e,fe)){let b=[],w=[];for(let V of _(e,fe))V instanceof $?b.push(V.value):V instanceof g&&w.push(V.subject);b.length>0&&(o.inValues=b),w.length>0&&(o.inRefs=w)}let S=k(e,De);S&&(o.datatype=S);let y=k(e,He);y&&(o.classRef=y);let l=ir(k(e,en));l&&(o.nodeKind=l);let f=G(e,qe);f!==void 0&&(o.message=f);let m=_n(k(e,me))??n;return m&&(o.severity=m),o}function Q(e){let n=[];for(let r of e){if(!(r instanceof R)||!we(r,X))continue;let o=_n(k(r,me)),t={name:r.name,uri:h(r),targetClass:k(r,Oe),targetNodes:ye(r,Xe),targetSubjectsOf:ye(r,Ye),targetObjectsOf:ye(r,Je),closed:L(r,Qe)===!0,ignoredProperties:[],severity:o,properties:[]};for(let a of _(r,Ze))a instanceof g&&t.ignoredProperties.push(a.subject);for(let a of _(r,Ue)){let s;if(a instanceof v?s=a:a instanceof g&&(s=K(e,a.subject)),!s)continue;let i=sr(s,o);i&&t.properties.push(i)}n.push(t)}return n}var x="kanonak.org/transformations",Z="values";var ee="allowed",C=e=>({type:`${x}/VarRef`,varName:e}),be=e=>({type:`${x}/IntegerLiteral`,integerLiteral:e}),cr=e=>({type:`${x}/DecimalLiteral`,decimalLiteral:e}),In=e=>Number.isInteger(e)?be(e):cr(e),wn=e=>({type:`${x}/Count`,source:e}),Vn=(e,n)=>({type:`${x}/GreaterThanOrEqual`,compareLeft:e,compareRight:n}),Nn=(e,n)=>({type:`${x}/LessThanOrEqual`,compareLeft:e,compareRight:n});function Re(e,n){if(!n||n.length===0)return e;let r=new Set(["i","m","s"]),o=[...new Set(n.split(""))];if(o.filter(a=>!r.has(a)).length>0)throw new Error(`sh:flags '${n}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${o.sort().join("")})${e}`}function ne(e){let n=[];return e.minCount!==void 0&&n.push({component:"minCount",per:"node",expr:Vn(wn(C(Z)),be(e.minCount))}),e.maxCount!==void 0&&n.push({component:"maxCount",per:"node",expr:Nn(wn(C(Z)),be(e.maxCount))}),(e.inValues!==void 0||e.inRefs!==void 0)&&n.push({component:"in",per:"value",expr:{type:`${x}/Contains`,haystack:C(ee),needle:C("v")}}),e.pattern!==void 0&&n.push({component:"pattern",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:Re(e.pattern.regex,e.pattern.flags)}}),e.minLength!==void 0&&n.push({component:"minLength",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:`(?s)^.{${e.minLength},}$`}}),e.maxLength!==void 0&&n.push({component:"maxLength",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:`(?s)^.{0,${e.maxLength}}$`}}),e.minInclusive!==void 0&&n.push({component:"minInclusive",per:"value",expr:Vn(C("v"),In(e.minInclusive))}),e.maxInclusive!==void 0&&n.push({component:"maxInclusive",per:"value",expr:Nn(C("v"),In(e.maxInclusive))}),n}import{evaluate as lr,ExpressionError as pr}from"@kanonak-protocol/expression";function Un(e,n){let r=dr(n)?n:Q(n),o=[];for(let t of r)for(let a of fr(e,t))hr(e,t,a,o);return{conforms:!o.some(t=>t.severity==="Violation"),results:o}}function dr(e){return e.length>0&&!(e[0]instanceof Object&&"statement"in e[0])&&typeof e[0].name=="string"&&"properties"in e[0]}function oe(e){let n=e.predicate;return n instanceof g?n:void 0}function fr(e,n){let r=new Map,o=e.catalog.filter(a=>a instanceof R),t=a=>{let s=h(a);r.set(s?c(s):`${a.namespace}/${a.name}`,a)};if(n.targetClass){let a=c(n.targetClass);if(e.reasoning){let s=new Set(e.reasoning.getInstancesOfClass(n.targetClass));for(let i of o){let u=h(i);u&&s.has(c(u))&&t(i)}}else for(let s of o)J(s).some(u=>c(u)===a||Y(e.catalog,u).some(d=>c(d)===a))&&t(s)}for(let a of n.targetNodes){let s=K(e.catalog,a);s instanceof R&&t(s)}for(let a of n.targetSubjectsOf){let s=c(a);for(let i of o)i.statement.some(u=>{let d=oe(u);return d&&c(d.subject)===s})&&t(i)}for(let a of n.targetObjectsOf){let s=c(a);for(let i of o)for(let u of i.statement){let d=oe(u);if(!(!d||c(d.subject)!==s))for(let p of mr(u)){let S=K(e.catalog,p);S instanceof R&&t(S)}}}return[...r.values()]}function mr(e){return e instanceof B?[e.object.subject]:e instanceof W?(e.object??[]).filter(n=>n instanceof g).map(n=>n.subject):[]}function kr(e,n,r){let o=[];for(let t of e.statement){let a=oe(t);if(!(!a||c(a.subject)!==n)){if(t instanceof se||t instanceof pe)o.push({kernel:t.object,kind:"string",literal:t.object});else if(t instanceof ce)o.push({kernel:t.object,kind:"number",literal:t.object});else if(t instanceof ue)o.push({kernel:t.object?1:0,kind:"boolean",literal:t.object});else if(t instanceof B)o.push({kernel:{ref:c(t.object.subject)},kind:"reference",ref:t.object.subject});else if(t instanceof le)o.push(jn(t.object,r,o.length));else if(t instanceof W){for(let s of t.object??[])if(s instanceof g)o.push({kernel:{ref:c(s.subject)},kind:"reference",ref:s.subject});else if(s instanceof v)o.push(jn(s,r,o.length));else if(s instanceof $){let i=s.value;typeof i=="boolean"?o.push({kernel:i?1:0,kind:"boolean",literal:i}):o.push({kernel:i,kind:typeof i=="number"?"number":"string",literal:i})}}}}return o}function jn(e,n,r){let o=e.name&&e.name.length>0?e.name:String(r);return{kernel:{ref:`${n}#${o}`},kind:"embedded"}}function hr(e,n,r,o){let t=h(r),a=t?c(t):`${r.namespace}/${r.name}`;for(let s of n.properties)gr(e,n,r,a,t,s,o);n.closed&&Kr(n,r,a,t,o)}function Ee(e,n,r,o,t,a={},s){return{focusNode:n,focusUri:r,constraintComponent:o,severity:s??An(e),message:t,sourceShape:e.name,sourceShapeUri:e.uri,...a}}function An(e){return e.severity??"Violation"}var Sr={minCount:cn,maxCount:un,in:dn,pattern:fn,minLength:mn,maxLength:kn,minInclusive:hn,maxInclusive:Sn};function gr(e,n,r,o,t,a,s){let i=c(a.path),u=kr(r,i,o),d=a.severity??An(n),p=a.path.name,S=[...(a.inValues??[]).map(l=>typeof l=="boolean"?l?1:0:l),...(a.inRefs??[]).map(l=>({ref:c(l)}))],y=(l,f,m)=>{s.push(Ee(n,o,t,l,a.message??f,{resultPath:a.path,value:m?.literal,valueRef:m?.ref},d))};for(let l of ne(a)){let f=Sr[l.component];if(l.per==="node"){On(l,{[Z]:u.map(b=>b.kernel),[ee]:S})||y(f,l.component==="minCount"?`'${p}' has ${u.length} value(s); minCount is ${a.minCount}.`:`'${p}' has ${u.length} value(s); maxCount is ${a.maxCount}.`);continue}for(let m of u){if((l.component==="pattern"||l.component==="minLength"||l.component==="maxLength")&&m.kind!=="string"){y(f,`'${p}' value is not a string; ${l.component} applies to string values.`,m);continue}On(l,{v:m.kernel,[ee]:S})||y(f,yr(l,p,a,m),m)}}if(a.nodeKind)for(let l of u)br(a.nodeKind,l)||y(gn,`'${p}' value is ${l.kind}; nodeKind requires ${a.nodeKind}.`,l);if(a.datatype)for(let l of u){let f=Rr(a.datatype,l);f&&y(ln,`'${p}' ${f}`,l)}if(a.classRef)for(let l of u){let f=Er(e,a.classRef,l);f&&y(pn,`'${p}' ${f}`,l)}}function yr(e,n,r,o){let t=o.ref?c(o.ref):JSON.stringify(o.literal);switch(e.component){case"in":return`'${n}' value ${t} is not in the permitted set.`;case"pattern":return`'${n}' value ${t} does not match pattern ${r.pattern?.regex}.`;case"minLength":return`'${n}' value ${t} is shorter than minLength ${r.minLength}.`;case"maxLength":return`'${n}' value ${t} is longer than maxLength ${r.maxLength}.`;case"minInclusive":return`'${n}' value ${t} is below minInclusive ${r.minInclusive} (or not numeric).`;case"maxInclusive":return`'${n}' value ${t} is above maxInclusive ${r.maxInclusive} (or not numeric).`;default:return`'${n}' value ${t} violates ${e.component}.`}}function On(e,n){let r=o=>{let t=o.varName;if(o.type==="kanonak.org/transformations/VarRef"&&typeof t=="string"&&t in n)return n[t];throw new pr(`Conformance lowering produced an unexpected leaf '${o.type}'`)};return lr(e.expr,void 0,r)===1}function br(e,n){switch(e){case"IRI":return n.kind==="reference";case"BlankNode":return n.kind==="embedded";case"Literal":return n.kind==="string"||n.kind==="number"||n.kind==="boolean"}}function Rr(e,n){if(n.kind==="reference"||n.kind==="embedded")return`value is a ${n.kind}; sh:datatype requires a literal of ${e.name}.`;let r=he(e);if(r!==void 0)switch(r){case I.Boolean:return n.kind==="boolean"?void 0:`value is not a boolean (${e.name}).`;case I.Integer:return n.kind!=="number"?`value is not a number (${e.name}).`:Number.isInteger(n.literal)?void 0:`value is not an integer (${e.name}).`;case I.Decimal:case I.Double:case I.Float:return n.kind==="number"?void 0:`value is not a number (${e.name}).`;default:return n.kind==="string"?void 0:`value is not a string-carried literal (${e.name}).`}}function Er(e,n,r){if(r.kind!=="reference"||!r.ref)return`value is not a reference; sh:class requires an instance of ${n.name}.`;let o=c(n);if(e.reasoning)return e.reasoning.isInstanceOf(r.ref,n)?void 0:`value ${c(r.ref)} is not an instance of ${n.name}.`;let t=K(e.catalog,r.ref);return t instanceof R?J(t).some(s=>c(s)===o||Y(e.catalog,s).some(i=>c(i)===o))?void 0:`value ${c(r.ref)} is not an instance of ${n.name}.`:`value ${c(r.ref)} does not resolve in this scope (sh:class ${n.name}).`}function Kr(e,n,r,o,t){let a=new Set([...e.properties.map(i=>c(i.path)),...e.ignoredProperties.map(i=>c(i))]),s=new Set;for(let i of n.statement){let u=oe(i);if(!u)continue;let d=c(u.subject);a.has(d)||s.has(d)||(s.add(d),t.push(Ee(e,r,o,ke,`'${n.name}' carries undeclared property '${u.subject.name}' (closed shape).`,{resultPath:u.subject})))}for(let i of n.unresolvedPredicates)s.has(i.key)||(s.add(i.key),t.push(Ee(e,r,o,ke,`'${n.name}' carries unresolvable property '${i.key}' (closed shape).`,{value:i.key})))}var xr="1.1.0";async function $n(e){let n=new H(e.repository),r=n.imports(),o=r.ensure(z,q,xr,"sh"),t=(i,u)=>i&&i.version&&typeof i.version.major=="number"?`${r.ensure(i.publisher,i.package_,U(i.version),i.package_)}.${i.name}`:u,a={},s=[];return e.result.results.forEach((i,u)=>{let d=`result-${u+1}`;s.push(d);let p={type:`${o}.ValidationResult`,[`${o}.focusNode`]:t(i.focusUri,i.focusNode),[`${o}.resultMessage`]:i.message,[`${o}.resultSeverity`]:`${o}.${i.severity}`,[`${o}.sourceConstraintComponent`]:`${o}.${i.constraintComponent.name}`};i.resultPath&&(p[`${o}.resultPath`]=t(i.resultPath,c(i.resultPath))),i.sourceShapeUri&&(p[`${o}.sourceShape`]=t(i.sourceShapeUri,i.sourceShape)),i.valueRef?p[`${o}.value`]=t(i.valueRef,c(i.valueRef)):i.value!==void 0&&(p[`${o}.value`]=i.value),a[d]=p}),a.report={type:`${o}.ValidationReport`,[`${o}.conforms`]:e.result.conforms,...s.length>0?{[`${o}.result`]:s}:{}},n.buildContentAddressed({publisher:e.publisher,book:r,body:a,...e.header!==void 0?{header:e.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as ci}from"@kanonak-protocol/types/document/models/enums";var E="kanonak.org",P="view",Mn="core-kanonak",Cr={publisher:E,package_:P,name:"rootView"},Pr={publisher:E,package_:P,name:"bind"},vr={publisher:E,package_:P,name:"produces"},Lr={publisher:E,package_:P,name:"projections"},_r={publisher:E,package_:P,name:"where"},Ir={publisher:E,package_:P,name:"value"},wr={publisher:E,package_:P,name:"as"},te=class{constructor(n,r=new A){this.repository=n;this.parser=r;this.objectParser=new N(this.parser),this.builder=new H(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(n,r={}){let o=await this.objectParser.parseKanonaks(this.repository),t=this.resolveView(o,n),a=k(t,Pr);if(!a)throw new Error(`View ${t.namespace}/${t.name} declares no view.bind; cannot materialize.`);let s=k(t,vr);if(!s)throw new Error(`View ${t.namespace}/${t.name} is a selection view (no view.produces). In-graph materialization of selection views is not yet supported \u2014 declare a view.produces output class to reshape the result.`);let i=Vr(t),u=Dn(o,E,Mn),d=Dn(o,E,P),p=this.builder.imports(),S=p.ensure(E,Mn,u,"ck"),y=p.ensure(E,P,d,"v"),l=p.ref(s),f=new En(this.repository,this.parser,this.objectParser),m=new Rn(f,o),b=this.readProjections(o,t),w=Or(t,_r),V=this.findInstances(o,a,await this.reason(r)),Ke={},Tn=new Set;for(let T of V){if(!await this.passesWhere(m,o,w,T))continue;let ae={type:l};for(let Ce of b){let Fn=await this.evaluateValue(m,o,Ce.value,T),Pe=this.builder.serializeValue(Hn(Fn),p);Pe!==void 0&&(ae[p.ref(Ce.as)]=Pe)}let xe=h(T);xe&&(ae[`${y}.derivedFrom`]=p.ref(xe)),Ke[this.rowName(T,Tn)]=ae}let re={};r.resolvedAt&&(re[`${S}.resolvedAt`]=r.resolvedAt),r.invocationId&&(re[`${S}.id`]=r.invocationId);let O=await this.builder.buildContentAddressed({publisher:i,book:p,body:Ke,contentHashProperty:`${S}.contentHash`,header:re});return{yaml:O.yaml,contentHash:O.contentHash,packageName:O.packageName,publisher:O.publisher,rowCount:O.resourceCount}}resolveView(n,r){let o=K(n,r);if(!o)throw new Error(`View ${r.publisher}/${r.package_}/${r.name} not found in the catalog.`);let t=k(o,Cr);if(t){let a=K(n,t);if(!a)throw new Error(`ViewPackage ${r.name} names rootView ${t.name}, which is not in the catalog.`);return a}return o}readProjections(n,r){let o=[];for(let t of _(r,Lr)){let a=t instanceof v?t:t instanceof g?K(n,t.subject):void 0;if(!a)continue;let s=de(a,Ir),i=k(a,wr);s&&i&&o.push({value:s,as:i})}return o}async reason(n){return new D({profile:n.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(n,r,o){let t=jr(n),a=[],s=new Set;for(let i of o.getInstancesOfClass(r)){if(s.has(i))continue;s.add(i);let u=t.get(i);u&&a.push(u)}return a.sort((i,u)=>{let d=M(h(i)),p=M(h(u));return d<p?-1:d>p?1:0}),a}async passesWhere(n,r,o,t){for(let a of o){let s=await this.evaluateValue(n,r,a,t);if(!Ur(s))return!1}return!0}async evaluateValue(n,r,o,t){let a=bn(o,"view-projection",{catalog:r,depth:0}),s=new Map([["input",t]]);return n.evaluate(a,s)}rowName(n,r){let o=ge(n.name)||"row",t=o,a=2;for(;r.has(t);)t=`${o}-${a++}`;return r.add(t),t}};function Hn(e){return Se(e)?e.value:Array.isArray(e)?e.map(Hn):e}function Vr(e){let n=h(e);if(!n)throw new Error(`Could not derive a publisher from view ${e.namespace}/${e.name}.`);return n.publisher}function Dn(e,n,r){let o=Nr(e,n,r);if(!o)throw new Error(`Package ${n}/${r} is not in the catalog; it must be importable to materialize a view.`);return o}function Nr(e,n,r){let o;for(let t of e){if(!(t instanceof R))continue;let a=h(t);!a||a.publisher!==n||a.package_!==r||!a.version||(!o||F(a.version,o)>0)&&(o=a.version)}return o?U(o):void 0}function jr(e){let n=new Map,r=new Map;for(let o of e){if(!(o instanceof R))continue;let t=h(o);if(!t||!t.version)continue;let a=M(t),s=r.get(a);(!s||F(t.version,s)>0)&&(r.set(a,t.version),n.set(a,o))}return n}function Or(e,n){let r=de(e,n);return r?[r]:_(e,n).filter(o=>o instanceof v)}function Ur(e){return e===!0?!0:e===!1||e===void 0||e===null?!1:typeof e=="string"?e.length>0:typeof e=="number"?e!==0:Se(e)?e.value.length>0:Array.isArray(e)?e.length>0:!!e}export{gt as AmbiguousReferenceRule,ue as BooleanStatement,Wt as CANONICAL_FORM_VERSION,I as Carrier,xt as ClassDefinitionRule,pt as ClassHierarchyCycleRule,no as CompositeKanonakDocumentRepository,Xt as DEFAULT_CONSENT_BINDING_PARAM,bo as DefinedKanonak,Ht as DiamondNameClashRule,Pt as DisplayLensScopeRule,eo as DocumentLocation,$o as EdgeType,v as EmbeddedKanonak,ct as EmbeddedKanonakTypeRule,le as EmbeddedStatement,rr as EntitlementDeniedError,ar as EntitlementProducer,Zn as FileSystemKanonakDocumentRepository,Bo as GitIgnoreFilter,Mo as GraphBuilder,mo as HttpKanonakDocumentRepository,ve as INTEGRITY_PREFIX,zt as ImportBook,ut as ImportExistenceRule,ie as InMemoryKanonakDocumentRepository,ro as KANONAK_USER_AGENT,yo as Kanonak,Go as KanonakDocumentPositions,N as KanonakObjectParser,Tt as KanonakObjectValidator,A as KanonakParser,Ro as KanonakUri,Xo as KanonakUriBuilder,Yo as KanonakUrlResolver,wo as KanonakVocabulary,It as LINE_STYLES,ot as LinkTargetRule,W as ListStatement,$ as LiteralKanonak,ko as LocalFirstRepository,ho as LockAwareRepository,At as LookBandPathRule,jt as LookRenderer,vt as LookSemanticSvgPathRule,Ct as MarkdownLinkRule,pe as MarkdownStatement,ht as NamespaceImportCycleRule,tt as NamespacePrefixRule,Ao as NodeType,ce as NumberStatement,Yt as OAuthDiscovery,To as OWL_RL_CLASSIFICATION_RULES,bt as ObjectPropertyValueValidationRule,Zo as OntologyValidationError,Jo as OntologyValidationResult,Dt as OwlOneOfRule,H as PackageBuilder,st as PackageHeaderRule,nr as ProducerRepository,Rt as PropertyDomainRule,dt as PropertyHierarchyCycleRule,Et as PropertyKindRangeConsistencyRule,Wo as PropertyMetadata,yt as PropertyRangeReferenceRule,ft as PropertyRangeRequiredRule,at as PropertyTypeSpecificityRule,lo as PublisherConfigResolver,po as PublisherIndex,Ho as RDFS_RULES,D as Reasoner,Fo as ReasoningResult,g as ReferenceKanonak,B as ReferenceStatement,to as RepositoryFactory,Kt as ReservedNameShadowRule,rt as ResourceNamingRule,xo as ResourceResolver,Vo as ResourceTypeClassifier,q as SHACL_PACKAGE,z as SHACL_PUBLISHER,X as SH_NODE_SHAPE,je as SH_PROPERTY_SHAPE,Ne as SH_SHAPE,Ko as ScalarStatement,Ut as SequenceNarrativeRule,Mt as ShaclShapeRule,Eo as Statement,se as StringStatement,mt as SubClassOfReferenceRule,kt as SubPropertyOfReferenceRule,R as SubjectKanonak,it as SubjectKanonakTypeRequiredRule,Zt as TokenCredentialProvider,Do as TripleStore,Lt as TxExpressionCompilesRule,$t as TxExpressionPathRule,Co as TypeResolver,St as UnresolvedPredicateRule,lt as UnresolvedReferenceRule,nt as ValidationCache,et as ValidationContext,Qo as ValidationSeverity,ci as VersionOperator,te as ViewMaterializer,or as allowAllPolicy,so as assertHttpsUrl,fo as assertPackageIdentity,go as buildLocalFirstRepository,Nt as buildOntologyModel,$n as buildReportPackageAsync,Q as buildShapesModel,Ft as canonicalForm,Bt as canonicalHash,he as carrierOf,So as collectKanonakFiles,F as compareVersions,Cn as computeIntegrity,Ie as computeIntegrityAsync,Gt as contentAddressedName,J as contextTypesOf,Qt as createCredentialedFetch,zn as createVersion,Un as evaluateConformance,Uo as extractMarkdownLinks,er as findDerivation,Oo as findMalformedReferences,qo as findMarkdownLinkAt,Re as foldFlagsIntoPattern,vo as formatKanonakAddress,U as formatVersion,oo as getGlobalCachePath,io as getKanonakUserAgent,Xn as isCompatibleVersion,Yn as isMajorCompatible,co as kanonakFetch,Kn as loadLockFile,ne as lowerConstraint,Lo as makeUriKey,tr as noopMeter,qt as normalizeHost,Jt as parseAuthChallenge,Po as parseKanonakAddress,Le as parseLockFile,qn as parseVersionString,zo as parseWithPositions,Qn as pickHighestDocument,No as propertiesInScope,wt as readSequenceConnectors,_t as resolveDisplayValue,jo as resolvePropertyStep,ge as sanitizeName,Jn as satisfiesVersionOperator,xn as saveLockFile,vn as scopeFromCatalog,Ln as scopeFromDocumentAsync,Pn as scopeFromRepositoryAsync,_e as serializeLockFile,uo as setKanonakFetchRetries,ao as setKanonakUserAgent,h as subjectUri,Y as superClassChain,Ot as supportedBandKeys,_o as tripleKey,M as uriKey,Io as uriTriple,Bn as versionOperatorFromChar,Wn as versionOperatorToChar,Gn as versionsEqual,Vt as walkSequence};
@@ -148,5 +148,17 @@ export declare function propertiesFor(catalog: Kanonak[], classUri: KanonakUri,
148
148
  *
149
149
  * Built entirely on the parsed object model — no `rdf:type` string matching,
150
150
  * no alias assumptions, no heuristics.
151
+ *
152
+ * One parse for many models (typescript#121). The second argument is either
153
+ * the repository — parsed into a catalog on this call — or a catalog the
154
+ * caller already parsed with `KanonakObjectParser.parseKanonaks`. A caller
155
+ * that needs models for several documents of one closure, or both the
156
+ * declared-only and the inherited view of a package, parses once and passes
157
+ * the catalog to every call: the parse, the SHACL constraint index and the
158
+ * property-class memo are then shared instead of rebuilt per call. The
159
+ * catalog form takes no repository, so there is no second source to disagree
160
+ * with it; the document must be one the catalog was parsed from, and a
161
+ * document whose package the catalog does not hold is an error rather than
162
+ * an empty model.
151
163
  */
152
- export declare function buildOntologyModel(doc: KanonakDocument, repo: IKanonakDocumentRepository, opts?: BuildOntologyModelOptions): Promise<OntologyModel>;
164
+ export declare function buildOntologyModel(doc: KanonakDocument, source: IKanonakDocumentRepository | Kanonak[], opts?: BuildOntologyModelOptions): Promise<OntologyModel>;
@@ -38,6 +38,19 @@ export type ShaclConstraintIndex = Map<string, ShapeForProperty[]>;
38
38
  * (`sh:path`) with the normalized constraints of its PropertyShape.
39
39
  */
40
40
  export declare function buildShaclConstraintIndex(catalog: Kanonak[]): ShaclConstraintIndex;
41
+ /**
42
+ * The constraint index of a catalog, built once per catalog. Every caller that
43
+ * holds a parsed catalog goes through here rather than calling
44
+ * {@link buildShaclConstraintIndex} directly: a batch validation asks for the
45
+ * index once per document over the same shared catalog, a site render once per
46
+ * entity-relationship band, and a generator once per model it builds.
47
+ *
48
+ * Keyed on the catalog array's identity, like the property-class memo in
49
+ * `TypeDirectedResolver`: a parse produces one array and nothing mutates it
50
+ * afterwards, so an entry can never outlive the catalog it describes. The
51
+ * index is read-only to its consumers.
52
+ */
53
+ export declare function shaclConstraintIndexFor(catalog: Kanonak[]): ShaclConstraintIndex;
41
54
  /**
42
55
  * The effective constraints on a property for a class: the merge of every
43
56
  * matching PropertyShape along the class's `subClassOf` chain, with shapes on
@@ -1,4 +1,4 @@
1
- import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{d as g}from"../chunk-DD3TCFBT.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import"../chunk-PVUBHIU2.js";import"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import{ga as m,oa as S}from"../chunk-7UYXTYXC.js";import{c as v,m as p,t as E}from"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as x}from"../chunk-QILEJIFU.js";import{homedir as P}from"os";import{join as d}from"path";import{existsSync as M,mkdirSync as D,readFileSync as j,writeFileSync as O}from"fs";import{createHash as C}from"crypto";import{pathToFileURL as B}from"url";var h="Xenova/all-MiniLM-L6-v2",w="q8",b=32;async function F(r){let{pipeline:e,env:t}=r.transformers;t.cacheDir=r.modelCacheDir??d(P(),".kanonak","models");let n=await e("feature-extraction",h,{dtype:w});return async s=>(await n(s,{pooling:"mean",normalize:!0})).tolist()}async function z(r){let e=d(r,"node_modules","@huggingface","transformers"),t=JSON.parse(j(d(e,"package.json"),"utf-8")),n=I(t);if(!n)throw new Error(`@huggingface/transformers at ${e} exposes no resolvable ESM entry.`);let s=await import(B(d(e,n)).href);return typeof s.pipeline=="function"?s:s.default}function I(r){let e=r.exports,t=n=>typeof n=="string"?n:n?.default;return typeof e=="string"?e:t(e?.node?.import)??t(e?.import)??t(e?.default)??r.module??r.main}var y=null;async function U(){return y||(y=(async()=>{let r;try{r=await import("@huggingface/transformers")}catch(e){throw new Error(`Semantic search requires the embedding runtime, which is an optional dependency.
1
+ import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{d as g}from"../chunk-HENE47QG.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import"../chunk-PVUBHIU2.js";import"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import{ga as m,oa as S}from"../chunk-7UYXTYXC.js";import{c as v,m as p,t as E}from"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as x}from"../chunk-QILEJIFU.js";import{homedir as P}from"os";import{join as d}from"path";import{existsSync as M,mkdirSync as D,readFileSync as j,writeFileSync as O}from"fs";import{createHash as C}from"crypto";import{pathToFileURL as B}from"url";var h="Xenova/all-MiniLM-L6-v2",w="q8",b=32;async function F(r){let{pipeline:e,env:t}=r.transformers;t.cacheDir=r.modelCacheDir??d(P(),".kanonak","models");let n=await e("feature-extraction",h,{dtype:w});return async s=>(await n(s,{pooling:"mean",normalize:!0})).tolist()}async function z(r){let e=d(r,"node_modules","@huggingface","transformers"),t=JSON.parse(j(d(e,"package.json"),"utf-8")),n=I(t);if(!n)throw new Error(`@huggingface/transformers at ${e} exposes no resolvable ESM entry.`);let s=await import(B(d(e,n)).href);return typeof s.pipeline=="function"?s:s.default}function I(r){let e=r.exports,t=n=>typeof n=="string"?n:n?.default;return typeof e=="string"?e:t(e?.node?.import)??t(e?.import)??t(e?.default)??r.module??r.main}var y=null;async function U(){return y||(y=(async()=>{let r;try{r=await import("@huggingface/transformers")}catch(e){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: ${e.message})`)}return F({transformers:r})})()),y}function H(r,e){let t=0;for(let n=0;n<r.length;n++)t+=r[n]*e[n];return t}function R(r,e){return e?r.version?e.version?x(r.version,e.version)>0:!0:!1:!0}function K(r,e){let t=g(r,e),n=[t.label],s=S(e);if(s.length>0){let i=E(r,s[0]),a=i?g(r,i).label:s[0].name;a&&n.push(`\u2014 a ${a}.`)}return t.summary&&n.push(t.summary),n.join(" ")}function q(r){let e=new Map;for(let t of r){if(!(t instanceof v))continue;let n=m(t);if(!n)continue;let s=p(n),i=e.get(s);(!i||R(n,m(i)))&&e.set(s,t)}return[...e.values()].sort((t,n)=>{let s=m(t)?p(m(t)):t.name,i=m(n)?p(m(n)):n.name;return s.localeCompare(i)})}var k=class{entries=[];embedder;constructor(e={}){this.embedder=e.embedder}resolveEmbedder(){return this.embedder?Promise.resolve(this.embedder):U()}get size(){return this.entries.length}async build(e,t={}){let n=q(e);if(t.include&&(n=n.filter(t.include)),n.length===0)return this.entries=[],{size:0,cached:!1};let s=n.map(o=>K(e,o)),i=t.cacheDir,a;if(i){let o=C("sha256").update(h+"|"+w+`
@@ -1,4 +1,4 @@
1
- import{c as Pe}from"../chunk-V3DH67P3.js";import{a as be,d as X,f as Se,h as ee}from"../chunk-IS3AQKB4.js";import{e as ve,g as $e,m as U,n as Z}from"../chunk-BZ3YTI3C.js";import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{a as H,b as G}from"../chunk-KIBR3HAT.js";import{r as te}from"../chunk-DD3TCFBT.js";import"../chunk-QHABFCRC.js";import{a as ye}from"../chunk-6VIUXP4N.js";import{m as oe}from"../chunk-PVUBHIU2.js";import{a as O}from"../chunk-HF5FJBS2.js";import{a as xe}from"../chunk-PEJALHXK.js";import{c as Re}from"../chunk-7UYXTYXC.js";import{c as we,u as re}from"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as V,e as E,f as W,g as ke}from"../chunk-QILEJIFU.js";import{readFileSync as de,writeFileSync as Ie,mkdirSync as Me}from"fs";import{join as se}from"path";import Fe from"js-yaml";var _e=[{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 q(o){return _e}function C(o){return`${o.publisher}/${o.package_}`}function z(o,e=[]){let c={"kanonak.org/look-styles":"pages render UNSTYLED \u2014 generated CSS stops at the :root token block","kanonak.org/look-tokens":"the :root block loses the universal design-token floor (colors, fonts, spacing)","kanonak.org/universal-look":"resources without their own look render as an empty HTML comment","kanonak.org/look":"band vocabulary (Hero, PropertyList, \u2026) is unresolvable \u2014 declared looks cannot render","kanonak.org/site":"the site vocabulary (content, navigation) is unresolvable \u2014 the base stylesheet cannot bind","kanonak.org/core-kanonak":"the Package/Publisher classes are unresolvable \u2014 package and publisher pages degrade","kanonak.org/link":"link vocabulary is unresolvable \u2014 cross-reference styling degrades"},r=[];for(let t of o)if(t.origin==="missing"){let a=C(t),u=c[a]??"whatever this package contributes to rendering is lost";r.push(`Render-stack package ${a} is MISSING (${t.reason??"unknown reason"}) \u2014 ${u}. Fix: kanonak install ${a} (as the user running the render), or restore network access to ${t.publisher}.`)}else t.resolvedButNotInCatalog&&r.push(`Render-stack package ${C(t)} resolved (${t.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);for(let t of e)r.push(`Import edge ${t.fromNamespace} \u2192 ${t.publisher}/${t.packageName} ${t.constraint} did NOT resolve (${t.reason==="no-compatible-version"?"no compatible version in the repository":"resolution threw"}) \u2014 every statement ${t.fromNamespace} authors against ${t.publisher}/${t.packageName} entities is dropped from the parse as an unresolved predicate (a look declaration loses its bands and pages render empty; see typescript#91). Fix: add a ${t.constraint}-compatible version of ${t.publisher}/${t.packageName} to the workspace or cache (kanonak install ${t.publisher}/${t.packageName}), or bump the import in ${t.fromNamespace}.`);return r}function ne(o){let{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,renderStack:d,producers:k,lockSource:y,configSource:s}=o,l=new Map,f=new Map,p=new Map,m=new Set;for(let S of r){if(!(S instanceof we))continue;let w=S.namespace||"";if(!a.has(w))continue;l.set(`${w}/${S.name}`,S);let P=w.split("/")[1]??"",[_,F]=P.split("@");if(!_||!F)continue;let D=ke(F);D&&(m.has(P)||(m.add(P),f.has(_)||f.set(_,[]),f.get(_).push({verStr:F,version:D})),S.name===_&&p.set(P,S))}for(let S of f.values())S.sort((w,P)=>V(P.version,w.version));return{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,bySubject:l,pkgVersions:f,pkgSelfByVer:p,renderStack:d,...k?{producers:k}:{},...y?{lockSource:y}:{},...s?{configSource:s}:{}}}async function pe(o,e={}){let c=new O,r=new ye(c),t=[],a=[];for(let i of ee(o)){let h;try{h=de(i,"utf-8")}catch{continue}let n;try{n=c.parse(h).metadata?.namespace_}catch{continue}if(!n?.version)continue;let g=n.version;a.push({publisher:n.publisher,package_:n.package_,verStr:E(g),version:g,source:h})}a.sort((i,h)=>V(h.version,i.version));for(let i of a)await r.saveDocumentAsync(c.parse(i.source),`${i.publisher}/${i.package_}@${i.verStr}`),t.push({publisher:i.publisher,package_:i.package_,verStr:i.verStr,source:i.source});let u=[...new Set(t.map(i=>i.publisher))].sort(),d=e.publisher;if(d){if(!u.includes(d))throw new Error(`Publisher "${d}" not found in workspace. Available: ${u.join(", ")||"(none)"}`)}else if(u.length===1)d=u[0];else throw u.length===0?new Error(`No Kanonak packages found under ${o}`):new Error(`Workspace has multiple publishers (${u.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let k=new Set,y=new Map;for(let i of t)i.publisher===d&&(k.add(`${i.publisher}/${i.package_}@${i.verStr}`),y.set(`${i.package_}@${i.verStr}`,i.source));let s=X(),l=new be(s,!0,c),f={};e.httpCache&&(f.getFromCache=e.httpCache.getFromCache,f.onFetch=e.httpCache.onFetch),e.fetchFn&&(f.fetchFn=e.fetchFn);let p=e.repository??new Se(r,l,new Z(f)),m=e.log??(()=>{}),S=q(void 0),w=[],P=i=>i.map(h=>h.metadata.namespace_?.version).filter(h=>h!==void 0).sort((h,n)=>V(n,h)).map(E);if(!e.repository){m(`[render-stack] resolving ${S.length} ambient look-stack package(s); cache: ${s}`);let i=e.fetchFn?new U({fetchFn:e.fetchFn}):new U;for(let h of S){let n=C(h),g=await r.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(g.length>0){let v=P(g);w.push({...h,origin:"workspace",versions:v}),m(`[render-stack] ${n} \u2014 workspace (${v.join(", ")})`);continue}let b=await l.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(b.length>0){let v=P(b);w.push({...h,origin:"cache",versions:v}),m(`[render-stack] ${n} \u2014 cache (${v.join(", ")})`);continue}try{let $=(await i.getLock(h.publisher))?.packages[`${h.publisher}/${h.package_}`];if(!$){let j=`publisher ${h.publisher} reachable but its lock does not pin ${h.package_}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let I=$.version,T=$.resolved,Q=await(e.fetchFn?e.fetchFn(T,h.publisher):ve(T));if(!Q.ok){let j=`fetch ${T} failed: HTTP ${Q.status} ${Q.statusText}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let fe=await Q.text();await r.saveDocumentAsync(c.parse(fe),`${h.publisher}/${h.package_}@${I}`);try{let j=se(s,h.publisher);Me(j,{recursive:!0}),Ie(se(j,`${h.package_}@${I}.kan.yml`),fe,"utf-8"),w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, installed to cache`)}catch(j){w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, but cache ${s} is NOT WRITABLE (${j.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(v){let $=`fetch failed: ${v.message}`;w.push({...h,origin:"missing",reason:$}),m(`[render-stack] ${n} \u2014 MISSING: ${$}`)}}}let _=(await r.getAllDocumentsAsync()).filter(i=>i.metadata.namespace_?.publisher===d);for(let i of S)_.push(...await p.getDocumentsByNamespaceAsync(i.publisher,i.package_));let F=[],D=await H(_,p,{onUnresolvedEdge:i=>F.push(i)}),A=p;if(!e.repository){for(let i of S)D.add(C(i));A=new G(p,D)}let B=await new oe(c).parseKanonaks(A),ce=new te(B),le=(i,h)=>re(B,{publisher:i,package_:h,name:h}).length>0,N;if(e.repository){N=[];for(let i of S){let h=await p.getDocumentsByNamespaceAsync(i.publisher,i.package_);N.push(h.length>0?{...i,origin:"repository",versions:P(h)}:{...i,origin:"missing",reason:"not present in the caller-supplied repository"})}}else N=w.map(i=>i.origin==="missing"||le(i.publisher,i.package_)?i:{...i,resolvedButNotInCatalog:!0});let Y=z(N,F);for(let i of Y)m(`[render-stack] WARNING: ${i}`);let J={contractSource:"universal-default",cachePath:s,packages:N,warnings:Y},K;try{K=de(se(o,"kanonak.lock"),"utf-8")}catch{K=De(d,t,c)}let L;try{L=de(se(o,".well-known","kanonak.json"),"utf-8")}catch{L=void 0}return ne({publisher:d,availablePublishers:u,catalog:B,lookRenderer:ce,localNamespaces:k,rawByNsKey:y,renderStack:J,...K?{lockSource:K}:{},...L?{configSource:L}:{}})}function De(o,e,c){let r=new Map;for(let a of e)a.publisher===o&&(r.has(a.package_)||r.set(a.package_,{verStr:a.verStr,source:a.source}));if(r.size===0)return;let t={};for(let a of[...r.keys()].sort()){let{verStr:u,source:d}=r.get(a),k={},y;try{y=c.parse(d).metadata?.imports}catch{y=void 0}for(let l of y?.[o]??[]){let f=r.get(l.packageName);f&&(k[`${o}/${l.packageName}`]=f.verStr)}let s={};for(let l of Object.keys(k).sort())s[l]=k[l];t[`${o}/${a}`]={version:u,resolved:`https://${o}/${a}/${u}.kan.yml`,integrity:Pe(d),dependencies:s}}return Fe.dump({version:"1",lastUpdated:"",packages:t},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as Ee,readFileSync as Ke,writeFileSync as Ve,mkdirSync as Ae}from"fs";import{join as je}from"path";async function ue(o,e={}){let c=new O,r=Re(o),t=r.kind==="resource"?r.uri.publisher:r.publisher,a=e.log??(()=>{}),u=e.cacheRoot??X(),d=(n,g,b)=>je(u,n,`${g}@${b}.kan.yml`),k=new Set,y=new Set,s=new Map,l=new Z({getFromCache:(n,g,b)=>{let v=d(n,g,b),$=Ee(v)?Ke(v,"utf-8"):null;return $!==null&&k.add(`${n}/${g}`),$},onFetch:(n,g,b,v)=>{y.add(`${n}/${g}`);try{let $=je(u,n);Ae($,{recursive:!0}),Ve(d(n,g,b),v,"utf-8")}catch($){s.set(`${n}/${g}`,$.message),a(`[render] fetched ${n}/${g}@${b} but cache ${u} is NOT WRITABLE (${$.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),f=new U(e.fetchFn?{fetchFn:e.fetchFn}:void 0),p;if(r.kind==="resource"){let n=r.uri.version;p=[n?{package_:r.uri.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let n=r.version;p=[n?{package_:r.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.package_}]}else p=((await f.getConfig(t)).featured_packages??[]).map(g=>({package_:g}));let m=async(n,g,b)=>{try{let v=b?c.buildImport(g,"=",b,n):c.buildImport(g,"*","0.0.0",n),$=await l.getHighestCompatibleVersionAsync(n,v);return $?{doc:$}:{doc:null,error:`${n} did not resolve ${g}${b?`@${b}`:""} (not in its index, or unreachable)`}}catch(v){return{doc:null,error:v.message}}},S=[],w=[];for(let n of p){let{doc:g,error:b}=await m(t,n.package_,n.version);g?S.push(g):b&&w.push(b)}if(S.length===0)throw new Error(`Could not fetch any package for address "${o}" from publisher "${t}".`+(w.length>0?` Reasons: ${w.join("; ")}`:""));let P=q(),_="universal-default",F=n=>n.map(g=>g.metadata.namespace_?.version).filter(g=>g!==void 0).sort((g,b)=>V(b,g)).map(E);a(`[render-stack] resolving ${P.length} ambient look-stack package(s) (contract: ${_}); cache: ${u}`);let D=[],A=[];for(let n of P){let g=C(n),{doc:b,error:v}=await m(n.publisher,n.package_,void 0);if(b){D.push(b);let $=F([b]),I=y.has(g)?"fetched":k.has(g)?"cache":"fetched";A.push({...n,origin:I,versions:$}),a(`[render-stack] ${g} \u2014 ${I} (${$.join(", ")})`+(s.has(g)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else A.push({...n,origin:"missing",reason:v??"unresolved"}),a(`[render-stack] ${g} \u2014 MISSING: ${v??"unresolved"}`)}let B=[],ce=await H([...S,...D],l,{onUnresolvedEdge:n=>B.push(n)}),le=new G(l,ce),N=await new oe(c).parseKanonaks(le),Y=new te(N),J=A.map(n=>n.origin==="missing"||re(N,{publisher:n.publisher,package_:n.package_,name:n.package_}).length>0?n:{...n,resolvedButNotInCatalog:!0}),K=z(J,B);for(let n of K)a(`[render-stack] WARNING: ${n}`);let L={contractSource:_,cachePath:u,packages:J,warnings:K},i=new Set,h=new Map;for(let n of await l.getAllDocumentsAsync()){let g=n.metadata.namespace_;if(!g?.version||g.publisher!==t)continue;let b=E(g.version),v=`${g.publisher}/${g.package_}@${b}`;i.add(v);let $=await l.getDocumentContentAsync(v);$!==null&&h.set(`${g.package_}@${b}`,$)}return ne({publisher:t,availablePublishers:[t],catalog:N,lookRenderer:Y,localNamespaces:i,rawByNsKey:h,renderStack:L})}import{VersionOperator as ie}from"@kanonak-protocol/types/document/models/enums";function ae(o){let{lookRenderer:e,publisher:c,renderStack:r,catalog:t}=o,a=e.explainStylesheet(e.publisherSubject(c)),u=[...a.tokens.entries()].map(([p,m])=>({name:p,value:m.value,source:`${m.sourceNamespace}/${m.sourceName}`,level:m.level})),d=a.baseStylesheet,k={present:d.css!==void 0,...d.sourceNamespace!==void 0?{source:d.sourceNamespace}:{},...d.scope!==void 0?{scope:d.scope}:{},...d.css!==void 0?{bytes:d.css.length}:{},...d.problem!==void 0?{problem:d.problem}:{},candidates:d.candidates},y=new Map;for(let p of t){let m=p.namespace;m&&y.set(m,(y.get(m)??0)+1)}let s=[...y.entries()].map(([p,m])=>({namespace:p,resources:m})).sort((p,m)=>p.namespace.localeCompare(m.namespace)),l=e.expressionFailures().map(p=>({carrier:p.carrier,reason:p.reason})),f=l.map(p=>`Expression carrier "${p.carrier}" did not compile: ${p.reason} Consequence: that value renders as nothing (and a parent operation consuming it may drop its whole tier). Fix: use a tx.Expression node class the runner implements, or remove the carrier.`);return{publisher:c,renderStack:{contractSource:r.contractSource,cachePath:r.cachePath,packages:r.packages.map(p=>({package_:C(p),origin:p.origin,...p.versions!==void 0?{versions:p.versions}:{},...p.reason!==void 0?{reason:p.reason}:{},...p.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:p.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:u,baseStylesheet:k,...a.look?{look:{sourceClass:`${a.look.sourceClass.publisher}/${a.look.sourceClass.package_}/${a.look.sourceClass.name}`}}:{}},expressionCarriers:l,catalog:s,warnings:[...r.warnings,...a.warnings.filter(p=>!r.warnings.includes(p)),...f]}}function Be(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ge(o){let e=Be,c=o.warnings.length===0,r=o.expressionCarriers.map(s=>`<tr><td><code>${e(s.carrier)}</code></td><td>${e(s.reason)}</td></tr>`).join(`
1
+ import{c as Pe}from"../chunk-V3DH67P3.js";import{a as be,d as X,f as Se,h as ee}from"../chunk-IS3AQKB4.js";import{e as ve,g as $e,m as U,n as Z}from"../chunk-BZ3YTI3C.js";import"../chunk-XK24CN3C.js";import"../chunk-SC5M74NM.js";import{a as H,b as G}from"../chunk-KIBR3HAT.js";import{r as te}from"../chunk-HENE47QG.js";import"../chunk-QHABFCRC.js";import{a as ye}from"../chunk-6VIUXP4N.js";import{m as oe}from"../chunk-PVUBHIU2.js";import{a as O}from"../chunk-HF5FJBS2.js";import{a as xe}from"../chunk-PEJALHXK.js";import{c as Re}from"../chunk-7UYXTYXC.js";import{c as we,u as re}from"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{c as V,e as E,f as W,g as ke}from"../chunk-QILEJIFU.js";import{readFileSync as de,writeFileSync as Ie,mkdirSync as Me}from"fs";import{join as se}from"path";import Fe from"js-yaml";var _e=[{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 q(o){return _e}function C(o){return`${o.publisher}/${o.package_}`}function z(o,e=[]){let c={"kanonak.org/look-styles":"pages render UNSTYLED \u2014 generated CSS stops at the :root token block","kanonak.org/look-tokens":"the :root block loses the universal design-token floor (colors, fonts, spacing)","kanonak.org/universal-look":"resources without their own look render as an empty HTML comment","kanonak.org/look":"band vocabulary (Hero, PropertyList, \u2026) is unresolvable \u2014 declared looks cannot render","kanonak.org/site":"the site vocabulary (content, navigation) is unresolvable \u2014 the base stylesheet cannot bind","kanonak.org/core-kanonak":"the Package/Publisher classes are unresolvable \u2014 package and publisher pages degrade","kanonak.org/link":"link vocabulary is unresolvable \u2014 cross-reference styling degrades"},r=[];for(let t of o)if(t.origin==="missing"){let a=C(t),u=c[a]??"whatever this package contributes to rendering is lost";r.push(`Render-stack package ${a} is MISSING (${t.reason??"unknown reason"}) \u2014 ${u}. Fix: kanonak install ${a} (as the user running the render), or restore network access to ${t.publisher}.`)}else t.resolvedButNotInCatalog&&r.push(`Render-stack package ${C(t)} resolved (${t.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);for(let t of e)r.push(`Import edge ${t.fromNamespace} \u2192 ${t.publisher}/${t.packageName} ${t.constraint} did NOT resolve (${t.reason==="no-compatible-version"?"no compatible version in the repository":"resolution threw"}) \u2014 every statement ${t.fromNamespace} authors against ${t.publisher}/${t.packageName} entities is dropped from the parse as an unresolved predicate (a look declaration loses its bands and pages render empty; see typescript#91). Fix: add a ${t.constraint}-compatible version of ${t.publisher}/${t.packageName} to the workspace or cache (kanonak install ${t.publisher}/${t.packageName}), or bump the import in ${t.fromNamespace}.`);return r}function ne(o){let{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,renderStack:d,producers:k,lockSource:y,configSource:s}=o,l=new Map,f=new Map,p=new Map,m=new Set;for(let S of r){if(!(S instanceof we))continue;let w=S.namespace||"";if(!a.has(w))continue;l.set(`${w}/${S.name}`,S);let P=w.split("/")[1]??"",[_,F]=P.split("@");if(!_||!F)continue;let D=ke(F);D&&(m.has(P)||(m.add(P),f.has(_)||f.set(_,[]),f.get(_).push({verStr:F,version:D})),S.name===_&&p.set(P,S))}for(let S of f.values())S.sort((w,P)=>V(P.version,w.version));return{publisher:e,availablePublishers:c,catalog:r,lookRenderer:t,localNamespaces:a,rawByNsKey:u,bySubject:l,pkgVersions:f,pkgSelfByVer:p,renderStack:d,...k?{producers:k}:{},...y?{lockSource:y}:{},...s?{configSource:s}:{}}}async function pe(o,e={}){let c=new O,r=new ye(c),t=[],a=[];for(let i of ee(o)){let h;try{h=de(i,"utf-8")}catch{continue}let n;try{n=c.parse(h).metadata?.namespace_}catch{continue}if(!n?.version)continue;let g=n.version;a.push({publisher:n.publisher,package_:n.package_,verStr:E(g),version:g,source:h})}a.sort((i,h)=>V(h.version,i.version));for(let i of a)await r.saveDocumentAsync(c.parse(i.source),`${i.publisher}/${i.package_}@${i.verStr}`),t.push({publisher:i.publisher,package_:i.package_,verStr:i.verStr,source:i.source});let u=[...new Set(t.map(i=>i.publisher))].sort(),d=e.publisher;if(d){if(!u.includes(d))throw new Error(`Publisher "${d}" not found in workspace. Available: ${u.join(", ")||"(none)"}`)}else if(u.length===1)d=u[0];else throw u.length===0?new Error(`No Kanonak packages found under ${o}`):new Error(`Workspace has multiple publishers (${u.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let k=new Set,y=new Map;for(let i of t)i.publisher===d&&(k.add(`${i.publisher}/${i.package_}@${i.verStr}`),y.set(`${i.package_}@${i.verStr}`,i.source));let s=X(),l=new be(s,!0,c),f={};e.httpCache&&(f.getFromCache=e.httpCache.getFromCache,f.onFetch=e.httpCache.onFetch),e.fetchFn&&(f.fetchFn=e.fetchFn);let p=e.repository??new Se(r,l,new Z(f)),m=e.log??(()=>{}),S=q(void 0),w=[],P=i=>i.map(h=>h.metadata.namespace_?.version).filter(h=>h!==void 0).sort((h,n)=>V(n,h)).map(E);if(!e.repository){m(`[render-stack] resolving ${S.length} ambient look-stack package(s); cache: ${s}`);let i=e.fetchFn?new U({fetchFn:e.fetchFn}):new U;for(let h of S){let n=C(h),g=await r.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(g.length>0){let v=P(g);w.push({...h,origin:"workspace",versions:v}),m(`[render-stack] ${n} \u2014 workspace (${v.join(", ")})`);continue}let b=await l.getDocumentsByNamespaceAsync(h.publisher,h.package_);if(b.length>0){let v=P(b);w.push({...h,origin:"cache",versions:v}),m(`[render-stack] ${n} \u2014 cache (${v.join(", ")})`);continue}try{let $=(await i.getLock(h.publisher))?.packages[`${h.publisher}/${h.package_}`];if(!$){let j=`publisher ${h.publisher} reachable but its lock does not pin ${h.package_}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let I=$.version,T=$.resolved,Q=await(e.fetchFn?e.fetchFn(T,h.publisher):ve(T));if(!Q.ok){let j=`fetch ${T} failed: HTTP ${Q.status} ${Q.statusText}`;w.push({...h,origin:"missing",reason:j}),m(`[render-stack] ${n} \u2014 MISSING: ${j}`);continue}let fe=await Q.text();await r.saveDocumentAsync(c.parse(fe),`${h.publisher}/${h.package_}@${I}`);try{let j=se(s,h.publisher);Me(j,{recursive:!0}),Ie(se(j,`${h.package_}@${I}.kan.yml`),fe,"utf-8"),w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, installed to cache`)}catch(j){w.push({...h,origin:"fetched",versions:[I]}),m(`[render-stack] ${n}@${I} \u2014 fetched from ${T}, but cache ${s} is NOT WRITABLE (${j.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(v){let $=`fetch failed: ${v.message}`;w.push({...h,origin:"missing",reason:$}),m(`[render-stack] ${n} \u2014 MISSING: ${$}`)}}}let _=(await r.getAllDocumentsAsync()).filter(i=>i.metadata.namespace_?.publisher===d);for(let i of S)_.push(...await p.getDocumentsByNamespaceAsync(i.publisher,i.package_));let F=[],D=await H(_,p,{onUnresolvedEdge:i=>F.push(i)}),A=p;if(!e.repository){for(let i of S)D.add(C(i));A=new G(p,D)}let B=await new oe(c).parseKanonaks(A),ce=new te(B),le=(i,h)=>re(B,{publisher:i,package_:h,name:h}).length>0,N;if(e.repository){N=[];for(let i of S){let h=await p.getDocumentsByNamespaceAsync(i.publisher,i.package_);N.push(h.length>0?{...i,origin:"repository",versions:P(h)}:{...i,origin:"missing",reason:"not present in the caller-supplied repository"})}}else N=w.map(i=>i.origin==="missing"||le(i.publisher,i.package_)?i:{...i,resolvedButNotInCatalog:!0});let Y=z(N,F);for(let i of Y)m(`[render-stack] WARNING: ${i}`);let J={contractSource:"universal-default",cachePath:s,packages:N,warnings:Y},K;try{K=de(se(o,"kanonak.lock"),"utf-8")}catch{K=De(d,t,c)}let L;try{L=de(se(o,".well-known","kanonak.json"),"utf-8")}catch{L=void 0}return ne({publisher:d,availablePublishers:u,catalog:B,lookRenderer:ce,localNamespaces:k,rawByNsKey:y,renderStack:J,...K?{lockSource:K}:{},...L?{configSource:L}:{}})}function De(o,e,c){let r=new Map;for(let a of e)a.publisher===o&&(r.has(a.package_)||r.set(a.package_,{verStr:a.verStr,source:a.source}));if(r.size===0)return;let t={};for(let a of[...r.keys()].sort()){let{verStr:u,source:d}=r.get(a),k={},y;try{y=c.parse(d).metadata?.imports}catch{y=void 0}for(let l of y?.[o]??[]){let f=r.get(l.packageName);f&&(k[`${o}/${l.packageName}`]=f.verStr)}let s={};for(let l of Object.keys(k).sort())s[l]=k[l];t[`${o}/${a}`]={version:u,resolved:`https://${o}/${a}/${u}.kan.yml`,integrity:Pe(d),dependencies:s}}return Fe.dump({version:"1",lastUpdated:"",packages:t},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as Ee,readFileSync as Ke,writeFileSync as Ve,mkdirSync as Ae}from"fs";import{join as je}from"path";async function ue(o,e={}){let c=new O,r=Re(o),t=r.kind==="resource"?r.uri.publisher:r.publisher,a=e.log??(()=>{}),u=e.cacheRoot??X(),d=(n,g,b)=>je(u,n,`${g}@${b}.kan.yml`),k=new Set,y=new Set,s=new Map,l=new Z({getFromCache:(n,g,b)=>{let v=d(n,g,b),$=Ee(v)?Ke(v,"utf-8"):null;return $!==null&&k.add(`${n}/${g}`),$},onFetch:(n,g,b,v)=>{y.add(`${n}/${g}`);try{let $=je(u,n);Ae($,{recursive:!0}),Ve(d(n,g,b),v,"utf-8")}catch($){s.set(`${n}/${g}`,$.message),a(`[render] fetched ${n}/${g}@${b} but cache ${u} is NOT WRITABLE (${$.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),f=new U(e.fetchFn?{fetchFn:e.fetchFn}:void 0),p;if(r.kind==="resource"){let n=r.uri.version;p=[n?{package_:r.uri.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let n=r.version;p=[n?{package_:r.package_,version:`${n.major}.${n.minor}.${n.patch}`}:{package_:r.package_}]}else p=((await f.getConfig(t)).featured_packages??[]).map(g=>({package_:g}));let m=async(n,g,b)=>{try{let v=b?c.buildImport(g,"=",b,n):c.buildImport(g,"*","0.0.0",n),$=await l.getHighestCompatibleVersionAsync(n,v);return $?{doc:$}:{doc:null,error:`${n} did not resolve ${g}${b?`@${b}`:""} (not in its index, or unreachable)`}}catch(v){return{doc:null,error:v.message}}},S=[],w=[];for(let n of p){let{doc:g,error:b}=await m(t,n.package_,n.version);g?S.push(g):b&&w.push(b)}if(S.length===0)throw new Error(`Could not fetch any package for address "${o}" from publisher "${t}".`+(w.length>0?` Reasons: ${w.join("; ")}`:""));let P=q(),_="universal-default",F=n=>n.map(g=>g.metadata.namespace_?.version).filter(g=>g!==void 0).sort((g,b)=>V(b,g)).map(E);a(`[render-stack] resolving ${P.length} ambient look-stack package(s) (contract: ${_}); cache: ${u}`);let D=[],A=[];for(let n of P){let g=C(n),{doc:b,error:v}=await m(n.publisher,n.package_,void 0);if(b){D.push(b);let $=F([b]),I=y.has(g)?"fetched":k.has(g)?"cache":"fetched";A.push({...n,origin:I,versions:$}),a(`[render-stack] ${g} \u2014 ${I} (${$.join(", ")})`+(s.has(g)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else A.push({...n,origin:"missing",reason:v??"unresolved"}),a(`[render-stack] ${g} \u2014 MISSING: ${v??"unresolved"}`)}let B=[],ce=await H([...S,...D],l,{onUnresolvedEdge:n=>B.push(n)}),le=new G(l,ce),N=await new oe(c).parseKanonaks(le),Y=new te(N),J=A.map(n=>n.origin==="missing"||re(N,{publisher:n.publisher,package_:n.package_,name:n.package_}).length>0?n:{...n,resolvedButNotInCatalog:!0}),K=z(J,B);for(let n of K)a(`[render-stack] WARNING: ${n}`);let L={contractSource:_,cachePath:u,packages:J,warnings:K},i=new Set,h=new Map;for(let n of await l.getAllDocumentsAsync()){let g=n.metadata.namespace_;if(!g?.version||g.publisher!==t)continue;let b=E(g.version),v=`${g.publisher}/${g.package_}@${b}`;i.add(v);let $=await l.getDocumentContentAsync(v);$!==null&&h.set(`${g.package_}@${b}`,$)}return ne({publisher:t,availablePublishers:[t],catalog:N,lookRenderer:Y,localNamespaces:i,rawByNsKey:h,renderStack:L})}import{VersionOperator as ie}from"@kanonak-protocol/types/document/models/enums";function ae(o){let{lookRenderer:e,publisher:c,renderStack:r,catalog:t}=o,a=e.explainStylesheet(e.publisherSubject(c)),u=[...a.tokens.entries()].map(([p,m])=>({name:p,value:m.value,source:`${m.sourceNamespace}/${m.sourceName}`,level:m.level})),d=a.baseStylesheet,k={present:d.css!==void 0,...d.sourceNamespace!==void 0?{source:d.sourceNamespace}:{},...d.scope!==void 0?{scope:d.scope}:{},...d.css!==void 0?{bytes:d.css.length}:{},...d.problem!==void 0?{problem:d.problem}:{},candidates:d.candidates},y=new Map;for(let p of t){let m=p.namespace;m&&y.set(m,(y.get(m)??0)+1)}let s=[...y.entries()].map(([p,m])=>({namespace:p,resources:m})).sort((p,m)=>p.namespace.localeCompare(m.namespace)),l=e.expressionFailures().map(p=>({carrier:p.carrier,reason:p.reason})),f=l.map(p=>`Expression carrier "${p.carrier}" did not compile: ${p.reason} Consequence: that value renders as nothing (and a parent operation consuming it may drop its whole tier). Fix: use a tx.Expression node class the runner implements, or remove the carrier.`);return{publisher:c,renderStack:{contractSource:r.contractSource,cachePath:r.cachePath,packages:r.packages.map(p=>({package_:C(p),origin:p.origin,...p.versions!==void 0?{versions:p.versions}:{},...p.reason!==void 0?{reason:p.reason}:{},...p.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:p.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:u,baseStylesheet:k,...a.look?{look:{sourceClass:`${a.look.sourceClass.publisher}/${a.look.sourceClass.package_}/${a.look.sourceClass.name}`}}:{}},expressionCarriers:l,catalog:s,warnings:[...r.warnings,...a.warnings.filter(p=>!r.warnings.includes(p)),...f]}}function Be(o){return o.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function ge(o){let e=Be,c=o.warnings.length===0,r=o.expressionCarriers.map(s=>`<tr><td><code>${e(s.carrier)}</code></td><td>${e(s.reason)}</td></tr>`).join(`
2
2
  `),t=o.warnings.length===0?'<p class="ok">\u2713 No problems detected \u2014 the render stack is fully resolved and pages should be styled.</p>':o.warnings.map(s=>`<div class="warn">\u26A0 ${e(s)}</div>`).join(`
3
3
  `),a=o.renderStack.packages.map(s=>{let l=s.origin!=="missing"&&!s.resolvedButNotInCatalog,f=s.origin==="missing"?'<span class="bad">MISSING</span>':s.resolvedButNotInCatalog?`<span class="bad">${e(s.origin)} (not in catalog)</span>`:`<span class="good">${e(s.origin)}</span>`,p=s.reason?e(s.reason):e((s.versions??[]).join(", "));return`<tr class="${l?"":"row-bad"}"><td><code>${e(s.package_)}</code></td><td>${f}</td><td>${p}</td></tr>`}).join(`
4
4
  `),u=o.stylesheet.baseStylesheet,d=u.present?`<p><span class="good">\u2713 present</span> \u2014 <code>${e(u.source??"")}</code> (${u.bytes} bytes, ${e(u.scope??"")})</p>`:`<p><span class="bad">\u2717 MISSING</span>${u.problem?` \u2014 ${e(u.problem)}`:""}${u.candidates.length>0?`<br>candidates considered: ${u.candidates.map(s=>`<code>${e(s)}</code>`).join(", ")}`:""}</p><p>Without the base stylesheet, generated CSS stops at the <code>:root</code> token block and pages appear unstyled.</p>`,k=o.stylesheet.tokens.map(s=>`<tr><td><code>--kan-${e(s.name)}</code></td><td><code>${e(s.value)}</code></td><td><code>${e(s.source)}</code></td><td>${e(s.level)}</td></tr>`).join(`
@@ -1,4 +1,4 @@
1
- import{a as pe}from"../chunk-L2J7WD7E.js";import"../chunk-BS7RRG7D.js";import{a as ve,b as M,c as Un,l as X,m as Vn,n as Rn,o as le,p as q,r as G}from"../chunk-DD3TCFBT.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import{a as ce,b as ue,c as de,e as $n,f as Tn,g as Bn,h as xn,m as fe}from"../chunk-PVUBHIU2.js";import{a as se}from"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import{e as U}from"../chunk-7UYXTYXC.js";import{b as Y,c as D,d as E,g as $,h as T,i as B,j as w,k as me,l as x,n as N,o as S,t as A}from"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{g as ie}from"../chunk-QILEJIFU.js";var Le="kanonak.org",Oe="document-ast",i=e=>({publisher:Le,package_:Oe,name:e}),m={Document:i("Document"),Block:i("Block"),Inline:i("Inline"),StructuredValue:i("StructuredValue"),Heading:i("Heading"),Paragraph:i("Paragraph"),RawBlock:i("RawBlock"),Text:i("Text"),StructuredMap:i("StructuredMap"),StructuredEntry:i("StructuredEntry"),StructuredList:i("StructuredList"),StringScalar:i("StringScalar"),IntegerScalar:i("IntegerScalar"),EscapeHint:i("EscapeHint"),MediaType:i("MediaType"),metadata:i("metadata"),children:i("children"),level:i("level"),inlines:i("inlines"),text:i("text"),entries:i("entries"),key:i("key"),value:i("value"),escapeHint:i("escapeHint"),items:i("items"),stringValue:i("stringValue"),integerValue:i("integerValue"),rawContent:i("rawContent"),mediaType:i("mediaType"),mimeType:i("mimeType"),ESC_RAW:i("esc-raw"),ESC_YAML_SAFE:i("esc-yaml-safe"),ESC_TOML_STRING:i("esc-toml-string"),ESC_TOML_MULTILINE:i("esc-toml-multiline"),ESC_JSON:i("esc-json"),ESC_DYNAMODB_BOOL:i("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:i("esc-dynamodb-number"),ESC_DYNAMODB_NULL:i("esc-dynamodb-null"),TEXT_PLAIN:i("text-plain"),TEXT_MARKDOWN:i("text-markdown"),TEXT_HTML:i("text-html"),TEXT_CSS:i("text-css"),APPLICATION_JSON:i("application-json"),TEXT_YAML:i("text-yaml"),IMAGE_SVG_XML:i("image-svg-xml"),ResourceLink:i("ResourceLink"),target:i("target"),linkLabel:i("linkLabel"),PropertyList:i("PropertyList"),propertyEntries:i("propertyEntries"),PropertyEntry:i("PropertyEntry"),propertyKey:i("propertyKey"),propertyValue:i("propertyValue"),Table:i("Table"),tableColumnLabels:i("tableColumnLabels"),tableRows:i("tableRows"),TableRow:i("TableRow"),tableCells:i("tableCells")};function ge(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var V=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(n,t){let r=Ie(n.metadata,t),o=Ke(n.children),s=["---",...r,"---","",o].join(`
1
+ import{a as pe}from"../chunk-L2J7WD7E.js";import"../chunk-BS7RRG7D.js";import{a as ve,b as M,c as Un,l as X,m as Vn,n as Rn,o as le,p as q,r as G}from"../chunk-HENE47QG.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import{a as ce,b as ue,c as de,e as $n,f as Tn,g as Bn,h as xn,m as fe}from"../chunk-PVUBHIU2.js";import{a as se}from"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import{e as U}from"../chunk-7UYXTYXC.js";import{b as Y,c as D,d as E,g as $,h as T,i as B,j as w,k as me,l as x,n as N,o as S,t as A}from"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import{g as ie}from"../chunk-QILEJIFU.js";var Le="kanonak.org",Oe="document-ast",i=e=>({publisher:Le,package_:Oe,name:e}),m={Document:i("Document"),Block:i("Block"),Inline:i("Inline"),StructuredValue:i("StructuredValue"),Heading:i("Heading"),Paragraph:i("Paragraph"),RawBlock:i("RawBlock"),Text:i("Text"),StructuredMap:i("StructuredMap"),StructuredEntry:i("StructuredEntry"),StructuredList:i("StructuredList"),StringScalar:i("StringScalar"),IntegerScalar:i("IntegerScalar"),EscapeHint:i("EscapeHint"),MediaType:i("MediaType"),metadata:i("metadata"),children:i("children"),level:i("level"),inlines:i("inlines"),text:i("text"),entries:i("entries"),key:i("key"),value:i("value"),escapeHint:i("escapeHint"),items:i("items"),stringValue:i("stringValue"),integerValue:i("integerValue"),rawContent:i("rawContent"),mediaType:i("mediaType"),mimeType:i("mimeType"),ESC_RAW:i("esc-raw"),ESC_YAML_SAFE:i("esc-yaml-safe"),ESC_TOML_STRING:i("esc-toml-string"),ESC_TOML_MULTILINE:i("esc-toml-multiline"),ESC_JSON:i("esc-json"),ESC_DYNAMODB_BOOL:i("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:i("esc-dynamodb-number"),ESC_DYNAMODB_NULL:i("esc-dynamodb-null"),TEXT_PLAIN:i("text-plain"),TEXT_MARKDOWN:i("text-markdown"),TEXT_HTML:i("text-html"),TEXT_CSS:i("text-css"),APPLICATION_JSON:i("application-json"),TEXT_YAML:i("text-yaml"),IMAGE_SVG_XML:i("image-svg-xml"),ResourceLink:i("ResourceLink"),target:i("target"),linkLabel:i("linkLabel"),PropertyList:i("PropertyList"),propertyEntries:i("propertyEntries"),PropertyEntry:i("PropertyEntry"),propertyKey:i("propertyKey"),propertyValue:i("propertyValue"),Table:i("Table"),tableColumnLabels:i("tableColumnLabels"),tableRows:i("tableRows"),TableRow:i("TableRow"),tableCells:i("tableCells")};function ge(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var V=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(n,t){let r=Ie(n.metadata,t),o=Ke(n.children),s=["---",...r,"---","",o].join(`
2
2
  `);return t?.trailingNewline&&(s.endsWith(`
3
3
  `)||(s+=`
4
4
  `)),s}};function Ie(e,n){if(!e)return[];let t=new Map;for(let c of e.entries)t.set(P(c.key),c);let r=new Map;if(n?.metadataRenames)for(let[c,u]of n.metadataRenames)r.set(P(c),u);let a=(n?.metadataKeys??e.entries.map(c=>c.key)).map(P),s=[];for(let c of a){let u=t.get(c);if(!u)continue;let f=r.get(c),l=P(f??c),d=ye(u.value,u.escapeHint);d!==void 0&&s.push(`${l}: ${d}`)}return s}function P(e){let n=e.lastIndexOf(".");return n===-1?e:e.substring(n+1)||e}function ye(e,n){switch(e.kind){case"StringScalar":return _e(e.stringValue,n);case"IntegerScalar":return String(e.integerValue);case"StructuredList":{let t=[];for(let r of e.items){let o=ye(r,n);o!==void 0&&t.push(o)}return t.join(", ")}case"StructuredMap":return;default:return}}function _e(e,n){return!n||ge(n,m.ESC_RAW)?e:ge(n,m.ESC_YAML_SAFE)?Ce(e):e}function Ce(e){return e.includes(`
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,H,I,J,K,L,M,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-LRVOGQI5.js";import"../chunk-KIBR3HAT.js";import"../chunk-DD3TCFBT.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import"../chunk-PVUBHIU2.js";import"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import"../chunk-7UYXTYXC.js";import"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,o as ClassHierarchyCycleRule,L as DiamondNameClashRule,D as DisplayLensScopeRule,l as EmbeddedKanonakTypeRule,m as ImportExistenceRule,M as KanonakObjectValidator,f as LinkTargetRule,H as LookBandPathRule,E as LookSemanticSvgPathRule,C as MarkdownLinkRule,t as NamespaceImportCycleRule,g as NamespacePrefixRule,x as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,K as OwlOneOfRule,k as PackageHeaderRule,y as PropertyDomainRule,p as PropertyHierarchyCycleRule,z as PropertyKindRangeConsistencyRule,w as PropertyRangeReferenceRule,q as PropertyRangeRequiredRule,i as PropertyTypeSpecificityRule,A as ReservedNameShadowRule,h as ResourceNamingRule,G as SequenceNarrativeRule,J as ShaclShapeRule,r as SubClassOfReferenceRule,s as SubPropertyOfReferenceRule,j as SubjectKanonakTypeRequiredRule,F as TxExpressionCompilesRule,I as TxExpressionPathRule,u as UnresolvedPredicateRule,n as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
1
+ import{A,B,C,D,E,F,G,H,I,J,K,L,M,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-C63WFML4.js";import"../chunk-KIBR3HAT.js";import"../chunk-HENE47QG.js";import"../chunk-QHABFCRC.js";import"../chunk-6VIUXP4N.js";import"../chunk-PVUBHIU2.js";import"../chunk-HF5FJBS2.js";import"../chunk-PEJALHXK.js";import"../chunk-7UYXTYXC.js";import"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,o as ClassHierarchyCycleRule,L as DiamondNameClashRule,D as DisplayLensScopeRule,l as EmbeddedKanonakTypeRule,m as ImportExistenceRule,M as KanonakObjectValidator,f as LinkTargetRule,H as LookBandPathRule,E as LookSemanticSvgPathRule,C as MarkdownLinkRule,t as NamespaceImportCycleRule,g as NamespacePrefixRule,x as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,K as OwlOneOfRule,k as PackageHeaderRule,y as PropertyDomainRule,p as PropertyHierarchyCycleRule,z as PropertyKindRangeConsistencyRule,w as PropertyRangeReferenceRule,q as PropertyRangeRequiredRule,i as PropertyTypeSpecificityRule,A as ReservedNameShadowRule,h as ResourceNamingRule,G as SequenceNarrativeRule,J as ShaclShapeRule,r as SubClassOfReferenceRule,s as SubPropertyOfReferenceRule,j as SubjectKanonakTypeRequiredRule,F as TxExpressionCompilesRule,I as TxExpressionPathRule,u as UnresolvedPredicateRule,n as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/sdk",
3
- "version": "5.32.0",
3
+ "version": "5.33.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",
@@ -134,7 +134,7 @@
134
134
  ],
135
135
  "dependencies": {
136
136
  "@kanonak-protocol/canonical": "^0.1.3",
137
- "@kanonak-protocol/types": "^5.32.0",
137
+ "@kanonak-protocol/types": "^5.33.0",
138
138
  "ignore": "^7.0.5",
139
139
  "js-yaml": "^4.1.0",
140
140
  "yaml": "^2.7.0",