@kanonak-protocol/sdk 5.25.0 → 5.27.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 (44) hide show
  1. package/dist/browser.d.ts +2 -0
  2. package/dist/browser.js +1 -1
  3. package/dist/chunk-4C7ZMXQT.js +68 -0
  4. package/dist/chunk-4VLLX3MZ.js +1 -0
  5. package/dist/chunk-CZY6OOTM.js +1 -0
  6. package/dist/{chunk-6YX2TDI5.js → chunk-KOV3AFBN.js} +1 -1
  7. package/dist/chunk-M7LXZN47.js +1 -0
  8. package/dist/chunk-NOPFCGB7.js +1 -0
  9. package/dist/chunk-RVR25FWW.js +2 -0
  10. package/dist/{chunk-5GFOZL7D.js → chunk-RWN5JZPU.js} +1 -1
  11. package/dist/chunk-ZZINR6NT.js +152 -0
  12. package/dist/graph/GraphBuilder.d.ts +2 -0
  13. package/dist/index.d.ts +2 -2
  14. package/dist/index.js +1 -1
  15. package/dist/kanonaks/walkDefinedKanonaks.d.ts +10 -1
  16. package/dist/look/LookRenderer.d.ts +36 -0
  17. package/dist/parsing/index.js +1 -1
  18. package/dist/reasoning/KanonakVocabulary.d.ts +3 -0
  19. package/dist/reasoning/index.js +1 -1
  20. package/dist/resolution/ResourceTypeClassifier.d.ts +8 -0
  21. package/dist/resolution/index.js +1 -1
  22. package/dist/search/index.js +1 -1
  23. package/dist/server/index.js +18 -10
  24. package/dist/server/renderDiagnostics.d.ts +10 -0
  25. package/dist/shacl/index.d.ts +1 -0
  26. package/dist/shacl/uris.d.ts +1 -0
  27. package/dist/transformations/index.js +2 -2
  28. package/dist/transformations/v3/CompiledTransformationV3.d.ts +17 -1
  29. package/dist/transformations/v3/TransformationUriConstantsV3.d.ts +5 -0
  30. package/dist/uri-helpers/UriHelpers.d.ts +10 -0
  31. package/dist/uri-helpers/index.d.ts +1 -1
  32. package/dist/uri-helpers/index.js +1 -1
  33. package/dist/validation/index.d.ts +1 -1
  34. package/dist/validation/index.js +1 -1
  35. package/dist/validation/rules/repository/TxExpressionCompilesRule.d.ts +44 -0
  36. package/dist/validation/rules/repository/index.d.ts +1 -0
  37. package/package.json +2 -2
  38. package/dist/chunk-3XOXKMYB.js +0 -63
  39. package/dist/chunk-AND44TIS.js +0 -152
  40. package/dist/chunk-H6UAD2LP.js +0 -1
  41. package/dist/chunk-I3UXFEJA.js +0 -2
  42. package/dist/chunk-O6YV2SDB.js +0 -1
  43. package/dist/chunk-USQLCG3Q.js +0 -1
  44. package/dist/chunk-YU2VGLOT.js +0 -1
package/dist/browser.d.ts CHANGED
@@ -23,6 +23,8 @@ export type { ResourceResolutionResult, ILogger, DocumentVersionPick, } from './
23
23
  export { InMemoryKanonakDocumentRepository } from './repositories/InMemoryKanonakDocumentRepository.js';
24
24
  export { HttpKanonakDocumentRepository } from './repositories/HttpKanonakDocumentRepository.js';
25
25
  export { PublisherIndex } from './repositories/PublisherIndex.js';
26
+ export { KanonakVocabulary } from './reasoning/KanonakVocabulary.js';
27
+ export { SHACL_PUBLISHER, SHACL_PACKAGE, SH_SHAPE, SH_NODE_SHAPE, SH_PROPERTY_SHAPE, } from './shacl/uris.js';
26
28
  export { PublisherConfigResolver } from './repositories/PublisherConfig.js';
27
29
  export type { PublisherConfig } from './repositories/PublisherConfig.js';
28
30
  export { findDerivation } from './derivation/index.js';
