@kanonak-protocol/sdk 5.28.0 → 5.30.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.
Files changed (57) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/chunk-7UYXTYXC.js +1 -0
  3. package/dist/{chunk-RJK6Y4HS.js → chunk-BS7RRG7D.js} +1 -1
  4. package/dist/chunk-BZ3YTI3C.js +2 -0
  5. package/dist/{chunk-N3XODYH5.js → chunk-CJMVIOZX.js} +1 -1
  6. package/dist/chunk-CR5QY3LJ.js +68 -0
  7. package/dist/{chunk-GJAYU443.js → chunk-EVMSO7HJ.js} +1 -1
  8. package/dist/chunk-F67UH4FD.js +1 -0
  9. package/dist/chunk-HF5FJBS2.js +1 -0
  10. package/dist/{chunk-JFBPQN6T.js → chunk-IS3AQKB4.js} +1 -1
  11. package/dist/chunk-J4ZD6IF6.js +2 -0
  12. package/dist/chunk-KIBR3HAT.js +1 -0
  13. package/dist/{chunk-S2VGNHHF.js → chunk-L2J7WD7E.js} +1 -1
  14. package/dist/chunk-PVUBHIU2.js +1 -0
  15. package/dist/{chunk-D66LUZDB.js → chunk-V3DH67P3.js} +1 -1
  16. package/dist/chunk-Z5Y4MCW5.js +155 -0
  17. package/dist/index.d.ts +3 -1
  18. package/dist/index.js +1 -1
  19. package/dist/introspection/OntologyModel.d.ts +11 -0
  20. package/dist/introspection/index.d.ts +1 -1
  21. package/dist/look/LookRenderer.d.ts +37 -0
  22. package/dist/look/index.d.ts +1 -0
  23. package/dist/look/sequenceWalk.d.ts +94 -0
  24. package/dist/parsing/KanonakObjectParser.d.ts +9 -0
  25. package/dist/parsing/index.js +1 -1
  26. package/dist/reasoning/index.js +1 -1
  27. package/dist/repositories/PublisherIndex.d.ts +13 -1
  28. package/dist/repositories/browser.js +1 -1
  29. package/dist/repositories/buildLocalFirstRepository.d.ts +1 -0
  30. package/dist/repositories/index.js +1 -1
  31. package/dist/resolution/ResourceTypeClassifier.d.ts +9 -0
  32. package/dist/resolution/TypeResolver.d.ts +11 -0
  33. package/dist/resolution/importMode.d.ts +26 -0
  34. package/dist/resolution/index.d.ts +1 -0
  35. package/dist/resolution/index.js +1 -1
  36. package/dist/search/index.js +1 -1
  37. package/dist/server/index.js +1 -1
  38. package/dist/transformations/index.js +1 -1
  39. package/dist/uri-helpers/UriHelpers.d.ts +12 -0
  40. package/dist/uri-helpers/index.d.ts +1 -1
  41. package/dist/uri-helpers/index.js +1 -1
  42. package/dist/validation/KanonakObjectValidator.d.ts +5 -1
  43. package/dist/validation/index.d.ts +1 -1
  44. package/dist/validation/index.js +1 -1
  45. package/dist/validation/rules/repository/LinkTargetRule.d.ts +42 -0
  46. package/dist/validation/rules/repository/SequenceNarrativeRule.d.ts +44 -0
  47. package/dist/validation/rules/repository/index.d.ts +2 -0
  48. package/package.json +2 -2
  49. package/dist/chunk-BA4HAURJ.js +0 -1
  50. package/dist/chunk-BRCVOR7A.js +0 -1
  51. package/dist/chunk-KDMBMX3J.js +0 -2
  52. package/dist/chunk-KOWDHKBN.js +0 -1
  53. package/dist/chunk-P5VQEDBS.js +0 -2
  54. package/dist/chunk-SR6I5ZSI.js +0 -68
  55. package/dist/chunk-SUXSCSHO.js +0 -1
  56. package/dist/chunk-TW7NJDMW.js +0 -152
  57. /package/dist/{chunk-PEB52US5.js → chunk-XK24CN3C.js} +0 -0
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{a as Zt,b as Qt,c as eo,d as no,e as H}from"./chunk-GJAYU443.js";import{a as Vn,b as Nn,c as On}from"./chunk-D66LUZDB.js";import{a as Xt,b as Yt,c as Jt,d as Yo,e as we,f as Jo,g as Zo,h as Qo,i as er,j as nr,k as tr,l as or,m as ar}from"./chunk-KDMBMX3J.js";import{a as rr}from"./chunk-S2VGNHHF.js";import{a as mt,b as ft,c as kt,d as yt,e as ht,f as Ct,g as It,h as _t,i as At}from"./chunk-JFBPQN6T.js";import{a as gt,b as St,c as bt,d as Pt,e as Rt,f as Et,h as Kt,i as De,j as Me,k as He,l as Te,m as xt,n as vt}from"./chunk-P5VQEDBS.js";import{a as oo,b as ro,c as ao,d as io}from"./chunk-RJK6Y4HS.js";import{a as so}from"./chunk-PEB52US5.js";import{a as wt}from"./chunk-SC5M74NM.js";import{A as Oo,B as $o,C as Uo,D as Do,E as Mo,F as Ho,G as Wo,H as zo,I as Go,L as qo,M as Xo,a as uo,b as lo,c as po,d as mo,e as fo,f as ko,g as yo,h as ho,i as go,j as So,k as bo,l as Po,m as Ro,n as Eo,o as Ko,p as xo,q as wo,r as vo,s as Co,t as Io,u as _o,v as Ao,w as Lo,x as jo,y as Vo,z as No}from"./chunk-SR6I5ZSI.js";import"./chunk-BRCVOR7A.js";import{c as An,d as To,f as xe,h as Ln,i as jn,j as Fo,k as Bo}from"./chunk-TW7NJDMW.js";import{a as me}from"./chunk-6VIUXP4N.js";import{a as E,b as D,c as ge,i as V,j as Ke,k as Gt,l as qt,m as A}from"./chunk-SUXSCSHO.js";import{a as j}from"./chunk-KOWDHKBN.js";import{a as co}from"./chunk-PEJALHXK.js";import{$ as Re,A as tn,B as on,C as rn,D as an,E as sn,F as cn,G as un,H as ln,I as pn,J as dn,K as mn,L as fn,M as Pe,N as kn,O as yn,P as hn,Q as gn,R as Sn,S as bn,T as Pn,U as Rn,V as En,W as Kn,X as xn,Y as wn,Z as vn,_ as Cn,a as $t,b as Ut,c as Se,d as Dt,da as Ft,e as M,f as Mt,fa as Bt,g as Ht,ga as h,ha as ee,i as Tt,j as X,k as Y,l as Fe,m as J,ma as Wt,n as Be,na as zt,o as We,oa as ne,p as ze,q as Ge,r as qe,s as Xe,t as Ye,u as Je,v as be,w as Ze,x as Qe,y as en,z as nn}from"./chunk-BA4HAURJ.js";import{A as _,B as Q,a as Lt,b as jt,c as g,d as k,e as Nt,f as Ot,g as fe,h as ke,i as ye,j as G,k as he,l as q,m as u,r as In,t as K,v as _n,w as I,x as Z,y,z as Ee}from"./chunk-N3XODYH5.js";import{a as Vt}from"./chunk-FUUTGGJS.js";import{a as at,b as de,c as z,d as it,e as w,f as st,g as ct,h as ut,i as lt,j as pt,k as dt}from"./chunk-QILEJIFU.js";import{a as to}from"./chunk-ODIECDN7.js";async function $n(n){let e=await new A().parseKanonaks(n),o=await new H().reason(n);return{kind:"merged",catalog:e,reasoning:o}}function Un(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function Dn(n,e){let o=e??new me(new j);return{kind:"standalone",catalog:await new A().parseKanonaks(new Q(n,o))}}function $(n){return typeof n=="number"?n:void 0}function ir(n){if(!n)return;let e=u(n);if(e===u(dn))return"IRI";if(e===u(mn))return"BlankNode";if(e===u(fn))return"Literal"}function Mn(n){if(!n)return;let e=u(n);if(e===u(kn))return"Violation";if(e===u(yn))return"Warning";if(e===u(hn))return"Info"}function ve(n,e){let o=y(n,e);if(o)return[o];let t=[];for(let r of _(n,e))r instanceof k&&t.push(r.subject);return t}function sr(n,e){let o=y(n,Ge);if(!o)return;let t={path:o},r=$(I(n,qe)),a=$(I(n,Xe));r!==void 0&&(t.minCount=r),a!==void 0&&(t.maxCount=a);let s=$(I(n,en)),i=$(I(n,nn));s!==void 0&&(t.minLength=s),i!==void 0&&(t.maxLength=i);let c=$(I(n,tn)),p=$(I(n,on));c!==void 0&&(t.minInclusive=c),p!==void 0&&(t.maxInclusive=p);let d=Z(n,Ze);if(d!==void 0){let P=Z(n,Qe);t.pattern=P!==void 0?{regex:d,flags:P}:{regex:d}}if(_n(n,be)){let P=[],N=[];for(let O of _(n,be))O instanceof D?P.push(O.value):O instanceof k&&N.push(O.subject);P.length>0&&(t.inValues=P),N.length>0&&(t.inRefs=N)}let S=y(n,Ye);S&&(t.datatype=S);let b=y(n,Je);b&&(t.classRef=b);let l=ir(y(n,pn));l&&(t.nodeKind=l);let m=Z(n,rn);m!==void 0&&(t.message=m);let f=Mn(y(n,Pe))??e;return f&&(t.severity=f),t}function te(n){let e=[];for(let o of n){if(!(o instanceof g)||!In(o,J))continue;let t=Mn(y(o,Pe)),r={name:o.name,uri:h(o),targetClass:y(o,We),targetNodes:ve(o,an),targetSubjectsOf:ve(o,sn),targetObjectsOf:ve(o,cn),closed:I(o,un)===!0,ignoredProperties:[],severity:t,properties:[]};for(let a of _(o,ln))a instanceof k&&r.ignoredProperties.push(a.subject);for(let a of _(o,ze)){let s;if(a instanceof E?s=a:a instanceof k&&(s=K(n,a.subject)),!s)continue;let i=sr(s,t);i&&r.properties.push(i)}e.push(r)}return e}var x="kanonak.org/transformations",oe="values";var re="allowed",v=n=>({type:`${x}/VarRef`,varName:n}),Ce=n=>({type:`${x}/IntegerLiteral`,integerLiteral:n}),cr=n=>({type:`${x}/DecimalLiteral`,decimalLiteral:n}),Hn=n=>Number.isInteger(n)?Ce(n):cr(n),Tn=n=>({type:`${x}/Count`,source:n}),Fn=(n,e)=>({type:`${x}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),Bn=(n,e)=>({type:`${x}/LessThanOrEqual`,compareLeft:n,compareRight:e});function Ie(n,e){if(!e||e.length===0)return n;let o=new Set(["i","m","s"]),t=[...new Set(e.split(""))];if(t.filter(a=>!o.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${t.sort().join("")})${n}`}function ae(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Fn(Tn(v(oe)),Ce(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:Bn(Tn(v(oe)),Ce(n.maxCount))}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${x}/Contains`,haystack:v(re),needle:v("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:Ie(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${x}/Matches`,matchSource:v("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Fn(v("v"),Hn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:Bn(v("v"),Hn(n.maxInclusive))}),e}import{evaluate as lr,ExpressionError as pr}from"@kanonak-protocol/expression";function Gn(n,e){let o=dr(e)?e:te(e),t=[];for(let r of o)for(let a of mr(n,r))yr(n,r,a,t);return{conforms:!t.some(r=>r.severity==="Violation"),results:t}}function dr(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function ie(n){let e=n.predicate;return e instanceof k?e:void 0}function mr(n,e){let o=new Map,t=n.catalog.filter(a=>a instanceof g),r=a=>{let s=h(a);o.set(s?u(s):`${a.namespace}/${a.name}`,a)};if(e.targetClass){let a=u(e.targetClass);if(n.reasoning){let s=new Set(n.reasoning.getInstancesOfClass(e.targetClass));for(let i of t){let c=h(i);c&&s.has(u(c))&&r(i)}}else for(let s of t)ne(s).some(c=>u(c)===a||ee(n.catalog,c).some(p=>u(p)===a))&&r(s)}for(let a of e.targetNodes){let s=K(n.catalog,a);s instanceof g&&r(s)}for(let a of e.targetSubjectsOf){let s=u(a);for(let i of t)i.statement.some(c=>{let p=ie(c);return p&&u(p.subject)===s})&&r(i)}for(let a of e.targetObjectsOf){let s=u(a);for(let i of t)for(let c of i.statement){let p=ie(c);if(!(!p||u(p.subject)!==s))for(let d of fr(c)){let S=K(n.catalog,d);S instanceof g&&r(S)}}}return[...o.values()]}function fr(n){return n instanceof G?[n.object.subject]:n instanceof q?(n.object??[]).filter(e=>e instanceof k).map(e=>e.subject):[]}function kr(n,e,o){let t=[];for(let r of n.statement){let a=ie(r);if(!(!a||u(a.subject)!==e)){if(r instanceof fe||r instanceof ge)t.push({kernel:r.object,kind:"string",literal:r.object});else if(r instanceof ke)t.push({kernel:r.object,kind:"number",literal:r.object});else if(r instanceof ye)t.push({kernel:r.object?1:0,kind:"boolean",literal:r.object});else if(r instanceof G)t.push({kernel:{ref:u(r.object.subject)},kind:"reference",ref:r.object.subject});else if(r instanceof he)t.push(Wn(r.object,o,t.length));else if(r instanceof q){for(let s of r.object??[])if(s instanceof k)t.push({kernel:{ref:u(s.subject)},kind:"reference",ref:s.subject});else if(s instanceof E)t.push(Wn(s,o,t.length));else if(s instanceof D){let i=s.value;typeof i=="boolean"?t.push({kernel:i?1:0,kind:"boolean",literal:i}):t.push({kernel:i,kind:typeof i=="number"?"number":"string",literal:i})}}}}return t}function Wn(n,e,o){let t=n.name&&n.name.length>0?n.name:String(o);return{kernel:{ref:`${e}#${t}`},kind:"embedded"}}function yr(n,e,o,t){let r=h(o),a=r?u(r):`${o.namespace}/${o.name}`;for(let s of e.properties)gr(n,e,o,a,r,s,t);e.closed&&Er(e,o,a,r,t)}function _e(n,e,o,t,r,a={},s){return{focusNode:e,focusUri:o,constraintComponent:t,severity:s??qn(n),message:r,sourceShape:n.name,sourceShapeUri:n.uri,...a}}function qn(n){return n.severity??"Violation"}var hr={minCount:gn,maxCount:Sn,in:Rn,pattern:En,minLength:Kn,maxLength:xn,minInclusive:wn,maxInclusive:vn};function gr(n,e,o,t,r,a,s){let i=u(a.path),c=kr(o,i,t),p=a.severity??qn(e),d=a.path.name,S=[...(a.inValues??[]).map(l=>typeof l=="boolean"?l?1:0:l),...(a.inRefs??[]).map(l=>({ref:u(l)}))],b=(l,m,f)=>{s.push(_e(e,t,r,l,a.message??m,{resultPath:a.path,value:f?.literal,valueRef:f?.ref},p))};for(let l of ae(a)){let m=hr[l.component];if(l.per==="node"){zn(l,{[oe]:c.map(P=>P.kernel),[re]:S})||b(m,l.component==="minCount"?`'${d}' has ${c.length} value(s); minCount is ${a.minCount}.`:`'${d}' has ${c.length} value(s); maxCount is ${a.maxCount}.`);continue}for(let f of c){if((l.component==="pattern"||l.component==="minLength"||l.component==="maxLength")&&f.kind!=="string"){b(m,`'${d}' value is not a string; ${l.component} applies to string values.`,f);continue}zn(l,{v:f.kernel,[re]:S})||b(m,Sr(l,d,a,f),f)}}if(a.nodeKind)for(let l of c)br(a.nodeKind,l)||b(Cn,`'${d}' value is ${l.kind}; nodeKind requires ${a.nodeKind}.`,l);if(a.datatype)for(let l of c){let m=Pr(a.datatype,l);m&&b(bn,`'${d}' ${m}`,l)}if(a.classRef)for(let l of c){let m=Rr(n,a.classRef,l);m&&b(Pn,`'${d}' ${m}`,l)}}function Sr(n,e,o,t){let r=t.ref?u(t.ref):JSON.stringify(t.literal);switch(n.component){case"in":return`'${e}' value ${r} is not in the permitted set.`;case"pattern":return`'${e}' value ${r} does not match pattern ${o.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${o.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${o.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${o.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${o.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function zn(n,e){let o=t=>{let r=t.varName;if(t.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new pr(`Conformance lowering produced an unexpected leaf '${t.type}'`)};return lr(n.expr,void 0,o)===1}function br(n,e){switch(n){case"IRI":return e.kind==="reference";case"BlankNode":return e.kind==="embedded";case"Literal":return e.kind==="string"||e.kind==="number"||e.kind==="boolean"}}function Pr(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let o=Ke(n);if(o!==void 0)switch(o){case V.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case V.Integer:return e.kind!=="number"?`value is not a number (${n.name}).`:Number.isInteger(e.literal)?void 0:`value is not an integer (${n.name}).`;case V.Decimal:case V.Double:case V.Float:return e.kind==="number"?void 0:`value is not a number (${n.name}).`;default:return e.kind==="string"?void 0:`value is not a string-carried literal (${n.name}).`}}function Rr(n,e,o){if(o.kind!=="reference"||!o.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let t=u(e);if(n.reasoning)return n.reasoning.isInstanceOf(o.ref,e)?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`;let r=K(n.catalog,o.ref);return r instanceof g?ne(r).some(s=>u(s)===t||ee(n.catalog,s).some(i=>u(i)===t))?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`:`value ${u(o.ref)} does not resolve in this scope (sh:class ${e.name}).`}function Er(n,e,o,t,r){let a=new Set([...n.properties.map(i=>u(i.path)),...n.ignoredProperties.map(i=>u(i))]),s=new Set;for(let i of e.statement){let c=ie(i);if(!c)continue;let p=u(c.subject);a.has(p)||s.has(p)||(s.add(p),r.push(_e(n,o,t,Re,`'${e.name}' carries undeclared property '${c.subject.name}' (closed shape).`,{resultPath:c.subject})))}for(let i of e.unresolvedPredicates)s.has(i.key)||(s.add(i.key),r.push(_e(n,o,t,Re,`'${e.name}' carries unresolvable property '${i.key}' (closed shape).`,{value:i.key})))}import*as Ae from"js-yaml";import{VersionOperator as Xn}from"@kanonak-protocol/types/document/models/enums";var Kr="0.0.0",L=class{constructor(e,o=new j,t){this.repository=e;this.parser=o;this.objectParser=t??new A(this.parser)}repository;parser;objectParser;imports(){return new T}serializeValue(e,o){return Zn(e,o)}async buildContentAddressed(e){let o=e.book.toImports(),t=await this.hashBody(e.publisher,o,e.body),r=Le(t),a={type:"EphemeralPackage",publisher:e.publisher,imports:o};e.contentHashProperty&&(a[e.contentHashProperty]=t),Object.assign(a,e.header??{}),a.imports=o;let s={[r]:a,...e.body},i=this.dump(s);return{yaml:i,byteCount:Jn(i),contentHash:t,packageName:r,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let o=e.book.toImports(),t={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:o},r;e.contentHashProperty&&(r=await this.hashBody(e.publisher,o,e.body),t[e.contentHashProperty]=r),Object.assign(t,e.header??{}),t.imports=o;let a={[e.name]:t,...e.body},s=this.dump(a),i={yaml:s,byteCount:Jn(s),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return r!==void 0&&(i.contentHash=r),i}dump(e){return Ae.dump(e,{lineWidth:-1})}async hashBody(e,o,t){let r={[Yn]:{type:"EphemeralPackage",publisher:e,imports:o},...t},a=this.parser.parse(Ae.dump(r,{lineWidth:-1})),s=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new Q(a,this.repository))).filter(p=>p instanceof g&&p.namespace===s&&p.name!==Yn);for(let p of c)p.namespace="ephemeral";return we(c)}},Yn="__pkgbuilder_probe__";function Jn(n){return new TextEncoder().encode(n).length}function Le(n){let e="sha256:",o=n.startsWith(e)?e.length:0;return`q-${n.slice(o,o+16)}`}var T=class{byKey=new Map;aliases=new Set;ensure(e,o,t,r,a=Xn.Major){let s=`${e}/${o}@${t}`,i=this.byKey.get(s);if(i)return i.alias;let c=this.uniqueAlias(r);return this.byKey.set(s,{publisher:e,package_:o,version:t,alias:c,match:a}),c}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,w(e.version),e.package_)}.${e.name}`}refLatest(e,o,t,r){return`${this.ensure(e,o,Kr,r??o,Xn.Any)}.${t}`}toImports(){let e=new Map;for(let t of this.byKey.values()){let r=e.get(t.publisher)??[];r.push(t),e.set(t.publisher,r)}return[...e.keys()].sort().map(t=>({publisher:t,packages:e.get(t).sort((r,a)=>r.package_<a.package_?-1:1).map(r=>({package:r.package_,match:de(r.match),version:r.version,alias:r.alias}))}))}uniqueAlias(e){let o=F(e)||"pkg",t=o,r=2;for(;this.aliases.has(t);)t=`${o}${r++}`;return this.aliases.add(t),t}};function Zn(n,e){if(n!=null){if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof k)return e.ref(n.subject);if(Array.isArray(n)){let o=n.map(t=>Zn(t,e)).filter(t=>t!==void 0);return o.length>0?o:void 0}if(n instanceof E)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(xr(n))throw new Error(`Value produced a bare URI without a version (${n.publisher}/${n.package_}/${n.name}); cannot serialize it as a reference.`)}}function F(n){return n.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function xr(n){return typeof n=="object"&&n!==null&&typeof n.publisher=="string"&&typeof n.package_=="string"&&typeof n.name=="string"}var wr="1.1.0";async function Qn(n){let e=new L(n.repository),o=e.imports(),t=o.ensure(X,Y,wr,"sh"),r=(i,c)=>i&&i.version&&typeof i.version.major=="number"?`${o.ensure(i.publisher,i.package_,w(i.version),i.package_)}.${i.name}`:c,a={},s=[];return n.result.results.forEach((i,c)=>{let p=`result-${c+1}`;s.push(p);let d={type:`${t}.ValidationResult`,[`${t}.focusNode`]:r(i.focusUri,i.focusNode),[`${t}.resultMessage`]:i.message,[`${t}.resultSeverity`]:`${t}.${i.severity}`,[`${t}.sourceConstraintComponent`]:`${t}.${i.constraintComponent.name}`};i.resultPath&&(d[`${t}.resultPath`]=r(i.resultPath,u(i.resultPath))),i.sourceShapeUri&&(d[`${t}.sourceShape`]=r(i.sourceShapeUri,i.sourceShape)),i.valueRef?d[`${t}.value`]=r(i.valueRef,u(i.valueRef)):i.value!==void 0&&(d[`${t}.value`]=i.value),a[p]=d}),a.report={type:`${t}.ValidationReport`,[`${t}.conforms`]:n.result.conforms,...s.length>0?{[`${t}.result`]:s}:{}},e.buildContentAddressed({publisher:n.publisher,book:o,body:a,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as Ci}from"@kanonak-protocol/types/document/models/enums";var se=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,o){return this.producers.find(t=>t.canProduce(e,o))}async produceCached(e,o,t,r){let a=`${o}/${t}@${w(r)}`,s=this.produced.get(a);if(s)return s;let{document:i}=await e.produce(o,t,r);return this.produced.set(a,i),i}async getHighestCompatibleVersionAsync(e,o){let t=this.producerFor(e,o.packageName);if(!t)return null;let r={operator:o.versionOperator,version:o.version},a=await t.resolveVersion(e,o.packageName,r);return a?this.produceCached(t,e,o.packageName,a):null}async getDocumentAsync(e){let o;try{o=Se(e)}catch{return null}if(o.kind!=="package"||!o.version)return null;let t=this.producerFor(o.publisher,o.package_);return t?this.produceCached(t,o.publisher,o.package_,o.version):null}async getDocumentsByNamespaceAsync(e,o){return Array.from(this.produced.values()).filter(t=>{let r=t.metadata.namespace_;return r!=null&&r.publisher===e&&r.package_===o})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var je={async authorize(){return{allowed:!0}}},Ve={async record(){}},B=class extends Error{constructor(o,t){let r=`${o.publisher}/${o.package_}${o.version?`@${o.version.major}.${o.version.minor}.${o.version.patch}`:""}`;super(`Not entitled to produce ${r}${t?`: ${t}`:""}`);this.address=o;this.reason=t;this.name="EntitlementDeniedError"}address;reason},ce=class{inner;ctx;policy;meter;constructor(e,o,t=je,r=Ve){this.inner=e,this.ctx=o,this.policy=t,this.meter=r}canProduce(e,o){return this.inner.canProduce(e,o)}async resolveVersion(e,o,t){return await this.assertAllowed({publisher:e,package_:o,version:t.version}),this.inner.resolveVersion(e,o,t)}async produce(e,o,t){let r={publisher:e,package_:o,version:t};await this.assertAllowed(r);let a=await this.inner.produce(e,o,t);return await this.meter.record(this.ctx,r,a),a}async assertAllowed(e){let o=await this.policy.authorize(this.ctx,e);if(!o.allowed)throw new B(e,o.reason)}};var R="kanonak.org",C="view",et="core-kanonak",vr={publisher:R,package_:C,name:"rootView"},Cr={publisher:R,package_:C,name:"bind"},Ir={publisher:R,package_:C,name:"produces"},_r={publisher:R,package_:C,name:"projections"},Ar={publisher:R,package_:C,name:"where"},Lr={publisher:R,package_:C,name:"value"},jr={publisher:R,package_:C,name:"as"},ue=class{constructor(e,o=new j){this.repository=e;this.parser=o;this.objectParser=new A(this.parser),this.builder=new L(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,o={}){let t=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(t,e),a=y(r,Cr);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let s=y(r,Ir);if(!s)throw new Error(`View ${r.namespace}/${r.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(r),c=nt(t,R,et),p=nt(t,R,C),d=this.builder.imports(),S=d.ensure(R,et,c,"ck"),b=d.ensure(R,C,p,"v"),l=d.ref(s),m=new jn(this.repository,this.parser,this.objectParser),f=new Ln(m,t),P=this.readProjections(t,r),N=$r(r,Ar),O=this.findInstances(t,a,await this.reason(o)),Ne={},ot=new Set;for(let W of O){if(!await this.passesWhere(f,t,N,W))continue;let pe={type:l};for(let $e of P){let rt=await this.evaluateValue(f,t,$e.value,W),Ue=this.builder.serializeValue(tt(rt),d);Ue!==void 0&&(pe[d.ref($e.as)]=Ue)}let Oe=h(W);Oe&&(pe[`${b}.derivedFrom`]=d.ref(Oe)),Ne[this.rowName(W,ot)]=pe}let le={};o.resolvedAt&&(le[`${S}.resolvedAt`]=o.resolvedAt),o.invocationId&&(le[`${S}.id`]=o.invocationId);let U=await this.builder.buildContentAddressed({publisher:i,book:d,body:Ne,contentHashProperty:`${S}.contentHash`,header:le});return{yaml:U.yaml,contentHash:U.contentHash,packageName:U.packageName,publisher:U.publisher,rowCount:U.resourceCount}}resolveView(e,o){let t=K(e,o);if(!t)throw new Error(`View ${o.publisher}/${o.package_}/${o.name} not found in the catalog.`);let r=y(t,vr);if(r){let a=K(e,r);if(!a)throw new Error(`ViewPackage ${o.name} names rootView ${r.name}, which is not in the catalog.`);return a}return t}readProjections(e,o){let t=[];for(let r of _(o,_r)){let a=r instanceof E?r:r instanceof k?K(e,r.subject):void 0;if(!a)continue;let s=Ee(a,Lr),i=y(a,jr);s&&i&&t.push({value:s,as:i})}return t}async reason(e){return new H({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,o,t){let r=Or(e),a=[],s=new Set;for(let i of t.getInstancesOfClass(o)){if(s.has(i))continue;s.add(i);let c=r.get(i);c&&a.push(c)}return a.sort((i,c)=>{let p=M(h(i)),d=M(h(c));return p<d?-1:p>d?1:0}),a}async passesWhere(e,o,t,r){for(let a of t){let s=await this.evaluateValue(e,o,a,r);if(!Ur(s))return!1}return!0}async evaluateValue(e,o,t,r){let a=An(t,"view-projection",{catalog:o,depth:0}),s=new Map([["input",r]]);return e.evaluate(a,s)}rowName(e,o){let t=F(e.name)||"row",r=t,a=2;for(;o.has(r);)r=`${t}-${a++}`;return o.add(r),r}};function tt(n){return xe(n)?n.value:Array.isArray(n)?n.map(tt):n}function Vr(n){let e=h(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function nt(n,e,o){let t=Nr(n,e,o);if(!t)throw new Error(`Package ${e}/${o} is not in the catalog; it must be importable to materialize a view.`);return t}function Nr(n,e,o){let t;for(let r of n){if(!(r instanceof g))continue;let a=h(r);!a||a.publisher!==e||a.package_!==o||!a.version||(!t||z(a.version,t)>0)&&(t=a.version)}return t?w(t):void 0}function Or(n){let e=new Map,o=new Map;for(let t of n){if(!(t instanceof g))continue;let r=h(t);if(!r||!r.version)continue;let a=M(r),s=o.get(a);(!s||z(r.version,s)>0)&&(o.set(a,r.version),e.set(a,t))}return e}function $r(n,e){let o=Ee(n,e);return o?[o]:_(n,e).filter(t=>t instanceof E)}function Ur(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:xe(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{_o as AmbiguousReferenceRule,ye as BooleanStatement,Jo as CANONICAL_FORM_VERSION,V as Carrier,Oo as ClassDefinitionRule,Eo as ClassHierarchyCycleRule,kt as CompositeKanonakDocumentRepository,Qo as DEFAULT_CONSENT_BINDING_PARAM,jt as DefinedKanonak,qo as DiamondNameClashRule,Uo as DisplayLensScopeRule,ft as DocumentLocation,Yt as EdgeType,E as EmbeddedKanonak,bo as EmbeddedKanonakTypeRule,he as EmbeddedStatement,B as EntitlementDeniedError,ce as EntitlementProducer,mt as FileSystemKanonakDocumentRepository,to as GitIgnoreFilter,Jt as GraphBuilder,vt as HttpKanonakDocumentRepository,De as INTEGRITY_PREFIX,T as ImportBook,Po as ImportExistenceRule,me as InMemoryKanonakDocumentRepository,gt as KANONAK_USER_AGENT,Lt as Kanonak,ro as KanonakDocumentPositions,A as KanonakObjectParser,Xo as KanonakObjectValidator,j as KanonakParser,Vt as KanonakUri,so as KanonakUriBuilder,co as KanonakUrlResolver,Ft as KanonakVocabulary,q as ListStatement,D as LiteralKanonak,Ct as LocalFirstRepository,It as LockAwareRepository,Ho as LookBandPathRule,Fo as LookRenderer,Do as LookSemanticSvgPathRule,$o as MarkdownLinkRule,ge as MarkdownStatement,Co as NamespaceImportCycleRule,ko as NamespacePrefixRule,Xt as NodeType,ke as NumberStatement,er as OAuthDiscovery,eo as OWL_RL_CLASSIFICATION_RULES,Lo as ObjectPropertyValueValidationRule,po as OntologyValidationError,uo as OntologyValidationResult,Go as OwlOneOfRule,L as PackageBuilder,So as PackageHeaderRule,se as ProducerRepository,jo as PropertyDomainRule,Ko as PropertyHierarchyCycleRule,Vo as PropertyKindRangeConsistencyRule,oo as PropertyMetadata,Ao as PropertyRangeReferenceRule,xo as PropertyRangeRequiredRule,ho as PropertyTypeSpecificityRule,Kt as PublisherConfigResolver,xt as PublisherIndex,Qt as RDFS_RULES,H as Reasoner,no as ReasoningResult,k as ReferenceKanonak,G as ReferenceStatement,ht as RepositoryFactory,No as ReservedNameShadowRule,yo as ResourceNamingRule,$t as ResourceResolver,Bt as ResourceTypeClassifier,Y as SHACL_PACKAGE,X as SHACL_PUBLISHER,J as SH_NODE_SHAPE,Be as SH_PROPERTY_SHAPE,Fe as SH_SHAPE,Ot as ScalarStatement,zo as ShaclShapeRule,Nt as Statement,fe as StringStatement,wo as SubClassOfReferenceRule,vo as SubPropertyOfReferenceRule,g as SubjectKanonak,go as SubjectKanonakTypeRequiredRule,or as TokenCredentialProvider,Zt as TripleStore,Mo as TxExpressionCompilesRule,Wo as TxExpressionPathRule,Ut as TypeResolver,Io as UnresolvedPredicateRule,Ro as UnresolvedReferenceRule,fo as ValidationCache,mo as ValidationContext,lo as ValidationSeverity,Ci as VersionOperator,ue as ViewMaterializer,je as allowAllPolicy,Pt as assertHttpsUrl,wt as assertPackageIdentity,At as buildLocalFirstRepository,ar as buildOntologyModel,Qn as buildReportPackageAsync,te as buildShapesModel,Yo as canonicalForm,we as canonicalHash,Ke as carrierOf,_t as collectKanonakFiles,z as compareVersions,On as computeIntegrity,Te as computeIntegrityAsync,Le as contentAddressedName,ne as contextTypesOf,tr as createCredentialedFetch,st as createVersion,Gn as evaluateConformance,qt as extractMarkdownLinks,rr as findDerivation,Gt as findMalformedReferences,io as findMarkdownLinkAt,Ie as foldFlagsIntoPattern,Dt as formatKanonakAddress,w as formatVersion,yt as getGlobalCachePath,bt as getKanonakUserAgent,ut as isCompatibleVersion,lt as isMajorCompatible,Rt as kanonakFetch,Vn as loadLockFile,ae as lowerConstraint,Mt as makeUriKey,Ve as noopMeter,Zo as normalizeHost,nr as parseAuthChallenge,Se as parseKanonakAddress,Me as parseLockFile,ct as parseVersionString,ao as parseWithPositions,dt as pickHighestDocument,Wt as propertiesInScope,To as resolveDisplayValue,zt as resolvePropertyStep,F as sanitizeName,pt as satisfiesVersionOperator,Nn as saveLockFile,Un as scopeFromCatalog,Dn as scopeFromDocumentAsync,$n as scopeFromRepositoryAsync,He as serializeLockFile,Et as setKanonakFetchRetries,St as setKanonakUserAgent,h as subjectUri,ee as superClassChain,Bo as supportedBandKeys,Ht as tripleKey,M as uriKey,Tt as uriTriple,at as versionOperatorFromChar,de as versionOperatorToChar,it as versionsEqual};
1
+ import{a as Zt,b as Qt,c as eo,d as no,e as H}from"./chunk-EVMSO7HJ.js";import{a as Vn,b as Nn,c as On}from"./chunk-V3DH67P3.js";import{a as Xt,b as Yt,c as Jt,d as tr,e as we,f as or,g as rr,h as ar,i as ir,j as sr,k as cr,l as ur}from"./chunk-J4ZD6IF6.js";import{a as lr}from"./chunk-L2J7WD7E.js";import{a as mt,b as ft,c as kt,d as yt,e as ht,f as vt,g as It,h as _t,i as Lt}from"./chunk-IS3AQKB4.js";import{a as gt,b as St,c as bt,d as Pt,e as Rt,f as Et,h as Kt,i as De,j as Me,k as He,l as Te,m as xt,n as Ct}from"./chunk-BZ3YTI3C.js";import{a as oo,b as ro,c as ao,d as io}from"./chunk-BS7RRG7D.js";import{a as so}from"./chunk-XK24CN3C.js";import{a as wt}from"./chunk-SC5M74NM.js";import{A as Oo,B as $o,C as Uo,D as Do,E as Mo,F as Ho,G as Xo,H as Yo,I as Jo,J as Zo,K as Qo,L as er,M as nr,a as uo,b as lo,c as po,d as mo,e as fo,f as ko,g as yo,h as ho,i as go,j as So,k as bo,l as Po,m as Ro,n as Eo,o as Ko,p as xo,q as wo,r as Co,s as vo,t as Io,u as _o,v as Lo,w as Ao,x as jo,y as Vo,z as No}from"./chunk-CR5QY3LJ.js";import"./chunk-KIBR3HAT.js";import{c as Ln,d as To,e as Fo,g as Bo,h as Wo,k as zo,m as xe,o as An,p as jn,r as Go,s as qo}from"./chunk-Z5Y4MCW5.js";import{a as me}from"./chunk-6VIUXP4N.js";import{a as E,b as D,c as ge,i as V,j as Ke,k as Gt,l as qt,m as L}from"./chunk-PVUBHIU2.js";import{a as j}from"./chunk-HF5FJBS2.js";import{a as co}from"./chunk-PEJALHXK.js";import{$ as Ee,A as rn,B as an,C as sn,D as cn,E as un,F as ln,G as pn,H as dn,I as mn,J as fn,K as kn,L as yn,M as Re,N as hn,O as gn,P as Sn,Q as bn,R as Pn,S as Rn,T as En,U as Kn,V as xn,W as wn,X as Cn,Y as vn,Z as In,_ as _n,a as $t,b as Ut,c as Se,d as Dt,da as Ft,e as M,f as Mt,fa as Bt,g as Ht,ga as h,ha as ee,i as Tt,j as Y,k as J,l as We,m as Z,ma as Wt,n as ze,na as zt,o as Ge,oa as ne,p as qe,q as Xe,r as Ye,s as Je,t as Ze,u as Qe,v as Pe,w as en,x as nn,y as tn,z as on}from"./chunk-7UYXTYXC.js";import{A as be,B as _,C as Q,a as At,b as jt,c as g,d as k,e as Nt,f as Ot,g as fe,h as ke,i as ye,j as G,k as he,l as q,m as u,r as Fe,t as K,w as Be,x as I,y as X,z as y}from"./chunk-CJMVIOZX.js";import{a as Vt}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{a as at,b as de,c as z,d as it,e as w,f as st,g as ct,h as ut,i as lt,j as pt,k as dt}from"./chunk-QILEJIFU.js";import{a as to}from"./chunk-ODIECDN7.js";async function $n(n){let e=await new L().parseKanonaks(n),o=await new H().reason(n);return{kind:"merged",catalog:e,reasoning:o}}function Un(n,e){return{kind:"merged",catalog:n,reasoning:e}}async function Dn(n,e){let o=e??new me(new j);return{kind:"standalone",catalog:await new L().parseKanonaks(new Q(n,o))}}function $(n){return typeof n=="number"?n:void 0}function pr(n){if(!n)return;let e=u(n);if(e===u(fn))return"IRI";if(e===u(kn))return"BlankNode";if(e===u(yn))return"Literal"}function Mn(n){if(!n)return;let e=u(n);if(e===u(hn))return"Violation";if(e===u(gn))return"Warning";if(e===u(Sn))return"Info"}function Ce(n,e){let o=y(n,e);if(o)return[o];let t=[];for(let r of _(n,e))r instanceof k&&t.push(r.subject);return t}function dr(n,e){let o=y(n,Xe);if(!o)return;let t={path:o},r=$(I(n,Ye)),a=$(I(n,Je));r!==void 0&&(t.minCount=r),a!==void 0&&(t.maxCount=a);let s=$(I(n,tn)),i=$(I(n,on));s!==void 0&&(t.minLength=s),i!==void 0&&(t.maxLength=i);let c=$(I(n,rn)),p=$(I(n,an));c!==void 0&&(t.minInclusive=c),p!==void 0&&(t.maxInclusive=p);let d=X(n,en);if(d!==void 0){let P=X(n,nn);t.pattern=P!==void 0?{regex:d,flags:P}:{regex:d}}if(Be(n,Pe)){let P=[],N=[];for(let O of _(n,Pe))O instanceof D?P.push(O.value):O instanceof k&&N.push(O.subject);P.length>0&&(t.inValues=P),N.length>0&&(t.inRefs=N)}let S=y(n,Ze);S&&(t.datatype=S);let b=y(n,Qe);b&&(t.classRef=b);let l=pr(y(n,mn));l&&(t.nodeKind=l);let m=X(n,sn);m!==void 0&&(t.message=m);let f=Mn(y(n,Re))??e;return f&&(t.severity=f),t}function te(n){let e=[];for(let o of n){if(!(o instanceof g)||!Fe(o,Z))continue;let t=Mn(y(o,Re)),r={name:o.name,uri:h(o),targetClass:y(o,Ge),targetNodes:Ce(o,cn),targetSubjectsOf:Ce(o,un),targetObjectsOf:Ce(o,ln),closed:I(o,pn)===!0,ignoredProperties:[],severity:t,properties:[]};for(let a of _(o,dn))a instanceof k&&r.ignoredProperties.push(a.subject);for(let a of _(o,qe)){let s;if(a instanceof E?s=a:a instanceof k&&(s=K(n,a.subject)),!s)continue;let i=dr(s,t);i&&r.properties.push(i)}e.push(r)}return e}var x="kanonak.org/transformations",oe="values";var re="allowed",C=n=>({type:`${x}/VarRef`,varName:n}),ve=n=>({type:`${x}/IntegerLiteral`,integerLiteral:n}),mr=n=>({type:`${x}/DecimalLiteral`,decimalLiteral:n}),Hn=n=>Number.isInteger(n)?ve(n):mr(n),Tn=n=>({type:`${x}/Count`,source:n}),Fn=(n,e)=>({type:`${x}/GreaterThanOrEqual`,compareLeft:n,compareRight:e}),Bn=(n,e)=>({type:`${x}/LessThanOrEqual`,compareLeft:n,compareRight:e});function Ie(n,e){if(!e||e.length===0)return n;let o=new Set(["i","m","s"]),t=[...new Set(e.split(""))];if(t.filter(a=>!o.has(a)).length>0)throw new Error(`sh:flags '${e}' is outside the pinned regex subset (supported: i, m, s)`);return`(?${t.sort().join("")})${n}`}function ae(n){let e=[];return n.minCount!==void 0&&e.push({component:"minCount",per:"node",expr:Fn(Tn(C(oe)),ve(n.minCount))}),n.maxCount!==void 0&&e.push({component:"maxCount",per:"node",expr:Bn(Tn(C(oe)),ve(n.maxCount))}),(n.inValues!==void 0||n.inRefs!==void 0)&&e.push({component:"in",per:"value",expr:{type:`${x}/Contains`,haystack:C(re),needle:C("v")}}),n.pattern!==void 0&&e.push({component:"pattern",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:Ie(n.pattern.regex,n.pattern.flags)}}),n.minLength!==void 0&&e.push({component:"minLength",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:`(?s)^.{${n.minLength},}$`}}),n.maxLength!==void 0&&e.push({component:"maxLength",per:"value",expr:{type:`${x}/Matches`,matchSource:C("v"),pattern:`(?s)^.{0,${n.maxLength}}$`}}),n.minInclusive!==void 0&&e.push({component:"minInclusive",per:"value",expr:Fn(C("v"),Hn(n.minInclusive))}),n.maxInclusive!==void 0&&e.push({component:"maxInclusive",per:"value",expr:Bn(C("v"),Hn(n.maxInclusive))}),e}import{evaluate as kr,ExpressionError as yr}from"@kanonak-protocol/expression";function Gn(n,e){let o=hr(e)?e:te(e),t=[];for(let r of o)for(let a of gr(n,r))Pr(n,r,a,t);return{conforms:!t.some(r=>r.severity==="Violation"),results:t}}function hr(n){return n.length>0&&!(n[0]instanceof Object&&"statement"in n[0])&&typeof n[0].name=="string"&&"properties"in n[0]}function ie(n){let e=n.predicate;return e instanceof k?e:void 0}function gr(n,e){let o=new Map,t=n.catalog.filter(a=>a instanceof g),r=a=>{let s=h(a);o.set(s?u(s):`${a.namespace}/${a.name}`,a)};if(e.targetClass){let a=u(e.targetClass);if(n.reasoning){let s=new Set(n.reasoning.getInstancesOfClass(e.targetClass));for(let i of t){let c=h(i);c&&s.has(u(c))&&r(i)}}else for(let s of t)ne(s).some(c=>u(c)===a||ee(n.catalog,c).some(p=>u(p)===a))&&r(s)}for(let a of e.targetNodes){let s=K(n.catalog,a);s instanceof g&&r(s)}for(let a of e.targetSubjectsOf){let s=u(a);for(let i of t)i.statement.some(c=>{let p=ie(c);return p&&u(p.subject)===s})&&r(i)}for(let a of e.targetObjectsOf){let s=u(a);for(let i of t)for(let c of i.statement){let p=ie(c);if(!(!p||u(p.subject)!==s))for(let d of Sr(c)){let S=K(n.catalog,d);S instanceof g&&r(S)}}}return[...o.values()]}function Sr(n){return n instanceof G?[n.object.subject]:n instanceof q?(n.object??[]).filter(e=>e instanceof k).map(e=>e.subject):[]}function br(n,e,o){let t=[];for(let r of n.statement){let a=ie(r);if(!(!a||u(a.subject)!==e)){if(r instanceof fe||r instanceof ge)t.push({kernel:r.object,kind:"string",literal:r.object});else if(r instanceof ke)t.push({kernel:r.object,kind:"number",literal:r.object});else if(r instanceof ye)t.push({kernel:r.object?1:0,kind:"boolean",literal:r.object});else if(r instanceof G)t.push({kernel:{ref:u(r.object.subject)},kind:"reference",ref:r.object.subject});else if(r instanceof he)t.push(Wn(r.object,o,t.length));else if(r instanceof q){for(let s of r.object??[])if(s instanceof k)t.push({kernel:{ref:u(s.subject)},kind:"reference",ref:s.subject});else if(s instanceof E)t.push(Wn(s,o,t.length));else if(s instanceof D){let i=s.value;typeof i=="boolean"?t.push({kernel:i?1:0,kind:"boolean",literal:i}):t.push({kernel:i,kind:typeof i=="number"?"number":"string",literal:i})}}}}return t}function Wn(n,e,o){let t=n.name&&n.name.length>0?n.name:String(o);return{kernel:{ref:`${e}#${t}`},kind:"embedded"}}function Pr(n,e,o,t){let r=h(o),a=r?u(r):`${o.namespace}/${o.name}`;for(let s of e.properties)Er(n,e,o,a,r,s,t);e.closed&&vr(e,o,a,r,t)}function _e(n,e,o,t,r,a={},s){return{focusNode:e,focusUri:o,constraintComponent:t,severity:s??qn(n),message:r,sourceShape:n.name,sourceShapeUri:n.uri,...a}}function qn(n){return n.severity??"Violation"}var Rr={minCount:bn,maxCount:Pn,in:Kn,pattern:xn,minLength:wn,maxLength:Cn,minInclusive:vn,maxInclusive:In};function Er(n,e,o,t,r,a,s){let i=u(a.path),c=br(o,i,t),p=a.severity??qn(e),d=a.path.name,S=[...(a.inValues??[]).map(l=>typeof l=="boolean"?l?1:0:l),...(a.inRefs??[]).map(l=>({ref:u(l)}))],b=(l,m,f)=>{s.push(_e(e,t,r,l,a.message??m,{resultPath:a.path,value:f?.literal,valueRef:f?.ref},p))};for(let l of ae(a)){let m=Rr[l.component];if(l.per==="node"){zn(l,{[oe]:c.map(P=>P.kernel),[re]:S})||b(m,l.component==="minCount"?`'${d}' has ${c.length} value(s); minCount is ${a.minCount}.`:`'${d}' has ${c.length} value(s); maxCount is ${a.maxCount}.`);continue}for(let f of c){if((l.component==="pattern"||l.component==="minLength"||l.component==="maxLength")&&f.kind!=="string"){b(m,`'${d}' value is not a string; ${l.component} applies to string values.`,f);continue}zn(l,{v:f.kernel,[re]:S})||b(m,Kr(l,d,a,f),f)}}if(a.nodeKind)for(let l of c)xr(a.nodeKind,l)||b(_n,`'${d}' value is ${l.kind}; nodeKind requires ${a.nodeKind}.`,l);if(a.datatype)for(let l of c){let m=wr(a.datatype,l);m&&b(Rn,`'${d}' ${m}`,l)}if(a.classRef)for(let l of c){let m=Cr(n,a.classRef,l);m&&b(En,`'${d}' ${m}`,l)}}function Kr(n,e,o,t){let r=t.ref?u(t.ref):JSON.stringify(t.literal);switch(n.component){case"in":return`'${e}' value ${r} is not in the permitted set.`;case"pattern":return`'${e}' value ${r} does not match pattern ${o.pattern?.regex}.`;case"minLength":return`'${e}' value ${r} is shorter than minLength ${o.minLength}.`;case"maxLength":return`'${e}' value ${r} is longer than maxLength ${o.maxLength}.`;case"minInclusive":return`'${e}' value ${r} is below minInclusive ${o.minInclusive} (or not numeric).`;case"maxInclusive":return`'${e}' value ${r} is above maxInclusive ${o.maxInclusive} (or not numeric).`;default:return`'${e}' value ${r} violates ${n.component}.`}}function zn(n,e){let o=t=>{let r=t.varName;if(t.type==="kanonak.org/transformations/VarRef"&&typeof r=="string"&&r in e)return e[r];throw new yr(`Conformance lowering produced an unexpected leaf '${t.type}'`)};return kr(n.expr,void 0,o)===1}function xr(n,e){switch(n){case"IRI":return e.kind==="reference";case"BlankNode":return e.kind==="embedded";case"Literal":return e.kind==="string"||e.kind==="number"||e.kind==="boolean"}}function wr(n,e){if(e.kind==="reference"||e.kind==="embedded")return`value is a ${e.kind}; sh:datatype requires a literal of ${n.name}.`;let o=Ke(n);if(o!==void 0)switch(o){case V.Boolean:return e.kind==="boolean"?void 0:`value is not a boolean (${n.name}).`;case V.Integer:return e.kind!=="number"?`value is not a number (${n.name}).`:Number.isInteger(e.literal)?void 0:`value is not an integer (${n.name}).`;case V.Decimal:case V.Double:case V.Float:return e.kind==="number"?void 0:`value is not a number (${n.name}).`;default:return e.kind==="string"?void 0:`value is not a string-carried literal (${n.name}).`}}function Cr(n,e,o){if(o.kind!=="reference"||!o.ref)return`value is not a reference; sh:class requires an instance of ${e.name}.`;let t=u(e);if(n.reasoning)return n.reasoning.isInstanceOf(o.ref,e)?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`;let r=K(n.catalog,o.ref);return r instanceof g?ne(r).some(s=>u(s)===t||ee(n.catalog,s).some(i=>u(i)===t))?void 0:`value ${u(o.ref)} is not an instance of ${e.name}.`:`value ${u(o.ref)} does not resolve in this scope (sh:class ${e.name}).`}function vr(n,e,o,t,r){let a=new Set([...n.properties.map(i=>u(i.path)),...n.ignoredProperties.map(i=>u(i))]),s=new Set;for(let i of e.statement){let c=ie(i);if(!c)continue;let p=u(c.subject);a.has(p)||s.has(p)||(s.add(p),r.push(_e(n,o,t,Ee,`'${e.name}' carries undeclared property '${c.subject.name}' (closed shape).`,{resultPath:c.subject})))}for(let i of e.unresolvedPredicates)s.has(i.key)||(s.add(i.key),r.push(_e(n,o,t,Ee,`'${e.name}' carries unresolvable property '${i.key}' (closed shape).`,{value:i.key})))}import*as Le from"js-yaml";import{VersionOperator as Xn}from"@kanonak-protocol/types/document/models/enums";var Ir="0.0.0",A=class{constructor(e,o=new j,t){this.repository=e;this.parser=o;this.objectParser=t??new L(this.parser)}repository;parser;objectParser;imports(){return new T}serializeValue(e,o){return Zn(e,o)}async buildContentAddressed(e){let o=e.book.toImports(),t=await this.hashBody(e.publisher,o,e.body),r=Ae(t),a={type:"EphemeralPackage",publisher:e.publisher,imports:o};e.contentHashProperty&&(a[e.contentHashProperty]=t),Object.assign(a,e.header??{}),a.imports=o;let s={[r]:a,...e.body},i=this.dump(s);return{yaml:i,byteCount:Jn(i),contentHash:t,packageName:r,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let o=e.book.toImports(),t={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:o},r;e.contentHashProperty&&(r=await this.hashBody(e.publisher,o,e.body),t[e.contentHashProperty]=r),Object.assign(t,e.header??{}),t.imports=o;let a={[e.name]:t,...e.body},s=this.dump(a),i={yaml:s,byteCount:Jn(s),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return r!==void 0&&(i.contentHash=r),i}dump(e){return Le.dump(e,{lineWidth:-1})}async hashBody(e,o,t){let r={[Yn]:{type:"EphemeralPackage",publisher:e,imports:o},...t},a=this.parser.parse(Le.dump(r,{lineWidth:-1})),s=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new Q(a,this.repository))).filter(p=>p instanceof g&&p.namespace===s&&p.name!==Yn);for(let p of c)p.namespace="ephemeral";return we(c)}},Yn="__pkgbuilder_probe__";function Jn(n){return new TextEncoder().encode(n).length}function Ae(n){let e="sha256:",o=n.startsWith(e)?e.length:0;return`q-${n.slice(o,o+16)}`}var T=class{byKey=new Map;aliases=new Set;ensure(e,o,t,r,a=Xn.Major){let s=`${e}/${o}@${t}`,i=this.byKey.get(s);if(i)return i.alias;let c=this.uniqueAlias(r);return this.byKey.set(s,{publisher:e,package_:o,version:t,alias:c,match:a}),c}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,w(e.version),e.package_)}.${e.name}`}refLatest(e,o,t,r){return`${this.ensure(e,o,Ir,r??o,Xn.Any)}.${t}`}toImports(){let e=new Map;for(let t of this.byKey.values()){let r=e.get(t.publisher)??[];r.push(t),e.set(t.publisher,r)}return[...e.keys()].sort().map(t=>({publisher:t,packages:e.get(t).sort((r,a)=>r.package_<a.package_?-1:1).map(r=>({package:r.package_,match:de(r.match),version:r.version,alias:r.alias}))}))}uniqueAlias(e){let o=F(e)||"pkg",t=o,r=2;for(;this.aliases.has(t);)t=`${o}${r++}`;return this.aliases.add(t),t}};function Zn(n,e){if(n!=null){if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof k)return e.ref(n.subject);if(Array.isArray(n)){let o=n.map(t=>Zn(t,e)).filter(t=>t!==void 0);return o.length>0?o:void 0}if(n instanceof E)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(_r(n))throw new Error(`Value produced a bare URI without a version (${n.publisher}/${n.package_}/${n.name}); cannot serialize it as a reference.`)}}function F(n){return n.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function _r(n){return typeof n=="object"&&n!==null&&typeof n.publisher=="string"&&typeof n.package_=="string"&&typeof n.name=="string"}var Lr="1.1.0";async function Qn(n){let e=new A(n.repository),o=e.imports(),t=o.ensure(Y,J,Lr,"sh"),r=(i,c)=>i&&i.version&&typeof i.version.major=="number"?`${o.ensure(i.publisher,i.package_,w(i.version),i.package_)}.${i.name}`:c,a={},s=[];return n.result.results.forEach((i,c)=>{let p=`result-${c+1}`;s.push(p);let d={type:`${t}.ValidationResult`,[`${t}.focusNode`]:r(i.focusUri,i.focusNode),[`${t}.resultMessage`]:i.message,[`${t}.resultSeverity`]:`${t}.${i.severity}`,[`${t}.sourceConstraintComponent`]:`${t}.${i.constraintComponent.name}`};i.resultPath&&(d[`${t}.resultPath`]=r(i.resultPath,u(i.resultPath))),i.sourceShapeUri&&(d[`${t}.sourceShape`]=r(i.sourceShapeUri,i.sourceShape)),i.valueRef?d[`${t}.value`]=r(i.valueRef,u(i.valueRef)):i.value!==void 0&&(d[`${t}.value`]=i.value),a[p]=d}),a.report={type:`${t}.ValidationReport`,[`${t}.conforms`]:n.result.conforms,...s.length>0?{[`${t}.result`]:s}:{}},e.buildContentAddressed({publisher:n.publisher,book:o,body:a,...n.header!==void 0?{header:n.header}:{},contentHashProperty:"contentHash"})}import{VersionOperator as ji}from"@kanonak-protocol/types/document/models/enums";var se=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,o){return this.producers.find(t=>t.canProduce(e,o))}async produceCached(e,o,t,r){let a=`${o}/${t}@${w(r)}`,s=this.produced.get(a);if(s)return s;let{document:i}=await e.produce(o,t,r);return this.produced.set(a,i),i}async getHighestCompatibleVersionAsync(e,o){let t=this.producerFor(e,o.packageName);if(!t)return null;let r={operator:o.versionOperator,version:o.version},a=await t.resolveVersion(e,o.packageName,r);return a?this.produceCached(t,e,o.packageName,a):null}async getDocumentAsync(e){let o;try{o=Se(e)}catch{return null}if(o.kind!=="package"||!o.version)return null;let t=this.producerFor(o.publisher,o.package_);return t?this.produceCached(t,o.publisher,o.package_,o.version):null}async getDocumentsByNamespaceAsync(e,o){return Array.from(this.produced.values()).filter(t=>{let r=t.metadata.namespace_;return r!=null&&r.publisher===e&&r.package_===o})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,o){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var je={async authorize(){return{allowed:!0}}},Ve={async record(){}},B=class extends Error{constructor(o,t){let r=`${o.publisher}/${o.package_}${o.version?`@${o.version.major}.${o.version.minor}.${o.version.patch}`:""}`;super(`Not entitled to produce ${r}${t?`: ${t}`:""}`);this.address=o;this.reason=t;this.name="EntitlementDeniedError"}address;reason},ce=class{inner;ctx;policy;meter;constructor(e,o,t=je,r=Ve){this.inner=e,this.ctx=o,this.policy=t,this.meter=r}canProduce(e,o){return this.inner.canProduce(e,o)}async resolveVersion(e,o,t){return await this.assertAllowed({publisher:e,package_:o,version:t.version}),this.inner.resolveVersion(e,o,t)}async produce(e,o,t){let r={publisher:e,package_:o,version:t};await this.assertAllowed(r);let a=await this.inner.produce(e,o,t);return await this.meter.record(this.ctx,r,a),a}async assertAllowed(e){let o=await this.policy.authorize(this.ctx,e);if(!o.allowed)throw new B(e,o.reason)}};var R="kanonak.org",v="view",et="core-kanonak",Ar={publisher:R,package_:v,name:"rootView"},jr={publisher:R,package_:v,name:"bind"},Vr={publisher:R,package_:v,name:"produces"},Nr={publisher:R,package_:v,name:"projections"},Or={publisher:R,package_:v,name:"where"},$r={publisher:R,package_:v,name:"value"},Ur={publisher:R,package_:v,name:"as"},ue=class{constructor(e,o=new j){this.repository=e;this.parser=o;this.objectParser=new L(this.parser),this.builder=new A(this.repository,this.parser,this.objectParser)}repository;parser;objectParser;builder;async materialize(e,o={}){let t=await this.objectParser.parseKanonaks(this.repository),r=this.resolveView(t,e),a=y(r,jr);if(!a)throw new Error(`View ${r.namespace}/${r.name} declares no view.bind; cannot materialize.`);let s=y(r,Vr);if(!s)throw new Error(`View ${r.namespace}/${r.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=Dr(r),c=nt(t,R,et),p=nt(t,R,v),d=this.builder.imports(),S=d.ensure(R,et,c,"ck"),b=d.ensure(R,v,p,"v"),l=d.ref(s),m=new jn(this.repository,this.parser,this.objectParser),f=new An(m,t),P=this.readProjections(t,r),N=Tr(r,Or),O=this.findInstances(t,a,await this.reason(o)),Ne={},ot=new Set;for(let W of O){if(!await this.passesWhere(f,t,N,W))continue;let pe={type:l};for(let $e of P){let rt=await this.evaluateValue(f,t,$e.value,W),Ue=this.builder.serializeValue(tt(rt),d);Ue!==void 0&&(pe[d.ref($e.as)]=Ue)}let Oe=h(W);Oe&&(pe[`${b}.derivedFrom`]=d.ref(Oe)),Ne[this.rowName(W,ot)]=pe}let le={};o.resolvedAt&&(le[`${S}.resolvedAt`]=o.resolvedAt),o.invocationId&&(le[`${S}.id`]=o.invocationId);let U=await this.builder.buildContentAddressed({publisher:i,book:d,body:Ne,contentHashProperty:`${S}.contentHash`,header:le});return{yaml:U.yaml,contentHash:U.contentHash,packageName:U.packageName,publisher:U.publisher,rowCount:U.resourceCount}}resolveView(e,o){let t=K(e,o);if(!t)throw new Error(`View ${o.publisher}/${o.package_}/${o.name} not found in the catalog.`);let r=y(t,Ar);if(r){let a=K(e,r);if(!a)throw new Error(`ViewPackage ${o.name} names rootView ${r.name}, which is not in the catalog.`);return a}return t}readProjections(e,o){let t=[];for(let r of _(o,Nr)){let a=r instanceof E?r:r instanceof k?K(e,r.subject):void 0;if(!a)continue;let s=be(a,$r),i=y(a,Ur);s&&i&&t.push({value:s,as:i})}return t}async reason(e){return new H({profile:e.reasoningProfile??"owl-rl-classification"}).reason(this.repository)}findInstances(e,o,t){let r=Hr(e),a=[],s=new Set;for(let i of t.getInstancesOfClass(o)){if(s.has(i))continue;s.add(i);let c=r.get(i);c&&a.push(c)}return a.sort((i,c)=>{let p=M(h(i)),d=M(h(c));return p<d?-1:p>d?1:0}),a}async passesWhere(e,o,t,r){for(let a of t){let s=await this.evaluateValue(e,o,a,r);if(!Fr(s))return!1}return!0}async evaluateValue(e,o,t,r){let a=Ln(t,"view-projection",{catalog:o,depth:0}),s=new Map([["input",r]]);return e.evaluate(a,s)}rowName(e,o){let t=F(e.name)||"row",r=t,a=2;for(;o.has(r);)r=`${t}-${a++}`;return o.add(r),r}};function tt(n){return xe(n)?n.value:Array.isArray(n)?n.map(tt):n}function Dr(n){let e=h(n);if(!e)throw new Error(`Could not derive a publisher from view ${n.namespace}/${n.name}.`);return e.publisher}function nt(n,e,o){let t=Mr(n,e,o);if(!t)throw new Error(`Package ${e}/${o} is not in the catalog; it must be importable to materialize a view.`);return t}function Mr(n,e,o){let t;for(let r of n){if(!(r instanceof g))continue;let a=h(r);!a||a.publisher!==e||a.package_!==o||!a.version||(!t||z(a.version,t)>0)&&(t=a.version)}return t?w(t):void 0}function Hr(n){let e=new Map,o=new Map;for(let t of n){if(!(t instanceof g))continue;let r=h(t);if(!r||!r.version)continue;let a=M(r),s=o.get(a);(!s||z(r.version,s)>0)&&(o.set(a,r.version),e.set(a,t))}return e}function Tr(n,e){let o=be(n,e);return o?[o]:_(n,e).filter(t=>t instanceof E)}function Fr(n){return n===!0?!0:n===!1||n===void 0||n===null?!1:typeof n=="string"?n.length>0:typeof n=="number"?n!==0:xe(n)?n.value.length>0:Array.isArray(n)?n.length>0:!!n}export{Lo as AmbiguousReferenceRule,ye as BooleanStatement,or as CANONICAL_FORM_VERSION,V as Carrier,$o as ClassDefinitionRule,Ko as ClassHierarchyCycleRule,kt as CompositeKanonakDocumentRepository,ar as DEFAULT_CONSENT_BINDING_PARAM,jt as DefinedKanonak,er as DiamondNameClashRule,Do as DisplayLensScopeRule,ft as DocumentLocation,Yt as EdgeType,E as EmbeddedKanonak,Po as EmbeddedKanonakTypeRule,he as EmbeddedStatement,B as EntitlementDeniedError,ce as EntitlementProducer,mt as FileSystemKanonakDocumentRepository,to as GitIgnoreFilter,Jt as GraphBuilder,Ct as HttpKanonakDocumentRepository,De as INTEGRITY_PREFIX,T as ImportBook,Ro as ImportExistenceRule,me as InMemoryKanonakDocumentRepository,gt as KANONAK_USER_AGENT,At as Kanonak,ro as KanonakDocumentPositions,L as KanonakObjectParser,nr as KanonakObjectValidator,j as KanonakParser,Vt as KanonakUri,so as KanonakUriBuilder,co as KanonakUrlResolver,Ft as KanonakVocabulary,Fo as LINE_STYLES,ko as LinkTargetRule,q as ListStatement,D as LiteralKanonak,vt as LocalFirstRepository,It as LockAwareRepository,Yo as LookBandPathRule,Go as LookRenderer,Mo as LookSemanticSvgPathRule,Uo as MarkdownLinkRule,ge as MarkdownStatement,Io as NamespaceImportCycleRule,yo as NamespacePrefixRule,Xt as NodeType,ke as NumberStatement,ir as OAuthDiscovery,eo as OWL_RL_CLASSIFICATION_RULES,jo as ObjectPropertyValueValidationRule,po as OntologyValidationError,uo as OntologyValidationResult,Qo as OwlOneOfRule,A as PackageBuilder,bo as PackageHeaderRule,se as ProducerRepository,Vo as PropertyDomainRule,xo as PropertyHierarchyCycleRule,No as PropertyKindRangeConsistencyRule,oo as PropertyMetadata,Ao as PropertyRangeReferenceRule,wo as PropertyRangeRequiredRule,go as PropertyTypeSpecificityRule,Kt as PublisherConfigResolver,xt as PublisherIndex,Qt as RDFS_RULES,H as Reasoner,no as ReasoningResult,k as ReferenceKanonak,G as ReferenceStatement,ht as RepositoryFactory,Oo as ReservedNameShadowRule,ho as ResourceNamingRule,$t as ResourceResolver,Bt as ResourceTypeClassifier,J as SHACL_PACKAGE,Y as SHACL_PUBLISHER,Z as SH_NODE_SHAPE,ze as SH_PROPERTY_SHAPE,We as SH_SHAPE,Ot as ScalarStatement,Xo as SequenceNarrativeRule,Zo as ShaclShapeRule,Nt as Statement,fe as StringStatement,Co as SubClassOfReferenceRule,vo as SubPropertyOfReferenceRule,g as SubjectKanonak,So as SubjectKanonakTypeRequiredRule,ur as TokenCredentialProvider,Zt as TripleStore,Ho as TxExpressionCompilesRule,Jo as TxExpressionPathRule,Ut as TypeResolver,_o as UnresolvedPredicateRule,Eo as UnresolvedReferenceRule,fo as ValidationCache,mo as ValidationContext,lo as ValidationSeverity,ji as VersionOperator,ue as ViewMaterializer,je as allowAllPolicy,Pt as assertHttpsUrl,wt as assertPackageIdentity,Lt as buildLocalFirstRepository,zo as buildOntologyModel,Qn as buildReportPackageAsync,te as buildShapesModel,tr as canonicalForm,we as canonicalHash,Ke as carrierOf,_t as collectKanonakFiles,z as compareVersions,On as computeIntegrity,Te as computeIntegrityAsync,Ae as contentAddressedName,ne as contextTypesOf,cr as createCredentialedFetch,st as createVersion,Gn as evaluateConformance,qt as extractMarkdownLinks,lr as findDerivation,Gt as findMalformedReferences,io as findMarkdownLinkAt,Ie as foldFlagsIntoPattern,Dt as formatKanonakAddress,w as formatVersion,yt as getGlobalCachePath,bt as getKanonakUserAgent,ut as isCompatibleVersion,lt as isMajorCompatible,Rt as kanonakFetch,Vn as loadLockFile,ae as lowerConstraint,Mt as makeUriKey,Ve as noopMeter,rr as normalizeHost,sr as parseAuthChallenge,Se as parseKanonakAddress,Me as parseLockFile,ct as parseVersionString,ao as parseWithPositions,dt as pickHighestDocument,Wt as propertiesInScope,Bo as readSequenceConnectors,To as resolveDisplayValue,zt as resolvePropertyStep,F as sanitizeName,pt as satisfiesVersionOperator,Nn as saveLockFile,Un as scopeFromCatalog,Dn as scopeFromDocumentAsync,$n as scopeFromRepositoryAsync,He as serializeLockFile,Et as setKanonakFetchRetries,St as setKanonakUserAgent,h as subjectUri,ee as superClassChain,qo as supportedBandKeys,Ht as tripleKey,M as uriKey,Tt as uriTriple,at as versionOperatorFromChar,de as versionOperatorToChar,it as versionsEqual,Wo as walkSequence};
@@ -1,4 +1,6 @@
1
+ import type { Kanonak } from '../kanonaks/Kanonak.js';
1
2
  import { KanonakUri } from '../resolution/KanonakUri.js';
3
+ import { type ShaclConstraintIndex } from './ShaclConstraints.js';
2
4
  import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
3
5
  import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
4
6
  /** A reference to a class, by its durable canonical identity. */
@@ -106,6 +108,15 @@ export interface BuildOntologyModelOptions {
106
108
  /** Flatten inherited properties (from ancestors + rdfs.Resource) into each class. */
107
109
  includeInherited?: boolean;
108
110
  }
111
+ /** Properties scoped to a class, resolved to durable schema definitions. */
112
+ /**
113
+ * The resolved, constraint-enriched property set of one class, from a parsed
114
+ * catalog. The catalog-scoped core that {@link buildOntologyModel} maps over a
115
+ * document's classes — exported so a renderer holding a catalog (the look
116
+ * layer's EntityRelationship band) draws the same model a generator consumes,
117
+ * rather than re-deriving property kind, range, and cardinality on its own.
118
+ */
119
+ export declare function propertiesFor(catalog: Kanonak[], classUri: KanonakUri, includeInherited: boolean, shacl: ShaclConstraintIndex): PropertyDef[];
109
120
  /**
110
121
  * Build the resolved type-model of an ontology package.
111
122
  *
@@ -1,2 +1,2 @@
1
- export { buildOntologyModel } from './OntologyModel.js';
1
+ export { buildOntologyModel, propertiesFor } from './OntologyModel.js';
2
2
  export type { OntologyModel, ClassDef, PropertyDef, ClassRef, TypeRef, EnumDef, EnumMember, BuildOntologyModelOptions, } from './OntologyModel.js';
@@ -21,6 +21,8 @@
21
21
  * stylesheet format; TransformationEngine integration.
22
22
  */
23
23
  import { SubjectKanonak, EmbeddedKanonak, type Kanonak } from '../kanonaks/index.js';
24
+ /** nodeTier → the pixel size at which a node's responsive SemanticSvg shows that tier. */
25
+ export declare const DIAGRAM_TIER_SIZE: Record<string, number>;
24
26
  type Uri = {
25
27
  publisher: string;
26
28
  package_: string;
@@ -593,6 +595,41 @@ export declare class LookRenderer {
593
595
  */
594
596
  private renderDiagramDag;
595
597
  /** One node tile: its identity SVG as an `<image>`, linked, with a title. */
598
+ /** One message in a Sequence, after the prose walk. */
599
+ private static readonly SEQ_COL_GAP;
600
+ private static readonly SEQ_ROW;
601
+ private static readonly SEQ_PAD;
602
+ /** Resolve a URI to its subject, version-agnostically (highest first). */
603
+ private subjectFor;
604
+ /**
605
+ * Render a Sequence band. See the band's own comment in look@2.4.0 for the
606
+ * authoring contract. The walk itself — prose order, graph edges, connector
607
+ * overlay — is `walkSequence` in sequenceWalk.ts, shared with the
608
+ * SequenceNarrativeRule so validate-time findings and the drawing agree.
609
+ * What the walk cannot draw is reported here as HTML comments, so a page
610
+ * never silently shows less than the prose says.
611
+ *
612
+ * Layout is deterministic and DOM-free: identity tiles across the top,
613
+ * dashed lifelines, one row per message at a fixed pitch.
614
+ */
615
+ private renderSequence;
616
+ private static readonly ER_BOX_W;
617
+ private static readonly ER_HEAD_H;
618
+ private static readonly ER_ROW_H;
619
+ private static readonly ER_GAP;
620
+ private static readonly ER_PAD;
621
+ /** Classes in scope for an ER band: a Package page → every class it declares; a Class page → it plus the classes its object properties reach. */
622
+ private erScope;
623
+ /**
624
+ * Crow's-foot cardinality glyph at the range end of a relationship, from
625
+ * the constraints the closure states: min 0 → ring, min ≥1 → bar;
626
+ * max 1 → bar, unbounded → crow's foot. `owl.FunctionalProperty` reads as
627
+ * max 1 without SHACL. Drawn pointing along the line into the box.
628
+ */
629
+ private erCardinalityGlyph;
630
+ /** Where a line from (fx,fy) toward the centre of a box exits that box's border. */
631
+ private erBorderPoint;
632
+ private renderEntityRelationship;
596
633
  private diagramTile;
597
634
  /**
598
635
  * Render a StatRow band — a strip of labeled stats. `look.stats` is a
@@ -1,2 +1,3 @@
1
1
  export { LookRenderer, supportedBandKeys, type ResolvedLook, type TokenProvenance, type BaseStylesheetStatus, type StylesheetExplanation, } from './LookRenderer.js';
2
2
  export { resolveDisplayValue, type DisplayValue } from './displayValue.js';
3
+ export { walkSequence, readSequenceSource, readSequenceConnectors, readSequenceParticipants, edgeStyleFor, hasPropertyCharacteristic, LINE_STYLES, type LineStyle, type SequenceWalk, type SequenceMessage, type SequenceGap, type SequenceConnector, } from './sequenceWalk.js';
@@ -0,0 +1,94 @@
1
+ import type { Kanonak } from '../kanonaks/Kanonak.js';
2
+ import type { SubjectKanonak } from '../kanonaks/SubjectKanonak.js';
3
+ import type { DefinedKanonak } from '../kanonaks/DefinedKanonak.js';
4
+ import type { KanonakUri } from '../resolution/KanonakUri.js';
5
+ import { type EntityUri } from '../uri-helpers/index.js';
6
+ /** How an edge draws. Shared by every diagram band that draws edges. */
7
+ export type LineStyle = 'solid' | 'dotted' | 'open' | 'thick';
8
+ export declare const LINE_STYLES: ReadonlySet<string>;
9
+ export interface SequenceConnector {
10
+ /** The property that constitutes the message. */
11
+ readonly relation: KanonakUri;
12
+ /** Its subject in the catalog, when it resolves. */
13
+ readonly subject: SubjectKanonak | undefined;
14
+ /** The authored `lineStyle`, when present and one of {@link LINE_STYLES}. */
15
+ readonly declaredStyle: LineStyle | undefined;
16
+ /** The authored `lineStyle` text when it is NOT a supported value. */
17
+ readonly invalidStyle: string | undefined;
18
+ }
19
+ export interface SequenceMessage {
20
+ readonly from: SubjectKanonak;
21
+ readonly to: SubjectKanonak;
22
+ readonly relation: KanonakUri;
23
+ readonly style: LineStyle;
24
+ readonly undirected: boolean;
25
+ }
26
+ export interface SequenceGap {
27
+ /** The two participants the prose placed consecutively. */
28
+ readonly prev: SubjectKanonak;
29
+ readonly next: SubjectKanonak;
30
+ /** The connector the prose selected for the pair, if any. */
31
+ readonly selected: KanonakUri | undefined;
32
+ }
33
+ export interface SequenceWalk {
34
+ readonly messages: readonly SequenceMessage[];
35
+ /** Consecutive participant pairs joined by no declared connector. The graph is the filter — but a gap is usually drift between prose and graph. */
36
+ readonly gaps: readonly SequenceGap[];
37
+ /** Participants that took part in a message, in first-mention order (explicit `participants` first). */
38
+ readonly lifelines: readonly SubjectKanonak[];
39
+ /** How many participant mentions the prose made (a mention that resolves to a non-property resource). */
40
+ readonly mentions: number;
41
+ /** Prose references to a property that is NOT a declared connector — a selector that selects nothing. */
42
+ readonly strayPropertyRefs: readonly KanonakUri[];
43
+ /** True when the instance carries no value at all for the band's `source` — nothing to walk. */
44
+ readonly sourceAbsent: boolean;
45
+ /** Why the walk could not run, when the BAND is misconfigured. Never set for a data condition. */
46
+ readonly problem?: string;
47
+ }
48
+ /** The band's `source` property URI. */
49
+ export declare function readSequenceSource(band: DefinedKanonak): KanonakUri | undefined;
50
+ /**
51
+ * The band's `connectors`. Each is an embedded Connector carrying a `relation`
52
+ * and an optional `lineStyle`; the relation is resolved to its subject so the
53
+ * ontology's own structure can be consulted.
54
+ */
55
+ export declare function readSequenceConnectors(catalog: Kanonak[], band: DefinedKanonak): SequenceConnector[];
56
+ /** The band's explicit `participants`, resolved, in authored order. */
57
+ export declare function readSequenceParticipants(catalog: Kanonak[], band: DefinedKanonak): SubjectKanonak[];
58
+ /** Does this property subject carry an OWL characteristic — by identity, through the SDK's one `subClassOf` traversal. */
59
+ export declare function hasPropertyCharacteristic(catalog: Kanonak[], prop: SubjectKanonak, characteristic: EntityUri): boolean;
60
+ /**
61
+ * How an edge for `connector` draws — structure first, overlay second,
62
+ * default last:
63
+ * - owl.SymmetricProperty → undirected (no arrowhead), whatever else is set
64
+ * - a declared `lineStyle`
65
+ * - owl.inverseOf naming another connector's relation → `dotted` (a reply)
66
+ * - `solid`
67
+ */
68
+ export declare function edgeStyleFor(catalog: Kanonak[], connector: SequenceConnector, all: readonly SequenceConnector[]): {
69
+ style: LineStyle;
70
+ undirected: boolean;
71
+ };
72
+ /**
73
+ * Walk an instance's narrative against the band's connectors.
74
+ *
75
+ * 1. The `source` property's MarkdownStatement supplies `links` — every
76
+ * `[[reference]]`, resolved, in document order. Nothing is parsed here.
77
+ * 2. Each link is classified through the object model: a resource that
78
+ * `propertyClassOf` recognises as a property is an EDGE SELECTOR; any
79
+ * other resolved resource is a PARTICIPANT mention.
80
+ * 3. For each consecutive pair of participants, every candidate connector
81
+ * (all of them, or the one a selector named) that HOLDS in the graph is
82
+ * a message. Direction is the triple's, never the sentence's — but the
83
+ * sentence chooses WHICH true edge is meant: a call and its reply both
84
+ * hold between one pair, and "A asks B" wants A→B while "B answers A"
85
+ * wants B→A. So edges running in prose order are taken, and the opposite
86
+ * direction only when nothing runs forward. Every drawn edge exists in
87
+ * the graph either way.
88
+ * 4. Lifelines are the participants that took part in a message, in
89
+ * first-mention order; explicit `participants` come first and always get
90
+ * a lifeline.
91
+ */
92
+ export declare function walkSequence(catalog: Kanonak[], instance: SubjectKanonak, band: DefinedKanonak): SequenceWalk;
93
+ /** Identity of a participant for ordering and self-message detection. */
94
+ export declare function participantKey(s: SubjectKanonak): string;
@@ -129,6 +129,15 @@ export declare class KanonakObjectParser implements IKanonakObjectParser {
129
129
  * Matches the C# ResolveReference approach — uses ResourceResolver
130
130
  * to build full Kanonak URIs from names like "forest" or "rdfs.Class".
131
131
  */
132
+ /**
133
+ * A reference through a LINK import (typescript#111): `alias.name` where
134
+ * the alias names an import with `mode: link`. The target is addressed, not
135
+ * loaded — so the URI is built from the import declaration alone, with no
136
+ * fetch: versionless (a data link floats to latest) unless the author
137
+ * pinned the import with `=`. `LinkTargetRule` verifies it one hop out at
138
+ * validate time. Returns undefined when the reference is not a link.
139
+ */
140
+ private linkReference;
132
141
  private resolveReference;
133
142
  saveKanonaks(kanonaks: Kanonak[], documentRepository: IKanonakDocumentRepository): Promise<void>;
134
143
  serializeToYaml(kanonaks: Kanonak[], namespaceString: string): Promise<string>;
@@ -1 +1 @@
1
- import{a as c,b as d,c as e,d as f}from"../chunk-RJK6Y4HS.js";import{m as b}from"../chunk-SUXSCSHO.js";import{a}from"../chunk-KOWDHKBN.js";import"../chunk-BA4HAURJ.js";import"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
1
+ import{a as c,b as d,c as e,d as f}from"../chunk-BS7RRG7D.js";import{m as b}from"../chunk-PVUBHIU2.js";import{a}from"../chunk-HF5FJBS2.js";import"../chunk-7UYXTYXC.js";import"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{d as KanonakDocumentPositions,b as KanonakObjectParser,a as KanonakParser,c as PropertyMetadata,f as findMarkdownLinkAt,e as parseWithPositions};
@@ -1 +1 @@
1
- import{a as g,b as h,c as i,d as j,e as k}from"../chunk-GJAYU443.js";import"../chunk-SUXSCSHO.js";import"../chunk-KOWDHKBN.js";import{ca as e,da as f,e as a,f as b,g as c,i as d}from"../chunk-BA4HAURJ.js";import"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.js";import"../chunk-QILEJIFU.js";export{f as KanonakVocabulary,i as OWL_RL_CLASSIFICATION_RULES,h as RDFS_RULES,k as Reasoner,j as ReasoningResult,g as TripleStore,e as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
1
+ import{a as g,b as h,c as i,d as j,e as k}from"../chunk-EVMSO7HJ.js";import"../chunk-PVUBHIU2.js";import"../chunk-HF5FJBS2.js";import{ca as e,da as f,e as a,f as b,g as c,i as d}from"../chunk-7UYXTYXC.js";import"../chunk-CJMVIOZX.js";import"../chunk-FUUTGGJS.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{f as KanonakVocabulary,i as OWL_RL_CLASSIFICATION_RULES,h as RDFS_RULES,k as Reasoner,j as ReasoningResult,g as TripleStore,e as canonicalizeBuiltinUri,b as makeUriKey,c as tripleKey,a as uriKey,d as uriTriple};
@@ -1,6 +1,6 @@
1
1
  import { PublisherConfigResolver, type PublisherConfig } from './PublisherConfig.js';
2
2
  import type { AuthenticatedFetchFn } from '../auth/index.js';
3
- import { type LockFile } from '../lock/LockFile.js';
3
+ import { type LockFile, type LockEntry } from '../lock/LockFile.js';
4
4
  /**
5
5
  * The client for a publisher's SERVED metadata: its `.well-known/kanonak.json`
6
6
  * discovery config, its `kanonak.lock` (the resolution + integrity source for
@@ -20,6 +20,7 @@ export declare class PublisherIndex {
20
20
  private readonly configResolver;
21
21
  private readonly fetchFn;
22
22
  private readonly lockCache;
23
+ private readonly packageLockCache;
23
24
  constructor(options?: {
24
25
  configResolver?: PublisherConfigResolver;
25
26
  fetchFn?: AuthenticatedFetchFn;
@@ -36,5 +37,16 @@ export declare class PublisherIndex {
36
37
  * then resolve such packages by direct fetch.
37
38
  */
38
39
  getLock(publisher: string): Promise<LockFile | null>;
40
+ /**
41
+ * The package's own served lock — `https://{publisher}/{package}/kanonak.lock`
42
+ * — the SHARDED form of the root lock (typescript#111). A publisher with
43
+ * millions of packages cannot serve one lock for all of them (hundreds of
44
+ * megabytes before the first entity resolves), so the root lock is optional
45
+ * for such a publisher and each package carries its own pin at a URL that
46
+ * costs one small request. Same LockFile shape, one entry; returns that
47
+ * entry, or null when the package serves no lock. Fetched once per package
48
+ * and memoized like the root lock.
49
+ */
50
+ getPackageLockEntry(publisher: string, packageName: string): Promise<LockEntry | null>;
39
51
  private fetchLock;
40
52
  }
@@ -1 +1 @@
1
- import{h as e,m as r,n}from"../chunk-P5VQEDBS.js";import"../chunk-SC5M74NM.js";import{a as o}from"../chunk-6VIUXP4N.js";import"../chunk-KOWDHKBN.js";import"../chunk-QILEJIFU.js";export{n as HttpKanonakDocumentRepository,o as InMemoryKanonakDocumentRepository,e as PublisherConfigResolver,r as PublisherIndex};
1
+ import{h as e,m as r,n}from"../chunk-BZ3YTI3C.js";import"../chunk-SC5M74NM.js";import{a as o}from"../chunk-6VIUXP4N.js";import"../chunk-HF5FJBS2.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{n as HttpKanonakDocumentRepository,o as InMemoryKanonakDocumentRepository,e as PublisherConfigResolver,r as PublisherIndex};
@@ -27,4 +27,5 @@ export interface HttpCacheHooks {
27
27
  */
28
28
  export declare function buildLocalFirstRepository(workspaceRoot: string, parser?: KanonakParser, options?: {
29
29
  httpCache?: HttpCacheHooks;
30
+ offline?: boolean;
30
31
  }): Promise<IKanonakDocumentRepository>;
@@ -1 +1 @@
1
- import{a as b,b as c,c as d,d as e,e as f,f as k,g as l,h as m,i as n}from"../chunk-JFBPQN6T.js";import{g,h,m as i,n as j}from"../chunk-P5VQEDBS.js";import"../chunk-SC5M74NM.js";import{a}from"../chunk-6VIUXP4N.js";import"../chunk-KOWDHKBN.js";import"../chunk-QILEJIFU.js";export{d as CompositeKanonakDocumentRepository,c as DocumentLocation,b as FileSystemKanonakDocumentRepository,j as HttpKanonakDocumentRepository,a as InMemoryKanonakDocumentRepository,k as LocalFirstRepository,l as LockAwareRepository,h as PublisherConfigResolver,i as PublisherIndex,f as RepositoryFactory,n as buildLocalFirstRepository,m as collectKanonakFiles,g as defaultPublisherConfig,e as getGlobalCachePath};
1
+ import{a as b,b as c,c as d,d as e,e as f,f as k,g as l,h as m,i as n}from"../chunk-IS3AQKB4.js";import{g,h,m as i,n as j}from"../chunk-BZ3YTI3C.js";import"../chunk-SC5M74NM.js";import{a}from"../chunk-6VIUXP4N.js";import"../chunk-HF5FJBS2.js";import"../chunk-F67UH4FD.js";import"../chunk-QILEJIFU.js";export{d as CompositeKanonakDocumentRepository,c as DocumentLocation,b as FileSystemKanonakDocumentRepository,j as HttpKanonakDocumentRepository,a as InMemoryKanonakDocumentRepository,k as LocalFirstRepository,l as LockAwareRepository,h as PublisherConfigResolver,i as PublisherIndex,f as RepositoryFactory,n as buildLocalFirstRepository,m as collectKanonakFiles,g as defaultPublisherConfig,e as getGlobalCachePath};
@@ -33,6 +33,15 @@ export declare class ResourceTypeClassifier {
33
33
  publisher: string;
34
34
  package_: string;
35
35
  }): boolean;
36
+ /**
37
+ * Does ANY of the resource's declared types name the core term `name`?
38
+ * A resource may carry several types (punning: `[rdfs.Class, OlympicSport]`
39
+ * — a class that is also an instance, which Wikidata does for every sport,
40
+ * profession and gender identity; typescript#111). Reading only the first
41
+ * type made such an entity not-a-class, so it failed `subClassOf` and was
42
+ * refused as an `owl.oneOf` member. The classifier answers over all of them.
43
+ */
44
+ private static hasCoreType;
36
45
  static isClassType(resource: SubjectKanonak): boolean;
37
46
  static isDatatypeType(resource: SubjectKanonak): boolean;
38
47
  static isDatatypePropertyType(resource: SubjectKanonak): boolean;
@@ -19,6 +19,17 @@ export declare class TypeResolver {
19
19
  * differ only in how derivations render the surrounding text.
20
20
  */
21
21
  isSubstitutableDatatype(uri: KanonakUri | null | undefined): boolean;
22
+ /**
23
+ * The same question by URI alone, for callers that hold no resolver — a
24
+ * validation rule deciding whether a property's declared range can carry
25
+ * `[[references]]`. ONE definition of "prose datatype"; the instance method
26
+ * delegates here.
27
+ */
28
+ static isSubstitutableDatatypeUri(uri: {
29
+ publisher: string;
30
+ package_: string;
31
+ name: string;
32
+ } | null | undefined): boolean;
22
33
  isKnownXsdDatatypeName(typeName: string): boolean;
23
34
  isClassTypeAsync(typeName: string, currentDocument: KanonakDocument): Promise<boolean>;
24
35
  getPropertyTypeClassification(propertyType: string | null | undefined): string;
@@ -0,0 +1,26 @@
1
+ import type { Import, KanonakDocument } from '@kanonak-protocol/types/document/models/types';
2
+ /**
3
+ * The two things an import can be (typescript#111).
4
+ *
5
+ * A DEPENDENCY is schema: the classes a `type` names, the properties and their
6
+ * ranges, the `subClassOf` chain. A document is meaningless without them, they
7
+ * are in its closure, and a cycle among them is an error.
8
+ *
9
+ * A LINK is data: an object-property value pointing at a resource in another
10
+ * package. It must resolve to a URI and be dereferenceable on demand, but the
11
+ * document is complete without loading it. Links are NOT in the closure, are
12
+ * exempt from the import-cycle rule, resolve version-agnostically unless the
13
+ * author pins with `=`, and are verified one hop out — the target package,
14
+ * never its closure — by `LinkTargetRule`. Any graph with mutual references
15
+ * (spouse ↔ spouse, part ↔ whole) is representable only this way.
16
+ *
17
+ * THE one place the distinction is read. Every seam that walks imports —
18
+ * resolver, closure, cycle rule, existence rule, the reference rules — asks
19
+ * this predicate rather than reading `mode` itself.
20
+ */
21
+ export declare const IMPORT_MODES: readonly ["dependency", "link"];
22
+ export type ImportMode = (typeof IMPORT_MODES)[number];
23
+ /** True when the import is a data LINK rather than a schema dependency. */
24
+ export declare function isLinkImport(import_: Import): boolean;
25
+ /** The `publisher/package` keys this document LINKS (not depends on). */
26
+ export declare function linkedPackages(document: KanonakDocument): Set<string>;
@@ -1,4 +1,5 @@
1
1
  export { ResourceResolver } from './ResourceResolver.js';
2
+ export { isLinkImport, linkedPackages, IMPORT_MODES, type ImportMode } from './importMode.js';
2
3
  export type { ILogger } from './ResourceResolver.js';
3
4
  export { assertPackageIdentity } from './assertPackageIdentity.js';
4
5
  export { KanonakUri } from './KanonakUri.js';
@@ -1 +1 @@
1
- import{a as C}from"../chunk-PEB52US5.js";import{a as l}from"../chunk-SC5M74NM.js";import{a as D}from"../chunk-PEJALHXK.js";import{a as n,b as o,c as p,d as q,ea as r,fa as s,ga as t,ha as u,ia as v,ja as w,ka as x,la as y,ma as z,na as A,oa as B}from"../chunk-BA4HAURJ.js";import"../chunk-N3XODYH5.js";import{a as m}from"../chunk-FUUTGGJS.js";import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-QILEJIFU.js";export{m as KanonakUri,C as KanonakUriBuilder,D as KanonakUrlResolver,n as ResourceResolver,s as ResourceTypeClassifier,o as TypeResolver,l as assertPackageIdentity,c as compareVersions,B as contextTypesOf,r as corePropertyClassOf,f as createVersion,q as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,y as isDatatypePropertySubject,i as isMajorCompatible,x as isObjectPropertySubject,w as isPropertySubject,p as parseKanonakAddress,g as parseVersionString,k as pickHighestDocument,z as propertiesInScope,v as propertyClassOf,A as resolvePropertyStep,j as satisfiesVersionOperator,t as subjectUri,u as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
1
+ import{a as F}from"../chunk-XK24CN3C.js";import{a as o}from"../chunk-SC5M74NM.js";import{a as G}from"../chunk-PEJALHXK.js";import{a as q,b as r,c as s,d as t,ea as u,fa as v,ga as w,ha as x,ia as y,ja as z,ka as A,la as B,ma as C,na as D,oa as E}from"../chunk-7UYXTYXC.js";import"../chunk-CJMVIOZX.js";import{a as p}from"../chunk-FUUTGGJS.js";import{a as l,b as m,c as n}from"../chunk-F67UH4FD.js";import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-QILEJIFU.js";export{l as IMPORT_MODES,p as KanonakUri,F as KanonakUriBuilder,G as KanonakUrlResolver,q as ResourceResolver,v as ResourceTypeClassifier,r as TypeResolver,o as assertPackageIdentity,c as compareVersions,E as contextTypesOf,u as corePropertyClassOf,f as createVersion,t as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,B as isDatatypePropertySubject,m as isLinkImport,i as isMajorCompatible,A as isObjectPropertySubject,z as isPropertySubject,n as linkedPackages,s as parseKanonakAddress,g as parseVersionString,k as pickHighestDocument,C as propertiesInScope,y as propertyClassOf,D as resolvePropertyStep,j as satisfiesVersionOperator,w as subjectUri,x as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
@@ -1,4 +1,4 @@
1
- import"../chunk-PEB52US5.js";import"../chunk-SC5M74NM.js";import{d as g}from"../chunk-TW7NJDMW.js";import"../chunk-6VIUXP4N.js";import"../chunk-SUXSCSHO.js";import"../chunk-KOWDHKBN.js";import"../chunk-PEJALHXK.js";import{ga as m,oa as S}from"../chunk-BA4HAURJ.js";import{c as v,m as p,t as E}from"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.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-Z5Y4MCW5.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-D66LUZDB.js";import{a as be,d as X,f as Se,h as ee}from"../chunk-JFBPQN6T.js";import{e as ve,g as $e,m as U,n as Z}from"../chunk-P5VQEDBS.js";import"../chunk-PEB52US5.js";import"../chunk-SC5M74NM.js";import{a as H,b as G}from"../chunk-BRCVOR7A.js";import{j as te}from"../chunk-TW7NJDMW.js";import{a as ye}from"../chunk-6VIUXP4N.js";import{m as oe}from"../chunk-SUXSCSHO.js";import{a as O}from"../chunk-KOWDHKBN.js";import{a as xe}from"../chunk-PEJALHXK.js";import{c as Re}from"../chunk-BA4HAURJ.js";import{c as we,u as re}from"../chunk-N3XODYH5.js";import"../chunk-FUUTGGJS.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-Z5Y4MCW5.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(`