@uniweb/runtime 0.6.13 → 0.6.15
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/app/_importmap/@uniweb-core.js +2 -0
- package/dist/app/_importmap/@uniweb-core.js.map +1 -0
- package/dist/app/_importmap/react-dom.js +2 -0
- package/dist/app/_importmap/react-dom.js.map +1 -0
- package/dist/app/_importmap/react-jsx-dev-runtime.js +2 -0
- package/dist/app/_importmap/react-jsx-dev-runtime.js.map +1 -0
- package/dist/app/_importmap/react-jsx-runtime.js +2 -0
- package/dist/app/_importmap/react-jsx-runtime.js.map +1 -0
- package/dist/app/_importmap/react.js +2 -0
- package/dist/app/_importmap/react.js.map +1 -0
- package/dist/app/assets/_commonjsHelpers-CqkleIqs.js +2 -0
- package/dist/app/assets/_commonjsHelpers-CqkleIqs.js.map +1 -0
- package/dist/app/assets/_importmap_react-dWoQamCw.js +2 -0
- package/dist/app/assets/_importmap_react-dWoQamCw.js.map +1 -0
- package/dist/app/assets/index-C0udIITE.js +9 -0
- package/dist/app/assets/index-C0udIITE.js.map +1 -0
- package/dist/app/assets/index-C6TPxGbh.js +133 -0
- package/dist/app/assets/index-C6TPxGbh.js.map +1 -0
- package/dist/app/assets/index-CsyMBO9p.js +8 -0
- package/dist/app/assets/index-CsyMBO9p.js.map +1 -0
- package/dist/app/assets/index-kA4PVysc.js +2 -0
- package/dist/app/assets/index-kA4PVysc.js.map +1 -0
- package/dist/app/assets/jsx-runtime-C3x2e0aW.js +2 -0
- package/dist/app/assets/jsx-runtime-C3x2e0aW.js.map +1 -0
- package/dist/app/index.html +31 -0
- package/dist/app/manifest.json +19 -0
- package/dist/ssr.js +319 -327
- package/dist/ssr.js.map +1 -1
- package/package.json +7 -4
- package/src/components/PageRenderer.jsx +12 -9
- package/src/foundation-loader.js +3 -0
- package/src/index.jsx +3 -4
- package/src/shell/index.html +12 -0
- package/src/shell/main.js +16 -0
- package/src/ssr-renderer.js +591 -0
- package/src/ssr.js +25 -28
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
const vt=Symbol.for("yaml.alias"),pt=Symbol.for("yaml.document"),W=Symbol.for("yaml.map"),rs=Symbol.for("yaml.pair"),D=Symbol.for("yaml.scalar"),ce=Symbol.for("yaml.seq"),j=Symbol.for("yaml.node.type"),Q=n=>!!n&&typeof n=="object"&&n[j]===vt,qe=n=>!!n&&typeof n=="object"&&n[j]===pt,Ne=n=>!!n&&typeof n=="object"&&n[j]===W,T=n=>!!n&&typeof n=="object"&&n[j]===rs,O=n=>!!n&&typeof n=="object"&&n[j]===D,Le=n=>!!n&&typeof n=="object"&&n[j]===ce;function A(n){if(n&&typeof n=="object")switch(n[j]){case W:case ce:return!0}return!1}function C(n){if(n&&typeof n=="object")switch(n[j]){case vt:case W:case D:case ce:return!0}return!1}const os=n=>(O(n)||A(n))&&!!n.anchor,J=Symbol("break visit"),Hs=Symbol("skip children"),ye=Symbol("remove node");function fe(n,e){const t=Ws(e);qe(n)?se(null,n.contents,t,Object.freeze([n]))===ye&&(n.contents=null):se(null,n,t,Object.freeze([]))}fe.BREAK=J;fe.SKIP=Hs;fe.REMOVE=ye;function se(n,e,t,s){const i=Js(n,e,t,s);if(C(i)||T(i))return Gs(n,s,i),se(n,i,t,s);if(typeof i!="symbol"){if(A(e)){s=Object.freeze(s.concat(e));for(let r=0;r<e.items.length;++r){const o=se(r,e.items[r],t,s);if(typeof o=="number")r=o-1;else{if(o===J)return J;o===ye&&(e.items.splice(r,1),r-=1)}}}else if(T(e)){s=Object.freeze(s.concat(e));const r=se("key",e.key,t,s);if(r===J)return J;r===ye&&(e.key=null);const o=se("value",e.value,t,s);if(o===J)return J;o===ye&&(e.value=null)}}return i}function Ws(n){return typeof n=="object"&&(n.Collection||n.Node||n.Value)?Object.assign({Alias:n.Node,Map:n.Node,Scalar:n.Node,Seq:n.Node},n.Value&&{Map:n.Value,Scalar:n.Value,Seq:n.Value},n.Collection&&{Map:n.Collection,Seq:n.Collection},n):n}function Js(n,e,t,s){if(typeof t=="function")return t(n,e,s);if(Ne(e))return t.Map?.(n,e,s);if(Le(e))return t.Seq?.(n,e,s);if(T(e))return t.Pair?.(n,e,s);if(O(e))return t.Scalar?.(n,e,s);if(Q(e))return t.Alias?.(n,e,s)}function Gs(n,e,t){const s=e[e.length-1];if(A(s))s.items[n]=t;else if(T(s))n==="key"?s.key=t:s.value=t;else if(qe(s))s.contents=t;else{const i=Q(s)?"alias":"scalar";throw new Error(`Cannot replace node with ${i} parent`)}}const zs={"!":"%21",",":"%2C","[":"%5B","]":"%5D","{":"%7B","}":"%7D"},Ys=n=>n.replace(/[!,[\]{}]/g,e=>zs[e]);class _{constructor(e,t){this.docStart=null,this.docEnd=!1,this.yaml=Object.assign({},_.defaultYaml,e),this.tags=Object.assign({},_.defaultTags,t)}clone(){const e=new _(this.yaml,this.tags);return e.docStart=this.docStart,e}atDocument(){const e=new _(this.yaml,this.tags);switch(this.yaml.version){case"1.1":this.atNextDocument=!0;break;case"1.2":this.atNextDocument=!1,this.yaml={explicit:_.defaultYaml.explicit,version:"1.2"},this.tags=Object.assign({},_.defaultTags);break}return e}add(e,t){this.atNextDocument&&(this.yaml={explicit:_.defaultYaml.explicit,version:"1.1"},this.tags=Object.assign({},_.defaultTags),this.atNextDocument=!1);const s=e.trim().split(/[ \t]+/),i=s.shift();switch(i){case"%TAG":{if(s.length!==2&&(t(0,"%TAG directive should contain exactly two parts"),s.length<2))return!1;const[r,o]=s;return this.tags[r]=o,!0}case"%YAML":{if(this.yaml.explicit=!0,s.length!==1)return t(0,"%YAML directive should contain exactly one part"),!1;const[r]=s;if(r==="1.1"||r==="1.2")return this.yaml.version=r,!0;{const o=/^\d+\.\d+$/.test(r);return t(6,`Unsupported YAML version ${r}`,o),!1}}default:return t(0,`Unknown directive ${i}`,!0),!1}}tagName(e,t){if(e==="!")return"!";if(e[0]!=="!")return t(`Not a valid tag: ${e}`),null;if(e[1]==="<"){const o=e.slice(2,-1);return o==="!"||o==="!!"?(t(`Verbatim tags aren't resolved, so ${e} is invalid.`),null):(e[e.length-1]!==">"&&t("Verbatim tags must end with a >"),o)}const[,s,i]=e.match(/^(.*!)([^!]*)$/s);i||t(`The ${e} tag has no suffix`);const r=this.tags[s];if(r)try{return r+decodeURIComponent(i)}catch(o){return t(String(o)),null}return s==="!"?e:(t(`Could not resolve tag: ${e}`),null)}tagString(e){for(const[t,s]of Object.entries(this.tags))if(e.startsWith(s))return t+Ys(e.substring(s.length));return e[0]==="!"?e:`!<${e}>`}toString(e){const t=this.yaml.explicit?[`%YAML ${this.yaml.version||"1.2"}`]:[],s=Object.entries(this.tags);let i;if(e&&s.length>0&&C(e.contents)){const r={};fe(e.contents,(o,a)=>{C(a)&&a.tag&&(r[a.tag]=!0)}),i=Object.keys(r)}else i=[];for(const[r,o]of s)r==="!!"&&o==="tag:yaml.org,2002:"||(!e||i.some(a=>a.startsWith(o)))&&t.push(`%TAG ${r} ${o}`);return t.join(`
|
|
2
|
+
`)}}_.defaultYaml={explicit:!1,version:"1.2"};_.defaultTags={"!!":"tag:yaml.org,2002:"};function as(n){if(/[\x00-\x19\s,[\]{}]/.test(n)){const t=`Anchor must not contain whitespace or control characters: ${JSON.stringify(n)}`;throw new Error(t)}return!0}function ls(n){const e=new Set;return fe(n,{Value(t,s){s.anchor&&e.add(s.anchor)}}),e}function cs(n,e){for(let t=1;;++t){const s=`${n}${t}`;if(!e.has(s))return s}}function Qs(n,e){const t=[],s=new Map;let i=null;return{onAnchor:r=>{t.push(r),i??(i=ls(n));const o=cs(e,i);return i.add(o),o},setAnchors:()=>{for(const r of t){const o=s.get(r);if(typeof o=="object"&&o.anchor&&(O(o.node)||A(o.node)))o.node.anchor=o.anchor;else{const a=new Error("Failed to resolve repeated object (this should not happen)");throw a.source=r,a}}},sourceObjects:s}}function ne(n,e,t,s){if(s&&typeof s=="object")if(Array.isArray(s))for(let i=0,r=s.length;i<r;++i){const o=s[i],a=ne(n,s,String(i),o);a===void 0?delete s[i]:a!==o&&(s[i]=a)}else if(s instanceof Map)for(const i of Array.from(s.keys())){const r=s.get(i),o=ne(n,s,i,r);o===void 0?s.delete(i):o!==r&&s.set(i,o)}else if(s instanceof Set)for(const i of Array.from(s)){const r=ne(n,s,i,i);r===void 0?s.delete(i):r!==i&&(s.delete(i),s.add(r))}else for(const[i,r]of Object.entries(s)){const o=ne(n,s,i,r);o===void 0?delete s[i]:o!==r&&(s[i]=o)}return n.call(e,t,s)}function x(n,e,t){if(Array.isArray(n))return n.map((s,i)=>x(s,String(i),t));if(n&&typeof n.toJSON=="function"){if(!t||!os(n))return n.toJSON(e,t);const s={aliasCount:0,count:1,res:void 0};t.anchors.set(n,s),t.onCreate=r=>{s.res=r,delete t.onCreate};const i=n.toJSON(e,t);return t.onCreate&&t.onCreate(i),i}return typeof n=="bigint"&&!t?.keep?Number(n):n}class It{constructor(e){Object.defineProperty(this,j,{value:e})}clone(){const e=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return this.range&&(e.range=this.range.slice()),e}toJS(e,{mapAsMap:t,maxAliasCount:s,onAnchor:i,reviver:r}={}){if(!qe(e))throw new TypeError("A document argument is required");const o={anchors:new Map,doc:e,keep:!0,mapAsMap:t===!0,mapKeyWarned:!1,maxAliasCount:typeof s=="number"?s:100},a=x(this,"",o);if(typeof i=="function")for(const{count:l,res:c}of o.anchors.values())i(c,l);return typeof r=="function"?ne(r,{"":a},"",a):a}}class Nt extends It{constructor(e){super(vt),this.source=e,Object.defineProperty(this,"tag",{set(){throw new Error("Alias nodes cannot have tags")}})}resolve(e,t){let s;t?.aliasResolveCache?s=t.aliasResolveCache:(s=[],fe(e,{Node:(r,o)=>{(Q(o)||os(o))&&s.push(o)}}),t&&(t.aliasResolveCache=s));let i;for(const r of s){if(r===this)break;r.anchor===this.source&&(i=r)}return i}toJSON(e,t){if(!t)return{source:this.source};const{anchors:s,doc:i,maxAliasCount:r}=t,o=this.resolve(i,t);if(!o){const l=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new ReferenceError(l)}let a=s.get(o);if(a||(x(o,null,t),a=s.get(o)),a?.res===void 0){const l="This should not happen: Alias anchor was not resolved?";throw new ReferenceError(l)}if(r>=0&&(a.count+=1,a.aliasCount===0&&(a.aliasCount=Pe(i,o,s)),a.count*a.aliasCount>r)){const l="Excessive alias count indicates a resource exhaustion attack";throw new ReferenceError(l)}return a.res}toString(e,t,s){const i=`*${this.source}`;if(e){if(as(this.source),e.options.verifyAliasOrder&&!e.anchors.has(this.source)){const r=`Unresolved alias (the anchor must be set before the alias): ${this.source}`;throw new Error(r)}if(e.implicitKey)return`${i} `}return i}}function Pe(n,e,t){if(Q(e)){const s=e.resolve(n),i=t&&s&&t.get(s);return i?i.count*i.aliasCount:0}else if(A(e)){let s=0;for(const i of e.items){const r=Pe(n,i,t);r>s&&(s=r)}return s}else if(T(e)){const s=Pe(n,e.key,t),i=Pe(n,e.value,t);return Math.max(s,i)}return 1}const fs=n=>!n||typeof n!="function"&&typeof n!="object";class I extends It{constructor(e){super(D),this.value=e}toJSON(e,t){return t?.keep?this.value:x(this.value,e,t)}toString(){return String(this.value)}}I.BLOCK_FOLDED="BLOCK_FOLDED";I.BLOCK_LITERAL="BLOCK_LITERAL";I.PLAIN="PLAIN";I.QUOTE_DOUBLE="QUOTE_DOUBLE";I.QUOTE_SINGLE="QUOTE_SINGLE";const Xs="tag:yaml.org,2002:";function Zs(n,e,t){if(e){const s=t.filter(r=>r.tag===e),i=s.find(r=>!r.format)??s[0];if(!i)throw new Error(`Tag ${e} not found`);return i}return t.find(s=>s.identify?.(n)&&!s.format)}function ke(n,e,t){if(qe(n)&&(n=n.contents),C(n))return n;if(T(n)){const u=t.schema[W].createNode?.(t.schema,null,t);return u.items.push(n),u}(n instanceof String||n instanceof Number||n instanceof Boolean||typeof BigInt<"u"&&n instanceof BigInt)&&(n=n.valueOf());const{aliasDuplicateObjects:s,onAnchor:i,onTagObj:r,schema:o,sourceObjects:a}=t;let l;if(s&&n&&typeof n=="object"){if(l=a.get(n),l)return l.anchor??(l.anchor=i(n)),new Nt(l.anchor);l={anchor:null,node:null},a.set(n,l)}e?.startsWith("!!")&&(e=Xs+e.slice(2));let c=Zs(n,e,o.tags);if(!c){if(n&&typeof n.toJSON=="function"&&(n=n.toJSON()),!n||typeof n!="object"){const u=new I(n);return l&&(l.node=u),u}c=n instanceof Map?o[W]:Symbol.iterator in Object(n)?o[ce]:o[W]}r&&(r(c),delete t.onTagObj);const f=c?.createNode?c.createNode(t.schema,n,t):typeof c?.nodeClass?.from=="function"?c.nodeClass.from(t.schema,n,t):new I(n);return e?f.tag=e:c.default||(f.tag=c.tag),l&&(l.node=f),f}function Re(n,e,t){let s=t;for(let i=e.length-1;i>=0;--i){const r=e[i];if(typeof r=="number"&&Number.isInteger(r)&&r>=0){const o=[];o[r]=s,s=o}else s=new Map([[r,s]])}return ke(s,void 0,{aliasDuplicateObjects:!1,keepUndefined:!1,onAnchor:()=>{throw new Error("This should not happen, please report a bug.")},schema:n,sourceObjects:new Map})}const pe=n=>n==null||typeof n=="object"&&!!n[Symbol.iterator]().next().done;class us extends It{constructor(e,t){super(e),Object.defineProperty(this,"schema",{value:t,configurable:!0,enumerable:!1,writable:!0})}clone(e){const t=Object.create(Object.getPrototypeOf(this),Object.getOwnPropertyDescriptors(this));return e&&(t.schema=e),t.items=t.items.map(s=>C(s)||T(s)?s.clone(e):s),this.range&&(t.range=this.range.slice()),t}addIn(e,t){if(pe(e))this.add(t);else{const[s,...i]=e,r=this.get(s,!0);if(A(r))r.addIn(i,t);else if(r===void 0&&this.schema)this.set(s,Re(this.schema,i,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${i}`)}}deleteIn(e){const[t,...s]=e;if(s.length===0)return this.delete(t);const i=this.get(t,!0);if(A(i))return i.deleteIn(s);throw new Error(`Expected YAML collection at ${t}. Remaining path: ${s}`)}getIn(e,t){const[s,...i]=e,r=this.get(s,!0);return i.length===0?!t&&O(r)?r.value:r:A(r)?r.getIn(i,t):void 0}hasAllNullValues(e){return this.items.every(t=>{if(!T(t))return!1;const s=t.value;return s==null||e&&O(s)&&s.value==null&&!s.commentBefore&&!s.comment&&!s.tag})}hasIn(e){const[t,...s]=e;if(s.length===0)return this.has(t);const i=this.get(t,!0);return A(i)?i.hasIn(s):!1}setIn(e,t){const[s,...i]=e;if(i.length===0)this.set(s,t);else{const r=this.get(s,!0);if(A(r))r.setIn(i,t);else if(r===void 0&&this.schema)this.set(s,Re(this.schema,i,t));else throw new Error(`Expected YAML collection at ${s}. Remaining path: ${i}`)}}}const en=n=>n.replace(/^(?!$)(?: $)?/gm,"#");function U(n,e){return/^\n+$/.test(n)?n.substring(1):e?n.replace(/^(?! *$)/gm,e):n}const G=(n,e,t)=>n.endsWith(`
|
|
3
|
+
`)?U(t,e):t.includes(`
|
|
4
|
+
`)?`
|
|
5
|
+
`+U(t,e):(n.endsWith(" ")?"":" ")+t,hs="flow",gt="block",xe="quoted";function Ve(n,e,t="flow",{indentAtStart:s,lineWidth:i=80,minContentWidth:r=20,onFold:o,onOverflow:a}={}){if(!i||i<0)return n;i<r&&(r=0);const l=Math.max(1+r,1+i-e.length);if(n.length<=l)return n;const c=[],f={};let u=i-e.length;typeof s=="number"&&(s>i-Math.max(2,r)?c.push(0):u=i-s);let h,p,m=!1,d=-1,g=-1,b=-1;t===gt&&(d=Dt(n,d,e.length),d!==-1&&(u=d+l));for(let k;k=n[d+=1];){if(t===xe&&k==="\\"){switch(g=d,n[d+1]){case"x":d+=3;break;case"u":d+=5;break;case"U":d+=9;break;default:d+=1}b=d}if(k===`
|
|
6
|
+
`)t===gt&&(d=Dt(n,d,e.length)),u=d+e.length+l,h=void 0;else{if(k===" "&&p&&p!==" "&&p!==`
|
|
7
|
+
`&&p!==" "){const S=n[d+1];S&&S!==" "&&S!==`
|
|
8
|
+
`&&S!==" "&&(h=d)}if(d>=u)if(h)c.push(h),u=h+l,h=void 0;else if(t===xe){for(;p===" "||p===" ";)p=k,k=n[d+=1],m=!0;const S=d>b+1?d-2:g-1;if(f[S])return n;c.push(S),f[S]=!0,u=S+l,h=void 0}else m=!0}p=k}if(m&&a&&a(),c.length===0)return n;o&&o();let y=n.slice(0,c[0]);for(let k=0;k<c.length;++k){const S=c[k],v=c[k+1]||n.length;S===0?y=`
|
|
9
|
+
${e}${n.slice(0,v)}`:(t===xe&&f[S]&&(y+=`${n[S]}\\`),y+=`
|
|
10
|
+
${e}${n.slice(S+1,v)}`)}return y}function Dt(n,e,t){let s=e,i=e+1,r=n[i];for(;r===" "||r===" ";)if(e<i+t)r=n[++e];else{do r=n[++e];while(r&&r!==`
|
|
11
|
+
`);s=e,i=e+1,r=n[i]}return s}const He=(n,e)=>({indentAtStart:e?n.indent.length:n.indentAtStart,lineWidth:n.options.lineWidth,minContentWidth:n.options.minContentWidth}),We=n=>/^(%|---|\.\.\.)/m.test(n);function tn(n,e,t){if(!e||e<0)return!1;const s=e-t,i=n.length;if(i<=s)return!1;for(let r=0,o=0;r<i;++r)if(n[r]===`
|
|
12
|
+
`){if(r-o>s)return!0;if(o=r+1,i-o<=s)return!1}return!0}function be(n,e){const t=JSON.stringify(n);if(e.options.doubleQuotedAsJSON)return t;const{implicitKey:s}=e,i=e.options.doubleQuotedMinMultiLineLength,r=e.indent||(We(n)?" ":"");let o="",a=0;for(let l=0,c=t[l];c;c=t[++l])if(c===" "&&t[l+1]==="\\"&&t[l+2]==="n"&&(o+=t.slice(a,l)+"\\ ",l+=1,a=l,c="\\"),c==="\\")switch(t[l+1]){case"u":{o+=t.slice(a,l);const f=t.substr(l+2,4);switch(f){case"0000":o+="\\0";break;case"0007":o+="\\a";break;case"000b":o+="\\v";break;case"001b":o+="\\e";break;case"0085":o+="\\N";break;case"00a0":o+="\\_";break;case"2028":o+="\\L";break;case"2029":o+="\\P";break;default:f.substr(0,2)==="00"?o+="\\x"+f.substr(2):o+=t.substr(l,6)}l+=5,a=l+1}break;case"n":if(s||t[l+2]==='"'||t.length<i)l+=1;else{for(o+=t.slice(a,l)+`
|
|
13
|
+
|
|
14
|
+
`;t[l+2]==="\\"&&t[l+3]==="n"&&t[l+4]!=='"';)o+=`
|
|
15
|
+
`,l+=2;o+=r,t[l+2]===" "&&(o+="\\"),l+=1,a=l+1}break;default:l+=1}return o=a?o+t.slice(a):t,s?o:Ve(o,r,xe,He(e,!1))}function mt(n,e){if(e.options.singleQuote===!1||e.implicitKey&&n.includes(`
|
|
16
|
+
`)||/[ \t]\n|\n[ \t]/.test(n))return be(n,e);const t=e.indent||(We(n)?" ":""),s="'"+n.replace(/'/g,"''").replace(/\n+/g,`$&
|
|
17
|
+
${t}`)+"'";return e.implicitKey?s:Ve(s,t,hs,He(e,!1))}function ie(n,e){const{singleQuote:t}=e.options;let s;if(t===!1)s=be;else{const i=n.includes('"'),r=n.includes("'");i&&!r?s=mt:r&&!i?s=be:s=t?mt:be}return s(n,e)}let yt;try{yt=new RegExp(`(^|(?<!
|
|
18
|
+
))
|
|
19
|
+
+(?!
|
|
20
|
+
|$)`,"g")}catch{yt=/\n+(?!\n|$)/g}function je({comment:n,type:e,value:t},s,i,r){const{blockQuote:o,commentString:a,lineWidth:l}=s.options;if(!o||/\n[\t ]+$/.test(t))return ie(t,s);const c=s.indent||(s.forceBlockIndent||We(t)?" ":""),f=o==="literal"?!0:o==="folded"||e===I.BLOCK_FOLDED?!1:e===I.BLOCK_LITERAL?!0:!tn(t,l,c.length);if(!t)return f?`|
|
|
21
|
+
`:`>
|
|
22
|
+
`;let u,h;for(h=t.length;h>0;--h){const v=t[h-1];if(v!==`
|
|
23
|
+
`&&v!==" "&&v!==" ")break}let p=t.substring(h);const m=p.indexOf(`
|
|
24
|
+
`);m===-1?u="-":t===p||m!==p.length-1?(u="+",r&&r()):u="",p&&(t=t.slice(0,-p.length),p[p.length-1]===`
|
|
25
|
+
`&&(p=p.slice(0,-1)),p=p.replace(yt,`$&${c}`));let d=!1,g,b=-1;for(g=0;g<t.length;++g){const v=t[g];if(v===" ")d=!0;else if(v===`
|
|
26
|
+
`)b=g;else break}let y=t.substring(0,b<g?b+1:g);y&&(t=t.substring(y.length),y=y.replace(/\n+/g,`$&${c}`));let S=(d?c?"2":"1":"")+u;if(n&&(S+=" "+a(n.replace(/ ?[\r\n]+/g," ")),i&&i()),!f){const v=t.replace(/\n+/g,`
|
|
27
|
+
$&`).replace(/(?:^|\n)([\t ].*)(?:([\n\t ]*)\n(?![\n\t ]))?/g,"$1$2").replace(/\n+/g,`$&${c}`);let N=!1;const L=He(s,!0);o!=="folded"&&e!==I.BLOCK_FOLDED&&(L.onOverflow=()=>{N=!0});const w=Ve(`${y}${v}${p}`,c,gt,L);if(!N)return`>${S}
|
|
28
|
+
${c}${w}`}return t=t.replace(/\n+/g,`$&${c}`),`|${S}
|
|
29
|
+
${c}${y}${t}${p}`}function sn(n,e,t,s){const{type:i,value:r}=n,{actualString:o,implicitKey:a,indent:l,indentStep:c,inFlow:f}=e;if(a&&r.includes(`
|
|
30
|
+
`)||f&&/[[\]{},]/.test(r))return ie(r,e);if(/^[\n\t ,[\]{}#&*!|>'"%@`]|^[?-]$|^[?-][ \t]|[\n:][ \t]|[ \t]\n|[\n\t ]#|[\n\t :]$/.test(r))return a||f||!r.includes(`
|
|
31
|
+
`)?ie(r,e):je(n,e,t,s);if(!a&&!f&&i!==I.PLAIN&&r.includes(`
|
|
32
|
+
`))return je(n,e,t,s);if(We(r)){if(l==="")return e.forceBlockIndent=!0,je(n,e,t,s);if(a&&l===c)return ie(r,e)}const u=r.replace(/\n+/g,`$&
|
|
33
|
+
${l}`);if(o){const h=d=>d.default&&d.tag!=="tag:yaml.org,2002:str"&&d.test?.test(u),{compat:p,tags:m}=e.doc.schema;if(m.some(h)||p?.some(h))return ie(r,e)}return a?u:Ve(u,l,hs,He(e,!1))}function Lt(n,e,t,s){const{implicitKey:i,inFlow:r}=e,o=typeof n.value=="string"?n:Object.assign({},n,{value:String(n.value)});let{type:a}=n;a!==I.QUOTE_DOUBLE&&/[\x00-\x08\x0b-\x1f\x7f-\x9f\u{D800}-\u{DFFF}]/u.test(o.value)&&(a=I.QUOTE_DOUBLE);const l=f=>{switch(f){case I.BLOCK_FOLDED:case I.BLOCK_LITERAL:return i||r?ie(o.value,e):je(o,e,t,s);case I.QUOTE_DOUBLE:return be(o.value,e);case I.QUOTE_SINGLE:return mt(o.value,e);case I.PLAIN:return sn(o,e,t,s);default:return null}};let c=l(a);if(c===null){const{defaultKeyType:f,defaultStringType:u}=e.options,h=i&&f||u;if(c=l(h),c===null)throw new Error(`Unsupported default string type ${h}`)}return c}function ds(n,e){const t=Object.assign({blockQuote:!0,commentString:en,defaultKeyType:null,defaultStringType:"PLAIN",directives:null,doubleQuotedAsJSON:!1,doubleQuotedMinMultiLineLength:40,falseStr:"false",flowCollectionPadding:!0,indentSeq:!0,lineWidth:80,minContentWidth:20,nullStr:"null",simpleKeys:!1,singleQuote:null,trueStr:"true",verifyAliasOrder:!0},n.schema.toStringOptions,e);let s;switch(t.collectionStyle){case"block":s=!1;break;case"flow":s=!0;break;default:s=null}return{anchors:new Set,doc:n,flowCollectionPadding:t.flowCollectionPadding?" ":"",indent:"",indentStep:typeof t.indent=="number"?" ".repeat(t.indent):" ",inFlow:s,options:t}}function nn(n,e){if(e.tag){const i=n.filter(r=>r.tag===e.tag);if(i.length>0)return i.find(r=>r.format===e.format)??i[0]}let t,s;if(O(e)){s=e.value;let i=n.filter(r=>r.identify?.(s));if(i.length>1){const r=i.filter(o=>o.test);r.length>0&&(i=r)}t=i.find(r=>r.format===e.format)??i.find(r=>!r.format)}else s=e,t=n.find(i=>i.nodeClass&&s instanceof i.nodeClass);if(!t){const i=s?.constructor?.name??(s===null?"null":typeof s);throw new Error(`Tag not resolved for ${i} value`)}return t}function rn(n,e,{anchors:t,doc:s}){if(!s.directives)return"";const i=[],r=(O(n)||A(n))&&n.anchor;r&&as(r)&&(t.add(r),i.push(`&${r}`));const o=n.tag??(e.default?null:e.tag);return o&&i.push(s.directives.tagString(o)),i.join(" ")}function ae(n,e,t,s){if(T(n))return n.toString(e,t,s);if(Q(n)){if(e.doc.directives)return n.toString(e);if(e.resolvedAliases?.has(n))throw new TypeError("Cannot stringify circular structure without alias nodes");e.resolvedAliases?e.resolvedAliases.add(n):e.resolvedAliases=new Set([n]),n=n.resolve(e.doc)}let i;const r=C(n)?n:e.doc.createNode(n,{onTagObj:l=>i=l});i??(i=nn(e.doc.schema.tags,r));const o=rn(r,i,e);o.length>0&&(e.indentAtStart=(e.indentAtStart??0)+o.length+1);const a=typeof i.stringify=="function"?i.stringify(r,e,t,s):O(r)?Lt(r,e,t,s):r.toString(e,t,s);return o?O(r)||a[0]==="{"||a[0]==="["?`${o} ${a}`:`${o}
|
|
34
|
+
${e.indent}${a}`:a}function on({key:n,value:e},t,s,i){const{allNullValues:r,doc:o,indent:a,indentStep:l,options:{commentString:c,indentSeq:f,simpleKeys:u}}=t;let h=C(n)&&n.comment||null;if(u){if(h)throw new Error("With simple keys, key nodes cannot have comments");if(A(n)||!C(n)&&typeof n=="object"){const L="With simple keys, collection cannot be used as a key value";throw new Error(L)}}let p=!u&&(!n||h&&e==null&&!t.inFlow||A(n)||(O(n)?n.type===I.BLOCK_FOLDED||n.type===I.BLOCK_LITERAL:typeof n=="object"));t=Object.assign({},t,{allNullValues:!1,implicitKey:!p&&(u||!r),indent:a+l});let m=!1,d=!1,g=ae(n,t,()=>m=!0,()=>d=!0);if(!p&&!t.inFlow&&g.length>1024){if(u)throw new Error("With simple keys, single line scalar must not span more than 1024 characters");p=!0}if(t.inFlow){if(r||e==null)return m&&s&&s(),g===""?"?":p?`? ${g}`:g}else if(r&&!u||e==null&&p)return g=`? ${g}`,h&&!m?g+=G(g,t.indent,c(h)):d&&i&&i(),g;m&&(h=null),p?(h&&(g+=G(g,t.indent,c(h))),g=`? ${g}
|
|
35
|
+
${a}:`):(g=`${g}:`,h&&(g+=G(g,t.indent,c(h))));let b,y,k;C(e)?(b=!!e.spaceBefore,y=e.commentBefore,k=e.comment):(b=!1,y=null,k=null,e&&typeof e=="object"&&(e=o.createNode(e))),t.implicitKey=!1,!p&&!h&&O(e)&&(t.indentAtStart=g.length+1),d=!1,!f&&l.length>=2&&!t.inFlow&&!p&&Le(e)&&!e.flow&&!e.tag&&!e.anchor&&(t.indent=t.indent.substring(2));let S=!1;const v=ae(e,t,()=>S=!0,()=>d=!0);let N=" ";if(h||b||y){if(N=b?`
|
|
36
|
+
`:"",y){const L=c(y);N+=`
|
|
37
|
+
${U(L,t.indent)}`}v===""&&!t.inFlow?N===`
|
|
38
|
+
`&&k&&(N=`
|
|
39
|
+
|
|
40
|
+
`):N+=`
|
|
41
|
+
${t.indent}`}else if(!p&&A(e)){const L=v[0],w=v.indexOf(`
|
|
42
|
+
`),$=w!==-1,V=t.inFlow??e.flow??e.items.length===0;if($||!V){let X=!1;if($&&(L==="&"||L==="!")){let E=v.indexOf(" ");L==="&"&&E!==-1&&E<w&&v[E+1]==="!"&&(E=v.indexOf(" ",E+1)),(E===-1||w<E)&&(X=!0)}X||(N=`
|
|
43
|
+
${t.indent}`)}}else(v===""||v[0]===`
|
|
44
|
+
`)&&(N="");return g+=N+v,t.inFlow?S&&s&&s():k&&!S?g+=G(g,t.indent,c(k)):d&&i&&i(),g}function ps(n,e){(n==="debug"||n==="warn")&&console.warn(e)}const Ce="<<",q={identify:n=>n===Ce||typeof n=="symbol"&&n.description===Ce,default:"key",tag:"tag:yaml.org,2002:merge",test:/^<<$/,resolve:()=>Object.assign(new I(Symbol(Ce)),{addToJSMap:gs}),stringify:()=>Ce},an=(n,e)=>(q.identify(e)||O(e)&&(!e.type||e.type===I.PLAIN)&&q.identify(e.value))&&n?.doc.schema.tags.some(t=>t.tag===q.tag&&t.default);function gs(n,e,t){if(t=n&&Q(t)?t.resolve(n.doc):t,Le(t))for(const s of t.items)tt(n,e,s);else if(Array.isArray(t))for(const s of t)tt(n,e,s);else tt(n,e,t)}function tt(n,e,t){const s=n&&Q(t)?t.resolve(n.doc):t;if(!Ne(s))throw new Error("Merge sources must be maps or map aliases");const i=s.toJSON(null,n,Map);for(const[r,o]of i)e instanceof Map?e.has(r)||e.set(r,o):e instanceof Set?e.add(r):Object.prototype.hasOwnProperty.call(e,r)||Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0});return e}function ms(n,e,{key:t,value:s}){if(C(t)&&t.addToJSMap)t.addToJSMap(n,e,s);else if(an(n,t))gs(n,e,s);else{const i=x(t,"",n);if(e instanceof Map)e.set(i,x(s,i,n));else if(e instanceof Set)e.add(i);else{const r=ln(t,i,n),o=x(s,r,n);r in e?Object.defineProperty(e,r,{value:o,writable:!0,enumerable:!0,configurable:!0}):e[r]=o}}return e}function ln(n,e,t){if(e===null)return"";if(typeof e!="object")return String(e);if(C(n)&&t?.doc){const s=ds(t.doc,{});s.anchors=new Set;for(const r of t.anchors.keys())s.anchors.add(r.anchor);s.inFlow=!0,s.inStringifyKey=!0;const i=n.toString(s);if(!t.mapKeyWarned){let r=JSON.stringify(i);r.length>40&&(r=r.substring(0,36)+'..."'),ps(t.doc.options.logLevel,`Keys with collection values will be stringified due to JS Object restrictions: ${r}. Set mapAsMap: true to use object keys.`),t.mapKeyWarned=!0}return i}return JSON.stringify(e)}function Ot(n,e,t){const s=ke(n,void 0,t),i=ke(e,void 0,t);return new B(s,i)}class B{constructor(e,t=null){Object.defineProperty(this,j,{value:rs}),this.key=e,this.value=t}clone(e){let{key:t,value:s}=this;return C(t)&&(t=t.clone(e)),C(s)&&(s=s.clone(e)),new B(t,s)}toJSON(e,t){const s=t?.mapAsMap?new Map:{};return ms(t,s,this)}toString(e,t,s){return e?.doc?on(this,e,t,s):JSON.stringify(this)}}function ys(n,e,t){return(e.inFlow??n.flow?fn:cn)(n,e,t)}function cn({comment:n,items:e},t,{blockItemPrefix:s,flowChars:i,itemIndent:r,onChompKeep:o,onComment:a}){const{indent:l,options:{commentString:c}}=t,f=Object.assign({},t,{indent:r,type:null});let u=!1;const h=[];for(let m=0;m<e.length;++m){const d=e[m];let g=null;if(C(d))!u&&d.spaceBefore&&h.push(""),Fe(t,h,d.commentBefore,u),d.comment&&(g=d.comment);else if(T(d)){const y=C(d.key)?d.key:null;y&&(!u&&y.spaceBefore&&h.push(""),Fe(t,h,y.commentBefore,u))}u=!1;let b=ae(d,f,()=>g=null,()=>u=!0);g&&(b+=G(b,r,c(g))),u&&g&&(u=!1),h.push(s+b)}let p;if(h.length===0)p=i.start+i.end;else{p=h[0];for(let m=1;m<h.length;++m){const d=h[m];p+=d?`
|
|
45
|
+
${l}${d}`:`
|
|
46
|
+
`}}return n?(p+=`
|
|
47
|
+
`+U(c(n),l),a&&a()):u&&o&&o(),p}function fn({items:n},e,{flowChars:t,itemIndent:s}){const{indent:i,indentStep:r,flowCollectionPadding:o,options:{commentString:a}}=e;s+=r;const l=Object.assign({},e,{indent:s,inFlow:!0,type:null});let c=!1,f=0;const u=[];for(let m=0;m<n.length;++m){const d=n[m];let g=null;if(C(d))d.spaceBefore&&u.push(""),Fe(e,u,d.commentBefore,!1),d.comment&&(g=d.comment);else if(T(d)){const y=C(d.key)?d.key:null;y&&(y.spaceBefore&&u.push(""),Fe(e,u,y.commentBefore,!1),y.comment&&(c=!0));const k=C(d.value)?d.value:null;k?(k.comment&&(g=k.comment),k.commentBefore&&(c=!0)):d.value==null&&y?.comment&&(g=y.comment)}g&&(c=!0);let b=ae(d,l,()=>g=null);m<n.length-1&&(b+=","),g&&(b+=G(b,s,a(g))),!c&&(u.length>f||b.includes(`
|
|
48
|
+
`))&&(c=!0),u.push(b),f=u.length}const{start:h,end:p}=t;if(u.length===0)return h+p;if(!c){const m=u.reduce((d,g)=>d+g.length+2,2);c=e.options.lineWidth>0&&m>e.options.lineWidth}if(c){let m=h;for(const d of u)m+=d?`
|
|
49
|
+
${r}${i}${d}`:`
|
|
50
|
+
`;return`${m}
|
|
51
|
+
${i}${p}`}else return`${h}${o}${u.join(" ")}${o}${p}`}function Fe({indent:n,options:{commentString:e}},t,s,i){if(s&&i&&(s=s.replace(/^\n+/,"")),s){const r=U(e(s),n);t.push(r.trimStart())}}function z(n,e){const t=O(e)?e.value:e;for(const s of n)if(T(s)&&(s.key===e||s.key===t||O(s.key)&&s.key.value===t))return s}class P extends us{static get tagName(){return"tag:yaml.org,2002:map"}constructor(e){super(W,e),this.items=[]}static from(e,t,s){const{keepUndefined:i,replacer:r}=s,o=new this(e),a=(l,c)=>{if(typeof r=="function")c=r.call(t,l,c);else if(Array.isArray(r)&&!r.includes(l))return;(c!==void 0||i)&&o.items.push(Ot(l,c,s))};if(t instanceof Map)for(const[l,c]of t)a(l,c);else if(t&&typeof t=="object")for(const l of Object.keys(t))a(l,t[l]);return typeof e.sortMapEntries=="function"&&o.items.sort(e.sortMapEntries),o}add(e,t){let s;T(e)?s=e:!e||typeof e!="object"||!("key"in e)?s=new B(e,e?.value):s=new B(e.key,e.value);const i=z(this.items,s.key),r=this.schema?.sortMapEntries;if(i){if(!t)throw new Error(`Key ${s.key} already set`);O(i.value)&&fs(s.value)?i.value.value=s.value:i.value=s.value}else if(r){const o=this.items.findIndex(a=>r(s,a)<0);o===-1?this.items.push(s):this.items.splice(o,0,s)}else this.items.push(s)}delete(e){const t=z(this.items,e);return t?this.items.splice(this.items.indexOf(t),1).length>0:!1}get(e,t){const i=z(this.items,e)?.value;return(!t&&O(i)?i.value:i)??void 0}has(e){return!!z(this.items,e)}set(e,t){this.add(new B(e,t),!0)}toJSON(e,t,s){const i=s?new s:t?.mapAsMap?new Map:{};t?.onCreate&&t.onCreate(i);for(const r of this.items)ms(t,i,r);return i}toString(e,t,s){if(!e)return JSON.stringify(this);for(const i of this.items)if(!T(i))throw new Error(`Map items must all be pairs; found ${JSON.stringify(i)} instead`);return!e.allNullValues&&this.hasAllNullValues(!1)&&(e=Object.assign({},e,{allNullValues:!0})),ys(this,e,{blockItemPrefix:"",flowChars:{start:"{",end:"}"},itemIndent:e.indent||"",onChompKeep:s,onComment:t})}}const ue={collection:"map",default:!0,nodeClass:P,tag:"tag:yaml.org,2002:map",resolve(n,e){return Ne(n)||e("Expected a mapping for this tag"),n},createNode:(n,e,t)=>P.from(n,e,t)};class Y extends us{static get tagName(){return"tag:yaml.org,2002:seq"}constructor(e){super(ce,e),this.items=[]}add(e){this.items.push(e)}delete(e){const t=Te(e);return typeof t!="number"?!1:this.items.splice(t,1).length>0}get(e,t){const s=Te(e);if(typeof s!="number")return;const i=this.items[s];return!t&&O(i)?i.value:i}has(e){const t=Te(e);return typeof t=="number"&&t<this.items.length}set(e,t){const s=Te(e);if(typeof s!="number")throw new Error(`Expected a valid index, not ${e}.`);const i=this.items[s];O(i)&&fs(t)?i.value=t:this.items[s]=t}toJSON(e,t){const s=[];t?.onCreate&&t.onCreate(s);let i=0;for(const r of this.items)s.push(x(r,String(i++),t));return s}toString(e,t,s){return e?ys(this,e,{blockItemPrefix:"- ",flowChars:{start:"[",end:"]"},itemIndent:(e.indent||"")+" ",onChompKeep:s,onComment:t}):JSON.stringify(this)}static from(e,t,s){const{replacer:i}=s,r=new this(e);if(t&&Symbol.iterator in Object(t)){let o=0;for(let a of t){if(typeof i=="function"){const l=t instanceof Set?a:String(o++);a=i.call(t,l,a)}r.items.push(ke(a,void 0,s))}}return r}}function Te(n){let e=O(n)?n.value:n;return e&&typeof e=="string"&&(e=Number(e)),typeof e=="number"&&Number.isInteger(e)&&e>=0?e:null}const he={collection:"seq",default:!0,nodeClass:Y,tag:"tag:yaml.org,2002:seq",resolve(n,e){return Le(n)||e("Expected a sequence for this tag"),n},createNode:(n,e,t)=>Y.from(n,e,t)},Je={identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify(n,e,t,s){return e=Object.assign({actualString:!0},e),Lt(n,e,t,s)}},Ge={identify:n=>n==null,createNode:()=>new I(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^(?:~|[Nn]ull|NULL)?$/,resolve:()=>new I(null),stringify:({source:n},e)=>typeof n=="string"&&Ge.test.test(n)?n:e.options.nullStr},At={identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:[Tt]rue|TRUE|[Ff]alse|FALSE)$/,resolve:n=>new I(n[0]==="t"||n[0]==="T"),stringify({source:n,value:e},t){if(n&&At.test.test(n)){const s=n[0]==="t"||n[0]==="T";if(e===s)return n}return e?t.options.trueStr:t.options.falseStr}};function F({format:n,minFractionDigits:e,tag:t,value:s}){if(typeof s=="bigint")return String(s);const i=typeof s=="number"?s:Number(s);if(!isFinite(i))return isNaN(i)?".nan":i<0?"-.inf":".inf";let r=Object.is(s,-0)?"-0":JSON.stringify(s);if(!n&&e&&(!t||t==="tag:yaml.org,2002:float")&&/^\d/.test(r)){let o=r.indexOf(".");o<0&&(o=r.length,r+=".");let a=e-(r.length-o-1);for(;a-- >0;)r+="0"}return r}const bs={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:F},ws={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:\.[0-9]+|[0-9]+(?:\.[0-9]*)?)[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n),stringify(n){const e=Number(n.value);return isFinite(e)?e.toExponential():F(n)}},ks={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:\.[0-9]+|[0-9]+\.[0-9]*)$/,resolve(n){const e=new I(parseFloat(n)),t=n.indexOf(".");return t!==-1&&n[n.length-1]==="0"&&(e.minFractionDigits=n.length-t-1),e},stringify:F},ze=n=>typeof n=="bigint"||Number.isInteger(n),Ct=(n,e,t,{intAsBigInt:s})=>s?BigInt(n):parseInt(n.substring(e),t);function Ss(n,e,t){const{value:s}=n;return ze(s)&&s>=0?t+s.toString(e):F(n)}const vs={identify:n=>ze(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^0o[0-7]+$/,resolve:(n,e,t)=>Ct(n,2,8,t),stringify:n=>Ss(n,8,"0o")},Is={identify:ze,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9]+$/,resolve:(n,e,t)=>Ct(n,0,10,t),stringify:F},Ns={identify:n=>ze(n)&&n>=0,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^0x[0-9a-fA-F]+$/,resolve:(n,e,t)=>Ct(n,2,16,t),stringify:n=>Ss(n,16,"0x")},un=[ue,he,Je,Ge,At,vs,Is,Ns,bs,ws,ks];function Kt(n){return typeof n=="bigint"||Number.isInteger(n)}const $e=({value:n})=>JSON.stringify(n),hn=[{identify:n=>typeof n=="string",default:!0,tag:"tag:yaml.org,2002:str",resolve:n=>n,stringify:$e},{identify:n=>n==null,createNode:()=>new I(null),default:!0,tag:"tag:yaml.org,2002:null",test:/^null$/,resolve:()=>null,stringify:$e},{identify:n=>typeof n=="boolean",default:!0,tag:"tag:yaml.org,2002:bool",test:/^true$|^false$/,resolve:n=>n==="true",stringify:$e},{identify:Kt,default:!0,tag:"tag:yaml.org,2002:int",test:/^-?(?:0|[1-9][0-9]*)$/,resolve:(n,e,{intAsBigInt:t})=>t?BigInt(n):parseInt(n,10),stringify:({value:n})=>Kt(n)?n.toString():JSON.stringify(n)},{identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^-?(?:0|[1-9][0-9]*)(?:\.[0-9]*)?(?:[eE][-+]?[0-9]+)?$/,resolve:n=>parseFloat(n),stringify:$e}],dn={default:!0,tag:"",test:/^/,resolve(n,e){return e(`Unresolved plain scalar ${JSON.stringify(n)}`),n}},pn=[ue,he].concat(hn,dn),Tt={identify:n=>n instanceof Uint8Array,default:!1,tag:"tag:yaml.org,2002:binary",resolve(n,e){if(typeof atob=="function"){const t=atob(n.replace(/[\n\r]/g,"")),s=new Uint8Array(t.length);for(let i=0;i<t.length;++i)s[i]=t.charCodeAt(i);return s}else return e("This environment does not support reading binary tags; either Buffer or atob is required"),n},stringify({comment:n,type:e,value:t},s,i,r){if(!t)return"";const o=t;let a;if(typeof btoa=="function"){let l="";for(let c=0;c<o.length;++c)l+=String.fromCharCode(o[c]);a=btoa(l)}else throw new Error("This environment does not support writing binary tags; either Buffer or btoa is required");if(e??(e=I.BLOCK_LITERAL),e!==I.QUOTE_DOUBLE){const l=Math.max(s.options.lineWidth-s.indent.length,s.options.minContentWidth),c=Math.ceil(a.length/l),f=new Array(c);for(let u=0,h=0;u<c;++u,h+=l)f[u]=a.substr(h,l);a=f.join(e===I.BLOCK_LITERAL?`
|
|
52
|
+
`:" ")}return Lt({comment:n,type:e,value:a},s,i,r)}};function Ls(n,e){if(Le(n))for(let t=0;t<n.items.length;++t){let s=n.items[t];if(!T(s)){if(Ne(s)){s.items.length>1&&e("Each pair must have its own sequence indicator");const i=s.items[0]||new B(new I(null));if(s.commentBefore&&(i.key.commentBefore=i.key.commentBefore?`${s.commentBefore}
|
|
53
|
+
${i.key.commentBefore}`:s.commentBefore),s.comment){const r=i.value??i.key;r.comment=r.comment?`${s.comment}
|
|
54
|
+
${r.comment}`:s.comment}s=i}n.items[t]=T(s)?s:new B(s)}}else e("Expected a sequence for this tag");return n}function Os(n,e,t){const{replacer:s}=t,i=new Y(n);i.tag="tag:yaml.org,2002:pairs";let r=0;if(e&&Symbol.iterator in Object(e))for(let o of e){typeof s=="function"&&(o=s.call(e,String(r++),o));let a,l;if(Array.isArray(o))if(o.length===2)a=o[0],l=o[1];else throw new TypeError(`Expected [key, value] tuple: ${o}`);else if(o&&o instanceof Object){const c=Object.keys(o);if(c.length===1)a=c[0],l=o[a];else throw new TypeError(`Expected tuple with one key, not ${c.length} keys`)}else a=o;i.items.push(Ot(a,l,t))}return i}const $t={collection:"seq",default:!1,tag:"tag:yaml.org,2002:pairs",resolve:Ls,createNode:Os};class re extends Y{constructor(){super(),this.add=P.prototype.add.bind(this),this.delete=P.prototype.delete.bind(this),this.get=P.prototype.get.bind(this),this.has=P.prototype.has.bind(this),this.set=P.prototype.set.bind(this),this.tag=re.tag}toJSON(e,t){if(!t)return super.toJSON(e);const s=new Map;t?.onCreate&&t.onCreate(s);for(const i of this.items){let r,o;if(T(i)?(r=x(i.key,"",t),o=x(i.value,r,t)):r=x(i,"",t),s.has(r))throw new Error("Ordered maps must not include duplicate keys");s.set(r,o)}return s}static from(e,t,s){const i=Os(e,t,s),r=new this;return r.items=i.items,r}}re.tag="tag:yaml.org,2002:omap";const Et={collection:"seq",identify:n=>n instanceof Map,nodeClass:re,default:!1,tag:"tag:yaml.org,2002:omap",resolve(n,e){const t=Ls(n,e),s=[];for(const{key:i}of t.items)O(i)&&(s.includes(i.value)?e(`Ordered maps must not include duplicate keys: ${i.value}`):s.push(i.value));return Object.assign(new re,t)},createNode:(n,e,t)=>re.from(n,e,t)};function As({value:n,source:e},t){return e&&(n?Cs:Ts).test.test(e)?e:n?t.options.trueStr:t.options.falseStr}const Cs={identify:n=>n===!0,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:Y|y|[Yy]es|YES|[Tt]rue|TRUE|[Oo]n|ON)$/,resolve:()=>new I(!0),stringify:As},Ts={identify:n=>n===!1,default:!0,tag:"tag:yaml.org,2002:bool",test:/^(?:N|n|[Nn]o|NO|[Ff]alse|FALSE|[Oo]ff|OFF)$/,resolve:()=>new I(!1),stringify:As},gn={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^(?:[-+]?\.(?:inf|Inf|INF)|\.nan|\.NaN|\.NAN)$/,resolve:n=>n.slice(-3).toLowerCase()==="nan"?NaN:n[0]==="-"?Number.NEGATIVE_INFINITY:Number.POSITIVE_INFINITY,stringify:F},mn={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"EXP",test:/^[-+]?(?:[0-9][0-9_]*)?(?:\.[0-9_]*)?[eE][-+]?[0-9]+$/,resolve:n=>parseFloat(n.replace(/_/g,"")),stringify(n){const e=Number(n.value);return isFinite(e)?e.toExponential():F(n)}},yn={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",test:/^[-+]?(?:[0-9][0-9_]*)?\.[0-9_]*$/,resolve(n){const e=new I(parseFloat(n.replace(/_/g,""))),t=n.indexOf(".");if(t!==-1){const s=n.substring(t+1).replace(/_/g,"");s[s.length-1]==="0"&&(e.minFractionDigits=s.length)}return e},stringify:F},Oe=n=>typeof n=="bigint"||Number.isInteger(n);function Ye(n,e,t,{intAsBigInt:s}){const i=n[0];if((i==="-"||i==="+")&&(e+=1),n=n.substring(e).replace(/_/g,""),s){switch(t){case 2:n=`0b${n}`;break;case 8:n=`0o${n}`;break;case 16:n=`0x${n}`;break}const o=BigInt(n);return i==="-"?BigInt(-1)*o:o}const r=parseInt(n,t);return i==="-"?-1*r:r}function _t(n,e,t){const{value:s}=n;if(Oe(s)){const i=s.toString(e);return s<0?"-"+t+i.substr(1):t+i}return F(n)}const bn={identify:Oe,default:!0,tag:"tag:yaml.org,2002:int",format:"BIN",test:/^[-+]?0b[0-1_]+$/,resolve:(n,e,t)=>Ye(n,2,2,t),stringify:n=>_t(n,2,"0b")},wn={identify:Oe,default:!0,tag:"tag:yaml.org,2002:int",format:"OCT",test:/^[-+]?0[0-7_]+$/,resolve:(n,e,t)=>Ye(n,1,8,t),stringify:n=>_t(n,8,"0")},kn={identify:Oe,default:!0,tag:"tag:yaml.org,2002:int",test:/^[-+]?[0-9][0-9_]*$/,resolve:(n,e,t)=>Ye(n,0,10,t),stringify:F},Sn={identify:Oe,default:!0,tag:"tag:yaml.org,2002:int",format:"HEX",test:/^[-+]?0x[0-9a-fA-F_]+$/,resolve:(n,e,t)=>Ye(n,2,16,t),stringify:n=>_t(n,16,"0x")};class oe extends P{constructor(e){super(e),this.tag=oe.tag}add(e){let t;T(e)?t=e:e&&typeof e=="object"&&"key"in e&&"value"in e&&e.value===null?t=new B(e.key,null):t=new B(e,null),z(this.items,t.key)||this.items.push(t)}get(e,t){const s=z(this.items,e);return!t&&T(s)?O(s.key)?s.key.value:s.key:s}set(e,t){if(typeof t!="boolean")throw new Error(`Expected boolean value for set(key, value) in a YAML set, not ${typeof t}`);const s=z(this.items,e);s&&!t?this.items.splice(this.items.indexOf(s),1):!s&&t&&this.items.push(new B(e))}toJSON(e,t){return super.toJSON(e,t,Set)}toString(e,t,s){if(!e)return JSON.stringify(this);if(this.hasAllNullValues(!0))return super.toString(Object.assign({},e,{allNullValues:!0}),t,s);throw new Error("Set items must all have null values")}static from(e,t,s){const{replacer:i}=s,r=new this(e);if(t&&Symbol.iterator in Object(t))for(let o of t)typeof i=="function"&&(o=i.call(t,o,o)),r.items.push(Ot(o,null,s));return r}}oe.tag="tag:yaml.org,2002:set";const Bt={collection:"map",identify:n=>n instanceof Set,nodeClass:oe,default:!1,tag:"tag:yaml.org,2002:set",createNode:(n,e,t)=>oe.from(n,e,t),resolve(n,e){if(Ne(n)){if(n.hasAllNullValues(!0))return Object.assign(new oe,n);e("Set items must all have null values")}else e("Expected a mapping for this tag");return n}};function Mt(n,e){const t=n[0],s=t==="-"||t==="+"?n.substring(1):n,i=o=>e?BigInt(o):Number(o),r=s.replace(/_/g,"").split(":").reduce((o,a)=>o*i(60)+i(a),i(0));return t==="-"?i(-1)*r:r}function $s(n){let{value:e}=n,t=o=>o;if(typeof e=="bigint")t=o=>BigInt(o);else if(isNaN(e)||!isFinite(e))return F(n);let s="";e<0&&(s="-",e*=t(-1));const i=t(60),r=[e%i];return e<60?r.unshift(0):(e=(e-r[0])/i,r.unshift(e%i),e>=60&&(e=(e-r[0])/i,r.unshift(e))),s+r.map(o=>String(o).padStart(2,"0")).join(":").replace(/000000\d*$/,"")}const Es={identify:n=>typeof n=="bigint"||Number.isInteger(n),default:!0,tag:"tag:yaml.org,2002:int",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+$/,resolve:(n,e,{intAsBigInt:t})=>Mt(n,t),stringify:$s},_s={identify:n=>typeof n=="number",default:!0,tag:"tag:yaml.org,2002:float",format:"TIME",test:/^[-+]?[0-9][0-9_]*(?::[0-5]?[0-9])+\.[0-9_]*$/,resolve:n=>Mt(n,!1),stringify:$s},Qe={identify:n=>n instanceof Date,default:!0,tag:"tag:yaml.org,2002:timestamp",test:RegExp("^([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})(?:(?:t|T|[ \\t]+)([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2}(\\.[0-9]+)?)(?:[ \\t]*(Z|[-+][012]?[0-9](?::[0-9]{2})?))?)?$"),resolve(n){const e=n.match(Qe.test);if(!e)throw new Error("!!timestamp expects a date, starting with yyyy-mm-dd");const[,t,s,i,r,o,a]=e.map(Number),l=e[7]?Number((e[7]+"00").substr(1,3)):0;let c=Date.UTC(t,s-1,i,r||0,o||0,a||0,l);const f=e[8];if(f&&f!=="Z"){let u=Mt(f,!1);Math.abs(u)<30&&(u*=60),c-=6e4*u}return new Date(c)},stringify:({value:n})=>n?.toISOString().replace(/(T00:00:00)?\.000Z$/,"")??""},Ut=[ue,he,Je,Ge,Cs,Ts,bn,wn,kn,Sn,gn,mn,yn,Tt,q,Et,$t,Bt,Es,_s,Qe],qt=new Map([["core",un],["failsafe",[ue,he,Je]],["json",pn],["yaml11",Ut],["yaml-1.1",Ut]]),Vt={binary:Tt,bool:At,float:ks,floatExp:ws,floatNaN:bs,floatTime:_s,int:Is,intHex:Ns,intOct:vs,intTime:Es,map:ue,merge:q,null:Ge,omap:Et,pairs:$t,seq:he,set:Bt,timestamp:Qe},vn={"tag:yaml.org,2002:binary":Tt,"tag:yaml.org,2002:merge":q,"tag:yaml.org,2002:omap":Et,"tag:yaml.org,2002:pairs":$t,"tag:yaml.org,2002:set":Bt,"tag:yaml.org,2002:timestamp":Qe};function st(n,e,t){const s=qt.get(e);if(s&&!n)return t&&!s.includes(q)?s.concat(q):s.slice();let i=s;if(!i)if(Array.isArray(n))i=[];else{const r=Array.from(qt.keys()).filter(o=>o!=="yaml11").map(o=>JSON.stringify(o)).join(", ");throw new Error(`Unknown schema "${e}"; use one of ${r} or define customTags array`)}if(Array.isArray(n))for(const r of n)i=i.concat(r);else typeof n=="function"&&(i=n(i.slice()));return t&&(i=i.concat(q)),i.reduce((r,o)=>{const a=typeof o=="string"?Vt[o]:o;if(!a){const l=JSON.stringify(o),c=Object.keys(Vt).map(f=>JSON.stringify(f)).join(", ");throw new Error(`Unknown custom tag ${l}; use one of ${c}`)}return r.includes(a)||r.push(a),r},[])}const In=(n,e)=>n.key<e.key?-1:n.key>e.key?1:0;class Pt{constructor({compat:e,customTags:t,merge:s,resolveKnownTags:i,schema:r,sortMapEntries:o,toStringDefaults:a}){this.compat=Array.isArray(e)?st(e,"compat"):e?st(null,e):null,this.name=typeof r=="string"&&r||"core",this.knownTags=i?vn:{},this.tags=st(t,this.name,s),this.toStringOptions=a??null,Object.defineProperty(this,W,{value:ue}),Object.defineProperty(this,D,{value:Je}),Object.defineProperty(this,ce,{value:he}),this.sortMapEntries=typeof o=="function"?o:o===!0?In:null}clone(){const e=Object.create(Pt.prototype,Object.getOwnPropertyDescriptors(this));return e.tags=this.tags.slice(),e}}function Nn(n,e){const t=[];let s=e.directives===!0;if(e.directives!==!1&&n.directives){const l=n.directives.toString(n);l?(t.push(l),s=!0):n.directives.docStart&&(s=!0)}s&&t.push("---");const i=ds(n,e),{commentString:r}=i.options;if(n.commentBefore){t.length!==1&&t.unshift("");const l=r(n.commentBefore);t.unshift(U(l,""))}let o=!1,a=null;if(n.contents){if(C(n.contents)){if(n.contents.spaceBefore&&s&&t.push(""),n.contents.commentBefore){const f=r(n.contents.commentBefore);t.push(U(f,""))}i.forceBlockIndent=!!n.comment,a=n.contents.comment}const l=a?void 0:()=>o=!0;let c=ae(n.contents,i,()=>a=null,l);a&&(c+=G(c,"",r(a))),(c[0]==="|"||c[0]===">")&&t[t.length-1]==="---"?t[t.length-1]=`--- ${c}`:t.push(c)}else t.push(ae(n.contents,i));if(n.directives?.docEnd)if(n.comment){const l=r(n.comment);l.includes(`
|
|
55
|
+
`)?(t.push("..."),t.push(U(l,""))):t.push(`... ${l}`)}else t.push("...");else{let l=n.comment;l&&o&&(l=l.replace(/^\n+/,"")),l&&((!o||a)&&t[t.length-1]!==""&&t.push(""),t.push(U(r(l),"")))}return t.join(`
|
|
56
|
+
`)+`
|
|
57
|
+
`}class Xe{constructor(e,t,s){this.commentBefore=null,this.comment=null,this.errors=[],this.warnings=[],Object.defineProperty(this,j,{value:pt});let i=null;typeof t=="function"||Array.isArray(t)?i=t:s===void 0&&t&&(s=t,t=void 0);const r=Object.assign({intAsBigInt:!1,keepSourceTokens:!1,logLevel:"warn",prettyErrors:!0,strict:!0,stringKeys:!1,uniqueKeys:!0,version:"1.2"},s);this.options=r;let{version:o}=r;s?._directives?(this.directives=s._directives.atDocument(),this.directives.yaml.explicit&&(o=this.directives.yaml.version)):this.directives=new _({version:o}),this.setSchema(o,s),this.contents=e===void 0?null:this.createNode(e,i,s)}clone(){const e=Object.create(Xe.prototype,{[j]:{value:pt}});return e.commentBefore=this.commentBefore,e.comment=this.comment,e.errors=this.errors.slice(),e.warnings=this.warnings.slice(),e.options=Object.assign({},this.options),this.directives&&(e.directives=this.directives.clone()),e.schema=this.schema.clone(),e.contents=C(this.contents)?this.contents.clone(e.schema):this.contents,this.range&&(e.range=this.range.slice()),e}add(e){Z(this.contents)&&this.contents.add(e)}addIn(e,t){Z(this.contents)&&this.contents.addIn(e,t)}createAlias(e,t){if(!e.anchor){const s=ls(this);e.anchor=!t||s.has(t)?cs(t||"a",s):t}return new Nt(e.anchor)}createNode(e,t,s){let i;if(typeof t=="function")e=t.call({"":e},"",e),i=t;else if(Array.isArray(t)){const g=y=>typeof y=="number"||y instanceof String||y instanceof Number,b=t.filter(g).map(String);b.length>0&&(t=t.concat(b)),i=t}else s===void 0&&t&&(s=t,t=void 0);const{aliasDuplicateObjects:r,anchorPrefix:o,flow:a,keepUndefined:l,onTagObj:c,tag:f}=s??{},{onAnchor:u,setAnchors:h,sourceObjects:p}=Qs(this,o||"a"),m={aliasDuplicateObjects:r??!0,keepUndefined:l??!1,onAnchor:u,onTagObj:c,replacer:i,schema:this.schema,sourceObjects:p},d=ke(e,f,m);return a&&A(d)&&(d.flow=!0),h(),d}createPair(e,t,s={}){const i=this.createNode(e,null,s),r=this.createNode(t,null,s);return new B(i,r)}delete(e){return Z(this.contents)?this.contents.delete(e):!1}deleteIn(e){return pe(e)?this.contents==null?!1:(this.contents=null,!0):Z(this.contents)?this.contents.deleteIn(e):!1}get(e,t){return A(this.contents)?this.contents.get(e,t):void 0}getIn(e,t){return pe(e)?!t&&O(this.contents)?this.contents.value:this.contents:A(this.contents)?this.contents.getIn(e,t):void 0}has(e){return A(this.contents)?this.contents.has(e):!1}hasIn(e){return pe(e)?this.contents!==void 0:A(this.contents)?this.contents.hasIn(e):!1}set(e,t){this.contents==null?this.contents=Re(this.schema,[e],t):Z(this.contents)&&this.contents.set(e,t)}setIn(e,t){pe(e)?this.contents=t:this.contents==null?this.contents=Re(this.schema,Array.from(e),t):Z(this.contents)&&this.contents.setIn(e,t)}setSchema(e,t={}){typeof e=="number"&&(e=String(e));let s;switch(e){case"1.1":this.directives?this.directives.yaml.version="1.1":this.directives=new _({version:"1.1"}),s={resolveKnownTags:!1,schema:"yaml-1.1"};break;case"1.2":case"next":this.directives?this.directives.yaml.version=e:this.directives=new _({version:e}),s={resolveKnownTags:!0,schema:"core"};break;case null:this.directives&&delete this.directives,s=null;break;default:{const i=JSON.stringify(e);throw new Error(`Expected '1.1', '1.2' or null as first argument, but found: ${i}`)}}if(t.schema instanceof Object)this.schema=t.schema;else if(s)this.schema=new Pt(Object.assign(s,t));else throw new Error("With a null YAML version, the { schema: Schema } option is required")}toJS({json:e,jsonArg:t,mapAsMap:s,maxAliasCount:i,onAnchor:r,reviver:o}={}){const a={anchors:new Map,doc:this,keep:!e,mapAsMap:s===!0,mapKeyWarned:!1,maxAliasCount:typeof i=="number"?i:100},l=x(this.contents,t??"",a);if(typeof r=="function")for(const{count:c,res:f}of a.anchors.values())r(f,c);return typeof o=="function"?ne(o,{"":l},"",l):l}toJSON(e,t){return this.toJS({json:!0,jsonArg:e,mapAsMap:!1,onAnchor:t})}toString(e={}){if(this.errors.length>0)throw new Error("Document with errors cannot be stringified");if("indent"in e&&(!Number.isInteger(e.indent)||Number(e.indent)<=0)){const t=JSON.stringify(e.indent);throw new Error(`"indent" option must be a positive integer, not ${t}`)}return Nn(this,e)}}function Z(n){if(A(n))return!0;throw new Error("Expected a YAML collection as document contents")}class Bs extends Error{constructor(e,t,s,i){super(),this.name=e,this.code=s,this.message=i,this.pos=t}}class ge extends Bs{constructor(e,t,s){super("YAMLParseError",e,t,s)}}class Ln extends Bs{constructor(e,t,s){super("YAMLWarning",e,t,s)}}const Ht=(n,e)=>t=>{if(t.pos[0]===-1)return;t.linePos=t.pos.map(a=>e.linePos(a));const{line:s,col:i}=t.linePos[0];t.message+=` at line ${s}, column ${i}`;let r=i-1,o=n.substring(e.lineStarts[s-1],e.lineStarts[s]).replace(/[\n\r]+$/,"");if(r>=60&&o.length>80){const a=Math.min(r-39,o.length-79);o="…"+o.substring(a),r-=a-1}if(o.length>80&&(o=o.substring(0,79)+"…"),s>1&&/^ *$/.test(o.substring(0,r))){let a=n.substring(e.lineStarts[s-2],e.lineStarts[s-1]);a.length>80&&(a=a.substring(0,79)+`…
|
|
58
|
+
`),o=a+o}if(/[^ ]/.test(o)){let a=1;const l=t.linePos[1];l?.line===s&&l.col>i&&(a=Math.max(1,Math.min(l.col-i,80-r)));const c=" ".repeat(r)+"^".repeat(a);t.message+=`:
|
|
59
|
+
|
|
60
|
+
${o}
|
|
61
|
+
${c}
|
|
62
|
+
`}};function le(n,{flow:e,indicator:t,next:s,offset:i,onError:r,parentIndent:o,startOnNewline:a}){let l=!1,c=a,f=a,u="",h="",p=!1,m=!1,d=null,g=null,b=null,y=null,k=null,S=null,v=null;for(const w of n)switch(m&&(w.type!=="space"&&w.type!=="newline"&&w.type!=="comma"&&r(w.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),m=!1),d&&(c&&w.type!=="comment"&&w.type!=="newline"&&r(d,"TAB_AS_INDENT","Tabs are not allowed as indentation"),d=null),w.type){case"space":!e&&(t!=="doc-start"||s?.type!=="flow-collection")&&w.source.includes(" ")&&(d=w),f=!0;break;case"comment":{f||r(w,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const $=w.source.substring(1)||" ";u?u+=h+$:u=$,h="",c=!1;break}case"newline":c?u?u+=w.source:(!S||t!=="seq-item-ind")&&(l=!0):h+=w.source,c=!0,p=!0,(g||b)&&(y=w),f=!0;break;case"anchor":g&&r(w,"MULTIPLE_ANCHORS","A node can have at most one anchor"),w.source.endsWith(":")&&r(w.offset+w.source.length-1,"BAD_ALIAS","Anchor ending in : is ambiguous",!0),g=w,v??(v=w.offset),c=!1,f=!1,m=!0;break;case"tag":{b&&r(w,"MULTIPLE_TAGS","A node can have at most one tag"),b=w,v??(v=w.offset),c=!1,f=!1,m=!0;break}case t:(g||b)&&r(w,"BAD_PROP_ORDER",`Anchors and tags must be after the ${w.source} indicator`),S&&r(w,"UNEXPECTED_TOKEN",`Unexpected ${w.source} in ${e??"collection"}`),S=w,c=t==="seq-item-ind"||t==="explicit-key-ind",f=!1;break;case"comma":if(e){k&&r(w,"UNEXPECTED_TOKEN",`Unexpected , in ${e}`),k=w,c=!1,f=!1;break}default:r(w,"UNEXPECTED_TOKEN",`Unexpected ${w.type} token`),c=!1,f=!1}const N=n[n.length-1],L=N?N.offset+N.source.length:i;return m&&s&&s.type!=="space"&&s.type!=="newline"&&s.type!=="comma"&&(s.type!=="scalar"||s.source!=="")&&r(s.offset,"MISSING_CHAR","Tags and anchors must be separated from the next token by white space"),d&&(c&&d.indent<=o||s?.type==="block-map"||s?.type==="block-seq")&&r(d,"TAB_AS_INDENT","Tabs are not allowed as indentation"),{comma:k,found:S,spaceBefore:l,comment:u,hasNewline:p,anchor:g,tag:b,newlineAfterProp:y,end:L,start:v??L}}function Se(n){if(!n)return null;switch(n.type){case"alias":case"scalar":case"double-quoted-scalar":case"single-quoted-scalar":if(n.source.includes(`
|
|
63
|
+
`))return!0;if(n.end){for(const e of n.end)if(e.type==="newline")return!0}return!1;case"flow-collection":for(const e of n.items){for(const t of e.start)if(t.type==="newline")return!0;if(e.sep){for(const t of e.sep)if(t.type==="newline")return!0}if(Se(e.key)||Se(e.value))return!0}return!1;default:return!0}}function bt(n,e,t){if(e?.type==="flow-collection"){const s=e.end[0];s.indent===n&&(s.source==="]"||s.source==="}")&&Se(e)&&t(s,"BAD_INDENT","Flow end indicator should be more indented than parent",!0)}}function Ms(n,e,t){const{uniqueKeys:s}=n.options;if(s===!1)return!1;const i=typeof s=="function"?s:(r,o)=>r===o||O(r)&&O(o)&&r.value===o.value;return e.some(r=>i(r.key,t))}const Wt="All mapping items must start at the same column";function On({composeNode:n,composeEmptyNode:e},t,s,i,r){const o=r?.nodeClass??P,a=new o(t.schema);t.atRoot&&(t.atRoot=!1);let l=s.offset,c=null;for(const f of s.items){const{start:u,key:h,sep:p,value:m}=f,d=le(u,{indicator:"explicit-key-ind",next:h??p?.[0],offset:l,onError:i,parentIndent:s.indent,startOnNewline:!0}),g=!d.found;if(g){if(h&&(h.type==="block-seq"?i(l,"BLOCK_AS_IMPLICIT_KEY","A block sequence may not be used as an implicit map key"):"indent"in h&&h.indent!==s.indent&&i(l,"BAD_INDENT",Wt)),!d.anchor&&!d.tag&&!p){c=d.end,d.comment&&(a.comment?a.comment+=`
|
|
64
|
+
`+d.comment:a.comment=d.comment);continue}(d.newlineAfterProp||Se(h))&&i(h??u[u.length-1],"MULTILINE_IMPLICIT_KEY","Implicit keys need to be on a single line")}else d.found?.indent!==s.indent&&i(l,"BAD_INDENT",Wt);t.atKey=!0;const b=d.end,y=h?n(t,h,d,i):e(t,b,u,null,d,i);t.schema.compat&&bt(s.indent,h,i),t.atKey=!1,Ms(t,a.items,y)&&i(b,"DUPLICATE_KEY","Map keys must be unique");const k=le(p??[],{indicator:"map-value-ind",next:m,offset:y.range[2],onError:i,parentIndent:s.indent,startOnNewline:!h||h.type==="block-scalar"});if(l=k.end,k.found){g&&(m?.type==="block-map"&&!k.hasNewline&&i(l,"BLOCK_AS_IMPLICIT_KEY","Nested mappings are not allowed in compact mappings"),t.options.strict&&d.start<k.found.offset-1024&&i(y.range,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit block mapping key"));const S=m?n(t,m,k,i):e(t,l,p,null,k,i);t.schema.compat&&bt(s.indent,m,i),l=S.range[2];const v=new B(y,S);t.options.keepSourceTokens&&(v.srcToken=f),a.items.push(v)}else{g&&i(y.range,"MISSING_CHAR","Implicit map keys need to be followed by map values"),k.comment&&(y.comment?y.comment+=`
|
|
65
|
+
`+k.comment:y.comment=k.comment);const S=new B(y);t.options.keepSourceTokens&&(S.srcToken=f),a.items.push(S)}}return c&&c<l&&i(c,"IMPOSSIBLE","Map comment with trailing content"),a.range=[s.offset,l,c??l],a}function An({composeNode:n,composeEmptyNode:e},t,s,i,r){const o=r?.nodeClass??Y,a=new o(t.schema);t.atRoot&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let l=s.offset,c=null;for(const{start:f,value:u}of s.items){const h=le(f,{indicator:"seq-item-ind",next:u,offset:l,onError:i,parentIndent:s.indent,startOnNewline:!0});if(!h.found)if(h.anchor||h.tag||u)u?.type==="block-seq"?i(h.end,"BAD_INDENT","All sequence items must start at the same column"):i(l,"MISSING_CHAR","Sequence item without - indicator");else{c=h.end,h.comment&&(a.comment=h.comment);continue}const p=u?n(t,u,h,i):e(t,h.end,f,null,h,i);t.schema.compat&&bt(s.indent,u,i),l=p.range[2],a.items.push(p)}return a.range=[s.offset,l,c??l],a}function Ae(n,e,t,s){let i="";if(n){let r=!1,o="";for(const a of n){const{source:l,type:c}=a;switch(c){case"space":r=!0;break;case"comment":{t&&!r&&s(a,"MISSING_CHAR","Comments must be separated from other tokens by white space characters");const f=l.substring(1)||" ";i?i+=o+f:i=f,o="";break}case"newline":i&&(o+=l),r=!0;break;default:s(a,"UNEXPECTED_TOKEN",`Unexpected ${c} at node end`)}e+=l.length}}return{comment:i,offset:e}}const nt="Block collections are not allowed within flow collections",it=n=>n&&(n.type==="block-map"||n.type==="block-seq");function Cn({composeNode:n,composeEmptyNode:e},t,s,i,r){const o=s.start.source==="{",a=o?"flow map":"flow sequence",l=r?.nodeClass??(o?P:Y),c=new l(t.schema);c.flow=!0;const f=t.atRoot;f&&(t.atRoot=!1),t.atKey&&(t.atKey=!1);let u=s.offset+s.start.source.length;for(let g=0;g<s.items.length;++g){const b=s.items[g],{start:y,key:k,sep:S,value:v}=b,N=le(y,{flow:a,indicator:"explicit-key-ind",next:k??S?.[0],offset:u,onError:i,parentIndent:s.indent,startOnNewline:!1});if(!N.found){if(!N.anchor&&!N.tag&&!S&&!v){g===0&&N.comma?i(N.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`):g<s.items.length-1&&i(N.start,"UNEXPECTED_TOKEN",`Unexpected empty item in ${a}`),N.comment&&(c.comment?c.comment+=`
|
|
66
|
+
`+N.comment:c.comment=N.comment),u=N.end;continue}!o&&t.options.strict&&Se(k)&&i(k,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line")}if(g===0)N.comma&&i(N.comma,"UNEXPECTED_TOKEN",`Unexpected , in ${a}`);else if(N.comma||i(N.start,"MISSING_CHAR",`Missing , between ${a} items`),N.comment){let L="";e:for(const w of y)switch(w.type){case"comma":case"space":break;case"comment":L=w.source.substring(1);break e;default:break e}if(L){let w=c.items[c.items.length-1];T(w)&&(w=w.value??w.key),w.comment?w.comment+=`
|
|
67
|
+
`+L:w.comment=L,N.comment=N.comment.substring(L.length+1)}}if(!o&&!S&&!N.found){const L=v?n(t,v,N,i):e(t,N.end,S,null,N,i);c.items.push(L),u=L.range[2],it(v)&&i(L.range,"BLOCK_IN_FLOW",nt)}else{t.atKey=!0;const L=N.end,w=k?n(t,k,N,i):e(t,L,y,null,N,i);it(k)&&i(w.range,"BLOCK_IN_FLOW",nt),t.atKey=!1;const $=le(S??[],{flow:a,indicator:"map-value-ind",next:v,offset:w.range[2],onError:i,parentIndent:s.indent,startOnNewline:!1});if($.found){if(!o&&!N.found&&t.options.strict){if(S)for(const E of S){if(E===$.found)break;if(E.type==="newline"){i(E,"MULTILINE_IMPLICIT_KEY","Implicit keys of flow sequence pairs need to be on a single line");break}}N.start<$.found.offset-1024&&i($.found,"KEY_OVER_1024_CHARS","The : indicator must be at most 1024 chars after the start of an implicit flow sequence key")}}else v&&("source"in v&&v.source?.[0]===":"?i(v,"MISSING_CHAR",`Missing space after : in ${a}`):i($.start,"MISSING_CHAR",`Missing , or : between ${a} items`));const V=v?n(t,v,$,i):$.found?e(t,$.end,S,null,$,i):null;V?it(v)&&i(V.range,"BLOCK_IN_FLOW",nt):$.comment&&(w.comment?w.comment+=`
|
|
68
|
+
`+$.comment:w.comment=$.comment);const X=new B(w,V);if(t.options.keepSourceTokens&&(X.srcToken=b),o){const E=c;Ms(t,E.items,w)&&i(L,"DUPLICATE_KEY","Map keys must be unique"),E.items.push(X)}else{const E=new P(t.schema);E.flow=!0,E.items.push(X);const Ft=(V??w).range;E.range=[w.range[0],Ft[1],Ft[2]],c.items.push(E)}u=V?V.range[2]:$.end}}const h=o?"}":"]",[p,...m]=s.end;let d=u;if(p?.source===h)d=p.offset+p.source.length;else{const g=a[0].toUpperCase()+a.substring(1),b=f?`${g} must end with a ${h}`:`${g} in block collection must be sufficiently indented and end with a ${h}`;i(u,f?"MISSING_CHAR":"BAD_INDENT",b),p&&p.source.length!==1&&m.unshift(p)}if(m.length>0){const g=Ae(m,d,t.options.strict,i);g.comment&&(c.comment?c.comment+=`
|
|
69
|
+
`+g.comment:c.comment=g.comment),c.range=[s.offset,d,g.offset]}else c.range=[s.offset,d,d];return c}function rt(n,e,t,s,i,r){const o=t.type==="block-map"?On(n,e,t,s,r):t.type==="block-seq"?An(n,e,t,s,r):Cn(n,e,t,s,r),a=o.constructor;return i==="!"||i===a.tagName?(o.tag=a.tagName,o):(i&&(o.tag=i),o)}function Tn(n,e,t,s,i){const r=s.tag,o=r?e.directives.tagName(r.source,h=>i(r,"TAG_RESOLVE_FAILED",h)):null;if(t.type==="block-seq"){const{anchor:h,newlineAfterProp:p}=s,m=h&&r?h.offset>r.offset?h:r:h??r;m&&(!p||p.offset<m.offset)&&i(m,"MISSING_CHAR","Missing newline after block sequence props")}const a=t.type==="block-map"?"map":t.type==="block-seq"?"seq":t.start.source==="{"?"map":"seq";if(!r||!o||o==="!"||o===P.tagName&&a==="map"||o===Y.tagName&&a==="seq")return rt(n,e,t,i,o);let l=e.schema.tags.find(h=>h.tag===o&&h.collection===a);if(!l){const h=e.schema.knownTags[o];if(h?.collection===a)e.schema.tags.push(Object.assign({},h,{default:!1})),l=h;else return h?i(r,"BAD_COLLECTION_TYPE",`${h.tag} used for ${a} collection, but expects ${h.collection??"scalar"}`,!0):i(r,"TAG_RESOLVE_FAILED",`Unresolved tag: ${o}`,!0),rt(n,e,t,i,o)}const c=rt(n,e,t,i,o,l),f=l.resolve?.(c,h=>i(r,"TAG_RESOLVE_FAILED",h),e.options)??c,u=C(f)?f:new I(f);return u.range=c.range,u.tag=o,l?.format&&(u.format=l.format),u}function $n(n,e,t){const s=e.offset,i=En(e,n.options.strict,t);if(!i)return{value:"",type:null,comment:"",range:[s,s,s]};const r=i.mode===">"?I.BLOCK_FOLDED:I.BLOCK_LITERAL,o=e.source?_n(e.source):[];let a=o.length;for(let d=o.length-1;d>=0;--d){const g=o[d][1];if(g===""||g==="\r")a=d;else break}if(a===0){const d=i.chomp==="+"&&o.length>0?`
|
|
70
|
+
`.repeat(Math.max(1,o.length-1)):"";let g=s+i.length;return e.source&&(g+=e.source.length),{value:d,type:r,comment:i.comment,range:[s,g,g]}}let l=e.indent+i.indent,c=e.offset+i.length,f=0;for(let d=0;d<a;++d){const[g,b]=o[d];if(b===""||b==="\r")i.indent===0&&g.length>l&&(l=g.length);else{g.length<l&&t(c+g.length,"MISSING_CHAR","Block scalars with more-indented leading empty lines must use an explicit indentation indicator"),i.indent===0&&(l=g.length),f=d,l===0&&!n.atRoot&&t(c,"BAD_INDENT","Block scalar values in collections must be indented");break}c+=g.length+b.length+1}for(let d=o.length-1;d>=a;--d)o[d][0].length>l&&(a=d+1);let u="",h="",p=!1;for(let d=0;d<f;++d)u+=o[d][0].slice(l)+`
|
|
71
|
+
`;for(let d=f;d<a;++d){let[g,b]=o[d];c+=g.length+b.length+1;const y=b[b.length-1]==="\r";if(y&&(b=b.slice(0,-1)),b&&g.length<l){const S=`Block scalar lines must not be less indented than their ${i.indent?"explicit indentation indicator":"first line"}`;t(c-b.length-(y?2:1),"BAD_INDENT",S),g=""}r===I.BLOCK_LITERAL?(u+=h+g.slice(l)+b,h=`
|
|
72
|
+
`):g.length>l||b[0]===" "?(h===" "?h=`
|
|
73
|
+
`:!p&&h===`
|
|
74
|
+
`&&(h=`
|
|
75
|
+
|
|
76
|
+
`),u+=h+g.slice(l)+b,h=`
|
|
77
|
+
`,p=!0):b===""?h===`
|
|
78
|
+
`?u+=`
|
|
79
|
+
`:h=`
|
|
80
|
+
`:(u+=h+b,h=" ",p=!1)}switch(i.chomp){case"-":break;case"+":for(let d=a;d<o.length;++d)u+=`
|
|
81
|
+
`+o[d][0].slice(l);u[u.length-1]!==`
|
|
82
|
+
`&&(u+=`
|
|
83
|
+
`);break;default:u+=`
|
|
84
|
+
`}const m=s+i.length+e.source.length;return{value:u,type:r,comment:i.comment,range:[s,m,m]}}function En({offset:n,props:e},t,s){if(e[0].type!=="block-scalar-header")return s(e[0],"IMPOSSIBLE","Block scalar header not found"),null;const{source:i}=e[0],r=i[0];let o=0,a="",l=-1;for(let h=1;h<i.length;++h){const p=i[h];if(!a&&(p==="-"||p==="+"))a=p;else{const m=Number(p);!o&&m?o=m:l===-1&&(l=n+h)}}l!==-1&&s(l,"UNEXPECTED_TOKEN",`Block scalar header includes extra characters: ${i}`);let c=!1,f="",u=i.length;for(let h=1;h<e.length;++h){const p=e[h];switch(p.type){case"space":c=!0;case"newline":u+=p.source.length;break;case"comment":t&&!c&&s(p,"MISSING_CHAR","Comments must be separated from other tokens by white space characters"),u+=p.source.length,f=p.source.substring(1);break;case"error":s(p,"UNEXPECTED_TOKEN",p.message),u+=p.source.length;break;default:{const m=`Unexpected token in block scalar header: ${p.type}`;s(p,"UNEXPECTED_TOKEN",m);const d=p.source;d&&typeof d=="string"&&(u+=d.length)}}}return{mode:r,indent:o,chomp:a,comment:f,length:u}}function _n(n){const e=n.split(/\n( *)/),t=e[0],s=t.match(/^( *)/),r=[s?.[1]?[s[1],t.slice(s[1].length)]:["",t]];for(let o=1;o<e.length;o+=2)r.push([e[o],e[o+1]]);return r}function Bn(n,e,t){const{offset:s,type:i,source:r,end:o}=n;let a,l;const c=(h,p,m)=>t(s+h,p,m);switch(i){case"scalar":a=I.PLAIN,l=Mn(r,c);break;case"single-quoted-scalar":a=I.QUOTE_SINGLE,l=Pn(r,c);break;case"double-quoted-scalar":a=I.QUOTE_DOUBLE,l=xn(r,c);break;default:return t(n,"UNEXPECTED_TOKEN",`Expected a flow scalar value, but found: ${i}`),{value:"",type:null,comment:"",range:[s,s+r.length,s+r.length]}}const f=s+r.length,u=Ae(o,f,e,t);return{value:l,type:a,comment:u.comment,range:[s,f,u.offset]}}function Mn(n,e){let t="";switch(n[0]){case" ":t="a tab character";break;case",":t="flow indicator character ,";break;case"%":t="directive indicator character %";break;case"|":case">":{t=`block scalar indicator ${n[0]}`;break}case"@":case"`":{t=`reserved character ${n[0]}`;break}}return t&&e(0,"BAD_SCALAR_START",`Plain value cannot start with ${t}`),Ps(n)}function Pn(n,e){return(n[n.length-1]!=="'"||n.length===1)&&e(n.length,"MISSING_CHAR","Missing closing 'quote"),Ps(n.slice(1,-1)).replace(/''/g,"'")}function Ps(n){let e,t;try{e=new RegExp(`(.*?)(?<![ ])[ ]*\r?
|
|
85
|
+
`,"sy"),t=new RegExp(`[ ]*(.*?)(?:(?<![ ])[ ]*)?\r?
|
|
86
|
+
`,"sy")}catch{e=/(.*?)[ \t]*\r?\n/sy,t=/[ \t]*(.*?)[ \t]*\r?\n/sy}let s=e.exec(n);if(!s)return n;let i=s[1],r=" ",o=e.lastIndex;for(t.lastIndex=o;s=t.exec(n);)s[1]===""?r===`
|
|
87
|
+
`?i+=r:r=`
|
|
88
|
+
`:(i+=r+s[1],r=" "),o=t.lastIndex;const a=/[ \t]*(.*)/sy;return a.lastIndex=o,s=a.exec(n),i+r+(s?.[1]??"")}function xn(n,e){let t="";for(let s=1;s<n.length-1;++s){const i=n[s];if(!(i==="\r"&&n[s+1]===`
|
|
89
|
+
`))if(i===`
|
|
90
|
+
`){const{fold:r,offset:o}=jn(n,s);t+=r,s=o}else if(i==="\\"){let r=n[++s];const o=Rn[r];if(o)t+=o;else if(r===`
|
|
91
|
+
`)for(r=n[s+1];r===" "||r===" ";)r=n[++s+1];else if(r==="\r"&&n[s+1]===`
|
|
92
|
+
`)for(r=n[++s+1];r===" "||r===" ";)r=n[++s+1];else if(r==="x"||r==="u"||r==="U"){const a={x:2,u:4,U:8}[r];t+=Fn(n,s+1,a,e),s+=a}else{const a=n.substr(s-1,2);e(s-1,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),t+=a}}else if(i===" "||i===" "){const r=s;let o=n[s+1];for(;o===" "||o===" ";)o=n[++s+1];o!==`
|
|
93
|
+
`&&!(o==="\r"&&n[s+2]===`
|
|
94
|
+
`)&&(t+=s>r?n.slice(r,s+1):i)}else t+=i}return(n[n.length-1]!=='"'||n.length===1)&&e(n.length,"MISSING_CHAR",'Missing closing "quote'),t}function jn(n,e){let t="",s=n[e+1];for(;(s===" "||s===" "||s===`
|
|
95
|
+
`||s==="\r")&&!(s==="\r"&&n[e+2]!==`
|
|
96
|
+
`);)s===`
|
|
97
|
+
`&&(t+=`
|
|
98
|
+
`),e+=1,s=n[e+1];return t||(t=" "),{fold:t,offset:e}}const Rn={0:"\0",a:"\x07",b:"\b",e:"\x1B",f:"\f",n:`
|
|
99
|
+
`,r:"\r",t:" ",v:"\v",N:"
",_:" ",L:"\u2028",P:"\u2029"," ":" ",'"':'"',"/":"/","\\":"\\"," ":" "};function Fn(n,e,t,s){const i=n.substr(e,t),o=i.length===t&&/^[0-9a-fA-F]+$/.test(i)?parseInt(i,16):NaN;if(isNaN(o)){const a=n.substr(e-2,t+2);return s(e-2,"BAD_DQ_ESCAPE",`Invalid escape sequence ${a}`),a}return String.fromCodePoint(o)}function xs(n,e,t,s){const{value:i,type:r,comment:o,range:a}=e.type==="block-scalar"?$n(n,e,s):Bn(e,n.options.strict,s),l=t?n.directives.tagName(t.source,u=>s(t,"TAG_RESOLVE_FAILED",u)):null;let c;n.options.stringKeys&&n.atKey?c=n.schema[D]:l?c=Dn(n.schema,i,l,t,s):e.type==="scalar"?c=Kn(n,i,e,s):c=n.schema[D];let f;try{const u=c.resolve(i,h=>s(t??e,"TAG_RESOLVE_FAILED",h),n.options);f=O(u)?u:new I(u)}catch(u){const h=u instanceof Error?u.message:String(u);s(t??e,"TAG_RESOLVE_FAILED",h),f=new I(i)}return f.range=a,f.source=i,r&&(f.type=r),l&&(f.tag=l),c.format&&(f.format=c.format),o&&(f.comment=o),f}function Dn(n,e,t,s,i){if(t==="!")return n[D];const r=[];for(const a of n.tags)if(!a.collection&&a.tag===t)if(a.default&&a.test)r.push(a);else return a;for(const a of r)if(a.test?.test(e))return a;const o=n.knownTags[t];return o&&!o.collection?(n.tags.push(Object.assign({},o,{default:!1,test:void 0})),o):(i(s,"TAG_RESOLVE_FAILED",`Unresolved tag: ${t}`,t!=="tag:yaml.org,2002:str"),n[D])}function Kn({atKey:n,directives:e,schema:t},s,i,r){const o=t.tags.find(a=>(a.default===!0||n&&a.default==="key")&&a.test?.test(s))||t[D];if(t.compat){const a=t.compat.find(l=>l.default&&l.test?.test(s))??t[D];if(o.tag!==a.tag){const l=e.tagString(o.tag),c=e.tagString(a.tag),f=`Value may be parsed as either ${l} or ${c}`;r(i,"TAG_RESOLVE_FAILED",f,!0)}}return o}function Un(n,e,t){if(e){t??(t=e.length);for(let s=t-1;s>=0;--s){let i=e[s];switch(i.type){case"space":case"comment":case"newline":n-=i.source.length;continue}for(i=e[++s];i?.type==="space";)n+=i.source.length,i=e[++s];break}}return n}const qn={composeNode:js,composeEmptyNode:xt};function js(n,e,t,s){const i=n.atKey,{spaceBefore:r,comment:o,anchor:a,tag:l}=t;let c,f=!0;switch(e.type){case"alias":c=Vn(n,e,s),(a||l)&&s(e,"ALIAS_PROPS","An alias node must not specify any properties");break;case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"block-scalar":c=xs(n,e,l,s),a&&(c.anchor=a.source.substring(1));break;case"block-map":case"block-seq":case"flow-collection":c=Tn(qn,n,e,t,s),a&&(c.anchor=a.source.substring(1));break;default:{const u=e.type==="error"?e.message:`Unsupported token (type: ${e.type})`;s(e,"UNEXPECTED_TOKEN",u),c=xt(n,e.offset,void 0,null,t,s),f=!1}}return a&&c.anchor===""&&s(a,"BAD_ALIAS","Anchor cannot be an empty string"),i&&n.options.stringKeys&&(!O(c)||typeof c.value!="string"||c.tag&&c.tag!=="tag:yaml.org,2002:str")&&s(l??e,"NON_STRING_KEY","With stringKeys, all keys must be strings"),r&&(c.spaceBefore=!0),o&&(e.type==="scalar"&&e.source===""?c.comment=o:c.commentBefore=o),n.options.keepSourceTokens&&f&&(c.srcToken=e),c}function xt(n,e,t,s,{spaceBefore:i,comment:r,anchor:o,tag:a,end:l},c){const f={type:"scalar",offset:Un(e,t,s),indent:-1,source:""},u=xs(n,f,a,c);return o&&(u.anchor=o.source.substring(1),u.anchor===""&&c(o,"BAD_ALIAS","Anchor cannot be an empty string")),i&&(u.spaceBefore=!0),r&&(u.comment=r,u.range[2]=l),u}function Vn({options:n},{offset:e,source:t,end:s},i){const r=new Nt(t.substring(1));r.source===""&&i(e,"BAD_ALIAS","Alias cannot be an empty string"),r.source.endsWith(":")&&i(e+t.length-1,"BAD_ALIAS","Alias ending in : is ambiguous",!0);const o=e+t.length,a=Ae(s,o,n.strict,i);return r.range=[e,o,a.offset],a.comment&&(r.comment=a.comment),r}function Hn(n,e,{offset:t,start:s,value:i,end:r},o){const a=Object.assign({_directives:e},n),l=new Xe(void 0,a),c={atKey:!1,atRoot:!0,directives:l.directives,options:l.options,schema:l.schema},f=le(s,{indicator:"doc-start",next:i??r?.[0],offset:t,onError:o,parentIndent:0,startOnNewline:!0});f.found&&(l.directives.docStart=!0,i&&(i.type==="block-map"||i.type==="block-seq")&&!f.hasNewline&&o(f.end,"MISSING_CHAR","Block collection cannot start on same line with directives-end marker")),l.contents=i?js(c,i,f,o):xt(c,f.end,s,null,f,o);const u=l.contents.range[2],h=Ae(r,u,!1,o);return h.comment&&(l.comment=h.comment),l.range=[t,u,h.offset],l}function de(n){if(typeof n=="number")return[n,n+1];if(Array.isArray(n))return n.length===2?n:[n[0],n[1]];const{offset:e,source:t}=n;return[e,e+(typeof t=="string"?t.length:1)]}function Jt(n){let e="",t=!1,s=!1;for(let i=0;i<n.length;++i){const r=n[i];switch(r[0]){case"#":e+=(e===""?"":s?`
|
|
100
|
+
|
|
101
|
+
`:`
|
|
102
|
+
`)+(r.substring(1)||" "),t=!0,s=!1;break;case"%":n[i+1]?.[0]!=="#"&&(i+=1),t=!1;break;default:t||(s=!0),t=!1}}return{comment:e,afterEmptyLine:s}}class Wn{constructor(e={}){this.doc=null,this.atDirectives=!1,this.prelude=[],this.errors=[],this.warnings=[],this.onError=(t,s,i,r)=>{const o=de(t);r?this.warnings.push(new Ln(o,s,i)):this.errors.push(new ge(o,s,i))},this.directives=new _({version:e.version||"1.2"}),this.options=e}decorate(e,t){const{comment:s,afterEmptyLine:i}=Jt(this.prelude);if(s){const r=e.contents;if(t)e.comment=e.comment?`${e.comment}
|
|
103
|
+
${s}`:s;else if(i||e.directives.docStart||!r)e.commentBefore=s;else if(A(r)&&!r.flow&&r.items.length>0){let o=r.items[0];T(o)&&(o=o.key);const a=o.commentBefore;o.commentBefore=a?`${s}
|
|
104
|
+
${a}`:s}else{const o=r.commentBefore;r.commentBefore=o?`${s}
|
|
105
|
+
${o}`:s}}t?(Array.prototype.push.apply(e.errors,this.errors),Array.prototype.push.apply(e.warnings,this.warnings)):(e.errors=this.errors,e.warnings=this.warnings),this.prelude=[],this.errors=[],this.warnings=[]}streamInfo(){return{comment:Jt(this.prelude).comment,directives:this.directives,errors:this.errors,warnings:this.warnings}}*compose(e,t=!1,s=-1){for(const i of e)yield*this.next(i);yield*this.end(t,s)}*next(e){switch(e.type){case"directive":this.directives.add(e.source,(t,s,i)=>{const r=de(e);r[0]+=t,this.onError(r,"BAD_DIRECTIVE",s,i)}),this.prelude.push(e.source),this.atDirectives=!0;break;case"document":{const t=Hn(this.options,this.directives,e,this.onError);this.atDirectives&&!t.directives.docStart&&this.onError(e,"MISSING_CHAR","Missing directives-end/doc-start indicator line"),this.decorate(t,!1),this.doc&&(yield this.doc),this.doc=t,this.atDirectives=!1;break}case"byte-order-mark":case"space":break;case"comment":case"newline":this.prelude.push(e.source);break;case"error":{const t=e.source?`${e.message}: ${JSON.stringify(e.source)}`:e.message,s=new ge(de(e),"UNEXPECTED_TOKEN",t);this.atDirectives||!this.doc?this.errors.push(s):this.doc.errors.push(s);break}case"doc-end":{if(!this.doc){const s="Unexpected doc-end without preceding document";this.errors.push(new ge(de(e),"UNEXPECTED_TOKEN",s));break}this.doc.directives.docEnd=!0;const t=Ae(e.end,e.offset+e.source.length,this.doc.options.strict,this.onError);if(this.decorate(this.doc,!0),t.comment){const s=this.doc.comment;this.doc.comment=s?`${s}
|
|
106
|
+
${t.comment}`:t.comment}this.doc.range[2]=t.offset;break}default:this.errors.push(new ge(de(e),"UNEXPECTED_TOKEN",`Unsupported token ${e.type}`))}}*end(e=!1,t=-1){if(this.doc)this.decorate(this.doc,!0),yield this.doc,this.doc=null;else if(e){const s=Object.assign({_directives:this.directives},this.options),i=new Xe(void 0,s);this.atDirectives&&this.onError(t,"MISSING_CHAR","Missing directives-end indicator line"),i.range=[0,t,t],this.decorate(i,!1),yield i}}}const Rs="\uFEFF",Fs="",Ds="",wt="";function Jn(n){switch(n){case Rs:return"byte-order-mark";case Fs:return"doc-mode";case Ds:return"flow-error-end";case wt:return"scalar";case"---":return"doc-start";case"...":return"doc-end";case"":case`
|
|
107
|
+
`:case`\r
|
|
108
|
+
`:return"newline";case"-":return"seq-item-ind";case"?":return"explicit-key-ind";case":":return"map-value-ind";case"{":return"flow-map-start";case"}":return"flow-map-end";case"[":return"flow-seq-start";case"]":return"flow-seq-end";case",":return"comma"}switch(n[0]){case" ":case" ":return"space";case"#":return"comment";case"%":return"directive-line";case"*":return"alias";case"&":return"anchor";case"!":return"tag";case"'":return"single-quoted-scalar";case'"':return"double-quoted-scalar";case"|":case">":return"block-scalar-header"}return null}function R(n){switch(n){case void 0:case" ":case`
|
|
109
|
+
`:case"\r":case" ":return!0;default:return!1}}const Gt=new Set("0123456789ABCDEFabcdef"),Gn=new Set("0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz-#;/?:@&=+$_.!~*'()"),Ee=new Set(",[]{}"),zn=new Set(` ,[]{}
|
|
110
|
+
\r `),ot=n=>!n||zn.has(n);class Yn{constructor(){this.atEnd=!1,this.blockScalarIndent=-1,this.blockScalarKeep=!1,this.buffer="",this.flowKey=!1,this.flowLevel=0,this.indentNext=0,this.indentValue=0,this.lineEndPos=null,this.next=null,this.pos=0}*lex(e,t=!1){if(e){if(typeof e!="string")throw TypeError("source is not a string");this.buffer=this.buffer?this.buffer+e:e,this.lineEndPos=null}this.atEnd=!t;let s=this.next??"stream";for(;s&&(t||this.hasChars(1));)s=yield*this.parseNext(s)}atLineEnd(){let e=this.pos,t=this.buffer[e];for(;t===" "||t===" ";)t=this.buffer[++e];return!t||t==="#"||t===`
|
|
111
|
+
`?!0:t==="\r"?this.buffer[e+1]===`
|
|
112
|
+
`:!1}charAt(e){return this.buffer[this.pos+e]}continueScalar(e){let t=this.buffer[e];if(this.indentNext>0){let s=0;for(;t===" ";)t=this.buffer[++s+e];if(t==="\r"){const i=this.buffer[s+e+1];if(i===`
|
|
113
|
+
`||!i&&!this.atEnd)return e+s+1}return t===`
|
|
114
|
+
`||s>=this.indentNext||!t&&!this.atEnd?e+s:-1}if(t==="-"||t==="."){const s=this.buffer.substr(e,3);if((s==="---"||s==="...")&&R(this.buffer[e+3]))return-1}return e}getLine(){let e=this.lineEndPos;return(typeof e!="number"||e!==-1&&e<this.pos)&&(e=this.buffer.indexOf(`
|
|
115
|
+
`,this.pos),this.lineEndPos=e),e===-1?this.atEnd?this.buffer.substring(this.pos):null:(this.buffer[e-1]==="\r"&&(e-=1),this.buffer.substring(this.pos,e))}hasChars(e){return this.pos+e<=this.buffer.length}setNext(e){return this.buffer=this.buffer.substring(this.pos),this.pos=0,this.lineEndPos=null,this.next=e,null}peek(e){return this.buffer.substr(this.pos,e)}*parseNext(e){switch(e){case"stream":return yield*this.parseStream();case"line-start":return yield*this.parseLineStart();case"block-start":return yield*this.parseBlockStart();case"doc":return yield*this.parseDocument();case"flow":return yield*this.parseFlowCollection();case"quoted-scalar":return yield*this.parseQuotedScalar();case"block-scalar":return yield*this.parseBlockScalar();case"plain-scalar":return yield*this.parsePlainScalar()}}*parseStream(){let e=this.getLine();if(e===null)return this.setNext("stream");if(e[0]===Rs&&(yield*this.pushCount(1),e=e.substring(1)),e[0]==="%"){let t=e.length,s=e.indexOf("#");for(;s!==-1;){const r=e[s-1];if(r===" "||r===" "){t=s-1;break}else s=e.indexOf("#",s+1)}for(;;){const r=e[t-1];if(r===" "||r===" ")t-=1;else break}const i=(yield*this.pushCount(t))+(yield*this.pushSpaces(!0));return yield*this.pushCount(e.length-i),this.pushNewline(),"stream"}if(this.atLineEnd()){const t=yield*this.pushSpaces(!0);return yield*this.pushCount(e.length-t),yield*this.pushNewline(),"stream"}return yield Fs,yield*this.parseLineStart()}*parseLineStart(){const e=this.charAt(0);if(!e&&!this.atEnd)return this.setNext("line-start");if(e==="-"||e==="."){if(!this.atEnd&&!this.hasChars(4))return this.setNext("line-start");const t=this.peek(3);if((t==="---"||t==="...")&&R(this.charAt(3)))return yield*this.pushCount(3),this.indentValue=0,this.indentNext=0,t==="---"?"doc":"stream"}return this.indentValue=yield*this.pushSpaces(!1),this.indentNext>this.indentValue&&!R(this.charAt(1))&&(this.indentNext=this.indentValue),yield*this.parseBlockStart()}*parseBlockStart(){const[e,t]=this.peek(2);if(!t&&!this.atEnd)return this.setNext("block-start");if((e==="-"||e==="?"||e===":")&&R(t)){const s=(yield*this.pushCount(1))+(yield*this.pushSpaces(!0));return this.indentNext=this.indentValue+1,this.indentValue+=s,yield*this.parseBlockStart()}return"doc"}*parseDocument(){yield*this.pushSpaces(!0);const e=this.getLine();if(e===null)return this.setNext("doc");let t=yield*this.pushIndicators();switch(e[t]){case"#":yield*this.pushCount(e.length-t);case void 0:return yield*this.pushNewline(),yield*this.parseLineStart();case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel=1,"flow";case"}":case"]":return yield*this.pushCount(1),"doc";case"*":return yield*this.pushUntil(ot),"doc";case'"':case"'":return yield*this.parseQuotedScalar();case"|":case">":return t+=yield*this.parseBlockScalarHeader(),t+=yield*this.pushSpaces(!0),yield*this.pushCount(e.length-t),yield*this.pushNewline(),yield*this.parseBlockScalar();default:return yield*this.parsePlainScalar()}}*parseFlowCollection(){let e,t,s=-1;do e=yield*this.pushNewline(),e>0?(t=yield*this.pushSpaces(!1),this.indentValue=s=t):t=0,t+=yield*this.pushSpaces(!0);while(e+t>0);const i=this.getLine();if(i===null)return this.setNext("flow");if((s!==-1&&s<this.indentNext&&i[0]!=="#"||s===0&&(i.startsWith("---")||i.startsWith("..."))&&R(i[3]))&&!(s===this.indentNext-1&&this.flowLevel===1&&(i[0]==="]"||i[0]==="}")))return this.flowLevel=0,yield Ds,yield*this.parseLineStart();let r=0;for(;i[r]===",";)r+=yield*this.pushCount(1),r+=yield*this.pushSpaces(!0),this.flowKey=!1;switch(r+=yield*this.pushIndicators(),i[r]){case void 0:return"flow";case"#":return yield*this.pushCount(i.length-r),"flow";case"{":case"[":return yield*this.pushCount(1),this.flowKey=!1,this.flowLevel+=1,"flow";case"}":case"]":return yield*this.pushCount(1),this.flowKey=!0,this.flowLevel-=1,this.flowLevel?"flow":"doc";case"*":return yield*this.pushUntil(ot),"flow";case'"':case"'":return this.flowKey=!0,yield*this.parseQuotedScalar();case":":{const o=this.charAt(1);if(this.flowKey||R(o)||o===",")return this.flowKey=!1,yield*this.pushCount(1),yield*this.pushSpaces(!0),"flow"}default:return this.flowKey=!1,yield*this.parsePlainScalar()}}*parseQuotedScalar(){const e=this.charAt(0);let t=this.buffer.indexOf(e,this.pos+1);if(e==="'")for(;t!==-1&&this.buffer[t+1]==="'";)t=this.buffer.indexOf("'",t+2);else for(;t!==-1;){let r=0;for(;this.buffer[t-1-r]==="\\";)r+=1;if(r%2===0)break;t=this.buffer.indexOf('"',t+1)}const s=this.buffer.substring(0,t);let i=s.indexOf(`
|
|
116
|
+
`,this.pos);if(i!==-1){for(;i!==-1;){const r=this.continueScalar(i+1);if(r===-1)break;i=s.indexOf(`
|
|
117
|
+
`,r)}i!==-1&&(t=i-(s[i-1]==="\r"?2:1))}if(t===-1){if(!this.atEnd)return this.setNext("quoted-scalar");t=this.buffer.length}return yield*this.pushToIndex(t+1,!1),this.flowLevel?"flow":"doc"}*parseBlockScalarHeader(){this.blockScalarIndent=-1,this.blockScalarKeep=!1;let e=this.pos;for(;;){const t=this.buffer[++e];if(t==="+")this.blockScalarKeep=!0;else if(t>"0"&&t<="9")this.blockScalarIndent=Number(t)-1;else if(t!=="-")break}return yield*this.pushUntil(t=>R(t)||t==="#")}*parseBlockScalar(){let e=this.pos-1,t=0,s;e:for(let r=this.pos;s=this.buffer[r];++r)switch(s){case" ":t+=1;break;case`
|
|
118
|
+
`:e=r,t=0;break;case"\r":{const o=this.buffer[r+1];if(!o&&!this.atEnd)return this.setNext("block-scalar");if(o===`
|
|
119
|
+
`)break}default:break e}if(!s&&!this.atEnd)return this.setNext("block-scalar");if(t>=this.indentNext){this.blockScalarIndent===-1?this.indentNext=t:this.indentNext=this.blockScalarIndent+(this.indentNext===0?1:this.indentNext);do{const r=this.continueScalar(e+1);if(r===-1)break;e=this.buffer.indexOf(`
|
|
120
|
+
`,r)}while(e!==-1);if(e===-1){if(!this.atEnd)return this.setNext("block-scalar");e=this.buffer.length}}let i=e+1;for(s=this.buffer[i];s===" ";)s=this.buffer[++i];if(s===" "){for(;s===" "||s===" "||s==="\r"||s===`
|
|
121
|
+
`;)s=this.buffer[++i];e=i-1}else if(!this.blockScalarKeep)do{let r=e-1,o=this.buffer[r];o==="\r"&&(o=this.buffer[--r]);const a=r;for(;o===" ";)o=this.buffer[--r];if(o===`
|
|
122
|
+
`&&r>=this.pos&&r+1+t>a)e=r;else break}while(!0);return yield wt,yield*this.pushToIndex(e+1,!0),yield*this.parseLineStart()}*parsePlainScalar(){const e=this.flowLevel>0;let t=this.pos-1,s=this.pos-1,i;for(;i=this.buffer[++s];)if(i===":"){const r=this.buffer[s+1];if(R(r)||e&&Ee.has(r))break;t=s}else if(R(i)){let r=this.buffer[s+1];if(i==="\r"&&(r===`
|
|
123
|
+
`?(s+=1,i=`
|
|
124
|
+
`,r=this.buffer[s+1]):t=s),r==="#"||e&&Ee.has(r))break;if(i===`
|
|
125
|
+
`){const o=this.continueScalar(s+1);if(o===-1)break;s=Math.max(s,o-2)}}else{if(e&&Ee.has(i))break;t=s}return!i&&!this.atEnd?this.setNext("plain-scalar"):(yield wt,yield*this.pushToIndex(t+1,!0),e?"flow":"doc")}*pushCount(e){return e>0?(yield this.buffer.substr(this.pos,e),this.pos+=e,e):0}*pushToIndex(e,t){const s=this.buffer.slice(this.pos,e);return s?(yield s,this.pos+=s.length,s.length):(t&&(yield""),0)}*pushIndicators(){switch(this.charAt(0)){case"!":return(yield*this.pushTag())+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"&":return(yield*this.pushUntil(ot))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators());case"-":case"?":case":":{const e=this.flowLevel>0,t=this.charAt(1);if(R(t)||e&&Ee.has(t))return e?this.flowKey&&(this.flowKey=!1):this.indentNext=this.indentValue+1,(yield*this.pushCount(1))+(yield*this.pushSpaces(!0))+(yield*this.pushIndicators())}}return 0}*pushTag(){if(this.charAt(1)==="<"){let e=this.pos+2,t=this.buffer[e];for(;!R(t)&&t!==">";)t=this.buffer[++e];return yield*this.pushToIndex(t===">"?e+1:e,!1)}else{let e=this.pos+1,t=this.buffer[e];for(;t;)if(Gn.has(t))t=this.buffer[++e];else if(t==="%"&&Gt.has(this.buffer[e+1])&&Gt.has(this.buffer[e+2]))t=this.buffer[e+=3];else break;return yield*this.pushToIndex(e,!1)}}*pushNewline(){const e=this.buffer[this.pos];return e===`
|
|
126
|
+
`?yield*this.pushCount(1):e==="\r"&&this.charAt(1)===`
|
|
127
|
+
`?yield*this.pushCount(2):0}*pushSpaces(e){let t=this.pos-1,s;do s=this.buffer[++t];while(s===" "||e&&s===" ");const i=t-this.pos;return i>0&&(yield this.buffer.substr(this.pos,i),this.pos=t),i}*pushUntil(e){let t=this.pos,s=this.buffer[t];for(;!e(s);)s=this.buffer[++t];return yield*this.pushToIndex(t,!1)}}class Qn{constructor(){this.lineStarts=[],this.addNewLine=e=>this.lineStarts.push(e),this.linePos=e=>{let t=0,s=this.lineStarts.length;for(;t<s;){const r=t+s>>1;this.lineStarts[r]<e?t=r+1:s=r}if(this.lineStarts[t]===e)return{line:t+1,col:1};if(t===0)return{line:0,col:e};const i=this.lineStarts[t-1];return{line:t,col:e-i+1}}}}function H(n,e){for(let t=0;t<n.length;++t)if(n[t].type===e)return!0;return!1}function zt(n){for(let e=0;e<n.length;++e)switch(n[e].type){case"space":case"comment":case"newline":break;default:return e}return-1}function Ks(n){switch(n?.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":case"flow-collection":return!0;default:return!1}}function _e(n){switch(n.type){case"document":return n.start;case"block-map":{const e=n.items[n.items.length-1];return e.sep??e.start}case"block-seq":return n.items[n.items.length-1].start;default:return[]}}function ee(n){if(n.length===0)return[];let e=n.length;e:for(;--e>=0;)switch(n[e].type){case"doc-start":case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":case"newline":break e}for(;n[++e]?.type==="space";);return n.splice(e,n.length)}function Yt(n){if(n.start.type==="flow-seq-start")for(const e of n.items)e.sep&&!e.value&&!H(e.start,"explicit-key-ind")&&!H(e.sep,"map-value-ind")&&(e.key&&(e.value=e.key),delete e.key,Ks(e.value)?e.value.end?Array.prototype.push.apply(e.value.end,e.sep):e.value.end=e.sep:Array.prototype.push.apply(e.start,e.sep),delete e.sep)}class Xn{constructor(e){this.atNewLine=!0,this.atScalar=!1,this.indent=0,this.offset=0,this.onKeyLine=!1,this.stack=[],this.source="",this.type="",this.lexer=new Yn,this.onNewLine=e}*parse(e,t=!1){this.onNewLine&&this.offset===0&&this.onNewLine(0);for(const s of this.lexer.lex(e,t))yield*this.next(s);t||(yield*this.end())}*next(e){if(this.source=e,this.atScalar){this.atScalar=!1,yield*this.step(),this.offset+=e.length;return}const t=Jn(e);if(t)if(t==="scalar")this.atNewLine=!1,this.atScalar=!0,this.type="scalar";else{switch(this.type=t,yield*this.step(),t){case"newline":this.atNewLine=!0,this.indent=0,this.onNewLine&&this.onNewLine(this.offset+e.length);break;case"space":this.atNewLine&&e[0]===" "&&(this.indent+=e.length);break;case"explicit-key-ind":case"map-value-ind":case"seq-item-ind":this.atNewLine&&(this.indent+=e.length);break;case"doc-mode":case"flow-error-end":return;default:this.atNewLine=!1}this.offset+=e.length}else{const s=`Not a YAML token: ${e}`;yield*this.pop({type:"error",offset:this.offset,message:s,source:e}),this.offset+=e.length}}*end(){for(;this.stack.length>0;)yield*this.pop()}get sourceToken(){return{type:this.type,offset:this.offset,indent:this.indent,source:this.source}}*step(){const e=this.peek(1);if(this.type==="doc-end"&&e?.type!=="doc-end"){for(;this.stack.length>0;)yield*this.pop();this.stack.push({type:"doc-end",offset:this.offset,source:this.source});return}if(!e)return yield*this.stream();switch(e.type){case"document":return yield*this.document(e);case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return yield*this.scalar(e);case"block-scalar":return yield*this.blockScalar(e);case"block-map":return yield*this.blockMap(e);case"block-seq":return yield*this.blockSequence(e);case"flow-collection":return yield*this.flowCollection(e);case"doc-end":return yield*this.documentEnd(e)}yield*this.pop()}peek(e){return this.stack[this.stack.length-e]}*pop(e){const t=e??this.stack.pop();if(!t)yield{type:"error",offset:this.offset,source:"",message:"Tried to pop an empty stack"};else if(this.stack.length===0)yield t;else{const s=this.peek(1);switch(t.type==="block-scalar"?t.indent="indent"in s?s.indent:0:t.type==="flow-collection"&&s.type==="document"&&(t.indent=0),t.type==="flow-collection"&&Yt(t),s.type){case"document":s.value=t;break;case"block-scalar":s.props.push(t);break;case"block-map":{const i=s.items[s.items.length-1];if(i.value){s.items.push({start:[],key:t,sep:[]}),this.onKeyLine=!0;return}else if(i.sep)i.value=t;else{Object.assign(i,{key:t,sep:[]}),this.onKeyLine=!i.explicitKey;return}break}case"block-seq":{const i=s.items[s.items.length-1];i.value?s.items.push({start:[],value:t}):i.value=t;break}case"flow-collection":{const i=s.items[s.items.length-1];!i||i.value?s.items.push({start:[],key:t,sep:[]}):i.sep?i.value=t:Object.assign(i,{key:t,sep:[]});return}default:yield*this.pop(),yield*this.pop(t)}if((s.type==="document"||s.type==="block-map"||s.type==="block-seq")&&(t.type==="block-map"||t.type==="block-seq")){const i=t.items[t.items.length-1];i&&!i.sep&&!i.value&&i.start.length>0&&zt(i.start)===-1&&(t.indent===0||i.start.every(r=>r.type!=="comment"||r.indent<t.indent))&&(s.type==="document"?s.end=i.start:s.items.push({start:i.start}),t.items.splice(-1,1))}}}*stream(){switch(this.type){case"directive-line":yield{type:"directive",offset:this.offset,source:this.source};return;case"byte-order-mark":case"space":case"comment":case"newline":yield this.sourceToken;return;case"doc-mode":case"doc-start":{const e={type:"document",offset:this.offset,start:[]};this.type==="doc-start"&&e.start.push(this.sourceToken),this.stack.push(e);return}}yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML stream`,source:this.source}}*document(e){if(e.value)return yield*this.lineEnd(e);switch(this.type){case"doc-start":{zt(e.start)!==-1?(yield*this.pop(),yield*this.step()):e.start.push(this.sourceToken);return}case"anchor":case"tag":case"space":case"comment":case"newline":e.start.push(this.sourceToken);return}const t=this.startBlockValue(e);t?this.stack.push(t):yield{type:"error",offset:this.offset,message:`Unexpected ${this.type} token in YAML document`,source:this.source}}*scalar(e){if(this.type==="map-value-ind"){const t=_e(this.peek(2)),s=ee(t);let i;e.end?(i=e.end,i.push(this.sourceToken),delete e.end):i=[this.sourceToken];const r={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:s,key:e,sep:i}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=r}else yield*this.lineEnd(e)}*blockScalar(e){switch(this.type){case"space":case"comment":case"newline":e.props.push(this.sourceToken);return;case"scalar":if(e.source=this.source,this.atNewLine=!0,this.indent=0,this.onNewLine){let t=this.source.indexOf(`
|
|
128
|
+
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
129
|
+
`,t)+1}yield*this.pop();break;default:yield*this.pop(),yield*this.step()}}*blockMap(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(this.onKeyLine=!1,t.value){const s="end"in t.value?t.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else if(t.sep)t.sep.push(this.sourceToken);else{if(this.atIndentedComment(t.start,e.indent)){const i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return}if(this.indent>=e.indent){const s=!this.onKeyLine&&this.indent===e.indent,i=s&&(t.sep||t.explicitKey)&&this.type!=="seq-item-ind";let r=[];if(i&&t.sep&&!t.value){const o=[];for(let a=0;a<t.sep.length;++a){const l=t.sep[a];switch(l.type){case"newline":o.push(a);break;case"space":break;case"comment":l.indent>e.indent&&(o.length=0);break;default:o.length=0}}o.length>=2&&(r=t.sep.splice(o[1]))}switch(this.type){case"anchor":case"tag":i||t.value?(r.push(this.sourceToken),e.items.push({start:r}),this.onKeyLine=!0):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"explicit-key-ind":!t.sep&&!t.explicitKey?(t.start.push(this.sourceToken),t.explicitKey=!0):i||t.value?(r.push(this.sourceToken),e.items.push({start:r,explicitKey:!0})):this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken],explicitKey:!0}]}),this.onKeyLine=!0;return;case"map-value-ind":if(t.explicitKey)if(t.sep)if(t.value)e.items.push({start:[],key:null,sep:[this.sourceToken]});else if(H(t.sep,"map-value-ind"))this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:r,key:null,sep:[this.sourceToken]}]});else if(Ks(t.key)&&!H(t.sep,"newline")){const o=ee(t.start),a=t.key,l=t.sep;l.push(this.sourceToken),delete t.key,delete t.sep,this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:a,sep:l}]})}else r.length>0?t.sep=t.sep.concat(r,this.sourceToken):t.sep.push(this.sourceToken);else if(H(t.start,"newline"))Object.assign(t,{key:null,sep:[this.sourceToken]});else{const o=ee(t.start);this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:o,key:null,sep:[this.sourceToken]}]})}else t.sep?t.value||i?e.items.push({start:r,key:null,sep:[this.sourceToken]}):H(t.sep,"map-value-ind")?this.stack.push({type:"block-map",offset:this.offset,indent:this.indent,items:[{start:[],key:null,sep:[this.sourceToken]}]}):t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});this.onKeyLine=!0;return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const o=this.flowScalar(this.type);i||t.value?(e.items.push({start:r,key:o,sep:[]}),this.onKeyLine=!0):t.sep?this.stack.push(o):(Object.assign(t,{key:o,sep:[]}),this.onKeyLine=!0);return}default:{const o=this.startBlockValue(e);if(o){if(o.type==="block-seq"){if(!t.explicitKey&&t.sep&&!H(t.sep,"newline")){yield*this.pop({type:"error",offset:this.offset,message:"Unexpected block-seq-ind on same line with key",source:this.source});return}}else s&&e.items.push({start:r});this.stack.push(o);return}}}}yield*this.pop(),yield*this.step()}*blockSequence(e){const t=e.items[e.items.length-1];switch(this.type){case"newline":if(t.value){const s="end"in t.value?t.value.end:void 0;(Array.isArray(s)?s[s.length-1]:void 0)?.type==="comment"?s?.push(this.sourceToken):e.items.push({start:[this.sourceToken]})}else t.start.push(this.sourceToken);return;case"space":case"comment":if(t.value)e.items.push({start:[this.sourceToken]});else{if(this.atIndentedComment(t.start,e.indent)){const i=e.items[e.items.length-2]?.value?.end;if(Array.isArray(i)){Array.prototype.push.apply(i,t.start),i.push(this.sourceToken),e.items.pop();return}}t.start.push(this.sourceToken)}return;case"anchor":case"tag":if(t.value||this.indent<=e.indent)break;t.start.push(this.sourceToken);return;case"seq-item-ind":if(this.indent!==e.indent)break;t.value||H(t.start,"seq-item-ind")?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return}if(this.indent>e.indent){const s=this.startBlockValue(e);if(s){this.stack.push(s);return}}yield*this.pop(),yield*this.step()}*flowCollection(e){const t=e.items[e.items.length-1];if(this.type==="flow-error-end"){let s;do yield*this.pop(),s=this.peek(1);while(s?.type==="flow-collection")}else if(e.end.length===0){switch(this.type){case"comma":case"explicit-key-ind":!t||t.sep?e.items.push({start:[this.sourceToken]}):t.start.push(this.sourceToken);return;case"map-value-ind":!t||t.value?e.items.push({start:[],key:null,sep:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):Object.assign(t,{key:null,sep:[this.sourceToken]});return;case"space":case"comment":case"newline":case"anchor":case"tag":!t||t.value?e.items.push({start:[this.sourceToken]}):t.sep?t.sep.push(this.sourceToken):t.start.push(this.sourceToken);return;case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":{const i=this.flowScalar(this.type);!t||t.value?e.items.push({start:[],key:i,sep:[]}):t.sep?this.stack.push(i):Object.assign(t,{key:i,sep:[]});return}case"flow-map-end":case"flow-seq-end":e.end.push(this.sourceToken);return}const s=this.startBlockValue(e);s?this.stack.push(s):(yield*this.pop(),yield*this.step())}else{const s=this.peek(2);if(s.type==="block-map"&&(this.type==="map-value-ind"&&s.indent===e.indent||this.type==="newline"&&!s.items[s.items.length-1].sep))yield*this.pop(),yield*this.step();else if(this.type==="map-value-ind"&&s.type!=="flow-collection"){const i=_e(s),r=ee(i);Yt(e);const o=e.end.splice(1,e.end.length);o.push(this.sourceToken);const a={type:"block-map",offset:e.offset,indent:e.indent,items:[{start:r,key:e,sep:o}]};this.onKeyLine=!0,this.stack[this.stack.length-1]=a}else yield*this.lineEnd(e)}}flowScalar(e){if(this.onNewLine){let t=this.source.indexOf(`
|
|
130
|
+
`)+1;for(;t!==0;)this.onNewLine(this.offset+t),t=this.source.indexOf(`
|
|
131
|
+
`,t)+1}return{type:e,offset:this.offset,indent:this.indent,source:this.source}}startBlockValue(e){switch(this.type){case"alias":case"scalar":case"single-quoted-scalar":case"double-quoted-scalar":return this.flowScalar(this.type);case"block-scalar-header":return{type:"block-scalar",offset:this.offset,indent:this.indent,props:[this.sourceToken],source:""};case"flow-map-start":case"flow-seq-start":return{type:"flow-collection",offset:this.offset,indent:this.indent,start:this.sourceToken,items:[],end:[]};case"seq-item-ind":return{type:"block-seq",offset:this.offset,indent:this.indent,items:[{start:[this.sourceToken]}]};case"explicit-key-ind":{this.onKeyLine=!0;const t=_e(e),s=ee(t);return s.push(this.sourceToken),{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,explicitKey:!0}]}}case"map-value-ind":{this.onKeyLine=!0;const t=_e(e),s=ee(t);return{type:"block-map",offset:this.offset,indent:this.indent,items:[{start:s,key:null,sep:[this.sourceToken]}]}}}return null}atIndentedComment(e,t){return this.type!=="comment"||this.indent<=t?!1:e.every(s=>s.type==="newline"||s.type==="space")}*documentEnd(e){this.type!=="doc-mode"&&(e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop()))}*lineEnd(e){switch(this.type){case"comma":case"doc-start":case"doc-end":case"flow-seq-end":case"flow-map-end":case"map-value-ind":yield*this.pop(),yield*this.step();break;case"newline":this.onKeyLine=!1;default:e.end?e.end.push(this.sourceToken):e.end=[this.sourceToken],this.type==="newline"&&(yield*this.pop())}}}function Zn(n){const e=n.prettyErrors!==!1;return{lineCounter:n.lineCounter||e&&new Qn||null,prettyErrors:e}}function ei(n,e={}){const{lineCounter:t,prettyErrors:s}=Zn(e),i=new Xn(t?.addNewLine),r=new Wn(e);let o=null;for(const a of r.compose(i.parse(n),!0,n.length))if(!o)o=a;else if(o.options.logLevel!=="silent"){o.errors.push(new ge(a.range.slice(0,2),"MULTIPLE_DOCS","Source contains multiple documents; please use YAML.parseAllDocuments()"));break}return s&&t&&(o.errors.forEach(Ht(n,t)),o.warnings.forEach(Ht(n,t))),o}function ti(n,e,t){let s;const i=ei(n,t);if(!i)return null;if(i.warnings.forEach(r=>ps(i.options.logLevel,r)),i.errors.length>0){if(i.options.logLevel!=="silent")throw i.errors[0];i.errors=[]}return i.toJS(Object.assign({reviver:s},t))}function si(n,e){const{language:t,tag:s,data:i}=e||{};if(!s)return n;if(i!==void 0)return i;const r=(t||"").toLowerCase();if(r==="json")try{return JSON.parse(n)}catch{return n}if(r==="yaml"||r==="yml")try{return ti(n)}catch{return n}return n}function ve(n){return n.type==="UniwebIcon"||n.type==="image"&&n.attrs?.role==="icon"}function kt(n,e={}){const t=[];return ni(n,t,e),t}function ni(n,e,t){n.content&&Array.isArray(n.content)&&n.content?.forEach(s=>{const i=ii(s,t);i&&(Array.isArray(i)?e.push(...i):e.push(i))})}function ii(n,e={}){const t=n.attrs,s=n.content,i=hi(n);if(i)return{type:"link",attrs:i};const r=di(n);if(r)return r;const o=pi(n);if(o)return o;switch(n.type){case"heading":return{type:"heading",level:n.attrs.level,text:te(s,e),children:we(s),attrs:t};case"paragraph":return{type:"paragraph",text:te(s,e),children:we(s),attrs:t};case"blockquote":return{type:"blockquote",children:kt({content:s}),attrs:t};case"dataBlock":return{type:"dataBlock",data:t.data,tag:t.tag};case"codeBlock":const a=te(s,e);return{type:"codeBlock",text:si(a,t),attrs:t};case"inset_placeholder":return{type:"inset",refId:t.refId};case"ImageBlock":return{type:"image",attrs:ci(t)};case"image":return{type:"image",attrs:t||{}};case"Video":return{type:"video",attrs:fi(t)};case"bulletList":case"orderedList":{const c=s.map(f=>f.type==="listItem"&&f.content?f.content:null).filter(Boolean);return{type:"list",style:n.type==="bulletList"?"bullet":"ordered",children:c.map(f=>kt({content:f})),attrs:t}}case"DividerBlock":case"horizontalRule":return{type:"divider"};case"card-group":return{type:"card-group",cards:n.content?.filter(c=>c.type==="card"&&!c.attrs?.hidden).map(c=>oi(c.attrs))||[]};case"document-group":return{type:"document-group",documents:n.content?.filter(c=>c.type==="document").map(c=>ai(c.attrs))||[]};case"FormBlock":let l=t?.data;if(typeof l=="string")try{l=JSON.parse(l)}catch{}return{type:"form",data:l,attrs:t};case"button":{let c=te(s,e);return c?{type:"button",text:c,children:we(s),attrs:t}:null}case"UniwebIcon":return{type:"icon",attrs:Ze(t)};case"Icon":return{type:"icon",attrs:li(t)};default:return{type:n.type,content:te(s,e)}}}function te(n,e={}){return n?n.reduce((t,s)=>{const{type:i,marks:r=[],text:o}=s;if(i==="text"){let a=o||"";if(r.some(l=>l.type==="textStyle")){const l=r.find(c=>c.type==="textStyle")?.attrs?.color;l&&(a=`<span style="color: var(--${l})">${a}</span>`)}if(r.some(l=>l.type==="highlight")&&(a=`<span style="background-color: var(--highlight)">${a}</span>`),r.some(l=>l.type==="span")){const c=r.find(p=>p.type==="span")?.attrs||{},f=[],u=[];c.class&&f.push(`class="${c.class}"`),c.id&&f.push(`id="${c.id}"`);for(const[p,m]of Object.entries(c))p==="class"||p==="id"||(p==="color"?u.push(`color: ${m}`):p==="bg"?u.push(`background: ${m}`):f.push(`${p}="${m}"`));u.length>0&&f.push(`style="${u.join("; ")}"`),a=`<span${f.length>0?` ${f.join(" ")}`:""}>${a}</span>`}if(r.some(l=>l.type==="bold")&&(a=`<strong>${a}</strong>`),r.some(l=>l.type==="italic")&&(a=`<em>${a}</em>`),r.some(l=>l.type==="link")){const l=r.find(m=>m.type==="link"),c=l.attrs.href,f=l.attrs.target||"_self",u=["pdf","doc","docx","xls","xlsx","ppt","pptx","jpg","jpeg","png","webp","gif","svg","mp4","mp3","wav","mov","zip"],h=c.split(".").pop()?.toLowerCase(),p=u.includes(h);a=`<a href="${c}" target="${f}"${p?" download":""}>${a}</a>`}return t+a}else return i==="hardBreak"?t+"<br>":t},"").trim():""}function we(n){if(!n)return[];const e=[];for(const t of n)if(ve(t))e.push({type:"icon",attrs:Ze(t.attrs)});else if(t.type==="math-inline")e.push(t);else if(t.type==="text"&&t.marks){const s=t.marks.find(i=>i.type==="link");s&&e.push({type:"link",attrs:{...s.attrs,label:t.text||""}})}return e}const ri="https://assets.uniweb.app/";function Us(n){if(!n||typeof n!="string")return"";const[e,t]=n.split("/");if(!t)return"";const s=t.substring(t.lastIndexOf(".")+1);return`${ri}dist/${e}/base.${s}`}function Ie(n){const e=n?.src||n?.url||"";return e||(n?.identifier?Us(n.identifier):"")}function oi(n){const{address:e,...t}=n;let s=null;try{e&&(s=JSON.parse(e))}catch{}const{coverImg:i=null,icon:r}=t;return r&&(t.icon=Ze(r)),{...t,address:s,coverImg:Ie(i)}}function ai(n){const{src:e,info:t={},coverImg:s=null,...i}=n;let r={...i,coverImg:Ie(s)};if(e)r.href=e;else{const{identifier:o=""}=t;o&&(r.downloadUrl=Us(o))}return r}function Ze(n){const{svg:e,url:t,size:s,color:i,preserveColors:r,href:o,target:a,library:l,name:c}=n||{},f={};return e&&(f.svg=e),t&&(f.url=t),s&&(f.size=s),i&&(f.color=i),r&&(f.preserveColors=r),o&&(f.href=o),a&&(f.target=a),l&&(f.library=l),c&&(f.name=c),f}function li(n){let{svg:e}=n;return e}function ci(n){let{info:e,targetId:t,caption:s="",direction:i,filter:r,alt:o="",url:a,href:l="",target:c="",theme:f,role:u,credit:h=""}=n,{contentType:p,viewType:m,contentId:d,identifier:g}=e||{};const b={center:"basic",wide:"lg",fill:"full"};return s=ui(s),g&&(a=Ie(e)),{contentType:p,viewType:m,contentId:t||d,url:a,value:g||"",alt:o||s,caption:s,direction:i,filter:r,imgPos:i==="left"||i==="right"?i:"",size:b[i]||"basic",href:l,target:c,theme:f,role:u,credit:h}}function fi(n){let{src:e,caption:t="",direction:s,info:i={},coverImg:r={},alt:o,href:a="",target:l=""}=n;return{src:Ie({src:e,...i}),caption:t,direction:s,coverImg:Ie(r),alt:o,href:a,target:l}}function ui(n){if(!n||typeof n!="string")return"";const e=n.replace(/<[^>]*>/g,"");return new DOMParser().parseFromString(e,"text/html").body.textContent}function hi(n){if(["paragraph","heading"].includes(n.type)){const e=n?.content||[],t=e.filter(s=>ve(s)?!1:s.type==="text"?(s.text||"").trim()!=="":!0);if(t.length===1){let s=t[0],i=s?.marks||[];for(let r=0;r<i.length;r++){let o=i[r];if(o?.type==="link"){const a=e.findIndex(f=>f.type==="text"&&f.text===s.text);let l=null,c=null;for(let f=0;f<e.length;f++)if(ve(e[f])){const u=Ze(e[f].attrs);f<a?l=u:f>a&&(c||(c=u))}return{...o?.attrs,label:s?.text||"",iconBefore:l,iconAfter:c,children:we(e)}}}}}return!1}function di(n){if(n.type!=="paragraph")return!1;const e=n?.content||[];if(!e.length)return!1;const t=e.filter(i=>!(ve(i)||i.type==="text"&&!(i.text||"").trim()));return t.length<2||!t.every(i=>i.type!=="text"?!1:i.marks?.some(o=>o.type==="link"))?!1:t.map(i=>({type:"link",attrs:{...i.marks.find(o=>o.type==="link")?.attrs,label:i.text||""}}))}function pi(n){if(!["paragraph","heading"].includes(n.type))return!1;let e=n?.content||[];if(!e.length)return!1;e=e.filter(a=>!ve(a));let t=e[0]?.marks?.find(a=>a.type==="link"&&a.attrs);if(!t||!e.every(a=>a?.marks?.some(l=>l.type==="link"&&l.attrs?.href===t.attrs?.href)||!1))return!1;const{href:s,target:i}=t.attrs,r=e.map(a=>{const l=a.marks?.filter(c=>c.type!=="link")||[];return{...a,marks:l}});let o=te(r);return o?{type:"paragraph",children:we(n.content),text:`<a target="${i}" href="${s}">${o}</a>`,attrs:n.attrs}:!1}function Qt(n){return n?{title:n.header.title||"",pretitle:n.header.pretitle||"",subtitle:n.header.subtitle||"",paragraphs:n.body.paragraphs||[],links:n.body.links||[],images:n.body.images||[],icons:n.body.icons||[],lists:n.body.lists||[],videos:n.body.videos||[],insets:n.body.insets||[],snippets:n.body.snippets||[],data:n.body.data||{},quotes:n.body.quotes||[],headings:n.body.headings||[]}:null}function gi(n,e={}){if(!n.length)return{title:"",pretitle:"",subtitle:"",paragraphs:[],links:[],images:[],icons:[],lists:[],videos:[],insets:[],snippets:[],data:{},quotes:[],headings:[],items:[]};const s=mi(n).map(c=>St(c));let i=null,r=[];ki(s)?(i=s[0],r=s.slice(1)):r=s;const a=Qt(i)||{title:"",pretitle:"",subtitle:"",paragraphs:[],links:[],images:[],icons:[],lists:[],videos:[],insets:[],data:{},quotes:[],headings:[]},l=r.map(Qt);return{...a,items:l}}function mi(n){const e=[];let t=[];for(let s=0;s<n.length;s++){const i=n[s];if(i.type==="divider"){t.length>0&&(e.push(t),t=[]);continue}if(i.type==="heading"){const r=s===1&&bi(n,0);t.length>0&&!r&&(e.push(t),t=[]);const o=wi(n,s);t.push(...o),s+=o.length-1}else t.push(i)}return t.length>0&&e.push(t),e}function yi(n,e){return e+1<n.length&&n[e].type==="heading"&&n[e+1].type==="heading"&&n[e].level>n[e+1].level}function bi(n,e){return e+1<n.length&&n[e].type==="image"&&(n[e].role==="banner"||n[e+1].type==="heading")}function wi(n,e){const t=[n[e]];let s=!1;for(let i=e+1;i<n.length;i++){const r=n[i],o=t[t.length-1];if(r.type!=="heading")break;if(r.level>o.level){s=!0,t.push(r);continue}if(t.length===1&&r.level<o.level){t.push(r);continue}if(r.level===o.level&&!s){t.push(r);continue}break}return t}function St(n){const e={pretitle:"",title:"",subtitle:""},t={images:[],icons:[],videos:[],insets:[],snippets:[],paragraphs:[],links:[],lists:[],data:{},quotes:[],headings:[]},s={level:null,contentTypes:new Set};if(!n)return{header:e,body:t,metadata:s};let i=null,r=null;for(let o=0;o<n.length;o++){yi(n,o)&&!e.pretitle&&(e.pretitle=n[o].text,o++);const a=n[o];if(a.type==="heading"){if(a.children&&Array.isArray(a.children)&&at(a.children,t),s.level??=a.level,r!==null&&a.level===r&&i){const l=e[i];Array.isArray(l)?l.push(a.text):e[i]=[l,a.text]}else e.title?e.subtitle?(t.headings.push(a.text),i=null):(e.subtitle=a.text,i="subtitle"):(e.title=a.text,i="title");r=a.level}else if(a.type==="list"){const l=a.children;t.lists.push(l.map(c=>St(c).body))}else{let l={...a.attrs};switch(a.type){case"paragraph":a.children&&Array.isArray(a.children)&&at(a.children,t),a.text&&t.paragraphs.push(a.text);break;case"image":a.attrs?.role==="icon"?t.icons.push(a.attrs):t.images.push(l);break;case"video":t.videos.push(l);break;case"link":a.children&&Array.isArray(a.children)&&at(a.children,t),t.links.push(l);break;case"icon":t.icons.push(a.attrs);break;case"button":t.links.push({href:a.attrs?.href||"",label:a.text||"",role:a.attrs?.variant?`button-${a.attrs.variant}`:"button",variant:a.attrs?.variant||"primary",size:a.attrs?.size,icon:a.attrs?.icon,target:a.attrs?.target,class:a.attrs?.class});break;case"blockquote":const c=St(a.children);t.quotes.push(c.body);break;case"dataBlock":t.data[a.tag]=a.data;break;case"codeBlock":const f=a.attrs?.tag;f?t.data[f]=a.text:t.snippets.push({language:a.attrs?.language||"",code:typeof a.text=="string"?a.text:""});break;case"inset":t.insets.push({refId:a.refId});break;case"form":t.data.form=a.data||a.attrs;break;case"card-group":(a.cards||[]).forEach(u=>{const h=u.cardType||"card";t.data[h]||(t.data[h]=[]);const{cardType:p,...m}=u;t.data[h].push(m)});break;case"document-group":a.documents.forEach(u=>{t.links.push({href:u.href||u.downloadUrl||"",label:u.title||"",role:"document",download:!0,preview:u.coverImg,fileType:u.fileType})});break}}}return{header:e,body:t,metadata:s}}function ki(n){if(n.length===0)return!1;if(n.length===1)return!0;const e=n[0].metadata.level,t=n[1].metadata.level;return!!(e&&(!t||e<t)||!e&&t)}function at(n,e){n.forEach(t=>{t.type==="icon"?e.icons.push(t.attrs):t.type==="link"&&e.links.push(t.attrs)})}function Si(n,e={}){const t={...e},s=kt(n,t),i=gi(s,t);return{raw:n,sequence:s,...i}}const De=[50,100,200,300,400,500,600,700,800,900,950],M={50:.97,100:.93,200:.87,300:.78,400:.68,500:.55,600:.48,700:.4,800:.32,900:.24,950:.14},vi={50:.15,100:.25,200:.4,300:.65,400:.85,500:1,600:.95,700:.85,800:.75,900:.6,950:.45},Ii=M[50]-M[500],Ni=M[500]-M[950],Ke={};for(const n of De)n<500?Ke[n]=(M[n]-M[500])/Ii:n>500&&(Ke[n]=(M[500]-M[n])/Ni);const Xt={fixed:{hueShift:{light:0,dark:0},chromaBoost:1,lightEndChroma:.15,darkEndChroma:.45},natural:{hueShift:{light:5,dark:-15},chromaBoost:1.1,lightEndChroma:.2,darkEndChroma:.4},vivid:{hueShift:{light:3,dark:-10},chromaBoost:1.4,lightEndChroma:.35,darkEndChroma:.55}};function Li(n){if(!n||typeof n!="string")throw new Error(`Invalid color: ${n}`);const e=n.trim().toLowerCase();if(e.startsWith("oklch("))return Oi(e);if(e.startsWith("#"))return Zt(e);if(e.startsWith("rgb"))return Ci(e);if(e.startsWith("hsl"))return Ti(e);if(/^[0-9a-f]{3,8}$/i.test(e))return Zt("#"+e);throw new Error(`Unsupported color format: ${n}`)}function Oi(n){const e=n.match(/oklch\(\s*([0-9.]+)(%?)\s+([0-9.]+)\s+([0-9.]+)(deg)?\s*\)/);if(!e)throw new Error(`Invalid oklch format: ${n}`);let t=parseFloat(e[1]);e[2]==="%"&&(t/=100);const s=parseFloat(e[3]),i=parseFloat(e[4]);return{l:t,c:s,h:i}}function Zt(n){const e=Ai(n);return jt(e.r,e.g,e.b)}function Ai(n){let e=n.replace("#","");e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),e.length===4&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]+e[3]+e[3]);const t=parseInt(e.slice(0,6),16);return{r:t>>16&255,g:t>>8&255,b:t&255}}function Ci(n){const e=n.match(/rgba?\(\s*([0-9.]+)[\s,]+([0-9.]+)[\s,]+([0-9.]+)/);if(!e)throw new Error(`Invalid rgb format: ${n}`);const t=parseFloat(e[1]),s=parseFloat(e[2]),i=parseFloat(e[3]);return jt(t,s,i)}function Ti(n){const e=n.match(/hsla?\(\s*([0-9.]+)(deg)?[\s,]+([0-9.]+)%[\s,]+([0-9.]+)%/);if(!e)throw new Error(`Invalid hsl format: ${n}`);const t=parseFloat(e[1]),s=parseFloat(e[3])/100,i=parseFloat(e[4])/100,r=$i(t,s,i);return jt(r.r*255,r.g*255,r.b*255)}function $i(n,e,t){const s=n/360;let i,r,o;if(e===0)i=r=o=t;else{const a=t<.5?t*(1+e):t+e-t*e,l=2*t-a;i=lt(l,a,s+1/3),r=lt(l,a,s),o=lt(l,a,s-1/3)}return{r:i,g:r,b:o}}function lt(n,e,t){return t<0&&(t+=1),t>1&&(t-=1),t<1/6?n+(e-n)*6*t:t<1/2?e:t<2/3?n+(e-n)*(2/3-t)*6:n}function jt(n,e,t){n/=255,e/=255,t/=255,n=ct(n),e=ct(e),t=ct(t);const s=.4122214708*n+.5363325363*e+.0514459929*t,i=.2119034982*n+.6806995451*e+.1073969566*t,r=.0883024619*n+.2817188376*e+.6299787005*t,o=Math.cbrt(s),a=Math.cbrt(i),l=Math.cbrt(r),c=.2104542553*o+.793617785*a-.0040720468*l,f=1.9779984951*o-2.428592205*a+.4505937099*l,u=.0259040371*o+.7827717662*a-.808675766*l,h=Math.sqrt(f*f+u*u);let p=Math.atan2(u,f)*(180/Math.PI);return p<0&&(p+=360),{l:c,c:h,h:p}}function ct(n){return n<=.04045?n/12.92:Math.pow((n+.055)/1.055,2.4)}function ft(n){return n<=.0031308?12.92*n:1.055*Math.pow(n,1/2.4)-.055}function et(n,e,t){const s=t*(Math.PI/180),i=e*Math.cos(s),r=e*Math.sin(s),o=n+.3963377774*i+.2158037573*r,a=n-.1055613458*i-.0638541728*r,l=n-.0894841775*i-1.291485548*r,c=o*o*o,f=a*a*a,u=l*l*l;let h=4.0767416621*c-3.3077115913*f+.2309699292*u,p=-1.2684380046*c+2.6097574011*f-.3413193965*u,m=-.0041960863*c-.7034186147*f+1.707614701*u;return h=Math.round(Math.max(0,Math.min(1,ft(h)))*255),p=Math.round(Math.max(0,Math.min(1,ft(p)))*255),m=Math.round(Math.max(0,Math.min(1,ft(m)))*255),{r:h,g:p,b:m}}function Ei(n,e,t){return n>=-.5&&n<=255.5&&e>=-.5&&e<=255.5&&t>=-.5&&t<=255.5}function qs(n,e,t){let s=0,i=t,r=0;for(let o=0;o<8;o++){const a=(s+i)/2,l=et(n,a,e);Ei(l.r,l.g,l.b)?(r=a,s=a):i=a}return r}function es(n,e,t,s){const i=1-s;return i*i*n+2*i*s*e+s*s*t}function Be(n,e,t){return n+(e-n)*t}function ut(n){return n=n%360,n<0?n+360:n}function _i(n){return n>=0&&n<120||n>300}function Ue(n,e,t){const s=(n*100).toFixed(1),i=e.toFixed(4),r=t.toFixed(1);return`oklch(${s}% ${i} ${r})`}function Rt(n,e,t){const s=i=>i.toString(16).padStart(2,"0");return`#${s(n)}${s(e)}${s(t)}`}function ts(n,e={}){const{format:t="oklch",mode:s="fixed",exactMatch:i}=e,r=Li(n),o=Xt[s]||Xt.fixed;return s==="fixed"?Bi(r,n,t,i):Mi(r,n,t,o,i)}function Bi(n,e,t,s){const i={},r=s!==!1;for(const o of De){if(r&&o===500){t==="hex"?i[o]=e.startsWith("#")?e:Vs(n):i[o]=Ue(n.l,n.c,n.h);continue}let a;r?o<500?a=n.l+Ke[o]*(M[50]-n.l):a=n.l-Ke[o]*(n.l-M[950]):a=M[o];const l=vi[o],c=n.c*l,f=qs(a,n.h,c);if(t==="hex"){const u=et(a,f,n.h);i[o]=Rt(u.r,u.g,u.b)}else i[o]=Ue(a,f,n.h)}return i}function Mi(n,e,t,s,i){const r={},o=_i(n.h),a=o?s.hueShift.light:-s.hueShift.light,l=o?s.hueShift.dark:-s.hueShift.dark,c={l:M[50],c:n.c*s.lightEndChroma,h:ut(n.h+a)},f={l:M[950],c:n.c*s.darkEndChroma,h:ut(n.h+l)},u=n.c*s.chromaBoost;for(let h=0;h<De.length;h++){const p=De[h];if(i!==!1&&p===500){t==="hex"?r[p]=e.startsWith("#")?e:Vs(n):r[p]=Ue(n.l,n.c,n.h);continue}let m,d,g;if(h<=5){const y=h/5;m=Be(c.l,n.l,y),g=Be(c.h,n.h,y);const k=(c.c+u)/2;d=es(c.c,k,u,y)}else{const y=(h-5)/5;m=Be(n.l,f.l,y),g=Be(n.h,f.h,y);const k=(u+f.c)/2;d=es(u,k,f.c,y)}g=ut(g);const b=qs(m,g,d);if(t==="hex"){const y=et(m,b,g);r[p]=Rt(y.r,y.g,y.b)}else r[p]=Ue(m,b,g)}return r}function Vs(n){const e=et(n.l,n.c,n.h);return Rt(e.r,e.g,e.b)}function Ui(n,e={}){const t={};for(const[s,i]of Object.entries(n)){if(typeof i=="object"&&i!==null&&!i.base&&Object.keys(i).some(o=>!isNaN(parseInt(o)))){t[s]=i;continue}if(typeof i=="object"&&i!==null&&i.base){const{base:r,...o}=i;t[s]=ts(r,{...e,...o})}else typeof i=="string"&&(t[s]=ts(i,e))}return t}const ss=new Set([50,100,200,300,400,500,600,700,800,900,950]),ns=/^([a-z][a-z0-9]*)-(\d+)$/,Pi=/^([a-z][a-z0-9]*-\d+)\/(\d+)$/,xi=/^rgba\(\s*(var\(--[^)]+\))\s*\/\s*([\d.]+)\s*\)$/;function is(n){if(typeof n!="string")return n;const e=n.match(xi);if(e){const r=e[1],o=parseFloat(e[2]);return o>=.999?r:`color-mix(in srgb, ${r} ${Math.round(o*100)}%, transparent)`}if(n.includes("(")||n.startsWith("#"))return n;const t=n.replace(/^-{0,2}/,""),s=t.match(Pi);if(s){const r=s[1],o=parseInt(s[2],10),a=r.match(ns);if(a&&ss.has(parseInt(a[2],10)))return o>=100?`var(--${r})`:`color-mix(in srgb, var(--${r}) ${o}%, transparent)`}const i=t.match(ns);if(i){const r=parseInt(i[2],10);if(ss.has(r))return`var(--${t})`}return n}class K{constructor(e,t,s){this.id=t,this.stableId=e.stableId||null,this.page=s,this.website=s.website,this.type=e.type||this.website.getDefaultBlockType(),this.Component=null,this.rawContent=e.content||{},this.parsedContent=this.parseContent(e.content),e.parsedContent?.data&&(this.parsedContent.data={...this.parsedContent.data||{},...e.parsedContent.data}),this.items=this.parsedContent.items||[];const i=e.params||e.config||{};this.preset=e.preset;const r=i.theme;if(r&&typeof r=="object"){const{mode:l,...c}=r;if(this.themeName=l||"",Object.keys(c).length>0){for(const f of Object.keys(c))c[f]=is(c[f]);this.contextOverrides=c}else this.contextOverrides=null}else this.themeName=r??"",this.contextOverrides=null;this.standardOptions=i.standardOptions||{},this.properties=i.properties||i,this.properties.theme&&typeof this.properties.theme=="object"&&(this.properties={...this.properties,theme:this.themeName});const o=i.background;o&&!this.standardOptions.background&&(this.standardOptions={...this.standardOptions,background:K.normalizeBackground(o)}),this.childBlocks=e.subsections?e.subsections.map((l,c)=>new K(l,`${t}_${c}`,this.page)):[],this.insets=[];const a=e.insets;if(a?.length>0)for(let l=0;l<a.length;l++){const c=a[l],f=c.title||"",u=new K({type:c.type,params:c.params||{},content:{title:f},stableId:c.refId,refId:c.refId},`${t}_inset_${l}`,this.page);this.insets.push(u)}this.fetch=e.fetch||null,this.dataLoading=!1,this.hasBackground=!1,this.refId=e.refId||null,this.dynamicContext=e.dynamicContext||null,this.startState=null,this.state=null,this.resetStateHook=null,this.context=null,this.componentVars=null,Object.seal(this)}parseContent(e){return e?.groups?e.groups:e?.type==="doc"?this.extractFromProseMirror(e):e?.doc?.type==="doc"?this.extractFromProseMirror(e.doc):e&&typeof e=="object"&&!Array.isArray(e)?e:{title:"",paragraphs:[],items:[],sequence:[]}}extractFromProseMirror(e){try{return Si(e)}catch(t){return console.warn("[Block] Semantic parser error, using fallback:",t.message),this.extractFromProseMirrorFallback(e)}}extractFromProseMirrorFallback(e){const t={title:"",pretitle:"",subtitle:"",paragraphs:[],links:[],images:[],lists:[],icons:[],items:[],sequence:[]};if(!e.content)return t;for(const s of e.content)if(s.type==="heading"){const i=this.extractText(s);s.attrs?.level===1?t.title=i:s.attrs?.level===2&&(t.subtitle=i)}else if(s.type==="paragraph"){const i=this.extractText(s);t.paragraphs.push(i)}return t}extractText(e){return e.content?e.content.filter(t=>t.type==="text").map(t=>t.text).join(""):""}initComponent(){if(this.Component)return this.Component;if(this.Component=globalThis.uniweb?.getComponent(this.type),!this.Component)return console.warn(`[Block] Component not found: ${this.type}`),null;const e=globalThis.uniweb?.getComponentMeta(this.type)||{},t=e.initialState;return this.startState=t?{...t}:null,this.initState(),this.context=e.context?{...e.context}:null,e.vars&&(this.componentVars=K.mergeComponentVars(e.vars,this.properties.vars)),this.Component}getBlockProperties(){return this.properties}getInset(e){return this.insets.find(t=>t.refId===e)||null}getChildBlockRenderer(){return globalThis.uniweb.childBlockRenderer}getBlockLinks(e={}){const t=globalThis.uniweb?.activeWebsite,s=this.parsedContent||{};if(e.nested){const o=(s.lists||[])[0];return K.parseNestedLinks(o,t)}return(s.links||[]).map(r=>({route:t?.makeHref(r.href)||r.href,label:r.label}))}initState(){this.state=this.startState,this.resetStateHook&&this.resetStateHook()}getIndex(){return this.page?this.page.getBlockIndex(this):-1}getBlockInfo(){return{type:this.type,theme:this.themeName,contextOverrides:this.contextOverrides,state:this.state,context:this.context}}getNextBlockInfo(){const e=this.getIndex();return e<0||!this.page?null:this.page.getBlockInfo(e+1)}getPrevBlockInfo(){const e=this.getIndex();return e<=0||!this.page?null:this.page.getBlockInfo(e-1)}useBlockState(e,t){t!==void 0&&this.startState===null?(this.startState=t,this.state=t):t=this.startState;const[s,i]=e(t);return this.resetStateHook=()=>i(t),[s,r=>i(this.state=r)]}getDynamicContext(){return this.dynamicContext}static mergeComponentVars(e,t={}){const s={};for(const[i,r]of Object.entries(e)){const o=typeof r=="string"?r:r?.default;o!=null&&(s[i]=o)}if(t&&typeof t=="object")for(const[i,r]of Object.entries(t))r!=null&&i in e&&(s[i]=String(r));return Object.keys(s).length>0?s:null}static normalizeBackground(e){if(typeof e=="string"){if(/^(\/|\.\/|\.\.\/|https?:\/\/)/.test(e)||/\.(jpe?g|png|webp|gif|svg|avif|mp4|webm|ogv|ogg)$/i.test(e)){const t=e.split(".").pop()?.toLowerCase();return["mp4","webm","ogv","ogg"].includes(t)?{mode:"video",video:{src:e}}:{mode:"image",image:{src:e}}}return/^(linear|radial|conic)-gradient\(/.test(e)?{mode:"gradient",gradient:e}:{mode:"color",color:is(e)}}if(e.mode)return e;if(typeof e.overlay=="number"&&(e={...e,overlay:{enabled:!0,type:"dark",opacity:e.overlay}}),e.video||e.sources)return{mode:"video",...e};if(e.image||e.src){if(e.src){const{src:t,position:s,size:i,lazy:r,...o}=e;return{mode:"image",image:{src:t,position:s,size:i,lazy:r},...o}}if(typeof e.image=="string"){const{image:t,...s}=e;return{mode:"image",image:{src:t},...s}}return{mode:"image",...e}}return e.gradient?{mode:"gradient",...e}:e.color?{mode:"color",...e}:e}static parseNestedLinks(e,t){const s=[];if(!e?.length)return s;for(const i of e){const{links:r=[],lists:o=[],paragraphs:a=[]}=i,l=r[0],c=o[0],f=a[0];let u="",h="",p=[],m=!0;l?(u=l.label,h=l.href,c&&(p=K.parseNestedLinks(c,t))):(u=f,m=!1,c&&(p=K.parseNestedLinks(c,t))),s.push({label:u,route:t?.makeHref(h)||h,child_items:p,hasData:m})}return s}}class ht{constructor(e,t,s){this.id=t,this.stableId=e.id||null,this.route=e.route,this.sourcePath=e.sourcePath||null,this.isIndex=e.isIndex||!1,this.parentRoute=e.parent||null,this.title=e.title||"",this.description=e.description||"",this.label=e.label||null,this.keywords=e.keywords||null,this.lastModified=e.lastModified||null,this.hidden=e.hidden||!1,this.hideInHeader=e.hideInHeader||!1,this.hideInFooter=e.hideInFooter||!1,this.layout={name:e.layout?.name||null,hide:e.layout?.hide||[],params:e.layout?.params||{}},this.seo={noindex:e.seo?.noindex||!1,image:e.seo?.image||null,ogTitle:e.seo?.ogTitle||null,ogDescription:e.seo?.ogDescription||null,canonical:e.seo?.canonical||null,changefreq:e.seo?.changefreq||null,priority:e.seo?.priority||null},this.parent=null,this.children=[],this.website=s,this.scrollY=0,this.fetch=e.fetch||null,this.dynamicContext=e.dynamicContext||null,this.version=e.version||null,this.versionMeta=e.versionMeta||null,this.versionScope=e.versionScope||null,this._bodySections=e.sections,this._bodyBlocks=null,Object.seal(this)}get bodyBlocks(){return this._bodyBlocks||(this._bodyBlocks=(this._bodySections||[]).map((e,t)=>new K(e,t,this))),this._bodyBlocks}getHeadMeta(){return{title:this.title,description:this.description,keywords:this.keywords,canonical:this.seo.canonical,robots:this.seo.noindex?"noindex, nofollow":null,og:{title:this.seo.ogTitle||this.title,description:this.seo.ogDescription||this.description,image:this.seo.image,url:this.route}}}isDynamicPage(){return this.dynamicContext!==null}getDynamicContext(){return this.dynamicContext}getDynamicParam(){return this.dynamicContext?.paramValue||null}getLayoutName(){return this.layout.name||this.website?.getDefaultLayoutName()||null}getBlockGroups(){return{body:this.bodyBlocks,...this.getLayoutAreas()}}getBlockIndex(e){return this.getPageBlocks().indexOf(e)}getBlockInfo(e){return this.getPageBlocks()[e]?.getBlockInfo()||null}getFirstBodyBlockInfo(){return this.bodyBlocks?.[0]?.getBlockInfo()||null}getPageBlocks(){const e=[],t=this.getLayoutAreas(),s=t.header,i=t.footer;return s&&e.push(...s),e.push(...this.bodyBlocks),i&&e.push(...i),e}getBodyBlocks(){return this.bodyBlocks}getAreaBlocks(e){return this.layout.hide.includes(e)?null:this.website.getAreaBlocks(e,this.getLayoutName())}getLayoutAreas(){const e=this.website.getLayoutAreas(this.getLayoutName()),t={};for(const[s,i]of Object.entries(e))this.layout.hide.includes(s)||(t[s]=i);return t}getLayoutParams(){return this.layout.params}resetBlockStates(){const e=this.getLayoutAreas(),t=[...this.bodyBlocks,...Object.values(e).flat()];for(const s of t)typeof s.initState=="function"&&s.initState()}getNavRoute(){return this.route}getLabel(){return this.label||this.title}isHidden(){return this.hidden}showInHeader(){return!this.hidden&&!this.hideInHeader}showInFooter(){return!this.hidden&&!this.hideInFooter}hasChildren(){return this.children.length>0}hasContent(){return this.bodyBlocks.length>0}getNavigableRoute(){if(this.hasContent())return this.route;const e=this.children||[],t=e.find(s=>s.isIndex);if(t)return t.getNavigableRoute();for(const s of e){const i=s.getNavigableRoute();if(i)return i}return this.route}getNormalizedRoute(){return this.website.normalizeRoute(this.route)}isActiveFor(e){return this.website.isRouteActive(this.route,e)}isActiveOrAncestor(e){if(this.website.isRouteActive(this.route,e))return!0;const t=this.sourcePath||this.route;return this.website.isRouteActiveOrAncestor(t,e)}isVersioned(){return this.version!==null}getVersion(){return this.version}getVersions(){return this.versionMeta?.versions||[]}isLatestVersion(){return this.version?.latest===!0}isDeprecatedVersion(){return this.version?.deprecated===!0}getVersionUrl(e){return this.isVersioned()?this.website.getVersionUrl(e,this.route):null}}function Me(n){const{path:e,url:t,schema:s,transform:i}=n;return JSON.stringify({path:e,url:t,schema:s,transform:i})}class ji{constructor(){this._cache=new Map,this._inflight=new Map,this._fetcher=null,Object.seal(this)}registerFetcher(e){this._fetcher=e}has(e){return this._cache.has(Me(e))}get(e){const t=Me(e);return this._cache.has(t)?this._cache.get(t):null}set(e,t){this._cache.set(Me(e),t)}async fetch(e){if(!this._fetcher)throw new Error("DataStore: no fetcher registered. Call registerFetcher() first.");const t=Me(e);if(this._cache.has(t))return{data:this._cache.get(t)};if(this._inflight.has(t))return this._inflight.get(t);const s=this._fetcher(e).then(i=>(this._inflight.delete(t),i.data!==void 0&&i.data!==null&&this._cache.set(t,i.data),i));return this._inflight.set(t,s),s}clear(){this._cache.clear(),this._inflight.clear()}}function me(n){if(!n)return n;const e={people:"person",children:"child",men:"men",women:"woman",series:"series"};if(e[n])return e[n];if(n.endsWith("ies"))return n.slice(0,-3)+"y";if(n.endsWith("es")){const t=n.slice(0,-2),s=t.slice(-1);return["s","x","z"].includes(s)||t.endsWith("ch")||t.endsWith("sh")?t:n.slice(0,-1)}return n.endsWith("s")?n.slice(0,-1):n}class Ri{constructor({dataStore:e}){this.dataStore=e,Object.seal(this)}_getRequestedSchemas(e){if(!e)return null;const t=e.inheritData;return t?Array.isArray(t)?t.length>0?t:null:t===!0?[]:null:null}_localizeConfig(e,t){if(!e.path||!t)return e;const s=t.getActiveLocale(),i=t.getDefaultLocale();return!s||s===i||!e.path.startsWith("/data/")?e:{...e,path:`/${s}${e.path}`}}_findFetchConfigs(e,t){const s=new Map,i=t.length===0,r=[];e.fetch&&r.push(e.fetch);const o=e.page;o?.fetch&&r.push(o.fetch),o?.parent?.fetch&&r.push(o.parent.fetch);const a=e.website?.config?.fetch;a&&r.push(a);const l=e.website;for(const c of r){const f=Array.isArray(c)?c:[c];for(const u of f)u.schema&&(s.has(u.schema)||(i||t.includes(u.schema))&&s.set(u.schema,this._localizeConfig(u,l)))}return s}_buildDetailConfig(e,t){const{detail:s}=e;if(!s)return null;const{paramName:i,paramValue:r}=t;if(!i||r===void 0)return null;const o=e.url||e.path;if(!o)return null;let a;if(s==="rest")a=`${o.replace(/\/$/,"")}/${encodeURIComponent(r)}`;else if(s==="query"){const c=o.includes("?")?"&":"?";a=`${o}${c}${i}=${encodeURIComponent(r)}`}else a=s.replace(/\{(\w+)\}/g,(c,f)=>f===i?encodeURIComponent(r):`{${f}}`);return{...!!e.path&&!e.url?{path:a}:{url:a},schema:me(e.schema)||e.schema,transform:e.transform}}_resolveSingularItem(e,t){if(!t)return e;const{paramName:s,paramValue:i,schema:r}=t;if(!r||!s||i===void 0)return e;const o=e[r];if(!Array.isArray(o))return e;const a=me(r),l=o.find(c=>String(c[s])===String(i));return l&&a?{...e,[a]:l}:e}resolve(e,t){const s=this._getRequestedSchemas(t);if(s===null)return{status:"none",data:null};const i=this._findFetchConfigs(e,s);if(i.size===0)return{status:"none",data:null};const r=e.dynamicContext||e.page?.dynamicContext,o={};let a=!0;for(const[l,c]of i)if(this.dataStore.has(c))o[l]=this.dataStore.get(c);else if(r&&c.detail){const f=this._buildDetailConfig(c,r);if(f&&this.dataStore.has(f)){const u=me(l)||l;o[u]=this.dataStore.get(f)}else a=!1}else a=!1;return a?{status:"ready",data:this._resolveSingularItem(o,r)}:{status:"pending",data:null}}async fetch(e,t){const s=this._getRequestedSchemas(t);if(s===null)return{data:null};const i=this._findFetchConfigs(e,s);if(i.size===0)return{data:null};const r=e.dynamicContext||e.page?.dynamicContext,o={},a=[];for(const[c,f]of i){if(r&&f.detail&&!this.dataStore.has(f)){const u=this._buildDetailConfig(f,r);if(u){a.push(this.dataStore.fetch(u).then(h=>{if(h.data!==void 0&&h.data!==null){const p=me(c)||c;o[p]=h.data}}));continue}}a.push(this.dataStore.fetch(f).then(u=>{u.data!==void 0&&u.data!==null&&(o[c]=u.data)}))}return a.length>0&&await Promise.all(a),{data:this._resolveSingularItem(o,r)}}}class Fi{constructor(e){const{pages:t=[],theme:s={},config:i={},layouts:r,notFound:o,versionedScopes:a={}}=e;if(this.name=i.name||"",this.description=i.description||"",this.url=i.url||"",this._layoutSets={},r&&typeof r=="object")for(const[c,f]of Object.entries(r)){this._layoutSets[c]={};for(const[u,h]of Object.entries(f))h&&(this._layoutSets[c][u]=new ht(h,`layout-${c}-${u}`,this))}this.notFoundPage=o||t.find(c=>c.route==="/404")||null;const l=t.filter(c=>c.route!=="/404");this._dynamicPageData=new Map;for(const c of l)(c.isDynamic||c.route?.includes(":"))&&this._dynamicPageData.set(c.route,c);this._dynamicPageCache=new Map,this.pages=l.map((c,f)=>new ht(c,f,this)),this.buildPageHierarchy(),this.activePage=this.pages.find(c=>c.isIndex&&c.getNavRoute()==="/")||this.pages[0],this.pageRoutes=this.pages.map(c=>c.route),this.themeData=s,this.config=i,this.defaultLocale=i.defaultLanguage||"en",this.activeLocale=i.activeLocale||this.defaultLocale,this.locales=this.buildLocalesList(i),this.activeLang=this.activeLocale,this.langs=this.locales.map(c=>({label:c.label||c.code,value:c.code})),this._routeTranslations=this._buildRouteTranslations(i),this.basePath="",this.dataStore=new ji,this.entityStore=new Ri({dataStore:this.dataStore}),this.versionedScopes=a,Object.seal(this)}buildLocalesList(e){const t=e.defaultLanguage||"en",s=e.languages||[],i=o=>typeof o=="string"?{code:o}:{code:o.code,...o.label&&{label:o.label}},r=new Map;r.set(t,{code:t});for(const o of s){const a=i(o);if(r.has(a.code)){const l=r.get(a.code);r.set(a.code,{...l,...a})}else r.set(a.code,a)}return Array.from(r.values()).map(o=>({...o,isDefault:o.code===t}))}_buildRouteTranslations(e){const t=e.i18n?.routeTranslations||{},s={};for(const[i,r]of Object.entries(t)){const o=new Map,a=new Map;for(const[l,c]of Object.entries(r))o.set(l,c),a.set(c,l);s[i]={forward:o,reverse:a}}return s}translateRoute(e,t=this.activeLocale){if(!t||t===this.defaultLocale)return e;const s=this._routeTranslations[t];if(!s)return e;const i=s.forward.get(e);if(i)return i;for(const[r,o]of s.forward)if(e.startsWith(r+"/"))return o+e.slice(r.length);return e}reverseTranslateRoute(e,t=this.activeLocale){if(!t||t===this.defaultLocale)return e;const s=this._routeTranslations[t];if(!s)return e;const i=s.reverse.get(e);if(i)return i;for(const[r,o]of s.reverse)if(e.startsWith(r+"/"))return o+e.slice(r.length);return e}buildPageHierarchy(){const e=new Map;for(const t of this.pages)e.set(t.route,t);for(const t of this.pages)if(t.parentRoute){const s=e.get(t.parentRoute);s&&(s.children.push(t),t.parent=s)}this._pageIdMap=new Map;for(const t of this.pages){t.stableId&&this._pageIdMap.set(t.stableId,t);const s=this.normalizeRoute(t.route);if(s&&!this._pageIdMap.has(s)&&this._pageIdMap.set(s,t),t.sourcePath){const i=t.sourcePath.replace(/^\//,"").replace(/\/$/,"");i&&!this._pageIdMap.has(i)&&this._pageIdMap.set(i,t)}}}getPage(e){let t=e;if(this.activeLocale&&this.activeLocale!==this.defaultLocale){const o=`/${this.activeLocale}`;t===o||t===`${o}/`?t="/":t.startsWith(`${o}/`)&&(t=t.slice(o.length))}t=this.reverseTranslateRoute(t);const s=t==="/"?"/":t.replace(/\/$/,""),i=this.pages.find(o=>o.route===s);if(i)return i;const r=this.pages.find(o=>o.isIndex&&o.getNavRoute()===s);if(r)return r;if(this._dynamicPageCache.has(s))return this._dynamicPageCache.get(s);for(const o of this.pages){if(!o.route.includes(":"))continue;const a=this._matchDynamicRoute(o.route,s);if(a){const l=this._createDynamicPage(o,s,a.params);if(l)return this._dynamicPageCache.set(s,l),l}}}_matchDynamicRoute(e,t){const s=[],i=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&").replace(/:(\w+)/g,(l,c)=>(s.push(c),"([^/]+)")),r=new RegExp(`^${i}$`),o=t.match(r);if(!o)return null;const a={};return s.forEach((l,c)=>{a[l]=decodeURIComponent(o[c+1])}),{params:a}}_createDynamicPage(e,t,s){const i=this._dynamicPageData.get(e.route);if(!i)return null;const r=JSON.parse(JSON.stringify(i));r.route=t,r.isDynamic=!1;const o=Object.keys(s)[0],a=Object.values(s)[0],l=i.parentSchema,c=this._singularize(l);if(r.dynamicContext={templateRoute:e.route,params:s,paramName:o,paramValue:a,schema:l,singularSchema:c},r.sections&&Array.isArray(r.sections))for(const p of r.sections)p.dynamicContext=r.dynamicContext;const f=e.route.replace(/\/:[\w]+$/,"")||"/",u=this.pages.find(p=>p.route===f||p.getNavRoute()===f);if(u&&l){const p=u.fetch;let m=[];if(p){const g=Array.isArray(p)?p.find(b=>b.schema===l):p.schema===l?p:null;g&&(m=this.dataStore.get(g)||[])}const d=m.find(g=>String(g[o])===String(a));d&&(d.title&&(r.title=d.title),(d.description||d.excerpt)&&(r.description=d.description||d.excerpt)),r.dynamicContext.currentItem=d||null,r.dynamicContext.allItems=m}const h=new ht(r,`dynamic-${t}`,this);return h.parent=e.parent,h}_singularize(e){return me(e)}setActivePage(e){const t=this.getPage(e);t&&(this.activePage=t)}setBasePath(e){!e||e==="/"?this.basePath="":this.basePath=e.endsWith("/")?e.slice(0,-1):e}getRemoteLayout(e){const t=globalThis.uniweb?.foundationConfig;return t?.layouts&&e&&t.layouts[e]?t.layouts[e]:null}getDefaultLayoutName(){return globalThis.uniweb?.foundationConfig?.defaultLayout||null}getDefaultBlockType(){return globalThis.uniweb?.foundationConfig?.defaultSection||"Section"}getAreaBlocks(e,t){return t&&this._layoutSets[t]?this._layoutSets[t][e]?.bodyBlocks||null:this._layoutSets.default&&this._layoutSets.default[e]?.bodyBlocks||null}getLayoutAreas(e){const t=e||"default",s=this._layoutSets[t]||this._layoutSets.default;if(!s)return{};const i={};for(const[r,o]of Object.entries(s))o?.bodyBlocks&&(i[r]=o.bodyBlocks);return i}getLayoutMeta(e){return globalThis.uniweb?.foundationConfig?.layoutMeta?.[e]||null}getRemoteProps(){return globalThis.uniweb?.foundationConfig?.props||null}getRoutingComponents(){return globalThis.uniweb?.routingComponents||{}}makeHref(e){if(!e)return e;let t;if(e.startsWith("page:"))t=e.slice(5);else if(e.startsWith("topic:"))t=e.slice(6);else return e;const[s,i]=t.split("#"),r=this._pageIdMap?.get(s);if(!r)return e;let o=r.route;return i&&(o+=`#section-${i}`),o}getLanguages(){return this.langs}getLanguage(){return this.activeLang}getLocales(){return this.locales}getActiveLocale(){return this.activeLocale}getDefaultLocale(){return this.defaultLocale}hasMultipleLocales(){return this.locales.length>1}setActiveLocale(e){this.locales.find(s=>s.code===e)&&(this.activeLocale=e,this.activeLang=e)}getLocaleUrl(e,t=null){let s=t||this.activePage.route;if(this.activeLocale&&this.activeLocale!==this.defaultLocale){const r=`/${this.activeLocale}`;s===r||s===`${r}/`?s="/":s.startsWith(`${r}/`)&&(s=s.slice(r.length))}if(s=this.reverseTranslateRoute(s),e===this.defaultLocale)return s;const i=this.translateRoute(s,e);return i==="/"?`/${e}/`:`/${e}${i}`}getLocale(e){return this.locales.find(t=>t.code===e)}localize(e,t="",s="",i=!1){const r=s||this.activeLang,o=this.langs[0]?.value||"en";if(typeof e=="object"&&!Array.isArray(e))return i?e?.[r]||e?.[o]||t:e?.[r]||t;if(typeof e=="string"){if(!e.startsWith("{")&&!e.startsWith('"'))return e;try{const a=JSON.parse(e);return typeof a=="object"?i?a?.[r]||a?.[o]||t:a?.[r]||t:a}catch{return e}}return t}isSearchEnabled(){return this.config?.search?.enabled!==!1}getSearchConfig(){const e=this.config?.search||{};return{enabled:this.isSearchEnabled(),indexUrl:this.getSearchIndexUrl(),locale:this.getActiveLocale(),include:{pages:e.include?.pages!==!1,sections:e.include?.sections!==!1,headings:e.include?.headings!==!1,paragraphs:e.include?.paragraphs!==!1,links:e.include?.links!==!1,lists:e.include?.lists!==!1},exclude:{routes:e.exclude?.routes||[],components:e.exclude?.components||[]}}}getSearchIndexUrl(){const e=this.getActiveLocale();return e===this.getDefaultLocale()?"/search-index.json":`/${e}/search-index.json`}getSearchData(){return this.pages.map(e=>({id:e.id,title:e.title,href:e.route,route:e.route,description:e.description,content:e.getPageBlocks().map(t=>t.title).filter(Boolean).join(`
|
|
132
|
+
`)}))}getPageHierarchy(e={}){const{nested:t=!0,for:s,includeHidden:i=!1,filter:r,sort:o}=e,a=f=>!(f.route.includes(":")||!i&&(f.hidden||s==="header"&&f.hideInHeader||s==="footer"&&f.hideInFooter)||!f.hasContent()&&!f.children?.some(a)||r&&!r(f));let l=this.pages.filter(a);t&&(l=l.filter(f=>!f.parent&&!f.parentRoute)),o&&l.sort(o);const c=f=>{const u=f.getNavRoute();return{id:f.id,route:u,navigableRoute:f.getNavigableRoute(),translatedRoute:this.translateRoute(u),title:f.title,label:f.getLabel(),description:f.description,hasContent:f.hasContent(),version:f.version||null,children:t&&f.hasChildren()?f.children.filter(a).map(c):[]}};return l.map(c)}getHeaderPages(){return this.getPageHierarchy({for:"header"})}getFooterPages(){return this.getPageHierarchy({for:"footer"})}getAllPages(e=!1){return this.getPageHierarchy({nested:!1,includeHidden:e})}getNotFoundPage(){return this.notFoundPage}getActiveRoute(){return this.activePage.getNormalizedRoute()}getActiveRootSegment(){return this.getActiveRoute().split("/")[0]}normalizeRoute(e){let t=(e||"").replace(/^\/+/,"").replace(/\/+$/,"");if(this.activeLocale&&this.activeLocale!==this.defaultLocale){const r=this.activeLocale;t===r?t="":t.startsWith(`${r}/`)&&(t=t.slice(r.length+1))}const s="/"+t;return t=this.reverseTranslateRoute(s).replace(/^\//,""),t}isRouteActive(e,t){return this.normalizeRoute(e)===this.normalizeRoute(t)}isRouteActiveOrAncestor(e,t){const s=this.normalizeRoute(e),i=this.normalizeRoute(t);return s===i?!0:s===""?!1:i.startsWith(s+"/")}getVersionedScopes(){return this.versionedScopes}hasVersionedContent(){return Object.keys(this.versionedScopes).length>0}getVersionScope(e){const t=e||"";for(const s of Object.keys(this.versionedScopes)){if(t===s)return s;if(s==="/"){if(t.startsWith("/")||t==="")return s}else if(t.startsWith(s+"/"))return s}return null}isVersionedRoute(e){return this.getVersionScope(e)!==null}getVersionMeta(e){return this.versionedScopes[e]||null}getPageVersion(e){return e?.version||null}getVersionsForRoute(e){const t=this.getVersionScope(e);return t?this.versionedScopes[t]?.versions||[]:[]}getVersionUrl(e,t){const s=this.getVersionScope(t);if(!s)return null;const i=this.versionedScopes[s];if(!i)return null;const r=i.versions.find(l=>l.id===e);if(!r)return null;const o=s==="/"?t:t.slice(s.length);let a=o;for(const l of i.versions){const c=`/${l.id}`;if(o.startsWith(c+"/")||o===c){a=o.slice(c.length);break}}return r.latest?s==="/"?a:s+a:s==="/"?"/"+e+a:s+"/"+e+a}getLatestVersion(e){return this.versionedScopes[e]?.latestId||null}}const dt=typeof window<"u"&&typeof document<"u";class Di{constructor(e={}){this.endpoint=e.endpoint||null,this.flushInterval=e.flushInterval||5e3,this.maxQueueSize=e.maxQueueSize||10,this.debug=e.debug||!1,this.queue=[],this.scrollMilestones=new Set,this.sessionId=this.generateSessionId(),this.sessionStart=Date.now(),this.flushIntervalId=null,dt&&this.isEnabled()&&(this.setupFlushInterval(),this.setupUnloadHandler()),Object.seal(this)}isEnabled(){return!!this.endpoint}generateSessionId(){return`${Date.now()}-${Math.random().toString(36).substr(2,9)}`}setupFlushInterval(){this.flushIntervalId=setInterval(()=>{this.flush()},this.flushInterval)}setupUnloadHandler(){const e=()=>{this.flush(!0)};window.addEventListener("visibilitychange",()=>{document.visibilityState==="hidden"&&e()}),window.addEventListener("pagehide",e)}addToQueue(e,t){if(!this.isEnabled()||!dt)return;const s={type:e,data:t,timestamp:Date.now(),sessionId:this.sessionId,url:window.location.href,referrer:document.referrer||null};this.queue.push(s),this.debug&&console.log("[Analytics] Event queued:",s),this.queue.length>=this.maxQueueSize&&this.flush()}trackPageView(e,t,s={}){this.scrollMilestones.clear(),this.addToQueue("pageview",{path:e,title:t,...s})}trackEvent(e,t={}){this.addToQueue("event",{name:e,...t})}trackScrollDepth(e){[25,50,75,100].includes(e)&&(this.scrollMilestones.has(e)||(this.scrollMilestones.add(e),this.addToQueue("scroll_depth",{depth:e})))}flush(e=!1){if(!this.isEnabled()||!dt||this.queue.length===0)return;const t=[...this.queue];this.queue=[];const s=JSON.stringify({events:t,sessionId:this.sessionId,sessionDuration:Date.now()-this.sessionStart});if(this.debug&&console.log("[Analytics] Flushing",t.length,"events"),e&&navigator.sendBeacon){const i=new Blob([s],{type:"application/json"});!navigator.sendBeacon(this.endpoint,i)&&this.debug&&console.warn("[Analytics] sendBeacon failed, events may be lost");return}fetch(this.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:s,keepalive:!0}).catch(i=>{this.debug&&console.warn("[Analytics] Flush failed:",i),this.queue.unshift(...t)})}destroy(){this.flushIntervalId&&clearInterval(this.flushIntervalId),this.flush(!0)}}class Ki{constructor(e){this.activeWebsite=new Fi(e),this.childBlockRenderer=null,this.routingComponents={},this.foundation=null,this.foundationConfig={},this.meta={},this.extensions=[],this.language="en",this.iconResolver=null,this.iconCache=new Map,this.analytics=new Di(e.analytics||{}),Object.seal(this)}async resolveIcon(e,t){return this.iconResolver?this.iconResolver(e,t):(console.warn("[Uniweb] No icon resolver configured"),null)}getIconSync(e,t){return this.iconCache.get(`${e}:${t}`)||null}setFoundation(e){this.foundation=e,e.default?.meta&&(this.meta=e.default.meta)}registerExtension(e){const t=e.default?.meta||{};this.extensions.push({foundation:e,meta:t})}getComponentMeta(e){const t=this.meta[e];if(t)return t;for(const s of this.extensions){const i=s.meta[e];if(i)return i}return null}getComponentDefaults(e){return this.getComponentMeta(e)?.defaults||{}}getComponent(e){if(!this.foundation){console.warn("[Runtime] No foundation loaded");return}const t=this.foundation[e];if(t)return t;for(const s of this.extensions){const i=s.foundation[e];if(i)return i}}listComponents(){const e=new Set;if(this.foundation)for(const t of Object.keys(this.foundation))t!=="default"&&e.add(t);for(const t of this.extensions)for(const s of Object.keys(t.foundation))s!=="default"&&e.add(s);return[...e]}setFoundationConfig(e){this.foundationConfig=e}}function qi(){return globalThis.uniweb}function Vi(n){const e=new Ki(n);return globalThis.uniweb=e,e}export{K as B,ht as P,Ki as U,Fi as W,Ui as a,Vi as c,qi as g,is as n};
|
|
133
|
+
//# sourceMappingURL=index-C6TPxGbh.js.map
|