package/dist/browser.js CHANGED
@@ -1 +1 @@
1
- import{a as _,b as q,c as w,d as he,e as Ke,f as Se,g as Ie,i as be,j as je,k as Oe,l as De,m as ve}from"./chunk-I3UXFEJA.js";import{a as Ve}from"./chunk-5GFOZL7D.js";import{a as m,b as c,c as u,e as d,h as R,i as y,j as f,k,l as x,m as P,n as g}from"./chunk-P5VQEDBS.js";import{a as B,b as z,c as W}from"./chunk-6YX2TDI5.js";import{a as X}from"./chunk-PEB52US5.js";import"./chunk-SC5M74NM.js";import{A as Pe,B as ge,L as Ce,a as Y,b as J,c as Q,d as Z,f as $,g as ee,h as oe,i as te,k as re,l as ne,m as ae,n as ie,o as se,p as pe,q as le,r as me,s as ce,t as ue,u as de,v as Re,w as ye,x as fe,y as ke,z as xe}from"./chunk-3XOXKMYB.js";import"./chunk-BRCVOR7A.js";import"./chunk-AND44TIS.js";import{a as p}from"./chunk-6VIUXP4N.js";import{a as S,c as A,i as U,j as G,m as H}from"./chunk-YU2VGLOT.js";import{a as l}from"./chunk-KOWDHKBN.js";import"./chunk-PEJALHXK.js";import{a as F,b as L,o as M}from"./chunk-O6YV2SDB.js";import{a as C,b as h,c as K,d as b,e as j,f as O,g as D,h as V,i as v,j as E,k as N,l as T}from"./chunk-H6UAD2LP.js";import{a as I}from"./chunk-FUUTGGJS.js";import{c as e,d as o,e as t,f as r,g as n,h as a,i,k as s}from"./chunk-QILEJIFU.js";export{de as AmbiguousReferenceRule,v as BooleanStatement,Se as CANONICAL_FORM_VERSION,U as Carrier,Pe as ClassDefinitionRule,ie as ClassHierarchyCycleRule,h as DefinedKanonak,q as EdgeType,S as EmbeddedKanonak,re as EmbeddedKanonakTypeRule,N as EmbeddedStatement,w as GraphBuilder,g as HttpKanonakDocumentRepository,y as INTEGRITY_PREFIX,ne as ImportExistenceRule,p as InMemoryKanonakDocumentRepository,m as KANONAK_USER_AGENT,C as Kanonak,z as KanonakDocumentPositions,H as KanonakObjectParser,Ce as KanonakObjectValidator,l as KanonakParser,I as KanonakUri,X as KanonakUriBuilder,T as ListStatement,ge as MarkdownLinkRule,A as MarkdownStatement,ce as NamespaceImportCycleRule,$ as NamespacePrefixRule,_ as NodeType,V as NumberStatement,be as OAuthDiscovery,ye as ObjectPropertyValueValidationRule,Q as OntologyValidationError,Y as OntologyValidationResult,fe as PropertyDomainRule,se as PropertyHierarchyCycleRule,ke as PropertyKindRangeConsistencyRule,B as PropertyMetadata,Re as PropertyRangeReferenceRule,pe as PropertyRangeRequiredRule,oe as PropertyTypeSpecificityRule,R as PublisherConfigResolver,P as PublisherIndex,b as ReferenceKanonak,E as ReferenceStatement,xe as ReservedNameShadowRule,ee as ResourceNamingRule,F as ResourceResolver,M as ResourceTypeClassifier,O as ScalarStatement,j as Statement,D as StringStatement,le as SubClassOfReferenceRule,me as SubPropertyOfReferenceRule,K as SubjectKanonak,te as SubjectKanonakTypeRequiredRule,De as TokenCredentialProvider,L as TypeResolver,ue as UnresolvedPredicateRule,ae as UnresolvedReferenceRule,Z as ValidationContext,J as ValidationSeverity,ve as buildOntologyModel,he as canonicalForm,Ke as canonicalHash,G as carrierOf,e as compareVersions,x as computeIntegrityAsync,Oe as createCredentialedFetch,r as createVersion,Ve as findDerivation,t as formatVersion,u as getKanonakUserAgent,a as isCompatibleVersion,i as isMajorCompatible,d as kanonakFetch,Ie as normalizeHost,je as parseAuthChallenge,f as parseLockFile,n as parseVersionString,W as parseWithPositions,s as pickHighestDocument,k as serializeLockFile,c as setKanonakUserAgent,o as versionsEqual};
1
+ import{a as Y,b as X,c as J,d as Oe,e as je,f as De,g as Ve,i as Ae,j as ve,k as Ne,l as He,m as Le}from"./chunk-RVR25FWW.js";import{a as Te}from"./chunk-RWN5JZPU.js";import{a as m,b as c,c as u,e as d,h as R,i as y,j as f,k,l as x,m as P,n as S}from"./chunk-P5VQEDBS.js";import{a as Q,b as Z,c as $}from"./chunk-KOV3AFBN.js";import{a as ee}from"./chunk-PEB52US5.js";import"./chunk-SC5M74NM.js";import{A as Ie,B as Ee,M as be,a as oe,b as te,c as re,d as ne,f as ae,g as ie,h as se,i as pe,k as le,l as me,m as ce,n as ue,o as de,p as Re,q as ye,r as fe,s as ke,t as xe,u as Pe,v as Se,w as Ce,x as ge,y as Ke,z as he}from"./chunk-4C7ZMXQT.js";import"./chunk-BRCVOR7A.js";import"./chunk-ZZINR6NT.js";import{a as p}from"./chunk-6VIUXP4N.js";import{a as h,c as H,i as w,j as z,m as W}from"./chunk-M7LXZN47.js";import{a as l}from"./chunk-KOWDHKBN.js";import"./chunk-PEJALHXK.js";import{a as T,b as L,da as B,fa as q,j as _,k as F,l as M,m as U,n as G}from"./chunk-NOPFCGB7.js";import{a as C,b as g,c as K,d as E,e as b,f as O,g as j,h as D,i as V,j as A,k as v,l as N}from"./chunk-CZY6OOTM.js";import{a as I}from"./chunk-FUUTGGJS.js";import{c as e,d as o,e as t,f as r,g as n,h as a,i,k as s}from"./chunk-QILEJIFU.js";export{Pe as AmbiguousReferenceRule,V as BooleanStatement,De as CANONICAL_FORM_VERSION,w as Carrier,Ie as ClassDefinitionRule,ue as ClassHierarchyCycleRule,g as DefinedKanonak,X as EdgeType,h as EmbeddedKanonak,le as EmbeddedKanonakTypeRule,v as EmbeddedStatement,J as GraphBuilder,S as HttpKanonakDocumentRepository,y as INTEGRITY_PREFIX,me as ImportExistenceRule,p as InMemoryKanonakDocumentRepository,m as KANONAK_USER_AGENT,C as Kanonak,Z as KanonakDocumentPositions,W as KanonakObjectParser,be as KanonakObjectValidator,l as KanonakParser,I as KanonakUri,ee as KanonakUriBuilder,B as KanonakVocabulary,N as ListStatement,Ee as MarkdownLinkRule,H as MarkdownStatement,ke as NamespaceImportCycleRule,ae as NamespacePrefixRule,Y as NodeType,D as NumberStatement,Ae as OAuthDiscovery,Ce as ObjectPropertyValueValidationRule,re as OntologyValidationError,oe as OntologyValidationResult,ge as PropertyDomainRule,de as PropertyHierarchyCycleRule,Ke as PropertyKindRangeConsistencyRule,Q as PropertyMetadata,Se as PropertyRangeReferenceRule,Re as PropertyRangeRequiredRule,se as PropertyTypeSpecificityRule,R as PublisherConfigResolver,P as PublisherIndex,E as ReferenceKanonak,A as ReferenceStatement,he as ReservedNameShadowRule,ie as ResourceNamingRule,T as ResourceResolver,q as ResourceTypeClassifier,F as SHACL_PACKAGE,_ as SHACL_PUBLISHER,U as SH_NODE_SHAPE,G as SH_PROPERTY_SHAPE,M as SH_SHAPE,O as ScalarStatement,b as Statement,j as StringStatement,ye as SubClassOfReferenceRule,fe as SubPropertyOfReferenceRule,K as SubjectKanonak,pe as SubjectKanonakTypeRequiredRule,He as TokenCredentialProvider,L as TypeResolver,xe as UnresolvedPredicateRule,ce as UnresolvedReferenceRule,ne as ValidationContext,te as ValidationSeverity,Le as buildOntologyModel,Oe as canonicalForm,je as canonicalHash,z as carrierOf,e as compareVersions,x as computeIntegrityAsync,Ne as createCredentialedFetch,r as createVersion,Te as findDerivation,t as formatVersion,u as getKanonakUserAgent,a as isCompatibleVersion,i as isMajorCompatible,d as kanonakFetch,Ve as normalizeHost,ve as parseAuthChallenge,f as parseLockFile,n as parseVersionString,$ as parseWithPositions,s as pickHighestDocument,k as serializeLockFile,c as setKanonakUserAgent,o as versionsEqual};
@@ -0,0 +1,68 @@
1
+ import{a as ft}from"./chunk-BRCVOR7A.js";import{c as yt,k as gt}from"./chunk-ZZINR6NT.js";import{a as v,b as We,c as ct,d as F,h as H,k as dt,m as P}from"./chunk-M7LXZN47.js";import{a as it}from"./chunk-KOWDHKBN.js";import{aa as Ge,ba as pt,fa as C,ga as A,ha as q,ia as X,ja as z,ma as mt,na as B,oa as ut}from"./chunk-NOPFCGB7.js";import{A as M,c as y,d as S,j as Ye,k as Z,l as W,m as K,n as Y,p as lt,q as w,s as R,u as ee,v as N,w as G,x as k,y as U,z as b}from"./chunk-CZY6OOTM.js";import{a as st}from"./chunk-FUUTGGJS.js";import{e as $}from"./chunk-QILEJIFU.js";var te=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 h=(o=>(o.Info="Info",o.Warning="Warning",o.Error="Error",o))(h||{});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 Je=class c{resolvedDocuments=[];currentEntityPath;withPath(e){let t=new c;return t.resolvedDocuments=this.resolvedDocuments,t.currentEntityPath=e,t}};var oe=class{constructor(e){this.underlying=e;this.repository=new Qe(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 ft(e,this.repository);let t={};return{merged:await new P().parseKanonaks(this.underlying,t),authored:t.authored??[]}})()),this.parsePromise}},Qe=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 P().parseKanonaks(new ne(c,e))}async function j(c,e,t){let o=await D(c,e,t),n=qe(c);return n?o.filter(r=>r instanceof y&&r.namespace===n):[]}async function re(c,e,t){let o=qe(c);if(!o)return[];let n;if(t)n=await t.getAuthoredKanonaks();else{let r={};await new P().parseKanonaks(new ne(c,e),r),n=r.authored??[]}return n.filter(r=>r instanceof y&&r.sourceDoc===o)}function qe(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${$(e.version)}`}var ne=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 ae=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 ie=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 se=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),d=new u;d.ruleType=this.ruleName,d.severity="Error",d.entityName=n,d.propertyName="type",d.actualValue=p,d.expectedValue=m,d.message=`Invalid property type '${p}'. Use '${m}' instead.`,d.suggestion="Properties should specify their type: DatatypeProperty for data values, ObjectProperty for relationships.",t.push(d)}}}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 ce=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 Tt=new Set(["EphemeralPackage"]),pe=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_?(!Tt.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 Lt={publisher:"kanonak.org",package_:"core-rdf",name:"type"},Mt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},Bt={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"},Ft={publisher:"kanonak.org",package_:"core-rdf",name:"Class"},le=class{ruleName="EmbeddedKanonakType";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await re(e,t,o);for(let i of a)i instanceof y&&this.walk(r,i,i.name,n);return n}walk(e,t,o,n){for(let r of t.statement)if(r instanceof Z){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 W){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=k(o,Lt);if(!i)return;let s=R(e,t);if(!s)return;let p=k(s,Mt);if(p&&!(Y(p,Bt)||Y(p,Ft))){if(K(i)===K(p)){a.push(this.redundant(n,r,i,p));return}q(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 Xe}from"@kanonak-protocol/types/document/models/enums";var me=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(g=>g.metadata.namespace_?.publisher===t).map(g=>g.metadata.namespace_.package_).filter((g,f,O)=>O.indexOf(g)===f),l=this.findSimilarPackages(o.packageName,p),m=`Import '${t}/${o.package_}' not found - package does not exist`,d=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:d,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 Xe.Exact:return`exactly ${e.version.major}.${e.version.minor}.${e.version.patch}`;case Xe.Compatible:return`${e.version.major}.${e.version.minor}.${e.version.patch} to ${e.version.major}.${e.version.minor}.x`;case Xe.Major:return e.version.major===0?`0.${e.version.minor}.x`:`${e.version.major}.x.x`;case Xe.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 Ht="kanonak.org",Wt="core-rdf",Yt=new Set(["type","subClassOf","subPropertyOf","domain","range"].map(c=>K({publisher:Ht,package_:Wt,name:c}))),ue=class{ruleName="UnresolvedReference";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await j(e,t,o);return F(a,({kanonak:i,path:s})=>{for(let p of i.statement){let l=Gt(p);if(!(!l||Yt.has(K(l)))){if(p instanceof Ye)this.check(r,s,l,p.object,n);else if(p instanceof W)for(let m of p.object)m instanceof S&&this.check(r,s,l,m,n)}}}),n}check(e,t,o,n,r){R(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 Gt(c){return c.predicate?.subject}var kt={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},ht={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"};function qt(c,e){let t=k(c,e);if(t)return[t];let o=[];for(let n of b(c,e))n instanceof S&&o.push(n.subject);return o}function ze(c,e,t){let o=[],n=new Set,r=new Set,a=i=>{let s=R(c,i),p=s?`${s.namespace}/${s.name}`:K(i);if(n.has(p)){let l=o.findIndex(d=>d.key===p),m=o.slice(l);return m.length<=1?null:[...m.map(d=>d.uri),i]}if(r.has(p))return null;if(n.add(p),o.push({key:p,uri:i}),s)for(let l of qt(s,t)){let m=a(l);if(m)return m}return o.pop(),n.delete(p),r.add(p),null};return a(e)}var Rt=c=>c,de=class{ruleName="ClassHierarchyCycle";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await j(e,t,o);for(let i of a){if(!(i instanceof y)||!(C.isClassType(Rt(i))||C.isDatatypeType(Rt(i))))continue;let s=A(i);if(!s)continue;let p=ze(r,s,kt);if(p){let l=p.map(d=>d.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 fe=class{ruleName="PropertyHierarchyCycle";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await j(e,t,o);for(let i of a){if(!(i instanceof y)||!z(r,i))continue;let s=A(i);if(!s)continue;let p=ze(r,s,ht);if(p){let l=p.map(d=>d.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 Xt={publisher:"kanonak.org",package_:"core-rdf",name:"range"},ye=class{ruleName="PropertyRangeRequired";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await j(e,t,o);for(let i of a){if(!(i instanceof y))continue;let s=X(r,i);if(s!=="ObjectProperty"&&s!=="DatatypeProperty")continue;let p=s==="ObjectProperty";ee(i,Xt)||n.push(this.error(i.name,p))}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 zt={publisher:"kanonak.org",package_:"core-rdf",name:"subClassOf"},Kt=c=>c,ge=class{ruleName="SubClassOfReference";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await j(e,t,o);for(let i of a){if(!(i instanceof y)||!bt(Kt(i)))continue;let s=Zt(i,zt);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=R(e,t);return o?bt(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 bt(c){return C.isClassType(c)||C.isDatatypeType(c)}function Zt(c,e){let t=k(c,e);if(t)return[t];let o=[];for(let n of b(c,e))n instanceof S&&o.push(n.subject);return o}var Jt={publisher:"kanonak.org",package_:"core-rdf",name:"subPropertyOf"},ke=class{ruleName="SubPropertyOfReference";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await j(e,t,o);for(let i of a){if(!(i instanceof y)||!z(r,i))continue;let s=Qt(i,Jt);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=R(e,t);return o?z(e,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 Qt(c,e){let t=k(c,e);if(t)return[t];let o=[];for(let n of b(c,e))n instanceof S&&o.push(n.subject);return o}var he=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 Re=class{ruleName="UnresolvedPredicate";async validateAsync(e,t,o){let n=[],r=qe(e);if(!r)return n;let a=await D(e,t,o);return F(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 Ke=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 d=m.metadata.namespace_?.toString()??"";await this.collectEntitiesRecursivelyAsync(m,t,o,n,[...r,d],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(g=>g.startsWith("(local:"))){let g=m.filter(f=>!f.startsWith("(local:"));g.length>1&&i.push(this.createAmbiguityError(e,l,`Property '${l}'`,g,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(g=>g.startsWith("(local:"))){let g=m.filter(f=>!f.startsWith("(local:"));g.length>1&&s.push(this.createAmbiguityError(e,t,`Reference '${o}'`,g,r,i,!1,o))}}else if(Array.isArray(o))for(let m=0;m<o.length;m++){let d=`${e}.${t}[${m}]`;this.validatePropertyValue(d,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 V of n){let I=this.findAliasForNamespace(a,V);if(I){let T=t?.split(".").pop()??t;p.push(`${I}.${T}`)}}let l=p.length>0?`Use one of: ${p.map(V=>`'${V}'`).join(", ")}`:`Add aliases to imports and use qualified names (e.g., 'alias.${t}')`,m=n.map(V=>{let I=r.get(V);return!I||I.length===0?` \u2022 ${V}`:I.length===1?` \u2022 ${V} (direct import)`:` \u2022 ${V}
15
+ imported via: ${I.join(" \u2192 ")}`}).join(`
16
+ `),d=e.split(".")[0],g=e.includes(".")?e:t,f=new u;f.ruleType=this.ruleName,f.severity="Error",f.entityName=d,g&&(f.propertyName=g);let O=s??t;return O&&(f.actualValue=O),f.message=`${o} is ambiguous - defined in multiple imported namespaces`,f.suggestion=`${l}
17
+
18
+ Defined in:
19
+ ${m}`,f.expectedValue="Unambiguous reference (use namespace alias to disambiguate)",f}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 eo={publisher:"kanonak.org",package_:"core-rdf",name:"range"},Et=c=>c,be=class{ruleName="PropertyRangeReference";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await j(e,t,o);for(let i of a){if(!(i instanceof y))continue;let s=X(r,i);if(s!=="ObjectProperty"&&s!=="DatatypeProperty")continue;let p=s==="ObjectProperty";for(let l of to(i,eo))this.resolvesToClassLike(r,l)||n.push(this.error(i.name,l,p))}return n}resolvesToClassLike(e,t){let o=R(e,t);return o?C.isClassType(Et(o))||C.isDatatypeType(Et(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 to(c,e){let t=k(c,e);if(t)return[t];let o=[];for(let n of b(c,e))n instanceof S&&o.push(n.subject);return o}var oo={publisher:"kanonak.org",package_:"core-rdf",name:"range"},Ee="kanonak.org",et="core-rdf",tt="core-owl",ot=c=>c,no=[{uri:{publisher:Ee,package_:et,name:"Class"},ok:(c,e)=>C.isClassType(ot(e))||C.isDatatypeType(ot(e))},{uri:{publisher:Ee,package_:et,name:"Datatype"},ok:(c,e)=>C.isDatatypeType(ot(e))},{uri:{publisher:Ee,package_:et,name:"Property"},ok:(c,e)=>z(c,e)},{uri:{publisher:Ee,package_:tt,name:"ObjectProperty"},ok:(c,e)=>X(c,e)==="ObjectProperty"},{uri:{publisher:Ee,package_:tt,name:"DatatypeProperty"},ok:(c,e)=>X(c,e)==="DatatypeProperty"},{uri:{publisher:Ee,package_:tt,name:"AnnotationProperty"},ok:(c,e)=>X(c,e)==="AnnotationProperty"}],Ve=class{ruleName="ObjectPropertyValue";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await re(e,t,o);for(let i of a)i instanceof y&&this.walk(r,i,i.name,n);return n}walk(e,t,o,n){for(let r of t.statement)if(r instanceof Ye)this.check(e,r.predicate?.subject,r.object.subject,o,n);else if(r instanceof Z)this.walk(e,r.object,Vt(o,r.predicate?.subject),n);else if(r instanceof W){let a=r.predicate?.subject;for(let i of r.object)i instanceof S?this.check(e,a,i.subject,o,n):i instanceof v&&this.walk(e,i,Vt(o,a),n)}}check(e,t,o,n,r){if(!t)return;let a=R(e,t);if(!a)return;let i=k(a,oo);if(!i)return;let s=no.find(l=>Y(i,l.uri));if(!s)return;let p=R(e,o);p&&(s.ok(e,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 Vt(c,e){return`${c}.${e?.name??"<embedded>"}`}var ro={publisher:"kanonak.org",package_:"core-rdf",name:"type"},ao={publisher:"kanonak.org",package_:"core-rdf",name:"domain"},io={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 re(e,t,o);for(let i of a)i instanceof y&&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 Z)this.walk(e,r.object,Dt(o,r.predicate?.subject),n);else if(r instanceof W)for(let a of r.object)a instanceof v&&this.walk(e,a,Dt(o,r.predicate?.subject),n)}checkNode(e,t,o,n){let r=vt(t,ro);if(r.length===0)return;let a,i=()=>{if(!a){a=new Set([K(io)]);for(let p of r)for(let l of q(e,p))a.add(K(l))}return a},s=new Set;for(let p of t.statement){let l=so(p);if(!l||Ge(l.name)||s.has(K(l)))continue;s.add(K(l));let m=R(e,l);if(!m)continue;let d=vt(m,ao);d.length!==0&&(d.some(g=>i().has(K(g)))||n.push(this.error(o,l,d,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 so(c){return c.predicate?.subject}function vt(c,e){let t=k(c,e);if(t)return[t];let o=[];for(let n of b(c,e))n instanceof S&&o.push(n.subject);return o}function Dt(c,e){return`${c}.${e?.name??"<embedded>"}`}var co={publisher:"kanonak.org",package_:"core-rdf",name:"range"},po={publisher:"kanonak.org",package_:"core-rdf",name:"Literal"},lo=c=>c,De=class{ruleName="PropertyKindRangeConsistency";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await j(e,t,o);for(let i of a){if(!(i instanceof y))continue;let s=X(r,i);if(s!=="ObjectProperty"&&s!=="DatatypeProperty")continue;let p=s==="ObjectProperty",l=s==="DatatypeProperty",m=k(i,co);if(!m||!R(r,m))continue;let d=mo(r,m);l&&!d?n.push(this.error(i.name,m,"datatype")):p&&d&&n.push(this.error(i.name,m,"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 mo(c,e){for(let t of q(c,e)){if(Y(t,po))return!0;let o=R(c,t);if(o&&C.isDatatypeType(lo(o)))return!0}return!1}var Ie=class{ruleName="ReservedNameShadow";async validateAsync(e,t,o){let n=[],r=await j(e,t,o);for(let a of r){if(!(a instanceof y))continue;let i=pt(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 uo={publisher:"kanonak.org",package_:"core-rdf",name:"type"},It=c=>c,Ce=class{ruleName="ClassDefinition";async validateAsync(e,t,o){let n=[],r=await D(e,t,o),a=await j(e,t,o);return F(a,({kanonak:i,path:s})=>{for(let p of fo(i,uo))this.resolvesToClassLike(r,p)||n.push(this.error(s,p))}),n}resolvesToClassLike(e,t){if(Ge(t.name))return!0;let o=R(e,t);return o?C.isClassType(It(o))||C.isDatatypeType(It(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 fo(c,e){let t=k(c,e);if(t)return[t];let o=[];for(let n of b(c,e))n instanceof S&&o.push(n.subject);return o}var Se=class{ruleName="MarkdownLink";async validateAsync(e,t,o){let n=[],r=await j(e,t,o);return F(r,({kanonak:a,path:i})=>{this.checkNode(a,i,n)}),n}checkNode(e,t,o){for(let n of e.statement){if(!(n instanceof ct))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 dt(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 Ct="kanonak.org",St="look",yo={publisher:Ct,package_:St,name:"displayLabel"},go={publisher:Ct,package_:St,name:"displaySummary"},Pe=class{ruleName="DisplayLensScope";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new P().parseKanonaks(new M(e,t));let a=ko(e);if(!a)return n;for(let i of r)i instanceof y&&i.namespace===a&&(this.checkLens(r,i,yo,"displayLabel",n),this.checkLens(r,i,go,"displaySummary",n));return n}checkLens(e,t,o,n,r){let a=k(t,o);if(!a)return;let i=[],s=A(t);if(s&&i.push(s),i.push(...ut(t)),i.length===0)return;i.some(l=>B(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 ko(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${$(e.version)}`}function J(c,e,t){let o=[];return Me(c,t,{input:e},o),o}function Me(c,e,t,o){if(w(e,H.VarRef)){let a=G(e,H.varName);return a?t[a]:void 0}if(w(e,H.PropertyRead)){let a=U(e,H.readSource),i=a?Me(c,a,t,o):void 0,s=k(e,H.readProp);if(!i||!s)return;let p=B(c,i,s);if(!p.ok){o.push({contextClass:i,propertyUri:s,via:"PropertyRead"});return}return p.descriptor?.range}if(w(e,H.Traverse)){let a=U(e,H.traverseSource),i=a?Me(c,a,t,o):void 0,s=k(e,H.through),p;if(i&&s){let m=B(c,i,s);m.ok?p=m.descriptor?.range:o.push({contextClass:i,propertyUri:s,via:"Traverse"})}let l=U(e,H.step);return l?Me(c,l,{...t,input:p},o):void 0}let n=G(e,H.loopVar),r=n?{...t,[n]:void 0}:t;for(let a of ho(e))Me(c,a,r,o)}function ho(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 Be="kanonak.org",Fe="look",Ro={publisher:Be,package_:Fe,name:"semanticSvg"},Ko={publisher:Be,package_:Fe,name:"tierChip"},bo={publisher:Be,package_:Fe,name:"tierIcon"},Eo={publisher:Be,package_:Fe,name:"tierCard"},Vo={publisher:Be,package_:Fe,name:"tierFull"},vo=[Ko,bo,Eo,Vo],je=class{ruleName="LookSemanticSvgPath";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new P().parseKanonaks(new M(e,t));let a=Do(e);if(!a)return n;for(let i of r)i instanceof y&&i.namespace===a&&this.checkSemanticSvg(r,i,n);return n}checkSemanticSvg(e,t,o){let n=U(t,Ro);if(!n)return;let r=A(t);if(r)for(let a of vo){let i=U(n,a);if(i)for(let s of J(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 Do(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${$(e.version)}`}var Pt={publisher:"kanonak.org",package_:"transformations",name:"Expression"},Oe=class{ruleName="TxExpressionCompiles";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new P().parseKanonaks(new M(e,t)),a=Co(e);if(!a)return n;let i=r.filter(g=>g instanceof y&&g.namespace===a);if(i.length===0)return n;let s=new Map,p=g=>{for(let f of lt(g)){let O=K(f),V=s.get(O);if(V===void 0&&(V=Y(f,Pt)||q(r,f).some(I=>Y(I,Pt)),s.set(O,V)),V)return!0}return!1},l=[],m=new Set;for(let g of i)F([g],({kanonak:f,path:O})=>{let V=f instanceof v&&p(f);if(V&&l.push({node:f,path:O,subject:g.name}),!!V)for(let I of Io(f))p(I)&&m.add(I)});let d=new Set;for(let{node:g,path:f,subject:O}of l)if(!m.has(g))try{yt(g,f,{catalog:r,depth:0})}catch(V){let I=V instanceof Error?V.message:String(V),T=`${O}\0${f}\0${I}`;if(d.has(T))continue;d.add(T),n.push(this.toError(O,f,I))}return n}toError(e,t,o){let n=new u;n.ruleType=this.ruleName,n.severity="Error",n.entityName=e,n.propertyName=t,n.actualValue=o;let r=/[.!?]$/.test(o)?o:`${o}.`;return n.message=`A tx.Expression at '${t}' cannot be compiled by the expression runner: ${r} It would contribute nothing at render time, and a parent operation consuming its result may drop its whole output.`,n.expectedValue="A tx.Expression built only from node classes the runner implements",n.suggestion=`A vocabulary can declare an Expression subclass that no runner implements \u2014 it validates structurally and then evaluates to nothing.
45
+
46
+ Possible solutions:
47
+ \u2022 Rebuild the expression from tx primitives the runner supports
48
+ \u2022 For numeric presentation (rounding, percentages, fixed precision), use tx.NumberFormat \u2014 it scales internally, so no arithmetic is needed
49
+ \u2022 If the node class should be supported, implement it in the runner first`,n}};function Io(c){let e=[];for(let t of c.statement)if(t instanceof Z)e.push(t.object);else if(t instanceof W)for(let o of t.object)o instanceof v&&e.push(o);return e}function Co(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${$(e.version)}`}var So="kanonak.org",E=(c,e)=>({publisher:So,package_:c,name:e}),Po=E("derivation","look"),jo=E("look","bands"),Oo=E("look","Distribution"),$o=E("look","StatRow"),Uo=E("look","VersionDelta"),wo=E("look","Timeline"),Ao=E("look","VersionDiff"),xo=E("look","TimePlot"),No=E("look","ReferenceList"),_o=E("look","Diagram"),To=E("look","alphaPath"),Lo=E("look","betaPath"),nt=E("look","metricPath"),jt=E("look","lowerPath"),Ot=E("look","upperPath"),$t=E("look","hueBy"),Mo=E("look","statPath"),Bo=E("look","laneBy"),Ut=E("look","labelPath"),Fo=E("look","badgePath"),Ho=E("look","mapPath"),Wo=E("look","nodeNote"),Yo=E("look","edgeValue"),Go=E("look","stats"),qo=E("look","facets"),Xo=E("look","channels"),zo=E("look","track"),Zo=E("look","source"),Jo=E("look","relation"),Qo=E("look","entries"),$e=class{ruleName="LookBandPath";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new P().parseKanonaks(new M(e,t));let a=tn(e);if(!a)return n;for(let i of r)i instanceof y&&i.namespace===a&&this.checkDeclaration(r,i,n);return n}checkDeclaration(e,t,o){let n=U(t,Po);if(!n)return;let r=A(t);if(!r)return;let a=b(n,jo).filter(i=>i instanceof v);for(let i of a)for(let s of this.carriersOf(e,i,r))for(let p of J(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=U(t,a);s&&n.push({slot:`look.${a.name}`,context:i,expr:s})};if(w(t,Oo))for(let a of[To,Lo,nt,jt,Ot,$t])r(a,o);if(w(t,Uo)&&r(nt,o),w(t,$o)){let a=b(t,Go).filter(i=>i instanceof v);for(let i of a){let s=U(i,Mo);s&&n.push({slot:"look.stats[].statPath",context:o,expr:s})}}if(w(t,wo)||w(t,Ao)){let a=this.rangeOf(e,o,k(t,zo));if(a)for(let i of[nt,jt,Ot,$t])r(i,a)}if(w(t,xo)){let a=this.rangeOf(e,o,k(t,Zo));if(a)for(let i of[Bo,Ut])r(i,a)}if(w(t,No))for(let a of b(t,Qo)){let i=a instanceof v?void 0:en(a),s=this.rangeOf(e,o,i);if(s)for(let p of[Ut,Fo])r(p,s)}if(w(t,_o)){let a=b(t,qo).filter(i=>i instanceof v);for(let i of a){let s=this.rangeOf(e,o,k(i,Jo));if(!s)continue;let p=U(i,Wo);p&&n.push({slot:"look.facets[].nodeNote",context:s,expr:p});let l=U(i,Yo);l&&n.push({slot:"look.facets[].edgeValue",context:s,expr:l});let m=b(i,Xo).filter(d=>d instanceof v);for(let d of m){let g=U(d,Ho);g&&n.push({slot:"look.facets[].channels[].mapPath",context:s,expr:g})}}}return n}rangeOf(e,t,o){if(!o)return;let n=B(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}'.
50
+
51
+ Possible solutions:
52
+ \u2022 Read a property declared on '${r}' (or an ancestor / rdfs.Resource)
53
+ \u2022 If the property should apply to '${r}', adjust its domain
54
+ \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,a}};function en(c){let e=c.subject;return e&&typeof e.name=="string"?e:void 0}function tn(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${$(e.version)}`}var on="kanonak.org",rt=(c,e)=>({publisher:on,package_:c,name:e}),nn=rt("derivation","look"),rn=rt("look","bands"),an=rt("core-rdf","type"),He=class{ruleName="UnrenderableBand";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new P().parseKanonaks(new M(e,t)),a=sn(e);if(!a)return n;let i=gt();for(let s of r){if(!(s instanceof y)||s.namespace!==a)continue;let p=U(s,nn);if(!p)continue;let l=b(p,rn).filter(m=>m instanceof v);for(let m of l){let d=this.typeOf(m);if(!d)continue;let g=`${d.publisher}/${d.package_}/${d.name}`;if(i.has(g))continue;let f=new u;f.ruleType=this.ruleName,f.severity="Warning",f.entityName=s.name,f.propertyName="derivation.look",f.actualValue=g,f.message=`Band '${d.name}' has no renderer, so this region of the page will be empty. The declaration is valid against the look vocabulary, but the renderer emits only an HTML comment for it \u2014 which a browser does not display, so the loss is silent. Use a band the renderer implements, or remove it until it is supported.`,n.push(f)}}return n}typeOf(e){let t=k(e,an);if(t)return{publisher:t.publisher,package_:t.package_,name:t.name}}};function sn(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${$(e.version)}`}var we="kanonak.org",Ae="view",cn={publisher:we,package_:Ae,name:"bind"},pn={publisher:we,package_:Ae,name:"produces"},ln={publisher:we,package_:Ae,name:"projections"},mn={publisher:we,package_:Ae,name:"where"},un={publisher:we,package_:Ae,name:"value"},dn={publisher:we,package_:Ae,name:"as"},Ue=class{ruleName="TxExpressionPath";async validateAsync(e,t,o){let n=[],r;o?r=await o.getKanonaks():r=await new P().parseKanonaks(new M(e,t));let a=gn(e);if(!a)return n;for(let i of r)i instanceof y&&i.namespace===a&&this.checkView(r,i,n);return n}checkView(e,t,o){let n=k(t,cn);if(!n)return;let r=k(t,pn),a=0;for(let s of yn(e,b(t,ln))){let p=U(s,un);if(p)for(let m of J(e,n,p))o.push(this.toError(t.name,`view.projections[${a}].value`,n,m));let l=k(s,dn);l&&r&&(B(e,r,l).ok||o.push(this.asError(t.name,a,r,l))),a+=1}let i=0;for(let s of fn(t,mn)){for(let p of J(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}'.
55
+
56
+ Possible solutions:
57
+ \u2022 Use an output property whose domain covers '${o.name}'
58
+ \u2022 Define a new property in the ViewPackage with domain '${o.name}' and the right range
59
+ \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}'.
60
+
61
+ Possible solutions:
62
+ \u2022 Read a property declared on '${a}' (or an ancestor / rdfs.Resource)
63
+ \u2022 If the property should apply to '${a}', adjust its domain
64
+ \u2022 If the path is wrong, correct the tx.PropertyRead/tx.Traverse chain`,s}};function fn(c,e){let t=U(c,e);return t?[t]:b(c,e).filter(o=>o instanceof v)}function yn(c,e){let t=[];for(let o of e)if(o instanceof v)t.push(o);else if(o instanceof S){let n=R(c,o.subject);n&&t.push(n)}return t}function gn(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${$(e.version)}`}var Ze="kanonak.org",kn="core-shacl",x=c=>({publisher:Ze,package_:kn,name:c}),hn=x("NodeShape"),Rn=x("PropertyShape"),Kn=x("targetClass"),bn=x("property"),En=x("path"),Vn=x("minCount"),vn=x("maxCount"),Dn=x("datatype"),In=x("class"),wt=x("in"),Cn=x("pattern"),Sn=x("flags"),Pn=x("minLength"),jn=x("maxLength"),On=x("minInclusive"),$n=x("maxInclusive"),Un=new Set(["decimal","integer","int","long","short","byte","float","double","nonNegativeInteger","positiveInteger","negativeInteger","nonPositiveInteger","unsignedInt","unsignedLong","unsignedShort","unsignedByte"]),At=c=>c,Ne=class{ruleName="ShaclShape";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new P().parseKanonaks(t),a=wn(e);if(!a)return n;let i=new Set;for(let s of r){if(!(s instanceof y)||s.namespace!==a||!w(s,hn))continue;let p=k(s,Kn);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.",Q(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 b(s,bn)){let m;if(l instanceof v)m=l;else if(l instanceof S){let d=R(r,l.subject);d&&(m=d,i.add(K(l.subject)))}m&&this.checkPropertyShape(r,s.name,m,p??void 0,n)}}for(let s of r){if(!(s instanceof y)||s.namespace!==a||!w(s,Rn))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=k(o,En);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=R(e,a),s=i?z(e,i):!1;s?n&&(B(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.`,Q(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.",Q(a)));let p=k(o,Dn),l=k(o,In);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.",Q(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.",Q(l)));let m=xe(N(o,Vn)),d=xe(N(o,vn));this.checkOrder(t,"minCount",m,"maxCount",d,r);let g=xe(N(o,Pn)),f=xe(N(o,jn));this.checkOrder(t,"minLength",g,"maxLength",f,r);let O=xe(N(o,On)),V=xe(N(o,$n));this.checkOrder(t,"minInclusive",O,"maxInclusive",V,r);let I=G(o,Cn);if(I!==void 0){let T=G(o,Sn);try{new RegExp(I,T)}catch{r.push(this.err(t,"pattern","Error",`sh:pattern on '${t}' is not a valid regular expression`+(T!==void 0?` (with flags '${T}')`:"")+`: ${I}`,"Provide a valid regular expression and flags.",I))}}if(ee(o,wt)&&b(o,wt).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=B(e,n,a).descriptor;L&&((I!==void 0||g!==void 0||f!==void 0)&&L.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.",Q(a))),(O!==void 0||V!==void 0)&&!this.isNumericDatatypeRange(L.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.",Q(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=R(e,t);return o?C.isClassType(At(o)):!1}resolvesToDatatype(e,t){if(t.publisher===Ze&&t.package_==="core-rdf"&&t.name==="Literal")return!0;let o=R(e,t);return o?C.isDatatypeType(At(o)):!1}isNumericDatatypeRange(e){return!e||e.publisher===Ze&&e.package_==="core-rdf"&&e.name==="Literal"?!0:e.publisher===Ze&&e.package_==="core-xsd"&&Un.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 xe(c){return typeof c=="number"?c:void 0}function Q(c){return`${c.publisher}/${c.package_}/${c.name}`}function wn(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${$(e.version)}`}var xt={publisher:"kanonak.org",package_:"core-owl",name:"oneOf"},An=c=>c,_e=class{ruleName="OwlOneOf";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new P().parseKanonaks(t),a=xn(e);if(!a)return n;for(let i of r){if(!(i instanceof y)||i.namespace!==a||!ee(i,xt))continue;let s=b(i,xt);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 We)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 S){let l=R(r,p.subject);l&&C.isSchemaDefinitionType(An(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 xn(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${$(e.version)}`}var Nn="kanonak.org",_n="core-shacl",_=c=>({publisher:Nn,package_:_n,name:c}),Tn=_("NodeShape"),Ln=_("targetClass"),Mn=_("property"),Bn=_("path"),Fn=_("minCount"),Hn=_("maxCount"),Wn=_("in"),Yn=_("pattern"),Gn=_("flags"),qn=_("minLength"),Xn=_("maxLength"),zn=_("minInclusive"),Zn=_("maxInclusive"),Jn=_("message");function Te(c){return typeof c=="number"?c:void 0}function Qn(c){let e={},t=Te(N(c,Fn)),o=Te(N(c,Hn));t!==void 0&&(e.minCount=t),o!==void 0&&(e.maxCount=o);let n=Te(N(c,qn)),r=Te(N(c,Xn));n!==void 0&&(e.minLength=n),r!==void 0&&(e.maxLength=r);let a=Te(N(c,zn)),i=Te(N(c,Zn));a!==void 0&&(e.minInclusive=a),i!==void 0&&(e.maxInclusive=i);let s=G(c,Yn);if(s!==void 0){let m=G(c,Gn);e.pattern=m!==void 0?{regex:s,flags:m}:{regex:s}}let p=b(c,Wn).filter(m=>m instanceof We).map(m=>m.value);p.length>0&&(e.enumValues=p);let l=G(c,Jn);return l!==void 0&&(e.message=l),e}function er(c,e){let t=[];for(let o of b(e,Mn))if(o instanceof v)t.push(o);else if(o instanceof S){let n=R(c,o.subject);n&&t.push(n)}return t}function Nt(c){let e=new Map;for(let t of c){if(!(t instanceof y)||!w(t,Tn))continue;let o=k(t,Ln);if(!o)continue;let n=K(o);for(let r of er(c,t)){let a=k(r,Bn);if(!a)continue;let i={pathKey:K(a),constraints:Qn(r)},s=e.get(n);s?s.push(i):e.set(n,[i])}}return e}function tr(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 _t(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,tr(r,s.constraints))}if(n)return r.cardinality=r.maxCount===1?"single":"list",r.required=(r.minCount??0)>=1,r}var or=c=>c,nr=new st("kanonak.org","core-rdf","Resource"),Le=class{ruleName="DiamondNameClash";async validateAsync(e,t,o){let n=[],r=o?await o.getKanonaks():await new P().parseKanonaks(t),a=rr(e);if(!a)return n;let i=Nt(r);for(let s of r){if(!(s instanceof y)||s.namespace!==a||!C.isClassType(or(s)))continue;let p=A(s);if(!p)continue;let l=q(r,p),m=K(p),d=new Set(l.map(f=>K(f)));d.delete(m),d.delete(K(nr));let g=new Map;for(let f of mt(r,p)){if(!f.domains.some(I=>d.has(K(I))))continue;let V=g.get(f.uri.name);V?V.push(f):g.set(f.uri.name,[f])}for(let[f,O]of g){if(O.length<2)continue;let V=L=>_t(i,l,L.uri)?.cardinality,I=new Set(O.map(L=>L.range?K(L.range):void 0).filter(L=>L!==void 0)),T=new Set(O.map(V).filter(L=>L!==void 0));I.size<=1&&T.size<=1||n.push(this.toError(s.name,f,O,V))}}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}':
65
+ \u2022 rename one of the properties, or
66
+ \u2022 re-domain one so it is not inherited by '${e}', or
67
+ \u2022 restructure the hierarchy so '${e}' inherits only one '${t}', or
68
+ \u2022 make the ranges/cardinalities compatible (identical) if they are meant to be the same property.`,i}};function rr(c){let e=c.metadata.namespace_;if(!(!e||!e.version))return`${e.publisher}/${e.package_}@${$(e.version)}`}var at=class{parser;documentRules;repositoryRules;includeWarnings=!0;constructor(e){this.parser=e??new it,this.documentRules=[new ae,new ie,new se,new ce,new pe],this.repositoryRules=[new le,new me,new ue,new de,new fe,new ye,new ge,new ke,new he,new Re,new Ke,new be,new Ve,new ve,new De,new Ie,new Ce,new Se,new Pe,new je,new $e,new He,new Oe,new Ue,new Ne,new _e,new Le]}async validateAsync(e,t,o){let n=new te;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 oe(new ne(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 oe(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 te;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{te as a,h as b,u as c,Je as d,oe as e,ae as f,ie as g,se as h,ce as i,pe as j,le as k,me as l,ue as m,de as n,fe as o,ye as p,ge as q,ke as r,he as s,Re as t,Ke as u,be as v,Ve as w,ve as x,De as y,Ie as z,Ce as A,Se as B,Pe as C,je as D,Oe as E,$e as F,Ue as G,Ne as H,_e as I,Nt as J,_t as K,Le as L,at as M};
@@ -0,0 +1 @@
1
+ import{a as j,b as x,m as $}from"./chunk-M7LXZN47.js";import{da as U,e as l,f as u,g as b,h as C,i as a}from"./chunk-NOPFCGB7.js";import{c as S,d as O,g as I,h as T,i as g,j as v,k as L,l as q}from"./chunk-CZY6OOTM.js";var d=class{all=new Set;byPIdx=new Map;bySPIdx=new Map;byPOIdx=new Map;tripleList=[];add(e){let r=b(e);return this.all.has(r)?!1:(this.all.add(r),this.tripleList.push(e),h(this.byPIdx,e.p,e),h(this.bySPIdx,`${e.s}|${e.p}`,e),e.o.kind==="uri"&&h(this.byPOIdx,`${e.p}|${e.o.key}`,e),!0)}has(e){return this.all.has(b(e))}size(){return this.tripleList.length}snapshot(){return this.tripleList.slice()}byPredicate(e){let r=this.byPIdx.get(e);return r?r.slice():[]}bySubjectPredicate(e,r){let t=this.bySPIdx.get(`${e}|${r}`);return t?t.slice():[]}byPredicateObject(e,r){let t=this.byPOIdx.get(`${e}|${r}`);return t?t.slice():[]}subjectsWithPredicateObject(e,r){let t=this.byPOIdx.get(`${e}|${r}`);if(!t)return[];let s=new Set;for(let n of t)s.add(n.s);return Array.from(s)}uriObjectsOf(e,r){let t=this.bySPIdx.get(`${e}|${r}`);if(!t)return[];let s=new Set;for(let n of t)n.o.kind==="uri"&&s.add(n.o.key);return Array.from(s)}hasUri(e,r,t){return this.all.has(`${e}|${r}|u:${t}`)}hasTriple(e,r,t){return this.all.has(`${e}|${r}|${C(t)}`)}};function h(o,e,r){let t=o.get(e);t?t.push(r):o.set(e,[r])}var _={name:"rdfs2",apply(o,e){let r=!1;for(let t of o.byPredicate(e.domain)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;for(let i of o.byPredicate(s))o.add(a(i.s,e.type,n))&&(r=!0)}return r}},E={name:"rdfs3",apply(o,e){let r=!1;for(let t of o.byPredicate(e.range)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;for(let i of o.byPredicate(s))i.o.kind==="uri"&&o.add(a(i.o.key,e.type,n))&&(r=!0)}return r}},A={name:"rdfs5",apply(o,e){let r=!1;for(let t of o.byPredicate(e.subPropertyOf)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;for(let i of o.bySubjectPredicate(n,e.subPropertyOf))i.o.kind==="uri"&&o.add(a(s,e.subPropertyOf,i.o.key))&&(r=!0)}return r}},V={name:"rdfs7",apply(o,e){let r=!1;for(let t of o.byPredicate(e.subPropertyOf)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.byPredicate(s)){let p={s:i.s,p:n,o:i.o};o.add(p)&&(r=!0)}}return r}},W={name:"rdfs9",apply(o,e){let r=!1;for(let t of o.byPredicate(e.subClassOf)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.byPredicateObject(e.type,s))o.add(a(i.s,e.type,n))&&(r=!0)}return r}},F={name:"rdfs11",apply(o,e){let r=!1;for(let t of o.byPredicate(e.subClassOf)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;for(let i of o.bySubjectPredicate(n,e.subClassOf))i.o.kind==="uri"&&o.add(a(s,e.subClassOf,i.o.key))&&(r=!0)}return r}},k=[_,E,A,V,W,F];var N={name:"prp-trp",apply(o,e){let r=!1,t=o.subjectsWithPredicateObject(e.type,e.transitiveProperty);for(let s of t){let n=o.byPredicate(s);for(let i of n){if(i.o.kind!=="uri")continue;let p=i.o.key;for(let c of o.bySubjectPredicate(p,s))c.o.kind==="uri"&&i.s!==c.o.key&&o.add(a(i.s,s,c.o.key))&&(r=!0)}}return r}},D={name:"prp-symp",apply(o,e){let r=!1,t=o.subjectsWithPredicateObject(e.type,e.symmetricProperty);for(let s of t)for(let n of o.byPredicate(s))n.o.kind==="uri"&&o.add(a(n.o.key,s,n.s))&&(r=!0);return r}},M={name:"prp-inv1",apply(o,e){let r=!1;for(let t of o.byPredicate(e.inverseOf)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;for(let i of o.byPredicate(s))i.o.kind==="uri"&&o.add(a(i.o.key,n,i.s))&&(r=!0)}return r}},z={name:"prp-inv2",apply(o,e){let r=!1;for(let t of o.byPredicate(e.inverseOf)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;for(let i of o.byPredicate(n))i.o.kind==="uri"&&o.add(a(i.o.key,s,i.s))&&(r=!0)}return r}},B={name:"prp-eqp1",apply(o,e){let r=!1;for(let t of o.byPredicate(e.equivalentProperty)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.byPredicate(s))o.add({s:i.s,p:n,o:i.o})&&(r=!0)}return r}},G={name:"prp-eqp2",apply(o,e){let r=!1;for(let t of o.byPredicate(e.equivalentProperty)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.byPredicate(n))o.add({s:i.s,p:s,o:i.o})&&(r=!0)}return r}},H={name:"cax-eqc1",apply(o,e){let r=!1;for(let t of o.byPredicate(e.equivalentClass)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.byPredicateObject(e.type,s))o.add(a(i.s,e.type,n))&&(r=!0)}return r}},J={name:"cax-eqc2",apply(o,e){let r=!1;for(let t of o.byPredicate(e.equivalentClass)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.byPredicateObject(e.type,n))o.add(a(i.s,e.type,s))&&(r=!0)}return r}},Q={name:"eq-rep-s",apply(o,e){let r=!1;for(let t of o.byPredicate(e.sameAs)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n){for(let i of o.snapshot())i.s===s&&o.add({s:n,p:i.p,o:i.o})&&(r=!0);for(let i of o.snapshot())i.s===n&&o.add({s,p:i.p,o:i.o})&&(r=!0)}}return r}},X={name:"eq-rep-o",apply(o,e){let r=!1;for(let t of o.byPredicate(e.sameAs)){if(t.o.kind!=="uri")continue;let s=t.s,n=t.o.key;if(s!==n)for(let i of o.snapshot())i.o.kind==="uri"&&(i.o.key===s?o.add(a(i.s,i.p,n))&&(r=!0):i.o.key===n&&o.add(a(i.s,i.p,s))&&(r=!0))}return r}},K=[N,D,M,z,B,G,H,J,Q,X];var y=class{constructor(e,r){this.store=e;this.vocabulary=r}store;vocabulary;getInstancesOfClass(e){let r=f(e);return this.store.subjectsWithPredicateObject(this.vocabulary.type,r)}getSubclasses(e){let r=f(e);return this.store.subjectsWithPredicateObject(this.vocabulary.subClassOf,r).filter(s=>s!==r)}getSuperclasses(e){let r=f(e);return this.store.uriObjectsOf(r,this.vocabulary.subClassOf).filter(t=>t!==r)}getTypesOfIndividual(e){return this.store.uriObjectsOf(f(e),this.vocabulary.type)}isInstanceOf(e,r){return this.store.hasUri(f(e),this.vocabulary.type,f(r))}getPropertyClosure(e){let r=f(e),t={},s=new Map;for(let n of this.store.byPredicate(r)){if(n.o.kind!=="uri")continue;let i=s.get(n.s);i||(i=new Set,s.set(n.s,i),t[n.s]=[]),i.has(n.o.key)||(i.add(n.o.key),t[n.s].push(n.o.key))}return t}getPropertyClosures(e){let r={};for(let t of e)r[f(t)]=this.getPropertyClosure(t);return r}triples(){return this.store.snapshot()}size(){return this.store.size()}};function f(o){return typeof o=="string"?o:u(o.publisher,o.package_,o.name)}var R=class{vocabulary;profile;maxIterations;constructor(e={}){this.vocabulary=e.vocabulary??new U,this.profile=e.profile??"owl-rl-classification",this.maxIterations=e.maxIterations??100}async reason(e){let r=new d,s=await new $().parseKanonaks(e),n=new P;for(let c of s)if(c instanceof S){let m=Y(c);if(!m)continue;for(let w of c.statement)this.emitStatement(m,w,r,n)}let i=[...k];this.profile==="owl-rl-classification"&&i.push(...K);let p=0;for(;p<this.maxIterations;){let c=!1;for(let m of i)m.apply(r,this.vocabulary)&&(c=!0);if(!c)break;p++}return new y(r,this.vocabulary)}emitStatement(e,r,t,s){let n=Z(r);if(n){if(r instanceof I){t.add({s:e,p:n,o:{kind:"literal",lexical:r.object,datatype:"string"}});return}if(r instanceof T){t.add({s:e,p:n,o:{kind:"literal",lexical:String(r.object),datatype:"number"}});return}if(r instanceof g){t.add({s:e,p:n,o:{kind:"literal",lexical:String(r.object),datatype:"boolean"}});return}if(r instanceof v){let i=l(r.object.subject);t.add(a(e,n,i));return}if(r instanceof L){let i=s.next();t.add({s:e,p:n,o:{kind:"blank",id:i}}),this.emitEmbedded(i,r.object,t,s);return}if(r instanceof q){for(let i of r.object??[])this.emitListItem(e,n,i,t,s);return}}}emitListItem(e,r,t,s,n){if(t instanceof O)s.add(a(e,r,l(t.subject)));else if(t instanceof j){let i=n.next();s.add({s:e,p:r,o:{kind:"blank",id:i}}),this.emitEmbedded(i,t,s,n)}else if(t instanceof x){let i=typeof t.value=="number"?"number":typeof t.value=="boolean"?"boolean":"string";s.add({s:e,p:r,o:{kind:"literal",lexical:String(t.value),datatype:i}})}}emitEmbedded(e,r,t,s){let n=`_:${e}`;for(let i of r.statement)this.emitStatement(n,i,t,s)}},P=class{counter=0;next(){return`b${this.counter++}`}};function Y(o){let e=o.namespace??"",r=e.indexOf("@"),t=r===-1?e:e.substring(0,r),s=t.indexOf("/");if(s===-1)return null;let n=t.substring(0,s),i=t.substring(s+1);return!n||!i||!o.name?null:u(n,i,o.name)}function Z(o){let e=o.predicate;return e?.subject?l(e.subject):null}export{d as a,k as b,K as c,y as d,R as e};
@@ -0,0 +1 @@
1
+ import{a as U}from"./chunk-FUUTGGJS.js";import{c as h,g as j}from"./chunk-QILEJIFU.js";var m=class{};var c=class extends m{statement=[];unresolvedPredicates=[];sourceDoc=""};var p=class extends c{namespace;name;icon};var a=class t extends m{subject;static parse(e){let n=new t;return n.subject=U.parse(e),n}};var s=class{predicate;object};var i=class extends s{carrier;lexical};var y=class t extends i{static parse(e,n){let r=new t;return r.predicate=a.parse(e),r.object=n,r}};var k=class t extends i{static parse(e,n){let r=new t;return r.predicate=a.parse(e),r.object=n,r}};var b=class extends i{};var f=class t extends s{static parse(e,n){let r=new t;return r.predicate=a.parse(e),r.object=a.parse(n),r}};var g=class extends s{};var d=class extends s{};function E(t){return`${t.publisher}/${t.package_}/${t.name}`}function S(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}function $(t){let e=t.version;return e&&typeof e.major=="number"?`https://${t.publisher}/${t.package_}/${e.major}.${e.minor}.${e.patch}/${t.name}`:`https://${t.publisher}/${t.package_}/${t.name}`}function A(t){if(!(t instanceof c))return[];let e=[];for(let n of t.statement)if(n.predicate?.subject?.name==="type"){if(n instanceof f)e.push(n.object.subject);else if(n instanceof d)for(let o of n.object)o instanceof a&&e.push(o.subject)}return e}function D(t,e){if(!(t instanceof c))return!1;for(let n of t.statement)if(n.predicate?.subject?.name==="type"&&n instanceof f){let o=n.object;if(S(o.subject,e))return!0}return!1}function P(t,e){let n=[];for(let r of t)r instanceof p&&D(r,e)&&n.push(r);return n}function v(t,e){let n=e.version,r=n&&typeof n.major=="number"?`${e.publisher}/${e.package_}@${n.major}.${n.minor}.${n.patch}`:void 0;for(let o of t){if(!(o instanceof p)||o.name!==e.name)continue;let u=o.namespace||"";if(r!==void 0){if(u===r)return o}else if(u.startsWith(`${e.publisher}/${e.package_}@`))return o}}function I(t,e){let n=[];for(let r of t){if(!(r instanceof p)||r.name!==e.name)continue;(r.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(r)}return n.sort((r,o)=>{let u=j((r.namespace||"").split("@")[1]??""),K=j((o.namespace||"").split("@")[1]??"");return u?K?h(K,u):-1:K?1:0}),n}function l(t,e){for(let n of t.statement){let r=n.predicate;if(r?.subject&&S(r.subject,e))return n}}function V(t,e){return l(t,e)!==void 0}function R(t,e){let n=l(t,e);if(n&&(n instanceof y||n instanceof k||n instanceof b))return n.object}function w(t,e){let n=R(t,e);return typeof n=="string"?n:void 0}function C(t,e){let n=l(t,e);if(n instanceof f)return n.object.subject}function B(t,e){let n=l(t,e);if(n instanceof g)return n.object}function T(t,e){let n=l(t,e);return n instanceof d?n.object??[]:[]}var x=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{m as a,c as b,p as c,a as d,s as e,i as f,y as g,k as h,b as i,f as j,g as k,d as l,E as m,S as n,$ as o,A as p,D as q,P as r,v as s,I as t,V as u,R as v,w,C as x,B as y,T as z,x as A};
@@ -1,2 +1,2 @@
1
- import{l as V}from"./chunk-YU2VGLOT.js";import{a as E}from"./chunk-KOWDHKBN.js";var L=class{propertyUri;propertyType;range;rangeUri;isImported;definedInNamespace};import{parseDocument as O,LineCounter as R,isMap as h,isPair as f,isScalar as g,isSeq as I}from"yaml";var K=class i{entities=new Map;entityBlocks=new Map;properties=new Map;propertyValues=new Map;valueListItems=new Map;importPackages=new Map;nestedKeys=new Map;nestedValues=new Map;static fromContent(e){let t=new i,n=new R,r=O(e,{lineCounter:n});if(r.errors.length>0||!h(r.contents))return t;N(r.contents,[],n,t);for(let o of r.contents.items){if(!f(o)||!g(o.key))continue;let a=String(o.key.value),u=o.key.range;if(!u)continue;t.entities.set(a,d(u,n));let s=o.value,c=s&&typeof s=="object"&&"range"in s?s.range:void 0;if(c?t.entityBlocks.set(a,d([u[0],u[1],c[2]],n)):t.entityBlocks.set(a,d(u,n)),h(o.value)){let k=new Map,m=new Map,l=new Map;for(let P of o.value.items){if(!f(P)||!g(P.key))continue;let b=String(P.key.value),p=P.key.range;p&&k.set(b,d(p,n));let S=P.value;if(S&&typeof S=="object"&&"range"in S&&Array.isArray(S.range)){let v=S.range;m.set(b,d(v,n))}if(I(S)){let v=[];for(let M of S.items)M&&typeof M=="object"&&"range"in M&&Array.isArray(M.range)&&v.push(d(M.range,n));v.length>0&&l.set(b,v)}}k.size>0&&t.properties.set(a,k),m.size>0&&t.propertyValues.set(a,m),l.size>0&&t.valueListItems.set(a,l);let y=j(o.value,n);y.length>0&&t.importPackages.set(a,y)}}return t}getEntityPosition(e){return this.entities.get(e)}getEntityBlockPosition(e){return this.entityBlocks.get(e)}findEntityAtPosition(e,t){for(let[n,r]of this.entityBlocks)if(w(r,e,t))return n}findPropertyAtPosition(e,t){let n=this.findEntityAtPosition(e,t);if(!n)return;let r=this.properties.get(n),o=this.propertyValues.get(n);if(!r&&!o)return{entityName:n};let a,u;if(o)for(let[s,c]of o)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);if(r)for(let[s,c]of r)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);return a?{entityName:n,propertyName:a}:{entityName:n}}getPropertyPosition(e,t){return this.properties.get(e)?.get(t)}getPropertyValuePosition(e,t){return this.propertyValues.get(e)?.get(t)}getImportPackages(e){return this.importPackages.get(e)??[]}getAllImportPackages(){let e=[];for(let[t,n]of this.importPackages)for(let r of n)e.push({entityName:t,entry:r});return e}findPropertySourceName(e,t){let n=this.properties.get(e);if(n){if(n.has(t))return t;for(let r of n.keys()){let o=r.lastIndexOf(".");if((o===-1?r:r.substring(o+1))===t)return r}}}getListItemPosition(e,t,n){let r=this.valueListItems.get(e)?.get(t);if(!(!r||n<0||n>=r.length))return r[n]}getNodeKeyPosition(e){return this.nestedKeys.get(JSON.stringify(e))}getNodeValuePosition(e){return this.nestedValues.get(JSON.stringify(e))}setNestedKeyPosition(e,t){this.nestedKeys.set(e,t)}setNestedValuePosition(e,t){this.nestedValues.set(e,t)}getMostSpecificPosition(e,t,n){if(e){if(t!==void 0){if(n!==void 0){let a=this.getListItemPosition(e,t,n);if(a)return a}let r=this.getPropertyValuePosition(e,t);if(r)return r;let o=this.getPropertyPosition(e,t);if(o)return o}return this.getEntityPosition(e)}}};function j(i,e){let t=[];if(!h(i))return t;let n=i.items.find(r=>f(r)&&g(r.key)&&String(r.key.value)==="imports");if(!n||!f(n)||!I(n.value))return t;for(let r of n.value.items){if(!h(r))continue;let o=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="publisher");if(!o||!f(o)||!g(o.value))continue;let a=String(o.value.value),u=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="packages");if(!(!u||!f(u)||!I(u.value)))for(let s of u.value.items){if(!h(s))continue;let c=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="package");if(!c||!f(c)||!g(c.value)||!c.value.range)continue;let k=String(c.value.value),m=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="version"),l=m&&f(m)&&g(m.value)?String(m.value.value):"",y=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="alias"),P=y&&f(y)&&g(y.value)?String(y.value.value):void 0,b=P!==void 0?{publisher:a,package_:k,version:l,alias:P,position:d(c.value.range,e)}:{publisher:a,package_:k,version:l,position:d(c.value.range,e)};t.push(b)}}return t}function w(i,e,t){return!(e<i.line||e>i.endLine||e===i.line&&t<i.column||e===i.endLine&&t>i.endColumn)}function C(i,e){let t=i.endLine-i.line,n=e.endLine-e.line;if(t!==n)return t<n;let r=i.endLine===i.line?i.endColumn-i.column:Number.MAX_SAFE_INTEGER,o=e.endLine===e.line?e.endColumn-e.column:Number.MAX_SAFE_INTEGER;return r<o}function N(i,e,t,n){if(h(i)){for(let r of i.items){if(!f(r)||!g(r.key))continue;let o=String(r.key.value),a=[...e,o],u=JSON.stringify(a);r.key.range&&n.setNestedKeyPosition(u,d(r.key.range,t));let s=r.value,c=D(s);c&&n.setNestedValuePosition(u,d(c,t)),N(s,a,t,n)}return}if(I(i)){for(let r=0;r<i.items.length;r++){let o=i.items[r],a=[...e,r],u=JSON.stringify(a),s=D(o);s&&n.setNestedValuePosition(u,d(s,t)),N(o,a,t,n)}return}}function D(i){if(!i||typeof i!="object"||!("range"in i))return;let e=i.range;return Array.isArray(e)&&e.length>=3?e:void 0}function d(i,e){let t=e.linePos(i[0]),n=e.linePos(i[2]);return{line:t.line-1,column:t.col-1,endLine:n.line-1,endColumn:n.col-1}}function x(i,e){let n=(e??new E).parse(i),r=K.fromContent(i);return{document:n,positions:r}}function W(i,e,t,n,r){if(e<n.line||e>n.endLine||e===n.line&&t<n.column||e===n.endLine&&t>=n.endColumn)return;let o=A(r,n.line,n.column),a=A(r,n.endLine,n.endColumn);if(o<0||a<0)return;let u=r.substring(o,a),s=V(u);if(s.length!==i.links.length)return;let c=e-n.line,k=e===n.line?t-n.column:t,m=A(u,c,k);if(!(m<0))for(let l=0;l<s.length;l++){let y=s[l];if(m>=y.startOffset&&m<y.endOffset)return i.links[l]}}function A(i,e,t){let n=0,r=0;for(let o=0;o<i.length;o++){if(n===e)return Math.min(r+t,i.length);i[o]===`
1
+ import{l as V}from"./chunk-M7LXZN47.js";import{a as E}from"./chunk-KOWDHKBN.js";var L=class{propertyUri;propertyType;range;rangeUri;isImported;definedInNamespace};import{parseDocument as O,LineCounter as R,isMap as h,isPair as f,isScalar as g,isSeq as I}from"yaml";var K=class i{entities=new Map;entityBlocks=new Map;properties=new Map;propertyValues=new Map;valueListItems=new Map;importPackages=new Map;nestedKeys=new Map;nestedValues=new Map;static fromContent(e){let t=new i,n=new R,r=O(e,{lineCounter:n});if(r.errors.length>0||!h(r.contents))return t;N(r.contents,[],n,t);for(let o of r.contents.items){if(!f(o)||!g(o.key))continue;let a=String(o.key.value),u=o.key.range;if(!u)continue;t.entities.set(a,d(u,n));let s=o.value,c=s&&typeof s=="object"&&"range"in s?s.range:void 0;if(c?t.entityBlocks.set(a,d([u[0],u[1],c[2]],n)):t.entityBlocks.set(a,d(u,n)),h(o.value)){let k=new Map,m=new Map,l=new Map;for(let P of o.value.items){if(!f(P)||!g(P.key))continue;let b=String(P.key.value),p=P.key.range;p&&k.set(b,d(p,n));let S=P.value;if(S&&typeof S=="object"&&"range"in S&&Array.isArray(S.range)){let v=S.range;m.set(b,d(v,n))}if(I(S)){let v=[];for(let M of S.items)M&&typeof M=="object"&&"range"in M&&Array.isArray(M.range)&&v.push(d(M.range,n));v.length>0&&l.set(b,v)}}k.size>0&&t.properties.set(a,k),m.size>0&&t.propertyValues.set(a,m),l.size>0&&t.valueListItems.set(a,l);let y=j(o.value,n);y.length>0&&t.importPackages.set(a,y)}}return t}getEntityPosition(e){return this.entities.get(e)}getEntityBlockPosition(e){return this.entityBlocks.get(e)}findEntityAtPosition(e,t){for(let[n,r]of this.entityBlocks)if(w(r,e,t))return n}findPropertyAtPosition(e,t){let n=this.findEntityAtPosition(e,t);if(!n)return;let r=this.properties.get(n),o=this.propertyValues.get(n);if(!r&&!o)return{entityName:n};let a,u;if(o)for(let[s,c]of o)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);if(r)for(let[s,c]of r)w(c,e,t)&&(!u||C(c,u))&&(a=s,u=c);return a?{entityName:n,propertyName:a}:{entityName:n}}getPropertyPosition(e,t){return this.properties.get(e)?.get(t)}getPropertyValuePosition(e,t){return this.propertyValues.get(e)?.get(t)}getImportPackages(e){return this.importPackages.get(e)??[]}getAllImportPackages(){let e=[];for(let[t,n]of this.importPackages)for(let r of n)e.push({entityName:t,entry:r});return e}findPropertySourceName(e,t){let n=this.properties.get(e);if(n){if(n.has(t))return t;for(let r of n.keys()){let o=r.lastIndexOf(".");if((o===-1?r:r.substring(o+1))===t)return r}}}getListItemPosition(e,t,n){let r=this.valueListItems.get(e)?.get(t);if(!(!r||n<0||n>=r.length))return r[n]}getNodeKeyPosition(e){return this.nestedKeys.get(JSON.stringify(e))}getNodeValuePosition(e){return this.nestedValues.get(JSON.stringify(e))}setNestedKeyPosition(e,t){this.nestedKeys.set(e,t)}setNestedValuePosition(e,t){this.nestedValues.set(e,t)}getMostSpecificPosition(e,t,n){if(e){if(t!==void 0){if(n!==void 0){let a=this.getListItemPosition(e,t,n);if(a)return a}let r=this.getPropertyValuePosition(e,t);if(r)return r;let o=this.getPropertyPosition(e,t);if(o)return o}return this.getEntityPosition(e)}}};function j(i,e){let t=[];if(!h(i))return t;let n=i.items.find(r=>f(r)&&g(r.key)&&String(r.key.value)==="imports");if(!n||!f(n)||!I(n.value))return t;for(let r of n.value.items){if(!h(r))continue;let o=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="publisher");if(!o||!f(o)||!g(o.value))continue;let a=String(o.value.value),u=r.items.find(s=>f(s)&&g(s.key)&&String(s.key.value)==="packages");if(!(!u||!f(u)||!I(u.value)))for(let s of u.value.items){if(!h(s))continue;let c=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="package");if(!c||!f(c)||!g(c.value)||!c.value.range)continue;let k=String(c.value.value),m=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="version"),l=m&&f(m)&&g(m.value)?String(m.value.value):"",y=s.items.find(p=>f(p)&&g(p.key)&&String(p.key.value)==="alias"),P=y&&f(y)&&g(y.value)?String(y.value.value):void 0,b=P!==void 0?{publisher:a,package_:k,version:l,alias:P,position:d(c.value.range,e)}:{publisher:a,package_:k,version:l,position:d(c.value.range,e)};t.push(b)}}return t}function w(i,e,t){return!(e<i.line||e>i.endLine||e===i.line&&t<i.column||e===i.endLine&&t>i.endColumn)}function C(i,e){let t=i.endLine-i.line,n=e.endLine-e.line;if(t!==n)return t<n;let r=i.endLine===i.line?i.endColumn-i.column:Number.MAX_SAFE_INTEGER,o=e.endLine===e.line?e.endColumn-e.column:Number.MAX_SAFE_INTEGER;return r<o}function N(i,e,t,n){if(h(i)){for(let r of i.items){if(!f(r)||!g(r.key))continue;let o=String(r.key.value),a=[...e,o],u=JSON.stringify(a);r.key.range&&n.setNestedKeyPosition(u,d(r.key.range,t));let s=r.value,c=D(s);c&&n.setNestedValuePosition(u,d(c,t)),N(s,a,t,n)}return}if(I(i)){for(let r=0;r<i.items.length;r++){let o=i.items[r],a=[...e,r],u=JSON.stringify(a),s=D(o);s&&n.setNestedValuePosition(u,d(s,t)),N(o,a,t,n)}return}}function D(i){if(!i||typeof i!="object"||!("range"in i))return;let e=i.range;return Array.isArray(e)&&e.length>=3?e:void 0}function d(i,e){let t=e.linePos(i[0]),n=e.linePos(i[2]);return{line:t.line-1,column:t.col-1,endLine:n.line-1,endColumn:n.col-1}}function x(i,e){let n=(e??new E).parse(i),r=K.fromContent(i);return{document:n,positions:r}}function W(i,e,t,n,r){if(e<n.line||e>n.endLine||e===n.line&&t<n.column||e===n.endLine&&t>=n.endColumn)return;let o=A(r,n.line,n.column),a=A(r,n.endLine,n.endColumn);if(o<0||a<0)return;let u=r.substring(o,a),s=V(u);if(s.length!==i.links.length)return;let c=e-n.line,k=e===n.line?t-n.column:t,m=A(u,c,k);if(!(m<0))for(let l=0;l<s.length;l++){let y=s[l];if(m>=y.startOffset&&m<y.endOffset)return i.links[l]}}function A(i,e,t){let n=0,r=0;for(let o=0;o<i.length;o++){if(n===e)return Math.min(r+t,i.length);i[o]===`
2
2
  `&&(n++,r=o+1)}return n===e?Math.min(r+t,i.length):-1}export{L as a,K as b,x as c,W as d};
@@ -0,0 +1 @@
1
+ import{a as G}from"./chunk-KOWDHKBN.js";import{a as H,aa as Y,b as J,ba as N,ca as A,ia as Z}from"./chunk-NOPFCGB7.js";import{a as X,b as q,c as w,d as g,g as R,h as T,i as M,j as D,k as K,l as P,m as x,n as _,s as Q}from"./chunk-CZY6OOTM.js";import{a as L}from"./chunk-FUUTGGJS.js";import{k as W}from"./chunk-QILEJIFU.js";var b=class extends q{name};var j=class extends X{value;carrier;lexical};var I=class extends R{links=[]};var ae="kanonak.org",oe="transformations",Ke=3,e=p=>({publisher:ae,package_:oe,name:p}),E={Transformation:e("Transformation"),InstanceTransformation:e("InstanceTransformation"),SetTransformation:e("SetTransformation"),inputPattern:e("inputPattern"),rule:e("rule"),artifactName:e("artifactName"),outputs:e("outputs"),formatOverrides:e("formatOverrides"),partitionBy:e("partitionBy"),InputPattern:e("InputPattern"),matchesClass:e("matchesClass"),requires:e("requires"),sortBy:e("sortBy"),SortKey:e("SortKey"),byProperty:e("byProperty"),order:e("order"),SortOrder:e("SortOrder"),ascending:e("ascending"),descending:e("descending"),OutputFormat:e("OutputFormat"),backendUri:e("backendUri"),FormatOverride:e("FormatOverride"),formatTarget:e("formatTarget"),metadataKeys:e("metadataKeys"),metadataRenames:e("metadataRenames"),trailingNewline:e("trailingNewline"),omitWrapper:e("omitWrapper"),RenameEntry:e("RenameEntry"),fromKey:e("fromKey"),toKey:e("toKey"),FMT_MARKDOWN_FRONTMATTER:e("markdown-with-frontmatter"),FMT_PLAIN_MARKDOWN:e("plain-markdown"),FMT_TOML:e("toml"),FMT_JSON:e("json"),FMT_HTML:e("html"),FMT_SVG:e("svg"),Expression:e("Expression"),ListSourcedExpression:e("ListSourcedExpression"),ListAggregate:e("ListAggregate"),IteratingExpression:e("IteratingExpression"),BuildAstNode:e("BuildAstNode"),astClass:e("astClass"),set:e("set"),AstFieldBinding:e("AstFieldBinding"),field:e("field"),bindValue:e("bindValue"),When:e("When"),condition:e("condition"),thenBuild:e("thenBuild"),elseBuild:e("elseBuild"),Concat:e("Concat"),parts:e("parts"),Fallback:e("Fallback"),primary:e("primary"),alternate:e("alternate"),StringLiteral:e("StringLiteral"),stringLiteral:e("stringLiteral"),IntegerLiteral:e("IntegerLiteral"),integerLiteral:e("integerLiteral"),DecimalLiteral:e("DecimalLiteral"),decimalLiteral:e("decimalLiteral"),BooleanLiteral:e("BooleanLiteral"),booleanLiteral:e("booleanLiteral"),VarRef:e("VarRef"),varName:e("varName"),PropertyRead:e("PropertyRead"),readSource:e("readSource"),readProp:e("readProp"),Traverse:e("Traverse"),traverseSource:e("traverseSource"),through:e("through"),step:e("step"),UriName:e("UriName"),uriNameOf:e("uriNameOf"),UriPublisher:e("UriPublisher"),uriPublisherOf:e("uriPublisherOf"),UriPackage:e("UriPackage"),uriPackageOf:e("uriPackageOf"),UriVersion:e("UriVersion"),uriVersionOf:e("uriVersionOf"),SubjectUri:e("SubjectUri"),subjectOf:e("subjectOf"),UriLiteral:e("UriLiteral"),refTo:e("refTo"),DisplayLabel:e("DisplayLabel"),labelTarget:e("labelTarget"),labelSource:e("labelSource"),ResolveRef:e("ResolveRef"),resolveSource:e("resolveSource"),Normalize:e("Normalize"),normSource:e("normSource"),normKind:e("normKind"),NormalizeKind:e("NormalizeKind"),NORM_TRIM_END:e("trim-end"),NORM_TO_UPPER:e("to-upper"),NORM_TO_LOWER:e("to-lower"),NORM_FIRST_CHAR:e("first-char"),UnescapedString:e("UnescapedString"),unescapedSource:e("unescapedSource"),IsSet:e("IsSet"),checkExpr:e("checkExpr"),ExpressionFragment:e("ExpressionFragment"),body:e("body"),CallFragment:e("CallFragment"),fragmentRef:e("fragmentRef"),source:e("source"),Join:e("Join"),separator:e("separator"),Count:e("Count"),Sum:e("Sum"),Min:e("Min"),Max:e("Max"),Average:e("Average"),loopVar:e("loopVar"),ForEach:e("ForEach"),emit:e("emit"),ListMap:e("ListMap"),mapBody:e("mapBody"),Filter:e("Filter"),predicate:e("predicate"),PartitionBy:e("PartitionBy"),partitionKey:e("partitionKey"),DistinctBy:e("DistinctBy"),distinctKey:e("distinctKey"),Partition:e("Partition"),key:e("key"),members:e("members"),AllStatements:e("AllStatements"),statementsOf:e("statementsOf"),StatementPredicate:e("StatementPredicate"),predicateOf:e("predicateOf"),StatementValue:e("StatementValue"),valueOf:e("valueOf"),DateFormat:e("DateFormat"),dateSource:e("dateSource"),dateFormat:e("dateFormat"),NumberFormat:e("NumberFormat"),numberSource:e("numberSource"),numberStyle:e("numberStyle"),fractionDigits:e("fractionDigits"),currencyCode:e("currencyCode"),BinaryArithmetic:e("BinaryArithmetic"),arithLeft:e("arithLeft"),arithRight:e("arithRight"),Add:e("Add"),Subtract:e("Subtract"),Multiply:e("Multiply"),Divide:e("Divide"),Reverse:e("Reverse"),WindowedMap:e("WindowedMap"),windowSize:e("windowSize"),windowVar:e("windowVar"),windowBody:e("windowBody"),PairwiseMap:e("PairwiseMap"),firstVar:e("firstVar"),secondVar:e("secondVar"),pairBody:e("pairBody"),Scan:e("Scan"),initialState:e("initialState"),stateVar:e("stateVar"),elementVar:e("elementVar"),accumulate:e("accumulate"),ListItemAt:e("ListItemAt"),itemIndex:e("itemIndex"),BinaryComparison:e("BinaryComparison"),compareLeft:e("compareLeft"),compareRight:e("compareRight"),Equals:e("Equals"),GreaterThan:e("GreaterThan"),LessThan:e("LessThan"),GreaterThanOrEqual:e("GreaterThanOrEqual"),LessThanOrEqual:e("LessThanOrEqual"),Not:e("Not"),operand:e("operand"),BooleanLogic:e("BooleanLogic"),operands:e("operands"),And:e("And"),Or:e("Or"),Contains:e("Contains"),haystack:e("haystack"),needle:e("needle"),UnaryNumericOp:e("UnaryNumericOp"),value:e("value"),Abs:e("Abs"),Negate:e("Negate"),KindPredicate:e("KindPredicate"),IsReference:e("IsReference"),IsEmbedded:e("IsEmbedded"),IsList:e("IsList"),kindCheck:e("kindCheck"),IsString:e("IsString"),IsNumber:e("IsNumber"),IsBoolean:e("IsBoolean"),StatementObject:e("StatementObject"),statementSource:e("statementSource"),Let:e("Let"),letName:e("letName"),letValue:e("letValue"),letBody:e("letBody"),GetStatementByName:e("GetStatementByName"),inSubject:e("inSubject"),byName:e("byName"),RenderMarkdown:e("RenderMarkdown"),renderSource:e("renderSource"),renderProp:e("renderProp"),renderFormat:e("renderFormat"),RenderFormat:e("RenderFormat"),RENDER_HTML:e("render-html"),RENDER_MARKDOWN:e("render-markdown")};import{Carrier as h,carrierOf as se}from"@kanonak-protocol/canonical";function B(p){return se(`${p.publisher}/${p.package_}/${p.name}`)}var ie=/\[\[([^\[\]\n]+)\]\]/g,ce=/\[\[/g,ee=/```[\s\S]*?```|`[^`\n]*`/g;function pe(p){let t=[];for(let n of p.matchAll(ee))t.push([n.index,n.index+n[0].length]);return t}function ve(p){if(!p||!p.includes("[["))return[];let t=pe(p),n=s=>t.some(([o,c])=>s>=o&&s<c),r=new Set(V(p).map(s=>s.startOffset)),a=[];for(let s of p.matchAll(ce)){let o=s.index;if(n(o)||r.has(o))continue;let c=p.slice(o,o+48).replace(/\s+/g," ").trim();a.push({startOffset:o,snippet:c})}return a}function V(p){if(!p||!p.includes("[["))return[];let t=[];for(let a of p.matchAll(ee))t.push([a.index,a.index+a[0].length]);let n=a=>t.some(([s,o])=>a>=s&&a<o),r=[];for(let a of p.matchAll(ie)){let s=a.index;if(n(s))continue;let o=a[1],c=o.indexOf("|"),m=(c===-1?o:o.slice(0,c)).trim();if(m.length===0)continue;let i=c===-1?"":o.slice(c+1).trim(),u={reference:m,startOffset:s,endOffset:s+a[0].length};i.length>0&&(u.displayText=i),r.push(u)}return r}function ne(p,t){for(let n of p)n instanceof w&&U(n,n.name,t)}function U(p,t,n){n({kanonak:p,path:t});for(let r of p.statement){let a=r.predicate?.subject?.name;if(r instanceof K)U(r.object,te(t,a,r.object),n);else if(r instanceof P)for(let s=0;s<r.object.length;s++){let o=r.object[s];o instanceof b&&U(o,te(t,a,o,s),n)}}}function te(p,t,n,r){let a=`${p}.${t??"<embedded>"}`,s=n instanceof b?n.name:void 0;return s?`${a}.${s}`:r===void 0?a:`${a}[${r}]`}var me={...N("range"),name:"range"};function fe(p){let t=p.lastIndexOf(".");return t===-1?p:p.slice(t+1)}var re=class{constructor(t){}async parseKanonaks(t,n){let r=await t.getAllDocumentsAsync(),a=new H(t),s=new J(a);this.knownPropertyClasses.clear();let o=await this.parseAllDocumentsAsync(r,a,s,t),c=await this.mergeAndCanonicalizeAsync(o,t);return await this.learnPropertyClassesAsync(c,r,a)&&(o=await this.parseAllDocumentsAsync(r,a,s,t),c=await this.mergeAndCanonicalizeAsync(o,t)),n&&(n.authored=o),c}knownPropertyClasses=new Map;async learnPropertyClassesAsync(t,n,r){let a=new Map;for(let m of n){let i=m.metadata.namespace_?.toString();i&&a.set(i,m)}let s=[],o=new Set;ne(t,({kanonak:m})=>{for(let i of m.unresolvedPredicates){let u=`${i.sourceDoc}::${i.key}`;o.has(u)||(o.add(u),s.push(i))}});let c=!1;for(let m of s){let i=a.get(m.sourceDoc);if(!i)continue;let u=await r.resolveEntityAsync(m.key,i);if(!u)continue;let d=x(u.uri);if(this.knownPropertyClasses.has(d))continue;let f=Q(t,u.uri);if(!f)continue;let l=Z(t,f);l&&(this.knownPropertyClasses.set(d,l),c=!0)}return c}async parseAllDocumentsAsync(t,n,r,a){let s=[];for(let o of t){let c=o.metadata.namespace_?.toString()??"";for(let[m,i]of Object.entries(o.body)){let u=new w,d=this.resolveCanonicalEntity(m,o,c);u.namespace=d.namespace,u.name=d.name,u.statement=[];let f=await this.parseStatements(i,o,n,r,a);u.statement.push(...f.statements),u.unresolvedPredicates=f.unresolved,F(u,c),s.push(u)}}return s}async mergeAndCanonicalizeAsync(t,n){let r=new Map,a=new Map,s=[];for(let i of t)if(i instanceof w){let u=`${i.namespace}/${i.name}`,d=r.get(u);if(d){let f=a.get(u);for(let l of i.statement){let y=$(l);f.has(y)||(f.add(y),d.statement.push(l))}for(let l of i.unresolvedPredicates)d.unresolvedPredicates.some(y=>y.key===l.key&&y.sourceDoc===l.sourceDoc)||d.unresolvedPredicates.push(l)}else{let f=new w;f.namespace=i.namespace,f.name=i.name,f.sourceDoc=i.sourceDoc;let l=new Set;for(let y of i.statement){let k=$(y);l.has(k)||(l.add(k),f.statement.push(y))}f.unresolvedPredicates=[...i.unresolvedPredicates],a.set(u,l),r.set(u,f),s.push(f)}}else s.push(i);let o=new Set;for(let i of s)if(i instanceof w){let u=i.namespace||"",d=u.indexOf("/"),f=d>=0?u.slice(0,d):"",l=d>=0?u.slice(d+1):"",y=l.indexOf("@"),k=y>=0?l.slice(0,y):l;o.add(`${f}/${k}/${i.name}`)}let c=i=>o.has(`${i.publisher}/${i.package_}/${i.name}`),m=new Map;for(let i of["core-rdf","core-owl","core-kanonak"]){let u=await n.getDocumentsByNamespaceAsync("kanonak.org",i);m.set(i,W(u).chosen?.metadata.namespace_?.version??void 0)}for(let i of t)i instanceof w&&this.canonicalizeStatementBuiltins(i.statement,c,m);return s}canonicalizeStatementBuiltins(t,n,r){for(let a of t){let s=a.predicate?.subject;if(A(s,n,r),a instanceof D)a.object instanceof g&&A(a.object.subject,n,r);else if(a instanceof K)a.object&&this.canonicalizeStatementBuiltins(a.object.statement,n,r);else if(a instanceof P)for(let o of a.object??[])o instanceof g?A(o.subject,n,r):o instanceof b&&this.canonicalizeStatementBuiltins(o.statement,n,r)}}resolveCanonicalEntity(t,n,r){if(!t.includes(".")||!n.metadata?.imports)return{namespace:r,name:t};let a=t.indexOf("."),s=t.substring(0,a),o=t.substring(a+1);for(let[c,m]of Object.entries(n.metadata.imports))for(let i of m)if((i.alias??i.packageName)===s){let d=i.version;return{namespace:`${c}/${i.packageName}@${d.major}.${d.minor}.${d.patch}`,name:o}}return{namespace:r,name:t}}async parseStatements(t,n,r,a,s){let o=[],c=[];if(typeof t!="object"||t===null||Array.isArray(t))return{statements:o,unresolved:c};let m=n.metadata.namespace_?.toString()??"";for(let[i,u]of Object.entries(t))try{let d=await this.getPropertyMetadata(i,n,r,s,a);if(!d){let l=i.includes(".")?i.slice(i.lastIndexOf(".")+1):i;Y(l)||c.push({key:i,sourceDoc:m});continue}let f=await this.parsePropertyValue(i,u,d,n,r,a,s);f&&o.push(f)}catch(d){throw new Error(`Failed to parse property '${i}': ${d.message}`,{cause:d})}return{statements:o,unresolved:c}}async getPropertyMetadata(t,n,r,a,s){let o=await r.resolveEntityAsync(t,n);if(!o)return;let c=o.entity,m=c.type?.toString()??"",i=m.includes(".")?m.substring(m.lastIndexOf(".")+1):m,u=new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]),d=this.knownPropertyClasses.get(x(o.uri));if(!u.has(i)&&!d)return;let f=d??s.getPropertyTypeClassification(m),l,y=async()=>{if(l)return l;if(!(o.isImported&&o.definedInNamespace))return l=n,n;if(typeof a.getDocumentAsync!="function")throw new Error(`Cannot resolve the range of imported property '${t}': the parse repository cannot fetch defining document '${o.definedInNamespace}'. Thread the real repository through to embedded-object parsing \u2014 no stub, no fallback.`);let v=await a.getDocumentAsync(o.definedInNamespace);if(!v)throw new Error(`Cannot resolve the range of imported property '${t}': defining document '${o.definedInNamespace}' was not found in the repository.`);return l=v,v},k=await this.readDefinitionSlot(c,me,y,r),S=k==null?void 0:String(k),O;if(f==="ObjectProperty")O="ObjectProperty";else if(f==="DatatypeProperty")O="DatatypeProperty";else{let v=S&&S.includes(".")?S.substring(S.lastIndexOf(".")+1):S??"";(S?s.isKnownXsdDatatypeName(S):!1)||v==="Literal"?O="DatatypeProperty":O="ObjectProperty"}let z;return S&&(z=(await r.resolveEntityAsync(S,await y()))?.uri),{propertyUri:o.uri.toString(),propertyType:O,range:S,rangeUri:z,isImported:o.isImported,definedInNamespace:o.definedInNamespace}}async readDefinitionSlot(t,n,r,a){let s=Object.keys(t).filter(i=>fe(i)===n.name);if(s.length===0)return;let o=await r(),c=N(n.name),m=c!==void 0&&c.publisher===n.publisher&&c.package_===n.package_;for(let i of s){let u=await a.resolveEntityAsync(i,o);if(u){if(_(u.uri,n))return t[i];continue}if(!i.includes(".")&&m)return t[i]}}async parsePropertyValue(t,n,r,a,s,o,c){let m=r.propertyUri;if(n!=null){if(Array.isArray(n))return this.parseListValue(m,n,r,a,s,o,c);if(r.propertyType==="DatatypeProperty")return this.parseDatatypeValue(m,n,r,a,s,o);if(r.propertyType==="ObjectProperty")return this.parseObjectValue(m,n,r,a,s,o,c)}}async parseDatatypeValue(t,n,r,a,s,o){let c;if(typeof n=="string"){if(o.isSubstitutableDatatype(r.rangeUri))return await this.parseSubstitutableValue(t,n,a,s);c=n}else if(typeof n=="number"||typeof n=="boolean")c=String(n);else return;return this.typedScalarStatement(t,c,r)}typedScalarStatement(t,n,r){let a=g.parse(t),s=r.rangeUri?B(r.rangeUri):void 0;if(s===h.Boolean){let c=new M;return c.predicate=a,c.object=n==="true"||n==="1",c.carrier=s,c.lexical=n,c}if(s===h.Integer||s===h.Decimal||s===h.Double||s===h.Float){let c=new T;return c.predicate=a,c.object=Number(n),c.carrier=s,c.lexical=n,c}let o=R.parse(t,n);return s&&(o.carrier=s,o.lexical=n),o}typedListLiteral(t,n){let r=new j,a=n.rangeUri?B(n.rangeUri):void 0;return a===h.Boolean?r.value=t==="true"||t==="1":a===h.Integer||a===h.Decimal||a===h.Double||a===h.Float?r.value=Number(t):r.value=t,a&&(r.carrier=a,r.lexical=t),r}async parseSubstitutableValue(t,n,r,a){let s=new I;s.predicate=g.parse(t),s.object=n;for(let o of V(n)){let c=await a.resolveEntityAsync(o.reference,r),m;c&&(m=new g,m.subject=c.uri);let i={reference:o.reference,startOffset:o.startOffset,endOffset:o.endOffset};o.displayText!==void 0&&(i.displayText=o.displayText),m!==void 0&&(i.target=m),s.links.push(i)}return s}async parseObjectValue(t,n,r,a,s,o,c){if(typeof n=="string"){if(r.rangeUri&&_(r.rangeUri,E.Expression))return this.coerceExpressionLiteral(t,n,r.rangeUri);let m=await this.resolveReference(n,a,s);if(!m)return;let i=new D;return i.predicate=g.parse(t),i.object=m,i}if(typeof n=="object"&&!Array.isArray(n)){let m=await this.parseStatements(n,a,s,o,c);if(m.statements.length>0){let d=new b;d.statement=m.statements,d.unresolvedPredicates=m.unresolved;let f=new K;return f.predicate=g.parse(t),f.object=d,f}let i=[];for(let[d,f]of Object.entries(n))if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let l=new b;l.name=d;let y=await this.parseStatements(f,a,s,o,c);l.statement=y.statements,l.unresolvedPredicates=y.unresolved,i.push(l)}else if(typeof f=="string"){let l=await this.resolveReference(f,a,s);l&&i.push(l)}if(i.length>0){let d=new P;return d.predicate=g.parse(t),d.object=i,d}let u=new K;return u.predicate=g.parse(t),u.object=new b,u}}coerceExpressionLiteral(t,n,r){let a=new b,s=new D,o=new g;o.subject=new L("kanonak.org","core-rdf","type"),s.predicate=o;let c=new g;c.subject=new L(r.publisher,r.package_,E.StringLiteral.name,r.version),s.object=c;let m=new R,i=new g;i.subject=new L(r.publisher,r.package_,E.stringLiteral.name,r.version),m.predicate=i,m.object=n,a.statement=[s,m];let u=new K;return u.predicate=g.parse(t),u.object=a,u}async parseListValue(t,n,r,a,s,o,c){let m=[],i=r.propertyType==="DatatypeProperty",u=r.rangeUri?.publisher==="kanonak.org"&&r.rangeUri?.package_==="core-rdf"&&r.rangeUri?.name==="List"||!r.rangeUri&&(r.range?.includes(".")?r.range.substring(r.range.lastIndexOf(".")+1):r.range)==="List";for(let f of n){let l=typeof f=="string"||typeof f=="number"||typeof f=="boolean";if(i&&l){let y=typeof f=="string"?f:String(f);m.push(this.typedListLiteral(y,r));continue}if(u&&l){if(typeof f=="string"){let y=await s.resolveEntityAsync(f,a);if(y){let k=new g;k.subject=y.uri,m.push(k)}else{let k=new j;k.value=f,m.push(k)}}else{let y=new j;y.value=f,m.push(y)}continue}if(typeof f=="string"){let y=await this.resolveReference(f,a,s);y&&m.push(y)}else if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let y=new b,k=await this.parseStatements(f,a,s,o,c);y.statement=k.statements,y.unresolvedPredicates=k.unresolved,m.push(y)}}let d=new P;return d.predicate=g.parse(t),d.object=m,d}async resolveReference(t,n,r){let a=await r.resolveEntityAsync(t,n);if(a){let o=new g;return o.subject=a.uri,o}let s=n.metadata?.namespace_;if(s){let{KanonakUri:o}=await import("./KanonakUri-4VJGV3FN.js");if(t.includes(".")){let m=t.indexOf("."),i=t.substring(0,m),u=t.substring(m+1);if(n.metadata?.imports){for(let[d,f]of Object.entries(n.metadata.imports))for(let l of f)if((l.alias??l.packageName)===i){let k=new g;return k.subject=new o(d,l.packageName,u,l.version),k}}}let c=new g;return c.subject=new o(s.publisher,s.package_,t,s.version??void 0),c}return null}async saveKanonaks(t,n){let r=new Map;for(let a of t)a instanceof w&&a.namespace&&(r.has(a.namespace)||r.set(a.namespace,[]),r.get(a.namespace).push(a));for(let[a,s]of r){let o=await this.convertKanonaksToDocument(a,s),c=`${a.split("@")[0]}.yml`;await n.saveDocumentAsync(o,c)}}async serializeToYaml(t,n){let r=t.filter(o=>o instanceof w&&o.namespace===n);if(r.length===0)throw new Error(`No kanonaks found with namespace '${n}'`);let a=await this.convertKanonaksToDocument(n,r);return new G().save(a)}async convertKanonaksToDocument(t,n){let a={metadata:{namespace_:t,get allImports(){if(!this.imports)return[];let o=[];for(let c of Object.values(this.imports))o.push(...c);return o}},body:{}},s=new Map;for(let o of n){let c={};for(let m of o.statement){let[i,u]=this.convertStatementToProperty(m);i&&u!==null&&u!==void 0&&(c[i]=u),this.collectImportsFromStatement(m,t,s)}a.body[o.name]=c}return a}convertStatementToProperty(t){if(t instanceof R)return[t.predicate.subject.name,t.object];if(t instanceof T)return[t.predicate.subject.name,t.object];if(t instanceof M)return[t.predicate.subject.name,t.object];if(t instanceof D)return[t.predicate.subject.name,t.object.subject.name];if(t instanceof P){let n=this.convertKanonakListToValue(t.object);return[t.predicate.subject.name,n]}else if(t instanceof K){let n=this.convertEmbeddedKanonakToValue(t.object);return[t.predicate.subject.name,n]}return[null,null]}convertKanonakListToValue(t){let n=[];for(let r of t)r instanceof g?n.push(r.subject.name):r instanceof b&&n.push(this.convertEmbeddedKanonakToValue(r));return n}convertEmbeddedKanonakToValue(t){let n={};for(let r of t.statement){let[a,s]=this.convertStatementToProperty(r);a&&s!==null&&s!==void 0&&(n[a]=s)}return n}collectImportsFromStatement(t,n,r){}};function F(p,t){p.sourceDoc=t;for(let n of p.statement)if(n instanceof K)F(n.object,t);else if(n instanceof P)for(let r of n.object)r instanceof b&&F(r,t)}function $(p){let t=p.predicate?.subject;return(t?`${t.publisher}/${t.package_}/${t.name}`:"?")+"="+ue(p)}function ue(p){return p instanceof I?"m:"+String(p.object):p instanceof R?"s:"+String(p.object):p instanceof T?"n:"+String(p.object):p instanceof M?"b:"+String(p.object):p instanceof D?"r:"+C(p.object):p instanceof K?"e:"+C(p.object):p instanceof P?"l:["+(p.object??[]).map(C).join("|")+"]":"x"}function C(p){if(!p)return"";if(p instanceof g){let t=p.subject;return"R("+(t?`${t.publisher}/${t.package_}/${t.name}`:"")+")"}return p instanceof b?"E("+(p.statement??[]).map($).join(";")+")":p instanceof j?"L("+String(p.value)+")":"N"}export{b as a,j as b,I as c,ne as d,ae as e,oe as f,Ke as g,E as h,h as i,B as j,ve as k,V as l,re as m};
@@ -0,0 +1 @@
1
+ import{c as B,d as G,m as h,n as X,s as Y,t as T,w as v,x as j,z as q}from"./chunk-CZY6OOTM.js";import{a as P}from"./chunk-FUUTGGJS.js";var W=class{cache=new Map;repository;logger;constructor(e,t){this.repository=e,this.logger=t}async resolveEntityAsync(e,t){let r=t.metadata?.namespace_?.toString()??"unknown",o=this.cache.get(r);if(o){let i=o.get(e);if(i)return i}let a=await this.buildEntityIndexAsyncInternal(t,new Set,"",new Map);return this.cache.set(r,a),a.get(e)??null}async resolveAllEntitiesAsync(e,t){let r=await this.buildAllEntitiesIndexAsync(t,new Set,"");if(e.includes(".")){let o=e.split("."),a=o[0],i=o[1],u=await this.findDocumentForAlias(t,a);return u?await this.resolveAllEntitiesAsync(i,u):[]}return r.filter(o=>o.entityName===e)}async buildAllEntitiesIndexAsync(e,t,r){let o=[],a=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${a}`),t.has(a))return this.logger?.debug?.(`Skipping ${a} - already visited (circular import prevention)`),o;t.add(a);let i=r.length===0?a:`${r} \u2192 ${a}`;for(let[u,c]of Object.entries(e.body))if(!u.includes(".")&&c&&typeof c=="object"&&!Array.isArray(c)){if(!e.metadata.namespace_)continue;let g=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};o.push({entityName:u,uri:new P(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,u,g),entity:c,definedInNamespace:a,isImported:r.length>0,importPath:i})}if(this.logger?.debug?.(`Collected ${o.length} entities from ${a}`),e.metadata?.imports){let u=Object.values(e.metadata.imports).reduce((c,g)=>c+g.length,0);this.logger?.debug?.(`Processing ${u} import(s) for ${a}`);for(let[c,g]of Object.entries(e.metadata.imports))for(let m of g)try{this.logger?.debug?.(`Resolving import: ${c}/${m.packageName}`);let d=await this.repository.getHighestCompatibleVersionAsync(c,m);if(d){this.logger?.debug?.(`Successfully loaded import: ${d.metadata?.namespace_?.toString()}`);let k=await this.buildAllEntitiesIndexAsync(d,t,i);o.push(...k),this.logger?.debug?.(`Added ${k.length} entities from import ${d.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${c}/${m.packageName}`)}catch(d){let k=d;throw this.logger?.error?.(`Failed to process import ${c}/${m.packageName} for namespace ${a}. Error: ${k.message}`,k),new Error(`Failed to process import ${c}/${m.packageName} for namespace ${a}. See inner exception for details.`,{cause:d})}}return o}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"",new Map)}async buildEntityIndexAsyncInternal(e,t,r,o){let a=new Map,i=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${i}`),t.has(i))return this.logger?.debug?.(`Skipping ${i} - circular import in progress`),a;let u=o.get(i);if(u)return u;t.add(i);let c=r.length===0?i:`${r} \u2192 ${i}`,g=0;for(let[m,d]of Object.entries(e.body))if(!m.includes(".")&&d&&typeof d=="object"&&!Array.isArray(d)){if(!e.metadata.namespace_)continue;if(!a.has(m)){let k=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};a.set(m,{entityName:m,uri:new P(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,m,k),entity:d,definedInNamespace:i,isImported:r.length>0,importPath:c}),g++}}if(this.logger?.debug?.(`Indexed ${g} entities from ${i}`),e.metadata?.imports){let m=Object.values(e.metadata.imports).reduce((d,k)=>d+k.length,0);this.logger?.debug?.(`Processing ${m} import(s) for ${i}`);for(let[d,k]of Object.entries(e.metadata.imports))for(let K of k)try{this.logger?.debug?.(`Resolving import: ${d}/${K.packageName}`);let E=await this.repository.getHighestCompatibleVersionAsync(d,K);if(E){this.logger?.debug?.(`Successfully loaded import: ${E.metadata?.namespace_?.toString()}`);let U=await this.buildEntityIndexAsyncInternal(E,t,c,o),$=0;for(let[O,C]of U.entries()){let _=a.get(O);if(!_)a.set(O,C),$++;else if(_.isImported&&C.isImported&&(_.uri.publisher!==C.uri.publisher||_.uri.package_!==C.uri.package_)){let A=_.isAmbiguous?_:{..._,isAmbiguous:!0,ambiguousNamespaces:[_.definedInNamespace]};A.ambiguousNamespaces.includes(C.definedInNamespace)||A.ambiguousNamespaces.push(C.definedInNamespace),a.set(O,A),this.logger?.warn?.(`Ambiguous reference '${O}': defined in ${A.ambiguousNamespaces.join(", ")}`)}if(K.alias&&!O.includes(".")){let A=`${K.alias}.${O}`;a.has(A)||(a.set(A,C),$++)}}this.logger?.debug?.(`Merged ${$} entities from import ${E.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${d}/${K.packageName}`)}catch(E){let U=E;throw this.logger?.error?.(`Failed to process import ${d}/${K.packageName} for namespace ${i}. Error: ${U.message}`,U),new Error(`Failed to process import ${d}/${K.packageName} for namespace ${i}. See inner exception for details.`,{cause:E})}}return t.delete(i),o.set(i,a),a}async findDocumentForAlias(e,t){if(!e.metadata?.imports)return null;for(let[r,o]of Object.entries(e.metadata.imports))for(let a of o){if(a.alias===t)return await this.repository.getHighestCompatibleVersionAsync(r,a);if(!a.alias&&a.packageName===t)return await this.repository.getHighestCompatibleVersionAsync(r,a)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}};var z=class n{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"&&n.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 t=e.includes(".")?e.split(".")[1]:e;return n.KNOWN_XSD_DATATYPES.has(t.toLowerCase())}async isClassTypeAsync(e,t){if(this.isKnownXsdDatatypeName(e))return!1;let r=await this.resourceResolver.resolveEntityAsync(e,t);if(r){let o=r.entity.type;if(o){let a=String(o);return a==="Class"||a==="rdfs.Class"||a.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,t){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(t)||e==="Property"&&this.isLiteralType(t))}isEffectiveObjectProperty(e,t){return!!(e==="ObjectProperty"||e==="Property"&&t&&!this.isXsdDatatype(t)&&!this.isLiteralType(t))}};function J(n){if(!n||n.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let e=n.trim(),t=e.split("/");if(t.length===1){let r=t[0];if(!r)throw new Error(`Invalid Kanonak address: "${n}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(r.includes("@"))throw new Error(`Invalid Kanonak address: "${n}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:r}}if(t.length===2){let[r,o]=t;if(!r||!o)throw new Error(`Invalid Kanonak address: "${n}". Expected publisher/package[@version].`);let a=o.indexOf("@");if(a===-1)return{kind:"package",publisher:r,package_:o};let i=o.substring(0,a),u=o.substring(a+1);if(!i||!u)throw new Error(`Invalid Kanonak address: "${n}". Expected publisher/package[@version].`);let c=re(u);return{kind:"package",publisher:r,package_:i,version:c}}return{kind:"resource",uri:P.parse(e)}}function Oe(n){switch(n.kind){case"publisher":return n.publisher;case"package":return n.version?`${n.publisher}/${n.package_}@${n.version.major}.${n.version.minor}.${n.version.patch}`:`${n.publisher}/${n.package_}`;case"resource":return n.uri.toString()}}function re(n){let e=n.split(".").map(Number);return oe(e[0]||0,e[1]||0,e[2]||0)}function oe(n,e,t){return{major:n,minor:e,patch:t,toString:()=>`${n}.${e}.${t}`,equals:r=>!r||typeof r!="object"?!1:r.major===n&&r.minor===e&&r.patch===t,getHashCode:()=>n<<20|e<<10|t,compareTo:r=>n!==r.major?n-r.major:e!==r.minor?e-r.minor:t-r.patch}}function Ne(n){return`${n.publisher}/${n.package_}/${n.name}`}function y(n,e,t){return`${n}/${e}/${t}`}function He(n){return`${n.s}|${n.p}|${ae(n.o)}`}function ae(n){switch(n.kind){case"uri":return`u:${n.key}`;case"literal":return`l:${n.datatype}:${n.lexical}`;case"blank":return`b:${n.id}`}}function Ie(n,e,t){return{s:n,p:e,o:{kind:"uri",key:t}}}var se="kanonak.org",ie="core-shacl",s=n=>({publisher:se,package_:ie,name:n}),N=s("Shape"),H=s("NodeShape"),I=s("PropertyShape"),$e=s("targetClass"),Te=s("property"),ve=s("path"),je=s("minCount"),we=s("maxCount"),Me=s("datatype"),Le=s("class"),Ve=s("in"),Fe=s("pattern"),Be=s("flags"),Ge=s("minLength"),Xe=s("maxLength"),Ye=s("minInclusive"),qe=s("maxInclusive"),We=s("message"),ze=s("targetNode"),Je=s("targetSubjectsOf"),Qe=s("targetObjectsOf"),Ze=s("closed"),et=s("ignoredProperties"),tt=s("nodeKind"),nt=s("IRI"),rt=s("BlankNode"),ot=s("Literal"),at=s("severity"),st=s("Violation"),it=s("Warning"),pt=s("Info"),ct=s("ValidationReport"),lt=s("conforms"),ut=s("result"),yt=s("ValidationResult"),dt=s("focusNode"),gt=s("resultPath"),mt=s("resultMessage"),ft=s("resultSeverity"),kt=s("sourceShape"),bt=s("value"),ht=s("sourceConstraintComponent"),St=s("MinCountConstraintComponent"),_t=s("MaxCountConstraintComponent"),Pt=s("DatatypeConstraintComponent"),Kt=s("ClassConstraintComponent"),Et=s("InConstraintComponent"),Ct=s("PatternConstraintComponent"),At=s("MinLengthConstraintComponent"),xt=s("MaxLengthConstraintComponent"),Rt=s("MinInclusiveConstraintComponent"),Ot=s("MaxInclusiveConstraintComponent"),Ut=s("NodeKindConstraintComponent"),Nt=s("ClosedConstraintComponent");var l="kanonak.org",p="core-rdf",f="core-owl",Z="core-kanonak",M=new Map([["type",p],["subClassOf",p],["subPropertyOf",p],["domain",p],["range",p],["label",p],["comment",p],["seeAlso",p],["isDefinedBy",p],["member",p],["Resource",p],["Class",p],["Property",p],["Datatype",p],["Literal",p],["List",p],["ObjectProperty",f],["DatatypeProperty",f],["AnnotationProperty",f],["Thing",f],["Nothing",f],["Package",Z]]),pe=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function $t(n){return M.has(n)}function Tt(n){let e=M.get(n);return e?{publisher:l,package_:e}:void 0}function L(n,e,t){if(!n||!n.name)return;let r=M.get(n.name);if(!r)return;let o=()=>{n.publisher=l,n.package_=r,t&&(n.version=t.get(r))};if(pe.has(n.name)){let a=n.publisher===l&&n.package_===r;n.publisher=l,n.package_=r,!a&&t&&(n.version=t.get(r));return}n.publisher===l&&n.package_===r||n.publisher&&n.publisher.length>0&&(!e||e(n))||o()}var Q=class{type=y(l,p,"type");subClassOf=y(l,p,"subClassOf");subPropertyOf=y(l,p,"subPropertyOf");domain=y(l,p,"domain");range=y(l,p,"range");label=y(l,p,"label");comment=y(l,p,"comment");resource=y(l,p,"Resource");class_=y(l,p,"Class");datatype=y(l,p,"Datatype");literal=y(l,p,"Literal");equivalentClass=y(l,f,"equivalentClass");equivalentProperty=y(l,f,"equivalentProperty");inverseOf=y(l,f,"inverseOf");sameAs=y(l,f,"sameAs");transitiveProperty=y(l,f,"TransitiveProperty");symmetricProperty=y(l,f,"SymmetricProperty");objectProperty=y(l,f,"ObjectProperty");datatypeProperty=y(l,f,"DatatypeProperty");annotationProperty=y(l,f,"AnnotationProperty");package_=y(l,Z,"Package");shape=w(N);nodeShape=w(H);propertyShape=w(I)};function w(n){return y(n.publisher,n.package_,n.name)}var ce=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function b(n){let e=n;if(e.entity&&typeof e.entity=="object"){let t=e.entity.type;if(typeof t=="string"){let o={publisher:"",package_:"",name:t.includes(".")?t.substring(t.lastIndexOf(".")+1):t};return L(o),{publisher:o.publisher,package_:o.package_,name:o.name}}}if(e.statement&&Array.isArray(e.statement)){for(let t of e.statement)if(t.predicate?.subject?.name==="type"&&t.object?.subject){let r=t.object.subject,o={publisher:r.publisher??"",package_:r.package_??"",name:r.name};return L(o),{publisher:o.publisher,package_:o.package_,name:o.name}}}return null}var le=[N,H,I];function S(n,e){return ce.has(`${n}/${e}`)}var ue=new Set(["Property","ObjectProperty","DatatypeProperty","AnnotationProperty"]);function V(n){if(S(n.publisher,n.package_))return ue.has(n.name)?n.name:void 0}var ee=class n{static getTypeUri(e){return b(e)}static isCoreOntologyType(e){return S(e.publisher,e.package_)}static isClassType(e){let t=b(e);return t?S(t.publisher,t.package_)&&t.name==="Class":!1}static isDatatypeType(e){let t=b(e);return t?S(t.publisher,t.package_)&&t.name==="Datatype":!1}static isDatatypePropertyType(e){let t=b(e);return t?S(t.publisher,t.package_)&&t.name==="DatatypeProperty":!1}static isObjectPropertyType(e){let t=b(e);return t?S(t.publisher,t.package_)&&t.name==="ObjectProperty":!1}static isAnnotationPropertyType(e){let t=b(e);return t?S(t.publisher,t.package_)&&t.name==="AnnotationProperty":!1}static isGenericPropertyType(e){let t=b(e);return t?S(t.publisher,t.package_)&&t.name==="Property":!1}static isAnyPropertyType(e){let t=b(e);return!t||!S(t.publisher,t.package_)?!1:t.name==="Property"||t.name==="DatatypeProperty"||t.name==="ObjectProperty"||t.name==="AnnotationProperty"}static isShapeType(e){let t=b(e);return t?le.some(r=>X(t,r)):!1}static isSchemaDefinitionType(e){if(n.isShapeType(e))return!0;let t=b(e);return!t||!S(t.publisher,t.package_)?!1:t.name==="Class"||t.name==="Property"||t.name==="DatatypeProperty"||t.name==="ObjectProperty"||t.name==="AnnotationProperty"||t.name==="Datatype"}static isInstanceOfKnownClass(e,t){if(n.isSchemaDefinitionType(e))return!1;let r=b(e);return r?t.has(r.name):!1}};var x="kanonak.org",R="core-rdf",ye={publisher:x,package_:R,name:"domain"},de={publisher:x,package_:R,name:"range"},ge={publisher:x,package_:R,name:"subClassOf"},me={publisher:x,package_:R,name:"type"},fe={publisher:x,package_:R,name:"label"},ke={publisher:x,package_:R,name:"comment"},be=new P(x,R,"Resource");function he(n){try{let e=J(`${n.namespace}/${n.name}`);return e.kind==="resource"?e.uri:void 0}catch{return}}function F(n,e){let t=j(n,e);if(t)return[t];let r=[];for(let o of q(n,e))o instanceof G&&r.push(o.subject);return r}function ne(n,e){let t=[],r=new Set,o="version"in e?e.version:void 0,a=[new P(e.publisher,e.package_,e.name,o??void 0)];for(;a.length>0;){let i=a.shift(),u=h(i);if(r.has(u))continue;r.add(u),t.push(i);let c=Se(n,i);c&&a.push(...F(c,ge))}return t}function Se(n,e){return e.version&&typeof e.version.major=="number"?Y(n,e)??T(n,e)[0]:T(n,e)[0]}function D(n,e){let t;for(let r of Ee(e)){let o=_e(n,r);if(o){if(o!=="Property")return o;t??=o}}return t}function _e(n,e){let t=V(e);if(t)return t;let r=te.get(n);r||(r=new Map,te.set(n,r));let o=e.version,a=o&&typeof o.major=="number"?`${h(e)}@${o.major}.${o.minor}.${o.patch}`:h(e),i=r.get(a);if(i!==void 0)return i??void 0;let u;for(let c of ne(n,e)){let g=V(c);if(g){if(g!=="Property"){u=g;break}u??="Property"}}return r.set(a,u??null),u}var te=new WeakMap;function qt(n,e){return D(n,e)!==void 0}function Wt(n,e){return D(n,e)==="ObjectProperty"}function zt(n,e){return D(n,e)==="DatatypeProperty"}function Pe(n,e){let t=new Set([h(be)]);for(let r of ne(n,e))t.add(h(r));return t}function Ke(n,e){let t=Pe(n,e),r=[],o=new Set;for(let a of n){if(!(a instanceof B))continue;let i=D(n,a);if(!i)continue;let u=F(a,ye);if(!u.some(m=>t.has(h(m))))continue;let c=he(a);if(!c)continue;let g=h(c);o.has(g)||(o.add(g),r.push({uri:c,label:v(a,fe),comment:v(a,ke),kind:i==="ObjectProperty"?"object":i==="DatatypeProperty"?"datatype":"other",range:j(a,de),domains:u}))}return r}function Jt(n,e,t){let r=Ke(n,e).find(o=>h(o.uri)===h(t));return r?{ok:!0,descriptor:r}:{ok:!1,message:`Property ${t.publisher}/${t.package_}/${t.name} is not in scope for ${e.publisher}/${e.package_}/${e.name}.`}}function Ee(n){return F(n,me)}export{W as a,z as b,J as c,Oe as d,Ne as e,y as f,He as g,ae as h,Ie as i,se as j,ie as k,N as l,H as m,I as n,$e as o,Te as p,ve as q,je as r,we as s,Me as t,Le as u,Ve as v,Fe as w,Be as x,Ge as y,Xe as z,Ye as A,qe as B,We as C,ze as D,Je as E,Qe as F,Ze as G,et as H,tt as I,nt as J,rt as K,ot as L,at as M,st as N,it as O,pt as P,St as Q,_t as R,Pt as S,Kt as T,Et as U,Ct as V,At as W,xt as X,Rt as Y,Ot as Z,Ut as _,Nt as $,$t as aa,Tt as ba,L as ca,Q as da,V as ea,ee as fa,he as ga,ne as ha,D as ia,qt as ja,Wt as ka,zt as la,Ke as ma,Jt as na,Ee as oa};
@@ -0,0 +1,2 @@
1
+ import{e as F}from"./chunk-P5VQEDBS.js";import{J as me,K as he}from"./chunk-4C7ZMXQT.js";import{a as te,b as $,c as le,i as z,m as D}from"./chunk-M7LXZN47.js";import{ba as ue,fa as O,ga as x,ha as ge,ia as B,ma as ye}from"./chunk-NOPFCGB7.js";import{b as ne,c as E,d as _,f as oe,g as ae,h as se,i as ie,j as ce,k as pe,l as L,m as K,s as G,u as de,w as I,x as fe,z as V}from"./chunk-CZY6OOTM.js";import{a as re}from"./chunk-FUUTGGJS.js";import{d as ee}from"./chunk-QILEJIFU.js";var Ce=(s=>(s.Class="Class",s.DatatypeProperty="DatatypeProperty",s.ObjectProperty="ObjectProperty",s.AnnotationProperty="AnnotationProperty",s.Instance="Instance",s.Datatype="Datatype",s.Shape="Shape",s.Unknown="Unknown",s))(Ce||{}),Se=(s=>(s.InstanceOf="instanceOf",s.SubClassOf="subClassOf",s.Domain="domain",s.Range="range",s.ObjectRelationship="objectRelationship",s.SubPropertyOf="subPropertyOf",s.PropertyValue="propertyValue",s.EmbeddedLink="embeddedLink",s))(Se||{}),H=class{static async buildFromRepository(n,t){let o=await new D().parseKanonaks(n),a=await n.getAllDocumentsAsync(),c=[],i=[],s=new Set,d=new Set,f=new Map;for(let g of o){let u=g;if(u.name&&(O.isClassType(u)&&s.add(u.name),g instanceof E)){let l=B(o,g);(l==="ObjectProperty"||l==="Property")&&d.add(u.name)}}for(let g of a)for(let[u,l]of Object.entries(g.body))d.has(u)&&l?.range&&typeof l.range=="string"&&f.set(u,l.range);let p=new Map;for(let g of o){let u=g;u.name&&p.set(u.name,u)}for(let g of a){let u=g.metadata.namespace_,l=u?`${u.publisher}/${u.package_}`:"",m=u?.version?`${u.version.major}.${u.version.minor}.${u.version.patch}`:"",b=ke(g);for(let[h,y]of Object.entries(g.body)){if(!y||typeof y!="object")continue;let C=p.get(h),k="Unknown";if(C){let T=C,j=C instanceof E?B(o,C):void 0;O.isClassType(T)?k="Class":j==="ObjectProperty"?k="ObjectProperty":j==="DatatypeProperty"?k="DatatypeProperty":j==="AnnotationProperty"?k="AnnotationProperty":O.isDatatypeType(T)?k="Datatype":j==="Property"?k="ObjectProperty":O.isShapeType(T)?k="Shape":O.isInstanceOfKnownClass(T,s)&&(k="Instance")}let S=l&&m?`${l}/${h}@${m}`:h,Z={};for(let[T,j]of Object.entries(y))T!=="type"&&(typeof j!="object"||j===null)&&(Z[T]=j);c.push({id:S,label:y.label??h,type:k,namespace:l,properties:Z}),be(S,y,k,s,d,i,l,m,b,t),q(S,y,d,f,c,i,l,m,b),Le(S,C,i)}}return{nodes:c,edges:i}}static buildFromDocument(n,t){let r=[],o=[],a=n.metadata.namespace_,c=a?.version?`${a.version.major}.${a.version.minor}.${a.version.patch}`:"",i=a?`${a.publisher}/${a.package_}`:"",s=new Set,d=new Set,f=new Map,p=ke(n);for(let[l,m]of Object.entries(n.body)){let b=m?.type;b&&(Me(b,p)&&s.add(l),Ue(b,p)&&(d.add(l),m.range&&typeof m.range=="string"&&f.set(l,m.range)))}for(let[l,m]of Object.entries(n.body)){if(!m||typeof m!="object")continue;let b=m.type,h=Fe(b,l,s,p),y=i&&c?`${i}/${l}@${c}`:l,C={};for(let[k,S]of Object.entries(m))k!=="type"&&(typeof S!="object"||S===null)&&(C[k]=S);r.push({id:y,label:m.label??l,type:h,namespace:i,properties:C}),be(y,m,h,s,d,o,i,c,p,t),q(y,m,d,f,r,o,i,c,p)}let g=new Set(r.map(l=>l.id)),u=o.filter(l=>g.has(l.source)&&g.has(l.target));return{nodes:r,edges:u}}};function ke(e,n){let t=new Map;if(e.metadata?.imports)for(let[r,o]of Object.entries(e.metadata.imports))for(let a of o){let c=a.alias??a.packageName,i=a.version,s=`${i.major}.${i.minor}.${i.patch}`;t.set(c,{publisher:r,package_:a.packageName,version:s})}return t}var Oe={"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"},De=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function W(e,n){if(e.includes(".")){let t=e.indexOf("."),r=e.substring(0,t),o=e.substring(t+1),a=n.get(r);if(a)return`${a.publisher}/${a.package_}/${o}`}return null}function Me(e,n){let t=W(e,n);return t?Oe[t]==="Class":!1}function Ue(e,n){let t=W(e,n);return t?De.has(t):!1}function Fe(e,n,t,r){if(!e||e==="Package")return"Unknown";let o=W(e,r);if(o){let c=Oe[o];if(c)return c;let i=o.split("/").pop()?.split("@")[0]??"";return t.has(i)?"Instance":"Unknown"}let a=e.split(".").pop()??e;return t.has(a)?"Instance":"Unknown"}var ve=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function be(e,n,t,r,o,a,c,i,s,d){let f=n.type,p=n.subClassOf;if(p){let h=Array.isArray(p)?p:[p];for(let y of h)typeof y=="string"&&a.push({source:e,target:v(y,c,i,s),type:"subClassOf",label:"subClassOf"})}let g=n.subPropertyOf;if(g){let h=Array.isArray(g)?g:[g];for(let y of h)typeof y=="string"&&a.push({source:e,target:v(y,c,i,s),type:"subPropertyOf",label:"subPropertyOf"})}let u=n.domain,l=n.range;if(d?.includePropertyEdges){let h=[[u,"domain","domain"],[l,"range","range"]];for(let[y,C,k]of h)if(y!=null)for(let S of Array.isArray(y)?y:[y])typeof S=="string"&&a.push({source:e,target:v(S,c,i,s),type:C,label:k})}if(t==="Instance"&&f){let h=f.split(".").pop()??f;a.push({source:e,target:v(h,c,i,s),type:"instanceOf",label:"type"})}if(t==="Instance")for(let[h,y]of Object.entries(n)){if(ve.has(h)||!o.has(h))continue;let C=Array.isArray(y)?y:[y];for(let k of C)typeof k=="string"&&Ge(k)&&a.push({source:e,target:v(k,c,i,s),type:"propertyValue",label:h,propertyId:v(h,c,i,s)})}if((t==="ObjectProperty"||t==="DatatypeProperty"||u&&l)&&u&&l){let h=typeof u=="string"?u:null,y=typeof l=="string"?l:null;h&&y&&a.push({source:v(h,c,i,s),target:v(y,c,i,s),type:"objectRelationship",label:n.label??e.split("/").pop()??"",propertyId:e})}}function q(e,n,t,r,o,a,c,i,s){for(let[d,f]of Object.entries(n)){if(ve.has(d)||typeof f!="object"||f===null||Array.isArray(f))continue;let p=f,g=`${e}/${d}`,u=r.get(d),l=u?u.split(".").pop()??u:"Unknown",m={};for(let[h,y]of Object.entries(p))(typeof y!="object"||y===null)&&(m[h]=y);o.push({id:g,label:`${l} (embedded)`,type:"Instance",namespace:c,properties:m});let b=c&&i?`${c}/${d}@${i}`:d;a.push({source:e,target:g,type:"propertyValue",label:d,propertyId:t.has(d)?b:void 0}),u&&a.push({source:g,target:v(l,c,i,s),type:"instanceOf",label:"type (inferred)"}),q(g,p,t,r,o,a,c,i,s)}}function Le(e,n,t){let r=n?.statement;if(Array.isArray(r))for(let o of r){if(!(o instanceof le))continue;let a=o.predicate?.subject?.name??"";for(let c of o.links){let i=c.target?.subject;if(!i)continue;let s=i.version,d=s&&typeof s.major=="number"?`@${s.major}.${s.minor}.${s.patch}`:"";t.push({source:e,target:`${i.publisher}/${i.package_}/${i.name}${d}`,type:"embeddedLink",label:a})}}}function Ge(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 v(e,n,t,r){if(e.includes("@")&&e.includes("/"))return e;if(e.includes(".")){let o=e.indexOf("."),a=e.substring(0,o),c=e.substring(o+1);if(r){let i=r.get(a);if(i)return`${i.publisher}/${i.package_}/${c}@${i.version}`}return n&&t?`${n}/${c}@${t}`:c}return n&&t?`${n}/${e}@${t}`:e}import{canonicalForm as Ve,canonicalHash as Be}from"@kanonak-protocol/canonical";function X(e){return typeof e=="object"&&e!==null&&Array.isArray(e.subjects)}import{CANONICAL_FORM_VERSION as en}from"@kanonak-protocol/canonical";function ze(e){return Ve(X(e)?e:Pe(e))}function He(e){return Be(X(e)?e:Pe(e))}function Pe(e){let n=[];for(let t of e)t instanceof E&&n.push({uri:Ze(t),statements:Y(t.statement)});return{subjects:n}}function Y(e){let n=[];for(let t of e){let r=Qe(t);if(!r)continue;if(t instanceof L&&qe(t.predicate.subject)){n.push(...Xe(t,r));continue}let o=Ye(t);o&&n.push({predicate:r,value:o})}return n}function qe(e){let n=ue("type");return n!==void 0&&e.name==="type"&&e.publisher===n.publisher&&e.package_===n.package_}var we=new TextEncoder;function We(e,n){let t=we.encode(e),r=we.encode(n),o=Math.min(t.length,r.length);for(let a=0;a<o;a++)if(t[a]!==r[a])return t[a]-r[a];return t.length-r.length}function Xe(e,n){let t=[];for(let r of e.object){if(!(r instanceof _))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(We);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 Ye(e){if(e instanceof oe&&e.carrier)return{lit:e.lexical??String(e.object),datatype:Te(e.carrier)};if(e instanceof ae)return{raw:e.object};if(e instanceof se)return{raw:e.lexical??String(e.object)};if(e instanceof ie)return{raw:e.lexical??String(e.object)};if(e instanceof ce)return{ref:J(e.object)};if(e instanceof pe)return je(e.object);if(e instanceof L)return{list:e.object.map(Je)}}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 Je(e){if(e instanceof _)return{ref:J(e)};if(e instanceof te)return je(e);if(e instanceof $){if(e.carrier)return{lit:e.lexical??String(e.value),datatype:Te(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 ne)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 Te(e){return e===z.LangString?"kanonak.org/core-rdf/langString":`kanonak.org/core-xsd/${e}`}function Qe(e){let n=e.predicate;if(n)return Ee(n.subject)}function Ze(e){let n=e.namespace??"",t=e.name??"";return`${n}/${t}`}function J(e){return Ee(e.subject)}function Ee(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}`}function A(e){let n=e.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!n)throw new Error("Publisher host cannot be empty");return n}var nn="key_thumbprint",N=class{cache=new Map;prCache=new Map;async discoverProtectedResource(n){let t=A(n);if(this.prCache.has(t))return this.prCache.get(t);let r=`https://${t}/.well-known/oauth-protected-resource`,o=await tn(r),a=o&&Array.isArray(o.authorization_servers)?o.authorization_servers.filter(i=>typeof i=="string"):[],c=a.length>0?a:null;return this.prCache.set(t,c),c}async discover(n){let t=A(n);if(this.cache.has(t))return this.cache.get(t);let r=`https://${t}/.well-known/oauth-authorization-server`,o=await this.tryEndpoint(r);if(!o){let a=`https://${t}/.well-known/openid-configuration`;o=await this.tryEndpoint(a)}return this.cache.set(t,o),o}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(o){let a=o instanceof Error?o.message:String(o);return a.includes("ENOTFOUND")||a.includes("ECONNREFUSED")?(console.error(` OAuth discovery: ${n} \u2014 host unreachable (${a})`),console.error(" If the server is behind a VPN, ensure you are connected.")):a.includes("CERT")||a.includes("SSL")||a.includes("TLS")?(console.error(` OAuth discovery: ${n} \u2014 TLS error (${a})`),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: ${a}`),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:w(r.issuer),authorizationEndpoint:w(r.authorization_endpoint),tokenEndpoint:w(r.token_endpoint),registrationEndpoint:w(r.registration_endpoint),revocationEndpoint:w(r.revocation_endpoint),scopesSupported:P(r.scopes_supported),responseTypesSupported:P(r.response_types_supported),grantTypesSupported:P(r.grant_types_supported),codeChallengeMethodsSupported:P(r.code_challenge_methods_supported),tokenEndpointAuthMethodsSupported:P(r.token_endpoint_auth_methods_supported),dpopSigningAlgValuesSupported:P(r.dpop_signing_alg_values_supported),enrollmentEndpoint:w(r.enrollment_endpoint),enrollmentIssuanceProtocols:P(r.enrollment_issuance_protocols),enrollmentKeyTypes:P(r.enrollment_key_types),enrollmentScopesSupported:P(r.enrollment_scopes_supported),enrollmentConsentBindingParam:w(r.enrollment_consent_binding_param),sessionEndpoint:w(r.session_endpoint),sessionEndpointAuthMethod:w(r.session_endpoint_auth_method)}}};async function tn(e){try{let n=await fetch(e);return n.ok?await n.json():null}catch{return null}}function w(e){return typeof e=="string"?e:null}function P(e){return Array.isArray(e)?e.filter(n=>typeof n=="string"):null}function Re(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 o=n.match(/acr_values\s*=\s*"([^"]*)"/i);o&&(r.acrValues=o[1])}return r}function rn(e){try{return new URL(e).host}catch{return null}}function on(e,n={}){let t=n.discovery??new N,r=new Map,o=new Map,a=async s=>{let d=r.get(s);if(d!==void 0)return d;let f=null,p=await t.discoverProtectedResource(s).catch(()=>null);return p&&p.length>0&&(f=rn(p[0])),r.set(s,f),f},c=async(s,d)=>{if(!e)return null;if(!(d.forceRefresh||d.challenge)&&o.has(s))return o.get(s);let p=await e.resolve(s,d).catch(()=>null);return o.set(s,p),p},i=async(s,d,f,p)=>{let g=await a(d);if(!g)return{res:await F(s,{method:f,redirect:"manual"}),authed:!1};let u=await c(g,{method:f,url:s,...p}),l=u?.headers??{};return{res:await F(s,{method:f,redirect:"manual",headers:l}),authed:!!u}};return async(s,d,f="GET")=>{let p=await i(s,d,f,{});if((p.res.status===401||p.res.status===403)&&p.authed){let g=Re(p.res),u={forceRefresh:g===void 0};return g&&(u.challenge=g),(await i(s,d,f,u)).res}return p.res}}var _e="KANONAK_TOKEN";function an(){return typeof process<"u"&&process.env?process.env:{}}function sn(e){return`${_e}_${e.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}var Q=class{tokens;env;constructor(n={}){this.tokens=n.tokens??{},this.env=n.env??an()}async resolve(n,t){let r=A(n),o=this.tokens[r]??this.env[sn(r)]??this.env[_e];return o?{headers:{Authorization:`Bearer ${o}`}}:null}};var R="kanonak.org",U="core-rdf",Ie="core-xsd",Ae={publisher:R,package_:U,name:"subClassOf"},Ne={publisher:R,package_:U,name:"label"},$e={publisher:R,package_:U,name:"comment"},Ke={publisher:R,package_:"core-owl",name:"oneOf"},xe=e=>e;function cn(e){let n=fe(e,Ae);if(n)return[n];let t=[];for(let r of V(e,Ae))r instanceof _&&t.push(r.subject);return t}function pn(e,n,t){if(n.publisher===R&&n.package_===U&&n.name==="Literal")return{kind:"datatype",uri:n};let o=G(e,n);if(o){let a=xe(o);if(O.isDatatypeType(a))return{kind:"datatype",uri:n};if(O.isClassType(a))return{kind:"class",uri:x(o)??n,localName:o.name}}return n.publisher===R&&n.package_===Ie?{kind:"datatype",uri:n}:t==="datatype"?{kind:"datatype",uri:n}:{kind:"class",uri:n,localName:n.name}}function ln(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=pn(e,n.range,n.kind),o=n.kind==="object"?"object":n.kind==="datatype"?"datatype":r.kind==="class"?"object":"datatype";return{uri:n.uri,localName:n.uri.name,kind:o,range:r,...n.label!==void 0?{label:n.label}:{},...n.comment!==void 0?{comment:n.comment}:{},...t??{}}}var M=e=>new re(R,Ie,e);function un(e){return typeof e=="boolean"?M("boolean"):typeof e=="number"?Number.isInteger(e)?M("integer"):M("decimal"):M("string")}function dn(e,n){let t=[];for(let r of V(n,Ke))if(r instanceof _){let o=G(e,r.subject),a=(o?x(o):void 0)??r.subject,c=o?I(o,Ne):void 0,i=o?I(o,$e):void 0;t.push({kind:"individual",uri:a,localName:a.name,...c!==void 0?{label:c}:{},...i!==void 0?{comment:i}:{}})}else r instanceof $&&t.push({kind:"literal",value:r.value,datatype:un(r.value)});return t}function fn(e,n,t,r){let o=ge(e,n),a=K(n);return ye(e,n).filter(i=>t?!0:i.domains.some(s=>K(s)===a)).map(i=>ln(e,i,he(r,o,i.uri)))}async function gn(e,n,t){let r=e.metadata?.namespace_;if(!r)throw new Error("buildOntologyModel: document has no namespace (publisher/package/version).");let o=t?.includeInherited??!1,a=await new D().parseKanonaks(n),c=me(a),i=[],s=[],d=new Set;for(let f of a){if(!(f instanceof E)||!O.isClassType(xe(f)))continue;let p=x(f);if(!p||p.publisher!==r.publisher||p.package_!==r.package_||p.version&&r.version&&!ee(p.version,r.version))continue;let g=K(p);if(d.has(g))continue;d.add(g);let u=cn(f).map(b=>({uri:b,localName:b.name})),l=I(f,Ne),m=I(f,$e);i.push({uri:p,localName:p.name,superClasses:u,properties:fn(a,p,o,c),...l!==void 0?{label:l}:{},...m!==void 0?{comment:m}:{}}),de(f,Ke)&&s.push({uri:p,localName:p.name,members:dn(a,f),...l!==void 0?{label:l}:{},...m!==void 0?{comment:m}:{}})}return{classes:i,enums:s}}export{Ce as a,Se as b,H as c,ze as d,He as e,en as f,A as g,nn as h,N as i,Re as j,on as k,Q as l,gn as m};
@@ -1 +1 @@
1
- import{a as D}from"./chunk-YU2VGLOT.js";import{c as j,d as m,g as R,j as p,k as K,l as k}from"./chunk-H6UAD2LP.js";import{c as b,g as u}from"./chunk-QILEJIFU.js";function F(a,e,n,t){let i=g(a);if(i.length>0){let s=v(i,e,n);return s?{transformation:s.transformation,source:"instance"}:void 0}let r=new Set,o=O(a);for(;o.length>0;){let s=o.shift(),f=_(s.subject);if(r.has(f))continue;r.add(f);let l=S(t,s.subject);if(l.length===0)continue;let U=l.flatMap(g),h=v(U,e,n);if(h)return{transformation:h.transformation,source:{publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name}};for(let T of l)for(let P of $(T))o.push(P)}let c={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"};if(!r.has(_(c))){let s=S(t,c).flatMap(g),f=v(s,e,n);if(f)return{transformation:f.transformation,source:c}}}function g(a){let e=[];for(let n of a.statement)if(n instanceof k&&d(n,"kanonak.org","derivation","derivations"))for(let t of n.object??[]){if(!(t instanceof D))continue;let i=x(t);i&&e.push(i)}return e}function v(a,e,n){let t=a.filter(o=>E(o.format,e)&&E(o.variant,n));if(t.length<=1)return t[0];let i=t[0].transformation,r=t[0];for(let o of t){let c=o.transformation;if(c.publisher!==i.publisher||c.package_!==i.package_||c.name!==i.name)continue;let s=u(r.transformation.version),f=u(c.version);s&&f&&b(f,s)>0&&(r=o)}return r}function x(a){let e,n,t;for(let i of a.statement)i instanceof p?d(i,"kanonak.org","derivation","format")?e=y(i):d(i,"kanonak.org","derivation","variant")&&(n=y(i)):i instanceof K&&d(i,"kanonak.org","derivation","transformation")&&(t=C(i.object));if(!(!e||!t))return n||(n={publisher:"kanonak.org",package_:"derivation",name:"default"}),{format:e,variant:n,transformation:t}}function C(a){let e,n,t,i;for(let r of a.statement){if(!(r instanceof R))continue;let o=r.predicate?.subject?.name;o==="publisher"?e=r.object:o==="package"?n=r.object:o==="version"?t=r.object:o==="name"&&(i=r.object)}if(!(!e||!n||!t||!i))return{publisher:e,package_:n,version:t,name:i}}function O(a){let e=[];for(let n of a.statement)n instanceof p&&n.predicate?.subject?.name==="type"&&n.object instanceof m&&e.push(n.object);return e}function $(a){let e=[];for(let n of a.statement)if(n instanceof p){if(n.predicate?.subject?.name!=="subClassOf")continue;n.object instanceof m&&e.push(n.object)}else if(n instanceof k){if(n.predicate?.subject?.name!=="subClassOf")continue;for(let t of n.object??[])t instanceof m&&e.push(t)}return e}function S(a,e){let n=[];for(let t of a){if(!(t instanceof j)||t.name!==e.name)continue;(t.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(t)}return n.sort((t,i)=>{let r=u((t.namespace||"").split("@")[1]??""),o=u((i.namespace||"").split("@")[1]??"");return!r||!o?0:b(o,r)}),n}function d(a,e,n,t){let i=a.predicate?.subject;return i?i.publisher===e&&i.package_===n&&i.name===t:!1}function y(a){let e=a.object.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}function E(a,e){return a.publisher===e.publisher&&a.package_===e.package_&&a.name===e.name}function _(a){return`${a.publisher}/${a.package_}/${a.name}`}export{F as a};
1
+ import{a as D}from"./chunk-M7LXZN47.js";import{c as j,d as m,g as R,j as p,k as K,l as k}from"./chunk-CZY6OOTM.js";import{c as b,g as u}from"./chunk-QILEJIFU.js";function F(a,e,n,t){let i=g(a);if(i.length>0){let s=v(i,e,n);return s?{transformation:s.transformation,source:"instance"}:void 0}let r=new Set,o=O(a);for(;o.length>0;){let s=o.shift(),f=_(s.subject);if(r.has(f))continue;r.add(f);let l=S(t,s.subject);if(l.length===0)continue;let U=l.flatMap(g),h=v(U,e,n);if(h)return{transformation:h.transformation,source:{publisher:s.subject.publisher,package_:s.subject.package_,name:s.subject.name}};for(let T of l)for(let P of $(T))o.push(P)}let c={publisher:"kanonak.org",package_:"core-rdf",name:"Resource"};if(!r.has(_(c))){let s=S(t,c).flatMap(g),f=v(s,e,n);if(f)return{transformation:f.transformation,source:c}}}function g(a){let e=[];for(let n of a.statement)if(n instanceof k&&d(n,"kanonak.org","derivation","derivations"))for(let t of n.object??[]){if(!(t instanceof D))continue;let i=x(t);i&&e.push(i)}return e}function v(a,e,n){let t=a.filter(o=>E(o.format,e)&&E(o.variant,n));if(t.length<=1)return t[0];let i=t[0].transformation,r=t[0];for(let o of t){let c=o.transformation;if(c.publisher!==i.publisher||c.package_!==i.package_||c.name!==i.name)continue;let s=u(r.transformation.version),f=u(c.version);s&&f&&b(f,s)>0&&(r=o)}return r}function x(a){let e,n,t;for(let i of a.statement)i instanceof p?d(i,"kanonak.org","derivation","format")?e=y(i):d(i,"kanonak.org","derivation","variant")&&(n=y(i)):i instanceof K&&d(i,"kanonak.org","derivation","transformation")&&(t=C(i.object));if(!(!e||!t))return n||(n={publisher:"kanonak.org",package_:"derivation",name:"default"}),{format:e,variant:n,transformation:t}}function C(a){let e,n,t,i;for(let r of a.statement){if(!(r instanceof R))continue;let o=r.predicate?.subject?.name;o==="publisher"?e=r.object:o==="package"?n=r.object:o==="version"?t=r.object:o==="name"&&(i=r.object)}if(!(!e||!n||!t||!i))return{publisher:e,package_:n,version:t,name:i}}function O(a){let e=[];for(let n of a.statement)n instanceof p&&n.predicate?.subject?.name==="type"&&n.object instanceof m&&e.push(n.object);return e}function $(a){let e=[];for(let n of a.statement)if(n instanceof p){if(n.predicate?.subject?.name!=="subClassOf")continue;n.object instanceof m&&e.push(n.object)}else if(n instanceof k){if(n.predicate?.subject?.name!=="subClassOf")continue;for(let t of n.object??[])t instanceof m&&e.push(t)}return e}function S(a,e){let n=[];for(let t of a){if(!(t instanceof j)||t.name!==e.name)continue;(t.namespace||"").startsWith(`${e.publisher}/${e.package_}@`)&&n.push(t)}return n.sort((t,i)=>{let r=u((t.namespace||"").split("@")[1]??""),o=u((i.namespace||"").split("@")[1]??"");return!r||!o?0:b(o,r)}),n}function d(a,e,n,t){let i=a.predicate?.subject;return i?i.publisher===e&&i.package_===n&&i.name===t:!1}function y(a){let e=a.object.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}function E(a,e){return a.publisher===e.publisher&&a.package_===e.package_&&a.name===e.name}function _(a){return`${a.publisher}/${a.package_}/${a.name}`}export{F as a};