@kanonak-protocol/sdk 5.13.0 → 5.14.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 (35) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/{chunk-IHB7UVEH.js → chunk-4PY3JJH3.js} +4 -4
  3. package/dist/{chunk-S6VSAKXB.js → chunk-5NH5XDGO.js} +1 -1
  4. package/dist/{chunk-EZSHR3CB.js → chunk-LYSCTQC2.js} +1 -1
  5. package/dist/chunk-MK6UVFOJ.js +2 -0
  6. package/dist/chunk-Q6XQ5IXW.js +63 -0
  7. package/dist/chunk-SVUMCLK5.js +1 -0
  8. package/dist/chunk-V6KIDED2.js +1 -0
  9. package/dist/chunk-YW6P24RF.js +1 -0
  10. package/dist/{chunk-TVSHIXLA.js → chunk-ZQAAF3GB.js} +1 -1
  11. package/dist/index.js +1 -1
  12. package/dist/kanonaks/walkDefinedKanonaks.d.ts +22 -0
  13. package/dist/parsing/KanonakObjectParser.d.ts +22 -0
  14. package/dist/parsing/index.js +1 -1
  15. package/dist/reasoning/index.js +1 -1
  16. package/dist/resolution/ResourceTypeClassifier.d.ts +24 -0
  17. package/dist/resolution/TypeDirectedResolver.d.ts +37 -0
  18. package/dist/resolution/index.d.ts +3 -2
  19. package/dist/resolution/index.js +1 -1
  20. package/dist/search/index.js +1 -1
  21. package/dist/server/index.js +1 -1
  22. package/dist/transformations/index.js +1 -1
  23. package/dist/uri-helpers/index.js +1 -1
  24. package/dist/validation/documentModel.d.ts +2 -15
  25. package/dist/validation/index.js +1 -1
  26. package/dist/validation/rules/repository/PropertyRangeRequiredRule.d.ts +4 -0
  27. package/dist/validation/rules/repository/SubPropertyOfReferenceRule.d.ts +4 -2
  28. package/package.json +2 -2
  29. package/dist/chunk-4SQZBFJJ.js +0 -2
  30. package/dist/chunk-6U26UASC.js +0 -1
  31. package/dist/chunk-7BHDZHJY.js +0 -1
  32. package/dist/chunk-7K5TAJ44.js +0 -63
  33. package/dist/chunk-GZPLWII7.js +0 -1
  34. package/dist/chunk-MX3DEXMV.js +0 -1
  35. package/dist/chunk-ZP6P7HNU.js +0 -1
@@ -9,9 +9,10 @@ export { KanonakUrlResolver } from './KanonakUrlResolver.js';
9
9
  export type { UrlAddress, PublisherUrlAddress, PackageUrlAddress, ResourceUrlAddress, VersionSpec, UrlForm, } from './KanonakUrlResolver.js';
10
10
  export type { ResourceResolutionResult } from './ResourceResolutionResult.js';
11
11
  export { TypeResolver } from './TypeResolver.js';
12
- export { propertiesInScope, resolvePropertyStep, contextTypesOf, subjectUri, superClassChain, } from './TypeDirectedResolver.js';
12
+ export { propertiesInScope, resolvePropertyStep, contextTypesOf, subjectUri, superClassChain, propertyClassOf, isPropertySubject, isObjectPropertySubject, isDatatypePropertySubject, } from './TypeDirectedResolver.js';
13
13
  export type { PropertyDescriptor, PropertyKind, StepResolution } from './TypeDirectedResolver.js';
14
- export { ResourceTypeClassifier } from './ResourceTypeClassifier.js';
14
+ export { ResourceTypeClassifier, corePropertyClassOf } from './ResourceTypeClassifier.js';
15
+ export type { PropertyClassKind } from './ResourceTypeClassifier.js';
15
16
  export { findInstancesByType } from './InstanceSearch.js';
16
17
  export type { InstanceSearchResult } from './InstanceSearch.js';
17
18
  export { compareVersions, versionsEqual, formatVersion, parseVersionString, createVersion, isCompatibleVersion, isMajorCompatible, pickHighestDocument, versionOperatorFromChar, versionOperatorToChar, } from './VersionUtils.js';
