@kanonak-protocol/sdk 5.36.0 → 5.38.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 (64) hide show
  1. package/dist/browser.js +1 -1
  2. package/dist/chunk-22DSABP6.js +1 -0
  3. package/dist/chunk-7JBKOJB4.js +1 -0
  4. package/dist/{chunk-4QXD6HKI.js → chunk-A3HRXFVX.js} +1 -1
  5. package/dist/{chunk-VENZTHCC.js → chunk-ADSDFJUO.js} +1 -1
  6. package/dist/chunk-D2X6J77P.js +1 -0
  7. package/dist/chunk-D4QGPMRW.js +1 -0
  8. package/dist/chunk-DONOB6RA.js +1 -0
  9. package/dist/{chunk-IN5VVPYH.js → chunk-ED35OFGD.js} +1 -1
  10. package/dist/chunk-GKIX3OD6.js +3 -0
  11. package/dist/chunk-HKX27KBZ.js +1 -0
  12. package/dist/{chunk-H7SX57L7.js → chunk-LBVHWFFL.js} +1 -1
  13. package/dist/chunk-NUTHBBDZ.js +1 -0
  14. package/dist/{chunk-6TEJENCD.js → chunk-O6SOU5Y2.js} +10 -10
  15. package/dist/{chunk-BZ3YTI3C.js → chunk-OOYGILH4.js} +2 -2
  16. package/dist/chunk-TYVZXABI.js +155 -0
  17. package/dist/chunk-VORVR5BZ.js +1 -0
  18. package/dist/index.d.ts +7 -7
  19. package/dist/index.js +1 -1
  20. package/dist/kanonaks/DefinedKanonak.d.ts +11 -0
  21. package/dist/kanonaks/LiteralKanonak.d.ts +2 -0
  22. package/dist/kanonaks/ReferenceKanonak.d.ts +2 -0
  23. package/dist/lock/LockFile.d.ts +6 -0
  24. package/dist/lock/index.d.ts +1 -1
  25. package/dist/look/displayValue.d.ts +3 -0
  26. package/dist/look/index.d.ts +1 -1
  27. package/dist/parsing/findMarkdownLinkAt.d.ts +8 -0
  28. package/dist/parsing/index.d.ts +2 -0
  29. package/dist/parsing/index.js +1 -1
  30. package/dist/parsing/sourceSymbols.d.ts +54 -0
  31. package/dist/producer/index.js +1 -1
  32. package/dist/reasoning/KanonakVocabulary.d.ts +21 -0
  33. package/dist/reasoning/index.d.ts +1 -1
  34. package/dist/reasoning/index.js +1 -1
  35. package/dist/repositories/LockAwareRepository.d.ts +1 -1
  36. package/dist/repositories/browser.js +1 -1
  37. package/dist/repositories/index.js +1 -1
  38. package/dist/resolution/ResourceTypeClassifier.d.ts +8 -1
  39. package/dist/resolution/index.d.ts +1 -0
  40. package/dist/resolution/index.js +1 -1
  41. package/dist/resolution/referenceSpelling.d.ts +14 -0
  42. package/dist/search/index.js +1 -1
  43. package/dist/server/closure.d.ts +8 -0
  44. package/dist/server/index.d.ts +1 -1
  45. package/dist/server/index.js +16 -16
  46. package/dist/server/requestRouter.d.ts +16 -0
  47. package/dist/statements/Statement.d.ts +9 -0
  48. package/dist/transformations/index.js +2 -2
  49. package/dist/transformations/v3/CompiledTransformationV3.d.ts +28 -27
  50. package/dist/transformations/v3/TransformationUriConstantsV3.d.ts +27 -0
  51. package/dist/uri-helpers/index.js +1 -1
  52. package/dist/validation/KanonakObjectValidator.d.ts +7 -1
  53. package/dist/validation/index.js +1 -1
  54. package/package.json +3 -3
  55. package/dist/chunk-7TU55KLO.js +0 -1
  56. package/dist/chunk-HF5FJBS2.js +0 -1
  57. package/dist/chunk-IS3AQKB4.js +0 -1
  58. package/dist/chunk-KIBR3HAT.js +0 -1
  59. package/dist/chunk-Q2FG7DME.js +0 -1
  60. package/dist/chunk-ROKDCCJN.js +0 -155
  61. package/dist/chunk-V3DH67P3.js +0 -1
  62. package/dist/chunk-XK24CN3C.js +0 -1
  63. package/dist/chunk-XNEWQEB6.js +0 -1
  64. package/dist/chunk-YBHIELES.js +0 -2
