@opencloud-eu/web-client 5.0.0 → 5.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,4 @@
1
+ "use strict";const H=require("./toString-DsGM1XcL.cjs"),Oe=require("./index-D0bnLDAA.cjs");var Se=/\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,Pe=/^\w*$/;function Le(n,e){if(H.isArray(n))return!1;var t=typeof n;return t=="number"||t=="symbol"||t=="boolean"||n==null||H.isSymbol(n)?!0:Pe.test(n)||!Se.test(n)||e!=null&&n in Object(e)}var ve="Expected a function";function re(n,e){if(typeof n!="function"||e!=null&&typeof e!="function")throw new TypeError(ve);var t=function(){var s=arguments,r=e?e.apply(this,s):s[0],i=t.cache;if(i.has(r))return i.get(r);var o=n.apply(this,s);return t.cache=i.set(r,o)||i,o};return t.cache=new(re.Cache||H.MapCache),t}re.Cache=H.MapCache;var He=500;function _e(n){var e=re(n,function(s){return t.size===He&&t.clear(),s}),t=e.cache;return e}var me=/[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g,ke=/\\(\\)?/g,Fe=_e(function(n){var e=[];return n.charCodeAt(0)===46&&e.push(""),n.replace(me,function(t,s,r,i){e.push(r?i.replace(ke,"$1"):s||t)}),e});function Ue(n,e){return H.isArray(n)?n:Le(n,e)?[n]:Fe(H.toString(n))}function Me(n){if(typeof n=="string"||H.isSymbol(n))return n;var e=n+"";return e=="0"&&1/n==-1/0?"-0":e}function Ve(n,e){e=Ue(e,n);for(var t=0,s=e.length;n!=null&&t<s;)n=n[Me(e[t++])];return t&&t==s?n:void 0}function Be(n,e,t){var s=n==null?void 0:Ve(n,e);return s===void 0?t:s}const pe=(n,e)=>{const t=new URL(n);t.pathname=[...t.pathname.split("/"),"cloud","capabilities"].filter(Boolean).join("/"),t.searchParams.append("format","json");const s=t.href;return{async getCapabilities(){const r=await e.get(s);return Be(r,"data.ocs.data",{capabilities:null,version:null})}}};function Re(n){return n instanceof Uint8Array||ArrayBuffer.isView(n)&&n.constructor.name==="Uint8Array"}function B(n,e=""){if(!Number.isSafeInteger(n)||n<0){const t=e&&`"${e}" `;throw new Error(`${t}expected integer >= 0, got ${n}`)}}function R(n,e,t=""){const s=Re(n),r=n?.length,i=e!==void 0;if(!s||i&&r!==e){const o=t&&`"${t}" `,a=i?` of length ${e}`:"",c=s?`length=${r}`:`type=${typeof n}`;throw new Error(o+"expected Uint8Array"+a+", got "+c)}return n}function be(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash must wrapped by utils.createHasher");B(n.outputLen),B(n.blockLen)}function Z(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function $e(n,e){R(n,void 0,"digestInto() output");const t=e.outputLen;if(n.length<t)throw new Error('"digestInto() output" expected to be of length >='+t)}function $(...n){for(let e=0;e<n.length;e++)n[e].fill(0)}function W(n){return new DataView(n.buffer,n.byteOffset,n.byteLength)}function Ke(n){if(typeof n!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(n))}function oe(n,e=""){return typeof n=="string"?Ke(n):R(n,void 0,e)}function je(n,e){if(e!==void 0&&{}.toString.call(e)!=="[object Object]")throw new Error("options must be object or undefined");return Object.assign(n,e)}function Ge(n,e={}){const t=(r,i)=>n(i).update(r).digest(),s=n(void 0);return t.outputLen=s.outputLen,t.blockLen=s.blockLen,t.create=r=>n(r),Object.assign(t,e),Object.freeze(t)}const Xe=n=>({oid:Uint8Array.from([6,9,96,134,72,1,101,3,4,2,n])});class Ee{oHash;iHash;blockLen;outputLen;finished=!1;destroyed=!1;constructor(e,t){if(be(e),R(t,void 0,"key"),this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,r=new Uint8Array(s);r.set(t.length>s?e.create().update(t).digest():t);for(let i=0;i<r.length;i++)r[i]^=54;this.iHash.update(r),this.oHash=e.create();for(let i=0;i<r.length;i++)r[i]^=106;this.oHash.update(r),$(r)}update(e){return Z(this),this.iHash.update(e),this}digestInto(e){Z(this),R(e,this.outputLen,"output"),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||=Object.create(Object.getPrototypeOf(this),{});const{oHash:t,iHash:s,finished:r,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=r,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=s._cloneInto(e.iHash),e}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const ye=(n,e,t)=>new Ee(n,e).update(t).digest();ye.create=(n,e)=>new Ee(n,e);function Ye(n,e,t,s){be(n);const r=je({dkLen:32,asyncTick:10},s),{c:i,dkLen:o,asyncTick:a}=r;if(B(i,"c"),B(o,"dkLen"),B(a,"asyncTick"),i<1)throw new Error("iterations (c) must be >= 1");const c=oe(e,"password"),f=oe(t,"salt"),l=new Uint8Array(o),u=ye.create(n,c),d=u._cloneInto().update(f);return{c:i,dkLen:o,asyncTick:a,DK:l,PRF:u,PRFSalt:d}}function We(n,e,t,s,r){return n.destroy(),e.destroy(),s&&s.destroy(),$(r),t}function Ze(n,e,t,s){const{c:r,dkLen:i,DK:o,PRF:a,PRFSalt:c}=Ye(n,e,t,s);let f;const l=new Uint8Array(4),u=W(l),d=new Uint8Array(a.outputLen);for(let w=1,E=0;E<i;w++,E+=a.outputLen){const b=o.subarray(E,E+a.outputLen);u.setInt32(0,w,!1),(f=c._cloneInto(f)).update(l).digestInto(d),b.set(d.subarray(0,b.length));for(let h=1;h<r;h++){a._cloneInto(f).update(d).digestInto(d);for(let y=0;y<b.length;y++)b[y]^=d[y]}}return We(a,c,o,f,d)}class qe{blockLen;outputLen;padOffset;isLE;buffer;view;finished=!1;length=0;pos=0;destroyed=!1;constructor(e,t,s,r){this.blockLen=e,this.outputLen=t,this.padOffset=s,this.isLE=r,this.buffer=new Uint8Array(e),this.view=W(this.buffer)}update(e){Z(this),R(e);const{view:t,buffer:s,blockLen:r}=this,i=e.length;for(let o=0;o<i;){const a=Math.min(r-this.pos,i-o);if(a===r){const c=W(e);for(;r<=i-o;o+=r)this.process(c,o);continue}s.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===r&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){Z(this),$e(e,this),this.finished=!0;const{buffer:t,view:s,blockLen:r,isLE:i}=this;let{pos:o}=this;t[o++]=128,$(this.buffer.subarray(o)),this.padOffset>r-o&&(this.process(s,0),o=0);for(let u=o;u<r;u++)t[u]=0;s.setBigUint64(r-8,BigInt(this.length*8),i),this.process(s,0);const a=W(e),c=this.outputLen;if(c%4)throw new Error("_sha2: outputLen must be aligned to 32bit");const f=c/4,l=this.get();if(f>l.length)throw new Error("_sha2: outputLen bigger than state");for(let u=0;u<f;u++)a.setUint32(4*u,l[u],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const s=e.slice(0,t);return this.destroy(),s}_cloneInto(e){e||=new this.constructor,e.set(...this.get());const{blockLen:t,buffer:s,length:r,finished:i,destroyed:o,pos:a}=this;return e.destroyed=o,e.finished=i,e.length=r,e.pos=a,r%t&&e.buffer.set(s),e}clone(){return this._cloneInto()}}const N=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),G=BigInt(2**32-1),ce=BigInt(32);function ze(n,e=!1){return e?{h:Number(n&G),l:Number(n>>ce&G)}:{h:Number(n>>ce&G)|0,l:Number(n&G)|0}}function Je(n,e=!1){const t=n.length;let s=new Uint32Array(t),r=new Uint32Array(t);for(let i=0;i<t;i++){const{h:o,l:a}=ze(n[i],e);[s[i],r[i]]=[o,a]}return[s,r]}const fe=(n,e,t)=>n>>>t,ae=(n,e,t)=>n<<32-t|e>>>t,F=(n,e,t)=>n>>>t|e<<32-t,U=(n,e,t)=>n<<32-t|e>>>t,X=(n,e,t)=>n<<64-t|e>>>t-32,Y=(n,e,t)=>n>>>t-32|e<<64-t;function O(n,e,t,s){const r=(e>>>0)+(s>>>0);return{h:n+t+(r/2**32|0)|0,l:r|0}}const Qe=(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),De=(n,e,t,s)=>e+t+s+(n/2**32|0)|0,et=(n,e,t,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(s>>>0),tt=(n,e,t,s,r)=>e+t+s+r+(n/2**32|0)|0,nt=(n,e,t,s,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(s>>>0)+(r>>>0),st=(n,e,t,s,r,i)=>e+t+s+r+i+(n/2**32|0)|0,we=Je(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),rt=we[0],it=we[1],L=new Uint32Array(80),v=new Uint32Array(80);class ot extends qe{constructor(e){super(128,e,16,!1)}get(){const{Ah:e,Al:t,Bh:s,Bl:r,Ch:i,Cl:o,Dh:a,Dl:c,Eh:f,El:l,Fh:u,Fl:d,Gh:w,Gl:E,Hh:b,Hl:h}=this;return[e,t,s,r,i,o,a,c,f,l,u,d,w,E,b,h]}set(e,t,s,r,i,o,a,c,f,l,u,d,w,E,b,h){this.Ah=e|0,this.Al=t|0,this.Bh=s|0,this.Bl=r|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=c|0,this.Eh=f|0,this.El=l|0,this.Fh=u|0,this.Fl=d|0,this.Gh=w|0,this.Gl=E|0,this.Hh=b|0,this.Hl=h|0}process(e,t){for(let g=0;g<16;g++,t+=4)L[g]=e.getUint32(t),v[g]=e.getUint32(t+=4);for(let g=16;g<80;g++){const S=L[g-15]|0,P=v[g-15]|0,J=F(S,P,1)^F(S,P,8)^fe(S,P,7),Q=U(S,P,1)^U(S,P,8)^ae(S,P,7),x=L[g-2]|0,C=v[g-2]|0,K=F(x,C,19)^X(x,C,61)^fe(x,C,6),D=U(x,C,19)^Y(x,C,61)^ae(x,C,6),j=et(Q,D,v[g-7],v[g-16]),ee=tt(j,J,K,L[g-7],L[g-16]);L[g]=ee|0,v[g]=j|0}let{Ah:s,Al:r,Bh:i,Bl:o,Ch:a,Cl:c,Dh:f,Dl:l,Eh:u,El:d,Fh:w,Fl:E,Gh:b,Gl:h,Hh:y,Hl:A}=this;for(let g=0;g<80;g++){const S=F(u,d,14)^F(u,d,18)^X(u,d,41),P=U(u,d,14)^U(u,d,18)^Y(u,d,41),J=u&w^~u&b,Q=d&E^~d&h,x=nt(A,P,Q,it[g],v[g]),C=st(x,y,S,J,rt[g],L[g]),K=x|0,D=F(s,r,28)^X(s,r,34)^X(s,r,39),j=U(s,r,28)^Y(s,r,34)^Y(s,r,39),ee=s&i^s&a^i&a,Ce=r&o^r&c^o&c;y=b|0,A=h|0,b=w|0,h=E|0,w=u|0,E=d|0,{h:u,l:d}=O(f|0,l|0,C|0,K|0),f=a|0,l=c|0,a=i|0,c=o|0,i=s|0,o=r|0;const ie=Qe(K,j,Ce);s=De(ie,C,D,ee),r=ie|0}({h:s,l:r}=O(this.Ah|0,this.Al|0,s|0,r|0)),{h:i,l:o}=O(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l:c}=O(this.Ch|0,this.Cl|0,a|0,c|0),{h:f,l}=O(this.Dh|0,this.Dl|0,f|0,l|0),{h:u,l:d}=O(this.Eh|0,this.El|0,u|0,d|0),{h:w,l:E}=O(this.Fh|0,this.Fl|0,w|0,E|0),{h:b,l:h}=O(this.Gh|0,this.Gl|0,b|0,h|0),{h:y,l:A}=O(this.Hh|0,this.Hl|0,y|0,A|0),this.set(s,r,i,o,a,c,f,l,u,d,w,E,b,h,y,A)}roundClean(){$(L,v)}destroy(){$(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class ct extends ot{Ah=N[0]|0;Al=N[1]|0;Bh=N[2]|0;Bl=N[3]|0;Ch=N[4]|0;Cl=N[5]|0;Dh=N[6]|0;Dl=N[7]|0;Eh=N[8]|0;El=N[9]|0;Fh=N[10]|0;Fl=N[11]|0;Gh=N[12]|0;Gl=N[13]|0;Hh=N[14]|0;Hl=N[15]|0;constructor(){super(64)}}const ft=Ge(()=>new ct,Xe(3)),at=(n,e,t,s)=>Oe.Buffer.from(Ze(ft,n,e,{c:t,dkLen:s})),Ne=":A-Za-z_\\u00C0-\\u00D6\\u00D8-\\u00F6\\u00F8-\\u02FF\\u0370-\\u037D\\u037F-\\u1FFF\\u200C-\\u200D\\u2070-\\u218F\\u2C00-\\u2FEF\\u3001-\\uD7FF\\uF900-\\uFDCF\\uFDF0-\\uFFFD",ut=Ne+"\\-.\\d\\u00B7\\u0300-\\u036F\\u203F-\\u2040",lt="["+Ne+"]["+ut+"]*",dt=new RegExp("^"+lt+"$");function Te(n,e){const t=[];let s=e.exec(n);for(;s;){const r=[];r.startIndex=e.lastIndex-s[0].length;const i=s.length;for(let o=0;o<i;o++)r.push(s[o]);t.push(r),s=e.exec(n)}return t}const z=function(n){const e=dt.exec(n);return!(e===null||typeof e>"u")};function ht(n){return typeof n<"u"}const gt={allowBooleanAttributes:!1,unpairedTags:[]};function pt(n,e){e=Object.assign({},gt,e);const t=[];let s=!1,r=!1;n[0]==="\uFEFF"&&(n=n.substr(1));for(let i=0;i<n.length;i++)if(n[i]==="<"&&n[i+1]==="?"){if(i+=2,i=le(n,i),i.err)return i}else if(n[i]==="<"){let o=i;if(i++,n[i]==="!"){i=de(n,i);continue}else{let a=!1;n[i]==="/"&&(a=!0,i++);let c="";for(;i<n.length&&n[i]!==">"&&n[i]!==" "&&n[i]!==" "&&n[i]!==`
2
+ `&&n[i]!=="\r";i++)c+=n[i];if(c=c.trim(),c[c.length-1]==="/"&&(c=c.substring(0,c.length-1),i--),!At(c)){let u;return c.trim().length===0?u="Invalid space after '<'.":u="Tag '"+c+"' is an invalid name.",p("InvalidTag",u,T(n,i))}const f=yt(n,i);if(f===!1)return p("InvalidAttr","Attributes for '"+c+"' have open quote.",T(n,i));let l=f.value;if(i=f.index,l[l.length-1]==="/"){const u=i-l.length;l=l.substring(0,l.length-1);const d=he(l,e);if(d===!0)s=!0;else return p(d.err.code,d.err.msg,T(n,u+d.err.line))}else if(a)if(f.tagClosed){if(l.trim().length>0)return p("InvalidTag","Closing tag '"+c+"' can't have attributes or invalid starting.",T(n,o));if(t.length===0)return p("InvalidTag","Closing tag '"+c+"' has not been opened.",T(n,o));{const u=t.pop();if(c!==u.tagName){let d=T(n,u.tagStartPos);return p("InvalidTag","Expected closing tag '"+u.tagName+"' (opened in line "+d.line+", col "+d.col+") instead of closing tag '"+c+"'.",T(n,o))}t.length==0&&(r=!0)}}else return p("InvalidTag","Closing tag '"+c+"' doesn't have proper closing.",T(n,i));else{const u=he(l,e);if(u!==!0)return p(u.err.code,u.err.msg,T(n,i-l.length+u.err.line));if(r===!0)return p("InvalidXml","Multiple possible root nodes found.",T(n,i));e.unpairedTags.indexOf(c)!==-1||t.push({tagName:c,tagStartPos:o}),s=!0}for(i++;i<n.length;i++)if(n[i]==="<")if(n[i+1]==="!"){i++,i=de(n,i);continue}else if(n[i+1]==="?"){if(i=le(n,++i),i.err)return i}else break;else if(n[i]==="&"){const u=Tt(n,i);if(u==-1)return p("InvalidChar","char '&' is not expected.",T(n,i));i=u}else if(r===!0&&!ue(n[i]))return p("InvalidXml","Extra text at the end",T(n,i));n[i]==="<"&&i--}}else{if(ue(n[i]))continue;return p("InvalidChar","char '"+n[i]+"' is not expected.",T(n,i))}if(s){if(t.length==1)return p("InvalidTag","Unclosed tag '"+t[0].tagName+"'.",T(n,t[0].tagStartPos));if(t.length>0)return p("InvalidXml","Invalid '"+JSON.stringify(t.map(i=>i.tagName),null,4).replace(/\r?\n/g,"")+"' found.",{line:1,col:1})}else return p("InvalidXml","Start tag expected.",1);return!0}function ue(n){return n===" "||n===" "||n===`
3
+ `||n==="\r"}function le(n,e){const t=e;for(;e<n.length;e++)if(n[e]=="?"||n[e]==" "){const s=n.substr(t,e-t);if(e>5&&s==="xml")return p("InvalidXml","XML declaration allowed only at the start of the document.",T(n,e));if(n[e]=="?"&&n[e+1]==">"){e++;break}else continue}return e}function de(n,e){if(n.length>e+5&&n[e+1]==="-"&&n[e+2]==="-"){for(e+=3;e<n.length;e++)if(n[e]==="-"&&n[e+1]==="-"&&n[e+2]===">"){e+=2;break}}else if(n.length>e+8&&n[e+1]==="D"&&n[e+2]==="O"&&n[e+3]==="C"&&n[e+4]==="T"&&n[e+5]==="Y"&&n[e+6]==="P"&&n[e+7]==="E"){let t=1;for(e+=8;e<n.length;e++)if(n[e]==="<")t++;else if(n[e]===">"&&(t--,t===0))break}else if(n.length>e+9&&n[e+1]==="["&&n[e+2]==="C"&&n[e+3]==="D"&&n[e+4]==="A"&&n[e+5]==="T"&&n[e+6]==="A"&&n[e+7]==="["){for(e+=8;e<n.length;e++)if(n[e]==="]"&&n[e+1]==="]"&&n[e+2]===">"){e+=2;break}}return e}const bt='"',Et="'";function yt(n,e){let t="",s="",r=!1;for(;e<n.length;e++){if(n[e]===bt||n[e]===Et)s===""?s=n[e]:s!==n[e]||(s="");else if(n[e]===">"&&s===""){r=!0;break}t+=n[e]}return s!==""?!1:{value:t,index:e,tagClosed:r}}const wt=new RegExp(`(\\s*)([^\\s=]+)(\\s*=)?(\\s*(['"])(([\\s\\S])*?)\\5)?`,"g");function he(n,e){const t=Te(n,wt),s={};for(let r=0;r<t.length;r++){if(t[r][1].length===0)return p("InvalidAttr","Attribute '"+t[r][2]+"' has no space in starting.",M(t[r]));if(t[r][3]!==void 0&&t[r][4]===void 0)return p("InvalidAttr","Attribute '"+t[r][2]+"' is without value.",M(t[r]));if(t[r][3]===void 0&&!e.allowBooleanAttributes)return p("InvalidAttr","boolean attribute '"+t[r][2]+"' is not allowed.",M(t[r]));const i=t[r][2];if(!It(i))return p("InvalidAttr","Attribute '"+i+"' is an invalid name.",M(t[r]));if(!s.hasOwnProperty(i))s[i]=1;else return p("InvalidAttr","Attribute '"+i+"' is repeated.",M(t[r]))}return!0}function Nt(n,e){let t=/\d/;for(n[e]==="x"&&(e++,t=/[\da-fA-F]/);e<n.length;e++){if(n[e]===";")return e;if(!n[e].match(t))break}return-1}function Tt(n,e){if(e++,n[e]===";")return-1;if(n[e]==="#")return e++,Nt(n,e);let t=0;for(;e<n.length;e++,t++)if(!(n[e].match(/\w/)&&t<20)){if(n[e]===";")break;return-1}return e}function p(n,e,t){return{err:{code:n,msg:e,line:t.line||t,col:t.col}}}function It(n){return z(n)}function At(n){return z(n)}function T(n,e){const t=n.substring(0,e).split(/\r?\n/);return{line:t.length,col:t[t.length-1].length+1}}function M(n){return n.startIndex+n[1].length}const xt={preserveOrder:!1,attributeNamePrefix:"@_",attributesGroupName:!1,textNodeName:"#text",ignoreAttributes:!0,removeNSPrefix:!1,allowBooleanAttributes:!1,parseTagValue:!0,parseAttributeValue:!1,trimValues:!0,cdataPropName:!1,numberParseOptions:{hex:!0,leadingZeros:!0,eNotation:!0},tagValueProcessor:function(n,e){return e},attributeValueProcessor:function(n,e){return e},stopNodes:[],alwaysCreateTextNode:!1,isArray:()=>!1,commentPropName:!1,unpairedTags:[],processEntities:!0,htmlEntities:!1,ignoreDeclaration:!1,ignorePiTags:!1,transformTagName:!1,transformAttributeName:!1,updateTag:function(n,e,t){return n},captureMetaData:!1},Ct=function(n){return Object.assign({},xt,n)};let q;typeof Symbol!="function"?q="@@xmlMetadata":q=Symbol("XML Node Metadata");class m{constructor(e){this.tagname=e,this.child=[],this[":@"]={}}add(e,t){e==="__proto__"&&(e="#__proto__"),this.child.push({[e]:t})}addChild(e,t){e.tagname==="__proto__"&&(e.tagname="#__proto__"),e[":@"]&&Object.keys(e[":@"]).length>0?this.child.push({[e.tagname]:e.child,":@":e[":@"]}):this.child.push({[e.tagname]:e.child}),t!==void 0&&(this.child[this.child.length-1][q]={startIndex:t})}static getMetaDataSymbol(){return q}}class Ot{constructor(e){this.suppressValidationErr=!e}readDocType(e,t){const s={};if(e[t+3]==="O"&&e[t+4]==="C"&&e[t+5]==="T"&&e[t+6]==="Y"&&e[t+7]==="P"&&e[t+8]==="E"){t=t+9;let r=1,i=!1,o=!1,a="";for(;t<e.length;t++)if(e[t]==="<"&&!o){if(i&&_(e,"!ENTITY",t)){t+=7;let c,f;if([c,f,t]=this.readEntityExp(e,t+1,this.suppressValidationErr),f.indexOf("&")===-1){const l=c.replace(/[.\-+*:]/g,"\\.");s[c]={regx:RegExp(`&${l};`,"g"),val:f}}}else if(i&&_(e,"!ELEMENT",t)){t+=8;const{index:c}=this.readElementExp(e,t+1);t=c}else if(i&&_(e,"!ATTLIST",t))t+=8;else if(i&&_(e,"!NOTATION",t)){t+=9;const{index:c}=this.readNotationExp(e,t+1,this.suppressValidationErr);t=c}else if(_(e,"!--",t))o=!0;else throw new Error("Invalid DOCTYPE");r++,a=""}else if(e[t]===">"){if(o?e[t-1]==="-"&&e[t-2]==="-"&&(o=!1,r--):r--,r===0)break}else e[t]==="["?i=!0:a+=e[t];if(r!==0)throw new Error("Unclosed DOCTYPE")}else throw new Error("Invalid Tag instead of DOCTYPE");return{entities:s,i:t}}readEntityExp(e,t){t=I(e,t);let s="";for(;t<e.length&&!/\s/.test(e[t])&&e[t]!=='"'&&e[t]!=="'";)s+=e[t],t++;if(V(s),t=I(e,t),!this.suppressValidationErr){if(e.substring(t,t+6).toUpperCase()==="SYSTEM")throw new Error("External entities are not supported");if(e[t]==="%")throw new Error("Parameter entities are not supported")}let r="";return[t,r]=this.readIdentifierVal(e,t,"entity"),t--,[s,r,t]}readNotationExp(e,t){t=I(e,t);let s="";for(;t<e.length&&!/\s/.test(e[t]);)s+=e[t],t++;!this.suppressValidationErr&&V(s),t=I(e,t);const r=e.substring(t,t+6).toUpperCase();if(!this.suppressValidationErr&&r!=="SYSTEM"&&r!=="PUBLIC")throw new Error(`Expected SYSTEM or PUBLIC, found "${r}"`);t+=r.length,t=I(e,t);let i=null,o=null;if(r==="PUBLIC")[t,i]=this.readIdentifierVal(e,t,"publicIdentifier"),t=I(e,t),(e[t]==='"'||e[t]==="'")&&([t,o]=this.readIdentifierVal(e,t,"systemIdentifier"));else if(r==="SYSTEM"&&([t,o]=this.readIdentifierVal(e,t,"systemIdentifier"),!this.suppressValidationErr&&!o))throw new Error("Missing mandatory system identifier for SYSTEM notation");return{notationName:s,publicIdentifier:i,systemIdentifier:o,index:--t}}readIdentifierVal(e,t,s){let r="";const i=e[t];if(i!=='"'&&i!=="'")throw new Error(`Expected quoted string, found "${i}"`);for(t++;t<e.length&&e[t]!==i;)r+=e[t],t++;if(e[t]!==i)throw new Error(`Unterminated ${s} value`);return t++,[t,r]}readElementExp(e,t){t=I(e,t);let s="";for(;t<e.length&&!/\s/.test(e[t]);)s+=e[t],t++;if(!this.suppressValidationErr&&!z(s))throw new Error(`Invalid element name: "${s}"`);t=I(e,t);let r="";if(e[t]==="E"&&_(e,"MPTY",t))t+=4;else if(e[t]==="A"&&_(e,"NY",t))t+=2;else if(e[t]==="("){for(t++;t<e.length&&e[t]!==")";)r+=e[t],t++;if(e[t]!==")")throw new Error("Unterminated content model")}else if(!this.suppressValidationErr)throw new Error(`Invalid Element Expression, found "${e[t]}"`);return{elementName:s,contentModel:r.trim(),index:t}}readAttlistExp(e,t){t=I(e,t);let s="";for(;t<e.length&&!/\s/.test(e[t]);)s+=e[t],t++;V(s),t=I(e,t);let r="";for(;t<e.length&&!/\s/.test(e[t]);)r+=e[t],t++;if(!V(r))throw new Error(`Invalid attribute name: "${r}"`);t=I(e,t);let i="";if(e.substring(t,t+8).toUpperCase()==="NOTATION"){if(i="NOTATION",t+=8,t=I(e,t),e[t]!=="(")throw new Error(`Expected '(', found "${e[t]}"`);t++;let a=[];for(;t<e.length&&e[t]!==")";){let c="";for(;t<e.length&&e[t]!=="|"&&e[t]!==")";)c+=e[t],t++;if(c=c.trim(),!V(c))throw new Error(`Invalid notation name: "${c}"`);a.push(c),e[t]==="|"&&(t++,t=I(e,t))}if(e[t]!==")")throw new Error("Unterminated list of notations");t++,i+=" ("+a.join("|")+")"}else{for(;t<e.length&&!/\s/.test(e[t]);)i+=e[t],t++;const a=["CDATA","ID","IDREF","IDREFS","ENTITY","ENTITIES","NMTOKEN","NMTOKENS"];if(!this.suppressValidationErr&&!a.includes(i.toUpperCase()))throw new Error(`Invalid attribute type: "${i}"`)}t=I(e,t);let o="";return e.substring(t,t+8).toUpperCase()==="#REQUIRED"?(o="#REQUIRED",t+=8):e.substring(t,t+7).toUpperCase()==="#IMPLIED"?(o="#IMPLIED",t+=7):[t,o]=this.readIdentifierVal(e,t,"ATTLIST"),{elementName:s,attributeName:r,attributeType:i,defaultValue:o,index:t}}}const I=(n,e)=>{for(;e<n.length&&/\s/.test(n[e]);)e++;return e};function _(n,e,t){for(let s=0;s<e.length;s++)if(e[s]!==n[t+s+1])return!1;return!0}function V(n){if(z(n))return n;throw new Error(`Invalid entity name ${n}`)}const St=/^[-+]?0x[a-fA-F0-9]+$/,Pt=/^([\-\+])?(0*)([0-9]*(\.[0-9]*)?)$/,Lt={hex:!0,leadingZeros:!0,decimalPoint:".",eNotation:!0};function vt(n,e={}){if(e=Object.assign({},Lt,e),!n||typeof n!="string")return n;let t=n.trim();if(e.skipLike!==void 0&&e.skipLike.test(t))return n;if(n==="0")return 0;if(e.hex&&St.test(t))return kt(t,16);if(t.includes("e")||t.includes("E"))return _t(n,t,e);{const s=Pt.exec(t);if(s){const r=s[1]||"",i=s[2];let o=mt(s[3]);const a=r?n[i.length+1]===".":n[i.length]===".";if(!e.leadingZeros&&(i.length>1||i.length===1&&!a))return n;{const c=Number(t),f=String(c);if(c===0)return c;if(f.search(/[eE]/)!==-1)return e.eNotation?c:n;if(t.indexOf(".")!==-1)return f==="0"||f===o||f===`${r}${o}`?c:n;let l=i?o:t;return i?l===f||r+l===f?c:n:l===f||l===r+f?c:n}}else return n}}const Ht=/^([-+])?(0*)(\d*(\.\d*)?[eE][-\+]?\d+)$/;function _t(n,e,t){if(!t.eNotation)return n;const s=e.match(Ht);if(s){let r=s[1]||"";const i=s[3].indexOf("e")===-1?"E":"e",o=s[2],a=r?n[o.length+1]===i:n[o.length]===i;return o.length>1&&a?n:o.length===1&&(s[3].startsWith(`.${i}`)||s[3][0]===i)?Number(e):t.leadingZeros&&!a?(e=(s[1]||"")+s[3],Number(e)):n}else return n}function mt(n){return n&&n.indexOf(".")!==-1&&(n=n.replace(/0+$/,""),n==="."?n="0":n[0]==="."?n="0"+n:n[n.length-1]==="."&&(n=n.substring(0,n.length-1))),n}function kt(n,e){if(parseInt)return parseInt(n,e);if(Number.parseInt)return Number.parseInt(n,e);if(window&&window.parseInt)return window.parseInt(n,e);throw new Error("parseInt, Number.parseInt, window.parseInt are not supported")}function Ie(n){return typeof n=="function"?n:Array.isArray(n)?e=>{for(const t of n)if(typeof t=="string"&&e===t||t instanceof RegExp&&t.test(e))return!0}:()=>!1}class Ft{constructor(e){if(this.options=e,this.currentNode=null,this.tagsNodeStack=[],this.docTypeEntities={},this.lastEntities={apos:{regex:/&(apos|#39|#x27);/g,val:"'"},gt:{regex:/&(gt|#62|#x3E);/g,val:">"},lt:{regex:/&(lt|#60|#x3C);/g,val:"<"},quot:{regex:/&(quot|#34|#x22);/g,val:'"'}},this.ampEntity={regex:/&(amp|#38|#x26);/g,val:"&"},this.htmlEntities={space:{regex:/&(nbsp|#160);/g,val:" "},cent:{regex:/&(cent|#162);/g,val:"¢"},pound:{regex:/&(pound|#163);/g,val:"£"},yen:{regex:/&(yen|#165);/g,val:"¥"},euro:{regex:/&(euro|#8364);/g,val:"€"},copyright:{regex:/&(copy|#169);/g,val:"©"},reg:{regex:/&(reg|#174);/g,val:"®"},inr:{regex:/&(inr|#8377);/g,val:"₹"},num_dec:{regex:/&#([0-9]{1,7});/g,val:(t,s)=>ge(s,10,"&#")},num_hex:{regex:/&#x([0-9a-fA-F]{1,6});/g,val:(t,s)=>ge(s,16,"&#x")}},this.addExternalEntities=Ut,this.parseXml=$t,this.parseTextData=Mt,this.resolveNameSpace=Vt,this.buildAttributesMap=Rt,this.isItStopNode=Xt,this.replaceEntitiesValue=jt,this.readStopNodeData=Wt,this.saveTextToParentTag=Gt,this.addChild=Kt,this.ignoreAttributesFn=Ie(this.options.ignoreAttributes),this.options.stopNodes&&this.options.stopNodes.length>0){this.stopNodesExact=new Set,this.stopNodesWildcard=new Set;for(let t=0;t<this.options.stopNodes.length;t++){const s=this.options.stopNodes[t];typeof s=="string"&&(s.startsWith("*.")?this.stopNodesWildcard.add(s.substring(2)):this.stopNodesExact.add(s))}}}}function Ut(n){const e=Object.keys(n);for(let t=0;t<e.length;t++){const s=e[t],r=s.replace(/[.\-+*:]/g,"\\.");this.lastEntities[s]={regex:new RegExp("&"+r+";","g"),val:n[s]}}}function Mt(n,e,t,s,r,i,o){if(n!==void 0&&(this.options.trimValues&&!s&&(n=n.trim()),n.length>0)){o||(n=this.replaceEntitiesValue(n));const a=this.options.tagValueProcessor(e,n,t,r,i);return a==null?n:typeof a!=typeof n||a!==n?a:this.options.trimValues?se(n,this.options.parseTagValue,this.options.numberParseOptions):n.trim()===n?se(n,this.options.parseTagValue,this.options.numberParseOptions):n}}function Vt(n){if(this.options.removeNSPrefix){const e=n.split(":"),t=n.charAt(0)==="/"?"/":"";if(e[0]==="xmlns")return"";e.length===2&&(n=t+e[1])}return n}const Bt=new RegExp(`([^\\s=]+)\\s*(=\\s*(['"])([\\s\\S]*?)\\3)?`,"gm");function Rt(n,e){if(this.options.ignoreAttributes!==!0&&typeof n=="string"){const t=Te(n,Bt),s=t.length,r={};for(let i=0;i<s;i++){const o=this.resolveNameSpace(t[i][1]);if(this.ignoreAttributesFn(o,e))continue;let a=t[i][4],c=this.options.attributeNamePrefix+o;if(o.length)if(this.options.transformAttributeName&&(c=this.options.transformAttributeName(c)),c==="__proto__"&&(c="#__proto__"),a!==void 0){this.options.trimValues&&(a=a.trim()),a=this.replaceEntitiesValue(a);const f=this.options.attributeValueProcessor(o,a,e);f==null?r[c]=a:typeof f!=typeof a||f!==a?r[c]=f:r[c]=se(a,this.options.parseAttributeValue,this.options.numberParseOptions)}else this.options.allowBooleanAttributes&&(r[c]=!0)}if(!Object.keys(r).length)return;if(this.options.attributesGroupName){const i={};return i[this.options.attributesGroupName]=r,i}return r}}const $t=function(n){n=n.replace(/\r\n?/g,`
4
+ `);const e=new m("!xml");let t=e,s="",r="";const i=new Ot(this.options.processEntities);for(let o=0;o<n.length;o++)if(n[o]==="<")if(n[o+1]==="/"){const c=k(n,">",o,"Closing Tag is not closed.");let f=n.substring(o+2,c).trim();if(this.options.removeNSPrefix){const d=f.indexOf(":");d!==-1&&(f=f.substr(d+1))}this.options.transformTagName&&(f=this.options.transformTagName(f)),t&&(s=this.saveTextToParentTag(s,t,r));const l=r.substring(r.lastIndexOf(".")+1);if(f&&this.options.unpairedTags.indexOf(f)!==-1)throw new Error(`Unpaired tag can not be used as closing tag: </${f}>`);let u=0;l&&this.options.unpairedTags.indexOf(l)!==-1?(u=r.lastIndexOf(".",r.lastIndexOf(".")-1),this.tagsNodeStack.pop()):u=r.lastIndexOf("."),r=r.substring(0,u),t=this.tagsNodeStack.pop(),s="",o=c}else if(n[o+1]==="?"){let c=ne(n,o,!1,"?>");if(!c)throw new Error("Pi Tag is not closed.");if(s=this.saveTextToParentTag(s,t,r),!(this.options.ignoreDeclaration&&c.tagName==="?xml"||this.options.ignorePiTags)){const f=new m(c.tagName);f.add(this.options.textNodeName,""),c.tagName!==c.tagExp&&c.attrExpPresent&&(f[":@"]=this.buildAttributesMap(c.tagExp,r)),this.addChild(t,f,r,o)}o=c.closeIndex+1}else if(n.substr(o+1,3)==="!--"){const c=k(n,"-->",o+4,"Comment is not closed.");if(this.options.commentPropName){const f=n.substring(o+4,c-2);s=this.saveTextToParentTag(s,t,r),t.add(this.options.commentPropName,[{[this.options.textNodeName]:f}])}o=c}else if(n.substr(o+1,2)==="!D"){const c=i.readDocType(n,o);this.docTypeEntities=c.entities,o=c.i}else if(n.substr(o+1,2)==="!["){const c=k(n,"]]>",o,"CDATA is not closed.")-2,f=n.substring(o+9,c);s=this.saveTextToParentTag(s,t,r);let l=this.parseTextData(f,t.tagname,r,!0,!1,!0,!0);l==null&&(l=""),this.options.cdataPropName?t.add(this.options.cdataPropName,[{[this.options.textNodeName]:f}]):t.add(this.options.textNodeName,l),o=c+2}else{let c=ne(n,o,this.options.removeNSPrefix),f=c.tagName;const l=c.rawTagName;let u=c.tagExp,d=c.attrExpPresent,w=c.closeIndex;if(this.options.transformTagName){const h=this.options.transformTagName(f);u===f&&(u=h),f=h}t&&s&&t.tagname!=="!xml"&&(s=this.saveTextToParentTag(s,t,r,!1));const E=t;E&&this.options.unpairedTags.indexOf(E.tagname)!==-1&&(t=this.tagsNodeStack.pop(),r=r.substring(0,r.lastIndexOf("."))),f!==e.tagname&&(r+=r?"."+f:f);const b=o;if(this.isItStopNode(this.stopNodesExact,this.stopNodesWildcard,r,f)){let h="";if(u.length>0&&u.lastIndexOf("/")===u.length-1)f[f.length-1]==="/"?(f=f.substr(0,f.length-1),r=r.substr(0,r.length-1),u=f):u=u.substr(0,u.length-1),o=c.closeIndex;else if(this.options.unpairedTags.indexOf(f)!==-1)o=c.closeIndex;else{const A=this.readStopNodeData(n,l,w+1);if(!A)throw new Error(`Unexpected end of ${l}`);o=A.i,h=A.tagContent}const y=new m(f);f!==u&&d&&(y[":@"]=this.buildAttributesMap(u,r)),h&&(h=this.parseTextData(h,f,r,!0,d,!0,!0)),r=r.substr(0,r.lastIndexOf(".")),y.add(this.options.textNodeName,h),this.addChild(t,y,r,b)}else{if(u.length>0&&u.lastIndexOf("/")===u.length-1){if(f[f.length-1]==="/"?(f=f.substr(0,f.length-1),r=r.substr(0,r.length-1),u=f):u=u.substr(0,u.length-1),this.options.transformTagName){const y=this.options.transformTagName(f);u===f&&(u=y),f=y}const h=new m(f);f!==u&&d&&(h[":@"]=this.buildAttributesMap(u,r)),this.addChild(t,h,r,b),r=r.substr(0,r.lastIndexOf("."))}else{const h=new m(f);this.tagsNodeStack.push(t),f!==u&&d&&(h[":@"]=this.buildAttributesMap(u,r)),this.addChild(t,h,r,b),t=h}s="",o=w}}else s+=n[o];return e.child};function Kt(n,e,t,s){this.options.captureMetaData||(s=void 0);const r=this.options.updateTag(e.tagname,t,e[":@"]);r===!1||(typeof r=="string"&&(e.tagname=r),n.addChild(e,s))}const jt=function(n){if(this.options.processEntities){for(let e in this.docTypeEntities){const t=this.docTypeEntities[e];n=n.replace(t.regx,t.val)}for(let e in this.lastEntities){const t=this.lastEntities[e];n=n.replace(t.regex,t.val)}if(this.options.htmlEntities)for(let e in this.htmlEntities){const t=this.htmlEntities[e];n=n.replace(t.regex,t.val)}n=n.replace(this.ampEntity.regex,this.ampEntity.val)}return n};function Gt(n,e,t,s){return n&&(s===void 0&&(s=e.child.length===0),n=this.parseTextData(n,e.tagname,t,!1,e[":@"]?Object.keys(e[":@"]).length!==0:!1,s),n!==void 0&&n!==""&&e.add(this.options.textNodeName,n),n=""),n}function Xt(n,e,t,s){return!!(e&&e.has(s)||n&&n.has(t))}function Yt(n,e,t=">"){let s,r="";for(let i=e;i<n.length;i++){let o=n[i];if(s)o===s&&(s="");else if(o==='"'||o==="'")s=o;else if(o===t[0])if(t[1]){if(n[i+1]===t[1])return{data:r,index:i}}else return{data:r,index:i};else o===" "&&(o=" ");r+=o}}function k(n,e,t,s){const r=n.indexOf(e,t);if(r===-1)throw new Error(s);return r+e.length-1}function ne(n,e,t,s=">"){const r=Yt(n,e+1,s);if(!r)return;let i=r.data;const o=r.index,a=i.search(/\s/);let c=i,f=!0;a!==-1&&(c=i.substring(0,a),i=i.substring(a+1).trimStart());const l=c;if(t){const u=c.indexOf(":");u!==-1&&(c=c.substr(u+1),f=c!==r.data.substr(u+1))}return{tagName:c,tagExp:i,closeIndex:o,attrExpPresent:f,rawTagName:l}}function Wt(n,e,t){const s=t;let r=1;for(;t<n.length;t++)if(n[t]==="<")if(n[t+1]==="/"){const i=k(n,">",t,`${e} is not closed`);if(n.substring(t+2,i).trim()===e&&(r--,r===0))return{tagContent:n.substring(s,t),i};t=i}else if(n[t+1]==="?")t=k(n,"?>",t+1,"StopNode is not closed.");else if(n.substr(t+1,3)==="!--")t=k(n,"-->",t+3,"StopNode is not closed.");else if(n.substr(t+1,2)==="![")t=k(n,"]]>",t,"StopNode is not closed.")-2;else{const i=ne(n,t,">");i&&((i&&i.tagName)===e&&i.tagExp[i.tagExp.length-1]!=="/"&&r++,t=i.closeIndex)}}function se(n,e,t){if(e&&typeof n=="string"){const s=n.trim();return s==="true"?!0:s==="false"?!1:vt(n,t)}else return ht(n)?n:""}function ge(n,e,t){const s=Number.parseInt(n,e);return s>=0&&s<=1114111?String.fromCodePoint(s):t+n+";"}const te=m.getMetaDataSymbol();function Zt(n,e){return Ae(n,e)}function Ae(n,e,t){let s;const r={};for(let i=0;i<n.length;i++){const o=n[i],a=qt(o);let c="";if(t===void 0?c=a:c=t+"."+a,a===e.textNodeName)s===void 0?s=o[a]:s+=""+o[a];else{if(a===void 0)continue;if(o[a]){let f=Ae(o[a],e,c);const l=Jt(f,e);o[te]!==void 0&&(f[te]=o[te]),o[":@"]?zt(f,o[":@"],c,e):Object.keys(f).length===1&&f[e.textNodeName]!==void 0&&!e.alwaysCreateTextNode?f=f[e.textNodeName]:Object.keys(f).length===0&&(e.alwaysCreateTextNode?f[e.textNodeName]="":f=""),r[a]!==void 0&&r.hasOwnProperty(a)?(Array.isArray(r[a])||(r[a]=[r[a]]),r[a].push(f)):e.isArray(a,c,l)?r[a]=[f]:r[a]=f}}}return typeof s=="string"?s.length>0&&(r[e.textNodeName]=s):s!==void 0&&(r[e.textNodeName]=s),r}function qt(n){const e=Object.keys(n);for(let t=0;t<e.length;t++){const s=e[t];if(s!==":@")return s}}function zt(n,e,t,s){if(e){const r=Object.keys(e),i=r.length;for(let o=0;o<i;o++){const a=r[o];s.isArray(a,t+"."+a,!0,!0)?n[a]=[e[a]]:n[a]=e[a]}}}function Jt(n,e){const{textNodeName:t}=e,s=Object.keys(n).length;return!!(s===0||s===1&&(n[t]||typeof n[t]=="boolean"||n[t]===0))}class xe{constructor(e){this.externalEntities={},this.options=Ct(e)}parse(e,t){if(typeof e!="string"&&e.toString)e=e.toString();else if(typeof e!="string")throw new Error("XML data is accepted in String or Bytes[] form.");if(t){t===!0&&(t={});const i=pt(e,t);if(i!==!0)throw Error(`${i.err.msg}:${i.err.line}:${i.err.col}`)}const s=new Ft(this.options);s.addExternalEntities(this.externalEntities);const r=s.parseXml(e);return this.options.preserveOrder||r===void 0?r:Zt(r,this.options)}addEntity(e,t){if(t.indexOf("&")!==-1)throw new Error("Entity value can't have '&'");if(e.indexOf("&")!==-1||e.indexOf(";")!==-1)throw new Error("An entity must be set without '&' and ';'. Eg. use '#xD' for '&#xD;'");if(t==="&")throw new Error("An entity with value '&' is not permitted");this.externalEntities[e]=t}static getMetaDataSymbol(){return m.getMetaDataSymbol()}}class Qt{axiosClient;baseURI;xmlParser;signingKey;ALGORITHM="sha512";TTL=1200;HASH_LENGTH=32;ITERATION_COUNT=1e4;constructor({axiosClient:e,baseURI:t}){this.axiosClient=e,this.baseURI=t,this.xmlParser=new xe}async signUrl(e,t){const s=new URL(e);s.searchParams.set("OC-Credential",t),s.searchParams.set("OC-Date",new Date().toISOString()),s.searchParams.set("OC-Expires",this.TTL.toString()),s.searchParams.set("OC-Verb","GET");const r=await this.createHashedKey(s.toString());return s.searchParams.set("OC-Algo",`PBKDF2/${this.ITERATION_COUNT}-SHA512`),s.searchParams.set("OC-Signature",r),s.toString()}async getSignKey(){if(this.signingKey)return this.signingKey;const e=await this.axiosClient.get(H.urlJoin(this.baseURI,"ocs/v1.php/cloud/user/signing-key"),{headers:{"Content-Type":"application/x-www-form-urlencoded"}}),t=this.xmlParser.parse(e.data);return this.signingKey=t.ocs.data["signing-key"],this.signingKey}async createHashedKey(e){const t=await this.getSignKey();return at(e,t,this.ITERATION_COUNT,this.HASH_LENGTH,this.ALGORITHM).toString("hex")}}const Dt=(n,e)=>{const t=new URL(n);t.pathname=[...t.pathname.split("/"),"ocs","v1.php"].filter(Boolean).join("/");const s=t.href,r=pe(s,e),i=new Qt({baseURI:n,axiosClient:e});return{getCapabilities:()=>r.getCapabilities(),signUrl:(o,a)=>i.signUrl(o,a)}};exports.GetCapabilitiesFactory=pe;exports.XMLParser=xe;exports.getIgnoreAttributesFn=Ie;exports.ocs=Dt;