@kanonak-protocol/sdk 3.16.0 → 3.18.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/browser.d.ts +4 -5
- package/dist/browser.js +2 -2
- package/dist/chunk-2JQMUZWN.js +1 -0
- package/dist/{chunk-YENGFI2R.js → chunk-2SSUPRX3.js} +1 -1
- package/dist/chunk-BQIWYLBU.js +2 -0
- package/dist/chunk-C2WWLKWE.js +1 -0
- package/dist/chunk-CQLO62JP.js +1 -0
- package/dist/chunk-FJ35VIV6.js +1 -0
- package/dist/chunk-IXE5THUW.js +1 -0
- package/dist/chunk-L4HXBHJ4.js +47 -0
- package/dist/chunk-VRZUCZEF.js +1 -0
- package/dist/chunk-Z72IKY6C.js +1 -0
- package/dist/graph/GraphBuilder.d.ts +3 -1
- package/dist/index.d.ts +4 -5
- package/dist/index.js +15 -15
- package/dist/parsing/KanonakObjectParser.d.ts +11 -0
- package/dist/parsing/PropertyMetadata.d.ts +9 -0
- package/dist/parsing/extractMarkdownLinks.d.ts +31 -0
- package/dist/parsing/index.js +1 -1
- package/dist/reasoning/index.js +1 -1
- package/dist/resolution/TypeResolver.d.ts +12 -0
- package/dist/resolution/index.d.ts +1 -0
- package/dist/resolution/index.js +1 -1
- package/dist/statements/MarkdownStatement.d.ts +38 -0
- package/dist/statements/index.d.ts +2 -0
- package/dist/transformations/index.js +29 -29
- package/dist/transformations/v3/CompiledTransformationV3.d.ts +15 -1
- package/dist/transformations/v3/ExpressionEngineV3.d.ts +10 -0
- package/dist/transformations/v3/TransformationUriConstantsV3.d.ts +7 -0
- package/dist/uri-helpers/UriHelpers.d.ts +24 -0
- package/dist/uri-helpers/index.d.ts +2 -2
- package/dist/uri-helpers/index.js +1 -1
- package/dist/validation/index.d.ts +1 -1
- package/dist/validation/index.js +1 -1
- package/dist/validation/rules/repository/MarkdownLinkRule.d.ts +28 -0
- package/dist/validation/rules/repository/SubClassOfReferenceRule.d.ts +8 -0
- package/dist/validation/rules/repository/index.d.ts +1 -0
- package/package.json +2 -10
- package/dist/chunk-7M7XXZOV.js +0 -1
- package/dist/chunk-AFF2TQ7Y.js +0 -2
- package/dist/chunk-C54LRL2A.js +0 -42
- package/dist/chunk-CRR4BQKR.js +0 -1
- package/dist/chunk-GKQVJITL.js +0 -1
- package/dist/chunk-NPWF35XZ.js +0 -1
- package/dist/chunk-QJ66UBDY.js +0 -1
- package/dist/chunk-RGMZAKJV.js +0 -1
- package/dist/chunk-USLG7UIM.js +0 -4
- package/dist/ctl/CtlGraphResolver.d.ts +0 -14
- package/dist/ctl/CtlKanonakUri.d.ts +0 -28
- package/dist/ctl/CtlMarkdownRenderer.d.ts +0 -17
- package/dist/ctl/CtlParser.d.ts +0 -10
- package/dist/ctl/CtlValidator.d.ts +0 -12
- package/dist/ctl/index.d.ts +0 -12
- package/dist/ctl/index.js +0 -1
- /package/dist/{ctl → resolution}/ResourceTypeClassifier.d.ts +0 -0
|
@@ -1,53 +1,53 @@
|
|
|
1
|
-
import{b
|
|
1
|
+
import{b,c as I,d,f as F}from"../chunk-2JQMUZWN.js";import{a as Ce}from"../chunk-C2WWLKWE.js";import"../chunk-CQLO62JP.js";import{a as Be}from"../chunk-FJ35VIV6.js";import{a as P,c as Re,d as Le}from"../chunk-Z72IKY6C.js";import{b as D,c as S,d as h,g as R,h as L,i as B,j as V,k as T,l as w}from"../chunk-W6T7MOKY.js";import{a as De}from"../chunk-MYITGTGJ.js";import"../chunk-IXE5THUW.js";import"../chunk-FUUTGGJS.js";var pt="kanonak.org",gt="document-ast",p=t=>({publisher:pt,package_:gt,name:t}),E={Document:p("Document"),Block:p("Block"),Inline:p("Inline"),StructuredValue:p("StructuredValue"),Heading:p("Heading"),Paragraph:p("Paragraph"),RawBlock:p("RawBlock"),Text:p("Text"),StructuredMap:p("StructuredMap"),StructuredEntry:p("StructuredEntry"),StructuredList:p("StructuredList"),StringScalar:p("StringScalar"),IntegerScalar:p("IntegerScalar"),EscapeHint:p("EscapeHint"),MediaType:p("MediaType"),metadata:p("metadata"),children:p("children"),level:p("level"),inlines:p("inlines"),text:p("text"),entries:p("entries"),key:p("key"),value:p("value"),escapeHint:p("escapeHint"),items:p("items"),stringValue:p("stringValue"),integerValue:p("integerValue"),rawContent:p("rawContent"),mediaType:p("mediaType"),mimeType:p("mimeType"),ESC_RAW:p("esc-raw"),ESC_YAML_SAFE:p("esc-yaml-safe"),ESC_TOML_STRING:p("esc-toml-string"),ESC_TOML_MULTILINE:p("esc-toml-multiline"),ESC_JSON:p("esc-json"),TEXT_PLAIN:p("text-plain"),TEXT_MARKDOWN:p("text-markdown"),TEXT_HTML:p("text-html"),TEXT_CSS:p("text-css"),APPLICATION_JSON:p("application-json"),TEXT_YAML:p("text-yaml"),IMAGE_SVG_XML:p("image-svg-xml"),ResourceLink:p("ResourceLink"),target:p("target"),linkLabel:p("linkLabel"),PropertyList:p("PropertyList"),propertyEntries:p("propertyEntries"),PropertyEntry:p("PropertyEntry"),propertyKey:p("propertyKey"),propertyValue:p("propertyValue"),Table:p("Table"),tableColumnLabels:p("tableColumnLabels"),tableRows:p("tableRows"),TableRow:p("TableRow"),tableCells:p("tableCells")};function Ue(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var J=class{backendUri="kanonak.org/transformations/markdown-with-frontmatter";render(e,n){let r=yt(e.metadata,n),i=wt(e.children),u=["---",...r,"---","",i].join(`
|
|
2
2
|
`);return n?.trailingNewline&&(u.endsWith(`
|
|
3
3
|
`)||(u+=`
|
|
4
|
-
`)),u}};function
|
|
4
|
+
`)),u}};function yt(t,e){if(!t)return[];let n=new Map;for(let c of t.entries)n.set(oe(c.key),c);let r=new Map;if(e?.metadataRenames)for(let[c,l]of e.metadataRenames)r.set(oe(c),l);let a=(e?.metadataKeys??t.entries.map(c=>c.key)).map(oe),u=[];for(let c of a){let l=n.get(c);if(!l)continue;let m=r.get(c),g=oe(m??c),k=Pe(l.value,l.escapeHint);k!==void 0&&u.push(`${g}: ${k}`)}return u}function oe(t){let e=t.lastIndexOf(".");return e===-1?t:t.substring(e+1)||t}function Pe(t,e){switch(t.kind){case"StringScalar":return kt(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let i=Pe(r,e);i!==void 0&&n.push(i)}return n.join(", ")}case"StructuredMap":return;default:return}}function kt(t,e){return!e||Ue(e,E.ESC_RAW)?t:Ue(e,E.ESC_YAML_SAFE)?ht(t):t}function ht(t){return t.includes(`
|
|
5
5
|
`)?`|-
|
|
6
6
|
${t.replace(/\n/g,`
|
|
7
|
-
`).trimEnd()}`:/[:#\[\]{}&*!|>'"%@`,]/.test(t)?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:t}function
|
|
7
|
+
`).trimEnd()}`:/[:#\[\]{}&*!|>'"%@`,]/.test(t)?`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"')}"`:t}function wt(t){let e=[];for(let n of t){let r=ge(n);r&&e.push(r)}return e.join(`
|
|
8
8
|
|
|
9
|
-
`)}function
|
|
10
|
-
`)}function
|
|
9
|
+
`)}function ge(t){switch(t.kind){case"Heading":return`${"#".repeat(t.level)} ${se(t.inlines)}`;case"Paragraph":return se(t.inlines);case"RawBlock":return t.rawContent;case"PropertyList":return Oe(t);case"Table":return bt(t);default:return""}}function bt(t){let e=t.tableColumnLabels??[],n=t.tableRows??[];if(e.length===0&&n.length===0)return"";let r=`| ${e.map(pe).join(" | ")} |`,i=`| ${e.map(()=>"---").join(" | ")} |`,a=n.map(u=>`| ${(u.tableCells??[]).map(St).join(" | ")} |`);return[r,i,...a].join(`
|
|
10
|
+
`)}function St(t){let e=t;return!e||typeof e!="object"||!e.kind?"":e.kind==="Text"||e.kind==="ResourceLink"||e.kind==="Badge"?pe(se([e])):pe(ge(e).replace(/\n+/g," "))}function pe(t){return t==null?"":String(t).replace(/\|/g,"\\|")}function Oe(t,e=0){if(!t.propertyEntries||t.propertyEntries.length===0)return"";let n=" ".repeat(e),r=[];for(let i of t.propertyEntries){let a=`${n}**${i.propertyKey}:**`,u=$t(i.propertyValue,e+1);u.includes(`
|
|
11
11
|
`)?r.push(`${a}
|
|
12
12
|
${u}`):r.push(`${a} ${u}`)}return r.join(`
|
|
13
13
|
|
|
14
|
-
`)}function
|
|
14
|
+
`)}function $t(t,e){if(!t||t.length===0)return"";let n=[],r=[];for(let i of t){let a=i;!a||typeof a!="object"||!a.kind||(a.kind==="Text"||a.kind==="ResourceLink"||a.kind==="Badge"?n.push(se([a])):a.kind==="PropertyList"?r.push(Oe(a,e)):r.push(ge(a)))}return r.length===0?n.join(""):n.length===0?r.join(`
|
|
15
15
|
|
|
16
16
|
`):`${n.join("")}
|
|
17
17
|
|
|
18
18
|
${r.join(`
|
|
19
19
|
|
|
20
|
-
`)}`}function
|
|
20
|
+
`)}`}function se(t){let e=[];for(let n of t)n.kind==="Text"?e.push(n.text):n.kind==="ResourceLink"?e.push(Et(n)):n.kind==="Badge"&&e.push(vt(n));return e.join("")}function Et(t){let e=Ie(t.target);if(!e)return t.linkLabel??"[unresolved link]";let n=I(e),r=t.linkLabel&&t.linkLabel.length>0?t.linkLabel:e.name,i=t.linkTooltip?` "${_e(t.linkTooltip)}"`:"";return`[${r}](${n}${i})`}function vt(t){if(!t.badgeTarget)return`*${t.badgeLabel}*`;let e=Ie(t.badgeTarget);if(!e)return`*${t.badgeLabel}*`;let n=I(e),r=t.badgeTooltip?` "${_e(t.badgeTooltip)}"`:"";return`*[${t.badgeLabel}](${n}${r})*`}function _e(t){return t==null?"":String(t).replace(/"/g,'\\"')}function Ie(t){if(!t||typeof t!="object")return;let e=t;if(e.subject&&e.subject.publisher&&e.subject.package_&&e.subject.name){let r={publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name};return e.subject.version&&(r.version=e.subject.version),r}let n=t;if(typeof n.namespace=="string"&&typeof n.name=="string"&&n.name.length>0){let r=/^([^/]+)\/([^@]+)@(\d+)\.(\d+)\.(\d+)$/.exec(n.namespace);if(r)return{publisher:r[1],package_:r[2],name:n.name,version:{major:Number(r[3]),minor:Number(r[4]),patch:Number(r[5])}}}}function jt(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var Y=class{backendUri="kanonak.org/transformations/toml";render(e,n){let i=Vt(e.metadata,n).join(`
|
|
21
21
|
`);return n?.trailingNewline&&(i.endsWith(`
|
|
22
22
|
`)||(i+=`
|
|
23
|
-
`)),i}};function
|
|
23
|
+
`)),i}};function Vt(t,e){if(!t)return[];let n=new Map;for(let a of t.entries)n.set(a.key,a);let r=e?.metadataKeys??t.entries.map(a=>a.key),i=[];for(let a of r){let u=n.get(a);if(!u)continue;let c=e?.metadataRenames.get(a)??a,l=Me(u.value,u.escapeHint);l!==void 0&&i.push(`${c} = ${l}`)}return i}function Me(t,e){switch(t.kind){case"StringScalar":return At(t.stringValue,e);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let n=[];for(let r of t.items){let i=Me(r,e);i!==void 0&&n.push(i)}return`[${n.join(", ")}]`}case"StructuredMap":return;default:return}}function At(t,e){return e&&jt(e,E.ESC_TOML_MULTILINE)?Tt(t):Kt(t)}function Kt(t){return`"${t.replace(/\\/g,"\\\\").replace(/"/g,'\\"').replace(/\n/g,"\\n")}"`}function Tt(t){return`"""
|
|
24
24
|
${t.replace(/"""/g,'\\"\\"\\"')}
|
|
25
|
-
"""`}var
|
|
25
|
+
"""`}var Z=class{backendUri="kanonak.org/transformations/json";render(e,n){let r=JSON.stringify(e,null,2);return n?.trailingNewline&&!r.endsWith(`
|
|
26
26
|
`)?r+`
|
|
27
|
-
`:r}};function
|
|
27
|
+
`:r}};function Q(t){let e=t.replace(/\r\n/g,`
|
|
28
28
|
`).split(`
|
|
29
|
-
`),n=[],r=0;for(;r<e.length;){let i=e[r];if(i.trim()===""){r++;continue}let a=/^(\s*)```(\S*)\s*$/.exec(i);if(a){let l=a[2],m=[];for(r++;r<e.length&&!/^(\s*)```\s*$/.test(e[r]);)m.push(e[r]),r++;r++;let g=
|
|
30
|
-
`)),k=l?` class="language-${
|
|
29
|
+
`),n=[],r=0;for(;r<e.length;){let i=e[r];if(i.trim()===""){r++;continue}let a=/^(\s*)```(\S*)\s*$/.exec(i);if(a){let l=a[2],m=[];for(r++;r<e.length&&!/^(\s*)```\s*$/.test(e[r]);)m.push(e[r]),r++;r++;let g=Fe(m.join(`
|
|
30
|
+
`)),k=l?` class="language-${qe(l)}"`:"";n.push(`<pre><code${k}>${g}</code></pre>`);continue}let u=/^(#{1,6})\s+(.*)$/.exec(i);if(u){let l=u[1].length,m=W(u[2].trim());n.push(`<h${l}>${m}</h${l}>`),r++;continue}if(i.includes("|")&&r+1<e.length&&Ne(e[r+1])){let l=ye(i),m=Dt(e[r+1]);r+=2;let g=[];for(;r<e.length&&e[r].trim()!==""&&e[r].includes("|");)g.push(ye(e[r])),r++;n.push(Rt(l,m,g));continue}if(/^\s*[-*]\s+/.test(i)){let l=[];for(;r<e.length&&/^\s*[-*]\s+/.test(e[r]);){let m=[e[r].replace(/^\s*[-*]\s+/,"")];for(r++;r<e.length&&e[r].trim()!==""&&!/^\s*[-*]\s+/.test(e[r])&&!/^\s*\d+\.\s+/.test(e[r]);)m.push(e[r]),r++;r<e.length&&e[r].trim()===""&&r++,l.push(`<li>${W(m.join(" ").trim())}</li>`)}n.push(`<ul>
|
|
31
31
|
${l.join(`
|
|
32
32
|
`)}
|
|
33
|
-
</ul>`);continue}if(/^\s*\d+\.\s+/.test(i)){let l=[];for(;r<e.length&&/^\s*\d+\.\s+/.test(e[r]);){let m=[e[r].replace(/^\s*\d+\.\s+/,"")];for(r++;r<e.length&&e[r].trim()!==""&&!/^\s*\d+\.\s+/.test(e[r])&&!/^\s*[-*]\s+/.test(e[r]);)m.push(e[r]),r++;r<e.length&&e[r].trim()===""&&r++,l.push(`<li>${
|
|
33
|
+
</ul>`);continue}if(/^\s*\d+\.\s+/.test(i)){let l=[];for(;r<e.length&&/^\s*\d+\.\s+/.test(e[r]);){let m=[e[r].replace(/^\s*\d+\.\s+/,"")];for(r++;r<e.length&&e[r].trim()!==""&&!/^\s*\d+\.\s+/.test(e[r])&&!/^\s*[-*]\s+/.test(e[r]);)m.push(e[r]),r++;r<e.length&&e[r].trim()===""&&r++,l.push(`<li>${W(m.join(" ").trim())}</li>`)}n.push(`<ol>
|
|
34
34
|
${l.join(`
|
|
35
35
|
`)}
|
|
36
|
-
</ol>`);continue}let c=[i];for(r++;r<e.length&&e[r].trim()!==""&&!/^(#{1,6})\s+/.test(e[r])&&!/^(\s*)```/.test(e[r])&&!/^\s*[-*]\s+/.test(e[r])&&!/^\s*\d+\.\s+/.test(e[r])&&!(e[r].includes("|")&&r+1<e.length&&
|
|
37
|
-
`)}function
|
|
36
|
+
</ol>`);continue}let c=[i];for(r++;r<e.length&&e[r].trim()!==""&&!/^(#{1,6})\s+/.test(e[r])&&!/^(\s*)```/.test(e[r])&&!/^\s*[-*]\s+/.test(e[r])&&!/^\s*\d+\.\s+/.test(e[r])&&!(e[r].includes("|")&&r+1<e.length&&Ne(e[r+1]));)c.push(e[r]),r++;n.push(`<p>${W(c.join(" "))}</p>`)}return n.join(`
|
|
37
|
+
`)}function Ne(t){return t.includes("-")?/^[\s|:-]+$/.test(t):!1}function ye(t){let e=t.trim();return e.startsWith("|")&&(e=e.slice(1)),e.endsWith("|")&&(e=e.slice(0,-1)),e.split("|").map(n=>n.trim())}function Dt(t){return ye(t).map(e=>{let n=e.startsWith(":"),r=e.endsWith(":");return n&&r?"center":r?"right":n?"left":null})}function Rt(t,e,n){let r=u=>{let c=e[u];return c?` style="text-align:${c}"`:""},i=t.map((u,c)=>`<th${r(c)}>${W(u)}</th>`).join(""),a=n.map(u=>`<tr>${u.map((l,m)=>`<td${r(m)}>${W(l)}</td>`).join("")}</tr>`).join(`
|
|
38
38
|
`);return`<table>
|
|
39
39
|
<thead><tr>${i}</tr></thead>
|
|
40
40
|
<tbody>
|
|
41
41
|
${a}
|
|
42
42
|
</tbody>
|
|
43
|
-
</table>`}function
|
|
43
|
+
</table>`}function W(t){let e=Fe(t);return e=e.replace(/`([^`\n]+)`/g,(n,r)=>`<code>${r}</code>`),e=e.replace(/\[([^\]]+)\]\(([^)\s]+)\)/g,(n,r,i)=>`<a href="${qe(i)}">${r}</a>`),e=e.replace(/\*\*([^*\n]+)\*\*/g,(n,r)=>`<strong>${r}</strong>`),e=e.replace(/(^|[^*])\*([^*\n]+)\*(?!\*)/g,(n,r,i)=>`${r}<em>${i}</em>`),e=e.replace(/(^|[\s(])_([^_\n]+)_(?=[\s).,;:!?]|$)/g,(n,r,i)=>`${r}<em>${i}</em>`),e}function Fe(t){return t.replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function qe(t){return t.replace(/"/g,""").replace(/&/g,"&")}function ke(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var x=class{backendUri="kanonak.org/transformations/html";render(e,n){let r=Ct(e.children);if(n?.omitWrapper){let c=r.endsWith(`
|
|
44
44
|
`)?r:`${r}
|
|
45
45
|
`;return n.trailingNewline===!1&&c.endsWith(`
|
|
46
|
-
`)?c.slice(0,-1):c}let i=
|
|
46
|
+
`)?c.slice(0,-1):c}let i=Lt(e.metadata)??"Untitled",a=Bt(e.metadata,n),u=`<!DOCTYPE html>
|
|
47
47
|
<html lang="en">
|
|
48
48
|
<head>
|
|
49
49
|
<meta charset="utf-8">
|
|
50
|
-
<title>${
|
|
50
|
+
<title>${C(i)}</title>
|
|
51
51
|
<style>
|
|
52
52
|
body { font-family: -apple-system, Segoe UI, Helvetica, Arial, sans-serif; max-width: 860px; margin: 2rem auto; padding: 0 1rem; color: #222; line-height: 1.55; }
|
|
53
53
|
h1, h2, h3, h4 { line-height: 1.2; }
|
|
@@ -73,33 +73,33 @@ ${a}${r}
|
|
|
73
73
|
</body>
|
|
74
74
|
</html>
|
|
75
75
|
`;return n?.trailingNewline===!1&&u.endsWith(`
|
|
76
|
-
`)?u.slice(0,-1):u}};function
|
|
76
|
+
`)?u.slice(0,-1):u}};function Lt(t){if(t){for(let e of t.entries)if((e.key==="title"||e.key==="name")&&e.value.kind==="StringScalar")return e.value.stringValue}}function Bt(t,e){if(!t||t.entries.length===0)return"";let n=e?.metadataKeys??t.entries.map(a=>a.key),r=new Map(t.entries.map(a=>[a.key,a])),i=[];for(let a of n){let u=r.get(a);if(!u)continue;let c=e?.metadataRenames.get(a)??a,l=We(u.value);l!==void 0&&i.push(` <dt>${C(c)}</dt>
|
|
77
77
|
<dd>${l}</dd>`)}return i.length===0?"":`<dl class="metadata">
|
|
78
78
|
${i.join(`
|
|
79
79
|
`)}
|
|
80
80
|
</dl>
|
|
81
|
-
`}function
|
|
82
|
-
`)}function
|
|
83
|
-
<tr>${e.map(a=>`<th>${
|
|
81
|
+
`}function We(t){switch(t.kind){case"StringScalar":return C(t.stringValue);case"IntegerScalar":return String(t.integerValue);case"StructuredList":{let e=[];for(let n of t.items){let r=We(n);r!==void 0&&e.push(`<code>${r}</code>`)}return e.join(", ")}case"StructuredMap":return;default:return}}function Ct(t){let e=[];for(let n of t){let r=he(n);r&&e.push(r)}return e.join(`
|
|
82
|
+
`)}function he(t){switch(t.kind){case"Heading":{let e=Math.max(1,Math.min(6,t.level));return`<h${e}>${ue(t.inlines)}</h${e}>`}case"Paragraph":return`<p>${ue(t.inlines)}</p>`;case"RawBlock":return Mt(t);case"PropertyList":return _t(t);case"Table":return Ut(t);default:return""}}function Ut(t){let e=t.tableColumnLabels??[],n=t.tableRows??[],r=e.length>0?`<thead>
|
|
83
|
+
<tr>${e.map(a=>`<th>${C(a)}</th>`).join("")}</tr>
|
|
84
84
|
</thead>
|
|
85
85
|
`:"",i=n.length>0?`<tbody>
|
|
86
|
-
${n.map(
|
|
86
|
+
${n.map(Pt).join(`
|
|
87
87
|
`)}
|
|
88
88
|
</tbody>
|
|
89
89
|
`:"";return`<table class="property-table">
|
|
90
|
-
${r}${i}</table>`}function
|
|
90
|
+
${r}${i}</table>`}function Pt(t){return` <tr>${(t.tableCells??[]).map(r=>`<td>${Ot(r)}</td>`).join("")}</tr>`}function Ot(t){let e=t;return!e||typeof e!="object"||!e.kind?"":e.kind==="Text"||e.kind==="ResourceLink"||e.kind==="Badge"?ue([e]):he(e)}function _t(t){if(!t.propertyEntries||t.propertyEntries.length===0)return"";let e=[];for(let n of t.propertyEntries){let i=`<dt${n.propertyTooltip?` title="${H(n.propertyTooltip)}"`:""}>${C(n.propertyKey)}</dt>`,a=`<dd>${It(n.propertyValue)}</dd>`;e.push(i,a)}return`<dl class="property-list">
|
|
91
91
|
${e.join(`
|
|
92
92
|
`)}
|
|
93
|
-
</dl>`}function
|
|
93
|
+
</dl>`}function It(t){if(!t||t.length===0)return"";let e=[];for(let n of t){let r=n;!r||typeof r!="object"||!r.kind||(r.kind==="Text"||r.kind==="ResourceLink"||r.kind==="Badge"?e.push(ue([r])):e.push(he(r)))}return e.join("")}function Mt(t){let e=t.mediaType;return e&&ke(e,E.TEXT_MARKDOWN)?Q(t.rawContent):e&&ke(e,E.TEXT_HTML)?t.rawContent:e&&ke(e,E.IMAGE_SVG_XML)?`<figure class="svg-figure">
|
|
94
94
|
${t.rawContent}
|
|
95
|
-
</figure>`:`<pre${e?` class="media-${
|
|
95
|
+
</figure>`:`<pre${e?` class="media-${H(e.name)}"`:""}><code>${C(t.rawContent)}</code></pre>`}function ue(t){let e=[];for(let n of t)n.kind==="Text"?e.push(C(n.text)):n.kind==="ResourceLink"?e.push(Nt(n)):n.kind==="Badge"&&e.push(Ft(n));return e.join("")}function Nt(t){let e=He(t.target);if(!e)return C(t.linkLabel??"[unresolved link]");let n=I(e),r=t.linkLabel&&t.linkLabel.length>0?t.linkLabel:e.name,i=t.linkTooltip?` title="${H(t.linkTooltip)}"`:"";return`<a class="kan-link" href="${H(n)}"${i}>${C(r)}</a>`}function Ft(t){let e=t.badgeTooltip?` title="${H(t.badgeTooltip)}"`:"",n=C(t.badgeLabel);if(!t.badgeTarget)return`<span class="kan-badge"${e}>${n}</span>`;let r=He(t.badgeTarget);if(!r)return`<span class="kan-badge"${e}>${n}</span>`;let i=I(r);return`<a class="kan-badge" href="${H(i)}"${e}>${n}</a>`}function He(t){if(!t||typeof t!="object")return;let e=t;if(e.subject&&e.subject.publisher&&e.subject.package_&&e.subject.name){let r={publisher:e.subject.publisher,package_:e.subject.package_,name:e.subject.name};return e.subject.version&&(r.version=e.subject.version),r}let n=t;if(typeof n.namespace=="string"&&typeof n.name=="string"&&n.name.length>0){let r=/^([^/]+)\/([^@]+)@(\d+)\.(\d+)\.(\d+)$/.exec(n.namespace);if(r)return{publisher:r[1],package_:r[2],name:n.name,version:{major:Number(r[3]),minor:Number(r[4]),patch:Number(r[5])}}}}function C(t){return t==null?"":String(t).replace(/&/g,"&").replace(/</g,"<").replace(/>/g,">").replace(/"/g,""").replace(/'/g,"'")}function H(t){return t==null?"":String(t).replace(/"/g,""").replace(/&/g,"&")}function qt(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var ee=class{backendUri="kanonak.org/transformations/svg";render(e,n){for(let r of e.children)if(r.kind==="RawBlock"&&r.mediaType&&qt(r.mediaType,E.IMAGE_SVG_XML)){let i=r.rawContent;return n?.trailingNewline&&!i.endsWith(`
|
|
96
96
|
`)&&(i+=`
|
|
97
|
-
`),i}return'<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'}};function
|
|
97
|
+
`),i}return'<svg xmlns="http://www.w3.org/2000/svg" width="1" height="1"/>'}};function Wt(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var te=class{backendUri="kanonak.org/transformations/stylesheet";render(e,n){let r=[];for(let a of e.children)a.kind==="RawBlock"&&a.mediaType&&Wt(a.mediaType,E.TEXT_CSS)&&r.push(a.rawContent);let i=r.join(`
|
|
98
98
|
|
|
99
99
|
`);return n?.trailingNewline&&i.length>0&&!i.endsWith(`
|
|
100
100
|
`)&&(i+=`
|
|
101
|
-
`),i}};function
|
|
101
|
+
`),i}};function Ht(t,e){return t.publisher===e.publisher&&t.package_===e.package_&&t.name===e.name}var ne=class{backendUri="kanonak.org/transformations/yaml";render(e,n){let r=[];for(let a of e.children)a.kind==="RawBlock"&&a.mediaType&&Ht(a.mediaType,E.TEXT_YAML)&&r.push(a.rawContent);let i=r.join(`
|
|
102
102
|
|
|
103
103
|
`);return n?.trailingNewline&&i.length>0&&!i.endsWith(`
|
|
104
104
|
`)&&(i+=`
|
|
105
|
-
`),i}};var te=class{constructor(e,n,r){this.repository=e;this.parser=n;this.objectParser=r}repository;parser;objectParser;cache=new Map;async resolveSubject(e,n){let r=N(n,e);if(r)return r;let i=e.version,a=i&&typeof i.major=="number"?`@${i.major}.${i.minor}.${i.patch}`:"",u=`${e.publisher}/${e.package_}${a}`,c=this.cache.get(u);if(!c){let m=await this.repository.getDocumentsByNamespaceAsync(e.publisher,e.package_);if(m.length===0)return;let g=i&&typeof i.major=="number"?m.find(K=>{let v=K.metadata?.namespace_?.version;return v&&v.major===i.major&&v.minor===i.minor&&v.patch===i.patch})??m[0]:m[0],k=new De(g,this.repository);c=await this.objectParser.parseKanonaks(k),this.cache.set(u,c)}let l=N(c,e);if(l)return l;for(let m of c)if(m instanceof b&&m.name===e.name)return m}};var Wt="kanonak.org",zt="transformations",Mn=3,s=t=>({publisher:Wt,package_:zt,name:t}),o={Transformation:s("Transformation"),InstanceTransformation:s("InstanceTransformation"),SetTransformation:s("SetTransformation"),inputPattern:s("inputPattern"),rule:s("rule"),artifactName:s("artifactName"),outputs:s("outputs"),formatOverrides:s("formatOverrides"),partitionBy:s("partitionBy"),InputPattern:s("InputPattern"),matchesClass:s("matchesClass"),requires:s("requires"),sortBy:s("sortBy"),SortKey:s("SortKey"),byProperty:s("byProperty"),order:s("order"),SortOrder:s("SortOrder"),ascending:s("ascending"),descending:s("descending"),OutputFormat:s("OutputFormat"),backendUri:s("backendUri"),FormatOverride:s("FormatOverride"),formatTarget:s("formatTarget"),metadataKeys:s("metadataKeys"),metadataRenames:s("metadataRenames"),trailingNewline:s("trailingNewline"),omitWrapper:s("omitWrapper"),RenameEntry:s("RenameEntry"),fromKey:s("fromKey"),toKey:s("toKey"),FMT_MARKDOWN_FRONTMATTER:s("markdown-with-frontmatter"),FMT_PLAIN_MARKDOWN:s("plain-markdown"),FMT_TOML:s("toml"),FMT_JSON:s("json"),FMT_HTML:s("html"),FMT_SVG:s("svg"),Expression:s("Expression"),ListSourcedExpression:s("ListSourcedExpression"),ListAggregate:s("ListAggregate"),IteratingExpression:s("IteratingExpression"),BuildAstNode:s("BuildAstNode"),astClass:s("astClass"),set:s("set"),AstFieldBinding:s("AstFieldBinding"),field:s("field"),bindValue:s("bindValue"),When:s("When"),condition:s("condition"),thenBuild:s("thenBuild"),elseBuild:s("elseBuild"),Concat:s("Concat"),parts:s("parts"),Fallback:s("Fallback"),primary:s("primary"),alternate:s("alternate"),StringLiteral:s("StringLiteral"),stringLiteral:s("stringLiteral"),IntegerLiteral:s("IntegerLiteral"),integerLiteral:s("integerLiteral"),DecimalLiteral:s("DecimalLiteral"),decimalLiteral:s("decimalLiteral"),BooleanLiteral:s("BooleanLiteral"),booleanLiteral:s("booleanLiteral"),VarRef:s("VarRef"),varName:s("varName"),PropertyRead:s("PropertyRead"),readSource:s("readSource"),readProp:s("readProp"),Traverse:s("Traverse"),traverseSource:s("traverseSource"),through:s("through"),step:s("step"),UriName:s("UriName"),uriNameOf:s("uriNameOf"),UriPublisher:s("UriPublisher"),uriPublisherOf:s("uriPublisherOf"),UriPackage:s("UriPackage"),uriPackageOf:s("uriPackageOf"),UriVersion:s("UriVersion"),uriVersionOf:s("uriVersionOf"),SubjectUri:s("SubjectUri"),subjectOf:s("subjectOf"),UriLiteral:s("UriLiteral"),refTo:s("refTo"),DisplayLabel:s("DisplayLabel"),labelTarget:s("labelTarget"),labelSource:s("labelSource"),ResolveRef:s("ResolveRef"),resolveSource:s("resolveSource"),Normalize:s("Normalize"),normSource:s("normSource"),normKind:s("normKind"),NormalizeKind:s("NormalizeKind"),NORM_TRIM_END:s("trim-end"),IsSet:s("IsSet"),checkExpr:s("checkExpr"),ExpressionFragment:s("ExpressionFragment"),body:s("body"),CallFragment:s("CallFragment"),fragmentRef:s("fragmentRef"),source:s("source"),Join:s("Join"),separator:s("separator"),Count:s("Count"),Sum:s("Sum"),Min:s("Min"),Max:s("Max"),Average:s("Average"),loopVar:s("loopVar"),ForEach:s("ForEach"),emit:s("emit"),ListMap:s("ListMap"),mapBody:s("mapBody"),Filter:s("Filter"),predicate:s("predicate"),PartitionBy:s("PartitionBy"),partitionKey:s("partitionKey"),DistinctBy:s("DistinctBy"),distinctKey:s("distinctKey"),Partition:s("Partition"),key:s("key"),members:s("members"),AllStatements:s("AllStatements"),statementsOf:s("statementsOf"),StatementPredicate:s("StatementPredicate"),predicateOf:s("predicateOf"),StatementValue:s("StatementValue"),valueOf:s("valueOf"),DateFormat:s("DateFormat"),dateSource:s("dateSource"),dateFormat:s("dateFormat"),BinaryArithmetic:s("BinaryArithmetic"),arithLeft:s("arithLeft"),arithRight:s("arithRight"),Add:s("Add"),Subtract:s("Subtract"),Multiply:s("Multiply"),Divide:s("Divide"),Reverse:s("Reverse"),WindowedMap:s("WindowedMap"),windowSize:s("windowSize"),windowVar:s("windowVar"),windowBody:s("windowBody"),PairwiseMap:s("PairwiseMap"),firstVar:s("firstVar"),secondVar:s("secondVar"),pairBody:s("pairBody"),Scan:s("Scan"),initialState:s("initialState"),stateVar:s("stateVar"),elementVar:s("elementVar"),accumulate:s("accumulate"),ListItemAt:s("ListItemAt"),itemIndex:s("itemIndex"),BinaryComparison:s("BinaryComparison"),compareLeft:s("compareLeft"),compareRight:s("compareRight"),Equals:s("Equals"),GreaterThan:s("GreaterThan"),LessThan:s("LessThan"),GreaterThanOrEqual:s("GreaterThanOrEqual"),LessThanOrEqual:s("LessThanOrEqual"),Not:s("Not"),operand:s("operand"),BooleanLogic:s("BooleanLogic"),operands:s("operands"),And:s("And"),Or:s("Or"),Contains:s("Contains"),haystack:s("haystack"),needle:s("needle"),UnaryNumericOp:s("UnaryNumericOp"),value:s("value"),Abs:s("Abs"),Negate:s("Negate"),KindPredicate:s("KindPredicate"),IsReference:s("IsReference"),IsEmbedded:s("IsEmbedded"),IsList:s("IsList"),kindCheck:s("kindCheck"),StatementObject:s("StatementObject"),statementSource:s("statementSource"),Let:s("Let"),letName:s("letName"),letValue:s("letValue"),letBody:s("letBody"),GetStatementByName:s("GetStatementByName"),inSubject:s("inSubject"),byName:s("byName")};var y=class extends Error{constructor(n,r){super(`${n} (at ${r})`);this.path=r}path};function se(t,e){let n=t.name,r=tn(e),i={catalog:e,depth:0};if(d(t,o.InstanceTransformation))return Ht(t,n,i,r);if(d(t,o.SetTransformation))return Gt(t,n,i,r);throw new y("Subject is not a recognized v3 transformation type \u2014 expected InstanceTransformation or SetTransformation",n)}function Ht(t,e,n,r){return{kind:"instance",name:t.name,inputPattern:Ge(t,e),rule:oe(t,o.rule,`${e}.rule`,n),artifactName:oe(t,o.artifactName,`${e}.artifactName`,n),outputs:Xe(t,`${e}.outputs`),overrides:Je(t,`${e}.formatOverrides`,n),fragments:r}}function Gt(t,e,n,r){let i=_(t,o.partitionBy);return{kind:"set",name:t.name,inputPattern:Ge(t,e),rule:oe(t,o.rule,`${e}.rule`,n),artifactName:oe(t,o.artifactName,`${e}.artifactName`,n),outputs:Xe(t,`${e}.outputs`),overrides:Je(t,`${e}.formatOverrides`,n),partitionBy:i,fragments:r}}function Ge(t,e){let n=ne(t,o.inputPattern);if(!n)throw new y("inputPattern is required",e);return Xt(n,`${e}.inputPattern`)}function Xt(t,e){let n=_(t,o.matchesClass);if(!n)throw new y("matchesClass is required",e);let r=[];for(let u of A(t,o.requires))if(u instanceof V)r.push(we(u.object.subject));else if(u instanceof w)for(let c of u.object)c instanceof h&&r.push(we(c.subject));let i=[],a=0;for(let u of A(t,o.sortBy))if(u instanceof w)for(let c of u.object)c instanceof P&&i.push(Fe(c,`${e}.sortBy[${a++}]`));else u instanceof T&&i.push(Fe(u.object,`${e}.sortBy[${a++}]`));return{matchesClass:n,requires:r,sortBy:i}}function Fe(t,e){let n=_(t,o.byProperty);if(!n)throw new y("SortKey.byProperty is required",e);let r=_(t,o.order);if(!r)throw new y("SortKey.order is required",e);if(E(r,o.ascending))return{byProperty:n,order:"ascending"};if(E(r,o.descending))return{byProperty:n,order:"descending"};throw new y(`SortKey.order must reference tx.ascending or tx.descending; got ${r.publisher}/${r.package_}/${r.name}`,e)}function oe(t,e,n,r){let i=ne(t,e);if(!i)throw new y("expression is required",n);return H(i,n,r)}function H(t,e,n){if(d(t,o.StringLiteral))return{kind:"string-literal",value:j(t,o.stringLiteral,e)};if(d(t,o.IntegerLiteral))return{kind:"integer-literal",value:He(t,o.integerLiteral,e)};if(d(t,o.DecimalLiteral))return{kind:"decimal-literal",value:He(t,o.decimalLiteral,e)};if(d(t,o.BooleanLiteral))return{kind:"boolean-literal",value:an(t,o.booleanLiteral,e)};if(d(t,o.VarRef))return{kind:"var-ref",varName:j(t,o.varName,e)};if(d(t,o.PropertyRead))return{kind:"property-read",source:f(t,o.readSource,`${e}.readSource`,n),readProp:M(t,o.readProp,e,"readProp")};if(d(t,o.Traverse))return{kind:"traverse",source:f(t,o.traverseSource,`${e}.traverseSource`,n),through:M(t,o.through,e,"through"),step:f(t,o.step,`${e}.step`,n)};if(d(t,o.BuildAstNode))return{kind:"build-ast-node",astClass:M(t,o.astClass,e,"astClass"),set:Yt(t,`${e}.set`,n)};if(d(t,o.When))return{kind:"when",condition:f(t,o.condition,`${e}.condition`,n),thenBuild:f(t,o.thenBuild,`${e}.thenBuild`,n),elseBuild:Jt(t,o.elseBuild,`${e}.elseBuild`,n)};if(d(t,o.Concat))return{kind:"concat",parts:ke(t,o.parts,`${e}.parts`,n)};if(d(t,o.Fallback))return{kind:"fallback",primary:f(t,o.primary,`${e}.primary`,n),alternate:f(t,o.alternate,`${e}.alternate`,n)};if(d(t,o.UriName))return{kind:"uri-name",source:f(t,o.uriNameOf,`${e}.uriNameOf`,n)};if(d(t,o.UriPublisher))return{kind:"uri-publisher",source:f(t,o.uriPublisherOf,`${e}.uriPublisherOf`,n)};if(d(t,o.UriPackage))return{kind:"uri-package",source:f(t,o.uriPackageOf,`${e}.uriPackageOf`,n)};if(d(t,o.UriVersion))return{kind:"uri-version",source:f(t,o.uriVersionOf,`${e}.uriVersionOf`,n)};if(d(t,o.SubjectUri))return{kind:"subject-uri",source:f(t,o.subjectOf,`${e}.subjectOf`,n)};if(d(t,o.UriLiteral))return{kind:"uri-literal",refTo:M(t,o.refTo,e,"refTo")};if(d(t,o.DisplayLabel))return{kind:"display-label",labelTarget:M(t,o.labelTarget,e,"labelTarget"),labelSource:M(t,o.labelSource,e,"labelSource")};if(d(t,o.ResolveRef))return{kind:"resolve-ref",source:f(t,o.resolveSource,`${e}.resolveSource`,n)};if(d(t,o.Normalize))return{kind:"normalize",source:f(t,o.normSource,`${e}.normSource`,n),normKind:Zt(t,e)};if(d(t,o.IsSet))return{kind:"is-set",check:f(t,o.checkExpr,`${e}.checkExpr`,n)};if(d(t,o.CallFragment))return Qt(t,e,n);if(d(t,o.Join))return{kind:"join",source:f(t,o.source,`${e}.source`,n),separator:j(t,o.separator,e)};if(d(t,o.Count))return{kind:"count",source:f(t,o.source,`${e}.source`,n)};if(d(t,o.Sum))return{kind:"sum",source:f(t,o.source,`${e}.source`,n)};if(d(t,o.Min))return{kind:"min",source:f(t,o.source,`${e}.source`,n)};if(d(t,o.Max))return{kind:"max",source:f(t,o.source,`${e}.source`,n)};if(d(t,o.Average))return{kind:"average",source:f(t,o.source,`${e}.source`,n)};if(d(t,o.ForEach))return{kind:"for-each",source:f(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),emit:f(t,o.emit,`${e}.emit`,n)};if(d(t,o.ListMap))return{kind:"list-map",source:f(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),mapBody:f(t,o.mapBody,`${e}.mapBody`,n)};if(d(t,o.Filter))return{kind:"filter",source:f(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),predicate:f(t,o.predicate,`${e}.predicate`,n)};if(d(t,o.PartitionBy))return{kind:"partition-by",source:f(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),partitionKey:f(t,o.partitionKey,`${e}.partitionKey`,n)};if(d(t,o.DistinctBy))return{kind:"distinct-by",source:f(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),distinctKey:f(t,o.distinctKey,`${e}.distinctKey`,n)};if(d(t,o.AllStatements))return{kind:"all-statements",source:f(t,o.statementsOf,`${e}.statementsOf`,n)};if(d(t,o.StatementPredicate))return{kind:"statement-predicate",source:f(t,o.predicateOf,`${e}.predicateOf`,n)};if(d(t,o.StatementValue))return{kind:"statement-value",source:f(t,o.valueOf,`${e}.valueOf`,n)};if(d(t,o.DateFormat))return{kind:"date-format",source:f(t,o.dateSource,`${e}.dateSource`,n),format:xt(t,e)};if(d(t,o.Add))return{kind:"add",left:f(t,o.arithLeft,`${e}.arithLeft`,n),right:f(t,o.arithRight,`${e}.arithRight`,n)};if(d(t,o.Subtract))return{kind:"subtract",left:f(t,o.arithLeft,`${e}.arithLeft`,n),right:f(t,o.arithRight,`${e}.arithRight`,n)};if(d(t,o.Multiply))return{kind:"multiply",left:f(t,o.arithLeft,`${e}.arithLeft`,n),right:f(t,o.arithRight,`${e}.arithRight`,n)};if(d(t,o.Divide))return{kind:"divide",left:f(t,o.arithLeft,`${e}.arithLeft`,n),right:f(t,o.arithRight,`${e}.arithRight`,n)};if(d(t,o.Reverse))return{kind:"reverse",source:f(t,o.source,`${e}.source`,n)};if(d(t,o.WindowedMap)){let r=Ye(t,o.windowSize);if(r===void 0||!Number.isInteger(r)||r<1)throw new y("windowSize must be a positive integer",`${e}.windowSize`);return{kind:"windowed-map",source:f(t,o.source,`${e}.source`,n),windowSize:r,windowVar:j(t,o.windowVar,e),windowBody:f(t,o.windowBody,`${e}.windowBody`,n)}}if(d(t,o.PairwiseMap))return{kind:"pairwise-map",source:f(t,o.source,`${e}.source`,n),firstVar:j(t,o.firstVar,e),secondVar:j(t,o.secondVar,e),pairBody:f(t,o.pairBody,`${e}.pairBody`,n)};if(d(t,o.Scan))return{kind:"scan",source:f(t,o.source,`${e}.source`,n),initialState:f(t,o.initialState,`${e}.initialState`,n),stateVar:j(t,o.stateVar,e),elementVar:j(t,o.elementVar,e),accumulate:f(t,o.accumulate,`${e}.accumulate`,n)};if(d(t,o.ListItemAt))return{kind:"list-item-at",source:f(t,o.source,`${e}.source`,n),itemIndex:f(t,o.itemIndex,`${e}.itemIndex`,n)};if(d(t,o.Equals))return{kind:"equals",left:f(t,o.compareLeft,`${e}.compareLeft`,n),right:f(t,o.compareRight,`${e}.compareRight`,n)};if(d(t,o.GreaterThan))return{kind:"greater-than",left:f(t,o.compareLeft,`${e}.compareLeft`,n),right:f(t,o.compareRight,`${e}.compareRight`,n)};if(d(t,o.LessThan))return{kind:"less-than",left:f(t,o.compareLeft,`${e}.compareLeft`,n),right:f(t,o.compareRight,`${e}.compareRight`,n)};if(d(t,o.GreaterThanOrEqual))return{kind:"greater-than-or-equal",left:f(t,o.compareLeft,`${e}.compareLeft`,n),right:f(t,o.compareRight,`${e}.compareRight`,n)};if(d(t,o.LessThanOrEqual))return{kind:"less-than-or-equal",left:f(t,o.compareLeft,`${e}.compareLeft`,n),right:f(t,o.compareRight,`${e}.compareRight`,n)};if(d(t,o.Not))return{kind:"not",operand:f(t,o.operand,`${e}.operand`,n)};if(d(t,o.And))return{kind:"and",operands:ke(t,o.operands,`${e}.operands`,n)};if(d(t,o.Or))return{kind:"or",operands:ke(t,o.operands,`${e}.operands`,n)};if(d(t,o.Contains))return{kind:"contains",haystack:f(t,o.haystack,`${e}.haystack`,n),needle:f(t,o.needle,`${e}.needle`,n)};if(d(t,o.Abs))return{kind:"abs",value:f(t,o.value,`${e}.value`,n)};if(d(t,o.Negate))return{kind:"negate",value:f(t,o.value,`${e}.value`,n)};if(d(t,o.IsReference))return{kind:"is-reference",check:f(t,o.kindCheck,`${e}.kindCheck`,n)};if(d(t,o.IsEmbedded))return{kind:"is-embedded",check:f(t,o.kindCheck,`${e}.kindCheck`,n)};if(d(t,o.IsList))return{kind:"is-list",check:f(t,o.kindCheck,`${e}.kindCheck`,n)};if(d(t,o.StatementObject))return{kind:"statement-object",source:f(t,o.statementSource,`${e}.statementSource`,n)};if(d(t,o.Let))return{kind:"let",bindName:j(t,o.letName,e),bindValue:f(t,o.letValue,`${e}.letValue`,n),body:f(t,o.letBody,`${e}.letBody`,n)};if(d(t,o.GetStatementByName))return{kind:"get-statement-by-name",inSubject:f(t,o.inSubject,`${e}.inSubject`,n),byName:f(t,o.byName,`${e}.byName`,n)};throw new y("Expression is not of a recognized v3 type \u2014 embedded has no matching subclass of tx.Expression",e)}function f(t,e,n,r){let i=ne(t,e);if(!i)throw new y("child expression is required",n);return H(i,n,r)}function Jt(t,e,n,r){let i=ne(t,e);if(i)return H(i,n,r)}function ke(t,e,n,r){let i=[],a=0;for(let u of A(t,e))if(u instanceof w)for(let c of u.object)c instanceof P&&i.push(H(c,`${n}[${a++}]`,r));else u instanceof T&&i.push(H(u.object,`${n}[${a++}]`,r));return i}function Yt(t,e,n){let r=[],i=0;for(let a of A(t,o.set))if(a instanceof w)for(let u of a.object)u instanceof P&&r.push(qe(u,`${e}[${i++}]`,n));else a instanceof T&&r.push(qe(a.object,`${e}[${i++}]`,n));return r}function qe(t,e,n){return{field:M(t,o.field,e,"field"),value:f(t,o.bindValue,`${e}.bindValue`,n)}}function Zt(t,e){let n=_(t,o.normKind);if(!n)throw new y("normKind is required",e);if(E(n,o.NORM_TRIM_END))return"trim-end";throw new y(`Unknown NormalizeKind: ${n.publisher}/${n.package_}/${n.name}`,e)}var We=new Set(["iso-date","iso-datetime","short-date","long-date","year","month-year"]);function xt(t,e){let n=z(t,o.dateFormat);if(!n)throw new y("dateFormat is required",e);if(!We.has(n))throw new y(`Unknown dateFormat "${n}"; supported: ${[...We].join(", ")}`,e);return n}function Qt(t,e,n){let r=_(t,o.fragmentRef);if(!r)throw new y("fragmentRef is required",e);if(!nn(n.catalog,r))throw new y(`ExpressionFragment not found: ${r.publisher}/${r.package_}/${r.name}`,e);return{kind:"call-fragment",fragmentKey:en(r)}}function en(t){return`${t.publisher}/${t.package_}/${t.name}`}function tn(t){let e=new Map,n=[];for(let r of t){if(!(r instanceof b)||!d(r,o.ExpressionFragment))continue;let i=ne(r,o.body);if(!i)continue;let a=(r.namespace||"").split("@")[0]||"",u=a.indexOf("/");if(u<0)continue;let c=a.substring(0,u),l=a.substring(u+1),m=`${c}/${l}/${r.name}`;n.push({key:m,subject:r,bodyEmb:i,pubPkgName:`${a}/${r.name}`})}for(let r of n){let i=H(r.bodyEmb,`fragment(${r.pubPkgName})`,{catalog:t,depth:0});e.set(r.key,i)}return e}function nn(t,e){for(let n of t)if(!(!(n instanceof b)||n.name!==e.name||!(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))&&d(n,o.ExpressionFragment))return n}function Xe(t,e){let n=new Set;for(let r of A(t,o.outputs))if(r instanceof V)n.add(r.object.subject.name);else if(r instanceof w)for(let i of r.object)i instanceof h&&n.add(i.subject.name);if(n.size===0)throw new y("outputs is required (at least one OutputFormat)",e);return n}function Je(t,e,n){let r=new Map,i=0;for(let a of A(t,o.formatOverrides))if(a instanceof w){for(let u of a.object)if(u instanceof P){let[c,l]=ze(u,`${e}[${i++}]`);r.set(c,l)}}else if(a instanceof T){let[u,c]=ze(a.object,`${e}[${i++}]`);r.set(u,c)}return r}function ze(t,e){let n=_(t,o.formatTarget);if(!n)throw new y("formatTarget is required",e);let r=[];for(let c of A(t,o.metadataKeys))if(c instanceof D)r.push(c.object);else if(c instanceof w)for(let l of c.object){let m=l.value;typeof m=="string"&&r.push(m)}let i=new Map;for(let c of A(t,o.metadataRenames))if(c instanceof w){for(let l of c.object)if(l instanceof P){let m=z(l,o.fromKey),g=z(l,o.toKey);m&&g&&i.set(m,g)}}else if(c instanceof T){let l=c.object,m=z(l,o.fromKey),g=z(l,o.toKey);m&&g&&i.set(m,g)}let a=he(t,o.trailingNewline),u=he(t,o.omitWrapper);return[n.name,{metadataKeys:r.length>0?r:void 0,metadataRenames:i,trailingNewline:a,omitWrapper:u}]}function rn(t){return t.predicate?.subject}function A(t,e){let n=[];for(let r of t.statement){let i=rn(r);i&&E(i,e)&&n.push(r)}return n}function ne(t,e){for(let n of A(t,e))if(n instanceof T)return n.object}function _(t,e){for(let n of A(t,e))if(n instanceof V)return we(n.object.subject)}function z(t,e){for(let n of A(t,e))if(n instanceof D)return n.object}function Ye(t,e){for(let n of A(t,e))if(n instanceof L)return n.object}function he(t,e){for(let n of A(t,e))if(n instanceof C)return n.object}function j(t,e,n){let r=z(t,e);if(r===void 0)throw new y(`${e.name} (string) is required`,n);return r}function He(t,e,n){let r=Ye(t,e);if(r===void 0)throw new y(`${e.name} (number) is required`,n);return r}function an(t,e,n){let r=he(t,e);if(r===void 0)throw new y(`${e.name} (boolean) is required`,n);return r}function M(t,e,n,r){let i=_(t,e);if(!i)throw new y(`${r} (URI reference) is required`,n);return i}function we(t){return{publisher:t.publisher,package_:t.package_,name:t.name}}var U=class extends Error{},ce=class{constructor(e,n,r=new Map){this.resolver=e;this.catalog=n;this.fragments=r}resolver;catalog;fragments;async evaluate(e,n){switch(e.kind){case"string-literal":return e.value;case"integer-literal":return e.value;case"decimal-literal":return e.value;case"boolean-literal":return e.value;case"uri-literal":return{...e.refTo};case"var-ref":{if(!n.has(e.varName))throw new U(`Unbound variable "${e.varName}"`);return n.get(e.varName)}case"concat":{let r=[];for(let i of e.parts){let a=await this.evaluate(i,n);if(a!=null)if(Array.isArray(a))for(let u of a)r.push(u);else r.push(a)}return r}case"fallback":{let r=await this.evaluate(e.primary,n);return xe(r)?r:this.evaluate(e.alternate,n)}case"when":return await this.evaluate(e.condition,n)===!0?this.evaluate(e.thenBuild,n):e.elseBuild?this.evaluate(e.elseBuild,n):void 0;case"is-set":{let r=await this.evaluate(e.check,n);return xe(r)}case"property-read":{let r=await this.evaluate(e.source,n);return Ze(r,e.readProp)}case"traverse":{let r=await this.evaluate(e.source,n);if(!(r instanceof B))return;let i=sn(r,e.through),a=[];for(let u of i){let c=await this.resolver.resolveSubject(u,this.catalog);if(!c)continue;let l=new Map(n);l.set("input",c);let m=await this.evaluate(e.step,l);m!=null&&a.push(ue(m))}return a.join("")}case"uri-name":{let r=await this.evaluate(e.source,n);return G(r)?r.name:r instanceof h?r.subject.name:r instanceof b?r.name:r instanceof P?r.name??"":void 0}case"uri-publisher":{let r=await this.evaluate(e.source,n);return be(r)?.publisher}case"uri-package":{let r=await this.evaluate(e.source,n);return be(r)?.package_}case"uri-version":{let r=await this.evaluate(e.source,n);return be(r)?.version}case"subject-uri":{let r=await this.evaluate(e.source,n);if(r instanceof b){let i=r.namespace??"",a=r.name??"";return!i||!a?void 0:`${i}/${a}`}if(r instanceof h){let i=r.subject,a=i.version;return a&&typeof a.major=="number"?`${i.publisher}/${i.package_}@${a.major}.${a.minor}.${a.patch}/${i.name}`:`${i.publisher}/${i.package_}/${i.name}`}return}case"display-label":{let r=await this.resolver.resolveSubject({...e.labelTarget},this.catalog);return r?Ze(r,e.labelSource):void 0}case"resolve-ref":{let r=await this.evaluate(e.source,n);return r instanceof b?r:r instanceof h?await this.resolver.resolveSubject(r.subject,this.catalog):G(r)?await this.resolver.resolveSubject(r,this.catalog):void 0}case"normalize":{let r=await this.evaluate(e.source,n),i=r==null?"":ue(r);return e.normKind==="trim-end"?i.replace(/[\s\r\n]+$/u,""):i}case"build-ast-node":{let r={kind:e.astClass.name};for(let i of e.set){let a=await this.evaluate(i.value,n);if(a==null||Array.isArray(a)&&a.length===0)continue;let u=i.field.name;cn.has(u)&&(Array.isArray(a)&&a.every(c=>Qe(c))?a=a.map(c=>String(c)).join(""):Qe(a)&&(a=String(a))),r[u]=a}return r}case"call-fragment":{let r=this.fragments.get(e.fragmentKey);if(!r)throw new U(`ExpressionFragment ${e.fragmentKey} not found in registry`);return this.evaluate(r,n)}case"join":return(await this.evaluateList(e.source,n)).map(i=>i==null?"":ue(i)).join(e.separator);case"count":return(await this.evaluateList(e.source,n)).length;case"sum":{let r=await this.evaluateList(e.source,n),i=0;for(let a of r)i+=$(a,"Sum");return i}case"min":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new U("Min on an empty list is undefined; guard with IsSet");let i=$(r[0],"Min");for(let a=1;a<r.length;a++){let u=$(r[a],"Min");u<i&&(i=u)}return i}case"max":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new U("Max on an empty list is undefined; guard with IsSet");let i=$(r[0],"Max");for(let a=1;a<r.length;a++){let u=$(r[a],"Max");u>i&&(i=u)}return i}case"average":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new U("Average on an empty list is undefined; guard with IsSet");let i=0;for(let a of r)i+=$(a,"Average");return i/r.length}case"for-each":{let r=await this.evaluateList(e.source,n),i=[];for(let a of r){let u=new Map(n);u.set(e.loopVar,a);let c=await this.evaluate(e.emit,u);if(c!=null)if(Array.isArray(c))for(let l of c)i.push(l);else i.push(c)}return i}case"list-map":{let r=await this.evaluateList(e.source,n),i=[];for(let a of r){let u=new Map(n);u.set(e.loopVar,a),i.push(await this.evaluate(e.mapBody,u))}return i}case"filter":{let r=await this.evaluateList(e.source,n),i=[];for(let a of r){let u=new Map(n);u.set(e.loopVar,a),await this.evaluate(e.predicate,u)===!0&&i.push(a)}return i}case"partition-by":{let r=await this.evaluateList(e.source,n),i=new Map,a=[];for(let u of r){let c=new Map(n);c.set(e.loopVar,u);let l=await this.evaluate(e.partitionKey,c),m=nt(l),g=i.get(m);g||(g={kind:"Partition",key:l,members:[]},i.set(m,g),a.push(m)),g.members.push(u)}return a.map(u=>i.get(u))}case"distinct-by":{let r=await this.evaluateList(e.source,n),i=new Set,a=[];for(let u of r){let c=new Map(n);c.set(e.loopVar,u);let l=await this.evaluate(e.distinctKey,c),m=nt(l);i.has(m)||(i.add(m),a.push(u))}return a}case"all-statements":{let r=await this.evaluate(e.source,n);return r instanceof B?r.statement:[]}case"statement-predicate":{let r=await this.evaluate(e.source,n);if($e(r)){let i=r.predicate;if(i instanceof h)return i}return}case"statement-value":{let r=await this.evaluate(e.source,n);return $e(r)?dn(r):void 0}case"date-format":{let r=await this.evaluate(e.source,n),i=r==null?"":ue(r);return i?fn(i,e.format):""}case"add":{let r=$(await this.evaluate(e.left,n),"Add"),i=$(await this.evaluate(e.right,n),"Add");return r+i}case"subtract":{let r=$(await this.evaluate(e.left,n),"Subtract"),i=$(await this.evaluate(e.right,n),"Subtract");return r-i}case"multiply":{let r=$(await this.evaluate(e.left,n),"Multiply"),i=$(await this.evaluate(e.right,n),"Multiply");return r*i}case"divide":{let r=$(await this.evaluate(e.left,n),"Divide"),i=$(await this.evaluate(e.right,n),"Divide");if(i===0)throw new U("Divide by zero; guard with When");return r/i}case"reverse":{if(e.source.kind==="reverse")return this.evaluate(e.source.source,n);let r=await this.evaluateReverseIterator(e.source,n);return r!==void 0?r:[...await this.evaluateList(e.source,n)].reverse()}case"windowed-map":{let r=await this.evaluateList(e.source,n);if(r.length<e.windowSize)return[];let i=[];for(let a=0;a+e.windowSize<=r.length;a++){let u=r.slice(a,a+e.windowSize),c=new Map(n);c.set(e.windowVar,u);let l=await this.evaluate(e.windowBody,c);if(l!=null)if(Array.isArray(l))for(let m of l)i.push(m);else i.push(l)}return i}case"pairwise-map":{let r=await this.evaluateList(e.source,n);if(r.length<2)return[];let i=[];for(let a=0;a+1<r.length;a++){let u=new Map(n);u.set(e.firstVar,r[a]),u.set(e.secondVar,r[a+1]);let c=await this.evaluate(e.pairBody,u);if(c!=null)if(Array.isArray(c))for(let l of c)i.push(l);else i.push(c)}return i}case"scan":{let r=await this.evaluateList(e.source,n);if(r.length===0)return[];let i=await this.evaluate(e.initialState,n),a=[];for(let u of r){let c=new Map(n);c.set(e.stateVar,i),c.set(e.elementVar,u);let l=await this.evaluate(e.accumulate,c);a.push(l),i=l}return a}case"list-item-at":{let r=await this.evaluateList(e.source,n),i=await this.evaluate(e.itemIndex,n);return typeof i!="number"||!Number.isInteger(i)||i<0||i>=r.length?void 0:r[i]}case"equals":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return et(r,i)}case"greater-than":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return typeof r!="number"||typeof i!="number"?!1:r>i}case"less-than":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return typeof r!="number"||typeof i!="number"?!1:r<i}case"greater-than-or-equal":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return typeof r!="number"||typeof i!="number"?!1:r>=i}case"less-than-or-equal":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return typeof r!="number"||typeof i!="number"?!1:r<=i}case"not":{let r=await this.evaluate(e.operand,n);return r===!0?!1:r===!1?!0:void 0}case"and":{for(let r of e.operands)if(await this.evaluate(r,n)!==!0)return!1;return!0}case"or":{for(let r of e.operands)if(await this.evaluate(r,n)===!0)return!0;return!1}case"contains":{let r=await this.evaluateList(e.haystack,n),i=await this.evaluate(e.needle,n);for(let a of r)if(et(a,i))return!0;return!1}case"abs":{let r=$(await this.evaluate(e.value,n),"Abs");return Math.abs(r)}case"negate":return-$(await this.evaluate(e.value,n),"Negate");case"is-reference":{let r=await this.evaluate(e.check,n);return r instanceof h||r instanceof b}case"is-embedded":return await this.evaluate(e.check,n)instanceof P;case"is-list":{let r=await this.evaluate(e.check,n);return Array.isArray(r)}case"statement-object":{let r=await this.evaluate(e.source,n);if(!$e(r))return;let i=r;return i instanceof D||i instanceof L||i instanceof C||i instanceof V||i instanceof T||i instanceof w?i.object:void 0}case"let":{let r=await this.evaluate(e.bindValue,n),i=new Map(n);return i.set(e.bindName,r),this.evaluate(e.body,i)}case"get-statement-by-name":{let r=await this.evaluate(e.inSubject,n),i=await this.evaluate(e.byName,n);if(!(r instanceof B)||typeof i!="string")return;for(let a of r.statement)if(a.predicate?.subject?.name===i)return a;return}default:{let r=e;throw new U("Unknown expression kind")}}}async evaluateList(e,n){let r=await this.evaluate(e,n);return r==null?[]:Array.isArray(r)?r:[r]}async evaluateReverseIterator(e,n){if(e.kind==="pairwise-map"){let r=await this.evaluateList(e.source,n);if(r.length<2)return[];let i=[];for(let a=r.length-1;a>=1;a--){let u=new Map(n);u.set(e.firstVar,r[a-1]),u.set(e.secondVar,r[a]);let c=await this.evaluate(e.pairBody,u);if(c!=null)if(Array.isArray(c))for(let l of c)i.push(l);else i.push(c)}return i}if(e.kind==="for-each"){let r=await this.evaluateList(e.source,n),i=[];for(let a=r.length-1;a>=0;a--){let u=new Map(n);u.set(e.loopVar,r[a]);let c=await this.evaluate(e.emit,u);if(c!=null)if(Array.isArray(c))for(let l of c)i.push(l);else i.push(c)}return i}if(e.kind==="list-map"){let r=await this.evaluateList(e.source,n),i=[];for(let a=r.length-1;a>=0;a--){let u=new Map(n);u.set(e.loopVar,r[a]),i.push(await this.evaluate(e.mapBody,u))}return i}if(e.kind==="windowed-map"){let r=await this.evaluateList(e.source,n);if(r.length<e.windowSize)return[];let i=[];for(let a=r.length-e.windowSize;a>=0;a--){let u=r.slice(a,a+e.windowSize),c=new Map(n);c.set(e.windowVar,u);let l=await this.evaluate(e.windowBody,c);if(l!=null)if(Array.isArray(l))for(let m of l)i.push(m);else i.push(l)}return i}}};function Ze(t,e){if(t instanceof B)return on(t,e);if(un(t))return E(e,o.key)?t.key:E(e,o.members)?t.members:void 0}function on(t,e){for(let n of t.statement){let r=rt(n);if(!(!r||!E(r,e))&&(n instanceof D||n instanceof L||n instanceof C||n instanceof V||n instanceof T||n instanceof w))return n.object}}function sn(t,e){let n=[];for(let r of t.statement){let i=rt(r);if(!(!i||!E(i,e))){if(r instanceof V)n.push(r.object.subject);else if(r instanceof w)for(let a of r.object)a instanceof h&&n.push(a.subject)}}return n}function rt(t){return t.predicate?.subject}function ue(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t instanceof B)return t.name??"";if(t instanceof h)return t.subject.name;if(G(t))return t.name;let e=t.value;return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function xe(t){return t==null?!1:typeof t=="string"||Array.isArray(t)?t.length>0:typeof t=="boolean"?t===!0:!0}function G(t){return typeof t=="object"&&t!==null&&typeof t.publisher=="string"&&typeof t.package_=="string"&&typeof t.name=="string"}function un(t){return typeof t=="object"&&t!==null&&t.kind==="Partition"&&Array.isArray(t.members)}function $(t,e){if(typeof t=="number"&&Number.isFinite(t))return t;throw new U(`${e} requires numeric elements; got ${ln(t)}`)}function be(t){if(t instanceof b){let e=t.namespace??"",n=e.indexOf("/"),r=e.indexOf("@",n+1);return n<0||r<0?void 0:{publisher:e.substring(0,n),package_:e.substring(n+1,r),version:e.substring(r+1),name:t.name??""}}if(t instanceof h){let e=t.subject,n=e.version;return{publisher:e.publisher,package_:e.package_,version:n&&typeof n.major=="number"?`${n.major}.${n.minor}.${n.patch}`:"",name:e.name}}if(G(t))return{publisher:t.publisher,package_:t.package_,version:"",name:t.name}}var cn=new Set(["stringValue","text","rawContent","key","propertyKey","linkLabel"]);function Qe(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function ln(t){return t===void 0?"undefined":t===null?"null":Array.isArray(t)?`array(${t.length})`:typeof t}function fn(t,e){let n=new Date(t);if(isNaN(n.getTime()))return"";let r=n.getUTCFullYear(),i=["January","February","March","April","May","June","July","August","September","October","November","December"][n.getUTCMonth()],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n.getUTCMonth()],u=n.getUTCDate(),c=(l,m=2)=>String(l).padStart(m,"0");switch(e){case"iso-date":return`${r}-${c(n.getUTCMonth()+1)}-${c(u)}`;case"iso-datetime":return`${r}-${c(n.getUTCMonth()+1)}-${c(u)}T${c(n.getUTCHours())}:${c(n.getUTCMinutes())}:${c(n.getUTCSeconds())}Z`;case"short-date":return`${a} ${u}`;case"long-date":return`${i} ${u}, ${r}`;case"year":return String(r);case"month-year":return`${i} ${r}`}}function et(t,e){if(t==null||e===void 0||e===null)return!1;if(t===e)return!0;let n=typeof t=="object"&&"value"in t?t.value:void 0,r=typeof e=="object"&&"value"in e?e.value:void 0,i=n??t,a=r??e,u=tt(t),c=tt(e);return u&&c?u.publisher===c.publisher&&u.package_===c.package_&&u.name===c.name:typeof i=="string"&&typeof a=="string"||typeof i=="number"&&typeof a=="number"||typeof i=="boolean"&&typeof a=="boolean"?i===a:!1}function tt(t){if(t instanceof h){let e=t.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}if(t instanceof b){let e=t.namespace??"",n=e.indexOf("/"),r=e.indexOf("@",n+1);if(n<0)return;let i=e.substring(0,n),a=r>=0?e.substring(n+1,r):e.substring(n+1);return{publisher:i,package_:a,name:t.name??""}}if(G(t))return{publisher:t.publisher,package_:t.package_,name:t.name}}function $e(t){return t instanceof D||t instanceof L||t instanceof C||t instanceof V||t instanceof T||t instanceof w}function dn(t){return t instanceof D||t instanceof L||t instanceof C?String(t.object??""):t instanceof V?t.object?.subject?.name??"":t instanceof T?"[embedded]":t instanceof w?(t.object??[]).map(n=>{if(n instanceof h)return n.subject.name;let r=n.name;if(r&&r.length>0)return r;let i=n.value;return typeof i=="string"||typeof i=="number"||typeof i=="boolean"?String(i):"[embedded]"}).join(", "):""}function nt(t){if(t===void 0)return"\0undef";if(t===null)return"\0null";if(typeof t=="string")return`s:${t}`;if(typeof t=="number")return`n:${t}`;if(typeof t=="boolean")return`b:${t}`;if(t instanceof h){let e=t.subject;return`r:${e.publisher}/${e.package_}/${e.name}`}if(t instanceof B){let e=t.name??"";return`k:${t.namespace??""}/${e}`}return G(t)?`u:${t.publisher}/${t.package_}/${t.name}`:`o:${JSON.stringify(t)}`}var mn={"markdown-with-frontmatter":{formatUri:"kanonak.org/transformations/markdown-with-frontmatter",extension:".md"},"plain-markdown":{formatUri:"kanonak.org/transformations/plain-markdown",extension:".md"},toml:{formatUri:"kanonak.org/transformations/toml",extension:".toml"},json:{formatUri:"kanonak.org/transformations/json",extension:".json"},html:{formatUri:"kanonak.org/transformations/html",extension:".html"},svg:{formatUri:"kanonak.org/transformations/svg",extension:".svg"},stylesheet:{formatUri:"kanonak.org/transformations/stylesheet",extension:".css"},yaml:{formatUri:"kanonak.org/transformations/yaml",extension:".yaml"}},I=class extends Error{},le=class{backends=new Map;constructor(){this.register(new X),this.register(new J),this.register(new Y),this.register(new Z),this.register(new x),this.register(new Q),this.register(new ee)}register(e){this.backends.set(e.backendUri,e)}async run(e){let n=e.transformationKanonaks??e.allKanonaks,r=se(e.transformation,n);if(!r.outputs.has(e.outputFormat))throw new I(`Transformation "${r.name}" does not declare output format "${e.outputFormat}". Declared: ${Array.from(r.outputs).join(", ")}`);let i=this.findBackend(e.outputFormat);if(!i)throw new I(`No backend registered for OutputFormat "${e.outputFormat}".`);let a=new te(e.repository,e.parser,e.objectParser),u=new ce(a,e.allKanonaks,r.fragments);return r.kind==="instance"?this.runInstance(r,e,i,u):this.runSet(r,e,i,u)}async runInstance(e,n,r,i){let a=it(n.instances,e.inputPattern.requires),u=at(a,e.inputPattern.sortBy),c=[];for(let l of u){let m=new Map;m.set("input",l);let g=await i.evaluate(e.rule,m);Se(g,e.name,`input "${l.name}"`);let k=ve(await i.evaluate(e.artifactName,m),e.name,`input "${l.name}"`),K=Ee(e.overrides.get(n.outputFormat),n.runtimeOverride),v=r.render(g,K);c.push({fileName:k,format:n.outputFormat,content:v,source:{kind:"instance",sourceName:l.name}})}return c}async runSet(e,n,r,i){let a=it(n.instances,e.inputPattern.requires),u=at(a,e.inputPattern.sortBy);return e.partitionBy?this.runSetWithPartition(e,u,n,r,i):this.runSetSingle(e,u,n,r,i)}async runSetSingle(e,n,r,i,a){let u=new Map;u.set("inputs",n);let c=await a.evaluate(e.rule,u);Se(c,e.name,"set");let l=ve(await a.evaluate(e.artifactName,u),e.name,"set"),m=Ee(e.overrides.get(r.outputFormat),r.runtimeOverride),g=i.render(c,m);return[{fileName:l,format:r.outputFormat,content:g,source:{kind:"set",memberCount:n.length}}]}async runSetWithPartition(e,n,r,i,a){let u=e.partitionBy,c=new Map,l=[];for(let g of n){let k=yn(g,u);if(k==null)continue;let K=kn(k),v=c.get(K);v||(v={keyValue:k,keyDisplay:hn(k),members:[]},c.set(K,v),l.push(K)),v.members.push(g)}let m=[];for(let g of l){let k=c.get(g),K=new Map;K.set("inputs",k.members),K.set("key",k.keyValue);let v=await a.evaluate(e.rule,K);Se(v,e.name,`partition "${k.keyDisplay}"`);let ct=ve(await a.evaluate(e.artifactName,K),e.name,`partition "${k.keyDisplay}"`),lt=Ee(e.overrides.get(r.outputFormat),r.runtimeOverride),ft=i.render(v,lt);m.push({fileName:ct,format:r.outputFormat,content:ft,source:{kind:"set",memberCount:k.members.length,partitionKey:k.keyDisplay}})}return m}findBackend(e){let n=mn[e];if(n)return this.backends.get(n.formatUri)}};function it(t,e){return e.length===0?t:t.filter(n=>{for(let r of e)if(!gn(n,r))return!1;return!0})}function at(t,e){if(e.length===0)return t;let n=[...t];return n.sort((r,i)=>{for(let a of e){let u=ot(r,a.byProperty),c=ot(i,a.byProperty),l=pn(u,c,a.order);if(l!==0)return l}return 0}),n}function ot(t,e){for(let n of t.statement){let r=je(n);if(!(!r||!E(r,e))){if(n instanceof D||n instanceof L||n instanceof C)return n.object;if(n instanceof w)throw new I(`Sort property "${e.name}" on instance "${t.name??"?"}" resolves to a list \u2014 list-typed properties are not sortable. Use a scalar property.`);if(n instanceof V)throw new I(`Sort property "${e.name}" on instance "${t.name??"?"}" resolves to a reference \u2014 reference-typed properties don't have a natural total order. Use a scalar property.`)}}}function pn(t,e,n){if(t===void 0&&e===void 0)return 0;if(t===void 0)return n==="ascending"?1:-1;if(e===void 0)return n==="ascending"?-1:1;let r;return typeof t=="number"&&typeof e=="number"?r=t-e:r=String(t).localeCompare(String(e)),n==="ascending"?r:-r}function gn(t,e){for(let n of t.statement){let r=je(n);if(!r||!E(r,e))continue;let i=n.object;if(i!=null&&!(typeof i=="string"&&i.length===0)&&!(Array.isArray(i)&&i.length===0))return!0}return!1}function yn(t,e){for(let n of t.statement){let r=je(n);if(!(!r||!E(r,e))&&(n instanceof D||n instanceof L||n instanceof C||n instanceof V||n instanceof w))return n.object}}function je(t){return t.predicate?.subject}function kn(t){if(t===void 0)return" undef";if(t===null)return" null";if(typeof t=="string")return`s:${t}`;if(typeof t=="number")return`n:${t}`;if(typeof t=="boolean")return`b:${t}`;if(t instanceof h){let e=t.subject;return`r:${e.publisher}/${e.package_}/${e.name}`}if(t instanceof B){let e=t.name??"";return`k:${t.namespace??""}/${e}`}if(typeof t=="object"&&t!==null&&typeof t.name=="string"&&typeof t.publisher=="string"){let e=t;return`u:${e.publisher}/${e.package_}/${e.name}`}return`o:${JSON.stringify(t)}`}function hn(t){return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):t instanceof h?t.subject.name:t instanceof B?t.name??"":typeof t=="object"&&t!==null&&typeof t.name=="string"?t.name:""}function Se(t,e,n){if(typeof t!="object"||t===null||t.kind!=="Document")throw new I(`Transformation "${e}" rule did not yield a Document for ${n}. Got: ${st(t)}`)}function ve(t,e,n){if(typeof t=="string")return t;if(Array.isArray(t)&&t.every(wn))return t.map(r=>String(r)).join("");throw new I(`Transformation "${e}" artifactName did not yield a string for ${n}. Got: ${st(t)}`)}function wn(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function st(t){if(t===void 0)return"undefined";if(t===null)return"null";if(Array.isArray(t))return`array(${t.length})`;if(typeof t=="object"){let e=t.kind;return e?`object(kind=${e})`:"object"}return typeof t}function Ee(t,e){if(!t&&!e)return;let n={metadataRenames:e?.metadataRenames??t?.metadataRenames??new Map},r=e?.metadataKeys??t?.metadataKeys;r!==void 0&&(n.metadataKeys=r);let i=e?.trailingNewline??t?.trailingNewline;i!==void 0&&(n.trailingNewline=i);let a=e?.omitWrapper??t?.omitWrapper;return a!==void 0&&(n.omitWrapper=a),n}var O=class extends Error{constructor(n,r){super(n);this.cause=r;this.name="RenderError"}cause},ut={publisher:"kanonak.org",package_:"derivation",name:"default"},Ve=class{constructor(e,n=new Ae,r=new Ke){this.repository=e;this.parser=n;this.objectParser=r}repository;parser;objectParser;runner=new le;cachedCatalog=void 0;invalidate(){this.cachedCatalog=void 0}async findDerivation(e){let n=await this.getCatalog(),r=N(n,e.resource);if(!(r instanceof b))return;let i=e.variant??ut;return Te(r,e.format,i,n)}async render(e){let n=await this.findDerivation(e);if(!n)throw new O(`No derivation found for ${F(e.resource)} \u2192 format ${F(e.format)}`+(e.variant?` variant ${F(e.variant)}`:""));let r={transformation:{publisher:n.transformation.publisher,package_:n.transformation.package_,name:n.transformation.name},input:e.resource,format:e.format};return e.omitWrapper!==void 0&&(r.omitWrapper=e.omitWrapper),this.runTransformation(r)}async runTransformation(e){let n=await this.getCatalog(),r=N(n,e.transformation);if(!(r instanceof b))throw new O(`Transformation not found: ${F(e.transformation)}`);let i=N(n,e.input);if(!(i instanceof b))throw new O(`Input resource not found: ${F(e.input)}`);let a=se(r,n),u=bn(a.outputs,e.format);if(!u)throw new O(`Transformation ${F(e.transformation)} declares outputs [${[...a.outputs].join(", ")}], none of which corresponds to format ${F(e.format)}`);let c;try{c=await this.runner.run({transformation:r,instances:[i],allKanonaks:n,repository:this.repository,parser:this.parser,objectParser:this.objectParser,outputFormat:u,...e.omitWrapper!==void 0?{runtimeOverride:{metadataRenames:new Map,omitWrapper:e.omitWrapper}}:{}})}catch(l){throw new O(`Transformation execution failed: ${l.message}`,l)}if(c.length===0)throw new O("Transformation produced no artifacts");return{content:c[0].content,format:e.format,filename:c[0].fileName}}async getCatalog(){return this.cachedCatalog||(this.cachedCatalog=await this.objectParser.parseKanonaks(this.repository)),this.cachedCatalog}};function F(t){return`${t.publisher}/${t.package_}/${t.name}`}function bn(t,e){let n=e.name;if(t.has(n))return n;for(let r of t)if(r.startsWith(n+"-")||r===n)return r}export{Q as CssBackend,ut as DEFAULT_VARIANT,S as DOCAST,mt as DOCAST_PKG,dt as DOCAST_PUB,ce as ExpressionEngineV3,U as ExpressionEvalErrorV3,Z as HtmlBackend,Y as JsonBackend,X as MarkdownFrontmatterBackend,te as ReferenceResolver,O as RenderError,mn as SUPPORTED_FORMATS_V3,x as SvgBackend,o as TX_V3,zt as TX_V3_PKG,Wt as TX_V3_PUB,Mn as TX_V3_VERSION_MAJOR,J as TomlBackend,Ve as TransformationEngine,y as TransformationLoadErrorV3,I as TransformationRunnerErrorV3,le as TransformationRunnerV3,ee as YamlBackend,se as compileTransformationV3,pe as renderMarkdownToHtml};
|
|
105
|
+
`),i}};var re=class{constructor(e,n,r){this.repository=e;this.parser=n;this.objectParser=r}repository;parser;objectParser;cache=new Map;async resolveSubject(e,n){let r=F(n,e);if(r)return r;let i=e.version,a=i&&typeof i.major=="number"?`@${i.major}.${i.minor}.${i.patch}`:"",u=`${e.publisher}/${e.package_}${a}`,c=this.cache.get(u);if(!c){let m=await this.repository.getDocumentsByNamespaceAsync(e.publisher,e.package_);if(m.length===0)return;let g=i&&typeof i.major=="number"?m.find(K=>{let v=K.metadata?.namespace_?.version;return v&&v.major===i.major&&v.minor===i.minor&&v.patch===i.patch})??m[0]:m[0],k=new Be(g,this.repository);c=await this.objectParser.parseKanonaks(k),this.cache.set(u,c)}let l=F(c,e);if(l)return l;for(let m of c)if(m instanceof S&&m.name===e.name)return m}};var zt="kanonak.org",Gt="transformations",Gn=3,s=t=>({publisher:zt,package_:Gt,name:t}),o={Transformation:s("Transformation"),InstanceTransformation:s("InstanceTransformation"),SetTransformation:s("SetTransformation"),inputPattern:s("inputPattern"),rule:s("rule"),artifactName:s("artifactName"),outputs:s("outputs"),formatOverrides:s("formatOverrides"),partitionBy:s("partitionBy"),InputPattern:s("InputPattern"),matchesClass:s("matchesClass"),requires:s("requires"),sortBy:s("sortBy"),SortKey:s("SortKey"),byProperty:s("byProperty"),order:s("order"),SortOrder:s("SortOrder"),ascending:s("ascending"),descending:s("descending"),OutputFormat:s("OutputFormat"),backendUri:s("backendUri"),FormatOverride:s("FormatOverride"),formatTarget:s("formatTarget"),metadataKeys:s("metadataKeys"),metadataRenames:s("metadataRenames"),trailingNewline:s("trailingNewline"),omitWrapper:s("omitWrapper"),RenameEntry:s("RenameEntry"),fromKey:s("fromKey"),toKey:s("toKey"),FMT_MARKDOWN_FRONTMATTER:s("markdown-with-frontmatter"),FMT_PLAIN_MARKDOWN:s("plain-markdown"),FMT_TOML:s("toml"),FMT_JSON:s("json"),FMT_HTML:s("html"),FMT_SVG:s("svg"),Expression:s("Expression"),ListSourcedExpression:s("ListSourcedExpression"),ListAggregate:s("ListAggregate"),IteratingExpression:s("IteratingExpression"),BuildAstNode:s("BuildAstNode"),astClass:s("astClass"),set:s("set"),AstFieldBinding:s("AstFieldBinding"),field:s("field"),bindValue:s("bindValue"),When:s("When"),condition:s("condition"),thenBuild:s("thenBuild"),elseBuild:s("elseBuild"),Concat:s("Concat"),parts:s("parts"),Fallback:s("Fallback"),primary:s("primary"),alternate:s("alternate"),StringLiteral:s("StringLiteral"),stringLiteral:s("stringLiteral"),IntegerLiteral:s("IntegerLiteral"),integerLiteral:s("integerLiteral"),DecimalLiteral:s("DecimalLiteral"),decimalLiteral:s("decimalLiteral"),BooleanLiteral:s("BooleanLiteral"),booleanLiteral:s("booleanLiteral"),VarRef:s("VarRef"),varName:s("varName"),PropertyRead:s("PropertyRead"),readSource:s("readSource"),readProp:s("readProp"),Traverse:s("Traverse"),traverseSource:s("traverseSource"),through:s("through"),step:s("step"),UriName:s("UriName"),uriNameOf:s("uriNameOf"),UriPublisher:s("UriPublisher"),uriPublisherOf:s("uriPublisherOf"),UriPackage:s("UriPackage"),uriPackageOf:s("uriPackageOf"),UriVersion:s("UriVersion"),uriVersionOf:s("uriVersionOf"),SubjectUri:s("SubjectUri"),subjectOf:s("subjectOf"),UriLiteral:s("UriLiteral"),refTo:s("refTo"),DisplayLabel:s("DisplayLabel"),labelTarget:s("labelTarget"),labelSource:s("labelSource"),ResolveRef:s("ResolveRef"),resolveSource:s("resolveSource"),Normalize:s("Normalize"),normSource:s("normSource"),normKind:s("normKind"),NormalizeKind:s("NormalizeKind"),NORM_TRIM_END:s("trim-end"),IsSet:s("IsSet"),checkExpr:s("checkExpr"),ExpressionFragment:s("ExpressionFragment"),body:s("body"),CallFragment:s("CallFragment"),fragmentRef:s("fragmentRef"),source:s("source"),Join:s("Join"),separator:s("separator"),Count:s("Count"),Sum:s("Sum"),Min:s("Min"),Max:s("Max"),Average:s("Average"),loopVar:s("loopVar"),ForEach:s("ForEach"),emit:s("emit"),ListMap:s("ListMap"),mapBody:s("mapBody"),Filter:s("Filter"),predicate:s("predicate"),PartitionBy:s("PartitionBy"),partitionKey:s("partitionKey"),DistinctBy:s("DistinctBy"),distinctKey:s("distinctKey"),Partition:s("Partition"),key:s("key"),members:s("members"),AllStatements:s("AllStatements"),statementsOf:s("statementsOf"),StatementPredicate:s("StatementPredicate"),predicateOf:s("predicateOf"),StatementValue:s("StatementValue"),valueOf:s("valueOf"),DateFormat:s("DateFormat"),dateSource:s("dateSource"),dateFormat:s("dateFormat"),BinaryArithmetic:s("BinaryArithmetic"),arithLeft:s("arithLeft"),arithRight:s("arithRight"),Add:s("Add"),Subtract:s("Subtract"),Multiply:s("Multiply"),Divide:s("Divide"),Reverse:s("Reverse"),WindowedMap:s("WindowedMap"),windowSize:s("windowSize"),windowVar:s("windowVar"),windowBody:s("windowBody"),PairwiseMap:s("PairwiseMap"),firstVar:s("firstVar"),secondVar:s("secondVar"),pairBody:s("pairBody"),Scan:s("Scan"),initialState:s("initialState"),stateVar:s("stateVar"),elementVar:s("elementVar"),accumulate:s("accumulate"),ListItemAt:s("ListItemAt"),itemIndex:s("itemIndex"),BinaryComparison:s("BinaryComparison"),compareLeft:s("compareLeft"),compareRight:s("compareRight"),Equals:s("Equals"),GreaterThan:s("GreaterThan"),LessThan:s("LessThan"),GreaterThanOrEqual:s("GreaterThanOrEqual"),LessThanOrEqual:s("LessThanOrEqual"),Not:s("Not"),operand:s("operand"),BooleanLogic:s("BooleanLogic"),operands:s("operands"),And:s("And"),Or:s("Or"),Contains:s("Contains"),haystack:s("haystack"),needle:s("needle"),UnaryNumericOp:s("UnaryNumericOp"),value:s("value"),Abs:s("Abs"),Negate:s("Negate"),KindPredicate:s("KindPredicate"),IsReference:s("IsReference"),IsEmbedded:s("IsEmbedded"),IsList:s("IsList"),kindCheck:s("kindCheck"),StatementObject:s("StatementObject"),statementSource:s("statementSource"),Let:s("Let"),letName:s("letName"),letValue:s("letValue"),letBody:s("letBody"),GetStatementByName:s("GetStatementByName"),inSubject:s("inSubject"),byName:s("byName"),RenderMarkdown:s("RenderMarkdown"),renderSource:s("renderSource"),renderProp:s("renderProp"),renderFormat:s("renderFormat"),RenderFormat:s("RenderFormat"),RENDER_HTML:s("render-html"),RENDER_MARKDOWN:s("render-markdown")};var y=class extends Error{constructor(n,r){super(`${n} (at ${r})`);this.path=r}path};function le(t,e){let n=t.name,r=an(e),i={catalog:e,depth:0};if(d(t,o.InstanceTransformation))return Xt(t,n,i,r);if(d(t,o.SetTransformation))return Jt(t,n,i,r);throw new y("Subject is not a recognized v3 transformation type \u2014 expected InstanceTransformation or SetTransformation",n)}function Xt(t,e,n,r){return{kind:"instance",name:t.name,inputPattern:Ze(t,e),rule:ce(t,o.rule,`${e}.rule`,n),artifactName:ce(t,o.artifactName,`${e}.artifactName`,n),outputs:Qe(t,`${e}.outputs`),overrides:xe(t,`${e}.formatOverrides`,n),fragments:r}}function Jt(t,e,n,r){let i=O(t,o.partitionBy);return{kind:"set",name:t.name,inputPattern:Ze(t,e),rule:ce(t,o.rule,`${e}.rule`,n),artifactName:ce(t,o.artifactName,`${e}.artifactName`,n),outputs:Qe(t,`${e}.outputs`),overrides:xe(t,`${e}.formatOverrides`,n),partitionBy:i,fragments:r}}function Ze(t,e){let n=ie(t,o.inputPattern);if(!n)throw new y("inputPattern is required",e);return Yt(n,`${e}.inputPattern`)}function Yt(t,e){let n=O(t,o.matchesClass);if(!n)throw new y("matchesClass is required",e);let r=[];for(let u of A(t,o.requires))if(u instanceof V)r.push(Se(u.object.subject));else if(u instanceof w)for(let c of u.object)c instanceof h&&r.push(Se(c.subject));let i=[],a=0;for(let u of A(t,o.sortBy))if(u instanceof w)for(let c of u.object)c instanceof P&&i.push(ze(c,`${e}.sortBy[${a++}]`));else u instanceof T&&i.push(ze(u.object,`${e}.sortBy[${a++}]`));return{matchesClass:n,requires:r,sortBy:i}}function ze(t,e){let n=O(t,o.byProperty);if(!n)throw new y("SortKey.byProperty is required",e);let r=O(t,o.order);if(!r)throw new y("SortKey.order is required",e);if(b(r,o.ascending))return{byProperty:n,order:"ascending"};if(b(r,o.descending))return{byProperty:n,order:"descending"};throw new y(`SortKey.order must reference tx.ascending or tx.descending; got ${r.publisher}/${r.package_}/${r.name}`,e)}function ce(t,e,n,r){let i=ie(t,e);if(!i)throw new y("expression is required",n);return G(i,n,r)}function G(t,e,n){if(d(t,o.StringLiteral))return{kind:"string-literal",value:j(t,o.stringLiteral,e)};if(d(t,o.IntegerLiteral))return{kind:"integer-literal",value:Ye(t,o.integerLiteral,e)};if(d(t,o.DecimalLiteral))return{kind:"decimal-literal",value:Ye(t,o.decimalLiteral,e)};if(d(t,o.BooleanLiteral))return{kind:"boolean-literal",value:un(t,o.booleanLiteral,e)};if(d(t,o.VarRef))return{kind:"var-ref",varName:j(t,o.varName,e)};if(d(t,o.PropertyRead))return{kind:"property-read",source:f(t,o.readSource,`${e}.readSource`,n),readProp:M(t,o.readProp,e,"readProp")};if(d(t,o.Traverse))return{kind:"traverse",source:f(t,o.traverseSource,`${e}.traverseSource`,n),through:M(t,o.through,e,"through"),step:f(t,o.step,`${e}.step`,n)};if(d(t,o.BuildAstNode))return{kind:"build-ast-node",astClass:M(t,o.astClass,e,"astClass"),set:Qt(t,`${e}.set`,n)};if(d(t,o.When))return{kind:"when",condition:f(t,o.condition,`${e}.condition`,n),thenBuild:f(t,o.thenBuild,`${e}.thenBuild`,n),elseBuild:Zt(t,o.elseBuild,`${e}.elseBuild`,n)};if(d(t,o.Concat))return{kind:"concat",parts:we(t,o.parts,`${e}.parts`,n)};if(d(t,o.Fallback))return{kind:"fallback",primary:f(t,o.primary,`${e}.primary`,n),alternate:f(t,o.alternate,`${e}.alternate`,n)};if(d(t,o.UriName))return{kind:"uri-name",source:f(t,o.uriNameOf,`${e}.uriNameOf`,n)};if(d(t,o.UriPublisher))return{kind:"uri-publisher",source:f(t,o.uriPublisherOf,`${e}.uriPublisherOf`,n)};if(d(t,o.UriPackage))return{kind:"uri-package",source:f(t,o.uriPackageOf,`${e}.uriPackageOf`,n)};if(d(t,o.UriVersion))return{kind:"uri-version",source:f(t,o.uriVersionOf,`${e}.uriVersionOf`,n)};if(d(t,o.SubjectUri))return{kind:"subject-uri",source:f(t,o.subjectOf,`${e}.subjectOf`,n)};if(d(t,o.UriLiteral))return{kind:"uri-literal",refTo:M(t,o.refTo,e,"refTo")};if(d(t,o.DisplayLabel))return{kind:"display-label",labelTarget:M(t,o.labelTarget,e,"labelTarget"),labelSource:M(t,o.labelSource,e,"labelSource")};if(d(t,o.ResolveRef))return{kind:"resolve-ref",source:f(t,o.resolveSource,`${e}.resolveSource`,n)};if(d(t,o.Normalize))return{kind:"normalize",source:f(t,o.normSource,`${e}.normSource`,n),normKind:xt(t,e)};if(d(t,o.RenderMarkdown))return{kind:"render-markdown",source:f(t,o.renderSource,`${e}.renderSource`,n),readProp:M(t,o.renderProp,e,"renderProp"),format:en(t,e)};if(d(t,o.IsSet))return{kind:"is-set",check:f(t,o.checkExpr,`${e}.checkExpr`,n)};if(d(t,o.CallFragment))return nn(t,e,n);if(d(t,o.Join))return{kind:"join",source:f(t,o.source,`${e}.source`,n),separator:j(t,o.separator,e)};if(d(t,o.Count))return{kind:"count",source:f(t,o.source,`${e}.source`,n)};if(d(t,o.Sum))return{kind:"sum",source:f(t,o.source,`${e}.source`,n)};if(d(t,o.Min))return{kind:"min",source:f(t,o.source,`${e}.source`,n)};if(d(t,o.Max))return{kind:"max",source:f(t,o.source,`${e}.source`,n)};if(d(t,o.Average))return{kind:"average",source:f(t,o.source,`${e}.source`,n)};if(d(t,o.ForEach))return{kind:"for-each",source:f(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),emit:f(t,o.emit,`${e}.emit`,n)};if(d(t,o.ListMap))return{kind:"list-map",source:f(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),mapBody:f(t,o.mapBody,`${e}.mapBody`,n)};if(d(t,o.Filter))return{kind:"filter",source:f(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),predicate:f(t,o.predicate,`${e}.predicate`,n)};if(d(t,o.PartitionBy))return{kind:"partition-by",source:f(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),partitionKey:f(t,o.partitionKey,`${e}.partitionKey`,n)};if(d(t,o.DistinctBy))return{kind:"distinct-by",source:f(t,o.source,`${e}.source`,n),loopVar:j(t,o.loopVar,e),distinctKey:f(t,o.distinctKey,`${e}.distinctKey`,n)};if(d(t,o.AllStatements))return{kind:"all-statements",source:f(t,o.statementsOf,`${e}.statementsOf`,n)};if(d(t,o.StatementPredicate))return{kind:"statement-predicate",source:f(t,o.predicateOf,`${e}.predicateOf`,n)};if(d(t,o.StatementValue))return{kind:"statement-value",source:f(t,o.valueOf,`${e}.valueOf`,n)};if(d(t,o.DateFormat))return{kind:"date-format",source:f(t,o.dateSource,`${e}.dateSource`,n),format:tn(t,e)};if(d(t,o.Add))return{kind:"add",left:f(t,o.arithLeft,`${e}.arithLeft`,n),right:f(t,o.arithRight,`${e}.arithRight`,n)};if(d(t,o.Subtract))return{kind:"subtract",left:f(t,o.arithLeft,`${e}.arithLeft`,n),right:f(t,o.arithRight,`${e}.arithRight`,n)};if(d(t,o.Multiply))return{kind:"multiply",left:f(t,o.arithLeft,`${e}.arithLeft`,n),right:f(t,o.arithRight,`${e}.arithRight`,n)};if(d(t,o.Divide))return{kind:"divide",left:f(t,o.arithLeft,`${e}.arithLeft`,n),right:f(t,o.arithRight,`${e}.arithRight`,n)};if(d(t,o.Reverse))return{kind:"reverse",source:f(t,o.source,`${e}.source`,n)};if(d(t,o.WindowedMap)){let r=et(t,o.windowSize);if(r===void 0||!Number.isInteger(r)||r<1)throw new y("windowSize must be a positive integer",`${e}.windowSize`);return{kind:"windowed-map",source:f(t,o.source,`${e}.source`,n),windowSize:r,windowVar:j(t,o.windowVar,e),windowBody:f(t,o.windowBody,`${e}.windowBody`,n)}}if(d(t,o.PairwiseMap))return{kind:"pairwise-map",source:f(t,o.source,`${e}.source`,n),firstVar:j(t,o.firstVar,e),secondVar:j(t,o.secondVar,e),pairBody:f(t,o.pairBody,`${e}.pairBody`,n)};if(d(t,o.Scan))return{kind:"scan",source:f(t,o.source,`${e}.source`,n),initialState:f(t,o.initialState,`${e}.initialState`,n),stateVar:j(t,o.stateVar,e),elementVar:j(t,o.elementVar,e),accumulate:f(t,o.accumulate,`${e}.accumulate`,n)};if(d(t,o.ListItemAt))return{kind:"list-item-at",source:f(t,o.source,`${e}.source`,n),itemIndex:f(t,o.itemIndex,`${e}.itemIndex`,n)};if(d(t,o.Equals))return{kind:"equals",left:f(t,o.compareLeft,`${e}.compareLeft`,n),right:f(t,o.compareRight,`${e}.compareRight`,n)};if(d(t,o.GreaterThan))return{kind:"greater-than",left:f(t,o.compareLeft,`${e}.compareLeft`,n),right:f(t,o.compareRight,`${e}.compareRight`,n)};if(d(t,o.LessThan))return{kind:"less-than",left:f(t,o.compareLeft,`${e}.compareLeft`,n),right:f(t,o.compareRight,`${e}.compareRight`,n)};if(d(t,o.GreaterThanOrEqual))return{kind:"greater-than-or-equal",left:f(t,o.compareLeft,`${e}.compareLeft`,n),right:f(t,o.compareRight,`${e}.compareRight`,n)};if(d(t,o.LessThanOrEqual))return{kind:"less-than-or-equal",left:f(t,o.compareLeft,`${e}.compareLeft`,n),right:f(t,o.compareRight,`${e}.compareRight`,n)};if(d(t,o.Not))return{kind:"not",operand:f(t,o.operand,`${e}.operand`,n)};if(d(t,o.And))return{kind:"and",operands:we(t,o.operands,`${e}.operands`,n)};if(d(t,o.Or))return{kind:"or",operands:we(t,o.operands,`${e}.operands`,n)};if(d(t,o.Contains))return{kind:"contains",haystack:f(t,o.haystack,`${e}.haystack`,n),needle:f(t,o.needle,`${e}.needle`,n)};if(d(t,o.Abs))return{kind:"abs",value:f(t,o.value,`${e}.value`,n)};if(d(t,o.Negate))return{kind:"negate",value:f(t,o.value,`${e}.value`,n)};if(d(t,o.IsReference))return{kind:"is-reference",check:f(t,o.kindCheck,`${e}.kindCheck`,n)};if(d(t,o.IsEmbedded))return{kind:"is-embedded",check:f(t,o.kindCheck,`${e}.kindCheck`,n)};if(d(t,o.IsList))return{kind:"is-list",check:f(t,o.kindCheck,`${e}.kindCheck`,n)};if(d(t,o.StatementObject))return{kind:"statement-object",source:f(t,o.statementSource,`${e}.statementSource`,n)};if(d(t,o.Let))return{kind:"let",bindName:j(t,o.letName,e),bindValue:f(t,o.letValue,`${e}.letValue`,n),body:f(t,o.letBody,`${e}.letBody`,n)};if(d(t,o.GetStatementByName))return{kind:"get-statement-by-name",inSubject:f(t,o.inSubject,`${e}.inSubject`,n),byName:f(t,o.byName,`${e}.byName`,n)};throw new y("Expression is not of a recognized v3 type \u2014 embedded has no matching subclass of tx.Expression",e)}function f(t,e,n,r){let i=ie(t,e);if(!i)throw new y("child expression is required",n);return G(i,n,r)}function Zt(t,e,n,r){let i=ie(t,e);if(i)return G(i,n,r)}function we(t,e,n,r){let i=[],a=0;for(let u of A(t,e))if(u instanceof w)for(let c of u.object)c instanceof P&&i.push(G(c,`${n}[${a++}]`,r));else u instanceof T&&i.push(G(u.object,`${n}[${a++}]`,r));return i}function Qt(t,e,n){let r=[],i=0;for(let a of A(t,o.set))if(a instanceof w)for(let u of a.object)u instanceof P&&r.push(Ge(u,`${e}[${i++}]`,n));else a instanceof T&&r.push(Ge(a.object,`${e}[${i++}]`,n));return r}function Ge(t,e,n){return{field:M(t,o.field,e,"field"),value:f(t,o.bindValue,`${e}.bindValue`,n)}}function xt(t,e){let n=O(t,o.normKind);if(!n)throw new y("normKind is required",e);if(b(n,o.NORM_TRIM_END))return"trim-end";throw new y(`Unknown NormalizeKind: ${n.publisher}/${n.package_}/${n.name}`,e)}function en(t,e){let n=O(t,o.renderFormat);if(!n)throw new y("renderFormat is required",e);if(b(n,o.RENDER_HTML))return"html";if(b(n,o.RENDER_MARKDOWN))return"markdown";throw new y(`Unknown RenderFormat: ${n.publisher}/${n.package_}/${n.name}`,e)}var Xe=new Set(["iso-date","iso-datetime","short-date","long-date","year","month-year"]);function tn(t,e){let n=z(t,o.dateFormat);if(!n)throw new y("dateFormat is required",e);if(!Xe.has(n))throw new y(`Unknown dateFormat "${n}"; supported: ${[...Xe].join(", ")}`,e);return n}function nn(t,e,n){let r=O(t,o.fragmentRef);if(!r)throw new y("fragmentRef is required",e);if(!on(n.catalog,r))throw new y(`ExpressionFragment not found: ${r.publisher}/${r.package_}/${r.name}`,e);return{kind:"call-fragment",fragmentKey:rn(r)}}function rn(t){return`${t.publisher}/${t.package_}/${t.name}`}function an(t){let e=new Map,n=[];for(let r of t){if(!(r instanceof S)||!d(r,o.ExpressionFragment))continue;let i=ie(r,o.body);if(!i)continue;let a=(r.namespace||"").split("@")[0]||"",u=a.indexOf("/");if(u<0)continue;let c=a.substring(0,u),l=a.substring(u+1),m=`${c}/${l}/${r.name}`;n.push({key:m,subject:r,bodyEmb:i,pubPkgName:`${a}/${r.name}`})}for(let r of n){let i=G(r.bodyEmb,`fragment(${r.pubPkgName})`,{catalog:t,depth:0});e.set(r.key,i)}return e}function on(t,e){for(let n of t)if(!(!(n instanceof S)||n.name!==e.name||!(n.namespace||"").startsWith(`${e.publisher}/${e.package_}@`))&&d(n,o.ExpressionFragment))return n}function Qe(t,e){let n=new Set;for(let r of A(t,o.outputs))if(r instanceof V)n.add(r.object.subject.name);else if(r instanceof w)for(let i of r.object)i instanceof h&&n.add(i.subject.name);if(n.size===0)throw new y("outputs is required (at least one OutputFormat)",e);return n}function xe(t,e,n){let r=new Map,i=0;for(let a of A(t,o.formatOverrides))if(a instanceof w){for(let u of a.object)if(u instanceof P){let[c,l]=Je(u,`${e}[${i++}]`);r.set(c,l)}}else if(a instanceof T){let[u,c]=Je(a.object,`${e}[${i++}]`);r.set(u,c)}return r}function Je(t,e){let n=O(t,o.formatTarget);if(!n)throw new y("formatTarget is required",e);let r=[];for(let c of A(t,o.metadataKeys))if(c instanceof R)r.push(c.object);else if(c instanceof w)for(let l of c.object){let m=l.value;typeof m=="string"&&r.push(m)}let i=new Map;for(let c of A(t,o.metadataRenames))if(c instanceof w){for(let l of c.object)if(l instanceof P){let m=z(l,o.fromKey),g=z(l,o.toKey);m&&g&&i.set(m,g)}}else if(c instanceof T){let l=c.object,m=z(l,o.fromKey),g=z(l,o.toKey);m&&g&&i.set(m,g)}let a=be(t,o.trailingNewline),u=be(t,o.omitWrapper);return[n.name,{metadataKeys:r.length>0?r:void 0,metadataRenames:i,trailingNewline:a,omitWrapper:u}]}function sn(t){return t.predicate?.subject}function A(t,e){let n=[];for(let r of t.statement){let i=sn(r);i&&b(i,e)&&n.push(r)}return n}function ie(t,e){for(let n of A(t,e))if(n instanceof T)return n.object}function O(t,e){for(let n of A(t,e))if(n instanceof V)return Se(n.object.subject)}function z(t,e){for(let n of A(t,e))if(n instanceof R)return n.object}function et(t,e){for(let n of A(t,e))if(n instanceof L)return n.object}function be(t,e){for(let n of A(t,e))if(n instanceof B)return n.object}function j(t,e,n){let r=z(t,e);if(r===void 0)throw new y(`${e.name} (string) is required`,n);return r}function Ye(t,e,n){let r=et(t,e);if(r===void 0)throw new y(`${e.name} (number) is required`,n);return r}function un(t,e,n){let r=be(t,e);if(r===void 0)throw new y(`${e.name} (boolean) is required`,n);return r}function M(t,e,n,r){let i=O(t,e);if(!i)throw new y(`${r} (URI reference) is required`,n);return i}function Se(t){return{publisher:t.publisher,package_:t.package_,name:t.name}}var cn={publisher:"kanonak.org",package_:"core-rdf",name:"label"},U=class extends Error{},de=class{constructor(e,n,r=new Map){this.resolver=e;this.catalog=n;this.fragments=r}resolver;catalog;fragments;async evaluate(e,n){switch(e.kind){case"string-literal":return e.value;case"integer-literal":return e.value;case"decimal-literal":return e.value;case"boolean-literal":return e.value;case"uri-literal":return{...e.refTo};case"var-ref":{if(!n.has(e.varName))throw new U(`Unbound variable "${e.varName}"`);return n.get(e.varName)}case"concat":{let r=[];for(let i of e.parts){let a=await this.evaluate(i,n);if(a!=null)if(Array.isArray(a))for(let u of a)r.push(u);else r.push(a)}return r}case"fallback":{let r=await this.evaluate(e.primary,n);return tt(r)?r:this.evaluate(e.alternate,n)}case"when":return await this.evaluate(e.condition,n)===!0?this.evaluate(e.thenBuild,n):e.elseBuild?this.evaluate(e.elseBuild,n):void 0;case"is-set":{let r=await this.evaluate(e.check,n);return tt(r)}case"property-read":{let r=await this.evaluate(e.source,n);return fe(r,e.readProp)}case"traverse":{let r=await this.evaluate(e.source,n);if(!(r instanceof D))return;let i=fn(r,e.through),a=[];for(let u of i){let c=await this.resolver.resolveSubject(u,this.catalog);if(!c)continue;let l=new Map(n);l.set("input",c);let m=await this.evaluate(e.step,l);m!=null&&a.push(ae(m))}return a.join("")}case"uri-name":{let r=await this.evaluate(e.source,n);return X(r)?r.name:r instanceof h?r.subject.name:r instanceof S?r.name:r instanceof P?r.name??"":void 0}case"uri-publisher":{let r=await this.evaluate(e.source,n);return $e(r)?.publisher}case"uri-package":{let r=await this.evaluate(e.source,n);return $e(r)?.package_}case"uri-version":{let r=await this.evaluate(e.source,n);return $e(r)?.version}case"subject-uri":{let r=await this.evaluate(e.source,n);if(r instanceof S){let i=r.namespace??"",a=r.name??"";return!i||!a?void 0:`${i}/${a}`}if(r instanceof h){let i=r.subject,a=i.version;return a&&typeof a.major=="number"?`${i.publisher}/${i.package_}@${a.major}.${a.minor}.${a.patch}/${i.name}`:`${i.publisher}/${i.package_}/${i.name}`}return}case"display-label":{let r=await this.resolver.resolveSubject({...e.labelTarget},this.catalog);return r?fe(r,e.labelSource):void 0}case"resolve-ref":{let r=await this.evaluate(e.source,n);return r instanceof S?r:r instanceof h?await this.resolver.resolveSubject(r.subject,this.catalog):X(r)?await this.resolver.resolveSubject(r,this.catalog):void 0}case"normalize":{let r=await this.evaluate(e.source,n),i=r==null?"":ae(r);return e.normKind==="trim-end"?i.replace(/[\s\r\n]+$/u,""):i}case"render-markdown":{let r=await this.evaluate(e.source,n);if(!(r instanceof D))return;let i;for(let u of r.statement){let c=ve(u);if(c&&b(c,e.readProp)){i=u;break}}if(!(i instanceof Re)){let u=fe(r,e.readProp);return u==null?void 0:ae(u)}let a=await this.renderMarkdownLinks(i);return e.format==="html"?Q(a):a}case"build-ast-node":{let r={kind:e.astClass.name};for(let i of e.set){let a=await this.evaluate(i.value,n);if(a==null||Array.isArray(a)&&a.length===0)continue;let u=i.field.name;mn.has(u)&&(Array.isArray(a)&&a.every(c=>nt(c))?a=a.map(c=>String(c)).join(""):nt(a)&&(a=String(a))),r[u]=a}return r}case"call-fragment":{let r=this.fragments.get(e.fragmentKey);if(!r)throw new U(`ExpressionFragment ${e.fragmentKey} not found in registry`);return this.evaluate(r,n)}case"join":return(await this.evaluateList(e.source,n)).map(i=>i==null?"":ae(i)).join(e.separator);case"count":return(await this.evaluateList(e.source,n)).length;case"sum":{let r=await this.evaluateList(e.source,n),i=0;for(let a of r)i+=$(a,"Sum");return i}case"min":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new U("Min on an empty list is undefined; guard with IsSet");let i=$(r[0],"Min");for(let a=1;a<r.length;a++){let u=$(r[a],"Min");u<i&&(i=u)}return i}case"max":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new U("Max on an empty list is undefined; guard with IsSet");let i=$(r[0],"Max");for(let a=1;a<r.length;a++){let u=$(r[a],"Max");u>i&&(i=u)}return i}case"average":{let r=await this.evaluateList(e.source,n);if(r.length===0)throw new U("Average on an empty list is undefined; guard with IsSet");let i=0;for(let a of r)i+=$(a,"Average");return i/r.length}case"for-each":{let r=await this.evaluateList(e.source,n),i=[];for(let a of r){let u=new Map(n);u.set(e.loopVar,a);let c=await this.evaluate(e.emit,u);if(c!=null)if(Array.isArray(c))for(let l of c)i.push(l);else i.push(c)}return i}case"list-map":{let r=await this.evaluateList(e.source,n),i=[];for(let a of r){let u=new Map(n);u.set(e.loopVar,a),i.push(await this.evaluate(e.mapBody,u))}return i}case"filter":{let r=await this.evaluateList(e.source,n),i=[];for(let a of r){let u=new Map(n);u.set(e.loopVar,a),await this.evaluate(e.predicate,u)===!0&&i.push(a)}return i}case"partition-by":{let r=await this.evaluateList(e.source,n),i=new Map,a=[];for(let u of r){let c=new Map(n);c.set(e.loopVar,u);let l=await this.evaluate(e.partitionKey,c),m=at(l),g=i.get(m);g||(g={kind:"Partition",key:l,members:[]},i.set(m,g),a.push(m)),g.members.push(u)}return a.map(u=>i.get(u))}case"distinct-by":{let r=await this.evaluateList(e.source,n),i=new Set,a=[];for(let u of r){let c=new Map(n);c.set(e.loopVar,u);let l=await this.evaluate(e.distinctKey,c),m=at(l);i.has(m)||(i.add(m),a.push(u))}return a}case"all-statements":{let r=await this.evaluate(e.source,n);return r instanceof D?r.statement:[]}case"statement-predicate":{let r=await this.evaluate(e.source,n);if(Ee(r)){let i=r.predicate;if(i instanceof h)return i}return}case"statement-value":{let r=await this.evaluate(e.source,n);return Ee(r)?yn(r):void 0}case"date-format":{let r=await this.evaluate(e.source,n),i=r==null?"":ae(r);return i?gn(i,e.format):""}case"add":{let r=$(await this.evaluate(e.left,n),"Add"),i=$(await this.evaluate(e.right,n),"Add");return r+i}case"subtract":{let r=$(await this.evaluate(e.left,n),"Subtract"),i=$(await this.evaluate(e.right,n),"Subtract");return r-i}case"multiply":{let r=$(await this.evaluate(e.left,n),"Multiply"),i=$(await this.evaluate(e.right,n),"Multiply");return r*i}case"divide":{let r=$(await this.evaluate(e.left,n),"Divide"),i=$(await this.evaluate(e.right,n),"Divide");if(i===0)throw new U("Divide by zero; guard with When");return r/i}case"reverse":{if(e.source.kind==="reverse")return this.evaluate(e.source.source,n);let r=await this.evaluateReverseIterator(e.source,n);return r!==void 0?r:[...await this.evaluateList(e.source,n)].reverse()}case"windowed-map":{let r=await this.evaluateList(e.source,n);if(r.length<e.windowSize)return[];let i=[];for(let a=0;a+e.windowSize<=r.length;a++){let u=r.slice(a,a+e.windowSize),c=new Map(n);c.set(e.windowVar,u);let l=await this.evaluate(e.windowBody,c);if(l!=null)if(Array.isArray(l))for(let m of l)i.push(m);else i.push(l)}return i}case"pairwise-map":{let r=await this.evaluateList(e.source,n);if(r.length<2)return[];let i=[];for(let a=0;a+1<r.length;a++){let u=new Map(n);u.set(e.firstVar,r[a]),u.set(e.secondVar,r[a+1]);let c=await this.evaluate(e.pairBody,u);if(c!=null)if(Array.isArray(c))for(let l of c)i.push(l);else i.push(c)}return i}case"scan":{let r=await this.evaluateList(e.source,n);if(r.length===0)return[];let i=await this.evaluate(e.initialState,n),a=[];for(let u of r){let c=new Map(n);c.set(e.stateVar,i),c.set(e.elementVar,u);let l=await this.evaluate(e.accumulate,c);a.push(l),i=l}return a}case"list-item-at":{let r=await this.evaluateList(e.source,n),i=await this.evaluate(e.itemIndex,n);return typeof i!="number"||!Number.isInteger(i)||i<0||i>=r.length?void 0:r[i]}case"equals":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return rt(r,i)}case"greater-than":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return typeof r!="number"||typeof i!="number"?!1:r>i}case"less-than":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return typeof r!="number"||typeof i!="number"?!1:r<i}case"greater-than-or-equal":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return typeof r!="number"||typeof i!="number"?!1:r>=i}case"less-than-or-equal":{let r=await this.evaluate(e.left,n),i=await this.evaluate(e.right,n);return typeof r!="number"||typeof i!="number"?!1:r<=i}case"not":{let r=await this.evaluate(e.operand,n);return r===!0?!1:r===!1?!0:void 0}case"and":{for(let r of e.operands)if(await this.evaluate(r,n)!==!0)return!1;return!0}case"or":{for(let r of e.operands)if(await this.evaluate(r,n)===!0)return!0;return!1}case"contains":{let r=await this.evaluateList(e.haystack,n),i=await this.evaluate(e.needle,n);for(let a of r)if(rt(a,i))return!0;return!1}case"abs":{let r=$(await this.evaluate(e.value,n),"Abs");return Math.abs(r)}case"negate":return-$(await this.evaluate(e.value,n),"Negate");case"is-reference":{let r=await this.evaluate(e.check,n);return r instanceof h||r instanceof S}case"is-embedded":return await this.evaluate(e.check,n)instanceof P;case"is-list":{let r=await this.evaluate(e.check,n);return Array.isArray(r)}case"statement-object":{let r=await this.evaluate(e.source,n);if(!Ee(r))return;let i=r;return i instanceof R||i instanceof L||i instanceof B||i instanceof V||i instanceof T||i instanceof w?i.object:void 0}case"let":{let r=await this.evaluate(e.bindValue,n),i=new Map(n);return i.set(e.bindName,r),this.evaluate(e.body,i)}case"get-statement-by-name":{let r=await this.evaluate(e.inSubject,n),i=await this.evaluate(e.byName,n);if(!(r instanceof D)||typeof i!="string")return;for(let a of r.statement)if(a.predicate?.subject?.name===i)return a;return}default:{let r=e;throw new U("Unknown expression kind")}}}async renderMarkdownLinks(e){let n=e.object,r="",i=0;for(let a of e.links){if(r+=n.slice(i,a.startOffset),a.target){let u=a.target.subject,c=a.displayText??await this.resolveLabel(u)??u.name;r+=`[${c}](${I(u)})`}else r+=a.displayText??a.reference;i=a.endOffset}return r+=n.slice(i),r}async resolveLabel(e){let n=await this.resolver.resolveSubject(e,this.catalog);if(!n)return;let r=fe(n,cn);return typeof r=="string"?r:void 0}async evaluateList(e,n){let r=await this.evaluate(e,n);return r==null?[]:Array.isArray(r)?r:[r]}async evaluateReverseIterator(e,n){if(e.kind==="pairwise-map"){let r=await this.evaluateList(e.source,n);if(r.length<2)return[];let i=[];for(let a=r.length-1;a>=1;a--){let u=new Map(n);u.set(e.firstVar,r[a-1]),u.set(e.secondVar,r[a]);let c=await this.evaluate(e.pairBody,u);if(c!=null)if(Array.isArray(c))for(let l of c)i.push(l);else i.push(c)}return i}if(e.kind==="for-each"){let r=await this.evaluateList(e.source,n),i=[];for(let a=r.length-1;a>=0;a--){let u=new Map(n);u.set(e.loopVar,r[a]);let c=await this.evaluate(e.emit,u);if(c!=null)if(Array.isArray(c))for(let l of c)i.push(l);else i.push(c)}return i}if(e.kind==="list-map"){let r=await this.evaluateList(e.source,n),i=[];for(let a=r.length-1;a>=0;a--){let u=new Map(n);u.set(e.loopVar,r[a]),i.push(await this.evaluate(e.mapBody,u))}return i}if(e.kind==="windowed-map"){let r=await this.evaluateList(e.source,n);if(r.length<e.windowSize)return[];let i=[];for(let a=r.length-e.windowSize;a>=0;a--){let u=r.slice(a,a+e.windowSize),c=new Map(n);c.set(e.windowVar,u);let l=await this.evaluate(e.windowBody,c);if(l!=null)if(Array.isArray(l))for(let m of l)i.push(m);else i.push(l)}return i}}};function fe(t,e){if(t instanceof D)return ln(t,e);if(dn(t))return b(e,o.key)?t.key:b(e,o.members)?t.members:void 0}function ln(t,e){for(let n of t.statement){let r=ve(n);if(!(!r||!b(r,e))&&(n instanceof R||n instanceof L||n instanceof B||n instanceof V||n instanceof T||n instanceof w))return n.object}}function fn(t,e){let n=[];for(let r of t.statement){let i=ve(r);if(!(!i||!b(i,e))){if(r instanceof V)n.push(r.object.subject);else if(r instanceof w)for(let a of r.object)a instanceof h&&n.push(a.subject)}}return n}function ve(t){return t.predicate?.subject}function ae(t){if(t==null)return"";if(typeof t=="string")return t;if(typeof t=="number"||typeof t=="boolean")return String(t);if(t instanceof D)return t.name??"";if(t instanceof h)return t.subject.name;if(X(t))return t.name;let e=t.value;return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"?String(e):""}function tt(t){return t==null?!1:typeof t=="string"||Array.isArray(t)?t.length>0:typeof t=="boolean"?t===!0:!0}function X(t){return typeof t=="object"&&t!==null&&typeof t.publisher=="string"&&typeof t.package_=="string"&&typeof t.name=="string"}function dn(t){return typeof t=="object"&&t!==null&&t.kind==="Partition"&&Array.isArray(t.members)}function $(t,e){if(typeof t=="number"&&Number.isFinite(t))return t;throw new U(`${e} requires numeric elements; got ${pn(t)}`)}function $e(t){if(t instanceof S){let e=t.namespace??"",n=e.indexOf("/"),r=e.indexOf("@",n+1);return n<0||r<0?void 0:{publisher:e.substring(0,n),package_:e.substring(n+1,r),version:e.substring(r+1),name:t.name??""}}if(t instanceof h){let e=t.subject,n=e.version;return{publisher:e.publisher,package_:e.package_,version:n&&typeof n.major=="number"?`${n.major}.${n.minor}.${n.patch}`:"",name:e.name}}if(X(t))return{publisher:t.publisher,package_:t.package_,version:"",name:t.name}}var mn=new Set(["stringValue","text","rawContent","key","propertyKey","linkLabel"]);function nt(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function pn(t){return t===void 0?"undefined":t===null?"null":Array.isArray(t)?`array(${t.length})`:typeof t}function gn(t,e){let n=new Date(t);if(isNaN(n.getTime()))return"";let r=n.getUTCFullYear(),i=["January","February","March","April","May","June","July","August","September","October","November","December"][n.getUTCMonth()],a=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"][n.getUTCMonth()],u=n.getUTCDate(),c=(l,m=2)=>String(l).padStart(m,"0");switch(e){case"iso-date":return`${r}-${c(n.getUTCMonth()+1)}-${c(u)}`;case"iso-datetime":return`${r}-${c(n.getUTCMonth()+1)}-${c(u)}T${c(n.getUTCHours())}:${c(n.getUTCMinutes())}:${c(n.getUTCSeconds())}Z`;case"short-date":return`${a} ${u}`;case"long-date":return`${i} ${u}, ${r}`;case"year":return String(r);case"month-year":return`${i} ${r}`}}function rt(t,e){if(t==null||e===void 0||e===null)return!1;if(t===e)return!0;let n=typeof t=="object"&&"value"in t?t.value:void 0,r=typeof e=="object"&&"value"in e?e.value:void 0,i=n??t,a=r??e,u=it(t),c=it(e);return u&&c?u.publisher===c.publisher&&u.package_===c.package_&&u.name===c.name:typeof i=="string"&&typeof a=="string"||typeof i=="number"&&typeof a=="number"||typeof i=="boolean"&&typeof a=="boolean"?i===a:!1}function it(t){if(t instanceof h){let e=t.subject;return{publisher:e.publisher,package_:e.package_,name:e.name}}if(t instanceof S){let e=t.namespace??"",n=e.indexOf("/"),r=e.indexOf("@",n+1);if(n<0)return;let i=e.substring(0,n),a=r>=0?e.substring(n+1,r):e.substring(n+1);return{publisher:i,package_:a,name:t.name??""}}if(X(t))return{publisher:t.publisher,package_:t.package_,name:t.name}}function Ee(t){return t instanceof R||t instanceof L||t instanceof B||t instanceof V||t instanceof T||t instanceof w}function yn(t){return t instanceof R||t instanceof L||t instanceof B?String(t.object??""):t instanceof V?t.object?.subject?.name??"":t instanceof T?"[embedded]":t instanceof w?(t.object??[]).map(n=>{if(n instanceof h)return n.subject.name;let r=n.name;if(r&&r.length>0)return r;let i=n.value;return typeof i=="string"||typeof i=="number"||typeof i=="boolean"?String(i):"[embedded]"}).join(", "):""}function at(t){if(t===void 0)return"\0undef";if(t===null)return"\0null";if(typeof t=="string")return`s:${t}`;if(typeof t=="number")return`n:${t}`;if(typeof t=="boolean")return`b:${t}`;if(t instanceof h){let e=t.subject;return`r:${e.publisher}/${e.package_}/${e.name}`}if(t instanceof D){let e=t.name??"";return`k:${t.namespace??""}/${e}`}return X(t)?`u:${t.publisher}/${t.package_}/${t.name}`:`o:${JSON.stringify(t)}`}var kn={"markdown-with-frontmatter":{formatUri:"kanonak.org/transformations/markdown-with-frontmatter",extension:".md"},"plain-markdown":{formatUri:"kanonak.org/transformations/plain-markdown",extension:".md"},toml:{formatUri:"kanonak.org/transformations/toml",extension:".toml"},json:{formatUri:"kanonak.org/transformations/json",extension:".json"},html:{formatUri:"kanonak.org/transformations/html",extension:".html"},svg:{formatUri:"kanonak.org/transformations/svg",extension:".svg"},stylesheet:{formatUri:"kanonak.org/transformations/stylesheet",extension:".css"},yaml:{formatUri:"kanonak.org/transformations/yaml",extension:".yaml"}},N=class extends Error{},me=class{backends=new Map;constructor(){this.register(new J),this.register(new Y),this.register(new Z),this.register(new x),this.register(new ee),this.register(new te),this.register(new ne)}register(e){this.backends.set(e.backendUri,e)}async run(e){let n=e.transformationKanonaks??e.allKanonaks,r=le(e.transformation,n);if(!r.outputs.has(e.outputFormat))throw new N(`Transformation "${r.name}" does not declare output format "${e.outputFormat}". Declared: ${Array.from(r.outputs).join(", ")}`);let i=this.findBackend(e.outputFormat);if(!i)throw new N(`No backend registered for OutputFormat "${e.outputFormat}".`);let a=new re(e.repository,e.parser,e.objectParser),u=new de(a,e.allKanonaks,r.fragments);return r.kind==="instance"?this.runInstance(r,e,i,u):this.runSet(r,e,i,u)}async runInstance(e,n,r,i){let a=ot(n.instances,e.inputPattern.requires),u=st(a,e.inputPattern.sortBy),c=[];for(let l of u){let m=new Map;m.set("input",l);let g=await i.evaluate(e.rule,m);je(g,e.name,`input "${l.name}"`);let k=Ve(await i.evaluate(e.artifactName,m),e.name,`input "${l.name}"`),K=Ae(e.overrides.get(n.outputFormat),n.runtimeOverride),v=r.render(g,K);c.push({fileName:k,format:n.outputFormat,content:v,source:{kind:"instance",sourceName:l.name}})}return c}async runSet(e,n,r,i){let a=ot(n.instances,e.inputPattern.requires),u=st(a,e.inputPattern.sortBy);return e.partitionBy?this.runSetWithPartition(e,u,n,r,i):this.runSetSingle(e,u,n,r,i)}async runSetSingle(e,n,r,i,a){let u=new Map;u.set("inputs",n);let c=await a.evaluate(e.rule,u);je(c,e.name,"set");let l=Ve(await a.evaluate(e.artifactName,u),e.name,"set"),m=Ae(e.overrides.get(r.outputFormat),r.runtimeOverride),g=i.render(c,m);return[{fileName:l,format:r.outputFormat,content:g,source:{kind:"set",memberCount:n.length}}]}async runSetWithPartition(e,n,r,i,a){let u=e.partitionBy,c=new Map,l=[];for(let g of n){let k=bn(g,u);if(k==null)continue;let K=Sn(k),v=c.get(K);v||(v={keyValue:k,keyDisplay:$n(k),members:[]},c.set(K,v),l.push(K)),v.members.push(g)}let m=[];for(let g of l){let k=c.get(g),K=new Map;K.set("inputs",k.members),K.set("key",k.keyValue);let v=await a.evaluate(e.rule,K);je(v,e.name,`partition "${k.keyDisplay}"`);let ft=Ve(await a.evaluate(e.artifactName,K),e.name,`partition "${k.keyDisplay}"`),dt=Ae(e.overrides.get(r.outputFormat),r.runtimeOverride),mt=i.render(v,dt);m.push({fileName:ft,format:r.outputFormat,content:mt,source:{kind:"set",memberCount:k.members.length,partitionKey:k.keyDisplay}})}return m}findBackend(e){let n=kn[e];if(n)return this.backends.get(n.formatUri)}};function ot(t,e){return e.length===0?t:t.filter(n=>{for(let r of e)if(!wn(n,r))return!1;return!0})}function st(t,e){if(e.length===0)return t;let n=[...t];return n.sort((r,i)=>{for(let a of e){let u=ut(r,a.byProperty),c=ut(i,a.byProperty),l=hn(u,c,a.order);if(l!==0)return l}return 0}),n}function ut(t,e){for(let n of t.statement){let r=Ke(n);if(!(!r||!b(r,e))){if(n instanceof R||n instanceof L||n instanceof B)return n.object;if(n instanceof w)throw new N(`Sort property "${e.name}" on instance "${t.name??"?"}" resolves to a list \u2014 list-typed properties are not sortable. Use a scalar property.`);if(n instanceof V)throw new N(`Sort property "${e.name}" on instance "${t.name??"?"}" resolves to a reference \u2014 reference-typed properties don't have a natural total order. Use a scalar property.`)}}}function hn(t,e,n){if(t===void 0&&e===void 0)return 0;if(t===void 0)return n==="ascending"?1:-1;if(e===void 0)return n==="ascending"?-1:1;let r;return typeof t=="number"&&typeof e=="number"?r=t-e:r=String(t).localeCompare(String(e)),n==="ascending"?r:-r}function wn(t,e){for(let n of t.statement){let r=Ke(n);if(!r||!b(r,e))continue;let i=n.object;if(i!=null&&!(typeof i=="string"&&i.length===0)&&!(Array.isArray(i)&&i.length===0))return!0}return!1}function bn(t,e){for(let n of t.statement){let r=Ke(n);if(!(!r||!b(r,e))&&(n instanceof R||n instanceof L||n instanceof B||n instanceof V||n instanceof w))return n.object}}function Ke(t){return t.predicate?.subject}function Sn(t){if(t===void 0)return" undef";if(t===null)return" null";if(typeof t=="string")return`s:${t}`;if(typeof t=="number")return`n:${t}`;if(typeof t=="boolean")return`b:${t}`;if(t instanceof h){let e=t.subject;return`r:${e.publisher}/${e.package_}/${e.name}`}if(t instanceof D){let e=t.name??"";return`k:${t.namespace??""}/${e}`}if(typeof t=="object"&&t!==null&&typeof t.name=="string"&&typeof t.publisher=="string"){let e=t;return`u:${e.publisher}/${e.package_}/${e.name}`}return`o:${JSON.stringify(t)}`}function $n(t){return t==null?"":typeof t=="string"?t:typeof t=="number"||typeof t=="boolean"?String(t):t instanceof h?t.subject.name:t instanceof D?t.name??"":typeof t=="object"&&t!==null&&typeof t.name=="string"?t.name:""}function je(t,e,n){if(typeof t!="object"||t===null||t.kind!=="Document")throw new N(`Transformation "${e}" rule did not yield a Document for ${n}. Got: ${ct(t)}`)}function Ve(t,e,n){if(typeof t=="string")return t;if(Array.isArray(t)&&t.every(En))return t.map(r=>String(r)).join("");throw new N(`Transformation "${e}" artifactName did not yield a string for ${n}. Got: ${ct(t)}`)}function En(t){return typeof t=="string"||typeof t=="number"||typeof t=="boolean"}function ct(t){if(t===void 0)return"undefined";if(t===null)return"null";if(Array.isArray(t))return`array(${t.length})`;if(typeof t=="object"){let e=t.kind;return e?`object(kind=${e})`:"object"}return typeof t}function Ae(t,e){if(!t&&!e)return;let n={metadataRenames:e?.metadataRenames??t?.metadataRenames??new Map},r=e?.metadataKeys??t?.metadataKeys;r!==void 0&&(n.metadataKeys=r);let i=e?.trailingNewline??t?.trailingNewline;i!==void 0&&(n.trailingNewline=i);let a=e?.omitWrapper??t?.omitWrapper;return a!==void 0&&(n.omitWrapper=a),n}var _=class extends Error{constructor(n,r){super(n);this.cause=r;this.name="RenderError"}cause},lt={publisher:"kanonak.org",package_:"derivation",name:"default"},Te=class{constructor(e,n=new De,r=new Le){this.repository=e;this.parser=n;this.objectParser=r}repository;parser;objectParser;runner=new me;cachedCatalog=void 0;invalidate(){this.cachedCatalog=void 0}async findDerivation(e){let n=await this.getCatalog(),r=F(n,e.resource);if(!(r instanceof S))return;let i=e.variant??lt;return Ce(r,e.format,i,n)}async render(e){let n=await this.findDerivation(e);if(!n)throw new _(`No derivation found for ${q(e.resource)} \u2192 format ${q(e.format)}`+(e.variant?` variant ${q(e.variant)}`:""));let r={transformation:{publisher:n.transformation.publisher,package_:n.transformation.package_,name:n.transformation.name},input:e.resource,format:e.format};return e.omitWrapper!==void 0&&(r.omitWrapper=e.omitWrapper),this.runTransformation(r)}async runTransformation(e){let n=await this.getCatalog(),r=F(n,e.transformation);if(!(r instanceof S))throw new _(`Transformation not found: ${q(e.transformation)}`);let i=F(n,e.input);if(!(i instanceof S))throw new _(`Input resource not found: ${q(e.input)}`);let a=le(r,n),u=vn(a.outputs,e.format);if(!u)throw new _(`Transformation ${q(e.transformation)} declares outputs [${[...a.outputs].join(", ")}], none of which corresponds to format ${q(e.format)}`);let c;try{c=await this.runner.run({transformation:r,instances:[i],allKanonaks:n,repository:this.repository,parser:this.parser,objectParser:this.objectParser,outputFormat:u,...e.omitWrapper!==void 0?{runtimeOverride:{metadataRenames:new Map,omitWrapper:e.omitWrapper}}:{}})}catch(l){throw new _(`Transformation execution failed: ${l.message}`,l)}if(c.length===0)throw new _("Transformation produced no artifacts");return{content:c[0].content,format:e.format,filename:c[0].fileName}}async getCatalog(){return this.cachedCatalog||(this.cachedCatalog=await this.objectParser.parseKanonaks(this.repository)),this.cachedCatalog}};function q(t){return`${t.publisher}/${t.package_}/${t.name}`}function vn(t,e){let n=e.name;if(t.has(n))return n;for(let r of t)if(r.startsWith(n+"-")||r===n)return r}export{te as CssBackend,lt as DEFAULT_VARIANT,E as DOCAST,gt as DOCAST_PKG,pt as DOCAST_PUB,de as ExpressionEngineV3,U as ExpressionEvalErrorV3,x as HtmlBackend,Z as JsonBackend,J as MarkdownFrontmatterBackend,re as ReferenceResolver,_ as RenderError,kn as SUPPORTED_FORMATS_V3,ee as SvgBackend,o as TX_V3,Gt as TX_V3_PKG,zt as TX_V3_PUB,Gn as TX_V3_VERSION_MAJOR,Y as TomlBackend,Te as TransformationEngine,y as TransformationLoadErrorV3,N as TransformationRunnerErrorV3,me as TransformationRunnerV3,ne as YamlBackend,le as compileTransformationV3,Q as renderMarkdownToHtml};
|
|
@@ -90,7 +90,7 @@ export interface CompiledFormatOverrideV3 {
|
|
|
90
90
|
* doctype + style + metadata <dl>; analogous in other backends). */
|
|
91
91
|
omitWrapper?: boolean | undefined;
|
|
92
92
|
}
|
|
93
|
-
export type CompiledExpressionV3 = CompiledStringLiteralV3 | CompiledIntegerLiteralV3 | CompiledDecimalLiteralV3 | CompiledBooleanLiteralV3 | CompiledVarRefV3 | CompiledPropertyReadV3 | CompiledTraverseV3 | CompiledBuildAstNodeV3 | CompiledWhenV3 | CompiledConcatV3 | CompiledFallbackV3 | CompiledUriNameV3 | CompiledUriPublisherV3 | CompiledUriPackageV3 | CompiledUriVersionV3 | CompiledSubjectUriV3 | CompiledUriLiteralV3 | CompiledDisplayLabelV3 | CompiledResolveRefV3 | CompiledNormalizeV3 | CompiledIsSetV3 | CompiledCallFragmentV3 | CompiledJoinV3 | CompiledCountV3 | CompiledSumV3 | CompiledMinV3 | CompiledMaxV3 | CompiledAverageV3 | CompiledForEachV3 | CompiledListMapV3 | CompiledFilterV3 | CompiledPartitionByV3 | CompiledDistinctByV3 | CompiledAllStatementsV3 | CompiledStatementPredicateV3 | CompiledStatementValueV3 | CompiledDateFormatV3 | CompiledAddV3 | CompiledSubtractV3 | CompiledMultiplyV3 | CompiledDivideV3 | CompiledReverseV3 | CompiledWindowedMapV3 | CompiledPairwiseMapV3 | CompiledScanV3 | CompiledListItemAtV3 | CompiledEqualsV3 | CompiledGreaterThanV3 | CompiledLessThanV3 | CompiledGreaterThanOrEqualV3 | CompiledLessThanOrEqualV3 | CompiledNotV3 | CompiledAndV3 | CompiledOrV3 | CompiledContainsV3 | CompiledAbsV3 | CompiledNegateV3 | CompiledIsReferenceV3 | CompiledIsEmbeddedV3 | CompiledIsListV3 | CompiledStatementObjectV3 | CompiledLetV3 | CompiledGetStatementByNameV3;
|
|
93
|
+
export type CompiledExpressionV3 = CompiledStringLiteralV3 | CompiledIntegerLiteralV3 | CompiledDecimalLiteralV3 | CompiledBooleanLiteralV3 | CompiledVarRefV3 | CompiledPropertyReadV3 | CompiledTraverseV3 | CompiledBuildAstNodeV3 | CompiledWhenV3 | CompiledConcatV3 | CompiledFallbackV3 | CompiledUriNameV3 | CompiledUriPublisherV3 | CompiledUriPackageV3 | CompiledUriVersionV3 | CompiledSubjectUriV3 | CompiledUriLiteralV3 | CompiledDisplayLabelV3 | CompiledResolveRefV3 | CompiledNormalizeV3 | CompiledIsSetV3 | CompiledCallFragmentV3 | CompiledJoinV3 | CompiledCountV3 | CompiledSumV3 | CompiledMinV3 | CompiledMaxV3 | CompiledAverageV3 | CompiledForEachV3 | CompiledListMapV3 | CompiledFilterV3 | CompiledPartitionByV3 | CompiledDistinctByV3 | CompiledAllStatementsV3 | CompiledStatementPredicateV3 | CompiledStatementValueV3 | CompiledDateFormatV3 | CompiledAddV3 | CompiledSubtractV3 | CompiledMultiplyV3 | CompiledDivideV3 | CompiledReverseV3 | CompiledWindowedMapV3 | CompiledPairwiseMapV3 | CompiledScanV3 | CompiledListItemAtV3 | CompiledEqualsV3 | CompiledGreaterThanV3 | CompiledLessThanV3 | CompiledGreaterThanOrEqualV3 | CompiledLessThanOrEqualV3 | CompiledNotV3 | CompiledAndV3 | CompiledOrV3 | CompiledContainsV3 | CompiledAbsV3 | CompiledNegateV3 | CompiledIsReferenceV3 | CompiledIsEmbeddedV3 | CompiledIsListV3 | CompiledStatementObjectV3 | CompiledLetV3 | CompiledGetStatementByNameV3 | CompiledRenderMarkdownV3;
|
|
94
94
|
export interface CompiledStringLiteralV3 {
|
|
95
95
|
kind: 'string-literal';
|
|
96
96
|
value: string;
|
|
@@ -122,6 +122,20 @@ export interface CompiledTraverseV3 {
|
|
|
122
122
|
through: EntityUri;
|
|
123
123
|
step: CompiledExpressionV3;
|
|
124
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* `tx.RenderMarkdown` (tx 3.11.0). Reads a core-prose datatype value
|
|
127
|
+
* (`renderProp`) off the subject yielded by `source`, substitutes each
|
|
128
|
+
* embedded `[[reference]]` with a canonical-URL hyperlink, and yields a
|
|
129
|
+
* rendered string. `format` discriminates the output: `html` runs the
|
|
130
|
+
* result through the markdown renderer; `markdown` keeps it as
|
|
131
|
+
* CommonMark with the references rewritten to `[label](url)`.
|
|
132
|
+
*/
|
|
133
|
+
export interface CompiledRenderMarkdownV3 {
|
|
134
|
+
kind: 'render-markdown';
|
|
135
|
+
source: CompiledExpressionV3;
|
|
136
|
+
readProp: EntityUri;
|
|
137
|
+
format: 'html' | 'markdown';
|
|
138
|
+
}
|
|
125
139
|
export interface CompiledBuildAstNodeV3 {
|
|
126
140
|
kind: 'build-ast-node';
|
|
127
141
|
astClass: EntityUri;
|
|
@@ -52,6 +52,16 @@ export declare class ExpressionEngineV3 {
|
|
|
52
52
|
*/
|
|
53
53
|
fragments?: Map<string, CompiledExpressionV3>);
|
|
54
54
|
evaluate(expr: CompiledExpressionV3, env: Env): Promise<EnvValue>;
|
|
55
|
+
/**
|
|
56
|
+
* Substitute every embedded `[[reference]]` in a MarkdownStatement's
|
|
57
|
+
* value with a canonical-URL markdown link `[label](url)`. The label
|
|
58
|
+
* is the `[[ref|label]]` display text, falling back to the resolved
|
|
59
|
+
* target's `rdfs.label`, then its local name. Unresolved links
|
|
60
|
+
* degrade to plain text — `MarkdownLinkRule` reports them.
|
|
61
|
+
*/
|
|
62
|
+
private renderMarkdownLinks;
|
|
63
|
+
/** Resolve a link target's `rdfs.label`; undefined when unresolvable. */
|
|
64
|
+
private resolveLabel;
|
|
55
65
|
/**
|
|
56
66
|
* Evaluate a source expression and coerce its result into a list.
|
|
57
67
|
* Single-valued results are wrapped in a single-element list so
|
|
@@ -204,4 +204,11 @@ export declare const TX_V3: {
|
|
|
204
204
|
readonly GetStatementByName: EntityUri;
|
|
205
205
|
readonly inSubject: EntityUri;
|
|
206
206
|
readonly byName: EntityUri;
|
|
207
|
+
readonly RenderMarkdown: EntityUri;
|
|
208
|
+
readonly renderSource: EntityUri;
|
|
209
|
+
readonly renderProp: EntityUri;
|
|
210
|
+
readonly renderFormat: EntityUri;
|
|
211
|
+
readonly RenderFormat: EntityUri;
|
|
212
|
+
readonly RENDER_HTML: EntityUri;
|
|
213
|
+
readonly RENDER_MARKDOWN: EntityUri;
|
|
207
214
|
};
|
|
@@ -27,6 +27,30 @@ export declare function uriKey(uri: KanonakUri | EntityUri): string;
|
|
|
27
27
|
* + local name (version ignored).
|
|
28
28
|
*/
|
|
29
29
|
export declare function uriMatches(uri: KanonakUri, target: EntityUri): boolean;
|
|
30
|
+
/**
|
|
31
|
+
* Structural shape shared by `KanonakUri` and any URI-parts object —
|
|
32
|
+
* enough to build a canonical URL. `version` carries `major/minor/patch`.
|
|
33
|
+
*/
|
|
34
|
+
export interface CanonicalUriParts {
|
|
35
|
+
publisher: string;
|
|
36
|
+
package_: string;
|
|
37
|
+
name: string;
|
|
38
|
+
version?: {
|
|
39
|
+
major: number;
|
|
40
|
+
minor: number;
|
|
41
|
+
patch: number;
|
|
42
|
+
} | null | undefined;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Map a Kanonak URI to its canonical https URL per the
|
|
46
|
+
* `kanonak-protocol@2.1.0` canonical-url-form convention:
|
|
47
|
+
* `https://publisher/package/version/name` — no `@`, no trailing slash,
|
|
48
|
+
* so fragments append cleanly. A URI with no resolved version falls
|
|
49
|
+
* back to the versionless `https://publisher/package/name` form. The
|
|
50
|
+
* mapping is pure structural substitution — no publisher infrastructure
|
|
51
|
+
* is consulted, and the URL parses back to its source URI structurally.
|
|
52
|
+
*/
|
|
53
|
+
export declare function toCanonicalUrl(uri: CanonicalUriParts): string;
|
|
30
54
|
/**
|
|
31
55
|
* True when a `Kanonak` is a `DefinedKanonak` whose `type` statement's
|
|
32
56
|
* object URI matches the given class URI.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export { uriKey, uriMatches, hasType, findSubjectsByType, findSubjectByUri, getDatatypeValue, getStringValue, getReferenceUri, getEmbeddedValue, getListValues, } from './UriHelpers.js';
|
|
2
|
-
export type { EntityUri } from './UriHelpers.js';
|
|
1
|
+
export { uriKey, uriMatches, toCanonicalUrl, hasType, findSubjectsByType, findSubjectByUri, getDatatypeValue, getStringValue, getReferenceUri, getEmbeddedValue, getListValues, } from './UriHelpers.js';
|
|
2
|
+
export type { EntityUri, CanonicalUriParts } from './UriHelpers.js';
|
|
3
3
|
export { SingleDocumentRepository } from './SingleDocumentRepository.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{a,b,c,d,e,f,g,h,i,j,k}from"../chunk-
|
|
1
|
+
import{a as b,b as c,c as d,d as e,e as f,f as g,g as h,h as i,i as j,j as k,k as l}from"../chunk-2JQMUZWN.js";import{a}from"../chunk-FJ35VIV6.js";import"../chunk-W6T7MOKY.js";import"../chunk-FUUTGGJS.js";export{a as SingleDocumentRepository,g as findSubjectByUri,f as findSubjectsByType,h as getDatatypeValue,k as getEmbeddedValue,l as getListValues,j as getReferenceUri,i as getStringValue,e as hasType,d as toCanonicalUrl,b as uriKey,c as uriMatches};
|
|
@@ -7,4 +7,4 @@ export { KanonakObjectValidator } from './KanonakObjectValidator.js';
|
|
|
7
7
|
export type { IDocumentValidationRule } from './rules/document/IDocumentValidationRule.js';
|
|
8
8
|
export type { IRepositoryValidationRule } from './rules/repository/IRepositoryValidationRule.js';
|
|
9
9
|
export { NamespacePrefixRule, ResourceNamingRule, PropertyTypeSpecificityRule, SubjectKanonakTypeRequiredRule } from './rules/document/index.js';
|
|
10
|
-
export { ImportExistenceRule, UnresolvedReferenceRule, TypeAmbiguityRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, InstancePropertyReferenceRule, DefinitionPropertyReferenceRule, XsdImportRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyImportRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyValueTypeRule, ClassDefinitionRule, EmbeddedKanonakTypeRule } from './rules/repository/index.js';
|
|
10
|
+
export { ImportExistenceRule, UnresolvedReferenceRule, TypeAmbiguityRule, ClassHierarchyCycleRule, PropertyHierarchyCycleRule, PropertyRangeRequiredRule, SubClassOfReferenceRule, SubPropertyOfReferenceRule, NamespaceImportCycleRule, InstancePropertyReferenceRule, DefinitionPropertyReferenceRule, XsdImportRule, AmbiguousReferenceRule, PropertyRangeReferenceRule, ObjectPropertyImportRule, ObjectPropertyValueValidationRule, PropertyDomainRule, PropertyValueTypeRule, ClassDefinitionRule, EmbeddedKanonakTypeRule, MarkdownLinkRule } from './rules/repository/index.js';
|
package/dist/validation/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{A,B,C,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-
|
|
1
|
+
import{A,B,C,D,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z}from"../chunk-L4HXBHJ4.js";import"../chunk-FJ35VIV6.js";import"../chunk-Z72IKY6C.js";import"../chunk-W6T7MOKY.js";import"../chunk-MYITGTGJ.js";import"../chunk-IXE5THUW.js";import"../chunk-FUUTGGJS.js";export{v as AmbiguousReferenceRule,B as ClassDefinitionRule,m as ClassHierarchyCycleRule,t as DefinitionPropertyReferenceRule,i as EmbeddedKanonakTypeRule,j as ImportExistenceRule,s as InstancePropertyReferenceRule,D as KanonakObjectValidator,C as MarkdownLinkRule,r as NamespaceImportCycleRule,e as NamespacePrefixRule,x as ObjectPropertyImportRule,y as ObjectPropertyValueValidationRule,c as OntologyValidationError,a as OntologyValidationResult,z as PropertyDomainRule,n as PropertyHierarchyCycleRule,w as PropertyRangeReferenceRule,o as PropertyRangeRequiredRule,g as PropertyTypeSpecificityRule,A as PropertyValueTypeRule,f as ResourceNamingRule,p as SubClassOfReferenceRule,q as SubPropertyOfReferenceRule,h as SubjectKanonakTypeRequiredRule,l as TypeAmbiguityRule,k as UnresolvedReferenceRule,d as ValidationContext,b as ValidationSeverity,u as XsdImportRule};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { IKanonakDocumentRepository } from '@kanonak-protocol/types/document/models';
|
|
2
|
+
import type { KanonakDocument } from '@kanonak-protocol/types/document/models/types';
|
|
3
|
+
import { OntologyValidationError } from '../../OntologyValidationError.js';
|
|
4
|
+
import type { IRepositoryValidationRule } from './IRepositoryValidationRule.js';
|
|
5
|
+
/**
|
|
6
|
+
* Validates `[[reference]]` placeholders embedded in core-prose datatype
|
|
7
|
+
* values (`Markdown` / `SubstitutableString`). Every placeholder must
|
|
8
|
+
* resolve through the document's import closure — exactly as
|
|
9
|
+
* ObjectProperty references do. Unresolved placeholders are reported as
|
|
10
|
+
* warnings, matching `UnresolvedReferenceRule`'s treatment of
|
|
11
|
+
* unresolved object references.
|
|
12
|
+
*
|
|
13
|
+
* The rule reuses the object parser rather than re-scanning the raw
|
|
14
|
+
* body: a `MarkdownStatement` already records each placeholder's
|
|
15
|
+
* resolution outcome in `links[].target`, so the rule and the parser
|
|
16
|
+
* can never disagree about what resolves.
|
|
17
|
+
*/
|
|
18
|
+
export declare class MarkdownLinkRule implements IRepositoryValidationRule {
|
|
19
|
+
readonly ruleName = "MarkdownLink";
|
|
20
|
+
validateAsync(document: KanonakDocument, repository: IKanonakDocumentRepository): Promise<OntologyValidationError[]>;
|
|
21
|
+
/**
|
|
22
|
+
* Walk a defined kanonak's statements for `MarkdownStatement`s,
|
|
23
|
+
* recursing through embedded kanonaks — a Markdown-ranged property
|
|
24
|
+
* may sit on an embedded object, not just a top-level subject.
|
|
25
|
+
*/
|
|
26
|
+
private checkDefined;
|
|
27
|
+
private unresolvedLinkError;
|
|
28
|
+
}
|