package/dist/browser.js CHANGED
@@ -1 +1 @@
1
- import{a as $,b as ee,c as oe,d as Ue,f as Be,g as we,h as Ge,i as qe}from"./chunk-H7SX57L7.js";import{a as ze}from"./chunk-IN5VVPYH.js";import{a as ve,b as He,c as Te,d as Le,e as Me,f as _e,g as Fe,h as We,i as Ye,j as Xe,k as Je,l as Qe}from"./chunk-VENZTHCC.js";import{a as c,b as m,c as u,e as d,h as f,i as y,j as R,k,l as x,m as P,n as g}from"./chunk-BZ3YTI3C.js";import{a as re,b as te,c as ne}from"./chunk-YBHIELES.js";import{a as ae}from"./chunk-XK24CN3C.js";import"./chunk-SC5M74NM.js";import{A as be,B as Ae,C as Oe,M as Ne,a as ie,b as se,c as pe,d as le,g as ce,h as me,i as ue,j as de,l as fe,m as ye,n as Re,o as ke,p as xe,q as Pe,r as ge,s as Se,t as Ce,u as Ee,v as Ie,w as Ke,x as he,y as je,z as De}from"./chunk-6TEJENCD.js";import"./chunk-KIBR3HAT.js";import{k as Ve}from"./chunk-ROKDCCJN.js";import"./chunk-QHABFCRC.js";import{a as p}from"./chunk-6VIUXP4N.js";import{a as X,f as J,g as Q,j as Z}from"./chunk-Q2FG7DME.js";import{a as l}from"./chunk-HF5FJBS2.js";import"./chunk-PEJALHXK.js";import{a as T,b as L,h as F,i as U,ia as q,j as B,k as w,ka as z,l as G}from"./chunk-7TU55KLO.js";import{I as W,J as Y,a as S,b as C,c as E,d as I,e as h,g as j,h as D,i as b,j as A,k as O,l as V,m as N,n as v,o as H,u as M,v as _}from"./chunk-XNEWQEB6.js";import{a as K}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{c as e,d as o,e as r,f as t,g as n,h as a,i,k as s}from"./chunk-QILEJIFU.js";export{Ie as AmbiguousReferenceRule,O as BooleanStatement,Te as CANONICAL_FORM_VERSION,J as Carrier,Ae as ClassDefinitionRule,ke as ClassHierarchyCycleRule,C as DefinedKanonak,ee as EdgeType,I as EmbeddedKanonak,fe as EmbeddedKanonakTypeRule,N as EmbeddedStatement,Je as EntitlementDeniedError,Qe as EntitlementProducer,oe as GraphBuilder,g as HttpKanonakDocumentRepository,y as INTEGRITY_PREFIX,_e as ImportBook,ye as ImportExistenceRule,p as InMemoryKanonakDocumentRepository,c as KANONAK_USER_AGENT,S as Kanonak,te as KanonakDocumentPositions,Z as KanonakObjectParser,Ne as KanonakObjectValidator,l as KanonakParser,K as KanonakUri,ae as KanonakUriBuilder,q as KanonakVocabulary,v as ListStatement,Oe as MarkdownLinkRule,H as MarkdownStatement,Ce as NamespaceImportCycleRule,ce as NamespacePrefixRule,$ as NodeType,A as NumberStatement,Be as OAuthDiscovery,he as ObjectPropertyValueValidationRule,pe as OntologyValidationError,ie as OntologyValidationResult,Le as PackageBuilder,We as ProducerRepository,je as PropertyDomainRule,xe as PropertyHierarchyCycleRule,De as PropertyKindRangeConsistencyRule,re as PropertyMetadata,Ke as PropertyRangeReferenceRule,Pe as PropertyRangeRequiredRule,ue as PropertyTypeSpecificityRule,f as PublisherConfigResolver,P as PublisherIndex,h as ReferenceKanonak,V as ReferenceStatement,be as ReservedNameShadowRule,me as ResourceNamingRule,T as ResourceResolver,z as ResourceTypeClassifier,U as SHACL_PACKAGE,F as SHACL_PUBLISHER,w as SH_NODE_SHAPE,G as SH_PROPERTY_SHAPE,B as SH_SHAPE,D as ScalarStatement,j as Statement,b as StringStatement,ge as SubClassOfReferenceRule,Se as SubPropertyOfReferenceRule,E as SubjectKanonak,de as SubjectKanonakTypeRequiredRule,qe as TokenCredentialProvider,L as TypeResolver,Ee as UnresolvedPredicateRule,Re as UnresolvedReferenceRule,le as ValidationContext,se as ValidationSeverity,Ye as allowAllPolicy,Ve as buildOntologyModel,ve as canonicalForm,He as canonicalHash,Q as carrierOf,e as compareVersions,x as computeIntegrityAsync,Me as contentAddressedName,Ge as createCredentialedFetch,t as createVersion,ze as findDerivation,r as formatVersion,u as getKanonakUserAgent,a as isCompatibleVersion,i as isMajorCompatible,d as kanonakFetch,Xe as noopMeter,Ue as normalizeHost,we as parseAuthChallenge,R as parseLockFile,n as parseVersionString,ne as parseWithPositions,s as pickHighestDocument,_ as referenceUris,Fe as sanitizeName,k as serializeLockFile,m as setKanonakUserAgent,Y as subjectAddress,M as typeReferenceUris,W as valuesOf,o as versionsEqual,X as walkDefinedKanonaks};
1
+ import{a as $,b as ee,c as oe,d as Ue,f as Be,g as we,h as Ge,i as qe}from"./chunk-LBVHWFFL.js";import{a as ze}from"./chunk-ED35OFGD.js";import{a as ve,b as He,c as Te,d as Le,e as Me,f as _e,g as Fe,h as We,i as Ye,j as Xe,k as Je,l as Qe}from"./chunk-ADSDFJUO.js";import{a as c,b as m,c as u,e as d,h as f,j as y,k as R,l as k,m as x,n as P,o as g}from"./chunk-OOYGILH4.js";import{a as re,b as te,c as ne}from"./chunk-GKIX3OD6.js";import{a as ae}from"./chunk-D2X6J77P.js";import"./chunk-SC5M74NM.js";import{A as be,B as Ae,C as Oe,M as Ne,a as ie,b as se,c as pe,d as le,g as ce,h as me,i as ue,j as de,l as fe,m as ye,n as Re,o as ke,p as xe,q as Pe,r as ge,s as Se,t as Ce,u as Ee,v as Ie,w as Ke,x as he,y as je,z as De}from"./chunk-O6SOU5Y2.js";import"./chunk-VORVR5BZ.js";import{m as Ve}from"./chunk-TYVZXABI.js";import"./chunk-QHABFCRC.js";import{a as p}from"./chunk-6VIUXP4N.js";import{a as X,g as J,h as Q,k as Z}from"./chunk-22DSABP6.js";import{a as l}from"./chunk-7JBKOJB4.js";import"./chunk-PEJALHXK.js";import{a as T,b as L,h as F,i as U,j as B,k as w,ka as q,l as G,ma as z}from"./chunk-NUTHBBDZ.js";import{I as W,J as Y,a as S,b as C,c as E,d as I,e as h,g as j,h as D,i as b,j as A,k as O,l as V,m as N,n as v,o as H,u as M,v as _}from"./chunk-D4QGPMRW.js";import{a as K}from"./chunk-FUUTGGJS.js";import"./chunk-F67UH4FD.js";import{c as e,d as o,e as r,f as t,g as n,h as a,i,k as s}from"./chunk-QILEJIFU.js";export{Ie as AmbiguousReferenceRule,O as BooleanStatement,Te as CANONICAL_FORM_VERSION,J as Carrier,Ae as ClassDefinitionRule,ke as ClassHierarchyCycleRule,C as DefinedKanonak,ee as EdgeType,I as EmbeddedKanonak,fe as EmbeddedKanonakTypeRule,N as EmbeddedStatement,Je as EntitlementDeniedError,Qe as EntitlementProducer,oe as GraphBuilder,g as HttpKanonakDocumentRepository,y as INTEGRITY_PREFIX,_e as ImportBook,ye as ImportExistenceRule,p as InMemoryKanonakDocumentRepository,c as KANONAK_USER_AGENT,S as Kanonak,te as KanonakDocumentPositions,Z as KanonakObjectParser,Ne as KanonakObjectValidator,l as KanonakParser,K as KanonakUri,ae as KanonakUriBuilder,q as KanonakVocabulary,v as ListStatement,Oe as MarkdownLinkRule,H as MarkdownStatement,Ce as NamespaceImportCycleRule,ce as NamespacePrefixRule,$ as NodeType,A as NumberStatement,Be as OAuthDiscovery,he as ObjectPropertyValueValidationRule,pe as OntologyValidationError,ie as OntologyValidationResult,Le as PackageBuilder,We as ProducerRepository,je as PropertyDomainRule,xe as PropertyHierarchyCycleRule,De as PropertyKindRangeConsistencyRule,re as PropertyMetadata,Ke as PropertyRangeReferenceRule,Pe as PropertyRangeRequiredRule,ue as PropertyTypeSpecificityRule,f as PublisherConfigResolver,P as PublisherIndex,h as ReferenceKanonak,V as ReferenceStatement,be as ReservedNameShadowRule,me as ResourceNamingRule,T as ResourceResolver,z as ResourceTypeClassifier,U as SHACL_PACKAGE,F as SHACL_PUBLISHER,w as SH_NODE_SHAPE,G as SH_PROPERTY_SHAPE,B as SH_SHAPE,D as ScalarStatement,j as Statement,b as StringStatement,ge as SubClassOfReferenceRule,Se as SubPropertyOfReferenceRule,E as SubjectKanonak,de as SubjectKanonakTypeRequiredRule,qe as TokenCredentialProvider,L as TypeResolver,Ee as UnresolvedPredicateRule,Re as UnresolvedReferenceRule,le as ValidationContext,se as ValidationSeverity,Ye as allowAllPolicy,Ve as buildOntologyModel,ve as canonicalForm,He as canonicalHash,Q as carrierOf,e as compareVersions,x as computeIntegrityAsync,Me as contentAddressedName,Ge as createCredentialedFetch,t as createVersion,ze as findDerivation,r as formatVersion,u as getKanonakUserAgent,a as isCompatibleVersion,i as isMajorCompatible,d as kanonakFetch,Xe as noopMeter,Ue as normalizeHost,we as parseAuthChallenge,R as parseLockFile,n as parseVersionString,ne as parseWithPositions,s as pickHighestDocument,_ as referenceUris,Fe as sanitizeName,k as serializeLockFile,m as setKanonakUserAgent,Y as subjectAddress,M as typeReferenceUris,W as valuesOf,o as versionsEqual,X as walkDefinedKanonaks};
@@ -0,0 +1 @@
1
+ import{a as X}from"./chunk-7JBKOJB4.js";import{a as H,b as J,fa as Q,ga as _,ha as Z,ja as E,pa as ne}from"./chunk-NUTHBBDZ.js";import{J as ee,K as te,c as P,d as w,e as k,f as L,g as q,i as M,j as I,k as T,l as O,m as R,n as j,o as N,r as x,s as U,z as Y}from"./chunk-D4QGPMRW.js";import{a as D}from"./chunk-FUUTGGJS.js";import{b as G}from"./chunk-F67UH4FD.js";import{k as W}from"./chunk-QILEJIFU.js";function re(p,t){for(let n of p)n instanceof P&&ae(n,ee(n),n.name,t)}function ae(p,t,n,r){let a=t.indexOf("#");r({kanonak:p,address:t,path:a<0?n:`${n}.${t.slice(a+1)}`});for(let i of ce(p))for(let{value:o,address:c}of te(p,i,t))o.item instanceof w&&ae(o.item,c,n,r)}function ce(p){let t=new Map;for(let n of p.statement){let r=n.predicate?.subject;if(!r)continue;let a=`${r.publisher}/${r.package_}/${r.name}`;t.has(a)||t.set(a,r)}return[...t.values()]}var oe="kanonak.org",pe="transformations",je=3,e=p=>({publisher:oe,package_:pe,name:p}),h=p=>({publisher:oe,package_:"math",name:p}),ve={Power:h("Power"),Modulo:h("Modulo"),Minimum:h("Minimum"),Maximum:h("Maximum"),Exp:h("Exp"),Ln:h("Ln"),Log10:h("Log10"),Sqrt:h("Sqrt"),Floor:h("Floor"),Ceil:h("Ceil"),Round:h("Round"),Sign:h("Sign"),Clip:h("Clip"),clipValue:h("clipValue"),clipLower:h("clipLower"),clipUpper:h("clipUpper")},A={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"),Matches:e("Matches"),matchSource:e("matchSource"),pattern:e("pattern"),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 K,carrierOf as me}from"@kanonak-protocol/canonical";function V(p){return me(`${p.publisher}/${p.package_}/${p.name}`)}var ue=/\[\[([^\[\]\n]+)\]\]/g,fe=/\[\[/g,ie=/```[\s\S]*?```|`[^`\n]*`/g;function le(p){let t=[];for(let n of p.matchAll(ie))t.push([n.index,n.index+n[0].length]);return t}function Me(p){if(!p||!p.includes("[["))return[];let t=le(p),n=i=>t.some(([o,c])=>i>=o&&i<c),r=new Set(C(p).map(i=>i.startOffset)),a=[];for(let i of p.matchAll(fe)){let o=i.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 C(p){if(!p||!p.includes("[["))return[];let t=[];for(let a of p.matchAll(ie))t.push([a.index,a.index+a[0].length]);let n=a=>t.some(([i,o])=>a>=i&&a<o),r=[];for(let a of p.matchAll(ue)){let i=a.index;if(n(i))continue;let o=a[1],c=o.indexOf("|"),m=(c===-1?o:o.slice(0,c)).trim();if(m.length===0)continue;let s=c===-1?"":o.slice(c+1).trim(),u={reference:m,startOffset:i,endOffset:i+a[0].length};s.length>0&&(u.displayText=s),r.push(u)}return r}import{VersionOperator as de}from"@kanonak-protocol/types/document/models/enums";var ye={..._("range"),name:"range"};function ge(p){let t=p.lastIndexOf(".");return t===-1?p:p.slice(t+1)}var se=class{constructor(t){}async parseKanonaks(t,n){let r=await t.getAllDocumentsAsync(),a=new H(t),i=new J(a);this.knownPropertyClasses.clear();let o=await this.parseAllDocumentsAsync(r,a,i,t),c=await this.mergeAndCanonicalizeAsync(o,t);return await this.learnPropertyClassesAsync(c,r,a)&&(o=await this.parseAllDocumentsAsync(r,a,i,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 s=m.metadata.namespace_?.toString();s&&a.set(s,m)}let i=[],o=new Set;re(t,({kanonak:m})=>{for(let s of m.unresolvedPredicates){let u=`${s.sourceDoc}::${s.key}`;o.has(u)||(o.add(u),i.push(s))}});let c=!1;for(let m of i){let s=a.get(m.sourceDoc);if(!s)continue;let u=await r.resolveEntityAsync(m.key,s);if(!u)continue;let l=x(u.uri);if(this.knownPropertyClasses.has(l))continue;let d=Y(t,u.uri);if(!d)continue;let f=ne(t,d);f&&(this.knownPropertyClasses.set(l,f),c=!0)}return c}async parseAllDocumentsAsync(t,n,r,a){let i=[];for(let o of t){let c=o.metadata.namespace_?.toString()??"";for(let[m,s]of Object.entries(o.body)){let u=new P,l=this.resolveCanonicalEntity(m,o,c);u.namespace=l.namespace,u.name=l.name,u.sourceKey=m,u.statement=[];let d=await this.parseStatements(s,o,n,r,a);u.statement.push(...d.statements),u.unresolvedPredicates=d.unresolved,F(u,c),i.push(u)}}return i}async mergeAndCanonicalizeAsync(t,n){let r=new Map,a=new Map,i=[];for(let s of t)if(s instanceof P){let u=`${s.namespace}/${s.name}`,l=r.get(u);if(l){let d=a.get(u);for(let f of s.statement){let g=$(f);d.has(g)||(d.add(g),l.statement.push(f))}for(let f of s.unresolvedPredicates)l.unresolvedPredicates.some(g=>g.key===f.key&&g.sourceDoc===f.sourceDoc)||l.unresolvedPredicates.push(f)}else{let d=new P;d.namespace=s.namespace,d.name=s.name,d.sourceDoc=s.sourceDoc,s.sourceKey!==void 0&&(d.sourceKey=s.sourceKey);let f=new Set;for(let g of s.statement){let S=$(g);f.has(S)||(f.add(S),d.statement.push(g))}d.unresolvedPredicates=[...s.unresolvedPredicates],a.set(u,f),r.set(u,d),i.push(d)}}else i.push(s);let o=new Set;for(let s of i)if(s instanceof P){let u=s.namespace||"",l=u.indexOf("/"),d=l>=0?u.slice(0,l):"",f=l>=0?u.slice(l+1):"",g=f.indexOf("@"),S=g>=0?f.slice(0,g):f;o.add(`${d}/${S}/${s.name}`)}let c=s=>o.has(`${s.publisher}/${s.package_}/${s.name}`),m=new Map;for(let s of Z()){let u=await n.getDocumentsByNamespaceAsync(s.publisher,s.package_);m.set(s.package_,W(u).chosen?.metadata.namespace_?.version??void 0)}for(let s of t)s instanceof P&&this.canonicalizeStatementBuiltins(s.statement,c,m);return i}canonicalizeStatementBuiltins(t,n,r){for(let a of t){let i=a.predicate?.subject;if(E(i,n,r),a instanceof O)a.object instanceof k&&E(a.object.subject,n,r);else if(a instanceof R)a.object&&this.canonicalizeStatementBuiltins(a.object.statement,n,r);else if(a instanceof j)for(let o of a.object??[])o instanceof k?E(o.subject,n,r):o instanceof w&&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("."),i=t.substring(0,a),o=t.substring(a+1);for(let[c,m]of Object.entries(n.metadata.imports))for(let s of m)if((s.alias??s.packageName)===i){let l=s.version;return{namespace:`${c}/${s.packageName}@${l.major}.${l.minor}.${l.patch}`,name:o}}return{namespace:r,name:t}}async parseStatements(t,n,r,a,i){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[s,u]of Object.entries(t))try{let l=await this.getPropertyMetadata(s,n,r,i,a);if(!l){let f=s.includes(".")?s.slice(s.lastIndexOf(".")+1):s;Q(f)||c.push({key:s,sourceDoc:m});continue}let d=await this.parsePropertyValue(s,u,l,n,r,a,i);d&&(d instanceof q&&(d.sourceKey=s),o.push(d))}catch(l){throw new Error(`Failed to parse property '${s}': ${l.message}`,{cause:l})}return{statements:o,unresolved:c}}async getPropertyMetadata(t,n,r,a,i){let o=await r.resolveEntityAsync(t,n);if(!o)return;let c=o.entity,m=c.type?.toString()??"",s=m.includes(".")?m.substring(m.lastIndexOf(".")+1):m,u=new Set(["Property","DatatypeProperty","ObjectProperty","AnnotationProperty"]),l=this.knownPropertyClasses.get(x(o.uri));if(!u.has(s)&&!l)return;let d=l??i.getPropertyTypeClassification(m),f,g=async()=>{if(f)return f;if(!(o.isImported&&o.definedInNamespace))return f=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 f=v,v},S=await this.readDefinitionSlot(c,ye,g,r),y=S==null?void 0:String(S),b;if(d==="ObjectProperty")b="ObjectProperty";else if(d==="DatatypeProperty")b="DatatypeProperty";else{let v=y&&y.includes(".")?y.substring(y.lastIndexOf(".")+1):y??"";(y?i.isKnownXsdDatatypeName(y):!1)||v==="Literal"?b="DatatypeProperty":b="ObjectProperty"}let z;return y&&(z=(await r.resolveEntityAsync(y,await g()))?.uri),{propertyUri:o.uri.toString(),propertyType:b,range:y,rangeUri:z,isImported:o.isImported,definedInNamespace:o.definedInNamespace}}async readDefinitionSlot(t,n,r,a){let i=Object.keys(t).filter(s=>ge(s)===n.name);if(i.length===0)return;let o=await r(),c=_(n.name),m=c!==void 0&&c.publisher===n.publisher&&c.package_===n.package_;for(let s of i){let u=await a.resolveEntityAsync(s,o);if(u){if(U(u.uri,n))return t[s];continue}if(!s.includes(".")&&m)return t[s]}}async parsePropertyValue(t,n,r,a,i,o,c){let m=r.propertyUri;if(n!=null){if(Array.isArray(n))return this.parseListValue(m,n,r,a,i,o,c);if(r.propertyType==="DatatypeProperty")return this.parseDatatypeValue(m,n,r,a,i,o);if(r.propertyType==="ObjectProperty")return this.parseObjectValue(m,n,r,a,i,o,c)}}async parseDatatypeValue(t,n,r,a,i,o){let c;if(typeof n=="string"){if(o.isSubstitutableDatatype(r.rangeUri))return await this.parseSubstitutableValue(t,n,a,i);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=k.parse(t),i=r.rangeUri?V(r.rangeUri):void 0;if(i===K.Boolean){let c=new T;return c.predicate=a,c.object=n==="true"||n==="1",c.carrier=i,c.lexical=n,c}if(i===K.Integer||i===K.Decimal||i===K.Double||i===K.Float){let c=new I;return c.predicate=a,c.object=Number(n),c.carrier=i,c.lexical=n,c}let o=M.parse(t,n);return i&&(o.carrier=i,o.lexical=n),o}typedListLiteral(t,n){let r=new L,a=n.rangeUri?V(n.rangeUri):void 0;return a===K.Boolean?r.value=t==="true"||t==="1":a===K.Integer||a===K.Decimal||a===K.Double||a===K.Float?r.value=Number(t):r.value=t,a&&(r.carrier=a,r.lexical=t),r}async parseSubstitutableValue(t,n,r,a){let i=new N;return i.predicate=k.parse(t),i.object=n,i.links=await this.resolveMarkdownLinks(n,r,a),i}async resolveMarkdownLinks(t,n,r){let a=[];for(let i of C(t)){let o=this.linkReference(i.reference,n);if(!o){let m=await r.resolveEntityAsync(i.reference,n);m&&(o=new k,o.subject=m.uri)}let c={reference:i.reference,startOffset:i.startOffset,endOffset:i.endOffset};i.displayText!==void 0&&(c.displayText=i.displayText),o!==void 0&&(c.target=o),a.push(c)}return a}async parseObjectValue(t,n,r,a,i,o,c){if(typeof n=="string"){if(r.rangeUri&&U(r.rangeUri,A.Expression))return this.coerceExpressionLiteral(t,n,r.rangeUri);let m=await this.resolveReference(n,a,i);if(!m)return;let s=new O;return s.predicate=k.parse(t),s.object=m,s}if(typeof n=="object"&&!Array.isArray(n)){let m=await this.parseStatements(n,a,i,o,c);if(m.statements.length>0){let l=new w;l.statement=m.statements,l.unresolvedPredicates=m.unresolved,r.rangeUri&&(l.rangeType=r.rangeUri);let d=new R;return d.predicate=k.parse(t),d.object=l,d}let s=[];for(let[l,d]of Object.entries(n))if(typeof d=="object"&&d!==null&&!Array.isArray(d)){let f=new w;f.name=l,f.sourceKey=l,r.rangeUri&&(f.rangeType=r.rangeUri);let g=await this.parseStatements(d,a,i,o,c);f.statement=g.statements,f.unresolvedPredicates=g.unresolved,s.push(f)}else if(typeof d=="string"){let f=await this.resolveReference(d,a,i);f&&(f.sourceKey=l,s.push(f))}if(s.length>0){let l=new j;return l.predicate=k.parse(t),l.object=s,l}let u=new R;return u.predicate=k.parse(t),u.object=new w,r.rangeUri&&(u.object.rangeType=r.rangeUri),u}}coerceExpressionLiteral(t,n,r){let a=new w,i=new O,o=new k;o.subject=new D("kanonak.org","core-rdf","type"),i.predicate=o;let c=new k;c.subject=new D(r.publisher,r.package_,A.StringLiteral.name,r.version),i.object=c;let m=new M,s=new k;s.subject=new D(r.publisher,r.package_,A.stringLiteral.name,r.version),m.predicate=s,m.object=n,a.statement=[i,m];let u=new R;return u.predicate=k.parse(t),u.object=a,u}async parseListValue(t,n,r,a,i,o,c){let m=[],s=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 d=0;d<n.length;d++){let f=n[d],g=y=>{y.sourceKey=d,m.push(y)},S=typeof f=="string"||typeof f=="number"||typeof f=="boolean";if(s&&S){let y=typeof f=="string"?f:String(f),b=this.typedListLiteral(y,r);o.isSubstitutableDatatype(r.rangeUri)&&(b.links=await this.resolveMarkdownLinks(y,a,i)),g(b);continue}if(u&&S){if(typeof f=="string"){let y=await i.resolveEntityAsync(f,a);if(y){let b=new k;b.subject=y.uri,g(b)}else{let b=new L;b.value=f,g(b)}}else{let y=new L;y.value=f,g(y)}continue}if(typeof f=="string"){let y=await this.resolveReference(f,a,i);y&&g(y)}else if(typeof f=="object"&&f!==null&&!Array.isArray(f)){let y=new w;r.rangeUri&&(y.rangeType=r.rangeUri);let b=await this.parseStatements(f,a,i,o,c);y.statement=b.statements,y.unresolvedPredicates=b.unresolved,g(y)}}let l=new j;return l.predicate=k.parse(t),l.object=m,l}linkReference(t,n){let r=t.indexOf(".");if(r<=0||!n.metadata?.imports)return;let a=t.substring(0,r),i=t.substring(r+1);for(let[o,c]of Object.entries(n.metadata.imports))for(let m of c){if(!G(m)||(m.alias??m.packageName)!==a)continue;let s=new k,u=m.versionOperator===de.Exact?m.version:void 0;return s.subject=new D(o,m.packageName,i,u),s}}async resolveReference(t,n,r){let a=this.linkReference(t,n);if(a)return a;let i=await r.resolveEntityAsync(t,n);if(i){let c=new k;return c.subject=i.uri,c}let o=n.metadata?.namespace_;if(o){let{KanonakUri:c}=await import("./KanonakUri-4VJGV3FN.js");if(t.includes(".")){let s=t.indexOf("."),u=t.substring(0,s),l=t.substring(s+1);if(n.metadata?.imports){for(let[d,f]of Object.entries(n.metadata.imports))for(let g of f)if((g.alias??g.packageName)===u){let y=new k;return y.subject=new c(d,g.packageName,l,g.version),y}}}let m=new k;return m.subject=new c(o.publisher,o.package_,t,o.version??void 0),m}return null}async saveKanonaks(t,n){let r=new Map;for(let a of t)a instanceof P&&a.namespace&&(r.has(a.namespace)||r.set(a.namespace,[]),r.get(a.namespace).push(a));for(let[a,i]of r){let o=await this.convertKanonaksToDocument(a,i),c=`${a.split("@")[0]}.yml`;await n.saveDocumentAsync(o,c)}}async serializeToYaml(t,n){let r=t.filter(o=>o instanceof P&&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 X().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:{}},i=new Map;for(let o of n){let c={};for(let m of o.statement){let[s,u]=this.convertStatementToProperty(m);s&&u!==null&&u!==void 0&&(c[s]=u),this.collectImportsFromStatement(m,t,i)}a.body[o.name]=c}return a}convertStatementToProperty(t){if(t instanceof M)return[t.predicate.subject.name,t.object];if(t instanceof I)return[t.predicate.subject.name,t.object];if(t instanceof T)return[t.predicate.subject.name,t.object];if(t instanceof O)return[t.predicate.subject.name,t.object.subject.name];if(t instanceof j){let n=this.convertKanonakListToValue(t.object);return[t.predicate.subject.name,n]}else if(t instanceof R){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 k?n.push(r.subject.name):r instanceof w&&n.push(this.convertEmbeddedKanonakToValue(r));return n}convertEmbeddedKanonakToValue(t){let n={};for(let r of t.statement){let[a,i]=this.convertStatementToProperty(r);a&&i!==null&&i!==void 0&&(n[a]=i)}return n}collectImportsFromStatement(t,n,r){}};function F(p,t){p.sourceDoc=t;for(let n of p.statement)if(n instanceof R)F(n.object,t);else if(n instanceof j)for(let r of n.object)r instanceof w&&F(r,t)}function $(p){let t=p.predicate?.subject;return(t?`${t.publisher}/${t.package_}/${t.name}`:"?")+"="+ke(p)}function ke(p){return p instanceof N?"m:"+String(p.object):p instanceof M?"s:"+String(p.object):p instanceof I?"n:"+String(p.object):p instanceof T?"b:"+String(p.object):p instanceof O?"r:"+B(p.object):p instanceof R?"e:"+B(p.object):p instanceof j?"l:["+(p.object??[]).map(B).join("|")+"]":"x"}function B(p){if(!p)return"";if(p instanceof k){let t=p.subject;return"R("+(t?`${t.publisher}/${t.package_}/${t.name}`:"")+")"}return p instanceof w?"E("+(p.statement??[]).map($).join(";")+")":p instanceof L?"L("+String(p.value)+")":"N"}export{re as a,oe as b,pe as c,je as d,ve as e,A as f,K as g,V as h,Me as i,C as j,se as k};
@@ -0,0 +1 @@
1
+ import{a as d}from"./chunk-F67UH4FD.js";import{a as l,b as h}from"./chunk-QILEJIFU.js";import*as c from"js-yaml";var y=new Set(["Package","EphemeralPackage"]);function f(m){return typeof m=="string"&&y.has(m)}var g=class{parse(e){let r=this.parseWithErrors(e);if(!r.isValid){let n=r.errors[0];throw new Error(`YAML parse error at line ${n.line}, column ${n.column}: ${n.message}`)}return r.document}parseWithErrors(e){let r=[],n;try{e=e.replace(/^\uFEFF/,"");let a=c.load(e,{schema:c.FAILSAFE_SCHEMA});if(!a||typeof a!="object")return n={metadata:this.createEmptyMetadata(),body:{},toString:()=>"KanonakDocument(empty)"},{document:n,errors:r,isValid:!0};let t=this.extractMetadata(a),o=this.extractBody(a,t);return n={metadata:t,body:o,toString:function(){return this.metadata.namespace_?`KanonakDocument(${this.metadata.namespace_.publisher}/${this.metadata.namespace_.package_})`:"KanonakDocument(no namespace)"}},{document:n,errors:r,isValid:!0}}catch(a){let t=a,o=t.mark?t.mark.line+1:0,i=t.mark?t.mark.column+1:0,s={message:t.message||"Unknown parse error",line:o,column:i,errorType:t.name==="YAMLException"?"SyntaxError":"Unknown",toString:()=>`${t.name==="YAMLException"?"SyntaxError":"Unknown"} at line ${o}: ${t.message||"Unknown parse error"}`};return r.push(s),{document:void 0,errors:r,isValid:!1}}}save(e){let r={};if(e.metadata.namespace_){let n=e.metadata.namespace_,a={type:"Package",publisher:n.publisher};n.version&&(a.version=`${n.version.major}.${n.version.minor}.${n.version.patch}`),e.metadata.imports&&(a.imports=this.serializeImports(e.metadata.imports)),r[n.package_]=a}return Object.assign(r,e.body),c.dump(r,{indent:2,noRefs:!0,sortKeys:!1})}createEmptyMetadata(){return{get allImports(){return[]}}}addAllImportsGetter(e){let r=e.imports;return Object.defineProperty(e,"allImports",{get:function(){if(!r)return[];let n=[];for(let a of Object.values(r))n.push(...a);return n},enumerable:!0,configurable:!0}),e}createVersion(e,r,n){return{major:e,minor:r,patch:n,toString:()=>`${e}.${r}.${n}`,equals:t=>!t||typeof t!="object"?!1:t.major===e&&t.minor===r&&t.patch===n,getHashCode:()=>e<<20|r<<10|n,compareTo:t=>e!==t.major?e-t.major:r!==t.minor?r-t.minor:n-t.patch}}extractMetadata(e){let r=this.createEmptyMetadata();for(let[n,a]of Object.entries(e))if(a&&typeof a=="object"&&f(a.type)){r.type_=a.type;let t=n,o=a.publisher,i=a.version?this.parseVersion(a.version):void 0;return o&&t&&(r.namespace_={publisher:o,package_:t,version:i,toString:function(){return this.version?`${this.publisher}/${this.package_}@${this.version.major}.${this.version.minor}.${this.version.patch}`:`${this.publisher}/${this.package_}`},equals:s=>!s||typeof s!="object"?!1:s.publisher===o&&s.package_===t&&(!i||!s.version||i.equals(s.version)),getHashCode:()=>{let s=0;for(let p=0;p<o.length;p++)s=(s<<5)-s+o.charCodeAt(p);for(let p=0;p<t.length;p++)s=(s<<5)-s+t.charCodeAt(p);return s|0}}),a.imports&&Array.isArray(a.imports)&&(r.imports=this.parseImportsV3(a.imports)),this.addAllImportsGetter(r)}return r}extractBody(e,r){let n={};for(let[a,t]of Object.entries(e))if(t&&typeof t=="object"&&f(t.type)){let o={};for(let[i,s]of Object.entries(t))i==="publisher"||i==="version"||i==="imports"||(o[i]=s);n[a]=o}else n[a]=t;return n}parseVersion(e){if(typeof e=="string"){let r=e.split(".").map(Number);return this.createVersion(r[0]||0,r[1]||0,r[2]||0)}return this.createVersion(e.major||0,e.minor||0,e.patch||0)}parseImportsV3(e){let r={};for(let n of e)if(!(!n||typeof n!="object"))if(n.packages&&Array.isArray(n.packages)){let a=n.publisher;if(!a)throw new Error("PublisherImport requires 'publisher' property");r[a]||(r[a]=[]);for(let t of n.packages){if(!t||typeof t!="object")continue;let o=this.parseImportFromEmbeddedObject(t,a);r[a].push(o)}}else{let a=this.parseImportFromEmbeddedObject(n,n.publisher),t=a.publisher||"";r[t]||(r[t]=[]),r[t].push(a)}return r}parseImportFromEmbeddedObject(e,r){let n=e.package;if(!n)throw new Error("Import requires 'package' property");let a=e.match;if(!a)throw new Error("Import requires 'match' property");let t=e.version;if(!t)throw new Error("Import requires 'version' property");let o;if(e.mode!==void 0&&e.mode!==null){if(!d.includes(e.mode))throw new Error(`Import '${n}' has an unknown mode '${e.mode}'; expected one of: ${d.join(", ")}`);o=e.mode}return this.makeImport(n,a,t,r,e.alias,o)}makeImport(e,r,n,a,t,o){let i=this.parseVersion(n),s=this.parseVersionOperator(r),p=this.calculateMaxVersion(r,i);return{package_:`${e} ${r} ${i.toString()}`,publisher:a,packageName:e,versionOperator:s,version:i,alias:t,...o?{mode:o}:{},minVersion:i,maxVersion:p,toEmbeddedObject:()=>{let u={package:e,match:r,version:i.toString()};return t&&(u.alias=t),o&&(u.mode=o),u},toString:()=>t?`${e} ${r} ${i.toString()} as ${t}`:`${e} ${r} ${i.toString()}`}}buildImport(e,r,n,a){return this.makeImport(e,r,n,a)}parseVersionOperator(e){return l(e)}calculateMaxVersion(e,r){switch(e){case"~":return this.createVersion(r.major,r.minor+1,0);case"^":return r.major===0?this.createVersion(0,r.minor+1,0):this.createVersion(r.major+1,0,0);default:return this.createVersion(999,999,999)}}serializeImports(e){let r=[];for(let[n,a]of Object.entries(e)){let t={publisher:n,packages:a.map(o=>{let i=h(o.versionOperator),s={package:o.packageName,match:i,version:`${o.version.major}.${o.version.minor}.${o.version.patch}`};return o.alias&&(s.alias=o.alias),s})};r.push(t)}return r}};export{g as a};
@@ -1 +1 @@
1
- import{j as $}from"./chunk-Q2FG7DME.js";import{c as l,d as u,e as b,f as C,g as a,ia as U}from"./chunk-7TU55KLO.js";import{c as S,d as j,e as O,f as x,i as I,j as T,k as g,l as v,m as L,n as q}from"./chunk-XNEWQEB6.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};
1
+ import{k as $}from"./chunk-22DSABP6.js";import{c as l,d as u,e as b,f as C,g as a,ka as U}from"./chunk-NUTHBBDZ.js";import{c as S,d as j,e as O,f as x,i as I,j as T,k as g,l as v,m as L,n as q}from"./chunk-D4QGPMRW.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}},H={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}},G={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,H,G,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 P=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 R;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)}},R=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,P as e};
@@ -1 +1 @@
1
- import{f as U,j as B}from"./chunk-Q2FG7DME.js";import{a as K}from"./chunk-HF5FJBS2.js";import{ga as _}from"./chunk-7TU55KLO.js";import{L as N,b as j,c as d,d as m,e as p,f as E,h as R,i as $,j as A,k as v,l as S,m as V,n as g,p as D}from"./chunk-XNEWQEB6.js";import{b as C,e as l}from"./chunk-QILEJIFU.js";import*as P from"js-yaml";import{canonicalForm as Y,canonicalHash as ee}from"@kanonak-protocol/canonical";function k(n){return typeof n=="object"&&n!==null&&Array.isArray(n.subjects)}import{CANONICAL_FORM_VERSION as Pe}from"@kanonak-protocol/canonical";function ke(n){return Y(k(n)?n:F(n))}function O(n){return ee(k(n)?n:F(n))}function F(n){let e=[];for(let t of n)t instanceof d&&e.push({uri:se(t),statements:h(t.statement)});return{subjects:e}}function h(n){let e=[];for(let t of n){let r=ie(t);if(!r)continue;if(t instanceof g&&ne(t.predicate.subject)){e.push(...re(t,r));continue}let o=oe(t);o&&e.push({predicate:r,value:o})}return e}function ne(n){let e=_("type");return e!==void 0&&n.name==="type"&&n.publisher===e.publisher&&n.package_===e.package_}var H=new TextEncoder;function te(n,e){let t=H.encode(n),r=H.encode(e),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 re(n,e){let t=[];for(let r of n.object){if(!(r instanceof p))throw new Error(`canonicalForm: a multi-valued type statement must contain only entity references, got ${r.constructor?.name??typeof r}`);t.push(b(r))}t.sort(te);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:e,value:{ref:r}}))}function oe(n){if(n instanceof R&&n.carrier)return{lit:n.lexical??String(n.object),datatype:z(n.carrier)};if(n instanceof $)return{raw:n.object};if(n instanceof A)return{raw:n.lexical??String(n.object)};if(n instanceof v)return{raw:n.lexical??String(n.object)};if(n instanceof S)return{ref:b(n.object)};if(n instanceof V)return M(n.object);if(n instanceof g)return{list:n.object.map(ae)}}function M(n){let e=h(n.statement);return n.name&&n.name.length>0?{embed:{name:n.name,statements:e}}:{embed:{statements:e}}}function ae(n){if(n instanceof p)return{ref:b(n)};if(n instanceof m)return M(n);if(n instanceof E){if(n.carrier)return{lit:n.lexical??String(n.value),datatype:z(n.carrier)};let e=n.value;if(typeof e=="string")return{raw:e};if(typeof e=="number")return{raw:String(e)};if(typeof e=="boolean")return{raw:String(e)}}if(n instanceof j)return{embed:{statements:h(n.statement)}};throw new Error(`canonicalForm: list item of unrecognized kind (${n.constructor?.name??typeof n}); add canonicalization support before hashing data that contains it`)}function z(n){return n===U.LangString?"kanonak.org/core-rdf/langString":`kanonak.org/core-xsd/${n}`}function ie(n){let e=n.predicate;if(e)return L(e.subject)}function se(n){let e=n.namespace??"",t=n.name??"";return`${e}/${t}`}function b(n){return L(n.subject)}function L(n){let e=n.version;return e&&typeof e.major=="number"?`${n.publisher}/${n.package_}@${e.major}.${e.minor}.${e.patch}/${n.name}`:`${n.publisher}/${n.package_}/${n.name}`}import{VersionOperator as T}from"@kanonak-protocol/types/document/models/enums";var ce="0.0.0",w=class{constructor(e,t=new K,r){this.repository=e;this.parser=t;this.objectParser=r??new B(this.parser)}repository;parser;objectParser;imports(){return new f}serializeValue(e,t){return G(e,t)}async buildContentAddressed(e){let t=e.book.toImports(),r=await this.hashBody(e.publisher,t,e.body),o=Z(r),a={type:"EphemeralPackage",publisher:e.publisher,imports:t};e.contentHashProperty&&(a[e.contentHashProperty]=r),Object.assign(a,e.header??{}),a.imports=t;let i={[o]:a,...e.body},s=this.dump(i);return{yaml:s,byteCount:W(s),contentHash:r,packageName:o,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let t=e.book.toImports(),r={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:t},o;e.contentHashProperty&&(o=await this.hashBody(e.publisher,t,e.body),r[e.contentHashProperty]=o),Object.assign(r,e.header??{}),r.imports=t;let a={[e.name]:r,...e.body},i=this.dump(a),s={yaml:i,byteCount:W(i),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return o!==void 0&&(s.contentHash=o),s}dump(e){return P.dump(e,{lineWidth:-1})}async hashBody(e,t,r){let o={[q]:{type:"EphemeralPackage",publisher:e,imports:t},...r},a=this.parser.parse(P.dump(o,{lineWidth:-1})),i=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new N(a,this.repository))).filter(u=>u instanceof d&&u.namespace===i&&u.name!==q);for(let u of c)u.namespace="ephemeral";return O(c)}},q="__pkgbuilder_probe__";function W(n){return new TextEncoder().encode(n).length}function Z(n){let e="sha256:",t=n.startsWith(e)?e.length:0;return`q-${n.slice(t,t+16)}`}var f=class{byKey=new Map;aliases=new Set;ensure(e,t,r,o,a=T.Major){let i=`${e}/${t}@${r}`,s=this.byKey.get(i);if(s)return s.alias;let c=this.uniqueAlias(o);return this.byKey.set(i,{publisher:e,package_:t,version:r,alias:c,match:a}),c}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,l(e.version),e.package_)}.${e.name}`}refLatest(e,t,r,o){return`${this.ensure(e,t,ce,o??t,T.Any)}.${r}`}toImports(){let e=new Map;for(let r of this.byKey.values()){let o=e.get(r.publisher)??[];o.push(r),e.set(r.publisher,o)}return[...e.keys()].sort().map(r=>({publisher:r,packages:e.get(r).sort((o,a)=>o.package_<a.package_?-1:1).map(o=>({package:o.package_,match:C(o.match),version:o.version,alias:o.alias}))}))}uniqueAlias(e){let t=J(e)||"pkg",r=t,o=2;for(;this.aliases.has(r);)r=`${t}${o++}`;return this.aliases.add(r),r}};function G(n,e){if(n!=null){if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof p)return e.ref(n.subject);if(Array.isArray(n)){let t=n.map(r=>G(r,e)).filter(r=>r!==void 0);return t.length>0?t:void 0}if(n instanceof m)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(ue(n))throw new Error(`Value produced a bare URI without a version (${n.publisher}/${n.package_}/${n.name}); cannot serialize it as a reference.`)}}function J(n){return n.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function ue(n){return typeof n=="object"&&n!==null&&typeof n.publisher=="string"&&typeof n.package_=="string"&&typeof n.name=="string"}var I=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,t){return this.producers.find(r=>r.canProduce(e,t))}async produceCached(e,t,r,o){let a=`${t}/${r}@${l(o)}`,i=this.produced.get(a);if(i)return i;let{document:s}=await e.produce(t,r,o);return this.produced.set(a,s),s}async getHighestCompatibleVersionAsync(e,t){let r=this.producerFor(e,t.packageName);if(!r)return null;let o={operator:t.versionOperator,version:t.version},a=await r.resolveVersion(e,t.packageName,o);return a?this.produceCached(r,e,t.packageName,a):null}async getDocumentAsync(e){let t;try{t=D(e)}catch{return null}if(t.kind!=="package"||!t.version)return null;let r=this.producerFor(t.publisher,t.package_);return r?this.produceCached(r,t.publisher,t.package_,t.version):null}async getDocumentsByNamespaceAsync(e,t){return Array.from(this.produced.values()).filter(r=>{let o=r.metadata.namespace_;return o!=null&&o.publisher===e&&o.package_===t})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,t){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,t){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var Q={async authorize(){return{allowed:!0}}},X={async record(){}},y=class extends Error{constructor(t,r){let o=`${t.publisher}/${t.package_}${t.version?`@${t.version.major}.${t.version.minor}.${t.version.patch}`:""}`;super(`Not entitled to produce ${o}${r?`: ${r}`:""}`);this.address=t;this.reason=r;this.name="EntitlementDeniedError"}address;reason},x=class{inner;ctx;policy;meter;constructor(e,t,r=Q,o=X){this.inner=e,this.ctx=t,this.policy=r,this.meter=o}canProduce(e,t){return this.inner.canProduce(e,t)}async resolveVersion(e,t,r){return await this.assertAllowed({publisher:e,package_:t,version:r.version}),this.inner.resolveVersion(e,t,r)}async produce(e,t,r){let o={publisher:e,package_:t,version:r};await this.assertAllowed(o);let a=await this.inner.produce(e,t,r);return await this.meter.record(this.ctx,o,a),a}async assertAllowed(e){let t=await this.policy.authorize(this.ctx,e);if(!t.allowed)throw new y(e,t.reason)}};export{ke as a,O as b,Pe as c,w as d,Z as e,f,J as g,I as h,Q as i,X as j,y as k,x as l};
1
+ import{g as U,k as B}from"./chunk-22DSABP6.js";import{a as K}from"./chunk-7JBKOJB4.js";import{ga as _}from"./chunk-NUTHBBDZ.js";import{L as N,b as j,c as d,d as m,e as p,f as E,h as R,i as $,j as A,k as v,l as S,m as V,n as g,p as D}from"./chunk-D4QGPMRW.js";import{b as C,e as l}from"./chunk-QILEJIFU.js";import*as P from"js-yaml";import{canonicalForm as Y,canonicalHash as ee}from"@kanonak-protocol/canonical";function k(n){return typeof n=="object"&&n!==null&&Array.isArray(n.subjects)}import{CANONICAL_FORM_VERSION as Pe}from"@kanonak-protocol/canonical";function ke(n){return Y(k(n)?n:F(n))}function O(n){return ee(k(n)?n:F(n))}function F(n){let e=[];for(let t of n)t instanceof d&&e.push({uri:se(t),statements:h(t.statement)});return{subjects:e}}function h(n){let e=[];for(let t of n){let r=ie(t);if(!r)continue;if(t instanceof g&&ne(t.predicate.subject)){e.push(...re(t,r));continue}let o=oe(t);o&&e.push({predicate:r,value:o})}return e}function ne(n){let e=_("type");return e!==void 0&&n.name==="type"&&n.publisher===e.publisher&&n.package_===e.package_}var H=new TextEncoder;function te(n,e){let t=H.encode(n),r=H.encode(e),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 re(n,e){let t=[];for(let r of n.object){if(!(r instanceof p))throw new Error(`canonicalForm: a multi-valued type statement must contain only entity references, got ${r.constructor?.name??typeof r}`);t.push(b(r))}t.sort(te);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:e,value:{ref:r}}))}function oe(n){if(n instanceof R&&n.carrier)return{lit:n.lexical??String(n.object),datatype:z(n.carrier)};if(n instanceof $)return{raw:n.object};if(n instanceof A)return{raw:n.lexical??String(n.object)};if(n instanceof v)return{raw:n.lexical??String(n.object)};if(n instanceof S)return{ref:b(n.object)};if(n instanceof V)return M(n.object);if(n instanceof g)return{list:n.object.map(ae)}}function M(n){let e=h(n.statement);return n.name&&n.name.length>0?{embed:{name:n.name,statements:e}}:{embed:{statements:e}}}function ae(n){if(n instanceof p)return{ref:b(n)};if(n instanceof m)return M(n);if(n instanceof E){if(n.carrier)return{lit:n.lexical??String(n.value),datatype:z(n.carrier)};let e=n.value;if(typeof e=="string")return{raw:e};if(typeof e=="number")return{raw:String(e)};if(typeof e=="boolean")return{raw:String(e)}}if(n instanceof j)return{embed:{statements:h(n.statement)}};throw new Error(`canonicalForm: list item of unrecognized kind (${n.constructor?.name??typeof n}); add canonicalization support before hashing data that contains it`)}function z(n){return n===U.LangString?"kanonak.org/core-rdf/langString":`kanonak.org/core-xsd/${n}`}function ie(n){let e=n.predicate;if(e)return L(e.subject)}function se(n){let e=n.namespace??"",t=n.name??"";return`${e}/${t}`}function b(n){return L(n.subject)}function L(n){let e=n.version;return e&&typeof e.major=="number"?`${n.publisher}/${n.package_}@${e.major}.${e.minor}.${e.patch}/${n.name}`:`${n.publisher}/${n.package_}/${n.name}`}import{VersionOperator as T}from"@kanonak-protocol/types/document/models/enums";var ce="0.0.0",w=class{constructor(e,t=new K,r){this.repository=e;this.parser=t;this.objectParser=r??new B(this.parser)}repository;parser;objectParser;imports(){return new f}serializeValue(e,t){return G(e,t)}async buildContentAddressed(e){let t=e.book.toImports(),r=await this.hashBody(e.publisher,t,e.body),o=Z(r),a={type:"EphemeralPackage",publisher:e.publisher,imports:t};e.contentHashProperty&&(a[e.contentHashProperty]=r),Object.assign(a,e.header??{}),a.imports=t;let i={[o]:a,...e.body},s=this.dump(i);return{yaml:s,byteCount:W(s),contentHash:r,packageName:o,publisher:e.publisher,resourceCount:Object.keys(e.body).length}}async buildNamed(e){let t=e.book.toImports(),r={type:e.type??"Package",publisher:e.publisher,version:e.version,imports:t},o;e.contentHashProperty&&(o=await this.hashBody(e.publisher,t,e.body),r[e.contentHashProperty]=o),Object.assign(r,e.header??{}),r.imports=t;let a={[e.name]:r,...e.body},i=this.dump(a),s={yaml:i,byteCount:W(i),packageName:e.name,publisher:e.publisher,resourceCount:Object.keys(e.body).length};return o!==void 0&&(s.contentHash=o),s}dump(e){return P.dump(e,{lineWidth:-1})}async hashBody(e,t,r){let o={[q]:{type:"EphemeralPackage",publisher:e,imports:t},...r},a=this.parser.parse(P.dump(o,{lineWidth:-1})),i=a.metadata.namespace_?.toString(),c=(await this.objectParser.parseKanonaks(new N(a,this.repository))).filter(u=>u instanceof d&&u.namespace===i&&u.name!==q);for(let u of c)u.namespace="ephemeral";return O(c)}},q="__pkgbuilder_probe__";function W(n){return new TextEncoder().encode(n).length}function Z(n){let e="sha256:",t=n.startsWith(e)?e.length:0;return`q-${n.slice(t,t+16)}`}var f=class{byKey=new Map;aliases=new Set;ensure(e,t,r,o,a=T.Major){let i=`${e}/${t}@${r}`,s=this.byKey.get(i);if(s)return s.alias;let c=this.uniqueAlias(o);return this.byKey.set(i,{publisher:e,package_:t,version:r,alias:c,match:a}),c}ref(e){if(!e.version||typeof e.version.major!="number")throw new Error(`Cannot serialize a reference to ${e.publisher}/${e.package_}/${e.name} without a version.`);return`${this.ensure(e.publisher,e.package_,l(e.version),e.package_)}.${e.name}`}refLatest(e,t,r,o){return`${this.ensure(e,t,ce,o??t,T.Any)}.${r}`}toImports(){let e=new Map;for(let r of this.byKey.values()){let o=e.get(r.publisher)??[];o.push(r),e.set(r.publisher,o)}return[...e.keys()].sort().map(r=>({publisher:r,packages:e.get(r).sort((o,a)=>o.package_<a.package_?-1:1).map(o=>({package:o.package_,match:C(o.match),version:o.version,alias:o.alias}))}))}uniqueAlias(e){let t=J(e)||"pkg",r=t,o=2;for(;this.aliases.has(r);)r=`${t}${o++}`;return this.aliases.add(r),r}};function G(n,e){if(n!=null){if(typeof n=="string"||typeof n=="number"||typeof n=="boolean")return n;if(n instanceof p)return e.ref(n.subject);if(Array.isArray(n)){let t=n.map(r=>G(r,e)).filter(r=>r!==void 0);return t.length>0?t:void 0}if(n instanceof m)throw new Error("Embedded values are not yet supported by PackageBuilder. Produce a literal or a reference, or compose the embedded shape into the output class.");if(ue(n))throw new Error(`Value produced a bare URI without a version (${n.publisher}/${n.package_}/${n.name}); cannot serialize it as a reference.`)}}function J(n){return n.replace(/[^A-Za-z0-9-]/g,"-").replace(/-+/g,"-").replace(/^-|-$/g,"")}function ue(n){return typeof n=="object"&&n!==null&&typeof n.publisher=="string"&&typeof n.package_=="string"&&typeof n.name=="string"}var I=class{constructor(e){this.producers=e}producers;produced=new Map;producerFor(e,t){return this.producers.find(r=>r.canProduce(e,t))}async produceCached(e,t,r,o){let a=`${t}/${r}@${l(o)}`,i=this.produced.get(a);if(i)return i;let{document:s}=await e.produce(t,r,o);return this.produced.set(a,s),s}async getHighestCompatibleVersionAsync(e,t){let r=this.producerFor(e,t.packageName);if(!r)return null;let o={operator:t.versionOperator,version:t.version},a=await r.resolveVersion(e,t.packageName,o);return a?this.produceCached(r,e,t.packageName,a):null}async getDocumentAsync(e){let t;try{t=D(e)}catch{return null}if(t.kind!=="package"||!t.version)return null;let r=this.producerFor(t.publisher,t.package_);return r?this.produceCached(r,t.publisher,t.package_,t.version):null}async getDocumentsByNamespaceAsync(e,t){return Array.from(this.produced.values()).filter(r=>{let o=r.metadata.namespace_;return o!=null&&o.publisher===e&&o.package_===t})}async getAllDocumentsAsync(){return Array.from(this.produced.values())}async saveDocumentAsync(e,t){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async deleteDocumentAsync(e){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async clearNamespaceAsync(e,t){throw new Error("ProducerRepository is read-only: a producer is a source, not a store.")}async getAllDocumentReferencesAsync(){return[]}async getDocumentContentAsync(e){return null}async getDocumentUriAsync(e){return null}};var Q={async authorize(){return{allowed:!0}}},X={async record(){}},y=class extends Error{constructor(t,r){let o=`${t.publisher}/${t.package_}${t.version?`@${t.version.major}.${t.version.minor}.${t.version.patch}`:""}`;super(`Not entitled to produce ${o}${r?`: ${r}`:""}`);this.address=t;this.reason=r;this.name="EntitlementDeniedError"}address;reason},x=class{inner;ctx;policy;meter;constructor(e,t,r=Q,o=X){this.inner=e,this.ctx=t,this.policy=r,this.meter=o}canProduce(e,t){return this.inner.canProduce(e,t)}async resolveVersion(e,t,r){return await this.assertAllowed({publisher:e,package_:t,version:r.version}),this.inner.resolveVersion(e,t,r)}async produce(e,t,r){let o={publisher:e,package_:t,version:r};await this.assertAllowed(o);let a=await this.inner.produce(e,t,r);return await this.meter.record(this.ctx,o,a),a}async assertAllowed(e){let t=await this.policy.authorize(this.ctx,e);if(!t.allowed)throw new y(e,t.reason)}};export{ke as a,O as b,Pe as c,w as d,Z as e,f,J as g,I as h,Q as i,X as j,y as k,x as l};
@@ -0,0 +1 @@
1
+ import{r as f}from"./chunk-D4QGPMRW.js";import{a as m}from"./chunk-FUUTGGJS.js";import{b as u}from"./chunk-F67UH4FD.js";var R=class{resourceResolver;constructor(e){this.resourceResolver=e}async buildFromNameAsync(e,o){return(await this.resourceResolver.resolveEntityAsync(e,o))?.uri??null}buildFromName(e,o,t){if(e.includes(".")){let r=e.split("."),c=r[0],l=r[1],i=this.findPackageNameForAlias(t,c);if(i){for(let n of o.values())if(n.entityName===l&&n.uri.package_===i)return n.uri}return null}let a=o.get(e);return a?a.uri:null}create(e,o,t,a){return new m(e,o,t,a)}findPackageNameForAlias(e,o){if(!e.metadata.imports)return null;for(let[t,a]of Object.entries(e.metadata.imports))for(let r of a)if(r.alias===o||!r.alias&&r.packageName===o)return r.packageName;return null}};async function y(s,e,o){let t=e.metadata?.namespace_,a=!!t&&t.publisher===s.publisher&&t.package_===s.package_,r=[];for(let[i,n]of Object.entries(e.metadata?.imports??{}))if(i===s.publisher)for(let p of n)p.packageName!==s.package_||u(p)||r.push(`${p.alias??p.packageName}.${s.name}`);let c=a?[s.name,...r]:[...r,s.name],l=f(s);for(let i of c){let n=await o.resolveEntityAsync(i,e);if(n&&!n.isAmbiguous&&f(n.uri)===l)return i}}export{R as a,y as b};
@@ -0,0 +1 @@
1
+ import{a as S}from"./chunk-FUUTGGJS.js";import{c as A,g as v}from"./chunk-QILEJIFU.js";var p=class{};var f=class extends p{statement=[];unresolvedPredicates=[];sourceDoc="";sourceKey};var l=class extends f{namespace;name;icon};var k=class extends f{name;rangeType};var s=class e extends p{subject;sourceKey;static parse(n){let t=new e;return t.subject=S.parse(n),t}};var $=class extends p{value;carrier;lexical;links;sourceKey};var m=class{predicate;object;sourceKey};var d=class extends m{carrier;lexical};var b=class e extends d{static parse(n,t){let r=new e;return r.predicate=s.parse(n),r.object=t,r}};var K=class e extends d{static parse(n,t){let r=new e;return r.predicate=s.parse(n),r.object=t,r}};var x=class extends d{};var y=class e extends m{static parse(n,t){let r=new e;return r.predicate=s.parse(n),r.object=s.parse(t),r}};var h=class extends m{};var j=class extends m{};var U=class extends b{links=[]};function E(e){return`${e.publisher}/${e.package_}/${e.name}`}function w(e,n){return e.publisher===n.publisher&&e.package_===n.package_&&e.name===n.name}function C(e){let n=e.version;return n&&typeof n.major=="number"?`https://${e.publisher}/${e.package_}/${n.major}.${n.minor}.${n.patch}/${e.name}`:`https://${e.publisher}/${e.package_}/${e.name}`}function T(e){return L(e,B)}var B={publisher:"kanonak.org",package_:"core-rdf",name:"type"};function L(e,n){let t=[];for(let r of D(e,n))r.item instanceof s&&t.push(r.item.subject);return t}function D(e,n){if(!(e instanceof f))return[];let t=[];for(let r of e.statement){let a=r.predicate;if(!(!a?.subject||!w(a.subject,n)))if(r instanceof y)t.push({item:r.object,fromList:!1});else if(r instanceof h)t.push({item:r.object,fromList:!1});else if(r instanceof U)t.push({item:{literal:!0,value:r.object,carrier:r.carrier,lexical:r.lexical,links:r.links},fromList:!1});else if(r instanceof b||r instanceof K||r instanceof x)t.push({item:{literal:!0,value:r.object,carrier:r.carrier,lexical:r.lexical},fromList:!1});else if(r instanceof j)for(let o of r.object??[])if(o instanceof s||o instanceof k)t.push({item:o,fromList:!0});else if(o instanceof $)t.push({item:{literal:!0,value:o.value,carrier:o.carrier,lexical:o.lexical,links:o.links},fromList:!0});else throw new Error(`rawValuesOf: a list value of '${n.name}' is a ${o?.constructor?.name??typeof o}; list items are references, embedded values or literals.`);else throw new Error(`rawValuesOf: '${n.name}' has a statement of unknown kind ${r?.constructor?.name??typeof r}.`)}return t}function I(e,n){if(!(e instanceof f))return!1;for(let t of e.statement)if(t.predicate?.subject?.name==="type"&&t instanceof y){let a=t.object;if(w(a.subject,n))return!0}return!1}function N(e,n){let t=[];for(let r of e)r instanceof l&&I(r,n)&&t.push(r);return t}function H(e,n){let t=n.version,r=t&&typeof t.major=="number"?`${n.publisher}/${n.package_}@${t.major}.${t.minor}.${t.patch}`:void 0;for(let a of e){if(!(a instanceof l)||a.name!==n.name)continue;let o=a.namespace||"";if(r!==void 0){if(o===r)return a}else if(o.startsWith(`${n.publisher}/${n.package_}@`))return a}}function W(e,n){let t=[];for(let r of e){if(!(r instanceof l)||r.name!==n.name)continue;(r.namespace||"").startsWith(`${n.publisher}/${n.package_}@`)&&t.push(r)}return t.sort((r,a)=>{let o=v((r.namespace||"").split("@")[1]??""),i=v((a.namespace||"").split("@")[1]??"");return o?i?A(i,o):-1:i?1:0}),t}function g(e,n){for(let t of e.statement){let r=t.predicate;if(r?.subject&&w(r.subject,n))return t}}function q(e,n){return g(e,n)!==void 0}function M(e,n){let t=g(e,n);if(t&&(t instanceof b||t instanceof K||t instanceof x))return t.object}function F(e,n){let t=M(e,n);return typeof t=="string"?t:void 0}function Y(e,n){let t=g(e,n);if(t instanceof y)return t.object.subject}function z(e,n){let t=g(e,n);if(t instanceof h)return t.object}function G(e,n){let t=g(e,n);return t instanceof j?t.object??[]:[]}function _(e){if(!e||e.trim().length===0)throw new Error("Kanonak address string cannot be null or empty");let n=e.trim(),t=n.split("/");if(t.length===1){let r=t[0];if(!r)throw new Error(`Invalid Kanonak address: "${e}". Expected publisher, publisher/package[@version], or publisher/package[@version]/name.`);if(r.includes("@"))throw new Error(`Invalid Kanonak address: "${e}". A bare publisher cannot carry an @version qualifier \u2014 versions belong to packages.`);return{kind:"publisher",publisher:r}}if(t.length===2){let[r,a]=t;if(!r||!a)throw new Error(`Invalid Kanonak address: "${e}". Expected publisher/package[@version].`);let o=a.indexOf("@");if(o===-1)return{kind:"package",publisher:r,package_:a};let i=a.substring(0,o),c=a.substring(o+1);if(!i||!c)throw new Error(`Invalid Kanonak address: "${e}". Expected publisher/package[@version].`);let u=J(c);return{kind:"package",publisher:r,package_:i,version:u}}return{kind:"resource",uri:S.parse(n)}}function Ge(e){switch(e.kind){case"publisher":return e.publisher;case"package":return e.version?`${e.publisher}/${e.package_}@${e.version.major}.${e.version.minor}.${e.version.patch}`:`${e.publisher}/${e.package_}`;case"resource":return e.uri.toString()}}function J(e){let n=e.split(".").map(Number);return Q(n[0]||0,n[1]||0,n[2]||0)}function Q(e,n,t){return{major:e,minor:n,patch:t,toString:()=>`${e}.${n}.${t}`,equals:r=>!r||typeof r!="object"?!1:r.major===e&&r.minor===n&&r.patch===t,getHashCode:()=>e<<20|n<<10|t,compareTo:r=>e!==r.major?e-r.major:n!==r.minor?n-r.minor:t-r.patch}}function X(e,n,t,r){let a=ee(e,n,r);if(a.length===0)return[];let o=ne(t);return a.map(({value:i,address:c})=>{let u=i.fromList;if(i.item instanceof s){let P=o.resolve(i.item.subject);return P?{kind:"subject",node:P,uri:i.item.subject,address:c,fromList:u}:{kind:"unresolved",uri:i.item.subject,address:c,fromList:u}}if(i.item instanceof k)return{kind:"embedded",node:i.item,address:c,fromList:u};let V={kind:"literal",value:i.item.value,carrier:i.item.carrier,lexical:i.item.lexical,address:c,fromList:u};return i.item.links&&(V.links=i.item.links),V})}function Z(e){let n=_(`${e.namespace}/${e.name}`);if(n.kind!=="resource")throw new Error(`subjectAddress: '${e.namespace}/${e.name}' is not a resource address`);return E(n.uri)}function ee(e,n,t){let r=D(e,n);if(r.length===0)return[];let a=t.includes("#")?`${t}.${n.name}`:`${t}#${n.name}`,o=r.length>1||r.some(i=>i.fromList);return r.map((i,c)=>({value:i,address:i.item instanceof k&&i.item.name?`${a}.${i.item.name}`:o?`${a}[${c}]`:a}))}var O=new WeakMap;function ne(e){let n=O.get(e);if(n)return n;let t=new Map,r=new Map;for(let a of e){if(!(a instanceof l))continue;let o=a.namespace||"",i=`${o}\0${a.name}`;t.has(i)||t.set(i,a);let c=o.indexOf("@");if(c>=0){let u=`${o.slice(0,c)}\0${a.name}`;r.has(u)||r.set(u,a)}}return n={resolve(a){let o=a.version;return o&&typeof o.major=="number"?t.get(`${a.publisher}/${a.package_}@${o.major}.${o.minor}.${o.patch}\0${a.name}`):r.get(`${a.publisher}/${a.package_}\0${a.name}`)}},O.set(e,n),n}var R=class{constructor(n,t){this.doc=n;this.broader=t}doc;broader;async getAllDocumentsAsync(){return[this.doc]}async getDocumentAsync(n){return this.broader.getDocumentAsync(n)}async getDocumentsByNamespaceAsync(n,t){return this.broader.getDocumentsByNamespaceAsync(n,t)}async getHighestCompatibleVersionAsync(n,t){return this.broader.getHighestCompatibleVersionAsync(n,t)}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(n){return this.broader.getDocumentContentAsync(n)}async getDocumentUriAsync(n){return this.broader.getDocumentUriAsync(n)}};export{p as a,f as b,l as c,k as d,s as e,$ as f,m as g,d as h,b as i,K as j,x as k,y as l,h as m,j as n,U as o,_ as p,Ge as q,E as r,w as s,C as t,T as u,L as v,D as w,I as x,N as y,H as z,W as A,g as B,q as C,M as D,F as E,Y as F,z as G,G as H,X as I,Z as J,ee as K,R as L};
@@ -0,0 +1 @@
1
+ import{j as i,k as o,l as r}from"./chunk-OOYGILH4.js";import{readFileSync as c,writeFileSync as l,existsSync as s}from"fs";import{createHash as a}from"crypto";var n="kanonak.lock";function f(e=n){return s(e)?o(c(e,"utf-8")):null}function k(e,t=n){e.lastUpdated=new Date().toISOString(),l(t,r(e),"utf-8")}function L(e){let t=a("sha256").update(e).digest("hex");return`${i}${t}`}export{f as a,k as b,L as c};
@@ -1 +1 @@
1
- import{c as j,d as D,e as m,i as R,l as p,m as K,n as k}from"./chunk-XNEWQEB6.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{c as j,d as D,e as m,i as R,l as p,m as K,n as k}from"./chunk-D4QGPMRW.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};
@@ -0,0 +1,3 @@
1
+ import{j as A}from"./chunk-22DSABP6.js";import{a as E}from"./chunk-7JBKOJB4.js";import{na as $}from"./chunk-NUTHBBDZ.js";import{c as V,d as I,e as N,f as x,g as U,l as W,m as J,n as _,o as B}from"./chunk-D4QGPMRW.js";var R=class{propertyUri;propertyType;range;rangeUri;isImported;definedInNamespace};import{parseDocument as H,LineCounter as Q,isMap as b,isPair as f,isScalar as l,isSeq as j}from"yaml";var L=class r{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 n=new r,t=new Q,o=H(e,{lineCounter:t});if(o.errors.length>0||!b(o.contents))return n;O(o.contents,[],t,n);for(let i of o.contents.items){if(!f(i)||!l(i.key))continue;let s=String(i.key.value),u=i.key.range;if(!u)continue;n.entities.set(s,g(u,t));let a=i.value,c=a&&typeof a=="object"&&"range"in a?a.range:void 0;if(c?n.entityBlocks.set(s,g([u[0],u[1],c[2]],t)):n.entityBlocks.set(s,g(u,t)),b(i.value)){let k=new Map,d=new Map,p=new Map;for(let S of i.value.items){if(!f(S)||!l(S.key))continue;let h=String(S.key.value),m=S.key.range;m&&k.set(h,g(m,t));let P=S.value;if(P&&typeof P=="object"&&"range"in P&&Array.isArray(P.range)){let v=P.range;d.set(h,g(v,t))}if(j(P)){let v=[];for(let K of P.items)K&&typeof K=="object"&&"range"in K&&Array.isArray(K.range)&&v.push(g(K.range,t));v.length>0&&p.set(h,v)}}k.size>0&&n.properties.set(s,k),d.size>0&&n.propertyValues.set(s,d),p.size>0&&n.valueListItems.set(s,p);let y=Y(i.value,t);y.length>0&&n.importPackages.set(s,y)}}return n}getEntityPosition(e){return this.entities.get(e)}getEntityBlockPosition(e){return this.entityBlocks.get(e)}findEntityAtPosition(e,n){for(let[t,o]of this.entityBlocks)if(C(o,e,n))return t}findPropertyAtPosition(e,n){let t=this.findEntityAtPosition(e,n);if(!t)return;let o=this.properties.get(t),i=this.propertyValues.get(t);if(!o&&!i)return{entityName:t};let s,u;if(i)for(let[a,c]of i)C(c,e,n)&&(!u||q(c,u))&&(s=a,u=c);if(o)for(let[a,c]of o)C(c,e,n)&&(!u||q(c,u))&&(s=a,u=c);return s?{entityName:t,propertyName:s}:{entityName:t}}getPropertyPosition(e,n){return this.properties.get(e)?.get(n)}getPropertyValuePosition(e,n){return this.propertyValues.get(e)?.get(n)}getImportPackages(e){return this.importPackages.get(e)??[]}getAllImportPackages(){let e=[];for(let[n,t]of this.importPackages)for(let o of t)e.push({entityName:n,entry:o});return e}findPropertySourceName(e,n){let t=this.properties.get(e);if(t){if(t.has(n))return n;for(let o of t.keys()){let i=o.lastIndexOf(".");if((i===-1?o:o.substring(i+1))===n)return o}}}getListItemPosition(e,n,t){let o=this.valueListItems.get(e)?.get(n);if(!(!o||t<0||t>=o.length))return o[t]}getNodeKeyPosition(e){return this.nestedKeys.get(JSON.stringify(e))}getNodeValuePosition(e){return this.nestedValues.get(JSON.stringify(e))}setNestedKeyPosition(e,n){this.nestedKeys.set(e,n)}setNestedValuePosition(e,n){this.nestedValues.set(e,n)}getMostSpecificPosition(e,n,t){if(e){if(n!==void 0){if(t!==void 0){let s=this.getListItemPosition(e,n,t);if(s)return s}let o=this.getPropertyValuePosition(e,n);if(o)return o;let i=this.getPropertyPosition(e,n);if(i)return i}return this.getEntityPosition(e)}}};function Y(r,e){let n=[];if(!b(r))return n;let t=r.items.find(o=>f(o)&&l(o.key)&&String(o.key.value)==="imports");if(!t||!f(t)||!j(t.value))return n;for(let o of t.value.items){if(!b(o))continue;let i=o.items.find(a=>f(a)&&l(a.key)&&String(a.key.value)==="publisher");if(!i||!f(i)||!l(i.value))continue;let s=String(i.value.value),u=o.items.find(a=>f(a)&&l(a.key)&&String(a.key.value)==="packages");if(!(!u||!f(u)||!j(u.value)))for(let a of u.value.items){if(!b(a))continue;let c=a.items.find(m=>f(m)&&l(m.key)&&String(m.key.value)==="package");if(!c||!f(c)||!l(c.value)||!c.value.range)continue;let k=String(c.value.value),d=a.items.find(m=>f(m)&&l(m.key)&&String(m.key.value)==="version"),p=d&&f(d)&&l(d.value)?String(d.value.value):"",y=a.items.find(m=>f(m)&&l(m.key)&&String(m.key.value)==="alias"),S=y&&f(y)&&l(y.value)?String(y.value.value):void 0,h=S!==void 0?{publisher:s,package_:k,version:p,alias:S,position:g(c.value.range,e)}:{publisher:s,package_:k,version:p,position:g(c.value.range,e)};n.push(h)}}return n}function C(r,e,n){return!(e<r.line||e>r.endLine||e===r.line&&n<r.column||e===r.endLine&&n>r.endColumn)}function q(r,e){let n=r.endLine-r.line,t=e.endLine-e.line;if(n!==t)return n<t;let o=r.endLine===r.line?r.endColumn-r.column:Number.MAX_SAFE_INTEGER,i=e.endLine===e.line?e.endColumn-e.column:Number.MAX_SAFE_INTEGER;return o<i}function O(r,e,n,t){if(b(r)){for(let o of r.items){if(!f(o)||!l(o.key))continue;let i=String(o.key.value),s=[...e,i],u=JSON.stringify(s);o.key.range&&t.setNestedKeyPosition(u,g(o.key.range,n));let a=o.value,c=z(a);c&&t.setNestedValuePosition(u,g(c,n)),O(a,s,n,t)}return}if(j(r)){for(let o=0;o<r.items.length;o++){let i=r.items[o],s=[...e,o],u=JSON.stringify(s),a=z(i);a&&t.setNestedValuePosition(u,g(a,n)),O(i,s,n,t)}return}}function z(r){if(!r||typeof r!="object"||!("range"in r))return;let e=r.range;return Array.isArray(e)&&e.length>=3?e:void 0}function g(r,e){let n=e.linePos(r[0]),t=e.linePos(r[2]);return{line:n.line-1,column:n.col-1,endLine:t.line-1,endColumn:t.col-1}}function Z(r,e){let t=(e??new E).parse(r),o=L.fromContent(r);return{document:t,positions:o}}function T(r,e,n,t,o){if(e<t.line||e>t.endLine||e===t.line&&n<t.column||e===t.endLine&&n>=t.endColumn)return;let i=M(o,t.line,t.column),s=M(o,t.endLine,t.endColumn);if(i<0||s<0)return;let u=o.substring(i,s),a=A(u);if(a.length!==r.links.length)return;let c=e-t.line,k=e===t.line?n-t.column:n,d=M(u,c,k);if(!(d<0))for(let p=0;p<a.length;p++){let y=a[p];if(d>=y.startOffset&&d<y.endOffset)return r.links[p]}}function G(r,e){let n=M(e,r.line,r.column),t=M(e,r.endLine,r.endColumn);if(n<0||t<0)return;let o=e.substring(n,t);return A(o).map(i=>{let s=F(e,n+i.startOffset),u=F(e,n+i.endOffset);return{line:s.line,column:s.column,endLine:u.line,endColumn:u.column}})}function F(r,e){let n=0,t=0;for(let o=0;o<e&&o<r.length;o++)r[o]===`
2
+ `&&(n++,t=o+1);return{line:n,column:e-t}}function M(r,e,n){let t=0,o=0;for(let i=0;i<r.length;i++){if(t===e)return Math.min(o+n,r.length);r[i]===`
3
+ `&&(t++,o=i+1)}return t===e?Math.min(o+n,r.length):-1}function ee(r,e,n){let t=[];for(let o of r){if(!(o instanceof V)||typeof o.sourceKey!="string")continue;let i=[o.sourceKey],s=$(o);s&&t.push({role:"subject",uri:s,range:w(e.getEntityPosition(o.sourceKey),i,"key"),path:i}),D(o.statement,i,e,n,t)}return t}function ne(r,e,n){let t;for(let o of r)te(o.range,e,n)&&(!t||oe(o.range,t.range))&&(t=o);return t}function D(r,e,n,t,o){for(let i of r){if(!(i instanceof U)||i.sourceKey===void 0)continue;let s=[...e,i.sourceKey],u=i.predicate?.subject;if(u&&o.push({role:"predicate",uri:u,range:w(n.getNodeKeyPosition(s),s,"key"),path:s}),i instanceof W)o.push({role:"reference",uri:i.object.subject,range:w(n.getNodeValuePosition(s),s,"value"),path:s});else if(i instanceof B)X(i.links,s,n,t,o);else if(i instanceof J)i.object&&D(i.object.statement,s,n,t,o);else if(i instanceof _)for(let a of i.object??[]){if(!(a instanceof N||a instanceof I||a instanceof x)||a.sourceKey===void 0)continue;let c=[...s,a.sourceKey];a instanceof N?o.push({role:"reference",uri:a.subject,range:w(n.getNodeValuePosition(c),c,"value"),path:c}):a instanceof I?D(a.statement,c,n,t,o):a.links&&X(a.links,c,n,t,o)}}}function X(r,e,n,t,o){if(t===void 0||r.length===0)return;let i=G(w(n.getNodeValuePosition(e),e,"value"),t);if(!i||i.length!==r.length)throw new Error(`sourceSymbols: the prose value at ${JSON.stringify(e)} has ${r.length} resolved [[reference]](s) but ${i?.length??0} in its source text \u2014 the source text is not the text this document was parsed from.`);r.forEach((s,u)=>{s.target&&o.push({role:"reference",uri:s.target.subject,range:i[u],path:e})})}function w(r,e,n){if(!r)throw new Error(`sourceSymbols: no source ${n} position for ${JSON.stringify(e)}. The object model has a node the position index does not \u2014 the positions were not built from the text this document was parsed from.`);return r}function te(r,e,n){return!(e<r.line||e>r.endLine||e===r.line&&n<r.column||e===r.endLine&&n>r.endColumn)}function oe(r,e){let n=r.endLine-r.line,t=e.endLine-e.line;return n!==t?n<t:r.endColumn-r.column<e.endColumn-e.column}export{R as a,L as b,Z as c,T as d,ee as e,ne as f};
@@ -0,0 +1 @@
1
+ import{i as b,o as A}from"./chunk-OOYGILH4.js";import{a as P}from"./chunk-6VIUXP4N.js";import{a as f}from"./chunk-7JBKOJB4.js";import{c as K,g as I,j as R}from"./chunk-QILEJIFU.js";import*as i from"fs/promises";import*as c from"path";import{pathToFileURL as F}from"url";var y=class{rootPath;recursive;parser;documentCache;filePathsByIdentifier;cacheInitialized=!1;cacheInitPromise=null;parsingErrors=new Map;constructor(e,t=!0,n){if(!e||e.trim().length===0)throw new Error("Root path cannot be null or empty");this.rootPath=c.resolve(e),this.recursive=t,this.parser=n??new f,this.documentCache=new Map,this.filePathsByIdentifier=new Map}async getAllDocumentsAsync(){await this.ensureCacheInitialized();let e=new Set(this.documentCache.values());return Array.from(e)}async getDocumentAsync(e){await this.ensureCacheInitialized();let t=this.documentCache.get(e);if(t)return t;let n=c.join(this.rootPath,e);if(t=this.documentCache.get(n),t)return t;for(let o of[".kan.yml",".yml",".yaml"])if(!e.endsWith(o)){let s=e+o;if(t=this.documentCache.get(s),t)return t;let a=c.join(this.rootPath,s);if(t=this.documentCache.get(a),t)return t}return null}async getDocumentsByNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values());return Array.from(n).filter(o=>o.metadata.namespace_?.publisher===e&&o.metadata.namespace_?.package_===t)}async getHighestCompatibleVersionAsync(e,t){await this.ensureCacheInitialized();let n=new Set(this.documentCache.values()),o=Array.from(n).filter(a=>a.metadata?.namespace_?.publisher===e&&a.metadata?.namespace_?.package_===t.packageName&&a.metadata?.namespace_?.version!==void 0);if(o.length===0)return null;let s=o.filter(a=>{let r=a.metadata.namespace_.version;return R(r,t)});return s.length===0?null:(s.sort((a,r)=>{let m=a.metadata.namespace_.version,p=r.metadata.namespace_.version;return K(p,m)}),s[0])}async saveDocumentAsync(e,t){let n,o=e.metadata.namespace_?.toString();if(o&&o.includes("@")&&o.includes("/")){let m=o.split("/"),p=m[0],h=m[1].replace("@","@")+".kan.yml";n=c.join(this.rootPath,p,h)}else n=c.join(this.rootPath,t),!n.endsWith(".yml")&&!n.endsWith(".yaml")&&!n.endsWith(".kan.yml")&&(n+=".kan.yml");let s=c.dirname(n);await i.mkdir(s,{recursive:!0});let a=this.parser.save(e);await i.writeFile(n,a,"utf8"),o&&this.documentCache.set(o,e),this.documentCache.set(n,e);let r=c.relative(this.rootPath,n);this.documentCache.set(r,e)}async deleteDocumentAsync(e){let t=await this.getDocumentAsync(e);if(!t)return;let n=this.filePathsByIdentifier.get(e);if(!n)return;try{await i.unlink(n)}catch{}let o=t.metadata.namespace_?.toString();o&&this.documentCache.delete(o),this.documentCache.delete(e),this.documentCache.delete(n);let s=c.relative(this.rootPath,n);this.documentCache.delete(s)}async clearNamespaceAsync(e,t){await this.ensureCacheInitialized();let n=[];for(let[s,a]of this.documentCache.entries()){let r=a.metadata.namespace_?.toString()||"";r.includes(e)&&r.includes(t)&&n.push([s,a])}let o=c.join(this.rootPath,e);try{let s=await i.readdir(o);for(let a of s)a.includes(t)&&a.endsWith(".kan.yml")&&await i.unlink(c.join(o,a))}catch{}for(let[s]of n)this.documentCache.delete(s)}async getAllDocumentReferencesAsync(){await this.ensureCacheInitialized();let e=new Set(this.filePathsByIdentifier.values()),t=[];for(let n of e){let o=F(n).toString(),s;for(let[m,p]of this.documentCache.entries())if(this.filePathsByIdentifier.get(m)===n&&p.metadata.namespace_){s=p.metadata.namespace_.toString();break}let a=s??c.relative(this.rootPath,n),r=this.parsingErrors.has(n);t.push({identifier:a,uri:o,hasParseError:r})}return t}async getDocumentContentAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await i.access(e),t=e}catch{let n=c.join(this.rootPath,e);try{await i.access(n),t=n}catch{return null}}try{return await i.readFile(t,"utf8")}catch{return null}}async getDocumentUriAsync(e){await this.ensureCacheInitialized();let t=this.filePathsByIdentifier.get(e);if(!t)try{await i.access(e),t=e}catch{let n=c.join(this.rootPath,e);try{await i.access(n),t=n}catch{return null}}return F(t).toString()}async refreshAsync(){this.documentCache.clear(),this.filePathsByIdentifier.clear(),this.parsingErrors.clear(),this.cacheInitialized=!1,this.cacheInitPromise=null,await this.ensureCacheInitialized()}async ensureCacheInitialized(){if(!this.cacheInitialized){if(this.cacheInitPromise){await this.cacheInitPromise;return}this.cacheInitPromise=this.loadDocuments(),await this.cacheInitPromise,this.cacheInitialized=!0}}async loadDocuments(){try{await i.mkdir(this.rootPath,{recursive:!0})}catch{}let t=(await this.findYamlFiles(this.rootPath,this.recursive)).map(async o=>{try{let s=await i.readFile(o,"utf8"),a=this.parser.parse(s);return{filePath:o,document:a,error:null}}catch(s){return{filePath:o,document:null,error:s instanceof Error?s.message:String(s)}}}),n=await Promise.all(t);for(let{filePath:o,document:s,error:a}of n){let r=c.relative(this.rootPath,o);if(s&&s.metadata.namespace_){let m=s.metadata.namespace_.toString();this.documentCache.set(m,s),this.documentCache.set(o,s),this.documentCache.set(r,s),this.filePathsByIdentifier.set(m,o),this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o)}else this.filePathsByIdentifier.set(o,o),this.filePathsByIdentifier.set(r,o);a&&this.parsingErrors.set(o,a)}}async findYamlFiles(e,t){let n=[];try{let o=await i.readdir(e,{withFileTypes:!0});for(let s of o){let a=c.join(e,s.name);if(s.isDirectory()&&t){let r=await this.findYamlFiles(a,t);n.push(...r)}else s.isFile()&&s.name.endsWith(".kan.yml")&&n.push(a)}}catch{}return n}};import*as g from"fs";var S=(n=>(n.NotFound="NotFound",n.Workspace="Workspace",n.Cache="Cache",n))(S||{}),D=class{cache;workspace;constructor(e,t,n){let o=n??new f;g.existsSync(e)||g.mkdirSync(e,{recursive:!0}),g.existsSync(t)||g.mkdirSync(t,{recursive:!0}),this.cache=new y(e,!0,o),this.workspace=new y(t,!0,o)}getCache(){return this.cache}getWorkspace(){return this.workspace}async getAllDocumentsAsync(){let e=await this.workspace.getAllDocumentsAsync(),t=await this.cache.getAllDocumentsAsync(),n=new Map;for(let o of t)if(o.metadata.namespace_){let s=o.metadata.namespace_.toString();n.set(s,o)}for(let o of e)if(o.metadata.namespace_){let s=o.metadata.namespace_.toString();n.set(s,o)}return Array.from(n.values())}async getDocumentAsync(e){let t=await this.workspace.getDocumentAsync(e);return t||await this.cache.getDocumentAsync(e)}async getDocumentsByNamespaceAsync(e,t){let n=await this.workspace.getDocumentsByNamespaceAsync(e,t),o=await this.cache.getDocumentsByNamespaceAsync(e,t),s=new Map;for(let a of o)if(a.metadata.namespace_?.version){let r=a.metadata.namespace_.version.toString();s.set(r,a)}for(let a of n)if(a.metadata.namespace_?.version){let r=a.metadata.namespace_.version.toString();s.set(r,a)}return Array.from(s.values())}async getHighestCompatibleVersionAsync(e,t){let n=await this.workspace.getHighestCompatibleVersionAsync(e,t);return n||await this.cache.getHighestCompatibleVersionAsync(e,t)}async saveDocumentAsync(e,t){await this.workspace.saveDocumentAsync(e,t)}async saveToCacheAsync(e,t){await this.cache.saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.workspace.deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.workspace.clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){let e=await this.workspace.getAllDocumentReferencesAsync(),t=await this.cache.getAllDocumentReferencesAsync(),n=[];return n.push(...e),n.push(...t),n}async getDocumentContentAsync(e){let t=await this.workspace.getDocumentContentAsync(e);return t||await this.cache.getDocumentContentAsync(e)}async getDocumentUriAsync(e){let t=await this.workspace.getDocumentUriAsync(e);return t||await this.cache.getDocumentUriAsync(e)}async getDocumentLocationAsync(e){return await this.workspace.getDocumentAsync(e)?"Workspace":await this.cache.getDocumentAsync(e)?"Cache":"NotFound"}};import{homedir as _}from"os";import{join as H}from"path";function d(){let u=process.env.KANONAK_PACKAGE_CACHE;return u||H(_(),".kanonak","packages")}var w=class u{static createComposite(e,t,n){let o=e??d(),s=t??".";return new D(o,s,n)}static createFromEnvironment(e){let t=d(),n=process.env.KANONAK_WORKSPACE_PATH??".";return u.createComposite(t,n,e)}};var k=class{repos;constructor(...e){this.repos=e}async getHighestCompatibleVersionAsync(e,t){for(let n of this.repos)try{let o=await n.getHighestCompatibleVersionAsync(e,t);if(o)return o}catch{}return null}async getAllDocumentsAsync(){let e=[],t=new Set;for(let n of this.repos)try{for(let o of await n.getAllDocumentsAsync()){let s=o.metadata?.namespace_,a=s?s.version?`${s.publisher}/${s.package_}@${s.version.major}.${s.version.minor}.${s.version.patch}`:`${s.publisher}/${s.package_}`:void 0;if(a!==void 0){if(t.has(a))continue;t.add(a)}e.push(o)}}catch{}return e}async getDocumentAsync(e){for(let t of this.repos)try{let n=await t.getDocumentAsync(e);if(n)return n}catch{}return null}async getDocumentsByNamespaceAsync(e,t){for(let n of this.repos)try{let o=await n.getDocumentsByNamespaceAsync(e,t);if(o.length>0)return o}catch{}return[]}async saveDocumentAsync(e,t){await this.repos[0].saveDocumentAsync(e,t)}async deleteDocumentAsync(e){await this.repos[0].deleteDocumentAsync(e)}async clearNamespaceAsync(e,t){await this.repos[0].clearNamespaceAsync(e,t)}async getAllDocumentReferencesAsync(){return this.repos[0].getAllDocumentReferencesAsync()}async getDocumentContentAsync(e){for(let t of this.repos)try{let n=await t.getDocumentContentAsync(e);if(n)return n}catch{}return null}async getDocumentUriAsync(e){for(let t of this.repos)try{let n=await t.getDocumentUriAsync(e);if(n)return n}catch{}return null}};import{VersionOperator as N}from"@kanonak-protocol/types/document/models/enums";var v=class{constructor(e,t){this.base=e;this.lock=t}base;lock;pinnedVersion(e,t){return b(this.lock,e,t)}async getHighestCompatibleVersionAsync(e,t){let n=this.pinnedVersion(e,t.packageName);if(n){let o=I(n);if(o){let s={...t,versionOperator:N.Exact,version:o};return this.base.getHighestCompatibleVersionAsync(e,s)}}return this.base.getHighestCompatibleVersionAsync(e,t)}async getDocumentsByNamespaceAsync(e,t){let n=await this.base.getDocumentsByNamespaceAsync(e,t),o=this.pinnedVersion(e,t);return o?n.filter(s=>{let a=s.metadata.namespace_?.version;return a?`${a.major}.${a.minor}.${a.patch}`===o:!1}):n}getAllDocumentsAsync(){return this.base.getAllDocumentsAsync()}getDocumentAsync(e){return this.base.getDocumentAsync(e)}saveDocumentAsync(e,t){return this.base.saveDocumentAsync(e,t)}deleteDocumentAsync(e){return this.base.deleteDocumentAsync(e)}clearNamespaceAsync(e,t){return this.base.clearNamespaceAsync(e,t)}getAllDocumentReferencesAsync(){return this.base.getAllDocumentReferencesAsync()}getDocumentContentAsync(e){return this.base.getDocumentContentAsync(e)}getDocumentUriAsync(e){return this.base.getDocumentUriAsync(e)}};import{readFileSync as B,readdirSync as V}from"fs";import{join as x}from"path";var $=new Set(["node_modules",".kanonak",".git","_site","build",".stage"]);function C(u,e=[]){for(let t of V(u,{withFileTypes:!0}))t.isDirectory()?$.has(t.name)||C(x(u,t.name),e):t.name.endsWith(".kan.yml")&&e.push(x(u,t.name));return e}async function j(u,e=new f,t={}){let n=new P(e);for(let m of C(u))try{let p=e.parse(B(m,"utf-8")),l=p.metadata?.namespace_,h=l?.version;l&&h&&await n.saveDocumentAsync(p,`${l.publisher}/${l.package_}@${h.major}.${h.minor}.${h.patch}`)}catch{}let o=new y(d(),!0,e);if(t.offline)return new k(n,o);let s=new Map,a=t.httpCache??{getFromCache:(m,p,l)=>s.get(`${m}|${p}|${l}`)??null,onFetch:(m,p,l,h)=>{s.set(`${m}|${p}|${l}`,h)}},r=new A({getFromCache:a.getFromCache,onFetch:a.onFetch});return new k(n,o,r)}export{y as a,S as b,D as c,d,w as e,k as f,v as g,C as h,j as i};
@@ -1,2 +1,2 @@
1
- import{e as R}from"./chunk-BZ3YTI3C.js";import{j as G}from"./chunk-Q2FG7DME.js";import{ka as S,na as j}from"./chunk-7TU55KLO.js";import{c as N,o as F}from"./chunk-XNEWQEB6.js";var z=(r=>(r.Class="Class",r.DatatypeProperty="DatatypeProperty",r.ObjectProperty="ObjectProperty",r.AnnotationProperty="AnnotationProperty",r.Instance="Instance",r.Datatype="Datatype",r.Shape="Shape",r.Unknown="Unknown",r))(z||{}),L=(r=>(r.InstanceOf="instanceOf",r.SubClassOf="subClassOf",r.Domain="domain",r.Range="range",r.ObjectRelationship="objectRelationship",r.SubPropertyOf="subPropertyOf",r.PropertyValue="propertyValue",r.EmbeddedLink="embeddedLink",r))(L||{}),$=class{static async buildFromRepository(e,n){let i=await new G().parseKanonaks(e),s=await e.getAllDocumentsAsync(),p=[],a=[],r=new Set,d=new Set,y=new Map;for(let f of i){let c=f;if(c.name&&(S.isClassType(c)&&r.add(c.name),f instanceof N)){let l=j(i,f);(l==="ObjectProperty"||l==="Property")&&d.add(c.name)}}for(let f of s)for(let[c,l]of Object.entries(f.body))d.has(c)&&l?.range&&typeof l.range=="string"&&y.set(c,l.range);let g=new Map;for(let f of i){let c=f;c.name&&g.set(c.name,c)}for(let f of s){let c=f.metadata.namespace_,l=c?`${c.publisher}/${c.package_}`:"",m=c?.version?`${c.version.major}.${c.version.minor}.${c.version.patch}`:"",O=U(f);for(let[h,u]of Object.entries(f.body)){if(!u||typeof u!="object")continue;let b=g.get(h),k="Unknown";if(b){let T=b,A=b instanceof N?j(i,b):void 0;S.isClassType(T)?k="Class":A==="ObjectProperty"?k="ObjectProperty":A==="DatatypeProperty"?k="DatatypeProperty":A==="AnnotationProperty"?k="AnnotationProperty":S.isDatatypeType(T)?k="Datatype":A==="Property"?k="ObjectProperty":S.isShapeType(T)?k="Shape":S.isInstanceOfKnownClass(T,r)&&(k="Instance")}let P=l&&m?`${l}/${h}@${m}`:h,I={};for(let[T,A]of Object.entries(u))T!=="type"&&(typeof A!="object"||A===null)&&(I[T]=A);p.push({id:P,label:u.label??h,type:k,namespace:l,properties:I}),K(P,u,k,r,d,a,l,m,O,n),D(P,u,d,y,p,a,l,m,O),Q(P,b,a)}}return{nodes:p,edges:a}}static buildFromDocument(e,n){let o=[],i=[],s=e.metadata.namespace_,p=s?.version?`${s.version.major}.${s.version.minor}.${s.version.patch}`:"",a=s?`${s.publisher}/${s.package_}`:"",r=new Set,d=new Set,y=new Map,g=U(e);for(let[l,m]of Object.entries(e.body)){let O=m?.type;O&&(Y(O,g)&&r.add(l),J(O,g)&&(d.add(l),m.range&&typeof m.range=="string"&&y.set(l,m.range)))}for(let[l,m]of Object.entries(e.body)){if(!m||typeof m!="object")continue;let O=m.type,h=X(O,l,r,g),u=a&&p?`${a}/${l}@${p}`:l,b={};for(let[k,P]of Object.entries(m))k!=="type"&&(typeof P!="object"||P===null)&&(b[k]=P);o.push({id:u,label:m.label??l,type:h,namespace:a,properties:b}),K(u,m,h,r,d,i,a,p,g,n),D(u,m,d,y,o,i,a,p,g)}let f=new Set(o.map(l=>l.id)),c=i.filter(l=>f.has(l.source)&&f.has(l.target));return{nodes:o,edges:c}}};function U(t,e){let n=new Map;if(t.metadata?.imports)for(let[o,i]of Object.entries(t.metadata.imports))for(let s of i){let p=s.alias??s.packageName,a=s.version,r=`${a.major}.${a.minor}.${a.patch}`;n.set(p,{publisher:o,package_:s.packageName,version:r})}return n}var B={"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"},W=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function M(t,e){if(t.includes(".")){let n=t.indexOf("."),o=t.substring(0,n),i=t.substring(n+1),s=e.get(o);if(s)return`${s.publisher}/${s.package_}/${i}`}return null}function Y(t,e){let n=M(t,e);return n?B[n]==="Class":!1}function J(t,e){let n=M(t,e);return n?W.has(n):!1}function X(t,e,n,o){if(!t||t==="Package")return"Unknown";let i=M(t,o);if(i){let p=B[i];if(p)return p;let a=i.split("/").pop()?.split("@")[0]??"";return n.has(a)?"Instance":"Unknown"}let s=t.split(".").pop()??t;return n.has(s)?"Instance":"Unknown"}var V=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function K(t,e,n,o,i,s,p,a,r,d){let y=e.type,g=e.subClassOf;if(g){let h=Array.isArray(g)?g:[g];for(let u of h)typeof u=="string"&&s.push({source:t,target:v(u,p,a,r),type:"subClassOf",label:"subClassOf"})}let f=e.subPropertyOf;if(f){let h=Array.isArray(f)?f:[f];for(let u of h)typeof u=="string"&&s.push({source:t,target:v(u,p,a,r),type:"subPropertyOf",label:"subPropertyOf"})}let c=e.domain,l=e.range;if(d?.includePropertyEdges){let h=[[c,"domain","domain"],[l,"range","range"]];for(let[u,b,k]of h)if(u!=null)for(let P of Array.isArray(u)?u:[u])typeof P=="string"&&s.push({source:t,target:v(P,p,a,r),type:b,label:k})}if(n==="Instance"&&y){let h=y.split(".").pop()??y;s.push({source:t,target:v(h,p,a,r),type:"instanceOf",label:"type"})}if(n==="Instance")for(let[h,u]of Object.entries(e)){if(V.has(h)||!i.has(h))continue;let b=Array.isArray(u)?u:[u];for(let k of b)typeof k=="string"&&Z(k)&&s.push({source:t,target:v(k,p,a,r),type:"propertyValue",label:h,propertyId:v(h,p,a,r)})}if((n==="ObjectProperty"||n==="DatatypeProperty"||c&&l)&&c&&l){let h=typeof c=="string"?c:null,u=typeof l=="string"?l:null;h&&u&&s.push({source:v(h,p,a,r),target:v(u,p,a,r),type:"objectRelationship",label:e.label??t.split("/").pop()??"",propertyId:t})}}function D(t,e,n,o,i,s,p,a,r){for(let[d,y]of Object.entries(e)){if(V.has(d)||typeof y!="object"||y===null||Array.isArray(y))continue;let g=y,f=`${t}/${d}`,c=o.get(d),l=c?c.split(".").pop()??c:"Unknown",m={};for(let[h,u]of Object.entries(g))(typeof u!="object"||u===null)&&(m[h]=u);i.push({id:f,label:`${l} (embedded)`,type:"Instance",namespace:p,properties:m});let O=p&&a?`${p}/${d}@${a}`:d;s.push({source:t,target:f,type:"propertyValue",label:d,propertyId:n.has(d)?O:void 0}),c&&s.push({source:f,target:v(l,p,a,r),type:"instanceOf",label:"type (inferred)"}),D(f,g,n,o,i,s,p,a,r)}}function Q(t,e,n){let o=e?.statement;if(Array.isArray(o))for(let i of o){if(!(i instanceof F))continue;let s=i.predicate?.subject?.name??"";for(let p of i.links){let a=p.target?.subject;if(!a)continue;let r=a.version,d=r&&typeof r.major=="number"?`@${r.major}.${r.minor}.${r.patch}`:"";n.push({source:t,target:`${a.publisher}/${a.package_}/${a.name}${d}`,type:"embeddedLink",label:s})}}}function Z(t){return!(!t||t.includes(" ")||t.includes(`
1
+ import{e as R}from"./chunk-OOYGILH4.js";import{k as G}from"./chunk-22DSABP6.js";import{ma as S,pa as j}from"./chunk-NUTHBBDZ.js";import{c as N,o as F}from"./chunk-D4QGPMRW.js";var z=(r=>(r.Class="Class",r.DatatypeProperty="DatatypeProperty",r.ObjectProperty="ObjectProperty",r.AnnotationProperty="AnnotationProperty",r.Instance="Instance",r.Datatype="Datatype",r.Shape="Shape",r.Unknown="Unknown",r))(z||{}),L=(r=>(r.InstanceOf="instanceOf",r.SubClassOf="subClassOf",r.Domain="domain",r.Range="range",r.ObjectRelationship="objectRelationship",r.SubPropertyOf="subPropertyOf",r.PropertyValue="propertyValue",r.EmbeddedLink="embeddedLink",r))(L||{}),$=class{static async buildFromRepository(e,n){let i=await new G().parseKanonaks(e),s=await e.getAllDocumentsAsync(),p=[],a=[],r=new Set,d=new Set,y=new Map;for(let f of i){let c=f;if(c.name&&(S.isClassType(c)&&r.add(c.name),f instanceof N)){let l=j(i,f);(l==="ObjectProperty"||l==="Property")&&d.add(c.name)}}for(let f of s)for(let[c,l]of Object.entries(f.body))d.has(c)&&l?.range&&typeof l.range=="string"&&y.set(c,l.range);let g=new Map;for(let f of i){let c=f;c.name&&g.set(c.name,c)}for(let f of s){let c=f.metadata.namespace_,l=c?`${c.publisher}/${c.package_}`:"",m=c?.version?`${c.version.major}.${c.version.minor}.${c.version.patch}`:"",O=U(f);for(let[h,u]of Object.entries(f.body)){if(!u||typeof u!="object")continue;let b=g.get(h),k="Unknown";if(b){let T=b,A=b instanceof N?j(i,b):void 0;S.isClassType(T)?k="Class":A==="ObjectProperty"?k="ObjectProperty":A==="DatatypeProperty"?k="DatatypeProperty":A==="AnnotationProperty"?k="AnnotationProperty":S.isDatatypeType(T)?k="Datatype":A==="Property"?k="ObjectProperty":S.isShapeType(T)?k="Shape":S.isInstanceOfKnownClass(T,r)&&(k="Instance")}let P=l&&m?`${l}/${h}@${m}`:h,I={};for(let[T,A]of Object.entries(u))T!=="type"&&(typeof A!="object"||A===null)&&(I[T]=A);p.push({id:P,label:u.label??h,type:k,namespace:l,properties:I}),K(P,u,k,r,d,a,l,m,O,n),D(P,u,d,y,p,a,l,m,O),Q(P,b,a)}}return{nodes:p,edges:a}}static buildFromDocument(e,n){let o=[],i=[],s=e.metadata.namespace_,p=s?.version?`${s.version.major}.${s.version.minor}.${s.version.patch}`:"",a=s?`${s.publisher}/${s.package_}`:"",r=new Set,d=new Set,y=new Map,g=U(e);for(let[l,m]of Object.entries(e.body)){let O=m?.type;O&&(Y(O,g)&&r.add(l),J(O,g)&&(d.add(l),m.range&&typeof m.range=="string"&&y.set(l,m.range)))}for(let[l,m]of Object.entries(e.body)){if(!m||typeof m!="object")continue;let O=m.type,h=X(O,l,r,g),u=a&&p?`${a}/${l}@${p}`:l,b={};for(let[k,P]of Object.entries(m))k!=="type"&&(typeof P!="object"||P===null)&&(b[k]=P);o.push({id:u,label:m.label??l,type:h,namespace:a,properties:b}),K(u,m,h,r,d,i,a,p,g,n),D(u,m,d,y,o,i,a,p,g)}let f=new Set(o.map(l=>l.id)),c=i.filter(l=>f.has(l.source)&&f.has(l.target));return{nodes:o,edges:c}}};function U(t,e){let n=new Map;if(t.metadata?.imports)for(let[o,i]of Object.entries(t.metadata.imports))for(let s of i){let p=s.alias??s.packageName,a=s.version,r=`${a.major}.${a.minor}.${a.patch}`;n.set(p,{publisher:o,package_:s.packageName,version:r})}return n}var B={"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"},W=new Set(["kanonak.org/core-owl/ObjectProperty","kanonak.org/core-owl/DatatypeProperty","kanonak.org/core-owl/AnnotationProperty","kanonak.org/core-rdf/Property"]);function M(t,e){if(t.includes(".")){let n=t.indexOf("."),o=t.substring(0,n),i=t.substring(n+1),s=e.get(o);if(s)return`${s.publisher}/${s.package_}/${i}`}return null}function Y(t,e){let n=M(t,e);return n?B[n]==="Class":!1}function J(t,e){let n=M(t,e);return n?W.has(n):!1}function X(t,e,n,o){if(!t||t==="Package")return"Unknown";let i=M(t,o);if(i){let p=B[i];if(p)return p;let a=i.split("/").pop()?.split("@")[0]??"";return n.has(a)?"Instance":"Unknown"}let s=t.split(".").pop()??t;return n.has(s)?"Instance":"Unknown"}var V=new Set(["type","label","comment","version","publisher","imports","license","match","alias","package"]);function K(t,e,n,o,i,s,p,a,r,d){let y=e.type,g=e.subClassOf;if(g){let h=Array.isArray(g)?g:[g];for(let u of h)typeof u=="string"&&s.push({source:t,target:v(u,p,a,r),type:"subClassOf",label:"subClassOf"})}let f=e.subPropertyOf;if(f){let h=Array.isArray(f)?f:[f];for(let u of h)typeof u=="string"&&s.push({source:t,target:v(u,p,a,r),type:"subPropertyOf",label:"subPropertyOf"})}let c=e.domain,l=e.range;if(d?.includePropertyEdges){let h=[[c,"domain","domain"],[l,"range","range"]];for(let[u,b,k]of h)if(u!=null)for(let P of Array.isArray(u)?u:[u])typeof P=="string"&&s.push({source:t,target:v(P,p,a,r),type:b,label:k})}if(n==="Instance"&&y){let h=y.split(".").pop()??y;s.push({source:t,target:v(h,p,a,r),type:"instanceOf",label:"type"})}if(n==="Instance")for(let[h,u]of Object.entries(e)){if(V.has(h)||!i.has(h))continue;let b=Array.isArray(u)?u:[u];for(let k of b)typeof k=="string"&&Z(k)&&s.push({source:t,target:v(k,p,a,r),type:"propertyValue",label:h,propertyId:v(h,p,a,r)})}if((n==="ObjectProperty"||n==="DatatypeProperty"||c&&l)&&c&&l){let h=typeof c=="string"?c:null,u=typeof l=="string"?l:null;h&&u&&s.push({source:v(h,p,a,r),target:v(u,p,a,r),type:"objectRelationship",label:e.label??t.split("/").pop()??"",propertyId:t})}}function D(t,e,n,o,i,s,p,a,r){for(let[d,y]of Object.entries(e)){if(V.has(d)||typeof y!="object"||y===null||Array.isArray(y))continue;let g=y,f=`${t}/${d}`,c=o.get(d),l=c?c.split(".").pop()??c:"Unknown",m={};for(let[h,u]of Object.entries(g))(typeof u!="object"||u===null)&&(m[h]=u);i.push({id:f,label:`${l} (embedded)`,type:"Instance",namespace:p,properties:m});let O=p&&a?`${p}/${d}@${a}`:d;s.push({source:t,target:f,type:"propertyValue",label:d,propertyId:n.has(d)?O:void 0}),c&&s.push({source:f,target:v(l,p,a,r),type:"instanceOf",label:"type (inferred)"}),D(f,g,n,o,i,s,p,a,r)}}function Q(t,e,n){let o=e?.statement;if(Array.isArray(o))for(let i of o){if(!(i instanceof F))continue;let s=i.predicate?.subject?.name??"";for(let p of i.links){let a=p.target?.subject;if(!a)continue;let r=a.version,d=r&&typeof r.major=="number"?`@${r.major}.${r.minor}.${r.patch}`:"";n.push({source:t,target:`${a.publisher}/${a.package_}/${a.name}${d}`,type:"embeddedLink",label:s})}}}function Z(t){return!(!t||t.includes(" ")||t.includes(`
2
2
  `)||t.startsWith("http://")||t.startsWith("https://")||/^\d{4}-\d{2}/.test(t)||/^\d+(\.\d+)?$/.test(t))}function v(t,e,n,o){if(t.includes("@")&&t.includes("/"))return t;if(t.includes(".")){let i=t.indexOf("."),s=t.substring(0,i),p=t.substring(i+1);if(o){let a=o.get(s);if(a)return`${a.publisher}/${a.package_}/${p}@${a.version}`}return e&&n?`${e}/${p}@${n}`:p}return e&&n?`${e}/${t}@${n}`:t}function _(t){let e=t.replace(/^https?:\/\//,"").replace(/^git:\/\//,"").replace(/\/+$/,"").trim();if(!e)throw new Error("Publisher host cannot be empty");return e}var ee="key_thumbprint",E=class{cache=new Map;prCache=new Map;async discoverProtectedResource(e){let n=_(e);if(this.prCache.has(n))return this.prCache.get(n);let o=`https://${n}/.well-known/oauth-protected-resource`,i=await te(o),s=i&&Array.isArray(i.authorization_servers)?i.authorization_servers.filter(a=>typeof a=="string"):[],p=s.length>0?s:null;return this.prCache.set(n,p),p}async discover(e){let n=_(e);if(this.cache.has(n))return this.cache.get(n);let o=`https://${n}/.well-known/oauth-authorization-server`,i=await this.tryEndpoint(o);if(!i){let s=`https://${n}/.well-known/openid-configuration`;i=await this.tryEndpoint(s)}return this.cache.set(n,i),i}async supportsOAuth(e){return await this.discover(e)!==null}static supportsPkceS256(e){return e.codeChallengeMethodsSupported?.some(n=>n.toUpperCase()==="S256")??!1}static supportsDynamicRegistration(e){return!!e.registrationEndpoint}static supportsAuthorizationCode(e){return e.responseTypesSupported?.some(n=>n.toLowerCase()==="code")??!1}static supportsEnrollment(e){return!!e.enrollmentEndpoint}static supportsSession(e){return!!e.sessionEndpoint}async tryEndpoint(e){let n;try{n=await fetch(e)}catch(i){let s=i instanceof Error?i.message:String(i);return s.includes("ENOTFOUND")||s.includes("ECONNREFUSED")?(console.error(` OAuth discovery: ${e} \u2014 host unreachable (${s})`),console.error(" If the server is behind a VPN, ensure you are connected.")):s.includes("CERT")||s.includes("SSL")||s.includes("TLS")?(console.error(` OAuth discovery: ${e} \u2014 TLS error (${s})`),console.error(" If using a custom CA certificate, set NODE_EXTRA_CA_CERTS=/path/to/ca.pem")):console.error(` OAuth discovery: ${e} \u2014 network error: ${s}`),null}if(!n.ok)return n.status===404||(n.status===403?(console.error(` OAuth discovery: ${e} \u2014 HTTP 403 Forbidden`),console.error(" Access may be blocked by a firewall, proxy, or WAF.")):n.status>=500&&(console.error(` OAuth discovery: ${e} \u2014 HTTP ${n.status} server error`),console.error(" The authorization server returned an internal error. Contact your IDP administrator."))),null;let o;try{o=await n.json()}catch{return console.error(` OAuth discovery: ${e} \u2014 response is not valid JSON`),console.error(" The endpoint may be returning HTML instead of JSON. Check IDP configuration."),null}return{issuer:C(o.issuer),authorizationEndpoint:C(o.authorization_endpoint),tokenEndpoint:C(o.token_endpoint),registrationEndpoint:C(o.registration_endpoint),revocationEndpoint:C(o.revocation_endpoint),scopesSupported:w(o.scopes_supported),responseTypesSupported:w(o.response_types_supported),grantTypesSupported:w(o.grant_types_supported),codeChallengeMethodsSupported:w(o.code_challenge_methods_supported),tokenEndpointAuthMethodsSupported:w(o.token_endpoint_auth_methods_supported),dpopSigningAlgValuesSupported:w(o.dpop_signing_alg_values_supported),enrollmentEndpoint:C(o.enrollment_endpoint),enrollmentIssuanceProtocols:w(o.enrollment_issuance_protocols),enrollmentKeyTypes:w(o.enrollment_key_types),enrollmentScopesSupported:w(o.enrollment_scopes_supported),enrollmentConsentBindingParam:C(o.enrollment_consent_binding_param),sessionEndpoint:C(o.session_endpoint),sessionEndpointAuthMethod:C(o.session_endpoint_auth_method)}}};async function te(t){try{let e=await fetch(t);return e.ok?await e.json():null}catch{return null}}function C(t){return typeof t=="string"?t:null}function w(t){return Array.isArray(t)?t.filter(e=>typeof e=="string"):null}function H(t){let e=t.headers.get("WWW-Authenticate")??void 0,n=t.headers.get("DPoP-Nonce")??void 0;if(!e&&!n)return;let o={wwwAuthenticate:e??""};if(n&&(o.nonce=n),e){let i=e.match(/acr_values\s*=\s*"([^"]*)"/i);i&&(o.acrValues=i[1])}return o}function ne(t){try{return new URL(t).host}catch{return null}}function re(t,e={}){let n=e.discovery??new E,o=new Map,i=new Map,s=async r=>{let d=o.get(r);if(d!==void 0)return d;let y=null,g=await n.discoverProtectedResource(r).catch(()=>null);return g&&g.length>0&&(y=ne(g[0])),o.set(r,y),y},p=async(r,d)=>{if(!t)return null;if(!(d.forceRefresh||d.challenge)&&i.has(r))return i.get(r);let g=await t.resolve(r,d).catch(()=>null);return i.set(r,g),g},a=async(r,d,y,g)=>{let f=await s(d);if(!f)return{res:await R(r,{method:y,redirect:"manual"}),authed:!1};let c=await p(f,{method:y,url:r,...g}),l=c?.headers??{};return{res:await R(r,{method:y,redirect:"manual",headers:l}),authed:!!c}};return async(r,d,y="GET")=>{let g=await a(r,d,y,{});if((g.res.status===401||g.res.status===403)&&g.authed){let f=H(g.res),c={forceRefresh:f===void 0};return f&&(c.challenge=f),(await a(r,d,y,c)).res}return g.res}}var q="KANONAK_TOKEN";function oe(){return typeof process<"u"&&process.env?process.env:{}}function se(t){return`${q}_${t.toUpperCase().replace(/[^A-Z0-9]+/g,"_")}`}var x=class{tokens;env;constructor(e={}){this.tokens=e.tokens??{},this.env=e.env??oe()}async resolve(e,n){let o=_(e),i=this.tokens[o]??this.env[se(o)]??this.env[q];return i?{headers:{Authorization:`Bearer ${i}`}}:null}};export{z as a,L as b,$ as c,_ as d,ee as e,E as f,H as g,re as h,x as i};
@@ -0,0 +1 @@
1
+ import{A as v,E as L,F as Q,c as B,d as G,p as X,r as S,s as Y,u as q,v as I,z as W}from"./chunk-D4QGPMRW.js";import{a as x}from"./chunk-FUUTGGJS.js";import{b as H}from"./chunk-F67UH4FD.js";var z=class{cache=new Map;repository;logger;constructor(e,n){this.repository=e,this.logger=n}async resolveEntityAsync(e,n){let o=n.metadata?.namespace_?.toString()??"unknown",s=this.cache.get(o);if(s){let i=s.get(e);if(i)return i}let a=await this.buildEntityIndexAsyncInternal(n,new Set,"",new Map);return this.cache.set(o,a),a.get(e)??null}async resolveAllEntitiesAsync(e,n){let o=await this.buildAllEntitiesIndexAsync(n,new Set,"");if(e.includes(".")){let s=e.split("."),a=s[0],i=s[1],y=await this.findDocumentForAlias(n,a);return y?await this.resolveAllEntitiesAsync(i,y):[]}return o.filter(s=>s.entityName===e)}async buildAllEntitiesIndexAsync(e,n,o){let s=[],a=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building ALL entities index for namespace: ${a}`),n.has(a))return this.logger?.debug?.(`Skipping ${a} - already visited (circular import prevention)`),s;n.add(a);let i=o.length===0?a:`${o} \u2192 ${a}`;for(let[y,l]of Object.entries(e.body))if(!y.includes(".")&&l&&typeof l=="object"&&!Array.isArray(l)){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};s.push({entityName:y,uri:new x(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,y,g),entity:l,definedInNamespace:a,isImported:o.length>0,importPath:i})}if(this.logger?.debug?.(`Collected ${s.length} entities from ${a}`),e.metadata?.imports){let y=Object.values(e.metadata.imports).reduce((l,g)=>l+g.length,0);this.logger?.debug?.(`Processing ${y} import(s) for ${a}`);for(let[l,g]of Object.entries(e.metadata.imports))for(let d of g)if(!H(d))try{this.logger?.debug?.(`Resolving import: ${l}/${d.packageName}`);let m=await this.repository.getHighestCompatibleVersionAsync(l,d);if(m){this.logger?.debug?.(`Successfully loaded import: ${m.metadata?.namespace_?.toString()}`);let k=await this.buildAllEntitiesIndexAsync(m,n,i);s.push(...k),this.logger?.debug?.(`Added ${k.length} entities from import ${m.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${l}/${d.packageName}`)}catch(m){let k=m;throw this.logger?.error?.(`Failed to process import ${l}/${d.packageName} for namespace ${a}. Error: ${k.message}`,k),new Error(`Failed to process import ${l}/${d.packageName} for namespace ${a}. See inner exception for details.`,{cause:m})}}return s}async buildEntityIndexAsync(e){return await this.buildEntityIndexAsyncInternal(e,new Set,"",new Map)}async buildEntityIndexAsyncInternal(e,n,o,s){let a=new Map,i=e.metadata?.namespace_?.toString()??"unknown";if(this.logger?.debug?.(`Building entity index for namespace: ${i}`),n.has(i))return this.logger?.debug?.(`Skipping ${i} - circular import in progress`),a;let y=s.get(i);if(y)return y;n.add(i);let l=o.length===0?i:`${o} \u2192 ${i}`,g=0;for(let[d,m]of Object.entries(e.body))if(!d.includes(".")&&m&&typeof m=="object"&&!Array.isArray(m)){if(!e.metadata.namespace_)continue;if(!a.has(d)){let k=e.metadata.namespace_.version??{major:1,minor:0,patch:0,toString:()=>"1.0.0",equals:()=>!1,getHashCode:()=>0,compareTo:()=>0};a.set(d,{entityName:d,uri:new x(e.metadata.namespace_.publisher,e.metadata.namespace_.package_,d,k),entity:m,definedInNamespace:i,isImported:o.length>0,importPath:l}),g++}}if(this.logger?.debug?.(`Indexed ${g} entities from ${i}`),e.metadata?.imports){let d=Object.values(e.metadata.imports).reduce((m,k)=>m+k.length,0);this.logger?.debug?.(`Processing ${d} import(s) for ${i}`);for(let[m,k]of Object.entries(e.metadata.imports))for(let b of k)if(!H(b))try{this.logger?.debug?.(`Resolving import: ${m}/${b.packageName}`);let h=await this.repository.getHighestCompatibleVersionAsync(m,b);if(h){this.logger?.debug?.(`Successfully loaded import: ${h.metadata?.namespace_?.toString()}`);let U=await this.buildEntityIndexAsyncInternal(h,n,l,s),M=0;for(let[A,P]of U.entries()){let _=a.get(A);if(!_)a.set(A,P),M++;else if(_.isImported&&P.isImported&&(_.uri.publisher!==P.uri.publisher||_.uri.package_!==P.uri.package_)){let C=_.isAmbiguous?_:{..._,isAmbiguous:!0,ambiguousNamespaces:[_.definedInNamespace]};C.ambiguousNamespaces.includes(P.definedInNamespace)||C.ambiguousNamespaces.push(P.definedInNamespace),a.set(A,C),this.logger?.warn?.(`Ambiguous reference '${A}': defined in ${C.ambiguousNamespaces.join(", ")}`)}if(b.alias&&!A.includes(".")){let C=`${b.alias}.${A}`;a.has(C)||(a.set(C,P),M++)}}this.logger?.debug?.(`Merged ${M} entities from import ${h.metadata?.namespace_?.toString()}`)}else this.logger?.warn?.(`Failed to load import: ${m}/${b.packageName}`)}catch(h){let U=h;throw this.logger?.error?.(`Failed to process import ${m}/${b.packageName} for namespace ${i}. Error: ${U.message}`,U),new Error(`Failed to process import ${m}/${b.packageName} for namespace ${i}. See inner exception for details.`,{cause:h})}}return n.delete(i),s.set(i,a),a}async findDocumentForAlias(e,n){if(!e.metadata?.imports)return null;for(let[o,s]of Object.entries(e.metadata.imports))for(let a of s)if(!H(a)){if(a.alias===n)return await this.repository.getHighestCompatibleVersionAsync(o,a);if(!a.alias&&a.packageName===n)return await this.repository.getHighestCompatibleVersionAsync(o,a)}return null}clearCache(){this.cache.clear()}clearCacheForDocument(e){this.cache.delete(e)}};var J=class t{static KNOWN_XSD_DATATYPES=new Set(["string","integer","int","boolean","decimal","float","double","date","datetime","time","duration","anyuri","base64binary","hexbinary","long","short","byte","nonnegativeinteger","positiveinteger","negativeinteger","nonpositiveinteger","unsignedint","unsignedlong","unsignedshort","unsignedbyte"]);resourceResolver;constructor(e){this.resourceResolver=e}isXsdDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-xsd"&&t.KNOWN_XSD_DATATYPES.has(e.name.toLowerCase()):!1}isLiteralType(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-rdf"&&e.name==="Literal":!1}isMarkdownDatatype(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&e.name==="Markdown":!1}isSubstitutableDatatype(e){return t.isSubstitutableDatatypeUri(e)}static isSubstitutableDatatypeUri(e){return e?e.publisher==="kanonak.org"&&e.package_==="core-prose"&&(e.name==="SubstitutableString"||e.name==="Markdown"):!1}isKnownXsdDatatypeName(e){let n=e.includes(".")?e.split(".")[1]:e;return t.KNOWN_XSD_DATATYPES.has(n.toLowerCase())}async isClassTypeAsync(e,n){if(this.isKnownXsdDatatypeName(e))return!1;let o=await this.resourceResolver.resolveEntityAsync(e,n);if(o){let s=o.entity.type;if(s){let a=String(s);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,n){return!!(e==="DatatypeProperty"||e==="Property"&&this.isXsdDatatype(n)||e==="Property"&&this.isLiteralType(n))}isEffectiveObjectProperty(e,n){return!!(e==="ObjectProperty"||e==="Property"&&n&&!this.isXsdDatatype(n)&&!this.isLiteralType(n))}};function Ue(t){return`${t.publisher}/${t.package_}/${t.name}`}function u(t,e,n){return`${t}/${e}/${n}`}function He(t){return`${t.s}|${t.p}|${ae(t.o)}`}function ae(t){switch(t.kind){case"uri":return`u:${t.key}`;case"literal":return`l:${t.datatype}:${t.lexical}`;case"blank":return`b:${t.id}`}}function Ie(t,e,n){return{s:t,p:e,o:{kind:"uri",key:n}}}var se="kanonak.org",ie="core-shacl",r=t=>({publisher:se,package_:ie,name:t}),D=r("Shape"),N=r("NodeShape"),T=r("PropertyShape"),Ne=r("targetClass"),Te=r("property"),je=r("path"),$e=r("minCount"),Me=r("maxCount"),ve=r("datatype"),Le=r("class"),we=r("in"),Ve=r("pattern"),Fe=r("flags"),Be=r("minLength"),Ge=r("maxLength"),Xe=r("minInclusive"),Ye=r("maxInclusive"),qe=r("message"),We=r("targetNode"),Qe=r("targetSubjectsOf"),ze=r("targetObjectsOf"),Je=r("closed"),Ze=r("ignoredProperties"),et=r("nodeKind"),tt=r("IRI"),nt=r("BlankNode"),rt=r("Literal"),ot=r("severity"),at=r("Violation"),st=r("Warning"),it=r("Info"),pt=r("ValidationReport"),ct=r("conforms"),lt=r("result"),ut=r("ValidationResult"),yt=r("focusNode"),mt=r("resultPath"),dt=r("resultMessage"),gt=r("resultSeverity"),ft=r("sourceShape"),kt=r("value"),St=r("sourceConstraintComponent"),bt=r("MinCountConstraintComponent"),_t=r("MaxCountConstraintComponent"),ht=r("DatatypeConstraintComponent"),Pt=r("ClassConstraintComponent"),Ct=r("InConstraintComponent"),Kt=r("PatternConstraintComponent"),Et=r("MinLengthConstraintComponent"),At=r("MaxLengthConstraintComponent"),xt=r("MinInclusiveConstraintComponent"),Rt=r("MaxInclusiveConstraintComponent"),Ot=r("NodeKindConstraintComponent"),Ut=r("ClosedConstraintComponent"),Ht=r("hasValue"),It=r("qualifiedValueShape"),Dt=r("qualifiedMinCount"),Nt=r("qualifiedMaxCount"),Tt=r("HasValueConstraintComponent"),jt=r("QualifiedMinCountConstraintComponent"),$t=r("QualifiedMaxCountConstraintComponent");var p="kanonak.org",c="core-rdf",f="core-owl",ee="core-kanonak",j=new Map([["type",c],["subClassOf",c],["subPropertyOf",c],["domain",c],["range",c],["label",c],["comment",c],["seeAlso",c],["isDefinedBy",c],["member",c],["Resource",c],["Class",c],["Property",c],["Datatype",c],["Literal",c],["List",c],["ObjectProperty",f],["DatatypeProperty",f],["AnnotationProperty",f],["Thing",f],["Nothing",f],["Package",ee]]),pe=new Set(["type","subClassOf","subPropertyOf","domain","range"]);function wt(t){return j.has(t)}function ce(t){let e=j.get(t);return e?{publisher:p,package_:e}:void 0}function Vt(){return[...new Set(j.values())].map(t=>({publisher:p,package_:t}))}function Ft(t){let e=ce(t);if(!e)throw new Error(`builtinUri: '${t}' is not a reserved built-in term.`);return{...e,name:t}}function V(t,e,n){if(!t||!t.name)return;let o=j.get(t.name);if(!o)return;let s=()=>{t.publisher=p,t.package_=o,n&&(t.version=n.get(o))};if(pe.has(t.name)){let a=t.publisher===p&&t.package_===o;t.publisher=p,t.package_=o,!a&&n&&(t.version=n.get(o));return}t.publisher===p&&t.package_===o||t.publisher&&t.publisher.length>0&&(!e||e(t))||s()}var Z=class{type=u(p,c,"type");subClassOf=u(p,c,"subClassOf");subPropertyOf=u(p,c,"subPropertyOf");domain=u(p,c,"domain");range=u(p,c,"range");label=u(p,c,"label");comment=u(p,c,"comment");resource=u(p,c,"Resource");class_=u(p,c,"Class");datatype=u(p,c,"Datatype");literal=u(p,c,"Literal");equivalentClass=u(p,f,"equivalentClass");equivalentProperty=u(p,f,"equivalentProperty");inverseOf=u(p,f,"inverseOf");sameAs=u(p,f,"sameAs");transitiveProperty=u(p,f,"TransitiveProperty");symmetricProperty=u(p,f,"SymmetricProperty");objectProperty=u(p,f,"ObjectProperty");datatypeProperty=u(p,f,"DatatypeProperty");annotationProperty=u(p,f,"AnnotationProperty");package_=u(p,ee,"Package");shape=w(D);nodeShape=w(N);propertyShape=w(T)};function w(t){return u(t.publisher,t.package_,t.name)}var le=new Set(["kanonak.org/core-rdf","kanonak.org/core-owl","kanonak.org/core-xsd","kanonak.org/core-kanonak"]);function R(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=e.entity.type;if(typeof n=="string"){let s={publisher:"",package_:"",name:n.includes(".")?n.substring(n.lastIndexOf(".")+1):n};return V(s),{publisher:s.publisher,package_:s.package_,name:s.name}}}return ne(t)[0]??null}function ne(t){let e=t;if(e.entity&&typeof e.entity=="object"){let n=R(t);return n?[n]:[]}return Array.isArray(e.statement)?q(t).map(n=>{let o={publisher:n.publisher??"",package_:n.package_??"",name:n.name};return V(o),{publisher:o.publisher,package_:o.package_,name:o.name}}):[]}var ue=[D,N,T];function O(t,e){return le.has(`${t}/${e}`)}var ye=new Set(["Property","ObjectProperty","DatatypeProperty","AnnotationProperty"]);function F(t){if(O(t.publisher,t.package_))return ye.has(t.name)?t.name:void 0}var te=class t{static getTypeUri(e){return R(e)}static isCoreOntologyType(e){return O(e.publisher,e.package_)}static hasCoreType(e,n){return ne(e).some(o=>O(o.publisher,o.package_)&&o.name===n)}static isClassType(e){return t.hasCoreType(e,"Class")}static isDatatypeType(e){return t.hasCoreType(e,"Datatype")}static isDatatypePropertyType(e){return t.hasCoreType(e,"DatatypeProperty")}static isObjectPropertyType(e){return t.hasCoreType(e,"ObjectProperty")}static isAnnotationPropertyType(e){return t.hasCoreType(e,"AnnotationProperty")}static isGenericPropertyType(e){return t.hasCoreType(e,"Property")}static isAnyPropertyType(e){let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"}static isShapeType(e){let n=R(e);return n?ue.some(o=>Y(n,o)):!1}static isSchemaDefinitionType(e){if(t.isShapeType(e))return!0;let n=R(e);return!n||!O(n.publisher,n.package_)?!1:n.name==="Class"||n.name==="Property"||n.name==="DatatypeProperty"||n.name==="ObjectProperty"||n.name==="AnnotationProperty"||n.name==="Datatype"}static isInstanceOfKnownClass(e,n){if(t.isSchemaDefinitionType(e))return!1;let o=R(e);return o?n.has(o.name):!1}};var K="kanonak.org",E="core-rdf",me={publisher:K,package_:E,name:"domain"},de={publisher:K,package_:E,name:"range"},ge={publisher:K,package_:E,name:"subClassOf"},fe={publisher:K,package_:E,name:"type"},ke={publisher:K,package_:E,name:"label"},Se={publisher:K,package_:E,name:"comment"},be=new x(K,E,"Resource");function _e(t){try{let e=X(`${t.namespace}/${t.name}`);return e.kind==="resource"?e.uri:void 0}catch{return}}function oe(t,e){let n=[],o=new Set,s="version"in e?e.version:void 0,a=[new x(e.publisher,e.package_,e.name,s??void 0)];for(;a.length>0;){let i=a.shift(),y=S(i);if(o.has(y))continue;o.add(y),n.push(i);let l=he(t,i);l&&a.push(...I(l,ge))}return n}function he(t,e){return e.version&&typeof e.version.major=="number"?W(t,e)??v(t,e)[0]:v(t,e)[0]}function $(t,e){let n;for(let o of Ee(e)){let s=Pe(t,o);if(s){if(s!=="Property")return s;n??=s}}return n}function Pe(t,e){let n=F(e);if(n)return n;let o=re.get(t);o||(o=new Map,re.set(t,o));let s=e.version,a=s&&typeof s.major=="number"?`${S(e)}@${s.major}.${s.minor}.${s.patch}`:S(e),i=o.get(a);if(i!==void 0)return i??void 0;let y;for(let l of oe(t,e)){let g=F(l);if(g){if(g!=="Property"){y=g;break}y??="Property"}}return o.set(a,y??null),y}var re=new WeakMap;function nn(t,e){return $(t,e)!==void 0}function rn(t,e){return $(t,e)==="ObjectProperty"}function on(t,e){return $(t,e)==="DatatypeProperty"}function Ce(t,e){let n=new Set([S(be)]);for(let o of oe(t,e))n.add(S(o));return n}function Ke(t,e){let n=Ce(t,e),o=[],s=new Set;for(let a of t){if(!(a instanceof B))continue;let i=$(t,a);if(!i)continue;let y=I(a,me);if(!y.some(d=>n.has(S(d))))continue;let l=_e(a);if(!l)continue;let g=S(l);s.has(g)||(s.add(g),o.push({uri:l,label:L(a,ke),comment:L(a,Se),kind:i==="ObjectProperty"?"object":i==="DatatypeProperty"?"datatype":"other",range:Q(a,de),domains:y}))}return o}function an(t,e,n){let o=Ke(t,e).find(s=>S(s.uri)===S(n));return o?{ok:!0,descriptor:o}:{ok:!1,message:`Property ${n.publisher}/${n.package_}/${n.name} is not in scope for ${e.publisher}/${e.package_}/${e.name}.`}}function Ee(t){let e=I(t,fe);return e.length>0?e:t instanceof G&&t.rangeType?[t.rangeType]:[]}export{z as a,J as b,Ue as c,u as d,He as e,ae as f,Ie as g,se as h,ie as i,D as j,N as k,T as l,Ne as m,Te as n,je as o,$e as p,Me as q,ve as r,Le as s,we as t,Ve as u,Fe as v,Be as w,Ge as x,Xe as y,Ye as z,qe as A,We as B,Qe as C,ze as D,Je as E,Ze as F,et as G,tt as H,nt as I,rt as J,ot as K,at as L,st as M,it as N,bt as O,_t as P,ht as Q,Pt as R,Ct as S,Kt as T,Et as U,At as V,xt as W,Rt as X,Ot as Y,Ut as Z,Ht as _,It as $,Dt as aa,Nt as ba,Tt as ca,jt as da,$t as ea,wt as fa,ce as ga,Vt as ha,Ft as ia,V as ja,Z as ka,F as la,te as ma,_e as na,oe as oa,$ as pa,nn as qa,rn as ra,on as sa,Ke as ta,an as ua,Ee as va};