@@ -1 +1 @@
1
- import{a as p,b as y}from"../chunk-PEUTCG3B.js";import{a as s}from"../chunk-PEJALHXK.js";import{a as k}from"../chunk-SC5M74NM.js";import{a as o,b as q,c as r,d as t,e as u,f as v,g as w,h as x}from"../chunk-ZP6P7HNU.js";import"../chunk-6U26UASC.js";import{a as m,b as n}from"../chunk-GZPLWII7.js";import"../chunk-7BHDZHJY.js";import{a as l}from"../chunk-FUUTGGJS.js";import{a,b,c,d,e,f,g,h,i,j}from"../chunk-2ACBWC7K.js";export{l as KanonakUri,p as KanonakUriBuilder,s as KanonakUrlResolver,m as ResourceResolver,o as ResourceTypeClassifier,n as TypeResolver,k as assertPackageIdentity,c as compareVersions,x as contextTypesOf,f as createVersion,y as findInstancesByType,r as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,i as isMajorCompatible,q as parseKanonakAddress,g as parseVersionString,j as pickHighestDocument,v as propertiesInScope,w as resolvePropertyStep,t as subjectUri,u as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
1
+ import{a as B,b as D}from"../chunk-PEUTCG3B.js";import{a as C}from"../chunk-PEJALHXK.js";import{a as k}from"../chunk-SC5M74NM.js";import{a as m,b as n,c as o,d as p,n as q,o as r,p as s,q as t,r as u,s as v,t as w,u as x,v as y,w as z,x as A}from"../chunk-SVUMCLK5.js";import"../chunk-YW6P24RF.js";import{a as l}from"../chunk-FUUTGGJS.js";import{a,b,c,d,e,f,g,h,i,j}from"../chunk-2ACBWC7K.js";export{l as KanonakUri,B as KanonakUriBuilder,C as KanonakUrlResolver,m as ResourceResolver,r as ResourceTypeClassifier,n as TypeResolver,k as assertPackageIdentity,c as compareVersions,A as contextTypesOf,q as corePropertyClassOf,f as createVersion,D as findInstancesByType,p as formatKanonakAddress,e as formatVersion,h as isCompatibleVersion,x as isDatatypePropertySubject,i as isMajorCompatible,w as isObjectPropertySubject,v as isPropertySubject,o as parseKanonakAddress,g as parseVersionString,j as pickHighestDocument,y as propertiesInScope,u as propertyClassOf,z as resolvePropertyStep,s as subjectUri,t as superClassChain,a as versionOperatorFromChar,b as versionOperatorToChar,d as versionsEqual};
@@ -1,4 +1,4 @@
1
- import{a as g}from"../chunk-IHB7UVEH.js";import"../chunk-QHABFCRC.js";import"../chunk-4NO7MHS7.js";import"../chunk-PEUTCG3B.js";import"../chunk-PEJALHXK.js";import"../chunk-SC5M74NM.js";import"../chunk-MX3DEXMV.js";import"../chunk-NJ3AZYQD.js";import{d as m,h as S}from"../chunk-ZP6P7HNU.js";import"../chunk-6U26UASC.js";import"../chunk-GZPLWII7.js";import{c as v,m as p,r as E}from"../chunk-7BHDZHJY.js";import"../chunk-FUUTGGJS.js";import{c as x}from"../chunk-2ACBWC7K.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{a as g}from"../chunk-4PY3JJH3.js";import"../chunk-QHABFCRC.js";import"../chunk-4NO7MHS7.js";import"../chunk-PEUTCG3B.js";import"../chunk-PEJALHXK.js";import"../chunk-SC5M74NM.js";import"../chunk-V6KIDED2.js";import"../chunk-NJ3AZYQD.js";import{p as m,x as S}from"../chunk-SVUMCLK5.js";import{c as v,m as p,r as E}from"../chunk-YW6P24RF.js";import"../chunk-FUUTGGJS.js";import{c as x}from"../chunk-2ACBWC7K.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 we}from"../chunk-L2KE7B3K.js";import{j as te}from"../chunk-IHB7UVEH.js";import"../chunk-QHABFCRC.js";import{a as fe,d as Q,f as be,h as Z}from"../chunk-CC44JAOT.js";import{e as ke,g as ye,j as G,k as X}from"../chunk-UXYCUGSF.js";import{a as me}from"../chunk-4NO7MHS7.js";import"../chunk-PEUTCG3B.js";import{a as $e}from"../chunk-PEJALHXK.js";import"../chunk-SC5M74NM.js";import{a as q,b as z}from"../chunk-ITKOKDBG.js";import{l as re}from"../chunk-MX3DEXMV.js";import{a as O}from"../chunk-NJ3AZYQD.js";import{b as Se}from"../chunk-ZP6P7HNU.js";import"../chunk-6U26UASC.js";import"../chunk-GZPLWII7.js";import{c as ve,s as ee}from"../chunk-7BHDZHJY.js";import"../chunk-FUUTGGJS.js";import{c as L,e as D,f as H,g as he}from"../chunk-2ACBWC7K.js";import{readFileSync as ie,writeFileSync as je,mkdirSync as Ce}from"fs";import{join as oe}from"path";import Fe from"js-yaml";var Re=[{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 U(t){return Re}function F(t){return`${t.publisher}/${t.package_}`}function Y(t){let e={"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"},s=[];for(let r of t)if(r.origin==="missing"){let i=F(r),o=e[i]??"whatever this package contributes to rendering is lost";s.push(`Render-stack package ${i} is MISSING (${r.reason??"unknown reason"}) \u2014 ${o}. Fix: kanonak install ${i} (as the user running the render), or restore network access to ${r.publisher}.`)}else r.resolvedButNotInCatalog&&s.push(`Render-stack package ${F(r)} resolved (${r.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);return s}function ne(t){let{publisher:e,availablePublishers:s,catalog:r,lookRenderer:i,localNamespaces:o,rawByNsKey:m,renderStack:p,producers:k,lockSource:c,configSource:h}=t,n=new Map,g=new Map,w=new Map,v=new Set;for(let $ of r){if(!($ instanceof ve))continue;let R=$.namespace||"";if(!o.has(R))continue;n.set(`${R}/${$.name}`,$);let _=R.split("/")[1]??"",[j,N]=_.split("@");if(!j||!N)continue;let K=he(N);K&&(v.has(_)||(v.add(_),g.has(j)||g.set(j,[]),g.get(j).push({verStr:N,version:K})),$.name===j&&w.set(_,$))}for(let $ of g.values())$.sort((R,_)=>L(_.version,R.version));return{publisher:e,availablePublishers:s,catalog:r,lookRenderer:i,localNamespaces:o,rawByNsKey:m,bySubject:n,pkgVersions:g,pkgSelfByVer:w,renderStack:p,...k?{producers:k}:{},...c?{lockSource:c}:{},...h?{configSource:h}:{}}}async function ce(t,e={}){let s=new O,r=new me(s),i=[],o=[];for(let l of Z(t)){let u;try{u=ie(l,"utf-8")}catch{continue}let y;try{y=s.parse(u).metadata?.namespace_}catch{continue}if(!y?.version)continue;let I=y.version;o.push({publisher:y.publisher,package_:y.package_,verStr:D(I),version:I,source:u})}o.sort((l,u)=>L(u.version,l.version));for(let l of o)await r.saveDocumentAsync(s.parse(l.source),`${l.publisher}/${l.package_}@${l.verStr}`),i.push({publisher:l.publisher,package_:l.package_,verStr:l.verStr,source:l.source});let m=[...new Set(i.map(l=>l.publisher))].sort(),p=e.publisher;if(p){if(!m.includes(p))throw new Error(`Publisher "${p}" not found in workspace. Available: ${m.join(", ")||"(none)"}`)}else if(m.length===1)p=m[0];else throw m.length===0?new Error(`No Kanonak packages found under ${t}`):new Error(`Workspace has multiple publishers (${m.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let k=new Set,c=new Map;for(let l of i)l.publisher===p&&(k.add(`${l.publisher}/${l.package_}@${l.verStr}`),c.set(`${l.package_}@${l.verStr}`,l.source));let h=Q(),n=new fe(h,!0,s),g={};e.httpCache&&(g.getFromCache=e.httpCache.getFromCache,g.onFetch=e.httpCache.onFetch),e.fetchFn&&(g.fetchFn=e.fetchFn);let w=e.repository??new be(r,n,new X(g)),v=e.log??(()=>{}),$=U(void 0),R=[],_=l=>l.map(u=>u.metadata.namespace_?.version).filter(u=>u!==void 0).sort((u,y)=>L(y,u)).map(D);if(!e.repository){v(`[render-stack] resolving ${$.length} ambient look-stack package(s); cache: ${h}`);let l=e.fetchFn?new G({fetchFn:e.fetchFn}):new G;for(let u of $){let y=F(u),I=await r.getDocumentsByNamespaceAsync(u.publisher,u.package_);if(I.length>0){let d=_(I);R.push({...u,origin:"workspace",versions:d}),v(`[render-stack] ${y} \u2014 workspace (${d.join(", ")})`);continue}let a=await n.getDocumentsByNamespaceAsync(u.publisher,u.package_);if(a.length>0){let d=_(a);R.push({...u,origin:"cache",versions:d}),v(`[render-stack] ${y} \u2014 cache (${d.join(", ")})`);continue}try{let f=(await l.getLock(u.publisher))?.packages[`${u.publisher}/${u.package_}`];if(!f){let C=`publisher ${u.publisher} reachable but its lock does not pin ${u.package_}`;R.push({...u,origin:"missing",reason:C}),v(`[render-stack] ${y} \u2014 MISSING: ${C}`);continue}let S=f.version,b=f.resolved,E=await(e.fetchFn?e.fetchFn(b,u.publisher):ke(b));if(!E.ok){let C=`fetch ${b} failed: HTTP ${E.status} ${E.statusText}`;R.push({...u,origin:"missing",reason:C}),v(`[render-stack] ${y} \u2014 MISSING: ${C}`);continue}let ge=await E.text();await r.saveDocumentAsync(s.parse(ge),`${u.publisher}/${u.package_}@${S}`);try{let C=oe(h,u.publisher);Ce(C,{recursive:!0}),je(oe(C,`${u.package_}@${S}.kan.yml`),ge,"utf-8"),R.push({...u,origin:"fetched",versions:[S]}),v(`[render-stack] ${y}@${S} \u2014 fetched from ${b}, installed to cache`)}catch(C){R.push({...u,origin:"fetched",versions:[S]}),v(`[render-stack] ${y}@${S} \u2014 fetched from ${b}, but cache ${h} is NOT WRITABLE (${C.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(d){let f=`fetch failed: ${d.message}`;R.push({...u,origin:"missing",reason:f}),v(`[render-stack] ${y} \u2014 MISSING: ${f}`)}}}let j=w;if(!e.repository){let l=(await r.getAllDocumentsAsync()).filter(y=>y.metadata.namespace_?.publisher===p),u=await q(l,w);for(let y of $)u.add(F(y));j=new z(w,u)}let N=await new re(s).parseKanonaks(j),K=new te(N),T=(l,u)=>ee(N,{publisher:l,package_:u,name:u}).length>0,V;if(e.repository){V=[];for(let l of $){let u=await w.getDocumentsByNamespaceAsync(l.publisher,l.package_);V.push(u.length>0?{...l,origin:"repository",versions:_(u)}:{...l,origin:"missing",reason:"not present in the caller-supplied repository"})}}else V=R.map(l=>l.origin==="missing"||T(l.publisher,l.package_)?l:{...l,resolvedButNotInCatalog:!0});let J=Y(V);for(let l of J)v(`[render-stack] WARNING: ${l}`);let W={contractSource:"universal-default",cachePath:h,packages:V,warnings:J},B;try{B=ie(oe(t,"kanonak.lock"),"utf-8")}catch{B=Ne(p,i,s)}let A;try{A=ie(oe(t,".well-known","kanonak.json"),"utf-8")}catch{A=void 0}return ne({publisher:p,availablePublishers:m,catalog:N,lookRenderer:K,localNamespaces:k,rawByNsKey:c,renderStack:W,...B?{lockSource:B}:{},...A?{configSource:A}:{}})}function Ne(t,e,s){let r=new Map;for(let o of e)o.publisher===t&&(r.has(o.package_)||r.set(o.package_,{verStr:o.verStr,source:o.source}));if(r.size===0)return;let i={};for(let o of[...r.keys()].sort()){let{verStr:m,source:p}=r.get(o),k={},c;try{c=s.parse(p).metadata?.imports}catch{c=void 0}for(let n of c?.[t]??[]){let g=r.get(n.packageName);g&&(k[`${t}/${n.packageName}`]=g.verStr)}let h={};for(let n of Object.keys(k).sort())h[n]=k[n];i[`${t}/${o}`]={version:m,resolved:`https://${t}/${o}/${m}.kan.yml`,integrity:we(p),dependencies:h}}return Fe.dump({version:"1",lastUpdated:"",packages:i},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as Me,readFileSync as Ie,writeFileSync as De,mkdirSync as Ke}from"fs";import{join as xe}from"path";async function le(t,e={}){let s=new O,r=Se(t),i=r.kind==="resource"?r.uri.publisher:r.publisher,o=e.log??(()=>{}),m=e.cacheRoot??Q(),p=(a,d,f)=>xe(m,a,`${d}@${f}.kan.yml`),k=new Set,c=new Set,h=new Map,n=new X({getFromCache:(a,d,f)=>{let S=p(a,d,f),b=Me(S)?Ie(S,"utf-8"):null;return b!==null&&k.add(`${a}/${d}`),b},onFetch:(a,d,f,S)=>{c.add(`${a}/${d}`);try{let b=xe(m,a);Ke(b,{recursive:!0}),De(p(a,d,f),S,"utf-8")}catch(b){h.set(`${a}/${d}`,b.message),o(`[render] fetched ${a}/${d}@${f} but cache ${m} is NOT WRITABLE (${b.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),g=new G(e.fetchFn?{fetchFn:e.fetchFn}:void 0),w;if(r.kind==="resource"){let a=r.uri.version;w=[a?{package_:r.uri.package_,version:`${a.major}.${a.minor}.${a.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let a=r.version;w=[a?{package_:r.package_,version:`${a.major}.${a.minor}.${a.patch}`}:{package_:r.package_}]}else w=((await g.getConfig(i)).featured_packages??[]).map(d=>({package_:d}));let v=async(a,d,f)=>{try{let S=f?s.buildImport(d,"=",f,a):s.buildImport(d,"*","0.0.0",a),b=await n.getHighestCompatibleVersionAsync(a,S);return b?{doc:b}:{doc:null,error:`${a} did not resolve ${d}${f?`@${f}`:""} (not in its index, or unreachable)`}}catch(S){return{doc:null,error:S.message}}},$=[],R=[];for(let a of w){let{doc:d,error:f}=await v(i,a.package_,a.version);d?$.push(d):f&&R.push(f)}if($.length===0)throw new Error(`Could not fetch any package for address "${t}" from publisher "${i}".`+(R.length>0?` Reasons: ${R.join("; ")}`:""));let _=U(),j="universal-default",N=a=>a.map(d=>d.metadata.namespace_?.version).filter(d=>d!==void 0).sort((d,f)=>L(f,d)).map(D);o(`[render-stack] resolving ${_.length} ambient look-stack package(s) (contract: ${j}); cache: ${m}`);let K=[],T=[];for(let a of _){let d=F(a),{doc:f,error:S}=await v(a.publisher,a.package_,void 0);if(f){K.push(f);let b=N([f]),E=c.has(d)?"fetched":k.has(d)?"cache":"fetched";T.push({...a,origin:E,versions:b}),o(`[render-stack] ${d} \u2014 ${E} (${b.join(", ")})`+(h.has(d)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else T.push({...a,origin:"missing",reason:S??"unresolved"}),o(`[render-stack] ${d} \u2014 MISSING: ${S??"unresolved"}`)}let V=await q([...$,...K],n),J=new z(n,V),W=await new re(s).parseKanonaks(J),B=new te(W),A=T.map(a=>a.origin==="missing"||ee(W,{publisher:a.publisher,package_:a.package_,name:a.package_}).length>0?a:{...a,resolvedButNotInCatalog:!0}),l=Y(A);for(let a of l)o(`[render-stack] WARNING: ${a}`);let u={contractSource:j,cachePath:m,packages:A,warnings:l},y=new Set,I=new Map;for(let a of await n.getAllDocumentsAsync()){let d=a.metadata.namespace_;if(!d?.version||d.publisher!==i)continue;let f=D(d.version),S=`${d.publisher}/${d.package_}@${f}`;y.add(S);let b=await n.getDocumentContentAsync(S);b!==null&&I.set(`${d.package_}@${f}`,b)}return ne({publisher:i,availablePublishers:[i],catalog:W,lookRenderer:B,localNamespaces:y,rawByNsKey:I,renderStack:u})}import{VersionOperator as ae}from"@kanonak-protocol/types/document/models/enums";function se(t){let{lookRenderer:e,publisher:s,renderStack:r,catalog:i}=t,o=e.explainStylesheet(e.publisherSubject(s)),m=[...o.tokens.entries()].map(([n,g])=>({name:n,value:g.value,source:`${g.sourceNamespace}/${g.sourceName}`,level:g.level})),p=o.baseStylesheet,k={present:p.css!==void 0,...p.sourceNamespace!==void 0?{source:p.sourceNamespace}:{},...p.scope!==void 0?{scope:p.scope}:{},...p.css!==void 0?{bytes:p.css.length}:{},...p.problem!==void 0?{problem:p.problem}:{},candidates:p.candidates},c=new Map;for(let n of i){let g=n.namespace;g&&c.set(g,(c.get(g)??0)+1)}let h=[...c.entries()].map(([n,g])=>({namespace:n,resources:g})).sort((n,g)=>n.namespace.localeCompare(g.namespace));return{publisher:s,renderStack:{contractSource:r.contractSource,cachePath:r.cachePath,packages:r.packages.map(n=>({package_:F(n),origin:n.origin,...n.versions!==void 0?{versions:n.versions}:{},...n.reason!==void 0?{reason:n.reason}:{},...n.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:n.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:m,baseStylesheet:k,...o.look?{look:{sourceClass:`${o.look.sourceClass.publisher}/${o.look.sourceClass.package_}/${o.look.sourceClass.name}`}}:{}},catalog:h,warnings:[...r.warnings,...o.warnings.filter(n=>!r.warnings.includes(n))]}}function Ve(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function de(t){let e=Ve,s=t.warnings.length===0,r=t.warnings.length===0?'<p class="ok">\u2713 No problems detected \u2014 the render stack is fully resolved and pages should be styled.</p>':t.warnings.map(c=>`<div class="warn">\u26A0 ${e(c)}</div>`).join(`
1
+ import{c as we}from"../chunk-L2KE7B3K.js";import{j as te}from"../chunk-4PY3JJH3.js";import"../chunk-QHABFCRC.js";import{a as fe,d as Q,f as be,h as Z}from"../chunk-CC44JAOT.js";import{e as ke,g as ye,j as G,k as X}from"../chunk-UXYCUGSF.js";import{a as me}from"../chunk-4NO7MHS7.js";import"../chunk-PEUTCG3B.js";import{a as $e}from"../chunk-PEJALHXK.js";import"../chunk-SC5M74NM.js";import{a as q,b as z}from"../chunk-ITKOKDBG.js";import{m as re}from"../chunk-V6KIDED2.js";import{a as O}from"../chunk-NJ3AZYQD.js";import{c as Se}from"../chunk-SVUMCLK5.js";import{c as ve,s as ee}from"../chunk-YW6P24RF.js";import"../chunk-FUUTGGJS.js";import{c as L,e as D,f as H,g as he}from"../chunk-2ACBWC7K.js";import{readFileSync as ie,writeFileSync as je,mkdirSync as Ce}from"fs";import{join as oe}from"path";import Fe from"js-yaml";var Re=[{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 U(t){return Re}function F(t){return`${t.publisher}/${t.package_}`}function Y(t){let e={"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"},s=[];for(let r of t)if(r.origin==="missing"){let i=F(r),o=e[i]??"whatever this package contributes to rendering is lost";s.push(`Render-stack package ${i} is MISSING (${r.reason??"unknown reason"}) \u2014 ${o}. Fix: kanonak install ${i} (as the user running the render), or restore network access to ${r.publisher}.`)}else r.resolvedButNotInCatalog&&s.push(`Render-stack package ${F(r)} resolved (${r.origin}) but is NOT in the parsed catalog \u2014 this is a closure-scoping bug; please report it.`);return s}function ne(t){let{publisher:e,availablePublishers:s,catalog:r,lookRenderer:i,localNamespaces:o,rawByNsKey:m,renderStack:p,producers:k,lockSource:c,configSource:h}=t,n=new Map,g=new Map,w=new Map,v=new Set;for(let $ of r){if(!($ instanceof ve))continue;let R=$.namespace||"";if(!o.has(R))continue;n.set(`${R}/${$.name}`,$);let _=R.split("/")[1]??"",[j,N]=_.split("@");if(!j||!N)continue;let K=he(N);K&&(v.has(_)||(v.add(_),g.has(j)||g.set(j,[]),g.get(j).push({verStr:N,version:K})),$.name===j&&w.set(_,$))}for(let $ of g.values())$.sort((R,_)=>L(_.version,R.version));return{publisher:e,availablePublishers:s,catalog:r,lookRenderer:i,localNamespaces:o,rawByNsKey:m,bySubject:n,pkgVersions:g,pkgSelfByVer:w,renderStack:p,...k?{producers:k}:{},...c?{lockSource:c}:{},...h?{configSource:h}:{}}}async function ce(t,e={}){let s=new O,r=new me(s),i=[],o=[];for(let l of Z(t)){let u;try{u=ie(l,"utf-8")}catch{continue}let y;try{y=s.parse(u).metadata?.namespace_}catch{continue}if(!y?.version)continue;let I=y.version;o.push({publisher:y.publisher,package_:y.package_,verStr:D(I),version:I,source:u})}o.sort((l,u)=>L(u.version,l.version));for(let l of o)await r.saveDocumentAsync(s.parse(l.source),`${l.publisher}/${l.package_}@${l.verStr}`),i.push({publisher:l.publisher,package_:l.package_,verStr:l.verStr,source:l.source});let m=[...new Set(i.map(l=>l.publisher))].sort(),p=e.publisher;if(p){if(!m.includes(p))throw new Error(`Publisher "${p}" not found in workspace. Available: ${m.join(", ")||"(none)"}`)}else if(m.length===1)p=m[0];else throw m.length===0?new Error(`No Kanonak packages found under ${t}`):new Error(`Workspace has multiple publishers (${m.join(", ")}). Pass --publisher <domain> to choose which one to serve.`);let k=new Set,c=new Map;for(let l of i)l.publisher===p&&(k.add(`${l.publisher}/${l.package_}@${l.verStr}`),c.set(`${l.package_}@${l.verStr}`,l.source));let h=Q(),n=new fe(h,!0,s),g={};e.httpCache&&(g.getFromCache=e.httpCache.getFromCache,g.onFetch=e.httpCache.onFetch),e.fetchFn&&(g.fetchFn=e.fetchFn);let w=e.repository??new be(r,n,new X(g)),v=e.log??(()=>{}),$=U(void 0),R=[],_=l=>l.map(u=>u.metadata.namespace_?.version).filter(u=>u!==void 0).sort((u,y)=>L(y,u)).map(D);if(!e.repository){v(`[render-stack] resolving ${$.length} ambient look-stack package(s); cache: ${h}`);let l=e.fetchFn?new G({fetchFn:e.fetchFn}):new G;for(let u of $){let y=F(u),I=await r.getDocumentsByNamespaceAsync(u.publisher,u.package_);if(I.length>0){let d=_(I);R.push({...u,origin:"workspace",versions:d}),v(`[render-stack] ${y} \u2014 workspace (${d.join(", ")})`);continue}let a=await n.getDocumentsByNamespaceAsync(u.publisher,u.package_);if(a.length>0){let d=_(a);R.push({...u,origin:"cache",versions:d}),v(`[render-stack] ${y} \u2014 cache (${d.join(", ")})`);continue}try{let f=(await l.getLock(u.publisher))?.packages[`${u.publisher}/${u.package_}`];if(!f){let C=`publisher ${u.publisher} reachable but its lock does not pin ${u.package_}`;R.push({...u,origin:"missing",reason:C}),v(`[render-stack] ${y} \u2014 MISSING: ${C}`);continue}let S=f.version,b=f.resolved,E=await(e.fetchFn?e.fetchFn(b,u.publisher):ke(b));if(!E.ok){let C=`fetch ${b} failed: HTTP ${E.status} ${E.statusText}`;R.push({...u,origin:"missing",reason:C}),v(`[render-stack] ${y} \u2014 MISSING: ${C}`);continue}let ge=await E.text();await r.saveDocumentAsync(s.parse(ge),`${u.publisher}/${u.package_}@${S}`);try{let C=oe(h,u.publisher);Ce(C,{recursive:!0}),je(oe(C,`${u.package_}@${S}.kan.yml`),ge,"utf-8"),R.push({...u,origin:"fetched",versions:[S]}),v(`[render-stack] ${y}@${S} \u2014 fetched from ${b}, installed to cache`)}catch(C){R.push({...u,origin:"fetched",versions:[S]}),v(`[render-stack] ${y}@${S} \u2014 fetched from ${b}, but cache ${h} is NOT WRITABLE (${C.message}); usable for this load only \u2014 every load will re-fetch it`)}}catch(d){let f=`fetch failed: ${d.message}`;R.push({...u,origin:"missing",reason:f}),v(`[render-stack] ${y} \u2014 MISSING: ${f}`)}}}let j=w;if(!e.repository){let l=(await r.getAllDocumentsAsync()).filter(y=>y.metadata.namespace_?.publisher===p),u=await q(l,w);for(let y of $)u.add(F(y));j=new z(w,u)}let N=await new re(s).parseKanonaks(j),K=new te(N),T=(l,u)=>ee(N,{publisher:l,package_:u,name:u}).length>0,V;if(e.repository){V=[];for(let l of $){let u=await w.getDocumentsByNamespaceAsync(l.publisher,l.package_);V.push(u.length>0?{...l,origin:"repository",versions:_(u)}:{...l,origin:"missing",reason:"not present in the caller-supplied repository"})}}else V=R.map(l=>l.origin==="missing"||T(l.publisher,l.package_)?l:{...l,resolvedButNotInCatalog:!0});let J=Y(V);for(let l of J)v(`[render-stack] WARNING: ${l}`);let W={contractSource:"universal-default",cachePath:h,packages:V,warnings:J},B;try{B=ie(oe(t,"kanonak.lock"),"utf-8")}catch{B=Ne(p,i,s)}let A;try{A=ie(oe(t,".well-known","kanonak.json"),"utf-8")}catch{A=void 0}return ne({publisher:p,availablePublishers:m,catalog:N,lookRenderer:K,localNamespaces:k,rawByNsKey:c,renderStack:W,...B?{lockSource:B}:{},...A?{configSource:A}:{}})}function Ne(t,e,s){let r=new Map;for(let o of e)o.publisher===t&&(r.has(o.package_)||r.set(o.package_,{verStr:o.verStr,source:o.source}));if(r.size===0)return;let i={};for(let o of[...r.keys()].sort()){let{verStr:m,source:p}=r.get(o),k={},c;try{c=s.parse(p).metadata?.imports}catch{c=void 0}for(let n of c?.[t]??[]){let g=r.get(n.packageName);g&&(k[`${t}/${n.packageName}`]=g.verStr)}let h={};for(let n of Object.keys(k).sort())h[n]=k[n];i[`${t}/${o}`]={version:m,resolved:`https://${t}/${o}/${m}.kan.yml`,integrity:we(p),dependencies:h}}return Fe.dump({version:"1",lastUpdated:"",packages:i},{lineWidth:-1,sortKeys:!1,quotingType:'"'})}import{existsSync as Me,readFileSync as Ie,writeFileSync as De,mkdirSync as Ke}from"fs";import{join as xe}from"path";async function le(t,e={}){let s=new O,r=Se(t),i=r.kind==="resource"?r.uri.publisher:r.publisher,o=e.log??(()=>{}),m=e.cacheRoot??Q(),p=(a,d,f)=>xe(m,a,`${d}@${f}.kan.yml`),k=new Set,c=new Set,h=new Map,n=new X({getFromCache:(a,d,f)=>{let S=p(a,d,f),b=Me(S)?Ie(S,"utf-8"):null;return b!==null&&k.add(`${a}/${d}`),b},onFetch:(a,d,f,S)=>{c.add(`${a}/${d}`);try{let b=xe(m,a);Ke(b,{recursive:!0}),De(p(a,d,f),S,"utf-8")}catch(b){h.set(`${a}/${d}`,b.message),o(`[render] fetched ${a}/${d}@${f} but cache ${m} is NOT WRITABLE (${b.message}); usable for this load only \u2014 every load will re-fetch it`)}},...e.fetchFn?{fetchFn:e.fetchFn}:{}}),g=new G(e.fetchFn?{fetchFn:e.fetchFn}:void 0),w;if(r.kind==="resource"){let a=r.uri.version;w=[a?{package_:r.uri.package_,version:`${a.major}.${a.minor}.${a.patch}`}:{package_:r.uri.package_}]}else if(r.kind==="package"){let a=r.version;w=[a?{package_:r.package_,version:`${a.major}.${a.minor}.${a.patch}`}:{package_:r.package_}]}else w=((await g.getConfig(i)).featured_packages??[]).map(d=>({package_:d}));let v=async(a,d,f)=>{try{let S=f?s.buildImport(d,"=",f,a):s.buildImport(d,"*","0.0.0",a),b=await n.getHighestCompatibleVersionAsync(a,S);return b?{doc:b}:{doc:null,error:`${a} did not resolve ${d}${f?`@${f}`:""} (not in its index, or unreachable)`}}catch(S){return{doc:null,error:S.message}}},$=[],R=[];for(let a of w){let{doc:d,error:f}=await v(i,a.package_,a.version);d?$.push(d):f&&R.push(f)}if($.length===0)throw new Error(`Could not fetch any package for address "${t}" from publisher "${i}".`+(R.length>0?` Reasons: ${R.join("; ")}`:""));let _=U(),j="universal-default",N=a=>a.map(d=>d.metadata.namespace_?.version).filter(d=>d!==void 0).sort((d,f)=>L(f,d)).map(D);o(`[render-stack] resolving ${_.length} ambient look-stack package(s) (contract: ${j}); cache: ${m}`);let K=[],T=[];for(let a of _){let d=F(a),{doc:f,error:S}=await v(a.publisher,a.package_,void 0);if(f){K.push(f);let b=N([f]),E=c.has(d)?"fetched":k.has(d)?"cache":"fetched";T.push({...a,origin:E,versions:b}),o(`[render-stack] ${d} \u2014 ${E} (${b.join(", ")})`+(h.has(d)?" [cache write FAILED \u2014 will re-fetch next load]":""))}else T.push({...a,origin:"missing",reason:S??"unresolved"}),o(`[render-stack] ${d} \u2014 MISSING: ${S??"unresolved"}`)}let V=await q([...$,...K],n),J=new z(n,V),W=await new re(s).parseKanonaks(J),B=new te(W),A=T.map(a=>a.origin==="missing"||ee(W,{publisher:a.publisher,package_:a.package_,name:a.package_}).length>0?a:{...a,resolvedButNotInCatalog:!0}),l=Y(A);for(let a of l)o(`[render-stack] WARNING: ${a}`);let u={contractSource:j,cachePath:m,packages:A,warnings:l},y=new Set,I=new Map;for(let a of await n.getAllDocumentsAsync()){let d=a.metadata.namespace_;if(!d?.version||d.publisher!==i)continue;let f=D(d.version),S=`${d.publisher}/${d.package_}@${f}`;y.add(S);let b=await n.getDocumentContentAsync(S);b!==null&&I.set(`${d.package_}@${f}`,b)}return ne({publisher:i,availablePublishers:[i],catalog:W,lookRenderer:B,localNamespaces:y,rawByNsKey:I,renderStack:u})}import{VersionOperator as ae}from"@kanonak-protocol/types/document/models/enums";function se(t){let{lookRenderer:e,publisher:s,renderStack:r,catalog:i}=t,o=e.explainStylesheet(e.publisherSubject(s)),m=[...o.tokens.entries()].map(([n,g])=>({name:n,value:g.value,source:`${g.sourceNamespace}/${g.sourceName}`,level:g.level})),p=o.baseStylesheet,k={present:p.css!==void 0,...p.sourceNamespace!==void 0?{source:p.sourceNamespace}:{},...p.scope!==void 0?{scope:p.scope}:{},...p.css!==void 0?{bytes:p.css.length}:{},...p.problem!==void 0?{problem:p.problem}:{},candidates:p.candidates},c=new Map;for(let n of i){let g=n.namespace;g&&c.set(g,(c.get(g)??0)+1)}let h=[...c.entries()].map(([n,g])=>({namespace:n,resources:g})).sort((n,g)=>n.namespace.localeCompare(g.namespace));return{publisher:s,renderStack:{contractSource:r.contractSource,cachePath:r.cachePath,packages:r.packages.map(n=>({package_:F(n),origin:n.origin,...n.versions!==void 0?{versions:n.versions}:{},...n.reason!==void 0?{reason:n.reason}:{},...n.resolvedButNotInCatalog!==void 0?{resolvedButNotInCatalog:n.resolvedButNotInCatalog}:{}}))},stylesheet:{tokens:m,baseStylesheet:k,...o.look?{look:{sourceClass:`${o.look.sourceClass.publisher}/${o.look.sourceClass.package_}/${o.look.sourceClass.name}`}}:{}},catalog:h,warnings:[...r.warnings,...o.warnings.filter(n=>!r.warnings.includes(n))]}}function Ve(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;").replace(/'/g,"&#39;")}function de(t){let e=Ve,s=t.warnings.length===0,r=t.warnings.length===0?'<p class="ok">\u2713 No problems detected \u2014 the render stack is fully resolved and pages should be styled.</p>':t.warnings.map(c=>`<div class="warn">\u26A0 ${e(c)}</div>`).join(`
2
2
  `),i=t.renderStack.packages.map(c=>{let h=c.origin!=="missing"&&!c.resolvedButNotInCatalog,n=c.origin==="missing"?'<span class="bad">MISSING</span>':c.resolvedButNotInCatalog?`<span class="bad">${e(c.origin)} (not in catalog)</span>`:`<span class="good">${e(c.origin)}</span>`,g=c.reason?e(c.reason):e((c.versions??[]).join(", "));return`<tr class="${h?"":"row-bad"}"><td><code>${e(c.package_)}</code></td><td>${n}</td><td>${g}</td></tr>`}).join(`
3
3
  `),o=t.stylesheet.baseStylesheet,m=o.present?`<p><span class="good">\u2713 present</span> \u2014 <code>${e(o.source??"")}</code> (${o.bytes} bytes, ${e(o.scope??"")})</p>`:`<p><span class="bad">\u2717 MISSING</span>${o.problem?` \u2014 ${e(o.problem)}`:""}${o.candidates.length>0?`<br>candidates considered: ${o.candidates.map(c=>`<code>${e(c)}</code>`).join(", ")}`:""}</p><p>Without the base stylesheet, generated CSS stops at the <code>:root</code> token block and pages appear unstyled.</p>`,p=t.stylesheet.tokens.map(c=>`<tr><td><code>--kan-${e(c.name)}</code></td><td><code>${e(c.value)}</code></td><td><code>${e(c.source)}</code></td><td>${e(c.level)}</td></tr>`).join(`
4
4
  `),k=t.catalog.map(c=>`<tr><td><code>${e(c.namespace)}</code></td><td>${c.resources}</td></tr>`).join(`
@@ -1,4 +1,4 @@
1
- import{b as Y,c as An,d as Sn,e as ce,f as Te,g as O,h as wn,i as X,j as q}from"../chunk-IHB7UVEH.js";import{a as se}from"../chunk-EZSHR3CB.js";import"../chunk-QHABFCRC.js";import"../chunk-4NO7MHS7.js";import"../chunk-S6VSAKXB.js";import"../chunk-PEJALHXK.js";import{d as kn,e as bn,f as hn,g as Dn,l as ie}from"../chunk-MX3DEXMV.js";import{a as ae}from"../chunk-NJ3AZYQD.js";import"../chunk-6U26UASC.js";import"../chunk-GZPLWII7.js";import{b as N,c as D,d as K,g as M,h as P,i as F,j as W,l as H,n as L,o as A,r as S}from"../chunk-7BHDZHJY.js";import"../chunk-FUUTGGJS.js";import{g as oe}from"../chunk-2ACBWC7K.js";var $e="kanonak.org",Ue="document-ast",i=e=>({publisher:$e,package_:Ue,name:e}),m={Document:i("Document"),Block:i("Block"),Inline:i("Inline"),StructuredValue:i("StructuredValue"),Heading:i("Heading"),Paragraph:i("Paragraph"),RawBlock:i("RawBlock"),Text:i("Text"),StructuredMap:i("StructuredMap"),StructuredEntry:i("StructuredEntry"),StructuredList:i("StructuredList"),StringScalar:i("StringScalar"),IntegerScalar:i("IntegerScalar"),EscapeHint:i("EscapeHint"),MediaType:i("MediaType"),metadata:i("metadata"),children:i("children"),level:i("level"),inlines:i("inlines"),text:i("text"),entries:i("entries"),key:i("key"),value:i("value"),escapeHint:i("escapeHint"),items:i("items"),stringValue:i("stringValue"),integerValue:i("integerValue"),rawContent:i("rawContent"),mediaType:i("mediaType"),mimeType:i("mimeType"),ESC_RAW:i("esc-raw"),ESC_YAML_SAFE:i("esc-yaml-safe"),ESC_TOML_STRING:i("esc-toml-string"),ESC_TOML_MULTILINE:i("esc-toml-multiline"),ESC_JSON:i("esc-json"),ESC_DYNAMODB_BOOL:i("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:i("esc-dynamodb-number"),ESC_DYNAMODB_NULL:i("esc-dynamodb-null"),TEXT_PLAIN:i("text-plain"),TEXT_MARKDOWN:i("text-markdown"),TEXT_HTML:i("text-html"),TEXT_CSS:i("text-css"),APPLICATION_JSON:i("application-json"),TEXT_YAML:i("text-yaml"),IMAGE_SVG_XML:i("image-svg-xml"),ResourceLink:i("ResourceLink"),target:i("target"),linkLabel:i("linkLabel"),PropertyList:i("PropertyList"),propertyEntries:i("propertyEntries"),PropertyEntry:i("PropertyEntry"),propertyKey:i("propertyKey"),propertyValue:i("propertyValue"),Table:i("Table"),tableColumnLabels:i("tableColumnLabels"),tableRows:i("tableRows"),TableRow:i("TableRow"),tableCells:i("tableCells")};function ue(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var j=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(n,t){let r=xe(n.metadata,t),o=Le(n.children),s=["---",...r,"---","",o].join(`
1
+ import{b as Y,c as An,d as Sn,e as ce,f as Te,g as O,h as wn,i as X,j as q}from"../chunk-4PY3JJH3.js";import{a as se}from"../chunk-LYSCTQC2.js";import"../chunk-QHABFCRC.js";import"../chunk-4NO7MHS7.js";import"../chunk-5NH5XDGO.js";import"../chunk-PEJALHXK.js";import{e as kn,f as bn,g as hn,h as Dn,m as ie}from"../chunk-V6KIDED2.js";import{a as ae}from"../chunk-NJ3AZYQD.js";import"../chunk-SVUMCLK5.js";import{b as N,c as D,d as K,g as M,h as P,i as F,j as W,l as H,n as L,o as A,r as S}from"../chunk-YW6P24RF.js";import"../chunk-FUUTGGJS.js";import{g as oe}from"../chunk-2ACBWC7K.js";var $e="kanonak.org",Ue="document-ast",i=e=>({publisher:$e,package_:Ue,name:e}),m={Document:i("Document"),Block:i("Block"),Inline:i("Inline"),StructuredValue:i("StructuredValue"),Heading:i("Heading"),Paragraph:i("Paragraph"),RawBlock:i("RawBlock"),Text:i("Text"),StructuredMap:i("StructuredMap"),StructuredEntry:i("StructuredEntry"),StructuredList:i("StructuredList"),StringScalar:i("StringScalar"),IntegerScalar:i("IntegerScalar"),EscapeHint:i("EscapeHint"),MediaType:i("MediaType"),metadata:i("metadata"),children:i("children"),level:i("level"),inlines:i("inlines"),text:i("text"),entries:i("entries"),key:i("key"),value:i("value"),escapeHint:i("escapeHint"),items:i("items"),stringValue:i("stringValue"),integerValue:i("integerValue"),rawContent:i("rawContent"),mediaType:i("mediaType"),mimeType:i("mimeType"),ESC_RAW:i("esc-raw"),ESC_YAML_SAFE:i("esc-yaml-safe"),ESC_TOML_STRING:i("esc-toml-string"),ESC_TOML_MULTILINE:i("esc-toml-multiline"),ESC_JSON:i("esc-json"),ESC_DYNAMODB_BOOL:i("esc-dynamodb-bool"),ESC_DYNAMODB_NUMBER:i("esc-dynamodb-number"),ESC_DYNAMODB_NULL:i("esc-dynamodb-null"),TEXT_PLAIN:i("text-plain"),TEXT_MARKDOWN:i("text-markdown"),TEXT_HTML:i("text-html"),TEXT_CSS:i("text-css"),APPLICATION_JSON:i("application-json"),TEXT_YAML:i("text-yaml"),IMAGE_SVG_XML:i("image-svg-xml"),ResourceLink:i("ResourceLink"),target:i("target"),linkLabel:i("linkLabel"),PropertyList:i("PropertyList"),propertyEntries:i("propertyEntries"),PropertyEntry:i("PropertyEntry"),propertyKey:i("propertyKey"),propertyValue:i("propertyValue"),Table:i("Table"),tableColumnLabels:i("tableColumnLabels"),tableRows:i("tableRows"),TableRow:i("TableRow"),tableCells:i("tableCells")};function ue(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}var j=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(n,t){let r=xe(n.metadata,t),o=Le(n.children),s=["---",...r,"---","",o].join(`
2
2
  `);return t?.trailingNewline&&(s.endsWith(`
3
3
  `)||(s+=`
4
4
  `)),s}};function xe(e,n){if(!e)return[];let t=new Map;for(let c of e.entries)t.set(I(c.key),c);let r=new Map;if(n?.metadataRenames)for(let[c,u]of n.metadataRenames)r.set(I(c),u);let a=(n?.metadataKeys??e.entries.map(c=>c.key)).map(I),s=[];for(let c of a){let u=t.get(c);if(!u)continue;let f=r.get(c),l=I(f??c),d=me(u.value,u.escapeHint);d!==void 0&&s.push(`${l}: ${d}`)}return s}function I(e){let n=e.lastIndexOf(".");return n===-1?e:e.substring(n+1)||e}function me(e,n){switch(e.kind){case"StringScalar":return Ve(e.stringValue,n);case"IntegerScalar":return String(e.integerValue);case"StructuredList":{let t=[];for(let r of e.items){let o=me(r,n);o!==void 0&&t.push(o)}return t.join(", ")}case"StructuredMap":return;default:return}}function Ve(e,n){return!n||ue(n,m.ESC_RAW)?e:ue(n,m.ESC_YAML_SAFE)?ve(e):e}function ve(e){return e.includes(`
@@ -1 +1 @@
1
- import{a as n}from"../chunk-6U26UASC.js";import{m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l,y as m}from"../chunk-7BHDZHJY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{n as SingleDocumentRepository,g as findAllResourcesByCanonicalUri,f as findSubjectByUri,e as findSubjectsByType,i as getDatatypeValue,l as getEmbeddedValue,m as getListValues,k as getReferenceUri,j as getStringValue,h as hasProperty,d as hasType,c as toCanonicalUrl,a as uriKey,b as uriMatches};
1
+ import{m as a,n as b,o as c,p as d,q as e,r as f,s as g,t as h,u as i,v as j,w as k,x as l,y as m,z as n}from"../chunk-YW6P24RF.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{n as SingleDocumentRepository,g as findAllResourcesByCanonicalUri,f as findSubjectByUri,e as findSubjectsByType,i as getDatatypeValue,l as getEmbeddedValue,m as getListValues,k as getReferenceUri,j as getStringValue,h as hasProperty,d as hasType,c as toCanonicalUrl,a as uriKey,b as uriMatches};
@@ -2,7 +2,6 @@ import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/documen
2
2
  import type { KanonakDocument, Import, DocumentReference } from '@kanonak-protocol/types/document/models/types';
3
3
  import type { ValidationCache } from './ValidationCache.js';
4
4
  import type { Kanonak } from '../kanonaks/Kanonak.js';
5
- import { DefinedKanonak } from '../kanonaks/DefinedKanonak.js';
6
5
  /**
7
6
  * Shared object-model substrate for repository validation rules (#65).
8
7
  *
@@ -47,20 +46,8 @@ export declare function getDocumentKanonaks(document: KanonakDocument, repositor
47
46
  * {@link getCatalogKanonaks}.
48
47
  */
49
48
  export declare function getAuthoredKanonaks(document: KanonakDocument, repository: IKanonakDocumentRepository, cache?: ValidationCache): Promise<Kanonak[]>;
50
- /** A DefinedKanonak visited during a walk, with a human-facing locator path. */
51
- export interface WalkNode {
52
- readonly kanonak: DefinedKanonak;
53
- /** `subjectName` for a subject, `subjectName/childName/...` for embeddeds. */
54
- readonly path: string;
55
- }
56
- /**
57
- * Depth-first visit of every DefinedKanonak reachable from `roots`: each
58
- * subject, then every embedded kanonak nested in its statements (single
59
- * embeddeds and embedded list items), at any depth. The visitor sees one node
60
- * at a time and should inspect only that node's OWN statements — the walk
61
- * handles the recursion.
62
- */
63
- export declare function walkDefinedKanonaks(roots: Kanonak[], visit: (node: WalkNode) => void): void;
49
+ export { walkDefinedKanonaks } from '../kanonaks/walkDefinedKanonaks.js';
50
+ export type { WalkNode } from '../kanonaks/walkDefinedKanonaks.js';
64
51
  /** `publisher/package@major.minor.patch` — matches `SubjectKanonak.namespace`
65
52
  * and the parser's `sourceDoc`. Undefined for a document without a namespace. */
66
53
  export declare function namespaceOf(document: KanonakDocument): string | undefined;
@@ -1 +1 @@
1
- import{A,B,C,D,E,F,G,J as H,K as I,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-7K5TAJ44.js";import"../chunk-ITKOKDBG.js";import"../chunk-MX3DEXMV.js";import"../chunk-NJ3AZYQD.js";import"../chunk-ZP6P7HNU.js";import"../chunk-6U26UASC.js";import"../chunk-GZPLWII7.js";import"../chunk-7BHDZHJY.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{u as AmbiguousReferenceRule,A as ClassDefinitionRule,n as ClassHierarchyCycleRule,H as DiamondNameClashRule,C as DisplayLensScopeRule,k as EmbeddedKanonakTypeRule,l as ImportExistenceRule,I as KanonakObjectValidator,D as LookSemanticSvgPathRule,B as MarkdownLinkRule,s as NamespaceImportCycleRule,f as NamespacePrefixRule,w as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,G as OwlOneOfRule,j as PackageHeaderRule,x as PropertyDomainRule,o as PropertyHierarchyCycleRule,y as PropertyKindRangeConsistencyRule,v as PropertyRangeReferenceRule,p as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,z as ReservedNameShadowRule,g as ResourceNamingRule,F as ShaclShapeRule,q as SubClassOfReferenceRule,r as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,E as TxExpressionPathRule,t as UnresolvedPredicateRule,m as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
1
+ import{A,B,C,D,E,F,G,J as H,K as I,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-Q6XQ5IXW.js";import"../chunk-ITKOKDBG.js";import"../chunk-V6KIDED2.js";import"../chunk-NJ3AZYQD.js";import"../chunk-SVUMCLK5.js";import"../chunk-YW6P24RF.js";import"../chunk-FUUTGGJS.js";import"../chunk-2ACBWC7K.js";export{u as AmbiguousReferenceRule,A as ClassDefinitionRule,n as ClassHierarchyCycleRule,H as DiamondNameClashRule,C as DisplayLensScopeRule,k as EmbeddedKanonakTypeRule,l as ImportExistenceRule,I as KanonakObjectValidator,D as LookSemanticSvgPathRule,B as MarkdownLinkRule,s as NamespaceImportCycleRule,f as NamespacePrefixRule,w as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,G as OwlOneOfRule,j as PackageHeaderRule,x as PropertyDomainRule,o as PropertyHierarchyCycleRule,y as PropertyKindRangeConsistencyRule,v as PropertyRangeReferenceRule,p as PropertyRangeRequiredRule,h as PropertyTypeSpecificityRule,z as ReservedNameShadowRule,g as ResourceNamingRule,F as ShaclShapeRule,q as SubClassOfReferenceRule,r as SubPropertyOfReferenceRule,i as SubjectKanonakTypeRequiredRule,E as TxExpressionPathRule,t as UnresolvedPredicateRule,m as UnresolvedReferenceRule,e as ValidationCache,d as ValidationContext,b as ValidationSeverity};
@@ -11,6 +11,10 @@ import type { ValidationCache } from '../../ValidationCache.js';
11
11
  * literal `'range'` dict key and falsely reported "must have a range" for a
12
12
  * property authored with `rdfs.range:` (#65 Gap B). Whether the declared range
13
13
  * actually RESOLVES is `PropertyRangeReferenceRule`'s concern.
14
+ *
15
+ * The Object/Datatype test is subsumption over the declared type, so a
16
+ * property declared with an OWL characteristic owes a range exactly like the
17
+ * `owl.ObjectProperty` it descends from.
14
18
  */
15
19
  export declare class PropertyRangeRequiredRule implements IRepositoryValidationRule {
16
20
  readonly ruleName = "PropertyRangeRequired";
@@ -7,8 +7,10 @@ import type { ValidationCache } from '../../ValidationCache.js';
7
7
  * Every `subPropertyOf` target must resolve to a defined or imported property.
8
8
  * Reads the resolved object model: the target is a `ReferenceKanonak` resolved
9
9
  * through the import closure (alias-agnostic), and its existence + property-ness
10
- * are checked by `findSubjectByUri` + `ResourceTypeClassifier`, never by a
11
- * hardcoded built-in-name list or `split('.')` alias extraction.
10
+ * are checked by `findSubjectByUri` + `isPropertySubject`, never by a
11
+ * hardcoded built-in-name list or `split('.')` alias extraction. Property-ness
12
+ * is decided by subsumption, so an OWL characteristic
13
+ * (`type: owl.TransitiveProperty`) is a property on both sides of the edge.
12
14
  */
13
15
  export declare class SubPropertyOfReferenceRule implements IRepositoryValidationRule {
14
16
  readonly ruleName = "SubPropertyOfReference";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kanonak-protocol/sdk",
3
- "version": "5.13.0",
3
+ "version": "5.14.0",
4
4
  "description": "TypeScript SDK for the Kanonak Protocol — parse, resolve, validate, reason over, and render .kan.yml packages.",
5
5
  "type": "module",
6
6
  "main": "./dist/index.js",
@@ -126,7 +126,7 @@
126
126
  ],
127
127
  "dependencies": {
128
128
  "@kanonak-protocol/canonical": "^0.1.3",
129
- "@kanonak-protocol/types": "^5.13.0",
129
+ "@kanonak-protocol/types": "^5.14.0",
130
130
  "ignore": "^7.0.5",
131
131
  "js-yaml": "^4.1.0",
132
132
  "yaml": "^2.7.0"
@@ -1,2 +0,0 @@
1
- import{e as F}from"./chunk-UXYCUGSF.js";import{H as ye,I as me}from"./chunk-7K5TAJ44.js";import{a as ne,b as I,c as pe,h as B,l as x}from"./chunk-MX3DEXMV.js";import{a as b,d as K,e as fe,f as ge}from"./chunk-ZP6P7HNU.js";import{i as de}from"./chunk-GZPLWII7.js";import{b as ee,c as A,d as E,f as re,g as oe,h as se,i as ae,j as ie,k as ce,l as L,m as N,r as G,t as le,v as $,w as ue,y as V}from"./chunk-7BHDZHJY.js";import{a as te}from"./chunk-FUUTGGJS.js";import{d as Z}from"./chunk-2ACBWC7K.js";var be=(a=>(a.Class="Class",a.DatatypeProperty="DatatypeProperty",a.ObjectProperty="ObjectProperty",a.AnnotationProperty="AnnotationProperty",a.Instance="Instance",a.Datatype="Datatype",a.Unknown="Unknown",a))(be||{}),Ce=(i=>(i.InstanceOf="instanceOf",i.SubClassOf="subClassOf",i.Domain="domain",i.Range="range",i.ObjectRelationship="objectRelationship",i.SubPropertyOf="subPropertyOf",i.PropertyValue="propertyValue",i.EmbeddedLink="embeddedLink",i))(Ce||{}),z=class{static async buildFromRepository(n,t){let s=await new x().parseKanonaks(n),o=await n.getAllDocumentsAsync(),c=[],a=[],i=new Set,d=new Set,f=new Map;for(let y of s){let l=y;l.name&&(b.isClassType(l)&&i.add(l.name),(b.isObjectPropertyType(l)||b.isGenericPropertyType(l))&&d.add(l.name))}for(let y of o)for(let[l,u]of Object.entries(y.body))d.has(l)&&u?.range&&typeof u.range=="string"&&f.set(l,u.range);let p=new Map;for(let y of s){let l=y;l.name&&p.set(l.name,l)}for(let y of o){let l=y.metadata.namespace_,u=l?`${l.publisher}/${l.package_}`:"",m=l?.version?`${l.version.major}.${l.version.minor}.${l.version.patch}`:"",C=he(y);for(let[h,g]of Object.entries(y.body)){if(!g||typeof g!="object")continue;let O=p.get(h),k="Unknown";if(O){let v=O;b.isClassType(v)?k="Class":b.isObjectPropertyType(v)?k="ObjectProperty":b.isDatatypePropertyType(v)?k="DatatypeProperty":b.isAnnotationPropertyType(v)?k="AnnotationProperty":b.isDatatypeType(v)?k="Datatype":b.isGenericPropertyType(v)?k="ObjectProperty":b.isInstanceOfKnownClass(v,i)&&(k="Instance")}let S=u&&m?`${u}/${h}@${m}`:h,Q={};for(let[v,U]of Object.entries(g))v!=="type"&&(typeof U!="object"||U===null)&&(Q[v]=U);c.push({id:S,label:g.label??h,type:k,namespace:u,properties:Q}),ke(S,g,k,i,d,a,u,m,C,t),H(S,g,d,f,c,a,u,m,C),Ue(S,O,a)}}return{nodes:c,edges:a}}static buildFromDocument(n,t){let r=[],s=[],o=n.metadata.namespace_,c=o?.version?`${o.version.major}.${o.version.minor}.${o.version.patch}`:"",a=o?`${o.publisher}/${o.package_}`:"",i=new Set,d=new Set,f=new Map,p=he(n);for(let[u,m]of Object.entries(n.body)){let C=m?.type;C&&(Ke(C,p)&&i.add(u),De(C,p)&&(d.add(u),m.range&&typeof m.range=="string"&&f.set(u,m.range)))}for(let[u,m]of Object.entries(n.body)){if(!m||typeof m!="object")continue;let C=m.type,h=Me(C,u,i,p),g=a&&c?`${a}/${u}@${c}`:u,O={};for(let[k,S]of Object.entries(m))k!=="type"&&(typeof S!="object"||S===null)&&(O[k]=S);r.push({id:g,label:m.label??u,type:h,namespace:a,properties:O}),ke(g,m,h,i,d,s,a,c,p,t),H(g,m,d,f,r,s,a,c,p)}let y=new Set(r.map(u=>u.id)),l=s.filter(u=>y.has(u.source)&&y.has(u.target));return{nodes:r,edges:l}}};function he(e,n){let t=new Map;if(e.metadata?.imports)for(let[r,s]of Object.entries(e.metadata.imports))for(let o of s){let c=o.alias??o.packageName,a=o.version,i=`${a.major}.${a.minor}.${a.patch}`;t.set(c,{publisher:r,package_:o.packageName,version:i})}return t}var Se={"kanonak.org/core-rdf/Class":"Class","kanonak.org/core-owl/Class":"Class","kanonak.org/core-rdfs/Class":"Class","kanonak.org/core-owl/ObjectProperty":"ObjectProperty","kanonak.org/core-owl/DatatypeProperty":"DatatypeProperty","kanonak.org/core-owl/AnnotationProperty":"AnnotationProperty","kanonak.org/core-rdf/Property":"ObjectProperty","kanonak.org/core-rdfs/Datatype":"Datatype"},xe=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function q(e,n){if(e.includes(".")){let t=e.indexOf("."),r=e.substring(0,t),s=e.substring(t+1),o=n.get(r);if(o)return`${o.publisher}/${o.package_}/${s}`}return null}function Ke(e,n){let t=q(e,n);return t?Se[t]==="Class":!1}function De(e,n){let t=q(e,n);return t?xe.has(t):!1}function Me(e,n,t,r){if(!e||e==="Package")return"Unknown";let s=q(e,r);if(s){let c=Se[s];if(c)return c;let a=s.split("/").pop()?.split("@")[0]??"";return t.has(a)?"Instance":"Unknown"}let o=e.split(".").pop()??e;return t.has(o)?"Instance":"Unknown"}var Oe=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function ke(e,n,t,r,s,o,c,a,i,d){let f=n.type,p=n.subClassOf;if(p){let h=Array.isArray(p)?p:[p];for(let g of h)typeof g=="string"&&o.push({source:e,target:w(g,c,a,i),type:"subClassOf",label:"subClassOf"})}let y=n.subPropertyOf;if(y){let h=Array.isArray(y)?y:[y];for(let g of h)typeof g=="string"&&o.push({source:e,target:w(g,c,a,i),type:"subPropertyOf",label:"subPropertyOf"})}let l=n.domain,u=n.range;if(d?.includePropertyEdges){let h=[[l,"domain","domain"],[u,"range","range"]];for(let[g,O,k]of h)if(g!=null)for(let S of Array.isArray(g)?g:[g])typeof S=="string"&&o.push({source:e,target:w(S,c,a,i),type:O,label:k})}if(t==="Instance"&&f){let h=f.split(".").pop()??f;o.push({source:e,target:w(h,c,a,i),type:"instanceOf",label:"type"})}if(t==="Instance")for(let[h,g]of Object.entries(n)){if(Oe.has(h)||!s.has(h))continue;let O=Array.isArray(g)?g:[g];for(let k of O)typeof k=="string"&&Fe(k)&&o.push({source:e,target:w(k,c,a,i),type:"propertyValue",label:h,propertyId:w(h,c,a,i)})}if((t==="ObjectProperty"||t==="DatatypeProperty"||l&&u)&&l&&u){let h=typeof l=="string"?l:null,g=typeof u=="string"?u:null;h&&g&&o.push({source:w(h,c,a,i),target:w(g,c,a,i),type:"objectRelationship",label:n.label??e.split("/").pop()??"",propertyId:e})}}function H(e,n,t,r,s,o,c,a,i){for(let[d,f]of Object.entries(n)){if(Oe.has(d)||typeof f!="object"||f===null||Array.isArray(f))continue;let p=f,y=`${e}/${d}`,l=r.get(d),u=l?l.split(".").pop()??l:"Unknown",m={};for(let[h,g]of Object.entries(p))(typeof g!="object"||g===null)&&(m[h]=g);s.push({id:y,label:`${u} (embedded)`,type:"Instance",namespace:c,properties:m});let C=c&&a?`${c}/${d}@${a}`:d;o.push({source:e,target:y,type:"propertyValue",label:d,propertyId:t.has(d)?C:void 0}),l&&o.push({source:y,target:w(u,c,a,i),type:"instanceOf",label:"type (inferred)"}),H(y,p,t,r,s,o,c,a,i)}}function Ue(e,n,t){let r=n?.statement;if(Array.isArray(r))for(let s of r){if(!(s instanceof pe))continue;let o=s.predicate?.subject?.name??"";for(let c of s.links){let a=c.target?.subject;if(!a)continue;let i=a.version,d=i&&typeof i.major=="number"?`@${i.major}.${i.minor}.${i.patch}`:"";t.push({source:e,target:`${a.publisher}/${a.package_}/${a.name}${d}`,type:"embeddedLink",label:o})}}}function Fe(e){return!(!e||e.includes(" ")||e.includes(`
2
- `)||e.startsWith("http://")||e.startsWith("https://")||/^\d{4}-\d{2}/.test(e)||/^\d+(\.\d+)?$/.test(e))}function w(e,n,t,r){if(e.includes("@")&&e.includes("/"))return e;if(e.includes(".")){let s=e.indexOf("."),o=e.substring(0,s),c=e.substring(s+1);if(r){let a=r.get(o);if(a)return`${a.publisher}/${a.package_}/${c}@${a.version}`}return n&&t?`${n}/${c}@${t}`:c}return n&&t?`${n}/${e}@${t}`:e}function R(e){let n=e.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!n)throw new Error("Publisher host cannot be empty");return n}var Le="key_thumbprint",_=class{cache=new Map;prCache=new Map;async discoverProtectedResource(n){let t=R(n);if(this.prCache.has(t))return this.prCache.get(t);let r=`https://${t}/.well-known/oauth-protected-resource`,s=await Ge(r),o=s&&Array.isArray(s.authorization_servers)?s.authorization_servers.filter(a=>typeof a=="string"):[],c=o.length>0?o:null;return this.prCache.set(t,c),c}async discover(n){let t=R(n);if(this.cache.has(t))return this.cache.get(t);let r=`https://${t}/.well-known/oauth-authorization-server`,s=await this.tryEndpoint(r);if(!s){let o=`https://${t}/.well-known/openid-configuration`;s=await this.tryEndpoint(o)}return this.cache.set(t,s),s}async supportsOAuth(n){return await this.discover(n)!==null}static supportsPkceS256(n){return n.codeChallengeMethodsSupported?.some(t=>t.toUpperCase()==="S256")??!1}static supportsDynamicRegistration(n){return!!n.registrationEndpoint}static supportsAuthorizationCode(n){return n.responseTypesSupported?.some(t=>t.toLowerCase()==="code")??!1}static supportsEnrollment(n){return!!n.enrollmentEndpoint}static supportsSession(n){return!!n.sessionEndpoint}async tryEndpoint(n){let t;try{t=await fetch(n)}catch(s){let o=s instanceof Error?s.message:String(s);return o.includes("ENOTFOUND")||o.includes("ECONNREFUSED")?(console.error(` OAuth discovery: ${n} \u2014 host unreachable (${o})`),console.error(" If the server is behind a VPN, ensure you are connected.")):o.includes("CERT")||o.includes("SSL")||o.includes("TLS")?(console.error(` OAuth discovery: ${n} \u2014 TLS error (${o})`),console.error(" If using a custom CA certificate, set NODE_EXTRA_CA_CERTS=/path/to/ca.pem")):console.error(` OAuth discovery: ${n} \u2014 network error: ${o}`),null}if(!t.ok)return t.status===404||(t.status===403?(console.error(` OAuth discovery: ${n} \u2014 HTTP 403 Forbidden`),console.error(" Access may be blocked by a firewall, proxy, or WAF.")):t.status>=500&&(console.error(` OAuth discovery: ${n} \u2014 HTTP ${t.status} server error`),console.error(" The authorization server returned an internal error. Contact your IDP administrator."))),null;let r;try{r=await t.json()}catch{return console.error(` OAuth discovery: ${n} \u2014 response is not valid JSON`),console.error(" The endpoint may be returning HTML instead of JSON. Check IDP configuration."),null}return{issuer:P(r.issuer),authorizationEndpoint:P(r.authorization_endpoint),tokenEndpoint:P(r.token_endpoint),registrationEndpoint:P(r.registration_endpoint),revocationEndpoint:P(r.revocation_endpoint),scopesSupported:T(r.scopes_supported),responseTypesSupported:T(r.response_types_supported),grantTypesSupported:T(r.grant_types_supported),codeChallengeMethodsSupported:T(r.code_challenge_methods_supported),tokenEndpointAuthMethodsSupported:T(r.token_endpoint_auth_methods_supported),dpopSigningAlgValuesSupported:T(r.dpop_signing_alg_values_supported),enrollmentEndpoint:P(r.enrollment_endpoint),enrollmentIssuanceProtocols:T(r.enrollment_issuance_protocols),enrollmentKeyTypes:T(r.enrollment_key_types),enrollmentScopesSupported:T(r.enrollment_scopes_supported),enrollmentConsentBindingParam:P(r.enrollment_consent_binding_param),sessionEndpoint:P(r.session_endpoint),sessionEndpointAuthMethod:P(r.session_endpoint_auth_method)}}};async function Ge(e){try{let n=await fetch(e);return n.ok?await n.json():null}catch{return null}}function P(e){return typeof e=="string"?e:null}function T(e){return Array.isArray(e)?e.filter(n=>typeof n=="string"):null}function ve(e){let n=e.headers.get("WWW-Authenticate")??void 0,t=e.headers.get("DPoP-Nonce")??void 0;if(!n&&!t)return;let r={wwwAuthenticate:n??""};if(t&&(r.nonce=t),n){let s=n.match(/acr_values\s*=\s*"([^"]*)"/i);s&&(r.acrValues=s[1])}return r}function Ve(e){try{return new URL(e).host}catch{return null}}function Be(e,n={}){let t=n.discovery??new _,r=new Map,s=new Map,o=async i=>{let d=r.get(i);if(d!==void 0)return d;let f=null,p=await t.discoverProtectedResource(i).catch(()=>null);return p&&p.length>0&&(f=Ve(p[0])),r.set(i,f),f},c=async(i,d)=>{if(!e)return null;if(!(d.forceRefresh||d.challenge)&&s.has(i))return s.get(i);let p=await e.resolve(i,d).catch(()=>null);return s.set(i,p),p},a=async(i,d,f,p)=>{let y=await o(d);if(!y)return{res:await F(i,{method:f,redirect:"manual"}),authed:!1};let l=await c(y,{method:f,url:i,...p}),u=l?.headers??{};return{res:await F(i,{method:f,redirect:"manual",headers:u}),authed:!!l}};return async(i,d,f="GET")=>{let p=await a(i,d,f,{});if((p.res.status===401||p.res.status===403)&&p.authed){let y=ve(p.res),l={forceRefresh:y===void 0};return y&&(l.challenge=y),(await a(i,d,f,l)).res}return p.res}}var we="KANONAK_TOKEN";function ze(){return typeof process<"u"&&process.env?process.env:{}}function He(e){return`${we}_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}var W=class{tokens;env;constructor(n={}){this.tokens=n.tokens??{},this.env=n.env??ze()}async resolve(n,t){let r=R(n),s=this.tokens[r]??this.env[He(r)]??this.env[we];return s?{headers:{Authorization:`Bearer ${s}`}}:null}};import{canonicalForm as qe,canonicalHash as We}from"@kanonak-protocol/canonical";function X(e){return typeof e=="object"&&e!==null&&Array.isArray(e.subjects)}import{CANONICAL_FORM_VERSION as on}from"@kanonak-protocol/canonical";function Xe(e){return qe(X(e)?e:Te(e))}function Ye(e){return We(X(e)?e:Te(e))}function Te(e){let n=[];for(let t of e)t instanceof A&&n.push({uri:rn(t),statements:Y(t.statement)});return{subjects:n}}function Y(e){let n=[];for(let t of e){let r=tn(t);if(!r)continue;if(t instanceof L&&Je(t.predicate.subject)){n.push(...Ze(t,r));continue}let s=en(t);s&&n.push({predicate:r,value:s})}return n}function Je(e){let n=de("type");return n!==void 0&&e.name==="type"&&e.publisher===n.publisher&&e.package_===n.package_}var Pe=new TextEncoder;function Qe(e,n){let t=Pe.encode(e),r=Pe.encode(n),s=Math.min(t.length,r.length);for(let o=0;o<s;o++)if(t[o]!==r[o])return t[o]-r[o];return t.length-r.length}function Ze(e,n){let t=[];for(let r of e.object){if(!(r instanceof E))throw new Error(`canonicalForm: a multi-valued type statement must contain only entity references, got ${r.constructor?.name??typeof r}`);t.push(J(r))}t.sort(Qe);for(let r=1;r<t.length;r++)if(t[r-1]===t[r])throw new Error(`canonicalForm: duplicate type ${t[r]} in a multi-valued type statement`);return t.map(r=>({predicate:n,value:{ref:r}}))}function en(e){if(e instanceof re&&e.carrier)return{lit:e.lexical??String(e.object),datatype:Ee(e.carrier)};if(e instanceof oe)return{raw:e.object};if(e instanceof se)return{raw:e.lexical??String(e.object)};if(e instanceof ae)return{raw:e.lexical??String(e.object)};if(e instanceof ie)return{ref:J(e.object)};if(e instanceof ce)return je(e.object);if(e instanceof L)return{list:e.object.map(nn)}}function je(e){let n=Y(e.statement);return e.name&&e.name.length>0?{embed:{name:e.name,statements:n}}:{embed:{statements:n}}}function nn(e){if(e instanceof E)return{ref:J(e)};if(e instanceof ne)return je(e);if(e instanceof I){if(e.carrier)return{lit:e.lexical??String(e.value),datatype:Ee(e.carrier)};let n=e.value;if(typeof n=="string")return{raw:n};if(typeof n=="number")return{raw:String(n)};if(typeof n=="boolean")return{raw:String(n)}}if(e instanceof ee)return{embed:{statements:Y(e.statement)}};throw new Error(`canonicalForm: list item of unrecognized kind (${e.constructor?.name??typeof e}); add canonicalization support before hashing data that contains it`)}function Ee(e){return e===B.LangString?"kanonak.org/core-rdf/langString":`kanonak.org/core-xsd/${e}`}function tn(e){let n=e.predicate;if(n)return Re(n.subject)}function rn(e){let n=e.namespace??"",t=e.name??"";return`${n}/${t}`}function J(e){return Re(e.subject)}function Re(e){let n=e.version;return n&&typeof n.major=="number"?`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}/${e.name}`:`${e.publisher}/${e.package_}/${e.name}`}var j="kanonak.org",M="core-rdf",Ae="core-xsd",_e={publisher:j,package_:M,name:"subClassOf"},Ie={publisher:j,package_:M,name:"label"},sn={publisher:j,package_:M,name:"comment"},Ne={publisher:j,package_:"core-owl",name:"oneOf"},$e=e=>e;function an(e){let n=ue(e,_e);if(n)return[n];let t=[];for(let r of V(e,_e))r instanceof E&&t.push(r.subject);return t}function cn(e,n,t){if(n.publisher===j&&n.package_===M&&n.name==="Literal")return{kind:"datatype",uri:n};let s=G(e,n);if(s){let o=$e(s);if(b.isDatatypeType(o))return{kind:"datatype",uri:n};if(b.isClassType(o))return{kind:"class",uri:K(s)??n,localName:s.name}}return n.publisher===j&&n.package_===Ae?{kind:"datatype",uri:n}:t==="datatype"?{kind:"datatype",uri:n}:{kind:"class",uri:n,localName:n.name}}function pn(e,n,t){if(!n.range)throw new Error(`Property ${n.uri.publisher}/${n.uri.package_}/${n.uri.name} has no rdfs.range; every property must declare a range. Validate the ontology before introspecting it.`);let r=cn(e,n.range,n.kind),s=n.kind==="object"?"object":n.kind==="datatype"?"datatype":r.kind==="class"?"object":"datatype";return{uri:n.uri,localName:n.uri.name,kind:s,range:r,...n.label!==void 0?{label:n.label}:{},...n.comment!==void 0?{comment:n.comment}:{},...t??{}}}var D=e=>new te(j,Ae,e);function ln(e){return typeof e=="boolean"?D("boolean"):typeof e=="number"?Number.isInteger(e)?D("integer"):D("decimal"):D("string")}function un(e,n){let t=[];for(let r of V(n,Ne))if(r instanceof E){let s=G(e,r.subject),o=(s?K(s):void 0)??r.subject,c=s?$(s,Ie):void 0;t.push({kind:"individual",uri:o,localName:o.name,...c!==void 0?{label:c}:{}})}else r instanceof I&&t.push({kind:"literal",value:r.value,datatype:ln(r.value)});return t}function dn(e,n,t,r){let s=fe(e,n),o=N(n);return ge(e,n).filter(a=>t?!0:a.domains.some(i=>N(i)===o)).map(a=>pn(e,a,me(r,s,a.uri)))}async function fn(e,n,t){let r=e.metadata?.namespace_;if(!r)throw new Error("buildOntologyModel: document has no namespace (publisher/package/version).");let s=t?.includeInherited??!1,o=await new x().parseKanonaks(n),c=ye(o),a=[],i=[],d=new Set;for(let f of o){if(!(f instanceof A)||!b.isClassType($e(f)))continue;let p=K(f);if(!p||p.publisher!==r.publisher||p.package_!==r.package_||p.version&&r.version&&!Z(p.version,r.version))continue;let y=N(p);if(d.has(y))continue;d.add(y);let l=an(f).map(C=>({uri:C,localName:C.name})),u=$(f,Ie),m=$(f,sn);a.push({uri:p,localName:p.name,superClasses:l,properties:dn(o,p,s,c),...u!==void 0?{label:u}:{},...m!==void 0?{comment:m}:{}}),le(f,Ne)&&i.push({uri:p,localName:p.name,members:un(o,f),...u!==void 0?{label:u}:{},...m!==void 0?{comment:m}:{}})}return{classes:a,enums:i}}export{be as a,Ce as b,z as c,R as d,Le as e,_ as f,ve as g,Be as h,W as i,Xe as j,Ye as k,on as l,fn as m};
@@ -1 +0,0 @@
1
- var o=class{constructor(e,n){this.doc=e;this.broader=n}doc;broader;async getAllDocumentsAsync(){return[this.doc]}async getDocumentAsync(e){return this.broader.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,n){return this.broader.getDocumentsByNamespaceAsync(e,n)}async getHighestCompatibleVersionAsync(e,n){return this.broader.getHighestCompatibleVersionAsync(e,n)}async saveDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async deleteDocumentAsync(){throw new Error("SingleDocumentRepository is read-only")}async clearNamespaceAsync(){throw new Error("SingleDocumentRepository is read-only")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}async getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}};export{o as a};
@@ -1 +0,0 @@
1
- import{a as y}from"./chunk-FUUTGGJS.js";import{c as x,g as j}from"./chunk-2ACBWC7K.js";var c=class{};var m=class extends c{statement=[];unresolvedPredicates=[];sourceDoc=""};var f=class extends m{namespace;name;icon};var i=class e extends c{subject;static parse(t){let n=new e;return n.subject=y.parse(t),n}};var o=class{predicate;object};var s=class extends o{carrier;lexical};var k=class e extends s{static parse(t,n){let r=new e;return r.predicate=i.parse(t),r.object=n,r}};var b=class e extends s{static parse(t,n){let r=new e;return r.predicate=i.parse(t),r.object=n,r}};var l=class extends s{};var u=class e extends o{static parse(t,n){let r=new e;return r.predicate=i.parse(t),r.object=i.parse(n),r}};var g=class extends o{};var K=class extends o{};function se(e){return`${e.publisher}/${e.package_}/${e.name}`}function U(e,t){return e.publisher===t.publisher&&e.package_===t.package_&&e.name===t.name}function ce(e){let t=e.version;return t&&typeof t.major=="number"?`https://${e.publisher}/${e.package_}/${t.major}.${t.minor}.${t.patch}/${e.name}`:`https://${e.publisher}/${e.package_}/${e.name}`}function h(e,t){if(!(e instanceof m))return!1;for(let n of e.statement)if(n.predicate?.subject?.name==="type"&&n instanceof u){let a=n.object;if(U(a.subject,t))return!0}return!1}function me(e,t){let n=[];for(let r of e)r instanceof f&&h(r,t)&&n.push(r);return n}function fe(e,t){let n=t.version,r=n&&typeof n.major=="number"?`${t.publisher}/${t.package_}@${n.major}.${n.minor}.${n.patch}`:void 0;for(let a of e){if(!(a instanceof f)||a.name!==t.name)continue;let p=a.namespace||"";if(r!==void 0){if(p===r)return a}else if(p.startsWith(`${t.publisher}/${t.package_}@`))return a}}function pe(e,t){let n=[];for(let r of e){if(!(r instanceof f)||r.name!==t.name)continue;(r.namespace||"").startsWith(`${t.publisher}/${t.package_}@`)&&n.push(r)}return n.sort((r,a)=>{let p=j((r.namespace||"").split("@")[1]??""),S=j((a.namespace||"").split("@")[1]??"");return p?S?x(S,p):-1:S?1:0}),n}function d(e,t){for(let n of e.statement){let r=n.predicate;if(r?.subject&&U(r.subject,t))return n}}function ue(e,t){return d(e,t)!==void 0}function $(e,t){let n=d(e,t);if(n&&(n instanceof k||n instanceof b||n instanceof l))return n.object}function de(e,t){let n=$(e,t);return typeof n=="string"?n:void 0}function ke(e,t){let n=d(e,t);if(n instanceof u)return n.object.subject}function be(e,t){let n=d(e,t);if(n instanceof g)return n.object}function le(e,t){let n=d(e,t);return n instanceof K?n.object??[]:[]}export{c as a,m as b,f as c,i as d,o as e,s as f,k as g,b as h,l as i,u as j,g as k,K as l,se as m,U as n,ce as o,h as p,me as q,fe as r,pe as s,ue as t,$ as u,de as v,ke as w,be as x,le as y};
@@ -1,63 +0,0 @@
1
- import{a as mt}from"./chunk-ITKOKDBG.js";import{a as v,b as Me,c as it,g as M,j as ct,l as S}from"./chunk-MX3DEXMV.js";import{a as rt}from"./chunk-NJ3AZYQD.js";import{a as y,d as A,e as Y,f as pt,g as L,h as lt}from"./chunk-ZP6P7HNU.js";import{a as G}from"./chunk-6U26UASC.js";import{h as Fe,i as st}from"./chunk-GZPLWII7.js";import{c as d,d as I,j as Be,k as H,l as F,m as K,n as z,p as P,r as h,t as J,u as x,v as W,w as g,x as O,y as V}from"./chunk-7BHDZHJY.js";import{a as at}from"./chunk-FUUTGGJS.js";import{e as U}from"./chunk-2ACBWC7K.js";var Q=class{isValid=!1;errors=[];warnings=[];infos=[];get totalIssues(){return this.errors.length+this.warnings.length+this.infos.length}get allDiagnostics(){return[...this.errors,...this.warnings,...this.infos]}};var k=(o=>(o.Info="Info",o.Warning="Warning",o.Error="Error",o))(k||{});var u=class{ruleType="";severity="Error";lineNumber;column;entityName;propertyName;propertyPath;message="";suggestion;actualValue;expectedValue;toString(){let e="";return this.lineNumber!==void 0&&(e+=`Line ${this.lineNumber}: `),this.entityName&&(e+=`[${this.entityName}] `),e+=this.message,e}};var ze=class c{resolvedDocuments=[];currentEntityPath;withPath(e){let t=new c;return t.resolvedDocuments=this.resolvedDocuments,t.currentEntityPath=e,t}};var ee=class{constructor(e){this.underlying=e;this.repository=new Xe(e)}underlying;repository;parsePromise=null;getKanonaks(){return this.parseOnce().then(e=>e.merged)}getAuthoredKanonaks(){return this.parseOnce().then(e=>e.authored)}parseOnce(){return this.parsePromise||(this.parsePromise=(async()=>{let e=await this.underlying.getAllDocumentsAsync();await mt(e,this.repository);let t={};return{merged:await new S().parseKanonaks(this.underlying,t),authored:t.authored??[]}})()),this.parsePromise}},Xe=class{constructor(e){this.inner=e}inner;highestVersionCache=new Map;byNamespaceCache=new Map;getAllDocumentsAsync(){return this.inner.getAllDocumentsAsync()}getDocumentAsync(e){return this.inner.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){let o=`${e}/${t}`,n=this.byNamespaceCache.get(o);return n||(n=this.inner.getDocumentsByNamespaceAsync(e,t),this.byNamespaceCache.set(o,n),n)}getHighestCompatibleVersionAsync(e,t){let o=t.version,n=o?`${o.major}.${o.minor}.${o.patch}`:"",r=`${e}/${t.packageName}@${t.versionOperator}:${n}`,a=this.highestVersionCache.get(r);return a||(a=this.inner.getHighestCompatibleVersionAsync(e,t),this.highestVersionCache.set(r,a),a)}saveDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}deleteDocumentAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}clearNamespaceAsync(){throw new Error("CachingRepository is read-only during a validation pass.")}getAllDocumentReferencesAsync(){return this.inner.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.inner.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.inner.getDocumentUriAsync(e)}};async function D(c,e,t){return t?t.getKanonaks():new S().parseKanonaks(new te(c,e))}async function C(c,e,t){let o=await D(c,e,t),n=We(c);return n?o.filter(r=>r instanceof d&&r.namespace===n):[]}async function oe(c,e,t){let o=We(c);if(!o)return[];let n;if(t)n=await t.getAuthoredKanonaks();else{let r={};await new S().parseKanonaks(new te(c,e),r),n=r.authored??[]}return n.filter(r=>r instanceof d&&r.sourceDoc===o)}function q(c,e){for(let t of c)t instanceof d&&Ze(t,t.name,e)}function Ze(c,e,t){t({kanonak:c,path:e});for(let o of c.statement)if(o instanceof H)Ze(o.object,ut(e,o.object),t);else if(o instanceof F)for(let n of o.object)n instanceof v&&Ze(n,ut(e,n),t)}function ut(c,e){let t=e instanceof v&&e.name?e.name:"<embedded>";return`${c}/${t}`}function We(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var te=class{constructor(e,t){this.document=e;this.broader=t}document;broader;async getAllDocumentsAsync(){let e=this.document.metadata.namespace_?.toString(),t=(await this.broader.getAllDocumentsAsync()).filter(o=>o.metadata.namespace_?.toString()!==e);return[this.document,...t]}getDocumentAsync(e){return this.broader.getDocumentAsync(e)}getDocumentsByNamespaceAsync(e,t){return this.broader.getDocumentsByNamespaceAsync(e,t)}getHighestCompatibleVersionAsync(e,t){return this.broader.getHighestCompatibleVersionAsync(e,t)}getAllDocumentReferencesAsync(){return this.broader.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.broader.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.broader.getDocumentUriAsync(e)}saveDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}deleteDocumentAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}clearNamespaceAsync(){throw new Error("DocumentWithRepositoryCatalog is read-only")}};var ne=class c{static NAMESPACE_PREFIX_PATTERN=/^(rdfs|xsd|owl|rdf|dc|foaf|skos|dct|dcterms|geo|time|prov|schema|og|dbo):/i;ruleName="NamespacePrefix";validate(e){let t=[];for(let[o,n]of Object.entries(e.body))n&&typeof n=="object"&&!Array.isArray(n)&&this.validateEntity(o,n,t);return t}validateEntity(e,t,o){for(let[n,r]of Object.entries(t)){let a=r?.toString()??"";if(a&&c.NAMESPACE_PREFIX_PATTERN.test(a)){let i=this.getSuggestionForPrefixedValue(a),s=e.split(".")[0],p=new u;p.ruleType=this.ruleName,p.severity="Error",p.entityName=s,p.propertyName=e,p.actualValue=n,p.expectedValue=i,p.message=`Invalid namespace prefix '${a}'. Use '${i}' without prefix.`,p.suggestion="Kanonak YAML uses simple type names. Namespace resolution is handled through imports.",o.push(p)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validateEntity(`${e}.${n}`,r,o)}}getSuggestionForPrefixedValue(e){let t=e.toLowerCase();if(t==="rdfs:class"||t==="owl:class")return"Class";if(t==="rdfs:property"||t==="rdf:property")return"DatatypeProperty or ObjectProperty";if(t.startsWith("xsd:"))return e.substring(4);let o=e.indexOf(":");return o>=0?e.substring(o+1):e}};var re=class c{static RESERVED_WORDS=new Set(["imports","namespace","type","label","comment","subclassof","domain","range","required","functional"]);static VALID_PROPERTIES=new Set(["type","label","comment","subClassOf","subPropertyOf","domain","range","required","functional","inverseOf","transitive","symmetric","inverseFunctional"]);static VALID_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_AUGMENTATION_PATTERN=/^[a-zA-Z][a-zA-Z0-9_-]*\.[a-zA-Z][a-zA-Z0-9_-]*$/;static VALID_PROPERTY_NAME_PATTERN=/^[a-zA-Z][a-zA-Z0-9_.]*$/;ruleName="ResourceNaming";validate(e){let t=[],o=e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-");for(let[n,r]of Object.entries(e.body)){let a=c.VALID_AUGMENTATION_PATTERN.test(n);if(!a&&!o&&c.RESERVED_WORDS.has(n.toLowerCase())){let i=new u;i.ruleType=this.ruleName,i.severity="Error",i.entityName=n,i.message=`Entity name '${n}' is a reserved word and cannot be used.`,i.suggestion="Choose a different name that doesn't conflict with Kanonak reserved words.",t.push(i);continue}if(!a&&!c.VALID_NAME_PATTERN.test(n)){let i;/^\d/.test(n)?i="Entity names must start with a letter, not a number.":n.includes(" ")?i="Entity names cannot contain spaces. Use camelCase or underscores instead.":i="Entity names must start with a letter and contain only letters, numbers, and underscores.";let s=new u;s.ruleType=this.ruleName,s.severity="Error",s.entityName=n,s.message=`Invalid entity name '${n}'. ${i}`,s.suggestion=i,t.push(s)}r&&typeof r=="object"&&!Array.isArray(r)&&this.validatePropertyNames(n,r,t)}return t}validatePropertyNames(e,t,o){for(let n of Object.keys(t))if(!c.VALID_PROPERTIES.has(n)&&!c.VALID_PROPERTY_NAME_PATTERN.test(n)){let r=new u;r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=n,r.message=`Property name '${n}' in entity '${e}' doesn't follow naming conventions.`,r.suggestion="Property names should start with a letter and contain only letters, numbers, and underscores.",o.push(r)}}};var ae=class c{static XSD_TYPES=new Set(["string","integer","int","long","short","byte","decimal","float","double","boolean","bool","datetime","date","time","duration","anyuri","anysimpletype","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte","base64binary","hexbinary"]);ruleName="PropertyTypeSpecificity";validate(e){let t=[];if(e.metadata?.namespace_?.publisher==="kanonak.org"&&e.metadata?.namespace_?.package_?.startsWith("core-"))return t;let o=this.isPropertyDefinedAsClass(e);for(let[n,r]of Object.entries(e.body))if(r&&typeof r=="object"&&!Array.isArray(r)){let a=r,i=a.type;if(i){let s=[];if(Array.isArray(i))for(let p of i){let l=p?.toString();l&&l==="Property"&&!o&&s.push(l)}else{let p=i?.toString();p&&p==="Property"&&!o&&s.push(p)}for(let p of s){let l=this.getPropertyValue(a,"range"),m=this.determinePropertyType(l),f=new u;f.ruleType=this.ruleName,f.severity="Error",f.entityName=n,f.propertyName="type",f.actualValue=p,f.expectedValue=m,f.message=`Invalid property type '${p}'. Use '${m}' instead.`,f.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",t.push(f)}}}return t}determinePropertyType(e){return!e||e.trim().length===0?"DatatypeProperty or ObjectProperty":c.XSD_TYPES.has(e.toLowerCase())?"DatatypeProperty":/^[A-Z]/.test(e)?"ObjectProperty":"DatatypeProperty or ObjectProperty"}getPropertyValue(e,t){let o=e[t];return o?o.toString():null}isPropertyDefinedAsClass(e){let t=e.body.Property;if(t&&typeof t=="object"&&!Array.isArray(t)){let n=t.type;if(n){let r=n.toString();return r==="Class"||r.endsWith(".Class")}}return!1}};var ie=class{get ruleName(){return"SubjectKanonakTypeRequired"}validate(e){let t=[];for(let[o,n]of Object.entries(e.body)){if(typeof n!="object"||n===null||Array.isArray(n)||o.includes("."))continue;let r=n,a="type"in r,i=r.type?.toString().trim();if(!a||!i){let s=new u;s.ruleType=this.ruleName,s.severity="Error",s.entityName=o,s.propertyName="type",s.message=`Subject Kanonak '${o}' must have a 'type' property.`,s.suggestion=`Add a type statement like:
2
- type: Scene
3
-
4
- Only embedded objects can infer type from their parent property's range. Subject Kanonaks (top-level entities) must explicitly declare their type.`,s.expectedValue="A valid class name (Scene, Character, Story, etc.)",t.push(s)}}return t}};var At=new Set(["EphemeralPackage"]),se=class{get ruleName(){return"PackageHeader"}validate(e){let t=e.metadata;if(!t.type_)return[];let o=[],n=this.packageKey(e,t.type_);return t.namespace_?(!At.has(t.type_)&&!t.namespace_.version&&o.push(this.error(n,"version",`Package resource '${n}' requires a 'version' property \u2014 packages are addressed by name@version.`,`Add a version, e.g.:
5
- version: 1.0.0`)),o):(o.push(this.error(n,"publisher",`Package resource '${n}' requires a 'publisher' property.`,`Add a publisher, e.g.:
6
- publisher: example.org`)),o)}packageKey(e,t){for(let[o,n]of Object.entries(e.body))if(n&&typeof n=="object"&&!Array.isArray(n)&&n.type===t)return o;return t}error(e,t,o,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.message=o,r.suggestion=n,r}};var wt={publisher:"kanonak.org",package_:"core-rdf",name:"type"},xt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},Tt={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},Nt={publisher:"kanonak.org",package_:"core-rdf",name:"Class"},ce=class{ruleName="EmbeddedKanonakType";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await oe(e,t,o);for(let i of a)i instanceof d&&this.walk(r,i,i.name,n);return n}walk(e,t,o,n){for(let r of t.statement)if(r instanceof H){let a=r.predicate?.subject,i=`${o}.${a?.name??"<embedded>"}`;this.check(e,a,r.object,o,i,n),this.walk(e,r.object,i,n)}else if(r instanceof F){let a=r.predicate?.subject,i=0;for(let s of r.object){if(s instanceof v){let p=`${o}.${a?.name??"<embedded>"}[${i}]`;this.check(e,a,s,o,p,n),this.walk(e,s,p,n)}i++}}}check(e,t,o,n,r,a){if(!t)return;let i=g(o,wt);if(!i)return;let s=h(e,t);if(!s)return;let p=g(s,xt);if(p&&!(z(p,Tt)||z(p,Nt))){if(K(i)===K(p)){a.push(this.redundant(n,r,i,p));return}Y(e,i).some(l=>K(l)===K(p))||a.push(this.notSubclass(n,r,i,p))}}redundant(e,t,o,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e,r.propertyName=t,r.actualValue=o.name,r.expectedValue=n.name,r.message=`Embedded object at '${t}' declares 'type: ${o.name}', which equals the parent property's range '${n.name}'. The declaration is redundant \u2014 the type is already inferred from the property's range.`,r.suggestion=`Remove the 'type: ${o.name}' line, or keep it if explicitness is preferred over concision.`,r}notSubclass(e,t,o,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.actualValue=o.name,r.expectedValue=n.name,r.message=`Embedded object at '${t}' has 'type: ${o.name}', which is not a subclass of the parent property's range '${n.name}'.`,r.suggestion=`Either remove the 'type: ${o.name}' line (so the type is inferred from the property's range '${n.name}'), or add 'subClassOf: ${n.name}' to the '${o.name}' class definition so the relationship holds.`,r}};import{VersionOperator as He}from"@kanonak-protocol/types/document/models/enums";var pe=class{ruleName="ImportExistence";async validateAsync(e,t){let o=[];if(!e.metadata?.imports)return o;let n=await t.getAllDocumentsAsync();for(let[r,a]of Object.entries(e.metadata.imports))for(let i of a)if(!await t.getHighestCompatibleVersionAsync(r,i)){let p=await this.determineImportErrorAsync(t,r,i,n),l=new u;l.ruleType=this.ruleName,l.severity="Error",l.message=p.message,l.suggestion=p.suggestion,l.entityName=`Import: ${r}/${i.packageName}`,l.actualValue=i.toString(),l.expectedValue=p.expectedValue,o.push(l)}return o}async determineImportErrorAsync(e,t,o,n){let r=await e.getDocumentsByNamespaceAsync(t,o.packageName);if(r.length===0){let p=n.filter(R=>R.metadata.namespace_?.publisher===t).map(R=>R.metadata.namespace_.package_).filter((R,E,N)=>N.indexOf(R)===E),l=this.findSimilarPackages(o.packageName,p),m=`Import '${t}/${o.package_}' not found - package does not exist`,f=l.length>0?`Did you mean: ${l.slice(0,3).join(", ")}?`:p.length>0?`Available packages in ${t}: ${p.slice(0,5).join(", ")}`:`No packages found for publisher '${t}'. Verify the publisher name is correct.`;return{message:m,suggestion:f,expectedValue:"Existing package"}}let i=r.filter(p=>p.metadata.namespace_?.version).map(p=>p.metadata.namespace_.version.toString()).sort().join(", "),s=this.getAcceptableVersionRange(o);return{message:`Import '${t}/${o.toString()}' version mismatch - no compatible version found`,suggestion:`Available versions: ${i}. Required: ${s}`,expectedValue:s}}getAcceptableVersionRange(e){switch(e.versionOperator){case He.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case He.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case He.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case He.Any:return`any version >= ${e.version.major}.${e.version.minor}.${e.version.patch}`;default:return e.toString()}}findSimilarPackages(e,t){if(t.length===0)return[];let o=t.filter(a=>a.toLowerCase().includes(e.toLowerCase())||e.toLowerCase().includes(a.toLowerCase()));if(o.length>0)return o.sort((a,i)=>a.length-i.length);let n=t.map(a=>({package:a,distance:this.levenshteinDistance(e.toLowerCase(),a.toLowerCase())})).sort((a,i)=>a.distance-i.distance),r=Math.max(3,Math.floor(e.length*.4));return n.filter(a=>a.distance<=r).map(a=>a.package)}levenshteinDistance(e,t){if(!e||e.length===0)return t?.length??0;if(!t||t.length===0)return e.length;let o=e.length,n=t.length,r=Array(o+1).fill(null).map(()=>Array(n+1).fill(0));for(let a=0;a<=o;a++)r[a][0]=a;for(let a=0;a<=n;a++)r[0][a]=a;for(let a=1;a<=o;a++)for(let i=1;i<=n;i++){let s=e[a-1]===t[i-1]?0:1;r[a][i]=Math.min(Math.min(r[a-1][i]+1,r[a][i-1]+1),r[a-1][i-1]+s)}return r[o][n]}};var _t="kanonak.org",Lt="core-rdf",Mt=new Set(["type","subClassOf","subPropertyOf","domain","range"].map(c=>K({publisher:_t,package_:Lt,name:c}))),le=class{ruleName="UnresolvedReference";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await C(e,t,o);return q(a,({kanonak:i,path:s})=>{for(let p of i.statement){let l=Bt(p);if(!(!l||Mt.has(K(l)))){if(p instanceof Be)this.check(r,s,l,p.object,n);else if(p instanceof F)for(let m of p.object)m instanceof I&&this.check(r,s,l,m,n)}}}),n}check(e,t,o,n,r){h(e,n.subject)||r.push(this.unresolvedError(t,o.name,n.subject))}unresolvedError(e,t,o){let n=`${o.publisher}/${o.package_}/${o.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName=t,r.actualValue=n,r.expectedValue="A reference that resolves to a defined or imported resource",r.message=`Reference to '${o.name}' in '${t}' could not be resolved`,r.suggestion=`The entity '${n}' is not defined in this namespace or any imported namespace.
7
- \u2022 Import the package that defines it, or check for a typo in '${o.name}'
8
- \u2022 If it lives in an imported namespace, alias-qualify the reference`,r}};function Bt(c){return c.predicate?.subject}var ft={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},dt={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"};function Ft(c,e){let t=g(c,e);if(t)return[t];let o=[];for(let n of V(c,e))n instanceof I&&o.push(n.subject);return o}function Ge(c,e,t){let o=[],n=new Set,r=new Set,a=i=>{let s=h(c,i),p=s?`${s.namespace}/${s.name}`:K(i);if(n.has(p)){let l=o.findIndex(f=>f.key===p),m=o.slice(l);return m.length<=1?null:[...m.map(f=>f.uri),i]}if(r.has(p))return null;if(n.add(p),o.push({key:p,uri:i}),s)for(let l of Ft(s,t)){let m=a(l);if(m)return m}return o.pop(),n.delete(p),r.add(p),null};return a(e)}var yt=c=>c,me=class{ruleName="ClassHierarchyCycle";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof d)||!(y.isClassType(yt(i))||y.isDatatypeType(yt(i))))continue;let s=A(i);if(!s)continue;let p=Ge(r,s,ft);if(p){let l=p.map(f=>f.name).join(" \u2192 "),m=new u;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular class hierarchy detected: ${l}`,m.suggestion="Remove the circular dependency by breaking one of the subClassOf relationships",m.entityName=i.name,m.propertyName="subClassOf",m.actualValue=l,n.push(m);break}}return n}};var Wt=c=>c,ue=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof d)||!y.isAnyPropertyType(Wt(i)))continue;let s=A(i);if(!s)continue;let p=Ge(r,s,dt);if(p){let l=p.map(f=>f.name).join(" \u2192 "),m=new u;m.ruleType=this.ruleName,m.severity="Error",m.message=`Circular property hierarchy detected: ${l}`,m.suggestion="Remove the circular dependency by breaking one of the subPropertyOf relationships",m.entityName=i.name,m.propertyName="subPropertyOf",m.actualValue=l,n.push(m);break}}return n}};var Ht={publisher:"kanonak.org",package_:"core-rdf",name:"range"},gt=c=>c,fe=class{ruleName="PropertyRangeRequired";async validateAsync(e,t,o){let n=[],r=await C(e,t,o);for(let a of r){if(!(a instanceof d))continue;let i=y.isObjectPropertyType(gt(a));!i&&!y.isDatatypePropertyType(gt(a))||J(a,Ht)||n.push(this.error(a.name,i))}return n}error(e,t){let o=new u;return o.ruleType=this.ruleName,o.severity="Error",o.entityName=e,o.propertyName="range",o.message=`Property '${e}' must have a 'range' defined.`,o.suggestion=t?"Add a range like: range: ClassName (the class this property expects)":"Add a range like: range: string (or integer, boolean, etc.)",o.expectedValue=t?"A class name (Character, Scene, Story, etc.)":"A datatype (string, integer, boolean, decimal, etc.)",o}};var Gt={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},kt=c=>c,de=class{ruleName="SubClassOfReference";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof d)||!ht(kt(i)))continue;let s=Yt(i,Gt);for(let p=0;p<s.length;p++)this.resolvesToClassLike(r,s[p])||n.push(this.error(i.name,s[p],s.length>1?`[${p}]`:""))}return n}resolvesToClassLike(e,t){let o=h(e,t);return o?ht(kt(o)):!1}error(e,t,o){let n=`${t.publisher}/${t.package_}/${t.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="subClassOf",r.actualValue=n,r.expectedValue="Defined or imported class",r.message=`Class '${t.name}' referenced in subClassOf${o} is not defined or imported`,r.suggestion=`Define '${t.name}' as a Class, or import a namespace that contains it`,r}};function ht(c){return y.isClassType(c)||y.isDatatypeType(c)}function Yt(c,e){let t=g(c,e);if(t)return[t];let o=[];for(let n of V(c,e))n instanceof I&&o.push(n.subject);return o}var qt={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"},Rt=c=>c,ye=class{ruleName="SubPropertyOfReference";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof d)||!y.isAnyPropertyType(Rt(i)))continue;let s=zt(i,qt);for(let p=0;p<s.length;p++)this.resolvesToProperty(r,s[p])||n.push(this.error(i.name,s[p],s.length>1?`[${p}]`:""))}return n}resolvesToProperty(e,t){let o=h(e,t);return o?y.isAnyPropertyType(Rt(o)):!1}error(e,t,o){let n=`${t.publisher}/${t.package_}/${t.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="subPropertyOf",r.actualValue=n,r.expectedValue="Defined or imported property",r.message=`Property '${t.name}' referenced in subPropertyOf${o} is not defined or imported`,r.suggestion=`Define '${t.name}' as a property, or import a namespace that contains it`,r}};function zt(c,e){let t=g(c,e);if(t)return[t];let o=[];for(let n of V(c,e))n instanceof I&&o.push(n.subject);return o}var ge=class{get ruleName(){return"NamespaceImportCycle"}async validateAsync(e,t){let o=[],n=e.metadata.namespace_?.toString();if(!n)return o;let r=new Map,a=new Set;await this.buildImportGraph(e,t,r,a);let i=this.detectCycle(n,r);if(i){let s=i.join(" \u2192 "),p=new u;p.ruleType=this.ruleName,p.severity="Error",p.message=`Circular namespace import detected: ${s}`,p.suggestion="Remove one of the imports to break the circular dependency. Circular dependencies prevent proper package resolution.",p.entityName="imports",p.propertyName="imports",p.actualValue=s,o.push(p)}return o}async buildImportGraph(e,t,o,n){let r=e.metadata.namespace_?.toString()??"";if(!(!r||n.has(r))&&(n.add(r),e.metadata.imports)){let a=[];for(let[i,s]of Object.entries(e.metadata.imports))for(let p of s){let l=`${i}/${p.packageName}@${p.version}`;a.push(l);let m=await t.getHighestCompatibleVersionAsync(i,p);m&&await this.buildImportGraph(m,t,o,n)}a.length>0&&o.set(r,a)}}detectCycle(e,t){let o=[],n=new Set;return this.detectCycleRecursive(e,t,o,n)}detectCycleRecursive(e,t,o,n){let r=o.indexOf(e);if(r>=0){let i=o.slice(r);return i.push(e),i}if(n.has(e))return null;o.push(e),n.add(e);let a=t.get(e);if(a)for(let i of a){let s=this.detectCycleRecursive(i,t,o,n);if(s)return s}return o.pop(),null}};var ke=class{ruleName="UnresolvedPredicate";async validateAsync(e,t,o){let n=[],r=We(e);if(!r)return n;let a=await D(e,t,o);return q(a,({kanonak:i,path:s})=>{for(let p of i.unresolvedPredicates)p.sourceDoc===r&&n.push(this.unresolvedPredicateError(s,p.key))}),n}unresolvedPredicateError(e,t){let o=t.lastIndexOf("."),n=o>0?t.slice(0,o):null,r=o>0?t.slice(o+1):t,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=t,a.actualValue=t,a.expectedValue="A defined or imported property",a.message=`Property '${t}' is not defined or imported`,a.suggestion=n?`The property '${r}' was not found in the namespace imported as '${n}'.
9
- 1. Check '${r}' is spelled correctly
10
- 2. Verify '${n}' is imported with the right alias and version
11
- 3. Ensure that namespace version actually defines '${r}'`:`The property '${t}' is not defined in this namespace or any imported namespace.
12
- 1. Define '${t}' as an ObjectProperty or DatatypeProperty here, OR
13
- 2. Import the namespace that defines it, OR
14
- 3. Alias-qualify it if it lives in an imported namespace ('alias.${t}')`,a}};var he=class{get ruleName(){return"AmbiguousReference"}async validateAsync(e,t){let o=[],{entitySources:n,importPaths:r}=await this.buildEntitySourceMapAsync(e,t),a=await this.buildDatatypePropertyNamesAsync(e,t);for(let[i,s]of Object.entries(e.body))typeof s=="object"&&s!==null&&!Array.isArray(s)&&this.validateEntityReferences(i,s,n,r,a,e,o);return o}async buildEntitySourceMapAsync(e,t){let o=new Map,n=new Set,r=new Map;for(let a of Object.keys(e.body)){let i=e.metadata.namespace_?.toString()??"";o.has(a)||o.set(a,[]),o.get(a).push(`(local:${i})`)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let s of i){let p=await t.getHighestCompatibleVersionAsync(a,s);if(p){let l=p.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(p,o,n,r,[l],t)}}return{entitySources:o,importPaths:r}}async collectEntitiesRecursivelyAsync(e,t,o,n,r,a){let i=e.metadata.namespace_?.toString()??"";if(!o.has(i)){o.add(i),n.has(i)||n.set(i,r);for(let s of Object.keys(e.body)){t.has(s)||t.set(s,[]);let p=t.get(s);p.includes(i)||p.push(i)}if(e.metadata.imports)for(let[s,p]of Object.entries(e.metadata.imports))for(let l of p){let m=await a.getHighestCompatibleVersionAsync(s,l);if(m){let f=m.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(m,t,o,n,[...r,f],a)}}}}async buildDatatypePropertyNamesAsync(e,t){let o=new Set,n=new Set;if(await this.collectDatatypePropertiesAsync(e,o,n,t),e.metadata.imports)for(let[r,a]of Object.entries(e.metadata.imports))for(let i of a){let s=await t.getHighestCompatibleVersionAsync(r,i);s&&await this.collectDatatypePropertiesAsync(s,o,n,t)}return o}async collectDatatypePropertiesAsync(e,t,o,n){let r=e.metadata.namespace_?.toString()??"";if(!o.has(r)){o.add(r);for(let[a,i]of Object.entries(e.body)){if(typeof i!="object"||i===null||Array.isArray(i))continue;let s=i.type;if(typeof s!="string")continue;(s.includes(".")?s.substring(s.lastIndexOf(".")+1):s)==="DatatypeProperty"&&t.add(a)}if(e.metadata.imports)for(let[a,i]of Object.entries(e.metadata.imports))for(let s of i){let p=await n.getHighestCompatibleVersionAsync(a,s);p&&await this.collectDatatypePropertiesAsync(p,t,o,n)}}}validateEntityReferences(e,t,o,n,r,a,i){for(let[s,p]of Object.entries(t)){let l=s;if(l&&!l.includes(".")){let m=o.get(l);if(m&&m.length>1&&!m.some(R=>R.startsWith("(local:"))){let R=m.filter(E=>!E.startsWith("(local:"));R.length>1&&i.push(this.createAmbiguityError(e,l,`Property '${l}'`,R,n,a,!0,l))}}this.validatePropertyValue(e,l,p,o,n,r,a,i)}}validatePropertyValue(e,t,o,n,r,a,i,s){if(o==null)return;let p=t&&t.includes(".")?t.substring(t.lastIndexOf(".")+1):t,l=!!p&&a.has(p);if(typeof o=="string"&&!o.includes(".")&&!l){let m=n.get(o);if(m&&m.length>1&&!m.some(R=>R.startsWith("(local:"))){let R=m.filter(E=>!E.startsWith("(local:"));R.length>1&&s.push(this.createAmbiguityError(e,t,`Reference '${o}'`,R,r,i,!1,o))}}else if(Array.isArray(o))for(let m=0;m<o.length;m++){let f=`${e}.${t}[${m}]`;this.validatePropertyValue(f,t,o[m],n,r,a,i,s)}else if(typeof o=="object"&&!Array.isArray(o)){let m=t?`${e}.${t}`:e;this.validateEntityReferences(m,o,n,r,a,i,s)}}createAmbiguityError(e,t,o,n,r,a,i,s){let p=[];for(let j of n){let $=this.findAliasForNamespace(a,j);if($){let B=t?.split(".").pop()??t;p.push(`${$}.${B}`)}}let l=p.length>0?`Use one of: ${p.map(j=>`'${j}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${t}')`,m=n.map(j=>{let $=r.get(j);return!$||$.length===0?` \u2022 ${j}`:$.length===1?` \u2022 ${j} (direct import)`:` \u2022 ${j}
15
- imported via: ${$.join(" \u2192 ")}`}).join(`
16
- `),f=e.split(".")[0],R=e.includes(".")?e:t,E=new u;E.ruleType=this.ruleName,E.severity="Error",E.entityName=f,R&&(E.propertyName=R);let N=s??t;return N&&(E.actualValue=N),E.message=`${o} is ambiguous - defined in multiple imported namespaces`,E.suggestion=`${l}
17
-
18
- Defined in:
19
- ${m}`,E.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",E}findAliasForNamespace(e,t){if(!e.metadata.imports)return null;for(let[o,n]of Object.entries(e.metadata.imports))for(let r of n)if(`${o}/${r.packageName}@${r.version}`===t&&r.alias)return r.alias;return null}};var Xt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},Ye=c=>c,Re=class{ruleName="PropertyRangeReference";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof d))continue;let s=y.isObjectPropertyType(Ye(i));if(!(!s&&!y.isDatatypePropertyType(Ye(i))))for(let p of Zt(i,Xt))this.resolvesToClassLike(r,p)||n.push(this.error(i.name,p,s))}return n}resolvesToClassLike(e,t){let o=h(e,t);return o?y.isClassType(Ye(o))||y.isDatatypeType(Ye(o)):!1}error(e,t,o){let n=`${t.publisher}/${t.package_}/${t.name}`,r=new u;return r.ruleType=this.ruleName,r.severity="Error",r.entityName=e,r.propertyName="range",r.actualValue=n,r.expectedValue=o?"A defined or imported class":"A datatype or defined class",r.message=`Property '${e}' has range '${t.name}' which is not defined or imported`,r.suggestion=o?`Define '${t.name}' as a Class here, or import the namespace that contains it (alias-qualify it if imported under an alias).`:`Use a datatype (xsd type, rdfs.Literal, or a datatype-derived type), or \u2014 if '${t.name}' is a class \u2014 make this an ObjectProperty.`,r}};function Zt(c,e){let t=g(c,e);if(t)return[t];let o=[];for(let n of V(c,e))n instanceof I&&o.push(n.subject);return o}var Jt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},Ke="kanonak.org",Je="core-rdf",Qe="core-owl",Qt=c=>c,eo=[{uri:{publisher:Ke,package_:Je,name:"Class"},ok:c=>y.isClassType(c)||y.isDatatypeType(c)},{uri:{publisher:Ke,package_:Je,name:"Datatype"},ok:c=>y.isDatatypeType(c)},{uri:{publisher:Ke,package_:Je,name:"Property"},ok:c=>y.isAnyPropertyType(c)},{uri:{publisher:Ke,package_:Qe,name:"ObjectProperty"},ok:c=>y.isObjectPropertyType(c)},{uri:{publisher:Ke,package_:Qe,name:"DatatypeProperty"},ok:c=>y.isDatatypePropertyType(c)},{uri:{publisher:Ke,package_:Qe,name:"AnnotationProperty"},ok:c=>y.isAnnotationPropertyType(c)}],be=class{ruleName="ObjectPropertyValue";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await oe(e,t,o);for(let i of a)i instanceof d&&this.walk(r,i,i.name,n);return n}walk(e,t,o,n){for(let r of t.statement)if(r instanceof Be)this.check(e,r.predicate?.subject,r.object.subject,o,n);else if(r instanceof H)this.walk(e,r.object,Kt(o,r.predicate?.subject),n);else if(r instanceof F){let a=r.predicate?.subject;for(let i of r.object)i instanceof I?this.check(e,a,i.subject,o,n):i instanceof v&&this.walk(e,i,Kt(o,a),n)}}check(e,t,o,n,r){if(!t)return;let a=h(e,t);if(!a)return;let i=g(a,Jt);if(!i)return;let s=eo.find(l=>z(i,l.uri));if(!s)return;let p=h(e,o);p&&(s.ok(Qt(p))||r.push(this.warn(n,t,i,o)))}warn(e,t,o,n){let r=new u;return r.ruleType=this.ruleName,r.severity="Warning",r.entityName=e.split(".")[0],r.propertyName=e,r.actualValue=n.name,r.expectedValue=o.name,r.message=`Property '${t.name}' expects a ${o.name}, but '${n.name}' is not a ${o.name}`,r.suggestion=`Reference a resource that is a ${o.name}, or correct the type of '${n.name}'.`,r}};function Kt(c,e){return`${c}.${e?.name??"<embedded>"}`}var to={publisher:"kanonak.org",package_:"core-rdf",name:"type"},oo={publisher:"kanonak.org",package_:"core-rdf",name:"domain"},no={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},Ve=class{ruleName="PropertyDomain";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await oe(e,t,o);for(let i of a)i instanceof d&&this.walk(r,i,i.name,n);return n}walk(e,t,o,n){this.checkNode(e,t,o,n);for(let r of t.statement)if(r instanceof H)this.walk(e,r.object,Vt(o,r.predicate?.subject),n);else if(r instanceof F)for(let a of r.object)a instanceof v&&this.walk(e,a,Vt(o,r.predicate?.subject),n)}checkNode(e,t,o,n){let r=bt(t,to);if(r.length===0)return;let a,i=()=>{if(!a){a=new Set([K(no)]);for(let p of r)for(let l of Y(e,p))a.add(K(l))}return a},s=new Set;for(let p of t.statement){let l=ro(p);if(!l||Fe(l.name)||s.has(K(l)))continue;s.add(K(l));let m=h(e,l);if(!m)continue;let f=bt(m,oo);f.length!==0&&(f.some(R=>i().has(K(R)))||n.push(this.error(o,l,f,r[0])))}}error(e,t,o,n){let r=o.map(i=>i.name).join(" | "),a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e.split(".")[0],a.propertyName=e,a.actualValue=t.name,a.expectedValue=`Property used on ${r} or its subclasses`,a.message=`Property '${t.name}' has domain '${r}' but is used on '${n.name}' at '${e}'`,a.suggestion=`Either:
20
- 1. Use '${t.name}' only on '${r}' (or a subclass) instances
21
- 2. Widen the property's domain to include '${n.name}'
22
- 3. Use a different property for '${n.name}'`,a}};function ro(c){return c.predicate?.subject}function bt(c,e){let t=g(c,e);if(t)return[t];let o=[];for(let n of V(c,e))n instanceof I&&o.push(n.subject);return o}function Vt(c,e){return`${c}.${e?.name??"<embedded>"}`}var ao={publisher:"kanonak.org",package_:"core-rdf",name:"range"},io={publisher:"kanonak.org",package_:"core-rdf",name:"Literal"},et=c=>c,Ee=class{ruleName="PropertyKindRangeConsistency";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await C(e,t,o);for(let i of a){if(!(i instanceof d))continue;let s=y.isObjectPropertyType(et(i)),p=y.isDatatypePropertyType(et(i));if(!s&&!p)continue;let l=g(i,ao);if(!l||!h(r,l))continue;let m=so(r,l);p&&!m?n.push(this.error(i.name,l,"datatype")):s&&m&&n.push(this.error(i.name,l,"object"))}return n}error(e,t,o){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName="range",n.actualValue=t.name,o==="datatype"?(n.expectedValue="A datatype (xsd type, rdfs.Literal, or a datatype-derived class)",n.message=`DatatypeProperty '${e}' has range '${t.name}', which is a class, not a datatype. A datatype property's values are literals.`,n.suggestion=`Use a datatype range (e.g. xsd.string, rdfs.Literal, or a datatype-derived class), or \u2014 if '${t.name}' is the intended target \u2014 declare '${e}' an ObjectProperty.`):(n.expectedValue="A plain class (not datatype-derived)",n.message=`ObjectProperty '${e}' has range '${t.name}', which is a datatype, not a class. An object property's values are references to resources.`,n.suggestion=`Declare '${e}' a DatatypeProperty (its values are literals of '${t.name}'), or change the range to a plain class.`),n}};function so(c,e){for(let t of Y(c,e)){if(z(t,io))return!0;let o=h(c,t);if(o&&y.isDatatypeType(et(o)))return!0}return!1}var ve=class{ruleName="ReservedNameShadow";async validateAsync(e,t,o){let n=[],r=await C(e,t,o);for(let a of r){if(!(a instanceof d))continue;let i=st(a.name);if(!i)continue;let s=A(a);s&&(i.publisher===s.publisher&&i.package_===s.package_||n.push(this.info(a.name,s,i)))}return n}info(e,t,o){let n=new u;return n.ruleType=this.ruleName,n.severity="Info",n.entityName=e,n.propertyName=e,n.actualValue=`${t.publisher}/${t.package_}/${e}`,n.expectedValue=`${o.publisher}/${o.package_}/${e}`,n.message=`'${e}' is also the reserved built-in '${o.publisher}/${o.package_}/${e}'. This local definition shadows it \u2014 a bare '${e}' reference in this package resolves to the local entity, not the built-in.`,n.suggestion=`If this is intentional, qualify bare references to '${e}' explicitly (this local one vs. the built-in '${o.publisher}/${o.package_}/${e}') so the choice is unambiguous to readers and tools \u2014 e.g. a self-referential 'subClassOf: ${e}' silently resolves to this local entity.`,n}};var co={publisher:"kanonak.org",package_:"core-rdf",name:"type"},Et=c=>c,De=class{ruleName="ClassDefinition";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await C(e,t,o);return q(a,({kanonak:i,path:s})=>{for(let p of po(i,co))this.resolvesToClassLike(r,p)||n.push(this.error(s,p))}),n}resolvesToClassLike(e,t){if(Fe(t.name))return!0;let o=h(e,t);return o?y.isClassType(Et(o))||y.isDatatypeType(Et(o)):!1}error(e,t){let o=`${t.publisher}/${t.package_}/${t.name}`,n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName="type",n.actualValue=o,n.expectedValue="Defined or imported class",n.message=`Class '${t.name}' is not defined or imported`,n.suggestion=`Define '${t.name}' as a Class in this document, or import a namespace that contains it`,n}};function po(c,e){let t=g(c,e);if(t)return[t];let o=[];for(let n of V(c,e))n instanceof I&&o.push(n.subject);return o}var Ie=class{ruleName="MarkdownLink";async validateAsync(e,t,o){let n=[],r=await C(e,t,o);return q(r,({kanonak:a,path:i})=>{this.checkNode(a,i,n)}),n}checkNode(e,t,o){for(let n of e.statement){if(!(n instanceof it))continue;let r=n.predicate.subject?.name??"(unknown)";for(let a of n.links)a.target||o.push(this.unresolvedLinkError(t,r,a.reference));for(let a of ct(n.object))o.push(this.malformedLinkError(t,r,a.snippet))}}unresolvedLinkError(e,t,o){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=t,n.actualValue=o,n.message=`Embedded link [[${o}]] in '${t}' could not be resolved`,n.expectedValue="A reference resolvable through the document's import closure",n.suggestion=`The reference '${o}' inside a markdown value cannot be found in the current document or any imported namespace.
23
-
24
- Possible solutions:
25
- \u2022 Import the package that defines '${o}' so the link can resolve
26
- \u2022 Check for typos in the reference name
27
- \u2022 If the name collides across imports, alias-qualify it: [[alias.${o}]]`,n}malformedLinkError(e,t,o){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=t,n.actualValue=o,n.message=`Malformed embedded reference near '${o}' in '${t}'`,n.expectedValue="A single-line [[reference]] with no internal line break",n.suggestion=`A '[[' in '${t}' does not form a complete [[reference]] link.
28
-
29
- A reference may not span a line break \u2014 the most common cause is wrapping a
30
- long reference across two lines in a block scalar, e.g.:
31
- ... read for [[persistent-energy-
32
- shock]] held ...
33
- which is parsed as literal text, not a link. Keep each [[reference]] on one
34
- line (let the line run long), or check for an unterminated [[.`,n}};var vt="kanonak.org",Dt="look",lo={publisher:vt,package_:Dt,name:"displayLabel"},mo={publisher:vt,package_:Dt,name:"displaySummary"},Ce=class{ruleName="DisplayLensScope";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new S().parseKanonaks(new G(e,t));let a=uo(e);if(!a)return n;for(let i of r)i instanceof d&&i.namespace===a&&(this.checkLens(r,i,lo,"displayLabel",n),this.checkLens(r,i,mo,"displaySummary",n));return n}checkLens(e,t,o,n,r){let a=g(t,o);if(!a)return;let i=[],s=A(t);if(s&&i.push(s),i.push(...lt(t)),i.length===0)return;i.some(l=>L(e,l,a).ok)||r.push(this.scopeError(t.name,n,a.name))}scopeError(e,t,o){let n=new u;return n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=t,n.actualValue=o,n.message=`${t} points at '${o}', which is not a property in scope for '${e}'`,n.expectedValue="A property whose domain is this resource's class, an ancestor, or rdfs.Resource",n.suggestion=`'${o}' resolves, but its domain does not cover '${e}', so the lens would silently fall back to the resource's name at render time.
35
-
36
- Possible solutions:
37
- \u2022 Point ${t} at a property declared on this class (or an ancestor / rdfs.Resource)
38
- \u2022 Set the property's domain to this class if it should apply here
39
- \u2022 Use rdfs.label / rdfs.comment for the universal default`,n}};function uo(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}function X(c,e,t){let o=[];return Te(c,t,{input:e},o),o}function Te(c,e,t,o){if(P(e,M.VarRef)){let a=W(e,M.varName);return a?t[a]:void 0}if(P(e,M.PropertyRead)){let a=O(e,M.readSource),i=a?Te(c,a,t,o):void 0,s=g(e,M.readProp);if(!i||!s)return;let p=L(c,i,s);if(!p.ok){o.push({contextClass:i,propertyUri:s,via:"PropertyRead"});return}return p.descriptor?.range}if(P(e,M.Traverse)){let a=O(e,M.traverseSource),i=a?Te(c,a,t,o):void 0,s=g(e,M.through),p;if(i&&s){let m=L(c,i,s);m.ok?p=m.descriptor?.range:o.push({contextClass:i,propertyUri:s,via:"Traverse"})}let l=O(e,M.step);return l?Te(c,l,{...t,input:p},o):void 0}let n=W(e,M.loopVar),r=n?{...t,[n]:void 0}:t;for(let a of fo(e))Te(c,a,r,o)}function fo(c){let e=[];for(let t of c.statement){let o=t.object;if(o instanceof v)e.push(o);else if(Array.isArray(o))for(let n of o)n instanceof v&&e.push(n)}return e}var Ne="kanonak.org",_e="look",yo={publisher:Ne,package_:_e,name:"semanticSvg"},go={publisher:Ne,package_:_e,name:"tierChip"},ko={publisher:Ne,package_:_e,name:"tierIcon"},ho={publisher:Ne,package_:_e,name:"tierCard"},Ro={publisher:Ne,package_:_e,name:"tierFull"},Ko=[go,ko,ho,Ro],Se=class{ruleName="LookSemanticSvgPath";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new S().parseKanonaks(new G(e,t));let a=bo(e);if(!a)return n;for(let i of r)i instanceof d&&i.namespace===a&&this.checkSemanticSvg(r,i,n);return n}checkSemanticSvg(e,t,o){let n=O(t,yo);if(!n)return;let r=A(t);if(r)for(let a of Ko){let i=O(n,a);if(i)for(let s of X(e,r,i))o.push(this.toError(t.name,a.name,s))}}toError(e,t,o){let n=`${o.propertyUri.publisher}/${o.propertyUri.package_}/${o.propertyUri.name}`,r=o.contextClass.name,a=r===e?`'${e}' (the class this SemanticSvg is declared on)`:`'${r}', reached by traversal from '${e}' (the class this SemanticSvg is declared on)`,i=new u;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=`look.semanticSvg.${t}`,i.actualValue=n,i.message=`tx.${o.via} reads property '${o.propertyUri.name}' off the rendered instance, but its domain is not in scope for ${a}. The read would silently return undefined at render time.`,i.expectedValue=`A property whose domain is '${r}', an ancestor, or rdfs.Resource`,i.suggestion=`Property '${n}' is not in scope for '${r}'.
40
-
41
- Possible solutions:
42
- \u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
43
- \u2022 If the property should apply to '${r}', adjust its domain
44
- \u2022 If the value comes from a pre-computed env binding, use tx.VarRef instead of PropertyRead`,i}};function bo(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var Vo="kanonak.org",b=(c,e)=>({publisher:Vo,package_:c,name:e}),Eo=b("derivation","look"),vo=b("look","bands"),Do=b("look","Distribution"),Io=b("look","StatRow"),Co=b("look","VersionDelta"),So=b("look","Timeline"),Po=b("look","VersionDiff"),jo=b("look","TimePlot"),$o=b("look","ReferenceList"),Oo=b("look","Diagram"),Uo=b("look","alphaPath"),Ao=b("look","betaPath"),tt=b("look","metricPath"),It=b("look","lowerPath"),Ct=b("look","upperPath"),St=b("look","hueBy"),wo=b("look","statPath"),xo=b("look","laneBy"),Pt=b("look","labelPath"),To=b("look","badgePath"),No=b("look","mapPath"),_o=b("look","nodeNote"),Lo=b("look","edgeValue"),Mo=b("look","stats"),Bo=b("look","facets"),Fo=b("look","channels"),Wo=b("look","track"),Ho=b("look","source"),Go=b("look","relation"),Yo=b("look","entries"),Le=class{ruleName="LookBandPath";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new S().parseKanonaks(new G(e,t));let a=zo(e);if(!a)return n;for(let i of r)i instanceof d&&i.namespace===a&&this.checkDeclaration(r,i,n);return n}checkDeclaration(e,t,o){let n=O(t,Eo);if(!n)return;let r=A(t);if(!r)return;let a=V(n,vo).filter(i=>i instanceof v);for(let i of a)for(let s of this.carriersOf(e,i,r))for(let p of X(e,s.context,s.expr))o.push(this.toError(t.name,s.slot,p))}carriersOf(e,t,o){let n=[],r=(a,i)=>{let s=O(t,a);s&&n.push({slot:`look.${a.name}`,context:i,expr:s})};if(P(t,Do))for(let a of[Uo,Ao,tt,It,Ct,St])r(a,o);if(P(t,Co)&&r(tt,o),P(t,Io)){let a=V(t,Mo).filter(i=>i instanceof v);for(let i of a){let s=O(i,wo);s&&n.push({slot:"look.stats[].statPath",context:o,expr:s})}}if(P(t,So)||P(t,Po)){let a=this.rangeOf(e,o,g(t,Wo));if(a)for(let i of[tt,It,Ct,St])r(i,a)}if(P(t,jo)){let a=this.rangeOf(e,o,g(t,Ho));if(a)for(let i of[xo,Pt])r(i,a)}if(P(t,$o))for(let a of V(t,Yo)){let i=a instanceof v?void 0:qo(a),s=this.rangeOf(e,o,i);if(s)for(let p of[Pt,To])r(p,s)}if(P(t,Oo)){let a=V(t,Bo).filter(i=>i instanceof v);for(let i of a){let s=this.rangeOf(e,o,g(i,Go));if(!s)continue;let p=O(i,_o);p&&n.push({slot:"look.facets[].nodeNote",context:s,expr:p});let l=O(i,Lo);l&&n.push({slot:"look.facets[].edgeValue",context:s,expr:l});let m=V(i,Fo).filter(f=>f instanceof v);for(let f of m){let R=O(f,No);R&&n.push({slot:"look.facets[].channels[].mapPath",context:s,expr:R})}}}return n}rangeOf(e,t,o){if(!o)return;let n=L(e,t,o);return n.ok?n.descriptor?.range:void 0}toError(e,t,o){let n=`${o.propertyUri.publisher}/${o.propertyUri.package_}/${o.propertyUri.name}`,r=o.contextClass.name,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=t,a.actualValue=n,a.message=`tx.${o.via} reads property '${o.propertyUri.name}', but its domain is not in scope for '${r}' (the class this band carrier is evaluated against). The read would silently return undefined at render time and the band would render empty.`,a.expectedValue=`A property whose domain is '${r}', an ancestor, or rdfs.Resource`,a.suggestion=`Property '${n}' is not in scope for '${r}'.
45
-
46
- Possible solutions:
47
- \u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
48
- \u2022 If the property should apply to '${r}', adjust its domain
49
- \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,a}};function qo(c){let e=c.subject;return e&&typeof e.name=="string"?e:void 0}function zo(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var je="kanonak.org",$e="view",Xo={publisher:je,package_:$e,name:"bind"},Zo={publisher:je,package_:$e,name:"produces"},Jo={publisher:je,package_:$e,name:"projections"},Qo={publisher:je,package_:$e,name:"where"},en={publisher:je,package_:$e,name:"value"},tn={publisher:je,package_:$e,name:"as"},Pe=class{ruleName="TxExpressionPath";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new S().parseKanonaks(new G(e,t));let a=rn(e);if(!a)return n;for(let i of r)i instanceof d&&i.namespace===a&&this.checkView(r,i,n);return n}checkView(e,t,o){let n=g(t,Xo);if(!n)return;let r=g(t,Zo),a=0;for(let s of nn(e,V(t,Jo))){let p=O(s,en);if(p)for(let m of X(e,n,p))o.push(this.toError(t.name,`view.projections[${a}].value`,n,m));let l=g(s,tn);l&&r&&(L(e,r,l).ok||o.push(this.asError(t.name,a,r,l))),a+=1}let i=0;for(let s of on(t,Qo)){for(let p of X(e,n,s))o.push(this.toError(t.name,`view.where[${i}]`,n,p));i+=1}}asError(e,t,o,n){let r=`${n.publisher}/${n.package_}/${n.name}`,a=new u;return a.ruleType=this.ruleName,a.severity="Error",a.entityName=e,a.propertyName=`view.projections[${t}].as`,a.actualValue=r,a.message=`Projection stores its value under property '${n.name}', but that property's domain is not in scope for the view's produces class '${o.name}'. The materialized result instance could not carry this value.`,a.expectedValue=`A property whose domain is '${o.name}', an ancestor, or rdfs.Resource`,a.suggestion=`Property '${r}' is not in scope for produces class '${o.name}'.
50
-
51
- Possible solutions:
52
- \u2022 Use an output property whose domain covers '${o.name}'
53
- \u2022 Define a new property in the ViewPackage with domain '${o.name}' and the right range
54
- \u2022 If the value belongs on a different output class, adjust the view's produces`,a}toError(e,t,o,n){let r=`${n.propertyUri.publisher}/${n.propertyUri.package_}/${n.propertyUri.name}`,a=n.contextClass.name,i=a===o.name?`the view's bound class '${o.name}'`:`'${a}', reached by traversal from the view's bound class '${o.name}'`,s=new u;return s.ruleType=this.ruleName,s.severity="Error",s.entityName=e,s.propertyName=t,s.actualValue=r,s.message=`tx.${n.via} reads property '${n.propertyUri.name}', but its domain is not in scope for ${i}. The read would silently return undefined when the view materializes.`,s.expectedValue=`A property whose domain is '${a}', an ancestor, or rdfs.Resource`,s.suggestion=`Property '${r}' is not in scope for '${a}'.
55
-
56
- Possible solutions:
57
- \u2022 Read a property declared on '${a}' (or an ancestor / rdfs.Resource)
58
- \u2022 If the property should apply to '${a}', adjust its domain
59
- \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,s}};function on(c,e){let t=O(c,e);return t?[t]:V(c,e).filter(o=>o instanceof v)}function nn(c,e){let t=[];for(let o of e)if(o instanceof v)t.push(o);else if(o instanceof I){let n=h(c,o.subject);n&&t.push(n)}return t}function rn(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var qe="kanonak.org",an="core-shacl",w=c=>({publisher:qe,package_:an,name:c}),sn=w("NodeShape"),cn=w("PropertyShape"),pn=w("targetClass"),ln=w("property"),mn=w("path"),un=w("minCount"),fn=w("maxCount"),dn=w("datatype"),yn=w("class"),jt=w("in"),gn=w("pattern"),kn=w("flags"),hn=w("minLength"),Rn=w("maxLength"),Kn=w("minInclusive"),bn=w("maxInclusive"),Vn=new Set(["decimal","integer","int","long","short","byte","float","double","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte"]),ot=c=>c,Ue=class{ruleName="ShaclShape";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new S().parseKanonaks(t),a=En(e);if(!a)return n;let i=new Set;for(let s of r){if(!(s instanceof d)||s.namespace!==a||!P(s,sn))continue;let p=g(s,pn);p?this.resolvesToClass(r,p)||n.push(this.err(s.name,"targetClass","Error",`NodeShape '${s.name}' sh:targetClass '${p.name}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",Z(p))):n.push(this.err(s.name,"targetClass","Error",`NodeShape '${s.name}' has no sh:targetClass; it constrains nothing.`,"Add sh:targetClass naming the class this shape applies to."));for(let l of V(s,ln)){let m;if(l instanceof v)m=l;else if(l instanceof I){let f=h(r,l.subject);f&&(m=f,i.add(K(l.subject)))}m&&this.checkPropertyShape(r,s.name,m,p??void 0,n)}}for(let s of r){if(!(s instanceof d)||s.namespace!==a||!P(s,cn))continue;let p=A(s);p&&i.has(K(p))||this.checkPropertyShape(r,s.name,s,void 0,n)}return n}checkPropertyShape(e,t,o,n,r){let a=g(o,mn);if(!a){r.push(this.err(t,"property.path","Error",`A PropertyShape on '${t}' has no sh:path; a PropertyShape must name the property it constrains.`,"Add sh:path naming a property."));return}let i=h(e,a),s=i?y.isAnyPropertyType(ot(i)):!1;s?n&&(L(e,n,a).ok||r.push(this.err(t,"property.path","Warning",`sh:path '${a.name}' is not in scope for sh:targetClass '${n.name}'; the constraint would never bind a value.`,`Constrain a property whose domain is '${n.name}', an ancestor, or rdfs.Resource.`,Z(a)))):r.push(this.err(t,"property.path","Error",`sh:path '${a.name}' on '${t}' does not resolve to a property.`,"Reference a defined or imported property.",Z(a)));let p=g(o,dn),l=g(o,yn);p&&l&&r.push(this.err(t,"property","Error",`A PropertyShape on '${t}' sets both sh:datatype and sh:class; a value is a literal or a node, not both.`,"Keep sh:datatype (literal values) or sh:class (node values), not both.")),p&&!this.resolvesToDatatype(e,p)&&r.push(this.err(t,"datatype","Error",`sh:datatype '${p.name}' on '${t}' does not resolve to a datatype.`,"Reference an xsd datatype or rdfs.Datatype.",Z(p))),l&&!this.resolvesToClass(e,l)&&r.push(this.err(t,"class","Error",`sh:class '${l.name}' on '${t}' does not resolve to a class.`,"Reference a defined or imported rdfs.Class.",Z(l)));let m=Oe(x(o,un)),f=Oe(x(o,fn));this.checkOrder(t,"minCount",m,"maxCount",f,r);let R=Oe(x(o,hn)),E=Oe(x(o,Rn));this.checkOrder(t,"minLength",R,"maxLength",E,r);let N=Oe(x(o,Kn)),j=Oe(x(o,bn));this.checkOrder(t,"minInclusive",N,"maxInclusive",j,r);let $=W(o,gn);if($!==void 0){let B=W(o,kn);try{new RegExp($,B)}catch{r.push(this.err(t,"pattern","Error",`sh:pattern on '${t}' is not a valid regular expression`+(B!==void 0?` (with flags '${B}')`:"")+`: ${$}`,"Provide a valid regular expression and flags.",$))}}if(J(o,jt)&&V(o,jt).length===0&&r.push(this.err(t,"in","Error",`sh:in on '${t}' is empty; an enumeration must list at least one permitted value.`,"List the permitted literal values, or remove sh:in.")),s&&n){let _=L(e,n,a).descriptor;_&&(($!==void 0||R!==void 0||E!==void 0)&&_.kind==="object"&&r.push(this.err(t,"pattern/minLength/maxLength","Warning",`String facets on '${t}' apply to '${a.name}', which is an object property; string facets constrain literal values.`,"Apply string facets to a datatype property, or use sh:class for node values.",Z(a))),(N!==void 0||j!==void 0)&&!this.isNumericDatatypeRange(_.range)&&r.push(this.err(t,"minInclusive/maxInclusive","Warning",`Numeric bounds on '${t}' apply to '${a.name}', whose range is not a numeric datatype.`,"Apply numeric bounds to a numeric datatype property.",Z(a))))}}checkOrder(e,t,o,n,r,a){o!==void 0&&r!==void 0&&o>r&&a.push(this.err(e,`${t}/${n}`,"Error",`${t} (${o}) exceeds ${n} (${r}) on '${e}'.`,`Set ${t} <= ${n}.`))}resolvesToClass(e,t){let o=h(e,t);return o?y.isClassType(ot(o)):!1}resolvesToDatatype(e,t){if(t.publisher===qe&&t.package_==="core-rdf"&&t.name==="Literal")return!0;let o=h(e,t);return o?y.isDatatypeType(ot(o)):!1}isNumericDatatypeRange(e){return!e||e.publisher===qe&&e.package_==="core-rdf"&&e.name==="Literal"?!0:e.publisher===qe&&e.package_==="core-xsd"&&Vn.has(e.name)}err(e,t,o,n,r,a){let i=new u;return i.ruleType=this.ruleName,i.severity=o,i.entityName=e,i.propertyName=t,i.message=n,i.suggestion=r,a!==void 0&&(i.actualValue=a),i}};function Oe(c){return typeof c=="number"?c:void 0}function Z(c){return`${c.publisher}/${c.package_}/${c.name}`}function En(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var $t={publisher:"kanonak.org",package_:"core-owl",name:"oneOf"},vn=c=>c,Ae=class{ruleName="OwlOneOf";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new S().parseKanonaks(t),a=Dn(e);if(!a)return n;for(let i of r){if(!(i instanceof d)||i.namespace!==a||!J(i,$t))continue;let s=V(i,$t);if(s.length===0){n.push(this.err(i.name,"Warning",`owl:oneOf on '${i.name}' is empty; a closed enumeration must list at least one individual.`,"List the individuals that make up the enumeration, or remove owl:oneOf."));continue}for(let p of s)if(p instanceof Me)n.push(this.err(i.name,"Error",`owl:oneOf member '${String(p.value)}' on '${i.name}' is not a named individual; a class enumeration is of individuals (a misspelled or unimported individual reads as a literal). For a closed set of literal VALUES, constrain a property with sh:in instead.`,"Reference a defined or imported individual, or move literal value sets to a property sh:in.",String(p.value)));else if(p instanceof I){let l=h(r,p.subject);l&&y.isSchemaDefinitionType(vn(l))&&n.push(this.err(i.name,"Error",`owl:oneOf member '${p.subject.name}' on '${i.name}' is a class/property/datatype, not an individual.`,"List named individuals (instances), not schema definitions.",`${p.subject.publisher}/${p.subject.package_}/${p.subject.name}`))}}return n}err(e,t,o,n,r){let a=new u;return a.ruleType=this.ruleName,a.severity=t,a.entityName=e,a.propertyName="oneOf",a.message=o,a.suggestion=n,r!==void 0&&(a.actualValue=r),a}};function Dn(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var In="kanonak.org",Cn="core-shacl",T=c=>({publisher:In,package_:Cn,name:c}),Sn=T("NodeShape"),Pn=T("targetClass"),jn=T("property"),$n=T("path"),On=T("minCount"),Un=T("maxCount"),An=T("in"),wn=T("pattern"),xn=T("flags"),Tn=T("minLength"),Nn=T("maxLength"),_n=T("minInclusive"),Ln=T("maxInclusive"),Mn=T("message");function we(c){return typeof c=="number"?c:void 0}function Bn(c){let e={},t=we(x(c,On)),o=we(x(c,Un));t!==void 0&&(e.minCount=t),o!==void 0&&(e.maxCount=o);let n=we(x(c,Tn)),r=we(x(c,Nn));n!==void 0&&(e.minLength=n),r!==void 0&&(e.maxLength=r);let a=we(x(c,_n)),i=we(x(c,Ln));a!==void 0&&(e.minInclusive=a),i!==void 0&&(e.maxInclusive=i);let s=W(c,wn);if(s!==void 0){let m=W(c,xn);e.pattern=m!==void 0?{regex:s,flags:m}:{regex:s}}let p=V(c,An).filter(m=>m instanceof Me).map(m=>m.value);p.length>0&&(e.enumValues=p);let l=W(c,Mn);return l!==void 0&&(e.message=l),e}function Fn(c,e){let t=[];for(let o of V(e,jn))if(o instanceof v)t.push(o);else if(o instanceof I){let n=h(c,o.subject);n&&t.push(n)}return t}function Ot(c){let e=new Map;for(let t of c){if(!(t instanceof d)||!P(t,Sn))continue;let o=g(t,Pn);if(!o)continue;let n=K(o);for(let r of Fn(c,t)){let a=g(r,$n);if(!a)continue;let i={pathKey:K(a),constraints:Bn(r)},s=e.get(n);s?s.push(i):e.set(n,[i])}}return e}function Wn(c,e){e.minCount!==void 0&&(c.minCount=e.minCount),e.maxCount!==void 0&&(c.maxCount=e.maxCount),e.minLength!==void 0&&(c.minLength=e.minLength),e.maxLength!==void 0&&(c.maxLength=e.maxLength),e.minInclusive!==void 0&&(c.minInclusive=e.minInclusive),e.maxInclusive!==void 0&&(c.maxInclusive=e.maxInclusive),e.pattern!==void 0&&(c.pattern=e.pattern),e.enumValues!==void 0&&(c.enumValues=e.enumValues),e.message!==void 0&&(c.message=e.message)}function Ut(c,e,t){let o=K(t),n=!1,r={};for(let a=e.length-1;a>=0;a--){let i=c.get(K(e[a]));if(i)for(let s of i)s.pathKey===o&&(n=!0,Wn(r,s.constraints))}if(n)return r.cardinality=r.maxCount===1?"single":"list",r.required=(r.minCount??0)>=1,r}var Hn=c=>c,Gn=new at("kanonak.org","core-rdf","Resource"),xe=class{ruleName="DiamondNameClash";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new S().parseKanonaks(t),a=Yn(e);if(!a)return n;let i=Ot(r);for(let s of r){if(!(s instanceof d)||s.namespace!==a||!y.isClassType(Hn(s)))continue;let p=A(s);if(!p)continue;let l=Y(r,p),m=K(p),f=new Set(l.map(E=>K(E)));f.delete(m),f.delete(K(Gn));let R=new Map;for(let E of pt(r,p)){if(!E.domains.some($=>f.has(K($))))continue;let j=R.get(E.uri.name);j?j.push(E):R.set(E.uri.name,[E])}for(let[E,N]of R){if(N.length<2)continue;let j=_=>Ut(i,l,_.uri)?.cardinality,$=new Set(N.map(_=>_.range?K(_.range):void 0).filter(_=>_!==void 0)),B=new Set(N.map(j).filter(_=>_!==void 0));$.size<=1&&B.size<=1||n.push(this.toError(s.name,E,N,j))}}return n}toError(e,t,o,n){let r=s=>{let p=`${s.uri.publisher}/${s.uri.package_}/${s.uri.name}`,l=s.range?`${s.range.publisher}/${s.range.package_}/${s.range.name}`:"no range",m=n(s);return`${p} (range ${l}${m?`, ${m}`:""})`},a=o.map(r).join("; "),i=new u;return i.ruleType=this.ruleName,i.severity="Error",i.entityName=e,i.propertyName=t,i.actualValue=a,i.message=`Class '${e}' inherits ${o.length} distinct properties named '${t}' with incompatible range or cardinality: ${a}. The generated interface would multiply-inherit '${t}' with conflicting types and could not compile.`,i.suggestion=`Disambiguate the diamond name-clash on '${t}':
60
- \u2022 rename one of the properties, or
61
- \u2022 re-domain one so it is not inherited by '${e}', or
62
- \u2022 restructure the hierarchy so '${e}' inherits only one '${t}', or
63
- \u2022 make the ranges/cardinalities compatible (identical) if they are meant to be the same property.`,i}};function Yn(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${U(e.version)}`}var nt=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e){this.parser=e??new rt,this.documentRules=[new ne,new re,new ae,new ie,new se],this.repositoryRules=[new ce,new pe,new le,new me,new ue,new fe,new de,new ye,new ge,new ke,new he,new Re,new be,new Ve,new Ee,new ve,new De,new Ie,new Ce,new Se,new Le,new Pe,new Ue,new Ae,new xe]}async validateAsync(e,t,o){let n=new Q;for(let r of this.documentRules)try{let a=r.validate(e);this.addErrorsToResult(n,a)}catch(a){let i=new u;i.ruleType=r.ruleName,i.severity="Error",i.message=`Validation rule '${r.ruleName}' failed: ${a instanceof Error?a.message:String(a)}`,n.errors.push(i)}if(t){let r=[],a=o??new ee(new te(e,t)),i=a.repository;for(let s of this.repositoryRules)try{let p=await s.validateAsync(e,i,a);this.addErrorsToResult(n,p)}catch(p){let l=p instanceof Error?p.message:String(p);r.push({ruleName:s.ruleName,cause:l})}if(r.length>0){let s=new Map;for(let{ruleName:p,cause:l}of r){let m=s.get(l);m?m.push(p):s.set(l,[p])}for(let[p,l]of s){let m=new u;m.ruleType=l[0],m.severity="Error",l.length===1?m.message=`Validation rule '${l[0]}' failed: ${p}`:m.message=`${p} (affects ${l.length} rules: ${l.join(", ")})`,n.errors.push(m)}}}return n.isValid=n.errors.length===0,n}async validateDocumentsAsync(e,t){let o=new ee(t),n=[];for(let r of e){let a=await this.validateAsync(r,o.repository,o);n.push({document:r,result:a})}return n}async validateYamlAsync(e,t,o){let n=this.parser.parseWithErrors(e);if(!n.isValid){let r=new Q;r.isValid=!1;for(let a of n.errors){let i=new u;i.ruleType="ParseError",i.severity="Error",i.lineNumber=a.line,i.column=a.column,i.message=a.message,a.keyName&&(i.entityName=a.keyName),a.errorType==="DuplicateKey"&&(i.suggestion="All property names must be unique across the entire document. Rename one of the duplicate properties to make them unique."),r.errors.push(i)}return r}return await this.validateAsync(n.document,t,o)}addDocumentRule(e){this.documentRules.push(e)}addRepositoryRule(e){this.repositoryRules.push(e)}removeDocumentRule(e){let t=this.documentRules.findIndex(o=>o instanceof e);t>=0&&this.documentRules.splice(t,1)}removeRepositoryRule(e){let t=this.repositoryRules.findIndex(o=>o instanceof e);t>=0&&this.repositoryRules.splice(t,1)}addErrorsToResult(e,t){for(let o of t)o.severity==="Error"?e.errors.push(o):o.severity==="Info"?this.includeWarnings&&e.infos.push(o):this.includeWarnings&&e.warnings.push(o)}};export{Q as a,k as b,u as c,ze as d,ee as e,ne as f,re as g,ae as h,ie as i,se as j,ce as k,pe as l,le as m,me as n,ue as o,fe as p,de as q,ye as r,ge as s,ke as t,he as u,Re as v,be as w,Ve as x,Ee as y,ve as z,De as A,Ie as B,Ce as C,Se as D,Pe as E,Ue as F,Ae as G,Ot as H,Ut as I,xe as J,nt as K};
@@ -1 +0,0 @@
1
- import{a as K}from"./chunk-FUUTGGJS.js";var D=class{cache=new Map;repository;logger;constructor(e,r){this.repository=e,this.logger=r}async resolveEntityAsync(e,r){let o=r.metadata?.namespace_?.toString()??"unknown",i=this.cache.get(o);if(i){let l=i.get(e);if(l)return l}let n=await this.buildEntityIndexAsyncInternal(r,new Set,"",new Map);return this.cache.set(o,n),n.get(e)??null}async resolveAllEntitiesAsync(e,r){let o=await this.buildAllEntitiesIndexAsync(r,new Set,"");if(e.includes(".")){let i=e.split("."),n=i[0],l=i[1],m=await this.findDocumentForAlias(r,n);return m?await this.resolveAllEntitiesAsync(l,m):[]}return o.filter(i=>i.entityName===e)}async buildAllEntitiesIndexAsync(e,r,o){let i=[],n=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${n}`),r.has(n))return this.logger?.debug?.(`Skipping ${n} - already visited (circular import prevention)`),i;r.add(n);let l=o.length===0?n:`${o} \u2192 ${n}`;for(let[m,u]of Object.entries(e.body))if(!m.includes(".")&&u&&typeof u=="object"&&!Array.isArray(u)){if(!e.metadata.namespace_)continue;let f=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};i.push({entityName:m,uri:new K(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,m,f),entity:u,definedInNamespace:n,isImported:o.length>0,importPath:l})}if(this.logger?.debug?.(`Collected ${i.length} entities from ${n}`),e.metadata?.imports){let m=Object.values(e.metadata.imports).reduce((u,f)=>u+f.length,0);this.logger?.debug?.(`Processing ${m} import(s) for ${n}`);for(let[u,f]of Object.entries(e.metadata.imports))for(let d of f)try{this.logger?.debug?.(`Resolving import: ${u}/${d.packageName}`);let p=await this.repository.getHighestCompatibleVersionAsync(u,d);if(p){this.logger?.debug?.(`Successfully loaded import: ${p.metadata?.namespace_?.toString()}`);let y=await this.buildAllEntitiesIndexAsync(p,r,l);i.push(...y),this.logger?.debug?.(`Added ${y.length} entities from import ${p.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${u}/${d.packageName}`)}catch(p){let y=p;throw this.logger?.error?.(`Failed to process import ${u}/${d.packageName} for namespace ${n}. Error: ${y.message}`,y),new Error(`Failed to process import ${u}/${d.packageName} for namespace ${n}. See inner exception for details.`,{cause:p})}}return i}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"",new Map)}async buildEntityIndexAsyncInternal(e,r,o,i){let n=new Map,l=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${l}`),r.has(l))return this.logger?.debug?.(`Skipping ${l} - circular import in progress`),n;let m=i.get(l);if(m)return m;r.add(l);let u=o.length===0?l:`${o} \u2192 ${l}`,f=0;for(let[d,p]of Object.entries(e.body))if(!d.includes(".")&&p&&typeof p=="object"&&!Array.isArray(p)){if(!e.metadata.namespace_)continue;if(!n.has(d)){let y=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};n.set(d,{entityName:d,uri:new K(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,d,y),entity:p,definedInNamespace:l,isImported:o.length>0,importPath:u}),f++}}if(this.logger?.debug?.(`Indexed ${f} entities from ${l}`),e.metadata?.imports){let d=Object.values(e.metadata.imports).reduce((p,y)=>p+y.length,0);this.logger?.debug?.(`Processing ${d} import(s) for ${l}`);for(let[p,y]of Object.entries(e.metadata.imports))for(let h of y)try{this.logger?.debug?.(`Resolving import: ${p}/${h.packageName}`);let k=await this.repository.getHighestCompatibleVersionAsync(p,h);if(k){this.logger?.debug?.(`Successfully loaded import: ${k.metadata?.namespace_?.toString()}`);let v=await this.buildEntityIndexAsyncInternal(k,r,u,i),A=0;for(let[P,R]of v.entries()){let b=n.get(P);if(!b)n.set(P,R),A++;else if(b.isImported&&R.isImported&&(b.uri.publisher!==R.uri.publisher||b.uri.package_!==R.uri.package_)){let $=b.isAmbiguous?b:{...b,isAmbiguous:!0,ambiguousNamespaces:[b.definedInNamespace]};$.ambiguousNamespaces.includes(R.definedInNamespace)||$.ambiguousNamespaces.push(R.definedInNamespace),n.set(P,$),this.logger?.warn?.(`Ambiguous reference '${P}': defined in ${$.ambiguousNamespaces.join(", ")}`)}if(h.alias&&!P.includes(".")){let $=`${h.alias}.${P}`;n.has($)||(n.set($,R),A++)}}this.logger?.debug?.(`Merged ${A} entities from import ${k.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${p}/${h.packageName}`)}catch(k){let v=k;throw this.logger?.error?.(`Failed to process import ${p}/${h.packageName} for namespace ${l}. Error: ${v.message}`,v),new Error(`Failed to process import ${p}/${h.packageName} for namespace ${l}. See inner exception for details.`,{cause:k})}}return r.delete(l),i.set(l,n),n}async findDocumentForAlias(e,r){if(!e.metadata?.imports)return null;for(let[o,i]of Object.entries(e.metadata.imports))for(let n of i){if(n.alias===r)return await this.repository.getHighestCompatibleVersionAsync(o,n);if(!n.alias&&n.packageName===r)return await this.repository.getHighestCompatibleVersionAsync(o,n)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}};var _=class t{static KNOWN_XSD_DATATYPES=new Set(["string","integer","int","boolean","decimal","float","double","date","datetime","time","duration","anyuri","base64binary","hexbinary","long","short","byte","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte"]);resourceResolver;constructor(e){this.resourceResolver=e}isXsdDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-xsd"&&t.KNOWN_XSD_DATATYPES.has(e.name.toLowerCase()):!1}isLiteralType(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Literal":!1}isMarkdownDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&e.name==="Markdown":!1}isSubstitutableDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&(e.name==="SubstitutableString"||e.name==="Markdown"):!1}isKnownXsdDatatypeName(e){let r=e.includes(".")?e.split(".")[1]:e;return t.KNOWN_XSD_DATATYPES.has(r.toLowerCase())}async isClassTypeAsync(e,r){if(this.isKnownXsdDatatypeName(e))return!1;let o=await this.resourceResolver.resolveEntityAsync(e,r);if(o){let i=o.entity.type;if(i){let n=String(i);return n==="Class"||n==="rdfs.Class"||n.endsWith(".Class")}}return!0}getPropertyTypeClassification(e){if(!e||e.trim().length===0)return"Property";switch(e.includes(".")?e.split(".")[1]:e){case"DatatypeProperty":return"DatatypeProperty";case"ObjectProperty":return"ObjectProperty";case"AnnotationProperty":return"AnnotationProperty";case"Property":return"Property";default:return"Property"}}isEffectiveDatatypeProperty(e,r){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(r)||e==="Property"&&this.isLiteralType(r))}isEffectiveObjectProperty(e,r){return!!(e==="ObjectProperty"||e==="Property"&&r&&!this.isXsdDatatype(r)&&!this.isLiteralType(r))}};function E(t){return`${t.publisher}/${t.package_}/${t.name}`}function c(t,e,r){return`${t}/${e}/${r}`}function C(t){return`${t.s}|${t.p}|${I(t.o)}`}function I(t){switch(t.kind){case"uri":return`u:${t.key}`;case"literal":return`l:${t.datatype}:${t.lexical}`;case"blank":return`b:${t.id}`}}function M(t,e,r){return{s:t,p:e,o:{kind:"uri",key:r}}}var s="kanonak.org",a="core-rdf",g="core-owl",x="core-kanonak",w=new Map([["type",a],["subClassOf",a],["subPropertyOf",a],["domain",a],["range",a],["label",a],["comment",a],["seeAlso",a],["isDefinedBy",a],["member",a],["Resource",a],["Class",a],["Property",a],["Datatype",a],["Literal",a],["List",a],["ObjectProperty",g],["DatatypeProperty",g],["AnnotationProperty",g],["Thing",g],["Nothing",g],["Package",x]]),O=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function F(t){return w.has(t)}function H(t){let e=w.get(t);return e?{publisher:s,package_:e}:void 0}function V(t,e,r){if(!t||!t.name)return;let o=w.get(t.name);if(!o)return;let i=()=>{t.publisher=s,t.package_=o,r&&(t.version=r.get(o))};if(O.has(t.name)){let n=t.publisher===s&&t.package_===o;t.publisher=s,t.package_=o,!n&&r&&(t.version=r.get(o));return}t.publisher===s&&t.package_===o||t.publisher&&t.publisher.length>0&&(!e||e(t))||i()}var S=class{type=c(s,a,"type");subClassOf=c(s,a,"subClassOf");subPropertyOf=c(s,a,"subPropertyOf");domain=c(s,a,"domain");range=c(s,a,"range");label=c(s,a,"label");comment=c(s,a,"comment");resource=c(s,a,"Resource");class_=c(s,a,"Class");datatype=c(s,a,"Datatype");literal=c(s,a,"Literal");equivalentClass=c(s,g,"equivalentClass");equivalentProperty=c(s,g,"equivalentProperty");inverseOf=c(s,g,"inverseOf");sameAs=c(s,g,"sameAs");transitiveProperty=c(s,g,"TransitiveProperty");symmetricProperty=c(s,g,"SymmetricProperty");objectProperty=c(s,g,"ObjectProperty");datatypeProperty=c(s,g,"DatatypeProperty");annotationProperty=c(s,g,"AnnotationProperty");package_=c(s,x,"Package")};export{D as a,_ as b,E as c,c as d,C as e,I as f,M as g,F as h,H as i,V as j,S as k};