@php-wasm/cli 2.0.16 → 2.0.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (3) hide show
  1. package/main.js +11 -11
  2. package/main.js.map +1 -1
  3. package/package.json +5 -5
package/main.js CHANGED
@@ -1,15 +1,15 @@
1
- import Ye from"os";import{readFileSync as Oe,writeFile as mn,statSync as yn,readdirSync as gn,lstatSync as wn,existsSync as bn,writeFileSync as Hr,mkdtempSync as ze,chmodSync as En}from"fs";import{rootCertificates as Tn}from"tls";import{LatestSupportedPHPVersion as xn,SupportedPHPVersionsList as Dn,PHP as vn}from"@php-wasm/universal";import{loadNodeRuntime as In,FileLockManagerForNode as Nn,useHostFilesystem as On}from"@php-wasm/node";import{WebSocketServer as Cn}from"ws";import An from"net";import"assert";import Pt,{resolve as Ce,normalize as Ln}from"path";import{format as Gr}from"util";import{fileURLToPath as _n}from"url";import Mn from"timers";const Yr=function(){return typeof process<"u"&&process.release?.name==="node"?"NODE":typeof window<"u"?"WEB":typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?"WORKER":"NODE"}();if(Yr==="NODE"){let u=function(c){return new Promise(function(a,f){c.onload=c.onerror=function(o){c.onload=c.onerror=null,o.type==="load"?a(c.result):f(new Error("Failed to read the blob/file"))}})},n=function(){const c=new Uint8Array([1,2,3,4]),f=new File([c],"test").stream();try{return f.getReader({mode:"byob"}),!0}catch{return!1}};if(typeof File>"u"){class c extends Blob{constructor(f,o,t){super(f);let i;t?.lastModified&&(i=new Date),(!i||isNaN(i.getFullYear()))&&(i=new Date),this.lastModifiedDate=i,this.lastModified=i.getMilliseconds(),this.name=o||""}}global.File=c}typeof Blob.prototype.arrayBuffer>"u"&&(Blob.prototype.arrayBuffer=function(){const a=new FileReader;return a.readAsArrayBuffer(this),u(a)}),typeof Blob.prototype.text>"u"&&(Blob.prototype.text=function(){const a=new FileReader;return a.readAsText(this),u(a)}),(typeof Blob.prototype.stream>"u"||!n())&&(Blob.prototype.stream=function(){let c=0;const a=this;return new ReadableStream({type:"bytes",autoAllocateChunkSize:512*1024,async pull(f){const o=f.byobRequest.view,i=await a.slice(c,c+o.byteLength).arrayBuffer(),m=new Uint8Array(i);new Uint8Array(o.buffer).set(m);const N=m.byteLength;f.byobRequest.respond(N),c+=N,c>=a.size&&f.close()}})})}if(Yr==="NODE"&&typeof CustomEvent>"u"){class u extends Event{constructor(c,a={}){super(c,a),this.detail=a.detail}initCustomEvent(){}}globalThis.CustomEvent=u}const Pn="playground-log",Fn=(u,...n)=>{ht.dispatchEvent(new CustomEvent(Pn,{detail:{log:u,args:n}}))},Sn=(u,...n)=>{switch(typeof u.message=="string"?Reflect.set(u,"message",Ie(u.message)):u.message.message&&typeof u.message.message=="string"&&Reflect.set(u.message,"message",Ie(u.message.message)),u.severity){case ut.Debug:console.debug(u.message,...n);break;case ut.Info:console.info(u.message,...n);break;case ut.Warn:console.warn(u.message,...n);break;case ut.Error:console.error(u.message,...n);break;case ut.Fatal:console.error(u.message,...n);break;default:console.log(u.message,...n)}},Bn=u=>u instanceof Error?[u.message,u.stack].join(`
2
- `):JSON.stringify(u,null,2),zr=[],Ke=u=>{zr.push(u)},Kr=u=>{if(u.raw===!0)Ke(u.message);else{const n=Un(typeof u.message=="object"?Bn(u.message):u.message,u.severity,u.prefix??xt.JS);Ke(n)}},ut={Fatal:{},Error:{name:"error",level:1},Warn:{name:"warn",level:2},Log:{name:"log",level:3},Info:{name:"info",level:4},Debug:{name:"debug",level:5}},xt={JS:"JavaScript"};class Rn extends EventTarget{constructor(n=[]){super(),this.fatalErrorEvent="playground-fatal-error",this.severity=ut.Info,this.handlers=n}getLogs(){return this.handlers.includes(Kr)?[...zr]:(this.error(`Logs aren't stored because the logToMemory handler isn't registered.
1
+ import Ye from"os";import{readFileSync as Oe,writeFile as mn,statSync as yn,readdirSync as gn,lstatSync as wn,existsSync as bn,writeFileSync as Hr,mkdtempSync as ze,chmodSync as En}from"fs";import{rootCertificates as Tn}from"tls";import{LatestSupportedPHPVersion as xn,SupportedPHPVersionsList as Dn,PHP as vn}from"@php-wasm/universal";import{loadNodeRuntime as In,FileLockManagerForNode as Nn,useHostFilesystem as On}from"@php-wasm/node";import{WebSocketServer as Cn}from"ws";import An from"net";import"assert";import Pt,{resolve as Ce,normalize as Ln}from"path";import{format as Gr}from"util";import{fileURLToPath as _n}from"url";import{createHash as Mn}from"crypto";import Pn from"timers";const Yr=function(){return typeof process<"u"&&process.release?.name==="node"?"NODE":typeof window<"u"?"WEB":typeof WorkerGlobalScope<"u"&&self instanceof WorkerGlobalScope?"WORKER":"NODE"}();if(Yr==="NODE"){let u=function(c){return new Promise(function(a,f){c.onload=c.onerror=function(o){c.onload=c.onerror=null,o.type==="load"?a(c.result):f(new Error("Failed to read the blob/file"))}})},n=function(){const c=new Uint8Array([1,2,3,4]),f=new File([c],"test").stream();try{return f.getReader({mode:"byob"}),!0}catch{return!1}};if(typeof File>"u"){class c extends Blob{constructor(f,o,t){super(f);let i;t?.lastModified&&(i=new Date),(!i||isNaN(i.getFullYear()))&&(i=new Date),this.lastModifiedDate=i,this.lastModified=i.getMilliseconds(),this.name=o||""}}global.File=c}typeof Blob.prototype.arrayBuffer>"u"&&(Blob.prototype.arrayBuffer=function(){const a=new FileReader;return a.readAsArrayBuffer(this),u(a)}),typeof Blob.prototype.text>"u"&&(Blob.prototype.text=function(){const a=new FileReader;return a.readAsText(this),u(a)}),(typeof Blob.prototype.stream>"u"||!n())&&(Blob.prototype.stream=function(){let c=0;const a=this;return new ReadableStream({type:"bytes",autoAllocateChunkSize:512*1024,async pull(f){const o=f.byobRequest.view,i=await a.slice(c,c+o.byteLength).arrayBuffer(),m=new Uint8Array(i);new Uint8Array(o.buffer).set(m);const N=m.byteLength;f.byobRequest.respond(N),c+=N,c>=a.size&&f.close()}})})}if(Yr==="NODE"&&typeof CustomEvent>"u"){class u extends Event{constructor(c,a={}){super(c,a),this.detail=a.detail}initCustomEvent(){}}globalThis.CustomEvent=u}const Fn="playground-log",Sn=(u,...n)=>{ht.dispatchEvent(new CustomEvent(Fn,{detail:{log:u,args:n}}))},Bn=(u,...n)=>{switch(typeof u.message=="string"?Reflect.set(u,"message",Ie(u.message)):u.message.message&&typeof u.message.message=="string"&&Reflect.set(u.message,"message",Ie(u.message.message)),u.severity){case ut.Debug:console.debug(u.message,...n);break;case ut.Info:console.info(u.message,...n);break;case ut.Warn:console.warn(u.message,...n);break;case ut.Error:console.error(u.message,...n);break;case ut.Fatal:console.error(u.message,...n);break;default:console.log(u.message,...n)}},Rn=u=>u instanceof Error?[u.message,u.stack].join(`
2
+ `):JSON.stringify(u,null,2),zr=[],Ke=u=>{zr.push(u)},Kr=u=>{if(u.raw===!0)Ke(u.message);else{const n=Xn(typeof u.message=="object"?Rn(u.message):u.message,u.severity,u.prefix??xt.JS);Ke(n)}},ut={Fatal:{},Error:{name:"error",level:1},Warn:{name:"warn",level:2},Log:{name:"log",level:3},Info:{name:"info",level:4},Debug:{name:"debug",level:5}},xt={JS:"JavaScript"};class jn extends EventTarget{constructor(n=[]){super(),this.fatalErrorEvent="playground-fatal-error",this.severity=ut.Info,this.handlers=n}getLogs(){return this.handlers.includes(Kr)?[...zr]:(this.error(`Logs aren't stored because the logToMemory handler isn't registered.
3
3
  If you're using a custom logger instance, make sure to register logToMemory handler.
4
- `),[])}logMessage(n,...c){const a={...n,severity:n.severity??ut.Log};for(const f of this.handlers)a.severity.level<=this.severity.level&&f(a,...c)}setSeverityFilterLevel(n){this.severity=n}log(n,...c){this.logMessage({message:n,severity:ut.Log,prefix:xt.JS,raw:!1},...c)}debug(n,...c){this.logMessage({message:n,severity:ut.Debug,prefix:xt.JS,raw:!1},...c)}info(n,...c){this.logMessage({message:n,severity:ut.Info,prefix:xt.JS,raw:!1},...c)}warn(n,...c){this.logMessage({message:n,severity:ut.Warn,prefix:xt.JS,raw:!1},...c)}error(n,...c){this.logMessage({message:n,severity:ut.Error,prefix:xt.JS,raw:!1},...c)}}const jn=()=>{try{}catch{}return[Kr,Sn,Fn]},ht=new Rn(jn()),Ie=u=>u.replace(/\t/g,""),Un=(u,n,c)=>{const a=new Date,f=new Intl.DateTimeFormat("en-GB",{year:"numeric",month:"short",day:"2-digit",timeZone:"UTC"}).format(a).replace(/ /g,"-"),o=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZone:"UTC",timeZoneName:"short"}).format(a),t=f+" "+o;return u=Ie(u),`[${t}] ${c} ${n.name}: ${u}`};var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ae={exports:{}},Dt=typeof Reflect=="object"?Reflect:null,Qe=Dt&&typeof Dt.apply=="function"?Dt.apply:function(n,c,a){return Function.prototype.apply.call(n,c,a)},Mt;Dt&&typeof Dt.ownKeys=="function"?Mt=Dt.ownKeys:Object.getOwnPropertySymbols?Mt=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Mt=function(n){return Object.getOwnPropertyNames(n)};function Xn(u){console&&console.warn&&console.warn(u)}var Qr=Number.isNaN||function(n){return n!==n};function Z(){Z.init.call(this)}Ae.exports=Z;Ae.exports.once=$n;Z.EventEmitter=Z;Z.prototype._events=void 0;Z.prototype._eventsCount=0;Z.prototype._maxListeners=void 0;var Je=10;function Ft(u){if(typeof u!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof u)}Object.defineProperty(Z,"defaultMaxListeners",{enumerable:!0,get:function(){return Je},set:function(u){if(typeof u!="number"||u<0||Qr(u))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+u+".");Je=u}});Z.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Z.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||Qr(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function Jr(u){return u._maxListeners===void 0?Z.defaultMaxListeners:u._maxListeners}Z.prototype.getMaxListeners=function(){return Jr(this)};Z.prototype.emit=function(n){for(var c=[],a=1;a<arguments.length;a++)c.push(arguments[a]);var f=n==="error",o=this._events;if(o!==void 0)f=f&&o.error===void 0;else if(!f)return!1;if(f){var t;if(c.length>0&&(t=c[0]),t instanceof Error)throw t;var i=new Error("Unhandled error."+(t?" ("+t.message+")":""));throw i.context=t,i}var m=o[n];if(m===void 0)return!1;if(typeof m=="function")Qe(m,this,c);else for(var N=m.length,w=nn(m,N),a=0;a<N;++a)Qe(w[a],this,c);return!0};function Zr(u,n,c,a){var f,o,t;if(Ft(c),o=u._events,o===void 0?(o=u._events=Object.create(null),u._eventsCount=0):(o.newListener!==void 0&&(u.emit("newListener",n,c.listener?c.listener:c),o=u._events),t=o[n]),t===void 0)t=o[n]=c,++u._eventsCount;else if(typeof t=="function"?t=o[n]=a?[c,t]:[t,c]:a?t.unshift(c):t.push(c),f=Jr(u),f>0&&t.length>f&&!t.warned){t.warned=!0;var i=new Error("Possible EventEmitter memory leak detected. "+t.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");i.name="MaxListenersExceededWarning",i.emitter=u,i.type=n,i.count=t.length,Xn(i)}return u}Z.prototype.addListener=function(n,c){return Zr(this,n,c,!1)};Z.prototype.on=Z.prototype.addListener;Z.prototype.prependListener=function(n,c){return Zr(this,n,c,!0)};function qn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function tn(u,n,c){var a={fired:!1,wrapFn:void 0,target:u,type:n,listener:c},f=qn.bind(a);return f.listener=c,a.wrapFn=f,f}Z.prototype.once=function(n,c){return Ft(c),this.on(n,tn(this,n,c)),this};Z.prototype.prependOnceListener=function(n,c){return Ft(c),this.prependListener(n,tn(this,n,c)),this};Z.prototype.removeListener=function(n,c){var a,f,o,t,i;if(Ft(c),f=this._events,f===void 0)return this;if(a=f[n],a===void 0)return this;if(a===c||a.listener===c)--this._eventsCount===0?this._events=Object.create(null):(delete f[n],f.removeListener&&this.emit("removeListener",n,a.listener||c));else if(typeof a!="function"){for(o=-1,t=a.length-1;t>=0;t--)if(a[t]===c||a[t].listener===c){i=a[t].listener,o=t;break}if(o<0)return this;o===0?a.shift():kn(a,o),a.length===1&&(f[n]=a[0]),f.removeListener!==void 0&&this.emit("removeListener",n,i||c)}return this};Z.prototype.off=Z.prototype.removeListener;Z.prototype.removeAllListeners=function(n){var c,a,f;if(a=this._events,a===void 0)return this;if(a.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):a[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete a[n]),this;if(arguments.length===0){var o=Object.keys(a),t;for(f=0;f<o.length;++f)t=o[f],t!=="removeListener"&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(c=a[n],typeof c=="function")this.removeListener(n,c);else if(c!==void 0)for(f=c.length-1;f>=0;f--)this.removeListener(n,c[f]);return this};function en(u,n,c){var a=u._events;if(a===void 0)return[];var f=a[n];return f===void 0?[]:typeof f=="function"?c?[f.listener||f]:[f]:c?Vn(f):nn(f,f.length)}Z.prototype.listeners=function(n){return en(this,n,!0)};Z.prototype.rawListeners=function(n){return en(this,n,!1)};Z.listenerCount=function(u,n){return typeof u.listenerCount=="function"?u.listenerCount(n):rn.call(u,n)};Z.prototype.listenerCount=rn;function rn(u){var n=this._events;if(n!==void 0){var c=n[u];if(typeof c=="function")return 1;if(c!==void 0)return c.length}return 0}Z.prototype.eventNames=function(){return this._eventsCount>0?Mt(this._events):[]};function nn(u,n){for(var c=new Array(n),a=0;a<n;++a)c[a]=u[a];return c}function kn(u,n){for(;n+1<u.length;n++)u[n]=u[n+1];u.pop()}function Vn(u){for(var n=new Array(u.length),c=0;c<n.length;++c)n[c]=u[c].listener||u[c];return n}function $n(u,n){return new Promise(function(c,a){function f(t){u.removeListener(n,o),a(t)}function o(){typeof u.removeListener=="function"&&u.removeListener("error",f),c([].slice.call(arguments))}on(u,n,o,{once:!0}),n!=="error"&&Wn(u,f,{once:!0})})}function Wn(u,n,c){typeof u.on=="function"&&on(u,"error",n,c)}function on(u,n,c,a){if(typeof u.on=="function")a.once?u.once(n,c):u.on(n,c);else if(typeof u.addEventListener=="function")u.addEventListener(n,function f(o){a.once&&u.removeEventListener(n,f),c(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof u)}var Le=Ae.exports;class Hn extends Le.EventEmitter{constructor(n=9229){super(),this.ws=null,this.connected=!1,this.buffer=[],this.wss=new Cn({port:n}),this.wss.on("connection",c=>{if(this.ws){c.close();return}this.ws=c,this.emit("clientConnected"),c.on("message",a=>{ht.debug("\x1B[1;32m[CDP][received]\x1B[0m",a.toString());let f;try{f=JSON.parse(a.toString())}catch{return}this.connected?this.emit("message",f):this.buffer.push(f)}),c.on("close",()=>{this.ws=null,this.emit("clientDisconnected")}),c.on("error",a=>{this.emit("error",a)})}),this.on("newListener",c=>{c==="message"&&process.nextTick(()=>{for(const a of this.buffer)this.emit("message",a);this.buffer=[],this.connected=!0})})}sendMessage(n){if(!this.ws||this.ws.readyState!==this.ws.OPEN)return;const c=JSON.stringify(n);ht.debug("\x1B[1;32m[CDP][send]\x1B[0m",c),this.ws.send(c)}close(){this.wss.close()}}class Gn extends Le.EventEmitter{constructor(n=9003){super(),this.socket=null,this.buffer="",this.expectedLength=null,this.server=An.createServer(),this.server.on("connection",c=>{if(this.socket){c.destroy();return}this.socket=c,c.setEncoding("utf8"),this.emit("connected"),c.on("data",a=>this.onData(a.toString())),c.on("close",()=>{this.socket=null,this.emit("disconnected")}),c.on("error",a=>{this.emit("error",a)})}),this.server.listen(n)}onData(n){for(ht.debug("\x1B[1;32m[XDebug][received]]\x1B[0m",n),this.buffer+=n;;){if(this.expectedLength===null){const c=this.buffer.indexOf("\0");if(c===-1)break;const a=this.buffer.substring(0,c),f=parseInt(a,10);if(isNaN(f)){this.buffer="";break}this.expectedLength=f,this.buffer=this.buffer.slice(c+1)}if(this.expectedLength!==null&&this.buffer.length>=this.expectedLength){const c=this.buffer.substring(0,this.expectedLength);this.buffer=this.buffer.slice(this.expectedLength),this.buffer.startsWith("\0")&&(this.buffer=this.buffer.slice(1));const a=c.trim();this.expectedLength=null,this.emit("message",a);continue}break}}sendCommand(n){this.socket&&(ht.debug("\x1B[1;32m[XDebug][send]\x1B[0m",n),this.socket.write(n+"\0"))}close(){this.server.close()}}/**
4
+ `),[])}logMessage(n,...c){const a={...n,severity:n.severity??ut.Log};for(const f of this.handlers)a.severity.level<=this.severity.level&&f(a,...c)}setSeverityFilterLevel(n){this.severity=n}log(n,...c){this.logMessage({message:n,severity:ut.Log,prefix:xt.JS,raw:!1},...c)}debug(n,...c){this.logMessage({message:n,severity:ut.Debug,prefix:xt.JS,raw:!1},...c)}info(n,...c){this.logMessage({message:n,severity:ut.Info,prefix:xt.JS,raw:!1},...c)}warn(n,...c){this.logMessage({message:n,severity:ut.Warn,prefix:xt.JS,raw:!1},...c)}error(n,...c){this.logMessage({message:n,severity:ut.Error,prefix:xt.JS,raw:!1},...c)}}const Un=()=>{try{}catch{}return[Kr,Bn,Sn]},ht=new jn(Un()),Ie=u=>u.replace(/\t/g,""),Xn=(u,n,c)=>{const a=new Date,f=new Intl.DateTimeFormat("en-GB",{year:"numeric",month:"short",day:"2-digit",timeZone:"UTC"}).format(a).replace(/ /g,"-"),o=new Intl.DateTimeFormat("en-GB",{hour:"2-digit",minute:"2-digit",second:"2-digit",hour12:!1,timeZone:"UTC",timeZoneName:"short"}).format(a),t=f+" "+o;return u=Ie(u),`[${t}] ${c} ${n.name}: ${u}`};var G=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},Ae={exports:{}},Dt=typeof Reflect=="object"?Reflect:null,Qe=Dt&&typeof Dt.apply=="function"?Dt.apply:function(n,c,a){return Function.prototype.apply.call(n,c,a)},Mt;Dt&&typeof Dt.ownKeys=="function"?Mt=Dt.ownKeys:Object.getOwnPropertySymbols?Mt=function(n){return Object.getOwnPropertyNames(n).concat(Object.getOwnPropertySymbols(n))}:Mt=function(n){return Object.getOwnPropertyNames(n)};function qn(u){console&&console.warn&&console.warn(u)}var Qr=Number.isNaN||function(n){return n!==n};function Z(){Z.init.call(this)}Ae.exports=Z;Ae.exports.once=Wn;Z.EventEmitter=Z;Z.prototype._events=void 0;Z.prototype._eventsCount=0;Z.prototype._maxListeners=void 0;var Je=10;function Ft(u){if(typeof u!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof u)}Object.defineProperty(Z,"defaultMaxListeners",{enumerable:!0,get:function(){return Je},set:function(u){if(typeof u!="number"||u<0||Qr(u))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+u+".");Je=u}});Z.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0};Z.prototype.setMaxListeners=function(n){if(typeof n!="number"||n<0||Qr(n))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+n+".");return this._maxListeners=n,this};function Jr(u){return u._maxListeners===void 0?Z.defaultMaxListeners:u._maxListeners}Z.prototype.getMaxListeners=function(){return Jr(this)};Z.prototype.emit=function(n){for(var c=[],a=1;a<arguments.length;a++)c.push(arguments[a]);var f=n==="error",o=this._events;if(o!==void 0)f=f&&o.error===void 0;else if(!f)return!1;if(f){var t;if(c.length>0&&(t=c[0]),t instanceof Error)throw t;var i=new Error("Unhandled error."+(t?" ("+t.message+")":""));throw i.context=t,i}var m=o[n];if(m===void 0)return!1;if(typeof m=="function")Qe(m,this,c);else for(var N=m.length,w=nn(m,N),a=0;a<N;++a)Qe(w[a],this,c);return!0};function Zr(u,n,c,a){var f,o,t;if(Ft(c),o=u._events,o===void 0?(o=u._events=Object.create(null),u._eventsCount=0):(o.newListener!==void 0&&(u.emit("newListener",n,c.listener?c.listener:c),o=u._events),t=o[n]),t===void 0)t=o[n]=c,++u._eventsCount;else if(typeof t=="function"?t=o[n]=a?[c,t]:[t,c]:a?t.unshift(c):t.push(c),f=Jr(u),f>0&&t.length>f&&!t.warned){t.warned=!0;var i=new Error("Possible EventEmitter memory leak detected. "+t.length+" "+String(n)+" listeners added. Use emitter.setMaxListeners() to increase limit");i.name="MaxListenersExceededWarning",i.emitter=u,i.type=n,i.count=t.length,qn(i)}return u}Z.prototype.addListener=function(n,c){return Zr(this,n,c,!1)};Z.prototype.on=Z.prototype.addListener;Z.prototype.prependListener=function(n,c){return Zr(this,n,c,!0)};function kn(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function tn(u,n,c){var a={fired:!1,wrapFn:void 0,target:u,type:n,listener:c},f=kn.bind(a);return f.listener=c,a.wrapFn=f,f}Z.prototype.once=function(n,c){return Ft(c),this.on(n,tn(this,n,c)),this};Z.prototype.prependOnceListener=function(n,c){return Ft(c),this.prependListener(n,tn(this,n,c)),this};Z.prototype.removeListener=function(n,c){var a,f,o,t,i;if(Ft(c),f=this._events,f===void 0)return this;if(a=f[n],a===void 0)return this;if(a===c||a.listener===c)--this._eventsCount===0?this._events=Object.create(null):(delete f[n],f.removeListener&&this.emit("removeListener",n,a.listener||c));else if(typeof a!="function"){for(o=-1,t=a.length-1;t>=0;t--)if(a[t]===c||a[t].listener===c){i=a[t].listener,o=t;break}if(o<0)return this;o===0?a.shift():Vn(a,o),a.length===1&&(f[n]=a[0]),f.removeListener!==void 0&&this.emit("removeListener",n,i||c)}return this};Z.prototype.off=Z.prototype.removeListener;Z.prototype.removeAllListeners=function(n){var c,a,f;if(a=this._events,a===void 0)return this;if(a.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):a[n]!==void 0&&(--this._eventsCount===0?this._events=Object.create(null):delete a[n]),this;if(arguments.length===0){var o=Object.keys(a),t;for(f=0;f<o.length;++f)t=o[f],t!=="removeListener"&&this.removeAllListeners(t);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(c=a[n],typeof c=="function")this.removeListener(n,c);else if(c!==void 0)for(f=c.length-1;f>=0;f--)this.removeListener(n,c[f]);return this};function en(u,n,c){var a=u._events;if(a===void 0)return[];var f=a[n];return f===void 0?[]:typeof f=="function"?c?[f.listener||f]:[f]:c?$n(f):nn(f,f.length)}Z.prototype.listeners=function(n){return en(this,n,!0)};Z.prototype.rawListeners=function(n){return en(this,n,!1)};Z.listenerCount=function(u,n){return typeof u.listenerCount=="function"?u.listenerCount(n):rn.call(u,n)};Z.prototype.listenerCount=rn;function rn(u){var n=this._events;if(n!==void 0){var c=n[u];if(typeof c=="function")return 1;if(c!==void 0)return c.length}return 0}Z.prototype.eventNames=function(){return this._eventsCount>0?Mt(this._events):[]};function nn(u,n){for(var c=new Array(n),a=0;a<n;++a)c[a]=u[a];return c}function Vn(u,n){for(;n+1<u.length;n++)u[n]=u[n+1];u.pop()}function $n(u){for(var n=new Array(u.length),c=0;c<n.length;++c)n[c]=u[c].listener||u[c];return n}function Wn(u,n){return new Promise(function(c,a){function f(t){u.removeListener(n,o),a(t)}function o(){typeof u.removeListener=="function"&&u.removeListener("error",f),c([].slice.call(arguments))}on(u,n,o,{once:!0}),n!=="error"&&Hn(u,f,{once:!0})})}function Hn(u,n,c){typeof u.on=="function"&&on(u,"error",n,c)}function on(u,n,c,a){if(typeof u.on=="function")a.once?u.once(n,c):u.on(n,c);else if(typeof u.addEventListener=="function")u.addEventListener(n,function f(o){a.once&&u.removeEventListener(n,f),c(o)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof u)}var Le=Ae.exports;class Gn extends Le.EventEmitter{constructor(n=9229){super(),this.ws=null,this.connected=!1,this.buffer=[],this.wss=new Cn({port:n}),this.wss.on("connection",c=>{if(this.ws){c.close();return}this.ws=c,this.emit("clientConnected"),c.on("message",a=>{ht.debug("\x1B[1;32m[CDP][received]\x1B[0m",a.toString());let f;try{f=JSON.parse(a.toString())}catch{return}this.connected?this.emit("message",f):this.buffer.push(f)}),c.on("close",()=>{this.ws=null,this.emit("clientDisconnected")}),c.on("error",a=>{this.emit("error",a)})}),this.on("newListener",c=>{c==="message"&&process.nextTick(()=>{for(const a of this.buffer)this.emit("message",a);this.buffer=[],this.connected=!0})})}sendMessage(n){if(!this.ws||this.ws.readyState!==this.ws.OPEN)return;const c=JSON.stringify(n);ht.debug("\x1B[1;32m[CDP][send]\x1B[0m",c),this.ws.send(c)}close(){this.wss.close()}}class Yn extends Le.EventEmitter{constructor(n=9003){super(),this.socket=null,this.buffer="",this.expectedLength=null,this.server=An.createServer(),this.server.on("connection",c=>{if(this.socket){c.destroy();return}this.socket=c,c.setEncoding("utf8"),this.emit("connected"),c.on("data",a=>this.onData(a.toString())),c.on("close",()=>{this.socket=null,this.emit("disconnected")}),c.on("error",a=>{this.emit("error",a)})}),this.server.listen(n)}onData(n){for(ht.debug("\x1B[1;32m[XDebug][received]]\x1B[0m",n),this.buffer+=n;;){if(this.expectedLength===null){const c=this.buffer.indexOf("\0");if(c===-1)break;const a=this.buffer.substring(0,c),f=parseInt(a,10);if(isNaN(f)){this.buffer="";break}this.expectedLength=f,this.buffer=this.buffer.slice(c+1)}if(this.expectedLength!==null&&this.buffer.length>=this.expectedLength){const c=this.buffer.substring(0,this.expectedLength);this.buffer=this.buffer.slice(this.expectedLength),this.buffer.startsWith("\0")&&(this.buffer=this.buffer.slice(1));const a=c.trim();this.expectedLength=null,this.emit("message",a);continue}break}}sendCommand(n){this.socket&&(ht.debug("\x1B[1;32m[XDebug][send]\x1B[0m",n),this.socket.write(n+"\0"))}close(){this.server.close()}}/**
5
5
  * @license
6
6
  * Copyright (c) 2016, Contributors
7
7
  * SPDX-License-Identifier: ISC
8
- */function At(u){if(u!==u.toLowerCase()&&u!==u.toUpperCase()||(u=u.toLowerCase()),u.indexOf("-")===-1&&u.indexOf("_")===-1)return u;{let c="",a=!1;const f=u.match(/^-+/);for(let o=f?f[0].length:0;o<u.length;o++){let t=u.charAt(o);a&&(a=!1,t=t.toUpperCase()),o!==0&&(t==="-"||t==="_")?a=!0:t!=="-"&&t!=="_"&&(c+=t)}return c}}function Yn(u,n){const c=u.toLowerCase();n=n||"-";let a="";for(let f=0;f<u.length;f++){const o=c.charAt(f),t=u.charAt(f);o!==t&&f>0?a+=`${n}${c.charAt(f)}`:a+=t}return a}function zn(u){return u==null?!1:typeof u=="number"||/^0x[0-9a-f]+$/i.test(u)?!0:/^0[^.]/.test(u)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(u)}/**
8
+ */function At(u){if(u!==u.toLowerCase()&&u!==u.toUpperCase()||(u=u.toLowerCase()),u.indexOf("-")===-1&&u.indexOf("_")===-1)return u;{let c="",a=!1;const f=u.match(/^-+/);for(let o=f?f[0].length:0;o<u.length;o++){let t=u.charAt(o);a&&(a=!1,t=t.toUpperCase()),o!==0&&(t==="-"||t==="_")?a=!0:t!=="-"&&t!=="_"&&(c+=t)}return c}}function zn(u,n){const c=u.toLowerCase();n=n||"-";let a="";for(let f=0;f<u.length;f++){const o=c.charAt(f),t=u.charAt(f);o!==t&&f>0?a+=`${n}${c.charAt(f)}`:a+=t}return a}function Kn(u){return u==null?!1:typeof u=="number"||/^0x[0-9a-f]+$/i.test(u)?!0:/^0[^.]/.test(u)?!1:/^[-]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(u)}/**
9
9
  * @license
10
10
  * Copyright (c) 2016, Contributors
11
11
  * SPDX-License-Identifier: ISC
12
- */function Kn(u){if(Array.isArray(u))return u.map(t=>typeof t!="string"?t+"":t);u=u.trim();let n=0,c=null,a=null,f=null;const o=[];for(let t=0;t<u.length;t++){if(c=a,a=u.charAt(t),a===" "&&!f){c!==" "&&n++;continue}a===f?f=null:(a==="'"||a==='"')&&!f&&(f=a),o[n]||(o[n]=""),o[n]+=a}return o}/**
12
+ */function Qn(u){if(Array.isArray(u))return u.map(t=>typeof t!="string"?t+"":t);u=u.trim();let n=0,c=null,a=null,f=null;const o=[];for(let t=0;t<u.length;t++){if(c=a,a=u.charAt(t),a===" "&&!f){c!==" "&&n++;continue}a===f?f=null:(a==="'"||a==='"')&&!f&&(f=a),o[n]||(o[n]=""),o[n]+=a}return o}/**
13
13
  * @license
14
14
  * Copyright (c) 2016, Contributors
15
15
  * SPDX-License-Identifier: ISC
@@ -17,14 +17,14 @@ import Ye from"os";import{readFileSync as Oe,writeFile as mn,statSync as yn,read
17
17
  * @license
18
18
  * Copyright (c) 2016, Contributors
19
19
  * SPDX-License-Identifier: ISC
20
- */let pt;class Qn{constructor(n){pt=n}parse(n,c){const a=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},c),f=Kn(n),o=typeof n=="string",t=Jn(Object.assign(Object.create(null),a.alias)),i=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},a.configuration),m=Object.assign(Object.create(null),a.default),N=a.configObjects||[],w=a.envPrefix,g=i["populate--"],b=g?"--":"_",x=Object.create(null),O=Object.create(null),_=a.__||pt.format,E={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},D=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,T=new RegExp("^--"+i["negation-prefix"]+"(.+)");[].concat(a.array||[]).filter(Boolean).forEach(function(C){const s=typeof C=="object"?C.key:C,e=Object.keys(C).map(function(r){return{boolean:"bools",string:"strings",number:"numbers"}[r]}).filter(Boolean).pop();e&&(E[e][s]=!0),E.arrays[s]=!0,E.keys.push(s)}),[].concat(a.boolean||[]).filter(Boolean).forEach(function(C){E.bools[C]=!0,E.keys.push(C)}),[].concat(a.string||[]).filter(Boolean).forEach(function(C){E.strings[C]=!0,E.keys.push(C)}),[].concat(a.number||[]).filter(Boolean).forEach(function(C){E.numbers[C]=!0,E.keys.push(C)}),[].concat(a.count||[]).filter(Boolean).forEach(function(C){E.counts[C]=!0,E.keys.push(C)}),[].concat(a.normalize||[]).filter(Boolean).forEach(function(C){E.normalize[C]=!0,E.keys.push(C)}),typeof a.narg=="object"&&Object.entries(a.narg).forEach(([C,s])=>{typeof s=="number"&&(E.nargs[C]=s,E.keys.push(C))}),typeof a.coerce=="object"&&Object.entries(a.coerce).forEach(([C,s])=>{typeof s=="function"&&(E.coercions[C]=s,E.keys.push(C))}),typeof a.config<"u"&&(Array.isArray(a.config)||typeof a.config=="string"?[].concat(a.config).filter(Boolean).forEach(function(C){E.configs[C]=!0}):typeof a.config=="object"&&Object.entries(a.config).forEach(([C,s])=>{(typeof s=="boolean"||typeof s=="function")&&(E.configs[C]=s)})),Tt(a.key,t,a.default,E.arrays),Object.keys(m).forEach(function(C){(E.aliases[C]||[]).forEach(function(s){m[s]=m[C]})});let p=null;it();let I=[];const A=Object.assign(Object.create(null),{_:[]}),j={};for(let C=0;C<f.length;C++){const s=f[C],e=s.replace(/^-{3,}/,"---");let r,l,v,M,P,q;if(s!=="--"&&/^-/.test(s)&&d(s))U(s);else if(e.match(/^---+(=|$)/)){U(s);continue}else if(s.match(/^--.+=/)||!i["short-option-groups"]&&s.match(/^-.+=/))M=s.match(/^--?([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3&&(k(M[1],E.arrays)?C=h(C,M[1],f,M[2]):k(M[1],E.nargs)!==!1?C=B(C,M[1],f,M[2]):F(M[1],M[2],!0));else if(s.match(T)&&i["boolean-negation"])M=s.match(T),M!==null&&Array.isArray(M)&&M.length>=2&&(l=M[1],F(l,k(l,E.arrays)?[!1]:!1));else if(s.match(/^--.+/)||!i["short-option-groups"]&&s.match(/^-[^-]+/))M=s.match(/^--?(.+)/),M!==null&&Array.isArray(M)&&M.length>=2&&(l=M[1],k(l,E.arrays)?C=h(C,l,f):k(l,E.nargs)!==!1?C=B(C,l,f):(P=f[C+1],P!==void 0&&(!P.match(/^-/)||P.match(D))&&!k(l,E.bools)&&!k(l,E.counts)||/^(true|false)$/.test(P)?(F(l,P),C++):F(l,L(l))));else if(s.match(/^-.\..+=/))M=s.match(/^-([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3&&F(M[1],M[2]);else if(s.match(/^-.\..+/)&&!s.match(D))P=f[C+1],M=s.match(/^-(.\..+)/),M!==null&&Array.isArray(M)&&M.length>=2&&(l=M[1],P!==void 0&&!P.match(/^-/)&&!k(l,E.bools)&&!k(l,E.counts)?(F(l,P),C++):F(l,L(l)));else if(s.match(/^-[^-]+/)&&!s.match(D)){v=s.slice(1,-1).split(""),r=!1;for(let V=0;V<v.length;V++){if(P=s.slice(V+2),v[V+1]&&v[V+1]==="="){q=s.slice(V+3),l=v[V],k(l,E.arrays)?C=h(C,l,f,q):k(l,E.nargs)!==!1?C=B(C,l,f,q):F(l,q),r=!0;break}if(P==="-"){F(v[V],P);continue}if(/[A-Za-z]/.test(v[V])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(P)&&k(P,E.bools)===!1){F(v[V],P),r=!0;break}if(v[V+1]&&v[V+1].match(/\W/)){F(v[V],P),r=!0;break}else F(v[V],L(v[V]))}l=s.slice(-1)[0],!r&&l!=="-"&&(k(l,E.arrays)?C=h(C,l,f):k(l,E.nargs)!==!1?C=B(C,l,f):(P=f[C+1],P!==void 0&&(!/^(-|--)[^-]/.test(P)||P.match(D))&&!k(l,E.bools)&&!k(l,E.counts)||/^(true|false)$/.test(P)?(F(l,P),C++):F(l,L(l))))}else if(s.match(/^-[0-9]$/)&&s.match(D)&&k(s.slice(1),E.bools))l=s.slice(1),F(l,L(l));else if(s==="--"){I=f.slice(C+1);break}else if(i["halt-at-non-option"]){I=f.slice(C);break}else U(s)}W(A,!0),W(A,!1),Y(A),z(),gt(A,E.aliases,m,!0),vt(A),i["set-placeholder-key"]&&bt(A),Object.keys(E.counts).forEach(function(C){Q(A,C.split("."))||F(C,0)}),g&&I.length&&(A[b]=[]),I.forEach(function(C){A[b].push(C)}),i["camel-case-expansion"]&&i["strip-dashed"]&&Object.keys(A).filter(C=>C!=="--"&&C.includes("-")).forEach(C=>{delete A[C]}),i["strip-aliased"]&&[].concat(...Object.keys(t).map(C=>t[C])).forEach(C=>{i["camel-case-expansion"]&&C.includes("-")&&delete A[C.split(".").map(s=>At(s)).join(".")],delete A[C]});function U(C){const s=$("_",C);(typeof s=="string"||typeof s=="number")&&A._.push(s)}function B(C,s,e,r){let l,v=k(s,E.nargs);if(v=typeof v!="number"||isNaN(v)?1:v,v===0)return H(r)||(p=Error(_("Argument unexpected for: %s",s))),F(s,L(s)),C;let M=H(r)?0:1;if(i["nargs-eats-options"])e.length-(C+1)+M<v&&(p=Error(_("Not enough arguments following: %s",s))),M=v;else{for(l=C+1;l<e.length&&(!e[l].match(/^-[^0-9]/)||e[l].match(D)||d(e[l]));l++)M++;M<v&&(p=Error(_("Not enough arguments following: %s",s)))}let P=Math.min(M,v);for(!H(r)&&P>0&&(F(s,r),P--),l=C+1;l<P+C+1;l++)F(s,e[l]);return C+P}function h(C,s,e,r){let l=[],v=r||e[C+1];const M=k(s,E.nargs);if(k(s,E.bools)&&!/^(true|false)$/.test(v))l.push(!0);else if(H(v)||H(r)&&/^-/.test(v)&&!D.test(v)&&!d(v)){if(m[s]!==void 0){const P=m[s];l=Array.isArray(P)?P:[P]}}else{H(r)||l.push(X(s,r,!0));for(let P=C+1;P<e.length&&!(!i["greedy-arrays"]&&l.length>0||M&&typeof M=="number"&&l.length>=M||(v=e[P],/^-/.test(v)&&!D.test(v)&&!d(v)));P++)C=P,l.push(X(s,v,o))}return typeof M=="number"&&(M&&l.length<M||isNaN(M)&&l.length===0)&&(p=Error(_("Not enough arguments following: %s",s))),F(s,l),C}function F(C,s,e=o){if(/-/.test(C)&&i["camel-case-expansion"]){const v=C.split(".").map(function(M){return At(M)}).join(".");R(C,v)}const r=X(C,s,e),l=C.split(".");et(A,l,r),E.aliases[C]&&E.aliases[C].forEach(function(v){const M=v.split(".");et(A,M,r)}),l.length>1&&i["dot-notation"]&&(E.aliases[l[0]]||[]).forEach(function(v){let M=v.split(".");const P=[].concat(l);P.shift(),M=M.concat(P),(E.aliases[C]||[]).includes(M.join("."))||et(A,M,r)}),k(C,E.normalize)&&!k(C,E.arrays)&&[C].concat(E.aliases[C]||[]).forEach(function(M){Object.defineProperty(j,M,{enumerable:!0,get(){return s},set(P){s=typeof P=="string"?pt.normalize(P):P}})})}function R(C,s){E.aliases[C]&&E.aliases[C].length||(E.aliases[C]=[s],x[s]=!0),E.aliases[s]&&E.aliases[s].length||R(s,C)}function X(C,s,e){e&&(s=Zn(s)),(k(C,E.bools)||k(C,E.counts))&&typeof s=="string"&&(s=s==="true");let r=Array.isArray(s)?s.map(function(l){return $(C,l)}):$(C,s);return k(C,E.counts)&&(H(r)||typeof r=="boolean")&&(r=Rt()),k(C,E.normalize)&&k(C,E.arrays)&&(Array.isArray(s)?r=s.map(l=>pt.normalize(l)):r=pt.normalize(s)),r}function $(C,s){return!i["parse-positional-numbers"]&&C==="_"||!k(C,E.strings)&&!k(C,E.bools)&&!Array.isArray(s)&&(zn(s)&&i["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${s}`)))||!H(s)&&k(C,E.numbers))&&(s=Number(s)),s}function Y(C){const s=Object.create(null);gt(s,E.aliases,m),Object.keys(E.configs).forEach(function(e){const r=C[e]||s[e];if(r)try{let l=null;const v=pt.resolve(pt.cwd(),r),M=E.configs[e];if(typeof M=="function"){try{l=M(v)}catch(P){l=P}if(l instanceof Error){p=l;return}}else l=pt.require(v);J(l)}catch(l){l.name==="PermissionDenied"?p=l:C[e]&&(p=Error(_("Invalid JSON config file: %s",r)))}})}function J(C,s){Object.keys(C).forEach(function(e){const r=C[e],l=s?s+"."+e:e;typeof r=="object"&&r!==null&&!Array.isArray(r)&&i["dot-notation"]?J(r,l):(!Q(A,l.split("."))||k(l,E.arrays)&&i["combine-arrays"])&&F(l,r)})}function z(){typeof N<"u"&&N.forEach(function(C){J(C)})}function W(C,s){if(typeof w>"u")return;const e=typeof w=="string"?w:"",r=pt.env();Object.keys(r).forEach(function(l){if(e===""||l.lastIndexOf(e,0)===0){const v=l.split("__").map(function(M,P){return P===0&&(M=M.substring(e.length)),At(M)});(s&&E.configs[v.join(".")]||!s)&&!Q(C,v)&&F(v.join("."),r[l])}})}function vt(C){let s;const e=new Set;Object.keys(C).forEach(function(r){if(!e.has(r)&&(s=k(r,E.coercions),typeof s=="function"))try{const l=$(r,s(C[r]));[].concat(E.aliases[r]||[],r).forEach(v=>{e.add(v),C[v]=l})}catch(l){p=l}})}function bt(C){return E.keys.forEach(s=>{~s.indexOf(".")||typeof C[s]>"u"&&(C[s]=void 0)}),C}function gt(C,s,e,r=!1){Object.keys(e).forEach(function(l){Q(C,l.split("."))||(et(C,l.split("."),e[l]),r&&(O[l]=!0),(s[l]||[]).forEach(function(v){Q(C,v.split("."))||et(C,v.split("."),e[l])}))})}function Q(C,s){let e=C;i["dot-notation"]||(s=[s.join(".")]),s.slice(0,-1).forEach(function(l){e=e[l]||{}});const r=s[s.length-1];return typeof e!="object"?!1:r in e}function et(C,s,e){let r=C;i["dot-notation"]||(s=[s.join(".")]),s.slice(0,-1).forEach(function(q){q=Ze(q),typeof r=="object"&&r[q]===void 0&&(r[q]={}),typeof r[q]!="object"||Array.isArray(r[q])?(Array.isArray(r[q])?r[q].push({}):r[q]=[r[q],{}],r=r[q][r[q].length-1]):r=r[q]});const l=Ze(s[s.length-1]),v=k(s.join("."),E.arrays),M=Array.isArray(e);let P=i["duplicate-arguments-array"];!P&&k(l,E.nargs)&&(P=!0,(!H(r[l])&&E.nargs[l]===1||Array.isArray(r[l])&&r[l].length===E.nargs[l])&&(r[l]=void 0)),e===Rt()?r[l]=Rt(r[l]):Array.isArray(r[l])?P&&v&&M?r[l]=i["flatten-duplicate-arrays"]?r[l].concat(e):(Array.isArray(r[l][0])?r[l]:[r[l]]).concat([e]):!P&&!!v==!!M?r[l]=e:r[l]=r[l].concat([e]):r[l]===void 0&&v?r[l]=M?e:[e]:P&&!(r[l]===void 0||k(l,E.counts)||k(l,E.bools))?r[l]=[r[l],e]:r[l]=e}function Tt(...C){C.forEach(function(s){Object.keys(s||{}).forEach(function(e){E.aliases[e]||(E.aliases[e]=[].concat(t[e]||[]),E.aliases[e].concat(e).forEach(function(r){if(/-/.test(r)&&i["camel-case-expansion"]){const l=At(r);l!==e&&E.aliases[e].indexOf(l)===-1&&(E.aliases[e].push(l),x[l]=!0)}}),E.aliases[e].concat(e).forEach(function(r){if(r.length>1&&/[A-Z]/.test(r)&&i["camel-case-expansion"]){const l=Yn(r,"-");l!==e&&E.aliases[e].indexOf(l)===-1&&(E.aliases[e].push(l),x[l]=!0)}}),E.aliases[e].forEach(function(r){E.aliases[r]=[e].concat(E.aliases[e].filter(function(l){return r!==l}))}))})})}function k(C,s){const e=[].concat(E.aliases[C]||[],C),r=Object.keys(s),l=e.find(v=>r.includes(v));return l?s[l]:!1}function wt(C){const s=Object.keys(E);return[].concat(s.map(r=>E[r])).some(function(r){return Array.isArray(r)?r.includes(C):r[C]})}function It(C,...s){return[].concat(...s).some(function(r){const l=C.match(r);return l&&wt(l[1])})}function y(C){if(C.match(D)||!C.match(/^-[^-]+/))return!1;let s=!0,e;const r=C.slice(1).split("");for(let l=0;l<r.length;l++){if(e=C.slice(l+2),!wt(r[l])){s=!1;break}if(r[l+1]&&r[l+1]==="="||e==="-"||/[A-Za-z]/.test(r[l])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(e)||r[l+1]&&r[l+1].match(/\W/))break}return s}function d(C){return i["unknown-options-as-args"]&&S(C)}function S(C){return C=C.replace(/^-{3,}/,"--"),C.match(D)||y(C)?!1:!It(C,/^-+([^=]+?)=[\s\S]*$/,T,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function L(C){return!k(C,E.bools)&&!k(C,E.counts)&&`${C}`in m?m[C]:K(tt(C))}function K(C){return{[ft.BOOLEAN]:!0,[ft.STRING]:"",[ft.NUMBER]:void 0,[ft.ARRAY]:[]}[C]}function tt(C){let s=ft.BOOLEAN;return k(C,E.strings)?s=ft.STRING:k(C,E.numbers)?s=ft.NUMBER:k(C,E.bools)?s=ft.BOOLEAN:k(C,E.arrays)&&(s=ft.ARRAY),s}function H(C){return C===void 0}function it(){Object.keys(E.counts).find(C=>k(C,E.arrays)?(p=Error(_("Invalid configuration: %s, opts.count excludes opts.array.",C)),!0):k(C,E.nargs)?(p=Error(_("Invalid configuration: %s, opts.count excludes opts.narg.",C)),!0):!1)}return{aliases:Object.assign({},E.aliases),argv:Object.assign(j,A),configuration:i,defaulted:Object.assign({},O),error:p,newAliases:Object.assign({},x)}}}function Jn(u){const n=[],c=Object.create(null);let a=!0;for(Object.keys(u).forEach(function(f){n.push([].concat(u[f],f))});a;){a=!1;for(let f=0;f<n.length;f++)for(let o=f+1;o<n.length;o++)if(n[f].filter(function(i){return n[o].indexOf(i)!==-1}).length){n[f]=n[f].concat(n[o]),n.splice(o,1),a=!0;break}}return n.forEach(function(f){f=f.filter(function(t,i,m){return m.indexOf(t)===i});const o=f.pop();o!==void 0&&typeof o=="string"&&(c[o]=f)}),c}function Rt(u){return u!==void 0?u+1:1}function Ze(u){return u==="__proto__"?"___proto___":u}function Zn(u){return typeof u=="string"&&(u[0]==="'"||u[0]==='"')&&u[u.length-1]===u[0]?u.substring(1,u.length-1):u}/**
20
+ */let pt;class Jn{constructor(n){pt=n}parse(n,c){const a=Object.assign({alias:void 0,array:void 0,boolean:void 0,config:void 0,configObjects:void 0,configuration:void 0,coerce:void 0,count:void 0,default:void 0,envPrefix:void 0,narg:void 0,normalize:void 0,string:void 0,number:void 0,__:void 0,key:void 0},c),f=Qn(n),o=typeof n=="string",t=Zn(Object.assign(Object.create(null),a.alias)),i=Object.assign({"boolean-negation":!0,"camel-case-expansion":!0,"combine-arrays":!1,"dot-notation":!0,"duplicate-arguments-array":!0,"flatten-duplicate-arrays":!0,"greedy-arrays":!0,"halt-at-non-option":!1,"nargs-eats-options":!1,"negation-prefix":"no-","parse-numbers":!0,"parse-positional-numbers":!0,"populate--":!1,"set-placeholder-key":!1,"short-option-groups":!0,"strip-aliased":!1,"strip-dashed":!1,"unknown-options-as-args":!1},a.configuration),m=Object.assign(Object.create(null),a.default),N=a.configObjects||[],w=a.envPrefix,g=i["populate--"],b=g?"--":"_",x=Object.create(null),O=Object.create(null),_=a.__||pt.format,E={aliases:Object.create(null),arrays:Object.create(null),bools:Object.create(null),strings:Object.create(null),numbers:Object.create(null),counts:Object.create(null),normalize:Object.create(null),configs:Object.create(null),nargs:Object.create(null),coercions:Object.create(null),keys:[]},D=/^-([0-9]+(\.[0-9]+)?|\.[0-9]+)$/,T=new RegExp("^--"+i["negation-prefix"]+"(.+)");[].concat(a.array||[]).filter(Boolean).forEach(function(C){const s=typeof C=="object"?C.key:C,e=Object.keys(C).map(function(r){return{boolean:"bools",string:"strings",number:"numbers"}[r]}).filter(Boolean).pop();e&&(E[e][s]=!0),E.arrays[s]=!0,E.keys.push(s)}),[].concat(a.boolean||[]).filter(Boolean).forEach(function(C){E.bools[C]=!0,E.keys.push(C)}),[].concat(a.string||[]).filter(Boolean).forEach(function(C){E.strings[C]=!0,E.keys.push(C)}),[].concat(a.number||[]).filter(Boolean).forEach(function(C){E.numbers[C]=!0,E.keys.push(C)}),[].concat(a.count||[]).filter(Boolean).forEach(function(C){E.counts[C]=!0,E.keys.push(C)}),[].concat(a.normalize||[]).filter(Boolean).forEach(function(C){E.normalize[C]=!0,E.keys.push(C)}),typeof a.narg=="object"&&Object.entries(a.narg).forEach(([C,s])=>{typeof s=="number"&&(E.nargs[C]=s,E.keys.push(C))}),typeof a.coerce=="object"&&Object.entries(a.coerce).forEach(([C,s])=>{typeof s=="function"&&(E.coercions[C]=s,E.keys.push(C))}),typeof a.config<"u"&&(Array.isArray(a.config)||typeof a.config=="string"?[].concat(a.config).filter(Boolean).forEach(function(C){E.configs[C]=!0}):typeof a.config=="object"&&Object.entries(a.config).forEach(([C,s])=>{(typeof s=="boolean"||typeof s=="function")&&(E.configs[C]=s)})),Tt(a.key,t,a.default,E.arrays),Object.keys(m).forEach(function(C){(E.aliases[C]||[]).forEach(function(s){m[s]=m[C]})});let p=null;it();let I=[];const A=Object.assign(Object.create(null),{_:[]}),j={};for(let C=0;C<f.length;C++){const s=f[C],e=s.replace(/^-{3,}/,"---");let r,l,v,M,P,q;if(s!=="--"&&/^-/.test(s)&&d(s))U(s);else if(e.match(/^---+(=|$)/)){U(s);continue}else if(s.match(/^--.+=/)||!i["short-option-groups"]&&s.match(/^-.+=/))M=s.match(/^--?([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3&&(k(M[1],E.arrays)?C=h(C,M[1],f,M[2]):k(M[1],E.nargs)!==!1?C=B(C,M[1],f,M[2]):F(M[1],M[2],!0));else if(s.match(T)&&i["boolean-negation"])M=s.match(T),M!==null&&Array.isArray(M)&&M.length>=2&&(l=M[1],F(l,k(l,E.arrays)?[!1]:!1));else if(s.match(/^--.+/)||!i["short-option-groups"]&&s.match(/^-[^-]+/))M=s.match(/^--?(.+)/),M!==null&&Array.isArray(M)&&M.length>=2&&(l=M[1],k(l,E.arrays)?C=h(C,l,f):k(l,E.nargs)!==!1?C=B(C,l,f):(P=f[C+1],P!==void 0&&(!P.match(/^-/)||P.match(D))&&!k(l,E.bools)&&!k(l,E.counts)||/^(true|false)$/.test(P)?(F(l,P),C++):F(l,L(l))));else if(s.match(/^-.\..+=/))M=s.match(/^-([^=]+)=([\s\S]*)$/),M!==null&&Array.isArray(M)&&M.length>=3&&F(M[1],M[2]);else if(s.match(/^-.\..+/)&&!s.match(D))P=f[C+1],M=s.match(/^-(.\..+)/),M!==null&&Array.isArray(M)&&M.length>=2&&(l=M[1],P!==void 0&&!P.match(/^-/)&&!k(l,E.bools)&&!k(l,E.counts)?(F(l,P),C++):F(l,L(l)));else if(s.match(/^-[^-]+/)&&!s.match(D)){v=s.slice(1,-1).split(""),r=!1;for(let V=0;V<v.length;V++){if(P=s.slice(V+2),v[V+1]&&v[V+1]==="="){q=s.slice(V+3),l=v[V],k(l,E.arrays)?C=h(C,l,f,q):k(l,E.nargs)!==!1?C=B(C,l,f,q):F(l,q),r=!0;break}if(P==="-"){F(v[V],P);continue}if(/[A-Za-z]/.test(v[V])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(P)&&k(P,E.bools)===!1){F(v[V],P),r=!0;break}if(v[V+1]&&v[V+1].match(/\W/)){F(v[V],P),r=!0;break}else F(v[V],L(v[V]))}l=s.slice(-1)[0],!r&&l!=="-"&&(k(l,E.arrays)?C=h(C,l,f):k(l,E.nargs)!==!1?C=B(C,l,f):(P=f[C+1],P!==void 0&&(!/^(-|--)[^-]/.test(P)||P.match(D))&&!k(l,E.bools)&&!k(l,E.counts)||/^(true|false)$/.test(P)?(F(l,P),C++):F(l,L(l))))}else if(s.match(/^-[0-9]$/)&&s.match(D)&&k(s.slice(1),E.bools))l=s.slice(1),F(l,L(l));else if(s==="--"){I=f.slice(C+1);break}else if(i["halt-at-non-option"]){I=f.slice(C);break}else U(s)}W(A,!0),W(A,!1),Y(A),z(),gt(A,E.aliases,m,!0),vt(A),i["set-placeholder-key"]&&bt(A),Object.keys(E.counts).forEach(function(C){Q(A,C.split("."))||F(C,0)}),g&&I.length&&(A[b]=[]),I.forEach(function(C){A[b].push(C)}),i["camel-case-expansion"]&&i["strip-dashed"]&&Object.keys(A).filter(C=>C!=="--"&&C.includes("-")).forEach(C=>{delete A[C]}),i["strip-aliased"]&&[].concat(...Object.keys(t).map(C=>t[C])).forEach(C=>{i["camel-case-expansion"]&&C.includes("-")&&delete A[C.split(".").map(s=>At(s)).join(".")],delete A[C]});function U(C){const s=$("_",C);(typeof s=="string"||typeof s=="number")&&A._.push(s)}function B(C,s,e,r){let l,v=k(s,E.nargs);if(v=typeof v!="number"||isNaN(v)?1:v,v===0)return H(r)||(p=Error(_("Argument unexpected for: %s",s))),F(s,L(s)),C;let M=H(r)?0:1;if(i["nargs-eats-options"])e.length-(C+1)+M<v&&(p=Error(_("Not enough arguments following: %s",s))),M=v;else{for(l=C+1;l<e.length&&(!e[l].match(/^-[^0-9]/)||e[l].match(D)||d(e[l]));l++)M++;M<v&&(p=Error(_("Not enough arguments following: %s",s)))}let P=Math.min(M,v);for(!H(r)&&P>0&&(F(s,r),P--),l=C+1;l<P+C+1;l++)F(s,e[l]);return C+P}function h(C,s,e,r){let l=[],v=r||e[C+1];const M=k(s,E.nargs);if(k(s,E.bools)&&!/^(true|false)$/.test(v))l.push(!0);else if(H(v)||H(r)&&/^-/.test(v)&&!D.test(v)&&!d(v)){if(m[s]!==void 0){const P=m[s];l=Array.isArray(P)?P:[P]}}else{H(r)||l.push(X(s,r,!0));for(let P=C+1;P<e.length&&!(!i["greedy-arrays"]&&l.length>0||M&&typeof M=="number"&&l.length>=M||(v=e[P],/^-/.test(v)&&!D.test(v)&&!d(v)));P++)C=P,l.push(X(s,v,o))}return typeof M=="number"&&(M&&l.length<M||isNaN(M)&&l.length===0)&&(p=Error(_("Not enough arguments following: %s",s))),F(s,l),C}function F(C,s,e=o){if(/-/.test(C)&&i["camel-case-expansion"]){const v=C.split(".").map(function(M){return At(M)}).join(".");R(C,v)}const r=X(C,s,e),l=C.split(".");et(A,l,r),E.aliases[C]&&E.aliases[C].forEach(function(v){const M=v.split(".");et(A,M,r)}),l.length>1&&i["dot-notation"]&&(E.aliases[l[0]]||[]).forEach(function(v){let M=v.split(".");const P=[].concat(l);P.shift(),M=M.concat(P),(E.aliases[C]||[]).includes(M.join("."))||et(A,M,r)}),k(C,E.normalize)&&!k(C,E.arrays)&&[C].concat(E.aliases[C]||[]).forEach(function(M){Object.defineProperty(j,M,{enumerable:!0,get(){return s},set(P){s=typeof P=="string"?pt.normalize(P):P}})})}function R(C,s){E.aliases[C]&&E.aliases[C].length||(E.aliases[C]=[s],x[s]=!0),E.aliases[s]&&E.aliases[s].length||R(s,C)}function X(C,s,e){e&&(s=ti(s)),(k(C,E.bools)||k(C,E.counts))&&typeof s=="string"&&(s=s==="true");let r=Array.isArray(s)?s.map(function(l){return $(C,l)}):$(C,s);return k(C,E.counts)&&(H(r)||typeof r=="boolean")&&(r=Rt()),k(C,E.normalize)&&k(C,E.arrays)&&(Array.isArray(s)?r=s.map(l=>pt.normalize(l)):r=pt.normalize(s)),r}function $(C,s){return!i["parse-positional-numbers"]&&C==="_"||!k(C,E.strings)&&!k(C,E.bools)&&!Array.isArray(s)&&(Kn(s)&&i["parse-numbers"]&&Number.isSafeInteger(Math.floor(parseFloat(`${s}`)))||!H(s)&&k(C,E.numbers))&&(s=Number(s)),s}function Y(C){const s=Object.create(null);gt(s,E.aliases,m),Object.keys(E.configs).forEach(function(e){const r=C[e]||s[e];if(r)try{let l=null;const v=pt.resolve(pt.cwd(),r),M=E.configs[e];if(typeof M=="function"){try{l=M(v)}catch(P){l=P}if(l instanceof Error){p=l;return}}else l=pt.require(v);J(l)}catch(l){l.name==="PermissionDenied"?p=l:C[e]&&(p=Error(_("Invalid JSON config file: %s",r)))}})}function J(C,s){Object.keys(C).forEach(function(e){const r=C[e],l=s?s+"."+e:e;typeof r=="object"&&r!==null&&!Array.isArray(r)&&i["dot-notation"]?J(r,l):(!Q(A,l.split("."))||k(l,E.arrays)&&i["combine-arrays"])&&F(l,r)})}function z(){typeof N<"u"&&N.forEach(function(C){J(C)})}function W(C,s){if(typeof w>"u")return;const e=typeof w=="string"?w:"",r=pt.env();Object.keys(r).forEach(function(l){if(e===""||l.lastIndexOf(e,0)===0){const v=l.split("__").map(function(M,P){return P===0&&(M=M.substring(e.length)),At(M)});(s&&E.configs[v.join(".")]||!s)&&!Q(C,v)&&F(v.join("."),r[l])}})}function vt(C){let s;const e=new Set;Object.keys(C).forEach(function(r){if(!e.has(r)&&(s=k(r,E.coercions),typeof s=="function"))try{const l=$(r,s(C[r]));[].concat(E.aliases[r]||[],r).forEach(v=>{e.add(v),C[v]=l})}catch(l){p=l}})}function bt(C){return E.keys.forEach(s=>{~s.indexOf(".")||typeof C[s]>"u"&&(C[s]=void 0)}),C}function gt(C,s,e,r=!1){Object.keys(e).forEach(function(l){Q(C,l.split("."))||(et(C,l.split("."),e[l]),r&&(O[l]=!0),(s[l]||[]).forEach(function(v){Q(C,v.split("."))||et(C,v.split("."),e[l])}))})}function Q(C,s){let e=C;i["dot-notation"]||(s=[s.join(".")]),s.slice(0,-1).forEach(function(l){e=e[l]||{}});const r=s[s.length-1];return typeof e!="object"?!1:r in e}function et(C,s,e){let r=C;i["dot-notation"]||(s=[s.join(".")]),s.slice(0,-1).forEach(function(q){q=Ze(q),typeof r=="object"&&r[q]===void 0&&(r[q]={}),typeof r[q]!="object"||Array.isArray(r[q])?(Array.isArray(r[q])?r[q].push({}):r[q]=[r[q],{}],r=r[q][r[q].length-1]):r=r[q]});const l=Ze(s[s.length-1]),v=k(s.join("."),E.arrays),M=Array.isArray(e);let P=i["duplicate-arguments-array"];!P&&k(l,E.nargs)&&(P=!0,(!H(r[l])&&E.nargs[l]===1||Array.isArray(r[l])&&r[l].length===E.nargs[l])&&(r[l]=void 0)),e===Rt()?r[l]=Rt(r[l]):Array.isArray(r[l])?P&&v&&M?r[l]=i["flatten-duplicate-arrays"]?r[l].concat(e):(Array.isArray(r[l][0])?r[l]:[r[l]]).concat([e]):!P&&!!v==!!M?r[l]=e:r[l]=r[l].concat([e]):r[l]===void 0&&v?r[l]=M?e:[e]:P&&!(r[l]===void 0||k(l,E.counts)||k(l,E.bools))?r[l]=[r[l],e]:r[l]=e}function Tt(...C){C.forEach(function(s){Object.keys(s||{}).forEach(function(e){E.aliases[e]||(E.aliases[e]=[].concat(t[e]||[]),E.aliases[e].concat(e).forEach(function(r){if(/-/.test(r)&&i["camel-case-expansion"]){const l=At(r);l!==e&&E.aliases[e].indexOf(l)===-1&&(E.aliases[e].push(l),x[l]=!0)}}),E.aliases[e].concat(e).forEach(function(r){if(r.length>1&&/[A-Z]/.test(r)&&i["camel-case-expansion"]){const l=zn(r,"-");l!==e&&E.aliases[e].indexOf(l)===-1&&(E.aliases[e].push(l),x[l]=!0)}}),E.aliases[e].forEach(function(r){E.aliases[r]=[e].concat(E.aliases[e].filter(function(l){return r!==l}))}))})})}function k(C,s){const e=[].concat(E.aliases[C]||[],C),r=Object.keys(s),l=e.find(v=>r.includes(v));return l?s[l]:!1}function wt(C){const s=Object.keys(E);return[].concat(s.map(r=>E[r])).some(function(r){return Array.isArray(r)?r.includes(C):r[C]})}function It(C,...s){return[].concat(...s).some(function(r){const l=C.match(r);return l&&wt(l[1])})}function y(C){if(C.match(D)||!C.match(/^-[^-]+/))return!1;let s=!0,e;const r=C.slice(1).split("");for(let l=0;l<r.length;l++){if(e=C.slice(l+2),!wt(r[l])){s=!1;break}if(r[l+1]&&r[l+1]==="="||e==="-"||/[A-Za-z]/.test(r[l])&&/^-?\d+(\.\d*)?(e-?\d+)?$/.test(e)||r[l+1]&&r[l+1].match(/\W/))break}return s}function d(C){return i["unknown-options-as-args"]&&S(C)}function S(C){return C=C.replace(/^-{3,}/,"--"),C.match(D)||y(C)?!1:!It(C,/^-+([^=]+?)=[\s\S]*$/,T,/^-+([^=]+?)$/,/^-+([^=]+?)-$/,/^-+([^=]+?\d+)$/,/^-+([^=]+?)\W+.*$/)}function L(C){return!k(C,E.bools)&&!k(C,E.counts)&&`${C}`in m?m[C]:K(tt(C))}function K(C){return{[ft.BOOLEAN]:!0,[ft.STRING]:"",[ft.NUMBER]:void 0,[ft.ARRAY]:[]}[C]}function tt(C){let s=ft.BOOLEAN;return k(C,E.strings)?s=ft.STRING:k(C,E.numbers)?s=ft.NUMBER:k(C,E.bools)?s=ft.BOOLEAN:k(C,E.arrays)&&(s=ft.ARRAY),s}function H(C){return C===void 0}function it(){Object.keys(E.counts).find(C=>k(C,E.arrays)?(p=Error(_("Invalid configuration: %s, opts.count excludes opts.array.",C)),!0):k(C,E.nargs)?(p=Error(_("Invalid configuration: %s, opts.count excludes opts.narg.",C)),!0):!1)}return{aliases:Object.assign({},E.aliases),argv:Object.assign(j,A),configuration:i,defaulted:Object.assign({},O),error:p,newAliases:Object.assign({},x)}}}function Zn(u){const n=[],c=Object.create(null);let a=!0;for(Object.keys(u).forEach(function(f){n.push([].concat(u[f],f))});a;){a=!1;for(let f=0;f<n.length;f++)for(let o=f+1;o<n.length;o++)if(n[f].filter(function(i){return n[o].indexOf(i)!==-1}).length){n[f]=n[f].concat(n[o]),n.splice(o,1),a=!0;break}}return n.forEach(function(f){f=f.filter(function(t,i,m){return m.indexOf(t)===i});const o=f.pop();o!==void 0&&typeof o=="string"&&(c[o]=f)}),c}function Rt(u){return u!==void 0?u+1:1}function Ze(u){return u==="__proto__"?"___proto___":u}function ti(u){return typeof u=="string"&&(u[0]==="'"||u[0]==='"')&&u[u.length-1]===u[0]?u.substring(1,u.length-1):u}/**
21
21
  * @fileoverview Main entrypoint for libraries using yargs-parser in Node.js
22
22
  * CJS and ESM environments.
23
23
  *
24
24
  * @license
25
25
  * Copyright (c) 2016, Contributors
26
26
  * SPDX-License-Identifier: ISC
27
- */var jt,Ut,Xt;const tr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,er=(Ut=(jt=process==null?void 0:process.versions)===null||jt===void 0?void 0:jt.node)!==null&&Ut!==void 0?Ut:(Xt=process==null?void 0:process.version)===null||Xt===void 0?void 0:Xt.slice(1);if(er&&Number(er.match(/^([^.]+)/)[1])<tr)throw Error(`yargs parser supports a minimum Node.js version of ${tr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);const ti=process?process.env:{};new Qn({cwd:process.cwd,env:()=>ti,format:Gr,normalize:Ln,resolve:Ce,require:u=>{if(typeof require<"u")return require(u);if(u.match(/\.json$/))return JSON.parse(Oe(u,"utf8"));throw Error("only .json config files are supported in ESM")}});const ei={fs:{readFileSync:Oe,writeFile:mn},format:Gr,resolve:Ce,exists:u=>{try{return yn(u).isFile()}catch{return!1}}};let lt;class ri{constructor(n){n=n||{},this.directory=n.directory||"./locales",this.updateFiles=typeof n.updateFiles=="boolean"?n.updateFiles:!0,this.locale=n.locale||"en",this.fallbackToLanguage=typeof n.fallbackToLanguage=="boolean"?n.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...n){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);const c=n.shift();let a=function(){};return typeof n[n.length-1]=="function"&&(a=n.pop()),a=a||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][c]&&this.updateFiles?(this.cache[this.locale][c]=c,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:a})):a(),lt.format.apply(lt.format,[this.cache[this.locale][c]||c].concat(n))}__n(){const n=Array.prototype.slice.call(arguments),c=n.shift(),a=n.shift(),f=n.shift();let o=function(){};typeof n[n.length-1]=="function"&&(o=n.pop()),this.cache[this.locale]||this._readLocaleFile();let t=f===1?c:a;this.cache[this.locale][c]&&(t=this.cache[this.locale][c][f===1?"one":"other"]),!this.cache[this.locale][c]&&this.updateFiles?(this.cache[this.locale][c]={one:c,other:a},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:o})):o();const i=[t];return~t.indexOf("%d")&&i.push(f),lt.format.apply(lt.format,i.concat(n))}setLocale(n){this.locale=n}getLocale(){return this.locale}updateLocale(n){this.cache[this.locale]||this._readLocaleFile();for(const c in n)Object.prototype.hasOwnProperty.call(n,c)&&(this.cache[this.locale][c]=n[c])}_taggedLiteral(n,...c){let a="";return n.forEach(function(f,o){const t=c[o+1];a+=f,typeof t<"u"&&(a+="%s")}),this.__.apply(this,[a].concat([].slice.call(c,1)))}_enqueueWrite(n){this.writeQueue.push(n),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){const n=this,c=this.writeQueue[0],a=c.directory,f=c.locale,o=c.cb,t=this._resolveLocaleFile(a,f),i=JSON.stringify(this.cache[f],null,2);lt.fs.writeFile(t,i,"utf-8",function(m){n.writeQueue.shift(),n.writeQueue.length>0&&n._processWriteQueue(),o(m)})}_readLocaleFile(){let n={};const c=this._resolveLocaleFile(this.directory,this.locale);try{lt.fs.readFileSync&&(n=JSON.parse(lt.fs.readFileSync(c,"utf-8")))}catch(a){if(a instanceof SyntaxError&&(a.message="syntax error in "+c),a.code==="ENOENT")n={};else throw a}this.cache[this.locale]=n}_resolveLocaleFile(n,c){let a=lt.resolve(n,"./",c+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(a)&&~c.lastIndexOf("_")){const f=lt.resolve(n,"./",c.split("_")[0]+".json");this._fileExistsSync(f)&&(a=f)}return a}_fileExistsSync(n){return lt.exists(n)}}function ni(u,n){lt=n;const c=new ri(u);return{__:c.__.bind(c),__n:c.__n.bind(c),setLocale:c.setLocale.bind(c),getLocale:c.getLocale.bind(c),updateLocale:c.updateLocale.bind(c),locale:c.locale}}const ii=u=>ni(u,ei);let Ot;try{Ot=_n(import.meta.url)}catch{Ot=process.cwd()}const oi=Ot.substring(0,Ot.lastIndexOf("node_modules"));oi||process.cwd(),process.cwd,process.exit,process.nextTick,typeof process.stdout.columns<"u"&&process.stdout.columns,ii({directory:Ce(Ot,"../../../locales"),updateFiles:!1});const si={};var qt={},rr;function _e(){return rr||(rr=1,function(){qt.defaults={"0.1":{explicitCharkey:!1,trim:!0,normalize:!0,normalizeTags:!1,attrkey:"@",charkey:"#",explicitArray:!1,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!1,validator:null,xmlns:!1,explicitChildren:!1,childkey:"@@",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,emptyTag:""},"0.2":{explicitCharkey:!1,trim:!1,normalize:!1,normalizeTags:!1,attrkey:"$",charkey:"_",explicitArray:!0,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!0,validator:null,xmlns:!1,explicitChildren:!1,preserveChildrenOrder:!1,childkey:"$$",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,rootName:"root",xmldec:{version:"1.0",encoding:"UTF-8",standalone:!0},doctype:null,renderOpts:{pretty:!0,indent:" ",newline:`
27
+ */var jt,Ut,Xt;const tr=process&&process.env&&process.env.YARGS_MIN_NODE_VERSION?Number(process.env.YARGS_MIN_NODE_VERSION):12,er=(Ut=(jt=process==null?void 0:process.versions)===null||jt===void 0?void 0:jt.node)!==null&&Ut!==void 0?Ut:(Xt=process==null?void 0:process.version)===null||Xt===void 0?void 0:Xt.slice(1);if(er&&Number(er.match(/^([^.]+)/)[1])<tr)throw Error(`yargs parser supports a minimum Node.js version of ${tr}. Read our version support policy: https://github.com/yargs/yargs-parser#supported-nodejs-versions`);const ei=process?process.env:{};new Jn({cwd:process.cwd,env:()=>ei,format:Gr,normalize:Ln,resolve:Ce,require:u=>{if(typeof require<"u")return require(u);if(u.match(/\.json$/))return JSON.parse(Oe(u,"utf8"));throw Error("only .json config files are supported in ESM")}});const ri={fs:{readFileSync:Oe,writeFile:mn},format:Gr,resolve:Ce,exists:u=>{try{return yn(u).isFile()}catch{return!1}}};let lt;class ni{constructor(n){n=n||{},this.directory=n.directory||"./locales",this.updateFiles=typeof n.updateFiles=="boolean"?n.updateFiles:!0,this.locale=n.locale||"en",this.fallbackToLanguage=typeof n.fallbackToLanguage=="boolean"?n.fallbackToLanguage:!0,this.cache=Object.create(null),this.writeQueue=[]}__(...n){if(typeof arguments[0]!="string")return this._taggedLiteral(arguments[0],...arguments);const c=n.shift();let a=function(){};return typeof n[n.length-1]=="function"&&(a=n.pop()),a=a||function(){},this.cache[this.locale]||this._readLocaleFile(),!this.cache[this.locale][c]&&this.updateFiles?(this.cache[this.locale][c]=c,this._enqueueWrite({directory:this.directory,locale:this.locale,cb:a})):a(),lt.format.apply(lt.format,[this.cache[this.locale][c]||c].concat(n))}__n(){const n=Array.prototype.slice.call(arguments),c=n.shift(),a=n.shift(),f=n.shift();let o=function(){};typeof n[n.length-1]=="function"&&(o=n.pop()),this.cache[this.locale]||this._readLocaleFile();let t=f===1?c:a;this.cache[this.locale][c]&&(t=this.cache[this.locale][c][f===1?"one":"other"]),!this.cache[this.locale][c]&&this.updateFiles?(this.cache[this.locale][c]={one:c,other:a},this._enqueueWrite({directory:this.directory,locale:this.locale,cb:o})):o();const i=[t];return~t.indexOf("%d")&&i.push(f),lt.format.apply(lt.format,i.concat(n))}setLocale(n){this.locale=n}getLocale(){return this.locale}updateLocale(n){this.cache[this.locale]||this._readLocaleFile();for(const c in n)Object.prototype.hasOwnProperty.call(n,c)&&(this.cache[this.locale][c]=n[c])}_taggedLiteral(n,...c){let a="";return n.forEach(function(f,o){const t=c[o+1];a+=f,typeof t<"u"&&(a+="%s")}),this.__.apply(this,[a].concat([].slice.call(c,1)))}_enqueueWrite(n){this.writeQueue.push(n),this.writeQueue.length===1&&this._processWriteQueue()}_processWriteQueue(){const n=this,c=this.writeQueue[0],a=c.directory,f=c.locale,o=c.cb,t=this._resolveLocaleFile(a,f),i=JSON.stringify(this.cache[f],null,2);lt.fs.writeFile(t,i,"utf-8",function(m){n.writeQueue.shift(),n.writeQueue.length>0&&n._processWriteQueue(),o(m)})}_readLocaleFile(){let n={};const c=this._resolveLocaleFile(this.directory,this.locale);try{lt.fs.readFileSync&&(n=JSON.parse(lt.fs.readFileSync(c,"utf-8")))}catch(a){if(a instanceof SyntaxError&&(a.message="syntax error in "+c),a.code==="ENOENT")n={};else throw a}this.cache[this.locale]=n}_resolveLocaleFile(n,c){let a=lt.resolve(n,"./",c+".json");if(this.fallbackToLanguage&&!this._fileExistsSync(a)&&~c.lastIndexOf("_")){const f=lt.resolve(n,"./",c.split("_")[0]+".json");this._fileExistsSync(f)&&(a=f)}return a}_fileExistsSync(n){return lt.exists(n)}}function ii(u,n){lt=n;const c=new ni(u);return{__:c.__.bind(c),__n:c.__n.bind(c),setLocale:c.setLocale.bind(c),getLocale:c.getLocale.bind(c),updateLocale:c.updateLocale.bind(c),locale:c.locale}}const oi=u=>ii(u,ri);let Ot;try{Ot=_n(import.meta.url)}catch{Ot=process.cwd()}const si=Ot.substring(0,Ot.lastIndexOf("node_modules"));si||process.cwd(),process.cwd,process.exit,process.nextTick,typeof process.stdout.columns<"u"&&process.stdout.columns,oi({directory:Ce(Ot,"../../../locales"),updateFiles:!1});var qt={},rr;function _e(){return rr||(rr=1,function(){qt.defaults={"0.1":{explicitCharkey:!1,trim:!0,normalize:!0,normalizeTags:!1,attrkey:"@",charkey:"#",explicitArray:!1,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!1,validator:null,xmlns:!1,explicitChildren:!1,childkey:"@@",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,emptyTag:""},"0.2":{explicitCharkey:!1,trim:!1,normalize:!1,normalizeTags:!1,attrkey:"$",charkey:"_",explicitArray:!0,ignoreAttrs:!1,mergeAttrs:!1,explicitRoot:!0,validator:null,xmlns:!1,explicitChildren:!1,preserveChildrenOrder:!1,childkey:"$$",charsAsChildren:!1,includeWhiteChars:!1,async:!1,strict:!0,attrNameProcessors:null,attrValueProcessors:null,tagNameProcessors:null,valueProcessors:null,rootName:"root",xmldec:{version:"1.0",encoding:"UTF-8",standalone:!0},doctype:null,renderOpts:{pretty:!0,indent:" ",newline:`
28
28
  `},headless:!1,chunkSize:1e4,emptyTag:"",cdata:!1}}}.call(G)),qt}var kt={},dt={},mt={},nr;function yt(){return nr||(nr=1,function(){var u,n,c,a,f,o,t,i=[].slice,m={}.hasOwnProperty;u=function(){var N,w,g,b,x,O;if(O=arguments[0],x=2<=arguments.length?i.call(arguments,1):[],f(Object.assign))Object.assign.apply(null,arguments);else for(N=0,g=x.length;N<g;N++)if(b=x[N],b!=null)for(w in b)m.call(b,w)&&(O[w]=b[w]);return O},f=function(N){return!!N&&Object.prototype.toString.call(N)==="[object Function]"},o=function(N){var w;return!!N&&((w=typeof N)=="function"||w==="object")},c=function(N){return f(Array.isArray)?Array.isArray(N):Object.prototype.toString.call(N)==="[object Array]"},a=function(N){var w;if(c(N))return!N.length;for(w in N)if(m.call(N,w))return!1;return!0},t=function(N){var w,g;return o(N)&&(g=Object.getPrototypeOf(N))&&(w=g.constructor)&&typeof w=="function"&&w instanceof w&&Function.prototype.toString.call(w)===Function.prototype.toString.call(Object)},n=function(N){return f(N.valueOf)?N.valueOf():N},mt.assign=u,mt.isFunction=f,mt.isObject=o,mt.isArray=c,mt.isEmpty=a,mt.isPlainObject=t,mt.getValue=n}.call(G)),mt}var Vt={exports:{}},ir;function sn(){return ir||(ir=1,function(){Vt.exports=function(){function u(){}return u.prototype.hasFeature=function(n,c){return!0},u.prototype.createDocumentType=function(n,c,a){throw new Error("This DOM method is not implemented.")},u.prototype.createDocument=function(n,c,a){throw new Error("This DOM method is not implemented.")},u.prototype.createHTMLDocument=function(n){throw new Error("This DOM method is not implemented.")},u.prototype.getFeature=function(n,c){throw new Error("This DOM method is not implemented.")},u}()}.call(G)),Vt.exports}var $t={exports:{}},Wt={exports:{}},Ht={exports:{}},or;function ai(){return or||(or=1,function(){Ht.exports=function(){function u(){}return u.prototype.handleError=function(n){throw new Error(n)},u}()}.call(G)),Ht.exports}var Gt={exports:{}},sr;function ui(){return sr||(sr=1,function(){Gt.exports=function(){function u(n){this.arr=n||[]}return Object.defineProperty(u.prototype,"length",{get:function(){return this.arr.length}}),u.prototype.item=function(n){return this.arr[n]||null},u.prototype.contains=function(n){return this.arr.indexOf(n)!==-1},u}()}.call(G)),Gt.exports}var ar;function ci(){return ar||(ar=1,function(){var u,n;u=ai(),n=ui(),Wt.exports=function(){function c(){this.defaultParams={"canonical-form":!1,"cdata-sections":!1,comments:!1,"datatype-normalization":!1,"element-content-whitespace":!0,entities:!0,"error-handler":new u,infoset:!0,"validate-if-schema":!1,namespaces:!0,"namespace-declarations":!0,"normalize-characters":!1,"schema-location":"","schema-type":"","split-cdata-sections":!0,validate:!1,"well-formed":!0},this.params=Object.create(this.defaultParams)}return Object.defineProperty(c.prototype,"parameterNames",{get:function(){return new n(Object.keys(this.defaultParams))}}),c.prototype.getParameter=function(a){return this.params.hasOwnProperty(a)?this.params[a]:null},c.prototype.canSetParameter=function(a,f){return!0},c.prototype.setParameter=function(a,f){return f!=null?this.params[a]=f:delete this.params[a]},c}()}.call(G)),Wt.exports}var Yt={exports:{}},zt={exports:{}},Kt={exports:{}},ur;function ot(){return ur||(ur=1,function(){Kt.exports={Element:1,Attribute:2,Text:3,CData:4,EntityReference:5,EntityDeclaration:6,ProcessingInstruction:7,Comment:8,Document:9,DocType:10,DocumentFragment:11,NotationDeclaration:12,Declaration:201,Raw:202,AttributeDeclaration:203,ElementDeclaration:204,Dummy:205}}.call(G)),Kt.exports}var Qt={exports:{}},cr;function an(){return cr||(cr=1,function(){var u;u=ot(),ct(),Qt.exports=function(){function n(c,a,f){if(this.parent=c,this.parent&&(this.options=this.parent.options,this.stringify=this.parent.stringify),a==null)throw new Error("Missing attribute name. "+this.debugInfo(a));this.name=this.stringify.name(a),this.value=this.stringify.attValue(f),this.type=u.Attribute,this.isId=!1,this.schemaTypeInfo=null}return Object.defineProperty(n.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(n.prototype,"ownerElement",{get:function(){return this.parent}}),Object.defineProperty(n.prototype,"textContent",{get:function(){return this.value},set:function(c){return this.value=c||""}}),Object.defineProperty(n.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(n.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(n.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(n.prototype,"specified",{get:function(){return!0}}),n.prototype.clone=function(){return Object.create(this)},n.prototype.toString=function(c){return this.options.writer.attribute(this,this.options.writer.filterOptions(c))},n.prototype.debugInfo=function(c){return c=c||this.name,c==null?"parent: <"+this.parent.name+">":"attribute: {"+c+"}, parent: <"+this.parent.name+">"},n.prototype.isEqualNode=function(c){return!(c.namespaceURI!==this.namespaceURI||c.prefix!==this.prefix||c.localName!==this.localName||c.value!==this.value)},n}()}.call(G)),Qt.exports}var Jt={exports:{}},lr;function Me(){return lr||(lr=1,function(){Jt.exports=function(){function u(n){this.nodes=n}return Object.defineProperty(u.prototype,"length",{get:function(){return Object.keys(this.nodes).length||0}}),u.prototype.clone=function(){return this.nodes=null},u.prototype.getNamedItem=function(n){return this.nodes[n]},u.prototype.setNamedItem=function(n){var c;return c=this.nodes[n.nodeName],this.nodes[n.nodeName]=n,c||null},u.prototype.removeNamedItem=function(n){var c;return c=this.nodes[n],delete this.nodes[n],c||null},u.prototype.item=function(n){return this.nodes[Object.keys(this.nodes)[n]]||null},u.prototype.getNamedItemNS=function(n,c){throw new Error("This DOM method is not implemented.")},u.prototype.setNamedItemNS=function(n){throw new Error("This DOM method is not implemented.")},u.prototype.removeNamedItemNS=function(n,c){throw new Error("This DOM method is not implemented.")},u}()}.call(G)),Jt.exports}var fr;function Pe(){return fr||(fr=1,function(){var u,n,c,a,f,o,t,i,m=function(w,g){for(var b in g)N.call(g,b)&&(w[b]=g[b]);function x(){this.constructor=w}return x.prototype=g.prototype,w.prototype=new x,w.__super__=g.prototype,w},N={}.hasOwnProperty;i=yt(),t=i.isObject,o=i.isFunction,f=i.getValue,a=ct(),u=ot(),n=an(),c=Me(),zt.exports=function(w){m(g,w);function g(b,x,O){var _,E,D,T;if(g.__super__.constructor.call(this,b),x==null)throw new Error("Missing element name. "+this.debugInfo());if(this.name=this.stringify.name(x),this.type=u.Element,this.attribs={},this.schemaTypeInfo=null,O!=null&&this.attribute(O),b.type===u.Document&&(this.isRoot=!0,this.documentObject=b,b.rootObject=this,b.children)){for(T=b.children,E=0,D=T.length;E<D;E++)if(_=T[E],_.type===u.DocType){_.name=this.name;break}}}return Object.defineProperty(g.prototype,"tagName",{get:function(){return this.name}}),Object.defineProperty(g.prototype,"namespaceURI",{get:function(){return""}}),Object.defineProperty(g.prototype,"prefix",{get:function(){return""}}),Object.defineProperty(g.prototype,"localName",{get:function(){return this.name}}),Object.defineProperty(g.prototype,"id",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(g.prototype,"className",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(g.prototype,"classList",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(g.prototype,"attributes",{get:function(){return(!this.attributeMap||!this.attributeMap.nodes)&&(this.attributeMap=new c(this.attribs)),this.attributeMap}}),g.prototype.clone=function(){var b,x,O,_;O=Object.create(this),O.isRoot&&(O.documentObject=null),O.attribs={},_=this.attribs;for(x in _)N.call(_,x)&&(b=_[x],O.attribs[x]=b.clone());return O.children=[],this.children.forEach(function(E){var D;return D=E.clone(),D.parent=O,O.children.push(D)}),O},g.prototype.attribute=function(b,x){var O,_;if(b!=null&&(b=f(b)),t(b))for(O in b)N.call(b,O)&&(_=b[O],this.attribute(O,_));else o(x)&&(x=x.apply()),this.options.keepNullAttributes&&x==null?this.attribs[b]=new n(this,b,""):x!=null&&(this.attribs[b]=new n(this,b,x));return this},g.prototype.removeAttribute=function(b){var x,O,_;if(b==null)throw new Error("Missing attribute name. "+this.debugInfo());if(b=f(b),Array.isArray(b))for(O=0,_=b.length;O<_;O++)x=b[O],delete this.attribs[x];else delete this.attribs[b];return this},g.prototype.toString=function(b){return this.options.writer.element(this,this.options.writer.filterOptions(b))},g.prototype.att=function(b,x){return this.attribute(b,x)},g.prototype.a=function(b,x){return this.attribute(b,x)},g.prototype.getAttribute=function(b){return this.attribs.hasOwnProperty(b)?this.attribs[b].value:null},g.prototype.setAttribute=function(b,x){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.getAttributeNode=function(b){return this.attribs.hasOwnProperty(b)?this.attribs[b]:null},g.prototype.setAttributeNode=function(b){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.removeAttributeNode=function(b){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.getElementsByTagName=function(b){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.getAttributeNS=function(b,x){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.setAttributeNS=function(b,x,O){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.removeAttributeNS=function(b,x){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.getAttributeNodeNS=function(b,x){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.setAttributeNodeNS=function(b){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.getElementsByTagNameNS=function(b,x){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.hasAttribute=function(b){return this.attribs.hasOwnProperty(b)},g.prototype.hasAttributeNS=function(b,x){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.setIdAttribute=function(b,x){return this.attribs.hasOwnProperty(b)?this.attribs[b].isId:x},g.prototype.setIdAttributeNS=function(b,x,O){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.setIdAttributeNode=function(b,x){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.getElementsByTagName=function(b){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.getElementsByTagNameNS=function(b,x){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.getElementsByClassName=function(b){throw new Error("This DOM method is not implemented."+this.debugInfo())},g.prototype.isEqualNode=function(b){var x,O,_;if(!g.__super__.isEqualNode.apply(this,arguments).isEqualNode(b)||b.namespaceURI!==this.namespaceURI||b.prefix!==this.prefix||b.localName!==this.localName||b.attribs.length!==this.attribs.length)return!1;for(x=O=0,_=this.attribs.length-1;0<=_?O<=_:O>=_;x=0<=_?++O:--O)if(!this.attribs[x].isEqualNode(b.attribs[x]))return!1;return!0},g}(a)}.call(G)),zt.exports}var Zt={exports:{}},te={exports:{}},hr;function St(){return hr||(hr=1,function(){var u,n=function(a,f){for(var o in f)c.call(f,o)&&(a[o]=f[o]);function t(){this.constructor=a}return t.prototype=f.prototype,a.prototype=new t,a.__super__=f.prototype,a},c={}.hasOwnProperty;u=ct(),te.exports=function(a){n(f,a);function f(o){f.__super__.constructor.call(this,o),this.value=""}return Object.defineProperty(f.prototype,"data",{get:function(){return this.value},set:function(o){return this.value=o||""}}),Object.defineProperty(f.prototype,"length",{get:function(){return this.value.length}}),Object.defineProperty(f.prototype,"textContent",{get:function(){return this.value},set:function(o){return this.value=o||""}}),f.prototype.clone=function(){return Object.create(this)},f.prototype.substringData=function(o,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},f.prototype.appendData=function(o){throw new Error("This DOM method is not implemented."+this.debugInfo())},f.prototype.insertData=function(o,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},f.prototype.deleteData=function(o,t){throw new Error("This DOM method is not implemented."+this.debugInfo())},f.prototype.replaceData=function(o,t,i){throw new Error("This DOM method is not implemented."+this.debugInfo())},f.prototype.isEqualNode=function(o){return!(!f.__super__.isEqualNode.apply(this,arguments).isEqualNode(o)||o.data!==this.data)},f}(u)}.call(G)),te.exports}var pr;function Fe(){return pr||(pr=1,function(){var u,n,c=function(f,o){for(var t in o)a.call(o,t)&&(f[t]=o[t]);function i(){this.constructor=f}return i.prototype=o.prototype,f.prototype=new i,f.__super__=o.prototype,f},a={}.hasOwnProperty;u=ot(),n=St(),Zt.exports=function(f){c(o,f);function o(t,i){if(o.__super__.constructor.call(this,t),i==null)throw new Error("Missing CDATA text. "+this.debugInfo());this.name="#cdata-section",this.type=u.CData,this.value=this.stringify.cdata(i)}return o.prototype.clone=function(){return Object.create(this)},o.prototype.toString=function(t){return this.options.writer.cdata(this,this.options.writer.filterOptions(t))},o}(n)}.call(G)),Zt.exports}var ee={exports:{}},dr;function Se(){return dr||(dr=1,function(){var u,n,c=function(f,o){for(var t in o)a.call(o,t)&&(f[t]=o[t]);function i(){this.constructor=f}return i.prototype=o.prototype,f.prototype=new i,f.__super__=o.prototype,f},a={}.hasOwnProperty;u=ot(),n=St(),ee.exports=function(f){c(o,f);function o(t,i){if(o.__super__.constructor.call(this,t),i==null)throw new Error("Missing comment text. "+this.debugInfo());this.name="#comment",this.type=u.Comment,this.value=this.stringify.comment(i)}return o.prototype.clone=function(){return Object.create(this)},o.prototype.toString=function(t){return this.options.writer.comment(this,this.options.writer.filterOptions(t))},o}(n)}.call(G)),ee.exports}var re={exports:{}},mr;function Be(){return mr||(mr=1,function(){var u,n,c,a=function(o,t){for(var i in t)f.call(t,i)&&(o[i]=t[i]);function m(){this.constructor=o}return m.prototype=t.prototype,o.prototype=new m,o.__super__=t.prototype,o},f={}.hasOwnProperty;c=yt().isObject,n=ct(),u=ot(),re.exports=function(o){a(t,o);function t(i,m,N,w){var g;t.__super__.constructor.call(this,i),c(m)&&(g=m,m=g.version,N=g.encoding,w=g.standalone),m||(m="1.0"),this.type=u.Declaration,this.version=this.stringify.xmlVersion(m),N!=null&&(this.encoding=this.stringify.xmlEncoding(N)),w!=null&&(this.standalone=this.stringify.xmlStandalone(w))}return t.prototype.toString=function(i){return this.options.writer.declaration(this,this.options.writer.filterOptions(i))},t}(n)}.call(G)),re.exports}var ne={exports:{}},ie={exports:{}},yr;function Re(){return yr||(yr=1,function(){var u,n,c=function(f,o){for(var t in o)a.call(o,t)&&(f[t]=o[t]);function i(){this.constructor=f}return i.prototype=o.prototype,f.prototype=new i,f.__super__=o.prototype,f},a={}.hasOwnProperty;n=ct(),u=ot(),ie.exports=function(f){c(o,f);function o(t,i,m,N,w,g){if(o.__super__.constructor.call(this,t),i==null)throw new Error("Missing DTD element name. "+this.debugInfo());if(m==null)throw new Error("Missing DTD attribute name. "+this.debugInfo(i));if(!N)throw new Error("Missing DTD attribute type. "+this.debugInfo(i));if(!w)throw new Error("Missing DTD attribute default. "+this.debugInfo(i));if(w.indexOf("#")!==0&&(w="#"+w),!w.match(/^(#REQUIRED|#IMPLIED|#FIXED|#DEFAULT)$/))throw new Error("Invalid default value type; expected: #REQUIRED, #IMPLIED, #FIXED or #DEFAULT. "+this.debugInfo(i));if(g&&!w.match(/^(#FIXED|#DEFAULT)$/))throw new Error("Default value only applies to #FIXED or #DEFAULT. "+this.debugInfo(i));this.elementName=this.stringify.name(i),this.type=u.AttributeDeclaration,this.attributeName=this.stringify.name(m),this.attributeType=this.stringify.dtdAttType(N),g&&(this.defaultValue=this.stringify.dtdAttDefault(g)),this.defaultValueType=w}return o.prototype.toString=function(t){return this.options.writer.dtdAttList(this,this.options.writer.filterOptions(t))},o}(n)}.call(G)),ie.exports}var oe={exports:{}},gr;function je(){return gr||(gr=1,function(){var u,n,c,a=function(o,t){for(var i in t)f.call(t,i)&&(o[i]=t[i]);function m(){this.constructor=o}return m.prototype=t.prototype,o.prototype=new m,o.__super__=t.prototype,o},f={}.hasOwnProperty;c=yt().isObject,n=ct(),u=ot(),oe.exports=function(o){a(t,o);function t(i,m,N,w){if(t.__super__.constructor.call(this,i),N==null)throw new Error("Missing DTD entity name. "+this.debugInfo(N));if(w==null)throw new Error("Missing DTD entity value. "+this.debugInfo(N));if(this.pe=!!m,this.name=this.stringify.name(N),this.type=u.EntityDeclaration,!c(w))this.value=this.stringify.dtdEntityValue(w),this.internal=!0;else{if(!w.pubID&&!w.sysID)throw new Error("Public and/or system identifiers are required for an external entity. "+this.debugInfo(N));if(w.pubID&&!w.sysID)throw new Error("System identifier is required for a public external entity. "+this.debugInfo(N));if(this.internal=!1,w.pubID!=null&&(this.pubID=this.stringify.dtdPubID(w.pubID)),w.sysID!=null&&(this.sysID=this.stringify.dtdSysID(w.sysID)),w.nData!=null&&(this.nData=this.stringify.dtdNData(w.nData)),this.pe&&this.nData)throw new Error("Notation declaration is not allowed in a parameter entity. "+this.debugInfo(N))}}return Object.defineProperty(t.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(t.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(t.prototype,"notationName",{get:function(){return this.nData||null}}),Object.defineProperty(t.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(t.prototype,"xmlEncoding",{get:function(){return null}}),Object.defineProperty(t.prototype,"xmlVersion",{get:function(){return null}}),t.prototype.toString=function(i){return this.options.writer.dtdEntity(this,this.options.writer.filterOptions(i))},t}(n)}.call(G)),oe.exports}var se={exports:{}},wr;function Ue(){return wr||(wr=1,function(){var u,n,c=function(f,o){for(var t in o)a.call(o,t)&&(f[t]=o[t]);function i(){this.constructor=f}return i.prototype=o.prototype,f.prototype=new i,f.__super__=o.prototype,f},a={}.hasOwnProperty;n=ct(),u=ot(),se.exports=function(f){c(o,f);function o(t,i,m){if(o.__super__.constructor.call(this,t),i==null)throw new Error("Missing DTD element name. "+this.debugInfo());m||(m="(#PCDATA)"),Array.isArray(m)&&(m="("+m.join(",")+")"),this.name=this.stringify.name(i),this.type=u.ElementDeclaration,this.value=this.stringify.dtdElementValue(m)}return o.prototype.toString=function(t){return this.options.writer.dtdElement(this,this.options.writer.filterOptions(t))},o}(n)}.call(G)),se.exports}var ae={exports:{}},br;function Xe(){return br||(br=1,function(){var u,n,c=function(f,o){for(var t in o)a.call(o,t)&&(f[t]=o[t]);function i(){this.constructor=f}return i.prototype=o.prototype,f.prototype=new i,f.__super__=o.prototype,f},a={}.hasOwnProperty;n=ct(),u=ot(),ae.exports=function(f){c(o,f);function o(t,i,m){if(o.__super__.constructor.call(this,t),i==null)throw new Error("Missing DTD notation name. "+this.debugInfo(i));if(!m.pubID&&!m.sysID)throw new Error("Public or system identifiers are required for an external entity. "+this.debugInfo(i));this.name=this.stringify.name(i),this.type=u.NotationDeclaration,m.pubID!=null&&(this.pubID=this.stringify.dtdPubID(m.pubID)),m.sysID!=null&&(this.sysID=this.stringify.dtdSysID(m.sysID))}return Object.defineProperty(o.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(o.prototype,"systemId",{get:function(){return this.sysID}}),o.prototype.toString=function(t){return this.options.writer.dtdNotation(this,this.options.writer.filterOptions(t))},o}(n)}.call(G)),ae.exports}var Er;function qe(){return Er||(Er=1,function(){var u,n,c,a,f,o,t,i,m=function(w,g){for(var b in g)N.call(g,b)&&(w[b]=g[b]);function x(){this.constructor=w}return x.prototype=g.prototype,w.prototype=new x,w.__super__=g.prototype,w},N={}.hasOwnProperty;i=yt().isObject,t=ct(),u=ot(),n=Re(),a=je(),c=Ue(),f=Xe(),o=Me(),ne.exports=function(w){m(g,w);function g(b,x,O){var _,E,D,T,p,I;if(g.__super__.constructor.call(this,b),this.type=u.DocType,b.children){for(T=b.children,E=0,D=T.length;E<D;E++)if(_=T[E],_.type===u.Element){this.name=_.name;break}}this.documentObject=b,i(x)&&(p=x,x=p.pubID,O=p.sysID),O==null&&(I=[x,O],O=I[0],x=I[1]),x!=null&&(this.pubID=this.stringify.dtdPubID(x)),O!=null&&(this.sysID=this.stringify.dtdSysID(O))}return Object.defineProperty(g.prototype,"entities",{get:function(){var b,x,O,_,E;for(_={},E=this.children,x=0,O=E.length;x<O;x++)b=E[x],b.type===u.EntityDeclaration&&!b.pe&&(_[b.name]=b);return new o(_)}}),Object.defineProperty(g.prototype,"notations",{get:function(){var b,x,O,_,E;for(_={},E=this.children,x=0,O=E.length;x<O;x++)b=E[x],b.type===u.NotationDeclaration&&(_[b.name]=b);return new o(_)}}),Object.defineProperty(g.prototype,"publicId",{get:function(){return this.pubID}}),Object.defineProperty(g.prototype,"systemId",{get:function(){return this.sysID}}),Object.defineProperty(g.prototype,"internalSubset",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),g.prototype.element=function(b,x){var O;return O=new c(this,b,x),this.children.push(O),this},g.prototype.attList=function(b,x,O,_,E){var D;return D=new n(this,b,x,O,_,E),this.children.push(D),this},g.prototype.entity=function(b,x){var O;return O=new a(this,!1,b,x),this.children.push(O),this},g.prototype.pEntity=function(b,x){var O;return O=new a(this,!0,b,x),this.children.push(O),this},g.prototype.notation=function(b,x){var O;return O=new f(this,b,x),this.children.push(O),this},g.prototype.toString=function(b){return this.options.writer.docType(this,this.options.writer.filterOptions(b))},g.prototype.ele=function(b,x){return this.element(b,x)},g.prototype.att=function(b,x,O,_,E){return this.attList(b,x,O,_,E)},g.prototype.ent=function(b,x){return this.entity(b,x)},g.prototype.pent=function(b,x){return this.pEntity(b,x)},g.prototype.not=function(b,x){return this.notation(b,x)},g.prototype.up=function(){return this.root()||this.documentObject},g.prototype.isEqualNode=function(b){return!(!g.__super__.isEqualNode.apply(this,arguments).isEqualNode(b)||b.name!==this.name||b.publicId!==this.publicId||b.systemId!==this.systemId)},g}(t)}.call(G)),ne.exports}var ue={exports:{}},Tr;function ke(){return Tr||(Tr=1,function(){var u,n,c=function(f,o){for(var t in o)a.call(o,t)&&(f[t]=o[t]);function i(){this.constructor=f}return i.prototype=o.prototype,f.prototype=new i,f.__super__=o.prototype,f},a={}.hasOwnProperty;u=ot(),n=ct(),ue.exports=function(f){c(o,f);function o(t,i){if(o.__super__.constructor.call(this,t),i==null)throw new Error("Missing raw text. "+this.debugInfo());this.type=u.Raw,this.value=this.stringify.raw(i)}return o.prototype.clone=function(){return Object.create(this)},o.prototype.toString=function(t){return this.options.writer.raw(this,this.options.writer.filterOptions(t))},o}(n)}.call(G)),ue.exports}var ce={exports:{}},xr;function Ve(){return xr||(xr=1,function(){var u,n,c=function(f,o){for(var t in o)a.call(o,t)&&(f[t]=o[t]);function i(){this.constructor=f}return i.prototype=o.prototype,f.prototype=new i,f.__super__=o.prototype,f},a={}.hasOwnProperty;u=ot(),n=St(),ce.exports=function(f){c(o,f);function o(t,i){if(o.__super__.constructor.call(this,t),i==null)throw new Error("Missing element text. "+this.debugInfo());this.name="#text",this.type=u.Text,this.value=this.stringify.text(i)}return Object.defineProperty(o.prototype,"isElementContentWhitespace",{get:function(){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),Object.defineProperty(o.prototype,"wholeText",{get:function(){var t,i,m;for(m="",i=this.previousSibling;i;)m=i.data+m,i=i.previousSibling;for(m+=this.data,t=this.nextSibling;t;)m=m+t.data,t=t.nextSibling;return m}}),o.prototype.clone=function(){return Object.create(this)},o.prototype.toString=function(t){return this.options.writer.text(this,this.options.writer.filterOptions(t))},o.prototype.splitText=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},o.prototype.replaceWholeText=function(t){throw new Error("This DOM method is not implemented."+this.debugInfo())},o}(n)}.call(G)),ce.exports}var le={exports:{}},Dr;function $e(){return Dr||(Dr=1,function(){var u,n,c=function(f,o){for(var t in o)a.call(o,t)&&(f[t]=o[t]);function i(){this.constructor=f}return i.prototype=o.prototype,f.prototype=new i,f.__super__=o.prototype,f},a={}.hasOwnProperty;u=ot(),n=St(),le.exports=function(f){c(o,f);function o(t,i,m){if(o.__super__.constructor.call(this,t),i==null)throw new Error("Missing instruction target. "+this.debugInfo());this.type=u.ProcessingInstruction,this.target=this.stringify.insTarget(i),this.name=this.target,m&&(this.value=this.stringify.insValue(m))}return o.prototype.clone=function(){return Object.create(this)},o.prototype.toString=function(t){return this.options.writer.processingInstruction(this,this.options.writer.filterOptions(t))},o.prototype.isEqualNode=function(t){return!(!o.__super__.isEqualNode.apply(this,arguments).isEqualNode(t)||t.target!==this.target)},o}(n)}.call(G)),le.exports}var fe={exports:{}},vr;function un(){return vr||(vr=1,function(){var u,n,c=function(f,o){for(var t in o)a.call(o,t)&&(f[t]=o[t]);function i(){this.constructor=f}return i.prototype=o.prototype,f.prototype=new i,f.__super__=o.prototype,f},a={}.hasOwnProperty;n=ct(),u=ot(),fe.exports=function(f){c(o,f);function o(t){o.__super__.constructor.call(this,t),this.type=u.Dummy}return o.prototype.clone=function(){return Object.create(this)},o.prototype.toString=function(t){return""},o}(n)}.call(G)),fe.exports}var he={exports:{}},Ir;function li(){return Ir||(Ir=1,function(){he.exports=function(){function u(n){this.nodes=n}return Object.defineProperty(u.prototype,"length",{get:function(){return this.nodes.length||0}}),u.prototype.clone=function(){return this.nodes=null},u.prototype.item=function(n){return this.nodes[n]||null},u}()}.call(G)),he.exports}var pe={exports:{}},Nr;function fi(){return Nr||(Nr=1,function(){pe.exports={Disconnected:1,Preceding:2,Following:4,Contains:8,ContainedBy:16,ImplementationSpecific:32}}.call(G)),pe.exports}var Or;function ct(){return Or||(Or=1,function(){var u,n,c,a,f,o,t,i,m,N,w,g,b,x,O,_,E,D={}.hasOwnProperty;E=yt(),_=E.isObject,O=E.isFunction,x=E.isEmpty,b=E.getValue,i=null,c=null,a=null,f=null,o=null,w=null,g=null,N=null,t=null,n=null,m=null,u=null,Yt.exports=function(){function T(p){this.parent=p,this.parent&&(this.options=this.parent.options,this.stringify=this.parent.stringify),this.value=null,this.children=[],this.baseURI=null,i||(i=Pe(),c=Fe(),a=Se(),f=Be(),o=qe(),w=ke(),g=Ve(),N=$e(),t=un(),n=ot(),m=li(),Me(),u=fi())}return Object.defineProperty(T.prototype,"nodeName",{get:function(){return this.name}}),Object.defineProperty(T.prototype,"nodeType",{get:function(){return this.type}}),Object.defineProperty(T.prototype,"nodeValue",{get:function(){return this.value}}),Object.defineProperty(T.prototype,"parentNode",{get:function(){return this.parent}}),Object.defineProperty(T.prototype,"childNodes",{get:function(){return(!this.childNodeList||!this.childNodeList.nodes)&&(this.childNodeList=new m(this.children)),this.childNodeList}}),Object.defineProperty(T.prototype,"firstChild",{get:function(){return this.children[0]||null}}),Object.defineProperty(T.prototype,"lastChild",{get:function(){return this.children[this.children.length-1]||null}}),Object.defineProperty(T.prototype,"previousSibling",{get:function(){var p;return p=this.parent.children.indexOf(this),this.parent.children[p-1]||null}}),Object.defineProperty(T.prototype,"nextSibling",{get:function(){var p;return p=this.parent.children.indexOf(this),this.parent.children[p+1]||null}}),Object.defineProperty(T.prototype,"ownerDocument",{get:function(){return this.document()||null}}),Object.defineProperty(T.prototype,"textContent",{get:function(){var p,I,A,j,U;if(this.nodeType===n.Element||this.nodeType===n.DocumentFragment){for(U="",j=this.children,I=0,A=j.length;I<A;I++)p=j[I],p.textContent&&(U+=p.textContent);return U}else return null},set:function(p){throw new Error("This DOM method is not implemented."+this.debugInfo())}}),T.prototype.setParent=function(p){var I,A,j,U,B;for(this.parent=p,p&&(this.options=p.options,this.stringify=p.stringify),U=this.children,B=[],A=0,j=U.length;A<j;A++)I=U[A],B.push(I.setParent(this));return B},T.prototype.element=function(p,I,A){var j,U,B,h,F,R,X,$,Y,J,z;if(R=null,I===null&&A==null&&(Y=[{},null],I=Y[0],A=Y[1]),I==null&&(I={}),I=b(I),_(I)||(J=[I,A],A=J[0],I=J[1]),p!=null&&(p=b(p)),Array.isArray(p))for(B=0,X=p.length;B<X;B++)U=p[B],R=this.element(U);else if(O(p))R=this.element(p.apply());else if(_(p)){for(F in p)if(D.call(p,F))if(z=p[F],O(z)&&(z=z.apply()),!this.options.ignoreDecorators&&this.stringify.convertAttKey&&F.indexOf(this.stringify.convertAttKey)===0)R=this.attribute(F.substr(this.stringify.convertAttKey.length),z);else if(!this.options.separateArrayItems&&Array.isArray(z)&&x(z))R=this.dummy();else if(_(z)&&x(z))R=this.element(F);else if(!this.options.keepNullNodes&&z==null)R=this.dummy();else if(!this.options.separateArrayItems&&Array.isArray(z))for(h=0,$=z.length;h<$;h++)U=z[h],j={},j[F]=U,R=this.element(j);else _(z)?!this.options.ignoreDecorators&&this.stringify.convertTextKey&&F.indexOf(this.stringify.convertTextKey)===0?R=this.element(z):(R=this.element(F),R.element(z)):R=this.element(F,z)}else!this.options.keepNullNodes&&A===null?R=this.dummy():!this.options.ignoreDecorators&&this.stringify.convertTextKey&&p.indexOf(this.stringify.convertTextKey)===0?R=this.text(A):!this.options.ignoreDecorators&&this.stringify.convertCDataKey&&p.indexOf(this.stringify.convertCDataKey)===0?R=this.cdata(A):!this.options.ignoreDecorators&&this.stringify.convertCommentKey&&p.indexOf(this.stringify.convertCommentKey)===0?R=this.comment(A):!this.options.ignoreDecorators&&this.stringify.convertRawKey&&p.indexOf(this.stringify.convertRawKey)===0?R=this.raw(A):!this.options.ignoreDecorators&&this.stringify.convertPIKey&&p.indexOf(this.stringify.convertPIKey)===0?R=this.instruction(p.substr(this.stringify.convertPIKey.length),A):R=this.node(p,I,A);if(R==null)throw new Error("Could not create any elements with: "+p+". "+this.debugInfo());return R},T.prototype.insertBefore=function(p,I,A){var j,U,B,h,F;if(p?.type)return B=p,h=I,B.setParent(this),h?(U=children.indexOf(h),F=children.splice(U),children.push(B),Array.prototype.push.apply(children,F)):children.push(B),B;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(p));return U=this.parent.children.indexOf(this),F=this.parent.children.splice(U),j=this.parent.element(p,I,A),Array.prototype.push.apply(this.parent.children,F),j},T.prototype.insertAfter=function(p,I,A){var j,U,B;if(this.isRoot)throw new Error("Cannot insert elements at root level. "+this.debugInfo(p));return U=this.parent.children.indexOf(this),B=this.parent.children.splice(U+1),j=this.parent.element(p,I,A),Array.prototype.push.apply(this.parent.children,B),j},T.prototype.remove=function(){var p;if(this.isRoot)throw new Error("Cannot remove the root element. "+this.debugInfo());return p=this.parent.children.indexOf(this),[].splice.apply(this.parent.children,[p,p-p+1].concat([])),this.parent},T.prototype.node=function(p,I,A){var j,U;return p!=null&&(p=b(p)),I||(I={}),I=b(I),_(I)||(U=[I,A],A=U[0],I=U[1]),j=new i(this,p,I),A!=null&&j.text(A),this.children.push(j),j},T.prototype.text=function(p){var I;return _(p)&&this.element(p),I=new g(this,p),this.children.push(I),this},T.prototype.cdata=function(p){var I;return I=new c(this,p),this.children.push(I),this},T.prototype.comment=function(p){var I;return I=new a(this,p),this.children.push(I),this},T.prototype.commentBefore=function(p){var I,A;return I=this.parent.children.indexOf(this),A=this.parent.children.splice(I),this.parent.comment(p),Array.prototype.push.apply(this.parent.children,A),this},T.prototype.commentAfter=function(p){var I,A;return I=this.parent.children.indexOf(this),A=this.parent.children.splice(I+1),this.parent.comment(p),Array.prototype.push.apply(this.parent.children,A),this},T.prototype.raw=function(p){var I;return I=new w(this,p),this.children.push(I),this},T.prototype.dummy=function(){var p;return p=new t(this),p},T.prototype.instruction=function(p,I){var A,j,U,B,h;if(p!=null&&(p=b(p)),I!=null&&(I=b(I)),Array.isArray(p))for(B=0,h=p.length;B<h;B++)A=p[B],this.instruction(A);else if(_(p))for(A in p)D.call(p,A)&&(j=p[A],this.instruction(A,j));else O(I)&&(I=I.apply()),U=new N(this,p,I),this.children.push(U);return this},T.prototype.instructionBefore=function(p,I){var A,j;return A=this.parent.children.indexOf(this),j=this.parent.children.splice(A),this.parent.instruction(p,I),Array.prototype.push.apply(this.parent.children,j),this},T.prototype.instructionAfter=function(p,I){var A,j;return A=this.parent.children.indexOf(this),j=this.parent.children.splice(A+1),this.parent.instruction(p,I),Array.prototype.push.apply(this.parent.children,j),this},T.prototype.declaration=function(p,I,A){var j,U;return j=this.document(),U=new f(j,p,I,A),j.children.length===0?j.children.unshift(U):j.children[0].type===n.Declaration?j.children[0]=U:j.children.unshift(U),j.root()||j},T.prototype.dtd=function(p,I){var A,j,U,B,h,F,R,X,$,Y;for(j=this.document(),U=new o(j,p,I),$=j.children,B=h=0,R=$.length;h<R;B=++h)if(A=$[B],A.type===n.DocType)return j.children[B]=U,U;for(Y=j.children,B=F=0,X=Y.length;F<X;B=++F)if(A=Y[B],A.isRoot)return j.children.splice(B,0,U),U;return j.children.push(U),U},T.prototype.up=function(){if(this.isRoot)throw new Error("The root node has no parent. Use doc() if you need to get the document object.");return this.parent},T.prototype.root=function(){var p;for(p=this;p;){if(p.type===n.Document)return p.rootObject;if(p.isRoot)return p;p=p.parent}},T.prototype.document=function(){var p;for(p=this;p;){if(p.type===n.Document)return p;p=p.parent}},T.prototype.end=function(p){return this.document().end(p)},T.prototype.prev=function(){var p;if(p=this.parent.children.indexOf(this),p<1)throw new Error("Already at the first node. "+this.debugInfo());return this.parent.children[p-1]},T.prototype.next=function(){var p;if(p=this.parent.children.indexOf(this),p===-1||p===this.parent.children.length-1)throw new Error("Already at the last node. "+this.debugInfo());return this.parent.children[p+1]},T.prototype.importDocument=function(p){var I;return I=p.root().clone(),I.parent=this,I.isRoot=!1,this.children.push(I),this},T.prototype.debugInfo=function(p){var I,A;return p=p||this.name,p==null&&!((I=this.parent)!=null&&I.name)?"":p==null?"parent: <"+this.parent.name+">":(A=this.parent)!=null&&A.name?"node: <"+p+">, parent: <"+this.parent.name+">":"node: <"+p+">"},T.prototype.ele=function(p,I,A){return this.element(p,I,A)},T.prototype.nod=function(p,I,A){return this.node(p,I,A)},T.prototype.txt=function(p){return this.text(p)},T.prototype.dat=function(p){return this.cdata(p)},T.prototype.com=function(p){return this.comment(p)},T.prototype.ins=function(p,I){return this.instruction(p,I)},T.prototype.doc=function(){return this.document()},T.prototype.dec=function(p,I,A){return this.declaration(p,I,A)},T.prototype.e=function(p,I,A){return this.element(p,I,A)},T.prototype.n=function(p,I,A){return this.node(p,I,A)},T.prototype.t=function(p){return this.text(p)},T.prototype.d=function(p){return this.cdata(p)},T.prototype.c=function(p){return this.comment(p)},T.prototype.r=function(p){return this.raw(p)},T.prototype.i=function(p,I){return this.instruction(p,I)},T.prototype.u=function(){return this.up()},T.prototype.importXMLBuilder=function(p){return this.importDocument(p)},T.prototype.replaceChild=function(p,I){throw new Error("This DOM method is not implemented."+this.debugInfo())},T.prototype.removeChild=function(p){throw new Error("This DOM method is not implemented."+this.debugInfo())},T.prototype.appendChild=function(p){throw new Error("This DOM method is not implemented."+this.debugInfo())},T.prototype.hasChildNodes=function(){return this.children.length!==0},T.prototype.cloneNode=function(p){throw new Error("This DOM method is not implemented."+this.debugInfo())},T.prototype.normalize=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},T.prototype.isSupported=function(p,I){return!0},T.prototype.hasAttributes=function(){return this.attribs.length!==0},T.prototype.compareDocumentPosition=function(p){var I,A;return I=this,I===p?0:this.document()!==p.document()?(A=u.Disconnected|u.ImplementationSpecific,Math.random()<.5?A|=u.Preceding:A|=u.Following,A):I.isAncestor(p)?u.Contains|u.Preceding:I.isDescendant(p)?u.Contains|u.Following:I.isPreceding(p)?u.Preceding:u.Following},T.prototype.isSameNode=function(p){throw new Error("This DOM method is not implemented."+this.debugInfo())},T.prototype.lookupPrefix=function(p){throw new Error("This DOM method is not implemented."+this.debugInfo())},T.prototype.isDefaultNamespace=function(p){throw new Error("This DOM method is not implemented."+this.debugInfo())},T.prototype.lookupNamespaceURI=function(p){throw new Error("This DOM method is not implemented."+this.debugInfo())},T.prototype.isEqualNode=function(p){var I,A,j;if(p.nodeType!==this.nodeType||p.children.length!==this.children.length)return!1;for(I=A=0,j=this.children.length-1;0<=j?A<=j:A>=j;I=0<=j?++A:--A)if(!this.children[I].isEqualNode(p.children[I]))return!1;return!0},T.prototype.getFeature=function(p,I){throw new Error("This DOM method is not implemented."+this.debugInfo())},T.prototype.setUserData=function(p,I,A){throw new Error("This DOM method is not implemented."+this.debugInfo())},T.prototype.getUserData=function(p){throw new Error("This DOM method is not implemented."+this.debugInfo())},T.prototype.contains=function(p){return p?p===this||this.isDescendant(p):!1},T.prototype.isDescendant=function(p){var I,A,j,U,B;for(B=this.children,j=0,U=B.length;j<U;j++)if(I=B[j],p===I||(A=I.isDescendant(p),A))return!0;return!1},T.prototype.isAncestor=function(p){return p.isDescendant(this)},T.prototype.isPreceding=function(p){var I,A;return I=this.treePosition(p),A=this.treePosition(this),I===-1||A===-1?!1:I<A},T.prototype.isFollowing=function(p){var I,A;return I=this.treePosition(p),A=this.treePosition(this),I===-1||A===-1?!1:I>A},T.prototype.treePosition=function(p){var I,A;return A=0,I=!1,this.foreachTreeNode(this.document(),function(j){if(A++,!I&&j===p)return I=!0}),I?A:-1},T.prototype.foreachTreeNode=function(p,I){var A,j,U,B,h;for(p||(p=this.document()),B=p.children,j=0,U=B.length;j<U;j++){if(A=B[j],h=I(A))return h;if(h=this.foreachTreeNode(A,I),h)return h}},T}()}.call(G)),Yt.exports}var de={exports:{}},Cr;function cn(){return Cr||(Cr=1,function(){var u=function(c,a){return function(){return c.apply(a,arguments)}},n={}.hasOwnProperty;de.exports=function(){function c(a){this.assertLegalName=u(this.assertLegalName,this),this.assertLegalChar=u(this.assertLegalChar,this);var f,o,t;a||(a={}),this.options=a,this.options.version||(this.options.version="1.0"),o=a.stringify||{};for(f in o)n.call(o,f)&&(t=o[f],this[f]=t)}return c.prototype.name=function(a){return this.options.noValidation?a:this.assertLegalName(""+a||"")},c.prototype.text=function(a){return this.options.noValidation?a:this.assertLegalChar(this.textEscape(""+a||""))},c.prototype.cdata=function(a){return this.options.noValidation?a:(a=""+a||"",a=a.replace("]]>","]]]]><![CDATA[>"),this.assertLegalChar(a))},c.prototype.comment=function(a){if(this.options.noValidation)return a;if(a=""+a||"",a.match(/--/))throw new Error("Comment text cannot contain double-hypen: "+a);return this.assertLegalChar(a)},c.prototype.raw=function(a){return this.options.noValidation?a:""+a||""},c.prototype.attValue=function(a){return this.options.noValidation?a:this.assertLegalChar(this.attEscape(a=""+a||""))},c.prototype.insTarget=function(a){return this.options.noValidation?a:this.assertLegalChar(""+a||"")},c.prototype.insValue=function(a){if(this.options.noValidation)return a;if(a=""+a||"",a.match(/\?>/))throw new Error("Invalid processing instruction value: "+a);return this.assertLegalChar(a)},c.prototype.xmlVersion=function(a){if(this.options.noValidation)return a;if(a=""+a||"",!a.match(/1\.[0-9]+/))throw new Error("Invalid version number: "+a);return a},c.prototype.xmlEncoding=function(a){if(this.options.noValidation)return a;if(a=""+a||"",!a.match(/^[A-Za-z](?:[A-Za-z0-9._-])*$/))throw new Error("Invalid encoding: "+a);return this.assertLegalChar(a)},c.prototype.xmlStandalone=function(a){return this.options.noValidation?a:a?"yes":"no"},c.prototype.dtdPubID=function(a){return this.options.noValidation?a:this.assertLegalChar(""+a||"")},c.prototype.dtdSysID=function(a){return this.options.noValidation?a:this.assertLegalChar(""+a||"")},c.prototype.dtdElementValue=function(a){return this.options.noValidation?a:this.assertLegalChar(""+a||"")},c.prototype.dtdAttType=function(a){return this.options.noValidation?a:this.assertLegalChar(""+a||"")},c.prototype.dtdAttDefault=function(a){return this.options.noValidation?a:this.assertLegalChar(""+a||"")},c.prototype.dtdEntityValue=function(a){return this.options.noValidation?a:this.assertLegalChar(""+a||"")},c.prototype.dtdNData=function(a){return this.options.noValidation?a:this.assertLegalChar(""+a||"")},c.prototype.convertAttKey="@",c.prototype.convertPIKey="?",c.prototype.convertTextKey="#text",c.prototype.convertCDataKey="#cdata",c.prototype.convertCommentKey="#comment",c.prototype.convertRawKey="#raw",c.prototype.assertLegalChar=function(a){var f,o;if(this.options.noValidation)return a;if(f="",this.options.version==="1.0"){if(f=/[\0-\x08\x0B\f\x0E-\x1F\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,o=a.match(f))throw new Error("Invalid character in string: "+a+" at index "+o.index)}else if(this.options.version==="1.1"&&(f=/[\0\uFFFE\uFFFF]|[\uD800-\uDBFF](?![\uDC00-\uDFFF])|(?:[^\uD800-\uDBFF]|^)[\uDC00-\uDFFF]/,o=a.match(f)))throw new Error("Invalid character in string: "+a+" at index "+o.index);return a},c.prototype.assertLegalName=function(a){var f;if(this.options.noValidation)return a;if(this.assertLegalChar(a),f=/^([:A-Z_a-z\xC0-\xD6\xD8-\xF6\xF8-\u02FF\u0370-\u037D\u037F-\u1FFF\u200C\u200D\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])([\x2D\.0-:A-Z_a-z\xB7\xC0-\xD6\xD8-\xF6\xF8-\u037D\u037F-\u1FFF\u200C\u200D\u203F\u2040\u2070-\u218F\u2C00-\u2FEF\u3001-\uD7FF\uF900-\uFDCF\uFDF0-\uFFFD]|[\uD800-\uDB7F][\uDC00-\uDFFF])*$/,!a.match(f))throw new Error("Invalid character in name");return a},c.prototype.textEscape=function(a){var f;return this.options.noValidation?a:(f=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,a.replace(f,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/\r/g,"&#xD;"))},c.prototype.attEscape=function(a){var f;return this.options.noValidation?a:(f=this.options.noDoubleEncoding?/(?!&\S+;)&/g:/&/g,a.replace(f,"&amp;").replace(/</g,"&lt;").replace(/"/g,"&quot;").replace(/\t/g,"&#x9;").replace(/\n/g,"&#xA;").replace(/\r/g,"&#xD;"))},c}()}.call(G)),de.exports}var me={exports:{}},ye={exports:{}},ge={exports:{}},Ar;function Bt(){return Ar||(Ar=1,function(){ge.exports={None:0,OpenTag:1,InsideTag:2,CloseTag:3}}.call(G)),ge.exports}var Lr;function ln(){return Lr||(Lr=1,function(){var u,n,c,a={}.hasOwnProperty;c=yt().assign,u=ot(),Be(),qe(),Fe(),Se(),Pe(),ke(),Ve(),$e(),un(),Re(),Ue(),je(),Xe(),n=Bt(),ye.exports=function(){function f(o){var t,i,m;o||(o={}),this.options=o,i=o.writer||{};for(t in i)a.call(i,t)&&(m=i[t],this["_"+t]=this[t],this[t]=m)}return f.prototype.filterOptions=function(o){var t,i,m,N,w,g,b,x;return o||(o={}),o=c({},this.options,o),t={writer:this},t.pretty=o.pretty||!1,t.allowEmpty=o.allowEmpty||!1,t.indent=(i=o.indent)!=null?i:" ",t.newline=(m=o.newline)!=null?m:`
29
29
  `,t.offset=(N=o.offset)!=null?N:0,t.dontPrettyTextNodes=(w=(g=o.dontPrettyTextNodes)!=null?g:o.dontprettytextnodes)!=null?w:0,t.spaceBeforeSlash=(b=(x=o.spaceBeforeSlash)!=null?x:o.spacebeforeslash)!=null?b:"",t.spaceBeforeSlash===!0&&(t.spaceBeforeSlash=" "),t.suppressPrettyCount=0,t.user={},t.state=n.None,t},f.prototype.indent=function(o,t,i){var m;return!t.pretty||t.suppressPrettyCount?"":t.pretty&&(m=(i||0)+t.offset+1,m>0)?new Array(m).join(t.indent):""},f.prototype.endline=function(o,t,i){return!t.pretty||t.suppressPrettyCount?"":t.newline},f.prototype.attribute=function(o,t,i){var m;return this.openAttribute(o,t,i),m=" "+o.name+'="'+o.value+'"',this.closeAttribute(o,t,i),m},f.prototype.cdata=function(o,t,i){var m;return this.openNode(o,t,i),t.state=n.OpenTag,m=this.indent(o,t,i)+"<![CDATA[",t.state=n.InsideTag,m+=o.value,t.state=n.CloseTag,m+="]]>"+this.endline(o,t,i),t.state=n.None,this.closeNode(o,t,i),m},f.prototype.comment=function(o,t,i){var m;return this.openNode(o,t,i),t.state=n.OpenTag,m=this.indent(o,t,i)+"<!-- ",t.state=n.InsideTag,m+=o.value,t.state=n.CloseTag,m+=" -->"+this.endline(o,t,i),t.state=n.None,this.closeNode(o,t,i),m},f.prototype.declaration=function(o,t,i){var m;return this.openNode(o,t,i),t.state=n.OpenTag,m=this.indent(o,t,i)+"<?xml",t.state=n.InsideTag,m+=' version="'+o.version+'"',o.encoding!=null&&(m+=' encoding="'+o.encoding+'"'),o.standalone!=null&&(m+=' standalone="'+o.standalone+'"'),t.state=n.CloseTag,m+=t.spaceBeforeSlash+"?>",m+=this.endline(o,t,i),t.state=n.None,this.closeNode(o,t,i),m},f.prototype.docType=function(o,t,i){var m,N,w,g,b;if(i||(i=0),this.openNode(o,t,i),t.state=n.OpenTag,g=this.indent(o,t,i),g+="<!DOCTYPE "+o.root().name,o.pubID&&o.sysID?g+=' PUBLIC "'+o.pubID+'" "'+o.sysID+'"':o.sysID&&(g+=' SYSTEM "'+o.sysID+'"'),o.children.length>0){for(g+=" [",g+=this.endline(o,t,i),t.state=n.InsideTag,b=o.children,N=0,w=b.length;N<w;N++)m=b[N],g+=this.writeChildNode(m,t,i+1);t.state=n.CloseTag,g+="]"}return t.state=n.CloseTag,g+=t.spaceBeforeSlash+">",g+=this.endline(o,t,i),t.state=n.None,this.closeNode(o,t,i),g},f.prototype.element=function(o,t,i){var m,N,w,g,b,x,O,_,E,D,T,p,I,A;i||(i=0),D=!1,T="",this.openNode(o,t,i),t.state=n.OpenTag,T+=this.indent(o,t,i)+"<"+o.name,p=o.attribs;for(E in p)a.call(p,E)&&(m=p[E],T+=this.attribute(m,t,i));if(w=o.children.length,g=w===0?null:o.children[0],w===0||o.children.every(function(j){return(j.type===u.Text||j.type===u.Raw)&&j.value===""}))t.allowEmpty?(T+=">",t.state=n.CloseTag,T+="</"+o.name+">"+this.endline(o,t,i)):(t.state=n.CloseTag,T+=t.spaceBeforeSlash+"/>"+this.endline(o,t,i));else if(t.pretty&&w===1&&(g.type===u.Text||g.type===u.Raw)&&g.value!=null)T+=">",t.state=n.InsideTag,t.suppressPrettyCount++,D=!0,T+=this.writeChildNode(g,t,i+1),t.suppressPrettyCount--,D=!1,t.state=n.CloseTag,T+="</"+o.name+">"+this.endline(o,t,i);else{if(t.dontPrettyTextNodes){for(I=o.children,b=0,O=I.length;b<O;b++)if(N=I[b],(N.type===u.Text||N.type===u.Raw)&&N.value!=null){t.suppressPrettyCount++,D=!0;break}}for(T+=">"+this.endline(o,t,i),t.state=n.InsideTag,A=o.children,x=0,_=A.length;x<_;x++)N=A[x],T+=this.writeChildNode(N,t,i+1);t.state=n.CloseTag,T+=this.indent(o,t,i)+"</"+o.name+">",D&&t.suppressPrettyCount--,T+=this.endline(o,t,i),t.state=n.None}return this.closeNode(o,t,i),T},f.prototype.writeChildNode=function(o,t,i){switch(o.type){case u.CData:return this.cdata(o,t,i);case u.Comment:return this.comment(o,t,i);case u.Element:return this.element(o,t,i);case u.Raw:return this.raw(o,t,i);case u.Text:return this.text(o,t,i);case u.ProcessingInstruction:return this.processingInstruction(o,t,i);case u.Dummy:return"";case u.Declaration:return this.declaration(o,t,i);case u.DocType:return this.docType(o,t,i);case u.AttributeDeclaration:return this.dtdAttList(o,t,i);case u.ElementDeclaration:return this.dtdElement(o,t,i);case u.EntityDeclaration:return this.dtdEntity(o,t,i);case u.NotationDeclaration:return this.dtdNotation(o,t,i);default:throw new Error("Unknown XML node type: "+o.constructor.name)}},f.prototype.processingInstruction=function(o,t,i){var m;return this.openNode(o,t,i),t.state=n.OpenTag,m=this.indent(o,t,i)+"<?",t.state=n.InsideTag,m+=o.target,o.value&&(m+=" "+o.value),t.state=n.CloseTag,m+=t.spaceBeforeSlash+"?>",m+=this.endline(o,t,i),t.state=n.None,this.closeNode(o,t,i),m},f.prototype.raw=function(o,t,i){var m;return this.openNode(o,t,i),t.state=n.OpenTag,m=this.indent(o,t,i),t.state=n.InsideTag,m+=o.value,t.state=n.CloseTag,m+=this.endline(o,t,i),t.state=n.None,this.closeNode(o,t,i),m},f.prototype.text=function(o,t,i){var m;return this.openNode(o,t,i),t.state=n.OpenTag,m=this.indent(o,t,i),t.state=n.InsideTag,m+=o.value,t.state=n.CloseTag,m+=this.endline(o,t,i),t.state=n.None,this.closeNode(o,t,i),m},f.prototype.dtdAttList=function(o,t,i){var m;return this.openNode(o,t,i),t.state=n.OpenTag,m=this.indent(o,t,i)+"<!ATTLIST",t.state=n.InsideTag,m+=" "+o.elementName+" "+o.attributeName+" "+o.attributeType,o.defaultValueType!=="#DEFAULT"&&(m+=" "+o.defaultValueType),o.defaultValue&&(m+=' "'+o.defaultValue+'"'),t.state=n.CloseTag,m+=t.spaceBeforeSlash+">"+this.endline(o,t,i),t.state=n.None,this.closeNode(o,t,i),m},f.prototype.dtdElement=function(o,t,i){var m;return this.openNode(o,t,i),t.state=n.OpenTag,m=this.indent(o,t,i)+"<!ELEMENT",t.state=n.InsideTag,m+=" "+o.name+" "+o.value,t.state=n.CloseTag,m+=t.spaceBeforeSlash+">"+this.endline(o,t,i),t.state=n.None,this.closeNode(o,t,i),m},f.prototype.dtdEntity=function(o,t,i){var m;return this.openNode(o,t,i),t.state=n.OpenTag,m=this.indent(o,t,i)+"<!ENTITY",t.state=n.InsideTag,o.pe&&(m+=" %"),m+=" "+o.name,o.value?m+=' "'+o.value+'"':(o.pubID&&o.sysID?m+=' PUBLIC "'+o.pubID+'" "'+o.sysID+'"':o.sysID&&(m+=' SYSTEM "'+o.sysID+'"'),o.nData&&(m+=" NDATA "+o.nData)),t.state=n.CloseTag,m+=t.spaceBeforeSlash+">"+this.endline(o,t,i),t.state=n.None,this.closeNode(o,t,i),m},f.prototype.dtdNotation=function(o,t,i){var m;return this.openNode(o,t,i),t.state=n.OpenTag,m=this.indent(o,t,i)+"<!NOTATION",t.state=n.InsideTag,m+=" "+o.name,o.pubID&&o.sysID?m+=' PUBLIC "'+o.pubID+'" "'+o.sysID+'"':o.pubID?m+=' PUBLIC "'+o.pubID+'"':o.sysID&&(m+=' SYSTEM "'+o.sysID+'"'),t.state=n.CloseTag,m+=t.spaceBeforeSlash+">"+this.endline(o,t,i),t.state=n.None,this.closeNode(o,t,i),m},f.prototype.openNode=function(o,t,i){},f.prototype.closeNode=function(o,t,i){},f.prototype.openAttribute=function(o,t,i){},f.prototype.closeAttribute=function(o,t,i){},f}()}.call(G)),ye.exports}var _r;function We(){return _r||(_r=1,function(){var u,n=function(a,f){for(var o in f)c.call(f,o)&&(a[o]=f[o]);function t(){this.constructor=a}return t.prototype=f.prototype,a.prototype=new t,a.__super__=f.prototype,a},c={}.hasOwnProperty;u=ln(),me.exports=function(a){n(f,a);function f(o){f.__super__.constructor.call(this,o)}return f.prototype.document=function(o,t){var i,m,N,w,g;for(t=this.filterOptions(t),w="",g=o.children,m=0,N=g.length;m<N;m++)i=g[m],w+=this.writeChildNode(i,t,0);return t.pretty&&w.slice(-t.newline.length)===t.newline&&(w=w.slice(0,-t.newline.length)),w},f}(u)}.call(G)),me.exports}var Mr;function fn(){return Mr||(Mr=1,function(){var u,n,c,a,f,o,t,i=function(N,w){for(var g in w)m.call(w,g)&&(N[g]=w[g]);function b(){this.constructor=N}return b.prototype=w.prototype,N.prototype=new b,N.__super__=w.prototype,N},m={}.hasOwnProperty;t=yt().isPlainObject,c=sn(),n=ci(),a=ct(),u=ot(),o=cn(),f=We(),$t.exports=function(N){i(w,N);function w(g){w.__super__.constructor.call(this,null),this.name="#document",this.type=u.Document,this.documentURI=null,this.domConfig=new n,g||(g={}),g.writer||(g.writer=new f),this.options=g,this.stringify=new o(g)}return Object.defineProperty(w.prototype,"implementation",{value:new c}),Object.defineProperty(w.prototype,"doctype",{get:function(){var g,b,x,O;for(O=this.children,b=0,x=O.length;b<x;b++)if(g=O[b],g.type===u.DocType)return g;return null}}),Object.defineProperty(w.prototype,"documentElement",{get:function(){return this.rootObject||null}}),Object.defineProperty(w.prototype,"inputEncoding",{get:function(){return null}}),Object.defineProperty(w.prototype,"strictErrorChecking",{get:function(){return!1}}),Object.defineProperty(w.prototype,"xmlEncoding",{get:function(){return this.children.length!==0&&this.children[0].type===u.Declaration?this.children[0].encoding:null}}),Object.defineProperty(w.prototype,"xmlStandalone",{get:function(){return this.children.length!==0&&this.children[0].type===u.Declaration?this.children[0].standalone==="yes":!1}}),Object.defineProperty(w.prototype,"xmlVersion",{get:function(){return this.children.length!==0&&this.children[0].type===u.Declaration?this.children[0].version:"1.0"}}),Object.defineProperty(w.prototype,"URL",{get:function(){return this.documentURI}}),Object.defineProperty(w.prototype,"origin",{get:function(){return null}}),Object.defineProperty(w.prototype,"compatMode",{get:function(){return null}}),Object.defineProperty(w.prototype,"characterSet",{get:function(){return null}}),Object.defineProperty(w.prototype,"contentType",{get:function(){return null}}),w.prototype.end=function(g){var b;return b={},g?t(g)&&(b=g,g=this.options.writer):g=this.options.writer,g.document(this,g.filterOptions(b))},w.prototype.toString=function(g){return this.options.writer.document(this,this.options.writer.filterOptions(g))},w.prototype.createElement=function(g){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createDocumentFragment=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createTextNode=function(g){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createComment=function(g){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createCDATASection=function(g){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createProcessingInstruction=function(g,b){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createAttribute=function(g){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createEntityReference=function(g){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.getElementsByTagName=function(g){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.importNode=function(g,b){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createElementNS=function(g,b){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createAttributeNS=function(g,b){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.getElementsByTagNameNS=function(g,b){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.getElementById=function(g){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.adoptNode=function(g){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.normalizeDocument=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.renameNode=function(g,b,x){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.getElementsByClassName=function(g){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createEvent=function(g){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createRange=function(){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createNodeIterator=function(g,b,x){throw new Error("This DOM method is not implemented."+this.debugInfo())},w.prototype.createTreeWalker=function(g,b,x){throw new Error("This DOM method is not implemented."+this.debugInfo())},w}(a)}.call(G)),$t.exports}var we={exports:{}},Pr;function hi(){return Pr||(Pr=1,function(){var u,n,c,a,f,o,t,i,m,N,w,g,b,x,O,_,E,D,T,p,I,A,j,U={}.hasOwnProperty;j=yt(),I=j.isObject,p=j.isFunction,A=j.isPlainObject,T=j.getValue,u=ot(),g=fn(),b=Pe(),a=Fe(),f=Se(),O=ke(),D=Ve(),x=$e(),N=Be(),w=qe(),o=Re(),i=je(),t=Ue(),m=Xe(),c=an(),E=cn(),_=We(),n=Bt(),we.exports=function(){function B(h,F,R){var X;this.name="?xml",this.type=u.Document,h||(h={}),X={},h.writer?A(h.writer)&&(X=h.writer,h.writer=new _):h.writer=new _,this.options=h,this.writer=h.writer,this.writerOptions=this.writer.filterOptions(X),this.stringify=new E(h),this.onDataCallback=F||function(){},this.onEndCallback=R||function(){},this.currentNode=null,this.currentLevel=-1,this.openTags={},this.documentStarted=!1,this.documentCompleted=!1,this.root=null}return B.prototype.createChildNode=function(h){var F,R,X,$,Y,J,z,W;switch(h.type){case u.CData:this.cdata(h.value);break;case u.Comment:this.comment(h.value);break;case u.Element:X={},z=h.attribs;for(R in z)U.call(z,R)&&(F=z[R],X[R]=F.value);this.node(h.name,X);break;case u.Dummy:this.dummy();break;case u.Raw:this.raw(h.value);break;case u.Text:this.text(h.value);break;case u.ProcessingInstruction:this.instruction(h.target,h.value);break;default:throw new Error("This XML node type is not supported in a JS object: "+h.constructor.name)}for(W=h.children,Y=0,J=W.length;Y<J;Y++)$=W[Y],this.createChildNode($),$.type===u.Element&&this.up();return this},B.prototype.dummy=function(){return this},B.prototype.node=function(h,F,R){var X;if(h==null)throw new Error("Missing node name.");if(this.root&&this.currentLevel===-1)throw new Error("Document can only have one root node. "+this.debugInfo(h));return this.openCurrent(),h=T(h),F==null&&(F={}),F=T(F),I(F)||(X=[F,R],R=X[0],F=X[1]),this.currentNode=new b(this,h,F),this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,R!=null&&this.text(R),this},B.prototype.element=function(h,F,R){var X,$,Y,J,z,W;if(this.currentNode&&this.currentNode.type===u.DocType)this.dtdElement.apply(this,arguments);else if(Array.isArray(h)||I(h)||p(h))for(J=this.options.noValidation,this.options.noValidation=!0,W=new g(this.options).element("TEMP_ROOT"),W.element(h),this.options.noValidation=J,z=W.children,$=0,Y=z.length;$<Y;$++)X=z[$],this.createChildNode(X),X.type===u.Element&&this.up();else this.node(h,F,R);return this},B.prototype.attribute=function(h,F){var R,X;if(!this.currentNode||this.currentNode.children)throw new Error("att() can only be used immediately after an ele() call in callback mode. "+this.debugInfo(h));if(h!=null&&(h=T(h)),I(h))for(R in h)U.call(h,R)&&(X=h[R],this.attribute(R,X));else p(F)&&(F=F.apply()),this.options.keepNullAttributes&&F==null?this.currentNode.attribs[h]=new c(this,h,""):F!=null&&(this.currentNode.attribs[h]=new c(this,h,F));return this},B.prototype.text=function(h){var F;return this.openCurrent(),F=new D(this,h),this.onData(this.writer.text(F,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},B.prototype.cdata=function(h){var F;return this.openCurrent(),F=new a(this,h),this.onData(this.writer.cdata(F,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},B.prototype.comment=function(h){var F;return this.openCurrent(),F=new f(this,h),this.onData(this.writer.comment(F,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},B.prototype.raw=function(h){var F;return this.openCurrent(),F=new O(this,h),this.onData(this.writer.raw(F,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},B.prototype.instruction=function(h,F){var R,X,$,Y,J;if(this.openCurrent(),h!=null&&(h=T(h)),F!=null&&(F=T(F)),Array.isArray(h))for(R=0,Y=h.length;R<Y;R++)X=h[R],this.instruction(X);else if(I(h))for(X in h)U.call(h,X)&&($=h[X],this.instruction(X,$));else p(F)&&(F=F.apply()),J=new x(this,h,F),this.onData(this.writer.processingInstruction(J,this.writerOptions,this.currentLevel+1),this.currentLevel+1);return this},B.prototype.declaration=function(h,F,R){var X;if(this.openCurrent(),this.documentStarted)throw new Error("declaration() must be the first node.");return X=new N(this,h,F,R),this.onData(this.writer.declaration(X,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},B.prototype.doctype=function(h,F,R){if(this.openCurrent(),h==null)throw new Error("Missing root node name.");if(this.root)throw new Error("dtd() must come before the root node.");return this.currentNode=new w(this,F,R),this.currentNode.rootNodeName=h,this.currentNode.children=!1,this.currentLevel++,this.openTags[this.currentLevel]=this.currentNode,this},B.prototype.dtdElement=function(h,F){var R;return this.openCurrent(),R=new t(this,h,F),this.onData(this.writer.dtdElement(R,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},B.prototype.attList=function(h,F,R,X,$){var Y;return this.openCurrent(),Y=new o(this,h,F,R,X,$),this.onData(this.writer.dtdAttList(Y,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},B.prototype.entity=function(h,F){var R;return this.openCurrent(),R=new i(this,!1,h,F),this.onData(this.writer.dtdEntity(R,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},B.prototype.pEntity=function(h,F){var R;return this.openCurrent(),R=new i(this,!0,h,F),this.onData(this.writer.dtdEntity(R,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},B.prototype.notation=function(h,F){var R;return this.openCurrent(),R=new m(this,h,F),this.onData(this.writer.dtdNotation(R,this.writerOptions,this.currentLevel+1),this.currentLevel+1),this},B.prototype.up=function(){if(this.currentLevel<0)throw new Error("The document node has no parent.");return this.currentNode?(this.currentNode.children?this.closeNode(this.currentNode):this.openNode(this.currentNode),this.currentNode=null):this.closeNode(this.openTags[this.currentLevel]),delete this.openTags[this.currentLevel],this.currentLevel--,this},B.prototype.end=function(){for(;this.currentLevel>=0;)this.up();return this.onEnd()},B.prototype.openCurrent=function(){if(this.currentNode)return this.currentNode.children=!0,this.openNode(this.currentNode)},B.prototype.openNode=function(h){var F,R,X,$;if(!h.isOpen){if(!this.root&&this.currentLevel===0&&h.type===u.Element&&(this.root=h),R="",h.type===u.Element){this.writerOptions.state=n.OpenTag,R=this.writer.indent(h,this.writerOptions,this.currentLevel)+"<"+h.name,$=h.attribs;for(X in $)U.call($,X)&&(F=$[X],R+=this.writer.attribute(F,this.writerOptions,this.currentLevel));R+=(h.children?">":"/>")+this.writer.endline(h,this.writerOptions,this.currentLevel),this.writerOptions.state=n.InsideTag}else this.writerOptions.state=n.OpenTag,R=this.writer.indent(h,this.writerOptions,this.currentLevel)+"<!DOCTYPE "+h.rootNodeName,h.pubID&&h.sysID?R+=' PUBLIC "'+h.pubID+'" "'+h.sysID+'"':h.sysID&&(R+=' SYSTEM "'+h.sysID+'"'),h.children?(R+=" [",this.writerOptions.state=n.InsideTag):(this.writerOptions.state=n.CloseTag,R+=">"),R+=this.writer.endline(h,this.writerOptions,this.currentLevel);return this.onData(R,this.currentLevel),h.isOpen=!0}},B.prototype.closeNode=function(h){var F;if(!h.isClosed)return F="",this.writerOptions.state=n.CloseTag,h.type===u.Element?F=this.writer.indent(h,this.writerOptions,this.currentLevel)+"</"+h.name+">"+this.writer.endline(h,this.writerOptions,this.currentLevel):F=this.writer.indent(h,this.writerOptions,this.currentLevel)+"]>"+this.writer.endline(h,this.writerOptions,this.currentLevel),this.writerOptions.state=n.None,this.onData(F,this.currentLevel),h.isClosed=!0},B.prototype.onData=function(h,F){return this.documentStarted=!0,this.onDataCallback(h,F+1)},B.prototype.onEnd=function(){return this.documentCompleted=!0,this.onEndCallback()},B.prototype.debugInfo=function(h){return h==null?"":"node: <"+h+">"},B.prototype.ele=function(){return this.element.apply(this,arguments)},B.prototype.nod=function(h,F,R){return this.node(h,F,R)},B.prototype.txt=function(h){return this.text(h)},B.prototype.dat=function(h){return this.cdata(h)},B.prototype.com=function(h){return this.comment(h)},B.prototype.ins=function(h,F){return this.instruction(h,F)},B.prototype.dec=function(h,F,R){return this.declaration(h,F,R)},B.prototype.dtd=function(h,F,R){return this.doctype(h,F,R)},B.prototype.e=function(h,F,R){return this.element(h,F,R)},B.prototype.n=function(h,F,R){return this.node(h,F,R)},B.prototype.t=function(h){return this.text(h)},B.prototype.d=function(h){return this.cdata(h)},B.prototype.c=function(h){return this.comment(h)},B.prototype.r=function(h){return this.raw(h)},B.prototype.i=function(h,F){return this.instruction(h,F)},B.prototype.att=function(){return this.currentNode&&this.currentNode.type===u.DocType?this.attList.apply(this,arguments):this.attribute.apply(this,arguments)},B.prototype.a=function(){return this.currentNode&&this.currentNode.type===u.DocType?this.attList.apply(this,arguments):this.attribute.apply(this,arguments)},B.prototype.ent=function(h,F){return this.entity(h,F)},B.prototype.pent=function(h,F){return this.pEntity(h,F)},B.prototype.not=function(h,F){return this.notation(h,F)},B}()}.call(G)),we.exports}var be={exports:{}},Fr;function pi(){return Fr||(Fr=1,function(){var u,n,c,a=function(o,t){for(var i in t)f.call(t,i)&&(o[i]=t[i]);function m(){this.constructor=o}return m.prototype=t.prototype,o.prototype=new m,o.__super__=t.prototype,o},f={}.hasOwnProperty;u=ot(),c=ln(),n=Bt(),be.exports=function(o){a(t,o);function t(i,m){this.stream=i,t.__super__.constructor.call(this,m)}return t.prototype.endline=function(i,m,N){return i.isLastRootNode&&m.state===n.CloseTag?"":t.__super__.endline.call(this,i,m,N)},t.prototype.document=function(i,m){var N,w,g,b,x,O,_,E,D;for(_=i.children,w=g=0,x=_.length;g<x;w=++g)N=_[w],N.isLastRootNode=w===i.children.length-1;for(m=this.filterOptions(m),E=i.children,D=[],b=0,O=E.length;b<O;b++)N=E[b],D.push(this.writeChildNode(N,m,0));return D},t.prototype.attribute=function(i,m,N){return this.stream.write(t.__super__.attribute.call(this,i,m,N))},t.prototype.cdata=function(i,m,N){return this.stream.write(t.__super__.cdata.call(this,i,m,N))},t.prototype.comment=function(i,m,N){return this.stream.write(t.__super__.comment.call(this,i,m,N))},t.prototype.declaration=function(i,m,N){return this.stream.write(t.__super__.declaration.call(this,i,m,N))},t.prototype.docType=function(i,m,N){var w,g,b,x;if(N||(N=0),this.openNode(i,m,N),m.state=n.OpenTag,this.stream.write(this.indent(i,m,N)),this.stream.write("<!DOCTYPE "+i.root().name),i.pubID&&i.sysID?this.stream.write(' PUBLIC "'+i.pubID+'" "'+i.sysID+'"'):i.sysID&&this.stream.write(' SYSTEM "'+i.sysID+'"'),i.children.length>0){for(this.stream.write(" ["),this.stream.write(this.endline(i,m,N)),m.state=n.InsideTag,x=i.children,g=0,b=x.length;g<b;g++)w=x[g],this.writeChildNode(w,m,N+1);m.state=n.CloseTag,this.stream.write("]")}return m.state=n.CloseTag,this.stream.write(m.spaceBeforeSlash+">"),this.stream.write(this.endline(i,m,N)),m.state=n.None,this.closeNode(i,m,N)},t.prototype.element=function(i,m,N){var w,g,b,x,O,_,E,D,T;N||(N=0),this.openNode(i,m,N),m.state=n.OpenTag,this.stream.write(this.indent(i,m,N)+"<"+i.name),D=i.attribs;for(E in D)f.call(D,E)&&(w=D[E],this.attribute(w,m,N));if(b=i.children.length,x=b===0?null:i.children[0],b===0||i.children.every(function(p){return(p.type===u.Text||p.type===u.Raw)&&p.value===""}))m.allowEmpty?(this.stream.write(">"),m.state=n.CloseTag,this.stream.write("</"+i.name+">")):(m.state=n.CloseTag,this.stream.write(m.spaceBeforeSlash+"/>"));else if(m.pretty&&b===1&&(x.type===u.Text||x.type===u.Raw)&&x.value!=null)this.stream.write(">"),m.state=n.InsideTag,m.suppressPrettyCount++,this.writeChildNode(x,m,N+1),m.suppressPrettyCount--,m.state=n.CloseTag,this.stream.write("</"+i.name+">");else{for(this.stream.write(">"+this.endline(i,m,N)),m.state=n.InsideTag,T=i.children,O=0,_=T.length;O<_;O++)g=T[O],this.writeChildNode(g,m,N+1);m.state=n.CloseTag,this.stream.write(this.indent(i,m,N)+"</"+i.name+">")}return this.stream.write(this.endline(i,m,N)),m.state=n.None,this.closeNode(i,m,N)},t.prototype.processingInstruction=function(i,m,N){return this.stream.write(t.__super__.processingInstruction.call(this,i,m,N))},t.prototype.raw=function(i,m,N){return this.stream.write(t.__super__.raw.call(this,i,m,N))},t.prototype.text=function(i,m,N){return this.stream.write(t.__super__.text.call(this,i,m,N))},t.prototype.dtdAttList=function(i,m,N){return this.stream.write(t.__super__.dtdAttList.call(this,i,m,N))},t.prototype.dtdElement=function(i,m,N){return this.stream.write(t.__super__.dtdElement.call(this,i,m,N))},t.prototype.dtdEntity=function(i,m,N){return this.stream.write(t.__super__.dtdEntity.call(this,i,m,N))},t.prototype.dtdNotation=function(i,m,N){return this.stream.write(t.__super__.dtdNotation.call(this,i,m,N))},t}(c)}.call(G)),be.exports}var Sr;function di(){return Sr||(Sr=1,function(){var u,n,c,a,f,o,t,i,m,N;N=yt(),i=N.assign,m=N.isFunction,c=sn(),a=fn(),f=hi(),t=We(),o=pi(),u=ot(),n=Bt(),dt.create=function(w,g,b,x){var O,_;if(w==null)throw new Error("Root element needs a name.");return x=i({},g,b,x),O=new a(x),_=O.element(w),x.headless||(O.declaration(x),(x.pubID!=null||x.sysID!=null)&&O.dtd(x)),_},dt.begin=function(w,g,b){var x;return m(w)&&(x=[w,g],g=x[0],b=x[1],w={}),g?new f(w,g,b):new a(w)},dt.stringWriter=function(w){return new t(w)},dt.streamWriter=function(w,g){return new o(w,g)},dt.implementation=new c,dt.nodeType=u,dt.writerState=n}.call(G)),dt}var Br;function mi(){return Br||(Br=1,function(){var u,n,c,a,f,o={}.hasOwnProperty;u=di(),n=_e().defaults,a=function(t){return typeof t=="string"&&(t.indexOf("&")>=0||t.indexOf(">")>=0||t.indexOf("<")>=0)},f=function(t){return"<![CDATA["+c(t)+"]]>"},c=function(t){return t.replace("]]>","]]]]><![CDATA[>")},kt.Builder=function(){function t(i){var m,N,w;this.options={},N=n["0.2"];for(m in N)o.call(N,m)&&(w=N[m],this.options[m]=w);for(m in i)o.call(i,m)&&(w=i[m],this.options[m]=w)}return t.prototype.buildObject=function(i){var m,N,w,g,b;return m=this.options.attrkey,N=this.options.charkey,Object.keys(i).length===1&&this.options.rootName===n["0.2"].rootName?(b=Object.keys(i)[0],i=i[b]):b=this.options.rootName,w=function(x){return function(O,_){var E,D,T,p,I,A;if(typeof _!="object")x.options.cdata&&a(_)?O.raw(f(_)):O.txt(_);else if(Array.isArray(_)){for(p in _)if(o.call(_,p)){D=_[p];for(I in D)T=D[I],O=w(O.ele(I),T).up()}}else for(I in _)if(o.call(_,I))if(D=_[I],I===m){if(typeof D=="object")for(E in D)A=D[E],O=O.att(E,A)}else if(I===N)x.options.cdata&&a(D)?O=O.raw(f(D)):O=O.txt(D);else if(Array.isArray(D))for(p in D)o.call(D,p)&&(T=D[p],typeof T=="string"?x.options.cdata&&a(T)?O=O.ele(I).raw(f(T)).up():O=O.ele(I,T).up():O=w(O.ele(I),T).up());else typeof D=="object"?O=w(O.ele(I),D).up():typeof D=="string"&&x.options.cdata&&a(D)?O=O.ele(I).raw(f(D)).up():(D==null&&(D=""),O=O.ele(I,D.toString()).up());return O}}(this),g=u.create(b,this.options.xmldec,this.options.doctype,{headless:this.options.headless,allowSurrogateChars:this.options.allowSurrogateChars}),w(g,i).end(this.options.renderOpts)},t}()}.call(G)),kt}var Ee={},Te={},xe={},Lt={exports:{}},De={},Nt={},Rr;function yi(){if(Rr)return Nt;Rr=1,Nt.byteLength=i,Nt.toByteArray=N,Nt.fromByteArray=b;for(var u=[],n=[],c=typeof Uint8Array<"u"?Uint8Array:Array,a="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",f=0,o=a.length;f<o;++f)u[f]=a[f],n[a.charCodeAt(f)]=f;n[45]=62,n[95]=63;function t(x){var O=x.length;if(O%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var _=x.indexOf("=");_===-1&&(_=O);var E=_===O?0:4-_%4;return[_,E]}function i(x){var O=t(x),_=O[0],E=O[1];return(_+E)*3/4-E}function m(x,O,_){return(O+_)*3/4-_}function N(x){var O,_=t(x),E=_[0],D=_[1],T=new c(m(x,E,D)),p=0,I=D>0?E-4:E,A;for(A=0;A<I;A+=4)O=n[x.charCodeAt(A)]<<18|n[x.charCodeAt(A+1)]<<12|n[x.charCodeAt(A+2)]<<6|n[x.charCodeAt(A+3)],T[p++]=O>>16&255,T[p++]=O>>8&255,T[p++]=O&255;return D===2&&(O=n[x.charCodeAt(A)]<<2|n[x.charCodeAt(A+1)]>>4,T[p++]=O&255),D===1&&(O=n[x.charCodeAt(A)]<<10|n[x.charCodeAt(A+1)]<<4|n[x.charCodeAt(A+2)]>>2,T[p++]=O>>8&255,T[p++]=O&255),T}function w(x){return u[x>>18&63]+u[x>>12&63]+u[x>>6&63]+u[x&63]}function g(x,O,_){for(var E,D=[],T=O;T<_;T+=3)E=(x[T]<<16&16711680)+(x[T+1]<<8&65280)+(x[T+2]&255),D.push(w(E));return D.join("")}function b(x){for(var O,_=x.length,E=_%3,D=[],T=16383,p=0,I=_-E;p<I;p+=T)D.push(g(x,p,p+T>I?I:p+T));return E===1?(O=x[_-1],D.push(u[O>>2]+u[O<<4&63]+"==")):E===2&&(O=(x[_-2]<<8)+x[_-1],D.push(u[O>>10]+u[O>>4&63]+u[O<<2&63]+"=")),D.join("")}return Nt}var _t={};/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */var jr;function gi(){return jr||(jr=1,_t.read=function(u,n,c,a,f){var o,t,i=f*8-a-1,m=(1<<i)-1,N=m>>1,w=-7,g=c?f-1:0,b=c?-1:1,x=u[n+g];for(g+=b,o=x&(1<<-w)-1,x>>=-w,w+=i;w>0;o=o*256+u[n+g],g+=b,w-=8);for(t=o&(1<<-w)-1,o>>=-w,w+=a;w>0;t=t*256+u[n+g],g+=b,w-=8);if(o===0)o=1-N;else{if(o===m)return t?NaN:(x?-1:1)*(1/0);t=t+Math.pow(2,a),o=o-N}return(x?-1:1)*t*Math.pow(2,o-a)},_t.write=function(u,n,c,a,f,o){var t,i,m,N=o*8-f-1,w=(1<<N)-1,g=w>>1,b=f===23?Math.pow(2,-24)-Math.pow(2,-77):0,x=a?0:o-1,O=a?1:-1,_=n<0||n===0&&1/n<0?1:0;for(n=Math.abs(n),isNaN(n)||n===1/0?(i=isNaN(n)?1:0,t=w):(t=Math.floor(Math.log(n)/Math.LN2),n*(m=Math.pow(2,-t))<1&&(t--,m*=2),t+g>=1?n+=b/m:n+=b*Math.pow(2,1-g),n*m>=2&&(t++,m/=2),t+g>=w?(i=0,t=w):t+g>=1?(i=(n*m-1)*Math.pow(2,f),t=t+g):(i=n*Math.pow(2,g-1)*Math.pow(2,f),t=0));f>=8;u[c+x]=i&255,x+=O,i/=256,f-=8);for(t=t<<f|i,N+=f;N>0;u[c+x]=t&255,x+=O,t/=256,N-=8);u[c+x-O]|=_*128}),_t}/*!
30
30
  * The buffer module from node.js, for the browser.
@@ -39,7 +39,7 @@ Char: `+y.c),d=new Error(d),y.error=d,R(y,"onerror",d),y}function z(y){return y.
39
39
  Actual: `+y.attribValue);else if(L==="xmlns"&&y.attribValue!==O)W(y,"xmlns: prefix must be bound to "+O+`
40
40
  Actual: `+y.attribValue);else{var K=y.tag,tt=y.tags[y.tags.length-1]||y;K.ns===tt.ns&&(K.ns=Object.create(tt.ns)),K.ns[L]=y.attribValue}y.attribList.push([y.attribName,y.attribValue])}else y.tag.attributes[y.attribName]=y.attribValue,X(y,"onattribute",{name:y.attribName,value:y.attribValue});y.attribName=y.attribValue=""}function Q(y,d){if(y.opt.xmlns){var S=y.tag,L=bt(y.tagName);S.prefix=L.prefix,S.local=L.local,S.uri=S.ns[L.prefix]||"",S.prefix&&!S.uri&&(W(y,"Unbound namespace prefix: "+JSON.stringify(y.tagName)),S.uri=L.prefix);var K=y.tags[y.tags.length-1]||y;S.ns&&K.ns!==S.ns&&Object.keys(S.ns).forEach(function(P){X(y,"onopennamespace",{prefix:P,uri:S.ns[P]})});for(var tt=0,H=y.attribList.length;tt<H;tt++){var it=y.attribList[tt],C=it[0],s=it[1],e=bt(C,!0),r=e.prefix,l=e.local,v=r===""?"":S.ns[r]||"",M={name:C,value:s,prefix:r,local:l,uri:v};r&&r!=="xmlns"&&!v&&(W(y,"Unbound namespace prefix: "+JSON.stringify(r)),M.uri=r),y.tag.attributes[C]=M,X(y,"onattribute",M)}y.attribList.length=0}y.tag.isSelfClosing=!!d,y.sawRoot=!0,y.tags.push(y.tag),X(y,"onopentag",y.tag),d||(!y.noscript&&y.tagName.toLowerCase()==="script"?y.state=h.SCRIPT:y.state=h.TEXT,y.tag=null,y.tagName=""),y.attribName=y.attribValue="",y.attribList.length=0}function et(y){if(!y.tagName){W(y,"Weird empty close tag."),y.textNode+="</>",y.state=h.TEXT;return}if(y.script){if(y.tagName!=="script"){y.script+="</"+y.tagName+">",y.tagName="",y.state=h.SCRIPT;return}X(y,"onscript",y.script),y.script=""}var d=y.tags.length,S=y.tagName;y.strict||(S=S[y.looseCase]());for(var L=S;d--;){var K=y.tags[d];if(K.name!==L)W(y,"Unexpected close tag");else break}if(d<0){W(y,"Unmatched closing tag: "+y.tagName),y.textNode+="</"+y.tagName+">",y.state=h.TEXT;return}y.tagName=S;for(var tt=y.tags.length;tt-- >d;){var H=y.tag=y.tags.pop();y.tagName=y.tag.name,X(y,"onclosetag",y.tagName);var it={};for(var C in H.ns)it[C]=H.ns[C];var s=y.tags[y.tags.length-1]||y;y.opt.xmlns&&H.ns!==s.ns&&Object.keys(H.ns).forEach(function(e){var r=H.ns[e];X(y,"onclosenamespace",{prefix:e,uri:r})})}d===0&&(y.closedRoot=!0),y.tagName=y.attribValue=y.attribName="",y.attribList.length=0,y.state=h.TEXT}function Tt(y){var d=y.entity,S=d.toLowerCase(),L,K="";return y.ENTITIES[d]?y.ENTITIES[d]:y.ENTITIES[S]?y.ENTITIES[S]:(d=S,d.charAt(0)==="#"&&(d.charAt(1)==="x"?(d=d.slice(2),L=parseInt(d,16),K=L.toString(16)):(d=d.slice(1),L=parseInt(d,10),K=L.toString(10))),d=d.replace(/^0+/,""),isNaN(L)||K.toLowerCase()!==d?(W(y,"Invalid character entity"),"&"+y.entity+";"):String.fromCodePoint(L))}function k(y,d){d==="<"?(y.state=h.OPEN_WAKA,y.startTagPosition=y.position):I(d)||(W(y,"Non-whitespace before first tag."),y.textNode=d,y.state=h.TEXT)}function wt(y,d){var S="";return d<y.length&&(S=y.charAt(d)),S}function It(y){var d=this;if(this.error)throw this.error;if(d.closed)return J(d,"Cannot write after close. Assign an onready handler.");if(y===null)return z(d);typeof y=="object"&&(y=y.toString());for(var S=0,L="";L=wt(y,S++),d.c=L,!!L;)switch(d.trackPosition&&(d.position++,L===`
41
41
  `?(d.line++,d.column=0):d.column++),d.state){case h.BEGIN:if(d.state=h.BEGIN_WHITESPACE,L==="\uFEFF")continue;k(d,L);continue;case h.BEGIN_WHITESPACE:k(d,L);continue;case h.TEXT:if(d.sawRoot&&!d.closedRoot){for(var K=S-1;L&&L!=="<"&&L!=="&";)L=wt(y,S++),L&&d.trackPosition&&(d.position++,L===`
42
- `?(d.line++,d.column=0):d.column++);d.textNode+=y.substring(K,S-1)}L==="<"&&!(d.sawRoot&&d.closedRoot&&!d.strict)?(d.state=h.OPEN_WAKA,d.startTagPosition=d.position):(!I(L)&&(!d.sawRoot||d.closedRoot)&&W(d,"Text data outside of root node."),L==="&"?d.state=h.TEXT_ENTITY:d.textNode+=L);continue;case h.SCRIPT:L==="<"?d.state=h.SCRIPT_ENDING:d.script+=L;continue;case h.SCRIPT_ENDING:L==="/"?d.state=h.CLOSE_TAG:(d.script+="<"+L,d.state=h.SCRIPT);continue;case h.OPEN_WAKA:if(L==="!")d.state=h.SGML_DECL,d.sgmlDecl="";else if(!I(L))if(U(E,L))d.state=h.OPEN_TAG,d.tagName=L;else if(L==="/")d.state=h.CLOSE_TAG,d.tagName="";else if(L==="?")d.state=h.PROC_INST,d.procInstName=d.procInstBody="";else{if(W(d,"Unencoded <"),d.startTagPosition+1<d.position){var tt=d.position-d.startTagPosition;L=new Array(tt).join(" ")+L}d.textNode+="<"+L,d.state=h.TEXT}continue;case h.SGML_DECL:if(d.sgmlDecl+L==="--"){d.state=h.COMMENT,d.comment="",d.sgmlDecl="";continue}d.doctype&&d.doctype!==!0&&d.sgmlDecl?(d.state=h.DOCTYPE_DTD,d.doctype+="<!"+d.sgmlDecl+L,d.sgmlDecl=""):(d.sgmlDecl+L).toUpperCase()===g?(X(d,"onopencdata"),d.state=h.CDATA,d.sgmlDecl="",d.cdata=""):(d.sgmlDecl+L).toUpperCase()===b?(d.state=h.DOCTYPE,(d.doctype||d.sawRoot)&&W(d,"Inappropriately located doctype declaration"),d.doctype="",d.sgmlDecl=""):L===">"?(X(d,"onsgmldeclaration",d.sgmlDecl),d.sgmlDecl="",d.state=h.TEXT):(A(L)&&(d.state=h.SGML_DECL_QUOTED),d.sgmlDecl+=L);continue;case h.SGML_DECL_QUOTED:L===d.q&&(d.state=h.SGML_DECL,d.q=""),d.sgmlDecl+=L;continue;case h.DOCTYPE:L===">"?(d.state=h.TEXT,X(d,"ondoctype",d.doctype),d.doctype=!0):(d.doctype+=L,L==="["?d.state=h.DOCTYPE_DTD:A(L)&&(d.state=h.DOCTYPE_QUOTED,d.q=L));continue;case h.DOCTYPE_QUOTED:d.doctype+=L,L===d.q&&(d.q="",d.state=h.DOCTYPE);continue;case h.DOCTYPE_DTD:L==="]"?(d.doctype+=L,d.state=h.DOCTYPE):L==="<"?(d.state=h.OPEN_WAKA,d.startTagPosition=d.position):A(L)?(d.doctype+=L,d.state=h.DOCTYPE_DTD_QUOTED,d.q=L):d.doctype+=L;continue;case h.DOCTYPE_DTD_QUOTED:d.doctype+=L,L===d.q&&(d.state=h.DOCTYPE_DTD,d.q="");continue;case h.COMMENT:L==="-"?d.state=h.COMMENT_ENDING:d.comment+=L;continue;case h.COMMENT_ENDING:L==="-"?(d.state=h.COMMENT_ENDED,d.comment=Y(d.opt,d.comment),d.comment&&X(d,"oncomment",d.comment),d.comment=""):(d.comment+="-"+L,d.state=h.COMMENT);continue;case h.COMMENT_ENDED:L!==">"?(W(d,"Malformed comment"),d.comment+="--"+L,d.state=h.COMMENT):d.doctype&&d.doctype!==!0?d.state=h.DOCTYPE_DTD:d.state=h.TEXT;continue;case h.CDATA:L==="]"?d.state=h.CDATA_ENDING:d.cdata+=L;continue;case h.CDATA_ENDING:L==="]"?d.state=h.CDATA_ENDING_2:(d.cdata+="]"+L,d.state=h.CDATA);continue;case h.CDATA_ENDING_2:L===">"?(d.cdata&&X(d,"oncdata",d.cdata),X(d,"onclosecdata"),d.cdata="",d.state=h.TEXT):L==="]"?d.cdata+="]":(d.cdata+="]]"+L,d.state=h.CDATA);continue;case h.PROC_INST:L==="?"?d.state=h.PROC_INST_ENDING:I(L)?d.state=h.PROC_INST_BODY:d.procInstName+=L;continue;case h.PROC_INST_BODY:if(!d.procInstBody&&I(L))continue;L==="?"?d.state=h.PROC_INST_ENDING:d.procInstBody+=L;continue;case h.PROC_INST_ENDING:L===">"?(X(d,"onprocessinginstruction",{name:d.procInstName,body:d.procInstBody}),d.procInstName=d.procInstBody="",d.state=h.TEXT):(d.procInstBody+="?"+L,d.state=h.PROC_INST_BODY);continue;case h.OPEN_TAG:U(D,L)?d.tagName+=L:(vt(d),L===">"?Q(d):L==="/"?d.state=h.OPEN_TAG_SLASH:(I(L)||W(d,"Invalid character in tag name"),d.state=h.ATTRIB));continue;case h.OPEN_TAG_SLASH:L===">"?(Q(d,!0),et(d)):(W(d,"Forward-slash in opening tag not followed by >"),d.state=h.ATTRIB);continue;case h.ATTRIB:if(I(L))continue;L===">"?Q(d):L==="/"?d.state=h.OPEN_TAG_SLASH:U(E,L)?(d.attribName=L,d.attribValue="",d.state=h.ATTRIB_NAME):W(d,"Invalid attribute name");continue;case h.ATTRIB_NAME:L==="="?d.state=h.ATTRIB_VALUE:L===">"?(W(d,"Attribute without value"),d.attribValue=d.attribName,gt(d),Q(d)):I(L)?d.state=h.ATTRIB_NAME_SAW_WHITE:U(D,L)?d.attribName+=L:W(d,"Invalid attribute name");continue;case h.ATTRIB_NAME_SAW_WHITE:if(L==="=")d.state=h.ATTRIB_VALUE;else{if(I(L))continue;W(d,"Attribute without value"),d.tag.attributes[d.attribName]="",d.attribValue="",X(d,"onattribute",{name:d.attribName,value:""}),d.attribName="",L===">"?Q(d):U(E,L)?(d.attribName=L,d.state=h.ATTRIB_NAME):(W(d,"Invalid attribute name"),d.state=h.ATTRIB)}continue;case h.ATTRIB_VALUE:if(I(L))continue;A(L)?(d.q=L,d.state=h.ATTRIB_VALUE_QUOTED):(d.opt.unquotedAttributeValues||J(d,"Unquoted attribute value"),d.state=h.ATTRIB_VALUE_UNQUOTED,d.attribValue=L);continue;case h.ATTRIB_VALUE_QUOTED:if(L!==d.q){L==="&"?d.state=h.ATTRIB_VALUE_ENTITY_Q:d.attribValue+=L;continue}gt(d),d.q="",d.state=h.ATTRIB_VALUE_CLOSED;continue;case h.ATTRIB_VALUE_CLOSED:I(L)?d.state=h.ATTRIB:L===">"?Q(d):L==="/"?d.state=h.OPEN_TAG_SLASH:U(E,L)?(W(d,"No whitespace between attributes"),d.attribName=L,d.attribValue="",d.state=h.ATTRIB_NAME):W(d,"Invalid attribute name");continue;case h.ATTRIB_VALUE_UNQUOTED:if(!j(L)){L==="&"?d.state=h.ATTRIB_VALUE_ENTITY_U:d.attribValue+=L;continue}gt(d),L===">"?Q(d):d.state=h.ATTRIB;continue;case h.CLOSE_TAG:if(d.tagName)L===">"?et(d):U(D,L)?d.tagName+=L:d.script?(d.script+="</"+d.tagName,d.tagName="",d.state=h.SCRIPT):(I(L)||W(d,"Invalid tagname in closing tag"),d.state=h.CLOSE_TAG_SAW_WHITE);else{if(I(L))continue;B(E,L)?d.script?(d.script+="</"+L,d.state=h.SCRIPT):W(d,"Invalid tagname in closing tag."):d.tagName=L}continue;case h.CLOSE_TAG_SAW_WHITE:if(I(L))continue;L===">"?et(d):W(d,"Invalid characters in closing tag");continue;case h.TEXT_ENTITY:case h.ATTRIB_VALUE_ENTITY_Q:case h.ATTRIB_VALUE_ENTITY_U:var H,it;switch(d.state){case h.TEXT_ENTITY:H=h.TEXT,it="textNode";break;case h.ATTRIB_VALUE_ENTITY_Q:H=h.ATTRIB_VALUE_QUOTED,it="attribValue";break;case h.ATTRIB_VALUE_ENTITY_U:H=h.ATTRIB_VALUE_UNQUOTED,it="attribValue";break}if(L===";"){var C=Tt(d);d.opt.unparsedEntities&&!Object.values(n.XML_ENTITIES).includes(C)?(d.entity="",d.state=H,d.write(C)):(d[it]+=C,d.entity="",d.state=H)}else U(d.entity.length?p:T,L)?d.entity+=L:(W(d,"Invalid character in entity name"),d[it]+="&"+d.entity+L,d.entity="",d.state=H);continue;default:throw new Error(d,"Unknown state: "+d.state)}return d.position>=d.bufferCheckPosition&&f(d),d}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */String.fromCodePoint||function(){var y=String.fromCharCode,d=Math.floor,S=function(){var L=16384,K=[],tt,H,it=-1,C=arguments.length;if(!C)return"";for(var s="";++it<C;){var e=Number(arguments[it]);if(!isFinite(e)||e<0||e>1114111||d(e)!==e)throw RangeError("Invalid code point: "+e);e<=65535?K.push(e):(e-=65536,tt=(e>>10)+55296,H=e%1024+56320,K.push(tt,H)),(it+1===C||K.length>L)&&(s+=y.apply(null,K),K.length=0)}return s};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:S,configurable:!0,writable:!0}):String.fromCodePoint=S}()})(u)}(Te)),Te}var ve={},Vr;function xi(){return Vr||(Vr=1,function(){ve.stripBOM=function(u){return u[0]==="\uFEFF"?u.substring(1):u}}.call(G)),ve}var Et={},$r;function hn(){return $r||($r=1,function(){var u;u=new RegExp(/(?!xmlns)^.*:/),Et.normalize=function(n){return n.toLowerCase()},Et.firstCharLowerCase=function(n){return n.charAt(0).toLowerCase()+n.slice(1)},Et.stripPrefix=function(n){return n.replace(u,"")},Et.parseNumbers=function(n){return isNaN(n)||(n=n%1===0?parseInt(n,10):parseFloat(n)),n},Et.parseBooleans=function(n){return/^(?:true|false)$/i.test(n)&&(n=n.toLowerCase()==="true"),n}}.call(G)),Et}var Wr;function Di(){return Wr||(Wr=1,function(u){(function(){var n,c,a,f,o,t,i,m,N,w=function(x,O){return function(){return x.apply(O,arguments)}},g=function(x,O){for(var _ in O)b.call(O,_)&&(x[_]=O[_]);function E(){this.constructor=x}return E.prototype=O.prototype,x.prototype=new E,x.__super__=O.prototype,x},b={}.hasOwnProperty;m=Ti(),f=Le,n=xi(),i=hn(),N=Mn.setImmediate,c=_e().defaults,o=function(x){return typeof x=="object"&&x!=null&&Object.keys(x).length===0},t=function(x,O,_){var E,D,T;for(E=0,D=x.length;E<D;E++)T=x[E],O=T(O,_);return O},a=function(x,O,_){var E;return E=Object.create(null),E.value=_,E.writable=!0,E.enumerable=!0,E.configurable=!0,Object.defineProperty(x,O,E)},u.Parser=function(x){g(O,x);function O(_){this.parseStringPromise=w(this.parseStringPromise,this),this.parseString=w(this.parseString,this),this.reset=w(this.reset,this),this.assignOrPush=w(this.assignOrPush,this),this.processAsync=w(this.processAsync,this);var E,D,T;if(!(this instanceof u.Parser))return new u.Parser(_);this.options={},D=c["0.2"];for(E in D)b.call(D,E)&&(T=D[E],this.options[E]=T);for(E in _)b.call(_,E)&&(T=_[E],this.options[E]=T);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(i.normalize)),this.reset()}return O.prototype.processAsync=function(){var _,E;try{return this.remaining.length<=this.options.chunkSize?(_=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(_),this.saxParser.close()):(_=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(_),N(this.processAsync))}catch(D){if(E=D,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(E)}},O.prototype.assignOrPush=function(_,E,D){return E in _?(_[E]instanceof Array||a(_,E,[_[E]]),_[E].push(D)):this.options.explicitArray?a(_,E,[D]):a(_,E,D)},O.prototype.reset=function(){var _,E,D,T;return this.removeAllListeners(),this.saxParser=m.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=function(p){return function(I){if(p.saxParser.resume(),!p.saxParser.errThrown)return p.saxParser.errThrown=!0,p.emit("error",I)}}(this),this.saxParser.onend=function(p){return function(){if(!p.saxParser.ended)return p.saxParser.ended=!0,p.emit("end",p.resultObject)}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,T=[],_=this.options.attrkey,E=this.options.charkey,this.saxParser.onopentag=function(p){return function(I){var A,j,U,B,h;if(U={},U[E]="",!p.options.ignoreAttrs){h=I.attributes;for(A in h)b.call(h,A)&&(!(_ in U)&&!p.options.mergeAttrs&&(U[_]={}),j=p.options.attrValueProcessors?t(p.options.attrValueProcessors,I.attributes[A],A):I.attributes[A],B=p.options.attrNameProcessors?t(p.options.attrNameProcessors,A):A,p.options.mergeAttrs?p.assignOrPush(U,B,j):a(U[_],B,j))}return U["#name"]=p.options.tagNameProcessors?t(p.options.tagNameProcessors,I.name):I.name,p.options.xmlns&&(U[p.options.xmlnskey]={uri:I.uri,local:I.local}),T.push(U)}}(this),this.saxParser.onclosetag=function(p){return function(){var I,A,j,U,B,h,F,R,X,$;if(h=T.pop(),B=h["#name"],(!p.options.explicitChildren||!p.options.preserveChildrenOrder)&&delete h["#name"],h.cdata===!0&&(I=h.cdata,delete h.cdata),X=T[T.length-1],h[E].match(/^\s*$/)&&!I?(A=h[E],delete h[E]):(p.options.trim&&(h[E]=h[E].trim()),p.options.normalize&&(h[E]=h[E].replace(/\s{2,}/g," ").trim()),h[E]=p.options.valueProcessors?t(p.options.valueProcessors,h[E],B):h[E],Object.keys(h).length===1&&E in h&&!p.EXPLICIT_CHARKEY&&(h=h[E])),o(h)&&(typeof p.options.emptyTag=="function"?h=p.options.emptyTag():h=p.options.emptyTag!==""?p.options.emptyTag:A),p.options.validator!=null&&($="/"+function(){var Y,J,z;for(z=[],Y=0,J=T.length;Y<J;Y++)U=T[Y],z.push(U["#name"]);return z}().concat(B).join("/"),function(){var Y;try{return h=p.options.validator($,X&&X[B],h)}catch(J){return Y=J,p.emit("error",Y)}}()),p.options.explicitChildren&&!p.options.mergeAttrs&&typeof h=="object"){if(!p.options.preserveChildrenOrder)U={},p.options.attrkey in h&&(U[p.options.attrkey]=h[p.options.attrkey],delete h[p.options.attrkey]),!p.options.charsAsChildren&&p.options.charkey in h&&(U[p.options.charkey]=h[p.options.charkey],delete h[p.options.charkey]),Object.getOwnPropertyNames(h).length>0&&(U[p.options.childkey]=h),h=U;else if(X){X[p.options.childkey]=X[p.options.childkey]||[],F={};for(j in h)b.call(h,j)&&a(F,j,h[j]);X[p.options.childkey].push(F),delete h["#name"],Object.keys(h).length===1&&E in h&&!p.EXPLICIT_CHARKEY&&(h=h[E])}}return T.length>0?p.assignOrPush(X,B,h):(p.options.explicitRoot&&(R=h,h={},a(h,B,R)),p.resultObject=h,p.saxParser.ended=!0,p.emit("end",p.resultObject))}}(this),D=function(p){return function(I){var A,j;if(j=T[T.length-1],j)return j[E]+=I,p.options.explicitChildren&&p.options.preserveChildrenOrder&&p.options.charsAsChildren&&(p.options.includeWhiteChars||I.replace(/\\n/g,"").trim()!=="")&&(j[p.options.childkey]=j[p.options.childkey]||[],A={"#name":"__text__"},A[E]=I,p.options.normalize&&(A[E]=A[E].replace(/\s{2,}/g," ").trim()),j[p.options.childkey].push(A)),j}}(this),this.saxParser.ontext=D,this.saxParser.oncdata=function(p){return function(I){var A;if(A=D(I),A)return A.cdata=!0}}()},O.prototype.parseString=function(_,E){var D;E!=null&&typeof E=="function"&&(this.on("end",function(T){return this.reset(),E(null,T)}),this.on("error",function(T){return this.reset(),E(T)}));try{return _=_.toString(),_.trim()===""?(this.emit("end",null),!0):(_=n.stripBOM(_),this.options.async?(this.remaining=_,N(this.processAsync),this.saxParser):this.saxParser.write(_).close())}catch(T){if(D=T,this.saxParser.errThrown||this.saxParser.ended){if(this.saxParser.ended)throw D}else return this.emit("error",D),this.saxParser.errThrown=!0}},O.prototype.parseStringPromise=function(_){return new Promise(function(E){return function(D,T){return E.parseString(_,function(p,I){return p?T(p):D(I)})}}(this))},O}(f),u.parseString=function(x,O,_){var E,D,T;return _!=null?(typeof _=="function"&&(E=_),typeof O=="object"&&(D=O)):(typeof O=="function"&&(E=O),D={}),T=new u.Parser(D),T.parseString(x,E)},u.parseStringPromise=function(x,O){var _,E;return typeof O=="object"&&(_=O),E=new u.Parser(_),E.parseStringPromise(x)}}).call(G)}(Ee)),Ee}var pn;(function(){var u,n,c,a=function(o,t){for(var i in t)f.call(t,i)&&(o[i]=t[i]);function m(){this.constructor=o}return m.prototype=t.prototype,o.prototype=new m,o.__super__=t.prototype,o},f={}.hasOwnProperty;n=_e(),u=mi(),c=Di(),hn(),n.defaults,function(o){a(t,o);function t(i){this.message=i}return t}(Error),u.Builder,c.Parser,c.parseString,pn=c.parseStringPromise}).call(G);class vi{constructor(n,c,a){this.nextTxnId=1,this.pendingCommands=new Map,this.breakpoints=new Map,this.scriptIdByUrl=new Map,this.nextScriptId=1,this.objectHandles=new Map,this.nextObjectId=1,this.callFramesMap=new Map,this.xdebugConnected=!1,this.dbgp=n,this.cdp=c,this.readPHPFile=a.getPHPFile,this.phpRoot=a.phpRoot||"";for(const f of a.knownScriptUrls)this.scriptIdByUrl.set(f,this.getOrCreateScriptId(f));this.breakOnFirstLine=a.breakOnFirstLine||!1}start(){this.dbgp.on("connected",()=>{this.xdebugConnected=!0,this.sendDbgpCommand("stdout","-c 1"),this.sendDbgpCommand("stderr","-c 1")}),this.dbgp.on("message",async n=>{try{const c=await pn(n,{explicitArray:!1});await this.handleDbgpMessage(c)}catch{}}),this.dbgp.on("disconnected",()=>{this.xdebugConnected=!1,this.cdp.sendMessage({method:"Debugger.paused",params:{reason:"terminated",callFrames:[]}})}),this.cdp.on("message",n=>{this.handleCdpMessage(n)}),this.cdp.on("clientDisconnected",()=>{this.xdebugConnected&&this.sendDbgpCommand("detach")}),this.sendInitialScripts().then(()=>{if(!this.breakOnFirstLine){const n=this.scriptIdByUrl.entries().next().value;n&&(this.cdp.sendMessage({method:"Debugger.paused",params:{callFrames:[{location:{scriptId:n[1],lineNumber:0},scopeChain:[],this:{type:"undefined"}}],reason:"other"}}),setTimeout(()=>{this.cdp.sendMessage({method:"Debugger.resumed"})},50))}this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:"info",text:`🎉 Welcome to WordPress Playground DevTools! 🎉
42
+ `?(d.line++,d.column=0):d.column++);d.textNode+=y.substring(K,S-1)}L==="<"&&!(d.sawRoot&&d.closedRoot&&!d.strict)?(d.state=h.OPEN_WAKA,d.startTagPosition=d.position):(!I(L)&&(!d.sawRoot||d.closedRoot)&&W(d,"Text data outside of root node."),L==="&"?d.state=h.TEXT_ENTITY:d.textNode+=L);continue;case h.SCRIPT:L==="<"?d.state=h.SCRIPT_ENDING:d.script+=L;continue;case h.SCRIPT_ENDING:L==="/"?d.state=h.CLOSE_TAG:(d.script+="<"+L,d.state=h.SCRIPT);continue;case h.OPEN_WAKA:if(L==="!")d.state=h.SGML_DECL,d.sgmlDecl="";else if(!I(L))if(U(E,L))d.state=h.OPEN_TAG,d.tagName=L;else if(L==="/")d.state=h.CLOSE_TAG,d.tagName="";else if(L==="?")d.state=h.PROC_INST,d.procInstName=d.procInstBody="";else{if(W(d,"Unencoded <"),d.startTagPosition+1<d.position){var tt=d.position-d.startTagPosition;L=new Array(tt).join(" ")+L}d.textNode+="<"+L,d.state=h.TEXT}continue;case h.SGML_DECL:if(d.sgmlDecl+L==="--"){d.state=h.COMMENT,d.comment="",d.sgmlDecl="";continue}d.doctype&&d.doctype!==!0&&d.sgmlDecl?(d.state=h.DOCTYPE_DTD,d.doctype+="<!"+d.sgmlDecl+L,d.sgmlDecl=""):(d.sgmlDecl+L).toUpperCase()===g?(X(d,"onopencdata"),d.state=h.CDATA,d.sgmlDecl="",d.cdata=""):(d.sgmlDecl+L).toUpperCase()===b?(d.state=h.DOCTYPE,(d.doctype||d.sawRoot)&&W(d,"Inappropriately located doctype declaration"),d.doctype="",d.sgmlDecl=""):L===">"?(X(d,"onsgmldeclaration",d.sgmlDecl),d.sgmlDecl="",d.state=h.TEXT):(A(L)&&(d.state=h.SGML_DECL_QUOTED),d.sgmlDecl+=L);continue;case h.SGML_DECL_QUOTED:L===d.q&&(d.state=h.SGML_DECL,d.q=""),d.sgmlDecl+=L;continue;case h.DOCTYPE:L===">"?(d.state=h.TEXT,X(d,"ondoctype",d.doctype),d.doctype=!0):(d.doctype+=L,L==="["?d.state=h.DOCTYPE_DTD:A(L)&&(d.state=h.DOCTYPE_QUOTED,d.q=L));continue;case h.DOCTYPE_QUOTED:d.doctype+=L,L===d.q&&(d.q="",d.state=h.DOCTYPE);continue;case h.DOCTYPE_DTD:L==="]"?(d.doctype+=L,d.state=h.DOCTYPE):L==="<"?(d.state=h.OPEN_WAKA,d.startTagPosition=d.position):A(L)?(d.doctype+=L,d.state=h.DOCTYPE_DTD_QUOTED,d.q=L):d.doctype+=L;continue;case h.DOCTYPE_DTD_QUOTED:d.doctype+=L,L===d.q&&(d.state=h.DOCTYPE_DTD,d.q="");continue;case h.COMMENT:L==="-"?d.state=h.COMMENT_ENDING:d.comment+=L;continue;case h.COMMENT_ENDING:L==="-"?(d.state=h.COMMENT_ENDED,d.comment=Y(d.opt,d.comment),d.comment&&X(d,"oncomment",d.comment),d.comment=""):(d.comment+="-"+L,d.state=h.COMMENT);continue;case h.COMMENT_ENDED:L!==">"?(W(d,"Malformed comment"),d.comment+="--"+L,d.state=h.COMMENT):d.doctype&&d.doctype!==!0?d.state=h.DOCTYPE_DTD:d.state=h.TEXT;continue;case h.CDATA:L==="]"?d.state=h.CDATA_ENDING:d.cdata+=L;continue;case h.CDATA_ENDING:L==="]"?d.state=h.CDATA_ENDING_2:(d.cdata+="]"+L,d.state=h.CDATA);continue;case h.CDATA_ENDING_2:L===">"?(d.cdata&&X(d,"oncdata",d.cdata),X(d,"onclosecdata"),d.cdata="",d.state=h.TEXT):L==="]"?d.cdata+="]":(d.cdata+="]]"+L,d.state=h.CDATA);continue;case h.PROC_INST:L==="?"?d.state=h.PROC_INST_ENDING:I(L)?d.state=h.PROC_INST_BODY:d.procInstName+=L;continue;case h.PROC_INST_BODY:if(!d.procInstBody&&I(L))continue;L==="?"?d.state=h.PROC_INST_ENDING:d.procInstBody+=L;continue;case h.PROC_INST_ENDING:L===">"?(X(d,"onprocessinginstruction",{name:d.procInstName,body:d.procInstBody}),d.procInstName=d.procInstBody="",d.state=h.TEXT):(d.procInstBody+="?"+L,d.state=h.PROC_INST_BODY);continue;case h.OPEN_TAG:U(D,L)?d.tagName+=L:(vt(d),L===">"?Q(d):L==="/"?d.state=h.OPEN_TAG_SLASH:(I(L)||W(d,"Invalid character in tag name"),d.state=h.ATTRIB));continue;case h.OPEN_TAG_SLASH:L===">"?(Q(d,!0),et(d)):(W(d,"Forward-slash in opening tag not followed by >"),d.state=h.ATTRIB);continue;case h.ATTRIB:if(I(L))continue;L===">"?Q(d):L==="/"?d.state=h.OPEN_TAG_SLASH:U(E,L)?(d.attribName=L,d.attribValue="",d.state=h.ATTRIB_NAME):W(d,"Invalid attribute name");continue;case h.ATTRIB_NAME:L==="="?d.state=h.ATTRIB_VALUE:L===">"?(W(d,"Attribute without value"),d.attribValue=d.attribName,gt(d),Q(d)):I(L)?d.state=h.ATTRIB_NAME_SAW_WHITE:U(D,L)?d.attribName+=L:W(d,"Invalid attribute name");continue;case h.ATTRIB_NAME_SAW_WHITE:if(L==="=")d.state=h.ATTRIB_VALUE;else{if(I(L))continue;W(d,"Attribute without value"),d.tag.attributes[d.attribName]="",d.attribValue="",X(d,"onattribute",{name:d.attribName,value:""}),d.attribName="",L===">"?Q(d):U(E,L)?(d.attribName=L,d.state=h.ATTRIB_NAME):(W(d,"Invalid attribute name"),d.state=h.ATTRIB)}continue;case h.ATTRIB_VALUE:if(I(L))continue;A(L)?(d.q=L,d.state=h.ATTRIB_VALUE_QUOTED):(d.opt.unquotedAttributeValues||J(d,"Unquoted attribute value"),d.state=h.ATTRIB_VALUE_UNQUOTED,d.attribValue=L);continue;case h.ATTRIB_VALUE_QUOTED:if(L!==d.q){L==="&"?d.state=h.ATTRIB_VALUE_ENTITY_Q:d.attribValue+=L;continue}gt(d),d.q="",d.state=h.ATTRIB_VALUE_CLOSED;continue;case h.ATTRIB_VALUE_CLOSED:I(L)?d.state=h.ATTRIB:L===">"?Q(d):L==="/"?d.state=h.OPEN_TAG_SLASH:U(E,L)?(W(d,"No whitespace between attributes"),d.attribName=L,d.attribValue="",d.state=h.ATTRIB_NAME):W(d,"Invalid attribute name");continue;case h.ATTRIB_VALUE_UNQUOTED:if(!j(L)){L==="&"?d.state=h.ATTRIB_VALUE_ENTITY_U:d.attribValue+=L;continue}gt(d),L===">"?Q(d):d.state=h.ATTRIB;continue;case h.CLOSE_TAG:if(d.tagName)L===">"?et(d):U(D,L)?d.tagName+=L:d.script?(d.script+="</"+d.tagName,d.tagName="",d.state=h.SCRIPT):(I(L)||W(d,"Invalid tagname in closing tag"),d.state=h.CLOSE_TAG_SAW_WHITE);else{if(I(L))continue;B(E,L)?d.script?(d.script+="</"+L,d.state=h.SCRIPT):W(d,"Invalid tagname in closing tag."):d.tagName=L}continue;case h.CLOSE_TAG_SAW_WHITE:if(I(L))continue;L===">"?et(d):W(d,"Invalid characters in closing tag");continue;case h.TEXT_ENTITY:case h.ATTRIB_VALUE_ENTITY_Q:case h.ATTRIB_VALUE_ENTITY_U:var H,it;switch(d.state){case h.TEXT_ENTITY:H=h.TEXT,it="textNode";break;case h.ATTRIB_VALUE_ENTITY_Q:H=h.ATTRIB_VALUE_QUOTED,it="attribValue";break;case h.ATTRIB_VALUE_ENTITY_U:H=h.ATTRIB_VALUE_UNQUOTED,it="attribValue";break}if(L===";"){var C=Tt(d);d.opt.unparsedEntities&&!Object.values(n.XML_ENTITIES).includes(C)?(d.entity="",d.state=H,d.write(C)):(d[it]+=C,d.entity="",d.state=H)}else U(d.entity.length?p:T,L)?d.entity+=L:(W(d,"Invalid character in entity name"),d[it]+="&"+d.entity+L,d.entity="",d.state=H);continue;default:throw new Error(d,"Unknown state: "+d.state)}return d.position>=d.bufferCheckPosition&&f(d),d}/*! http://mths.be/fromcodepoint v0.1.0 by @mathias */String.fromCodePoint||function(){var y=String.fromCharCode,d=Math.floor,S=function(){var L=16384,K=[],tt,H,it=-1,C=arguments.length;if(!C)return"";for(var s="";++it<C;){var e=Number(arguments[it]);if(!isFinite(e)||e<0||e>1114111||d(e)!==e)throw RangeError("Invalid code point: "+e);e<=65535?K.push(e):(e-=65536,tt=(e>>10)+55296,H=e%1024+56320,K.push(tt,H)),(it+1===C||K.length>L)&&(s+=y.apply(null,K),K.length=0)}return s};Object.defineProperty?Object.defineProperty(String,"fromCodePoint",{value:S,configurable:!0,writable:!0}):String.fromCodePoint=S}()})(u)}(Te)),Te}var ve={},Vr;function xi(){return Vr||(Vr=1,function(){ve.stripBOM=function(u){return u[0]==="\uFEFF"?u.substring(1):u}}.call(G)),ve}var Et={},$r;function hn(){return $r||($r=1,function(){var u;u=new RegExp(/(?!xmlns)^.*:/),Et.normalize=function(n){return n.toLowerCase()},Et.firstCharLowerCase=function(n){return n.charAt(0).toLowerCase()+n.slice(1)},Et.stripPrefix=function(n){return n.replace(u,"")},Et.parseNumbers=function(n){return isNaN(n)||(n=n%1===0?parseInt(n,10):parseFloat(n)),n},Et.parseBooleans=function(n){return/^(?:true|false)$/i.test(n)&&(n=n.toLowerCase()==="true"),n}}.call(G)),Et}var Wr;function Di(){return Wr||(Wr=1,function(u){(function(){var n,c,a,f,o,t,i,m,N,w=function(x,O){return function(){return x.apply(O,arguments)}},g=function(x,O){for(var _ in O)b.call(O,_)&&(x[_]=O[_]);function E(){this.constructor=x}return E.prototype=O.prototype,x.prototype=new E,x.__super__=O.prototype,x},b={}.hasOwnProperty;m=Ti(),f=Le,n=xi(),i=hn(),N=Pn.setImmediate,c=_e().defaults,o=function(x){return typeof x=="object"&&x!=null&&Object.keys(x).length===0},t=function(x,O,_){var E,D,T;for(E=0,D=x.length;E<D;E++)T=x[E],O=T(O,_);return O},a=function(x,O,_){var E;return E=Object.create(null),E.value=_,E.writable=!0,E.enumerable=!0,E.configurable=!0,Object.defineProperty(x,O,E)},u.Parser=function(x){g(O,x);function O(_){this.parseStringPromise=w(this.parseStringPromise,this),this.parseString=w(this.parseString,this),this.reset=w(this.reset,this),this.assignOrPush=w(this.assignOrPush,this),this.processAsync=w(this.processAsync,this);var E,D,T;if(!(this instanceof u.Parser))return new u.Parser(_);this.options={},D=c["0.2"];for(E in D)b.call(D,E)&&(T=D[E],this.options[E]=T);for(E in _)b.call(_,E)&&(T=_[E],this.options[E]=T);this.options.xmlns&&(this.options.xmlnskey=this.options.attrkey+"ns"),this.options.normalizeTags&&(this.options.tagNameProcessors||(this.options.tagNameProcessors=[]),this.options.tagNameProcessors.unshift(i.normalize)),this.reset()}return O.prototype.processAsync=function(){var _,E;try{return this.remaining.length<=this.options.chunkSize?(_=this.remaining,this.remaining="",this.saxParser=this.saxParser.write(_),this.saxParser.close()):(_=this.remaining.substr(0,this.options.chunkSize),this.remaining=this.remaining.substr(this.options.chunkSize,this.remaining.length),this.saxParser=this.saxParser.write(_),N(this.processAsync))}catch(D){if(E=D,!this.saxParser.errThrown)return this.saxParser.errThrown=!0,this.emit(E)}},O.prototype.assignOrPush=function(_,E,D){return E in _?(_[E]instanceof Array||a(_,E,[_[E]]),_[E].push(D)):this.options.explicitArray?a(_,E,[D]):a(_,E,D)},O.prototype.reset=function(){var _,E,D,T;return this.removeAllListeners(),this.saxParser=m.parser(this.options.strict,{trim:!1,normalize:!1,xmlns:this.options.xmlns}),this.saxParser.errThrown=!1,this.saxParser.onerror=function(p){return function(I){if(p.saxParser.resume(),!p.saxParser.errThrown)return p.saxParser.errThrown=!0,p.emit("error",I)}}(this),this.saxParser.onend=function(p){return function(){if(!p.saxParser.ended)return p.saxParser.ended=!0,p.emit("end",p.resultObject)}}(this),this.saxParser.ended=!1,this.EXPLICIT_CHARKEY=this.options.explicitCharkey,this.resultObject=null,T=[],_=this.options.attrkey,E=this.options.charkey,this.saxParser.onopentag=function(p){return function(I){var A,j,U,B,h;if(U={},U[E]="",!p.options.ignoreAttrs){h=I.attributes;for(A in h)b.call(h,A)&&(!(_ in U)&&!p.options.mergeAttrs&&(U[_]={}),j=p.options.attrValueProcessors?t(p.options.attrValueProcessors,I.attributes[A],A):I.attributes[A],B=p.options.attrNameProcessors?t(p.options.attrNameProcessors,A):A,p.options.mergeAttrs?p.assignOrPush(U,B,j):a(U[_],B,j))}return U["#name"]=p.options.tagNameProcessors?t(p.options.tagNameProcessors,I.name):I.name,p.options.xmlns&&(U[p.options.xmlnskey]={uri:I.uri,local:I.local}),T.push(U)}}(this),this.saxParser.onclosetag=function(p){return function(){var I,A,j,U,B,h,F,R,X,$;if(h=T.pop(),B=h["#name"],(!p.options.explicitChildren||!p.options.preserveChildrenOrder)&&delete h["#name"],h.cdata===!0&&(I=h.cdata,delete h.cdata),X=T[T.length-1],h[E].match(/^\s*$/)&&!I?(A=h[E],delete h[E]):(p.options.trim&&(h[E]=h[E].trim()),p.options.normalize&&(h[E]=h[E].replace(/\s{2,}/g," ").trim()),h[E]=p.options.valueProcessors?t(p.options.valueProcessors,h[E],B):h[E],Object.keys(h).length===1&&E in h&&!p.EXPLICIT_CHARKEY&&(h=h[E])),o(h)&&(typeof p.options.emptyTag=="function"?h=p.options.emptyTag():h=p.options.emptyTag!==""?p.options.emptyTag:A),p.options.validator!=null&&($="/"+function(){var Y,J,z;for(z=[],Y=0,J=T.length;Y<J;Y++)U=T[Y],z.push(U["#name"]);return z}().concat(B).join("/"),function(){var Y;try{return h=p.options.validator($,X&&X[B],h)}catch(J){return Y=J,p.emit("error",Y)}}()),p.options.explicitChildren&&!p.options.mergeAttrs&&typeof h=="object"){if(!p.options.preserveChildrenOrder)U={},p.options.attrkey in h&&(U[p.options.attrkey]=h[p.options.attrkey],delete h[p.options.attrkey]),!p.options.charsAsChildren&&p.options.charkey in h&&(U[p.options.charkey]=h[p.options.charkey],delete h[p.options.charkey]),Object.getOwnPropertyNames(h).length>0&&(U[p.options.childkey]=h),h=U;else if(X){X[p.options.childkey]=X[p.options.childkey]||[],F={};for(j in h)b.call(h,j)&&a(F,j,h[j]);X[p.options.childkey].push(F),delete h["#name"],Object.keys(h).length===1&&E in h&&!p.EXPLICIT_CHARKEY&&(h=h[E])}}return T.length>0?p.assignOrPush(X,B,h):(p.options.explicitRoot&&(R=h,h={},a(h,B,R)),p.resultObject=h,p.saxParser.ended=!0,p.emit("end",p.resultObject))}}(this),D=function(p){return function(I){var A,j;if(j=T[T.length-1],j)return j[E]+=I,p.options.explicitChildren&&p.options.preserveChildrenOrder&&p.options.charsAsChildren&&(p.options.includeWhiteChars||I.replace(/\\n/g,"").trim()!=="")&&(j[p.options.childkey]=j[p.options.childkey]||[],A={"#name":"__text__"},A[E]=I,p.options.normalize&&(A[E]=A[E].replace(/\s{2,}/g," ").trim()),j[p.options.childkey].push(A)),j}}(this),this.saxParser.ontext=D,this.saxParser.oncdata=function(p){return function(I){var A;if(A=D(I),A)return A.cdata=!0}}()},O.prototype.parseString=function(_,E){var D;E!=null&&typeof E=="function"&&(this.on("end",function(T){return this.reset(),E(null,T)}),this.on("error",function(T){return this.reset(),E(T)}));try{return _=_.toString(),_.trim()===""?(this.emit("end",null),!0):(_=n.stripBOM(_),this.options.async?(this.remaining=_,N(this.processAsync),this.saxParser):this.saxParser.write(_).close())}catch(T){if(D=T,this.saxParser.errThrown||this.saxParser.ended){if(this.saxParser.ended)throw D}else return this.emit("error",D),this.saxParser.errThrown=!0}},O.prototype.parseStringPromise=function(_){return new Promise(function(E){return function(D,T){return E.parseString(_,function(p,I){return p?T(p):D(I)})}}(this))},O}(f),u.parseString=function(x,O,_){var E,D,T;return _!=null?(typeof _=="function"&&(E=_),typeof O=="object"&&(D=O)):(typeof O=="function"&&(E=O),D={}),T=new u.Parser(D),T.parseString(x,E)},u.parseStringPromise=function(x,O){var _,E;return typeof O=="object"&&(_=O),E=new u.Parser(_),E.parseStringPromise(x)}}).call(G)}(Ee)),Ee}var pn;(function(){var u,n,c,a=function(o,t){for(var i in t)f.call(t,i)&&(o[i]=t[i]);function m(){this.constructor=o}return m.prototype=t.prototype,o.prototype=new m,o.__super__=t.prototype,o},f={}.hasOwnProperty;n=_e(),u=mi(),c=Di(),hn(),n.defaults,function(o){a(t,o);function t(i){this.message=i}return t}(Error),u.Builder,c.Parser,c.parseString,pn=c.parseStringPromise}).call(G);class vi{constructor(n,c,a){this.nextTxnId=1,this.pendingCommands=new Map,this.breakpoints=new Map,this.scriptIdByUrl=new Map,this.nextScriptId=1,this.objectHandles=new Map,this.nextObjectId=1,this.callFramesMap=new Map,this.xdebugConnected=!1,this.dbgp=n,this.cdp=c,this.readPHPFile=a.getPHPFile,this.phpRoot=a.phpRoot||"";for(const f of a.knownScriptUrls)this.scriptIdByUrl.set(f,this.getOrCreateScriptId(f));this.breakOnFirstLine=a.breakOnFirstLine||!1}start(){this.dbgp.on("connected",()=>{this.xdebugConnected=!0,this.sendDbgpCommand("stdout","-c 1"),this.sendDbgpCommand("stderr","-c 1")}),this.dbgp.on("message",async n=>{try{const c=await pn(n,{explicitArray:!1});await this.handleDbgpMessage(c)}catch{}}),this.dbgp.on("disconnected",()=>{this.xdebugConnected=!1,this.cdp.sendMessage({method:"Debugger.paused",params:{reason:"terminated",callFrames:[]}})}),this.cdp.on("message",n=>{this.handleCdpMessage(n)}),this.cdp.on("clientDisconnected",()=>{this.xdebugConnected&&this.sendDbgpCommand("detach")}),this.sendInitialScripts().then(()=>{if(!this.breakOnFirstLine){const n=this.scriptIdByUrl.entries().next().value;n&&(this.cdp.sendMessage({method:"Debugger.paused",params:{callFrames:[{location:{scriptId:n[1],lineNumber:0},scopeChain:[],this:{type:"undefined"}}],reason:"other"}}),setTimeout(()=>{this.cdp.sendMessage({method:"Debugger.resumed"})},50))}this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:"info",text:`🎉 Welcome to WordPress Playground DevTools! 🎉
43
43
  ‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾‾
44
44
 
45
45
  1. Add breakpoints in your files to start step debugging.
@@ -47,12 +47,12 @@ Actual: `+y.attribValue);else{var K=y.tag,tt=y.tags[y.tags.length-1]||y;K.ns===t
47
47
  2. Run your php file, project, plugin or theme using PHP.wasm or Playground CLI.
48
48
 
49
49
  3. Witness the magic break.`,timestamp:Date.now()}}}),this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:"info",text:" ",timestamp:Date.now()}}})})}stop(){this.dbgp.close(),this.cdp.close()}async sendInitialScripts(){for(const[n,c]of this.scriptIdByUrl.entries())await this.sendScriptToCDP(n,c)}async sendScriptToCDP(n,c){const a=this.uriFromBridgeToCDPSyntaxHighlight(n),f=this.uriFromBridgeToCDP(n),o=await this.readPHPFile(n),t=o.split(`
50
- `),i=t.map((g,b)=>b===0?"AAAA":"AACA").join(";"),m={version:3,file:f,sources:[a],sourcesContent:[o],mappings:i},w=`data:application/json;base64,${Buffer.from(JSON.stringify(m),"utf-8").toString("base64")}`;this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:c,url:f,startLine:0,startColumn:0,endLine:t.length,endColumn:0,executionContextId:1,sourceMapURL:w}})}getOrCreateScriptId(n){let c=this.scriptIdByUrl.get(n);return c||(c=si.createHash("sha256").update(String(this.nextScriptId++)).digest("hex").slice(0,16),this.scriptIdByUrl.set(n,c)),c}formatPropertyFullName(n){let c=!1,a="";for(const f of n)f==='"'||f==="\\"||f==="\0"?(a+="\\"+f,c=!0):f===" "?(a+=f,c=!0):a+=f;return(c||n.includes("'"))&&(a=`"${a}"`),a}sendDbgpCommand(n,c){const f=(this.nextTxnId++).toString();let o=`${n} -i ${f}`;return c!==void 0&&(o+=` ${c}`),this.dbgp.sendCommand(o),f}async handleCdpMessage(n){const{id:c,method:a,params:f}=n;let o={},t=!0;switch(a){case"Debugger.enable":case"Runtime.enable":o={};break;case"Debugger.setBreakpointByUrl":{const{url:i,lineNumber:m}=f,N=this.uriFromCDPToBridge(i),w=this.uriFromBridgeToDBGP(N),g=(typeof m=="number"?m:0)+1,b=String(this.breakpoints.size+1);if(this.xdebugConnected){const x=`breakpoint_set -t line -f ${this.formatPropertyFullName(w)} -n ${g}`,O=this.sendDbgpCommand(x);this.pendingCommands.set(O,{cdpId:c,cdpMethod:a,params:{breakpointId:b,fileUri:N,lineNumber:g}}),t=!1}else this.breakpoints.set(b,{cdpId:b,xdebugId:null,fileUri:N,lineNumber:g}),o={breakpointId:b,locations:[{scriptId:this.getOrCreateScriptId(N),lineNumber:g-1,columnNumber:0}]};break}case"Debugger.removeBreakpoint":{const{breakpointId:i}=f,m=String(i),N=this.breakpoints.get(m);if(N){if(N.xdebugId&&this.xdebugConnected){const w=`breakpoint_remove -d ${N.xdebugId}`,g=this.sendDbgpCommand(w);this.pendingCommands.set(g,{cdpId:c,cdpMethod:a}),t=!1}this.breakpoints.delete(m)}o={};break}case"Debugger.resume":{this.xdebugConnected&&this.sendDbgpCommand("run"),o={};break}case"Debugger.stepOver":{this.xdebugConnected&&this.sendDbgpCommand("step_over"),o={};break}case"Debugger.stepInto":{this.xdebugConnected&&this.sendDbgpCommand("step_into"),o={};break}case"Debugger.stepOut":{this.xdebugConnected&&this.sendDbgpCommand("step_out"),o={};break}case"Debugger.pause":{this.xdebugConnected&&this.sendDbgpCommand("break"),o={};break}case"Runtime.evaluate":case"Debugger.evaluateOnCallFrame":{const i=f.expression||"",m=f.callFrameId;if(a==="Debugger.evaluateOnCallFrame"){if(m===void 0||!this.callFramesMap.has(m)){this.cdp.sendMessage({id:c,error:{code:-32e3,message:"No such call frame"}});return}if(this.callFramesMap.get(m)!==0){this.cdp.sendMessage({id:c,error:{code:-32e3,message:"Evaluation in this frame not supported"}});return}}if(this.xdebugConnected){const N=Buffer.from(i).toString("base64"),w=this.sendDbgpCommand("eval",`-- ${N}`);this.pendingCommands.set(w,{cdpId:c,cdpMethod:a}),t=!1}else o={result:{type:"undefined",value:void 0}};break}case"Runtime.getProperties":{const{objectId:i}=f,m=this.objectHandles.get(i);if(m&&this.xdebugConnected)if(m.type==="context"){const N=m.contextId??0,g=`context_get -d ${m.depth} -c ${N} -p 0 -m 32`,b=this.sendDbgpCommand(g),x={...m,currentPage:0,aggregatedProps:[]};this.objectHandles.set(i,x),this.pendingCommands.set(b,{cdpId:c,cdpMethod:a,params:{objectId:i}}),t=!1}else if(m.type==="property"){const N=m.depth,w=m.fullname,g=this.formatPropertyFullName(w),b=`property_get -d ${N} -n ${g} -p 0 -m 32`,x=this.sendDbgpCommand(b),O={...m,currentPage:0,aggregatedProps:[]};this.objectHandles.set(i,O),this.pendingCommands.set(x,{cdpId:c,cdpMethod:a,params:{parentObjectId:i}}),t=!1}else o={result:[]};else o={result:[]};break}case"Debugger.getScriptSource":{const i=f.scriptId,m=[...this.scriptIdByUrl.entries()].find(([,w])=>w===i)?.[0],N=[];m&&N.push(`Here's the full path for your convenience:
50
+ `),i=t.map((g,b)=>b===0?"AAAA":"AACA").join(";"),m={version:3,file:f,sources:[a],sourcesContent:[o],mappings:i},w=`data:application/json;base64,${Buffer.from(JSON.stringify(m),"utf-8").toString("base64")}`;this.cdp.sendMessage({method:"Debugger.scriptParsed",params:{scriptId:c,url:f,startLine:0,startColumn:0,endLine:t.length,endColumn:0,executionContextId:1,sourceMapURL:w}})}getOrCreateScriptId(n){let c=this.scriptIdByUrl.get(n);return c||(c=Mn("sha256").update(String(this.nextScriptId++)).digest("hex").slice(0,16),this.scriptIdByUrl.set(n,c)),c}formatPropertyFullName(n){let c=!1,a="";for(const f of n)f==='"'||f==="\\"||f==="\0"?(a+="\\"+f,c=!0):f===" "?(a+=f,c=!0):a+=f;return(c||n.includes("'"))&&(a=`"${a}"`),a}sendDbgpCommand(n,c){const f=(this.nextTxnId++).toString();let o=`${n} -i ${f}`;return c!==void 0&&(o+=` ${c}`),this.dbgp.sendCommand(o),f}async handleCdpMessage(n){const{id:c,method:a,params:f}=n;let o={},t=!0;switch(a){case"Debugger.enable":case"Runtime.enable":o={};break;case"Debugger.setBreakpointByUrl":{const{url:i,lineNumber:m}=f,N=this.uriFromCDPToBridge(i),w=this.uriFromBridgeToDBGP(N),g=(typeof m=="number"?m:0)+1,b=String(this.breakpoints.size+1);if(this.xdebugConnected){const x=`breakpoint_set -t line -f ${this.formatPropertyFullName(w)} -n ${g}`,O=this.sendDbgpCommand(x);this.pendingCommands.set(O,{cdpId:c,cdpMethod:a,params:{breakpointId:b,fileUri:N,lineNumber:g}}),t=!1}else this.breakpoints.set(b,{cdpId:b,xdebugId:null,fileUri:N,lineNumber:g}),o={breakpointId:b,locations:[{scriptId:this.getOrCreateScriptId(N),lineNumber:g-1,columnNumber:0}]};break}case"Debugger.removeBreakpoint":{const{breakpointId:i}=f,m=String(i),N=this.breakpoints.get(m);if(N){if(N.xdebugId&&this.xdebugConnected){const w=`breakpoint_remove -d ${N.xdebugId}`,g=this.sendDbgpCommand(w);this.pendingCommands.set(g,{cdpId:c,cdpMethod:a}),t=!1}this.breakpoints.delete(m)}o={};break}case"Debugger.resume":{this.xdebugConnected&&this.sendDbgpCommand("run"),o={};break}case"Debugger.stepOver":{this.xdebugConnected&&this.sendDbgpCommand("step_over"),o={};break}case"Debugger.stepInto":{this.xdebugConnected&&this.sendDbgpCommand("step_into"),o={};break}case"Debugger.stepOut":{this.xdebugConnected&&this.sendDbgpCommand("step_out"),o={};break}case"Debugger.pause":{this.xdebugConnected&&this.sendDbgpCommand("break"),o={};break}case"Runtime.evaluate":case"Debugger.evaluateOnCallFrame":{const i=f.expression||"",m=f.callFrameId;if(a==="Debugger.evaluateOnCallFrame"){if(m===void 0||!this.callFramesMap.has(m)){this.cdp.sendMessage({id:c,error:{code:-32e3,message:"No such call frame"}});return}if(this.callFramesMap.get(m)!==0){this.cdp.sendMessage({id:c,error:{code:-32e3,message:"Evaluation in this frame not supported"}});return}}if(this.xdebugConnected){const N=Buffer.from(i).toString("base64"),w=this.sendDbgpCommand("eval",`-- ${N}`);this.pendingCommands.set(w,{cdpId:c,cdpMethod:a}),t=!1}else o={result:{type:"undefined",value:void 0}};break}case"Runtime.getProperties":{const{objectId:i}=f,m=this.objectHandles.get(i);if(m&&this.xdebugConnected)if(m.type==="context"){const N=m.contextId??0,g=`context_get -d ${m.depth} -c ${N} -p 0 -m 32`,b=this.sendDbgpCommand(g),x={...m,currentPage:0,aggregatedProps:[]};this.objectHandles.set(i,x),this.pendingCommands.set(b,{cdpId:c,cdpMethod:a,params:{objectId:i}}),t=!1}else if(m.type==="property"){const N=m.depth,w=m.fullname,g=this.formatPropertyFullName(w),b=`property_get -d ${N} -n ${g} -p 0 -m 32`,x=this.sendDbgpCommand(b),O={...m,currentPage:0,aggregatedProps:[]};this.objectHandles.set(i,O),this.pendingCommands.set(x,{cdpId:c,cdpMethod:a,params:{parentObjectId:i}}),t=!1}else o={result:[]};else o={result:[]};break}case"Debugger.getScriptSource":{const i=f.scriptId,m=[...this.scriptIdByUrl.entries()].find(([,w])=>w===i)?.[0],N=[];m&&N.push(`Here's the full path for your convenience:
51
51
  `,`${this.uriFromBridgeToCDPSyntaxHighlight(m).replace("file://","")}
52
52
  `),o={scriptSource:["`Are you looking for your source code?","Go to PHP.wasm group in the navigator and find it there.",...N,"What is this file, then? It's a placeholder required due to the dev tools limitations.","The XDebug <-> Devtools bridge implement PHP syntax highlighting using source maps,",'and the unfortunate side effect is having a "source" file and a "target" file.',`This is the "source". If you're interested in even more details, see the discussion at:
53
53
  `,"https://github.com/WordPress/wordpress-playground/pull/2566`"].join(`
54
- `)};break}default:o={};break}t&&this.cdp.sendMessage({id:c,result:o})}uriFromBridgeToCDPSyntaxHighlight(n){return`file://PHP.wasm/${n}`}uriFromBridgeToCDP(n){return n=this.scriptIdByUrl.get(n)??"",`file://placeholders/${n}`}uriFromCDPToBridge(n){const c="file://placeholders/";return[...this.scriptIdByUrl.entries()].find(([,a])=>a===n.slice(c.length))?.[0]??""}uriFromBridgeToDBGP(n){return Pt.resolve(process.cwd(),n)}uriFromDBGPToBridge(n){n=n.startsWith("file://")?n.slice(7):n;const c=n.indexOf(this.phpRoot);return c!==-1?n.slice(c):n}async handleDbgpMessage(n){if(n.init){this.breakpoints.forEach(a=>{this.handleCdpMessage({id:a.cdpId,method:"Debugger.setBreakpointByUrl",params:{url:this.uriFromBridgeToCDP(a.fileUri),lineNumber:a.lineNumber-1}})});const c=this.breakOnFirstLine?this.sendDbgpCommand("step_into"):this.sendDbgpCommand("run");this.pendingCommands.set(c,{});return}if(n.response){const c=n.response,a=c.$,f=a.command,o=a.transaction_id,t=this.pendingCommands.get(o);switch(f){case"breakpoint_set":{if(t&&t.cdpId!==void 0&&t.cdpMethod==="Debugger.setBreakpointByUrl"){const i=a.id,m=t.params;if(m){const{breakpointId:N,fileUri:w,lineNumber:g}=m;this.breakpoints.set(N,{cdpId:N,xdebugId:i,fileUri:w,lineNumber:g});const b=this.getOrCreateScriptId(w),x={breakpointId:N,locations:[{scriptId:b,lineNumber:g-1,columnNumber:0}]};this.cdp.sendMessage({id:t.cdpId,result:x})}this.pendingCommands.delete(o)}break}case"breakpoint_remove":{t&&t.cdpId!==void 0&&(this.cdp.sendMessage({id:t.cdpId,result:{}}),this.pendingCommands.delete(o));break}case"run":case"step_into":case"step_over":case"step_out":{const i=a.status;if(c["xdebug:message"]){const m=this.uriFromDBGPToBridge(c["xdebug:message"].$.filename);m&&!this.scriptIdByUrl.has(m)&&await this.sendScriptToCDP(m,this.getOrCreateScriptId(m))}if(i==="break"){const m=this.sendDbgpCommand("stack_get");this.pendingCommands.set(m,{}),this.pendingCommands.delete(o)}else(i==="stopping"||i==="stopped")&&this.cdp.sendMessage({method:"Debugger.resumed",params:{}});break}case"eval":{if(t&&t.cdpId!==void 0){let i;if(c.property){const N=c.property,w=N.$.type,g=N.$.encoding;let b=null;if(Object.prototype.hasOwnProperty.call(N,"_")?b=N._:typeof N.$value<"u"&&(b=N.$value),g==="base64"&&b!==null)try{b=Buffer.from(b,"base64").toString()}catch{}if(w==="string")i={type:"string",value:b??""};else if(w==="int"||w==="float"||w==="bool"||w==="boolen"||w==="integer"||w==="double"){let x=b;w.startsWith("int")||w==="integer"?x=parseInt(b||"0",10):w==="float"||w==="double"?x=parseFloat(b||"0"):w.startsWith("bool")&&(x=b==="1"||b==="true"),i={type:"number",value:x}}else if(w==="array"||w==="object"){const x=N.$.classname||(w==="array"?"Array":"Object"),O=String(this.nextObjectId++),_=N.$.fullname||"";this.objectHandles.set(O,{type:"property",depth:0,contextId:0,fullname:_}),i={type:"object",objectId:O,className:x,description:x}}else w==="null"?i={type:"object",subtype:"null",value:null}:i={type:"undefined",value:void 0}}else i={type:"undefined",value:void 0};const m={result:i};this.cdp.sendMessage({id:t.cdpId,result:m}),this.pendingCommands.delete(o)}break}case"context_get":case"property_get":{if(t&&t.cdpId!==void 0){const i=t.params?.objectId||t.params?.parentObjectId,m=i?this.objectHandles.get(i):null,N=c.property?.property??c.property,w=[];if(N){const g=Array.isArray(N)?N:[N];for(const b of g){const x=b.$.name||b.$.fullname||"";let O=b.$.type||"undefined";const _=b.$.children==="1",E=b.$.encoding;let D=null;if(typeof b._<"u"&&(D=b._),E==="base64"&&D!==null)try{D=Buffer.from(D,"base64").toString()}catch{}if(_){const T=b.$.classname||(O==="array"?"Array":"Object"),p=String(this.nextObjectId++),I=t.cdpMethod==="Runtime.getProperties"&&t.params?.parentObjectId&&this.objectHandles.get(t.params.parentObjectId)?.contextId||0,A=t.cdpMethod==="Runtime.getProperties"&&t.params?.parentObjectId&&this.objectHandles.get(t.params.parentObjectId)?.depth||0;this.objectHandles.set(p,{type:"property",depth:A,contextId:I,fullname:b.$.fullname||x}),w.push({name:b.$.key||x,value:{type:"object",className:T,description:T,objectId:p},writable:!1,configurable:!1,enumerable:!0})}else{let T,p;O==="string"?T=D??"":O==="int"||O==="integer"?T=parseInt(D||"0",10):O==="float"||O==="double"?T=parseFloat(D||"0"):O==="bool"||O==="boolean"?(T=D==="1"||D==="true",O="boolean"):O==="null"?(T=null,p="null"):T=D;const I={type:O==="integer"?"number":O};p&&(I.subtype=p),I.value=T,w.push({name:b.$.key||x,value:I,writable:!1,configurable:!1,enumerable:!0})}}}if(m){const g=(m.aggregatedProps||[]).concat(w),b=32;if(w.length===b){const O=(m.currentPage||0)+1,_={...m,currentPage:O,aggregatedProps:g};this.objectHandles.set(i,_);let E;if(f==="context_get"){const T=m.contextId??0;E=`context_get -d ${m.depth} -c ${T} -p ${O} -m ${b}`}else{const T=m.depth,p=m.fullname,I=this.formatPropertyFullName(p);E=`property_get -d ${T} -n ${I} -p ${O} -m ${b}`}const D=this.sendDbgpCommand(E);this.pendingCommands.set(D,{cdpId:t.cdpId,cdpMethod:t.cdpMethod,params:t.params}),this.pendingCommands.delete(o);return}else{const O={result:g};this.cdp.sendMessage({id:t.cdpId,result:O}),this.pendingCommands.delete(o)}}else{const g={result:w};this.cdp.sendMessage({id:t.cdpId,result:g}),this.pendingCommands.delete(o)}}break}case"stack_get":{if(c.stack){const i=Array.isArray(c.stack)?c.stack:[c.stack],m=[];this.callFramesMap.clear();for(const w of i){const g=this.uriFromDBGPToBridge(w.$.filename),b=this.getOrCreateScriptId(g);this.scriptIdByUrl.has(g)||(this.scriptIdByUrl.set(g,b),await this.sendScriptToCDP(g,b))}for(const w of i){const g=parseInt(w.$.level,10),b=this.uriFromDBGPToBridge(w.$.filename),x=parseInt(w.$.lineno,10),O=w.$.where&&w.$.where!=="{main}"?w.$.where:"(anonymous)",_=`frame:${g}`;this.callFramesMap.set(_,g);const E=[],D=String(this.nextObjectId++);this.objectHandles.set(D,{type:"context",contextId:0,depth:g}),E.push({type:"local",object:{objectId:D,className:"Object",description:"Local"}});const T=String(this.nextObjectId++);this.objectHandles.set(T,{type:"context",contextId:1,depth:g}),E.push({type:"global",object:{objectId:T,className:"Object",description:"Global"}}),m.push({callFrameId:_,functionName:O,location:{scriptId:this.getOrCreateScriptId(b),lineNumber:x-1,columnNumber:0},scopeChain:E,this:{type:"object",className:"Object",description:"Object",objectId:T}})}let N="pause";if(i.length>0){const w=i[0];if(w.$.filename&&w.$.lineno){const g=this.uriFromDBGPToBridge(w.$.filename),b=parseInt(w.$.lineno,10);for(const x of this.breakpoints.values())if(x.fileUri===g&&x.lineNumber===b){N="breakpoint";break}}}this.cdp.sendMessage({method:"Debugger.paused",params:{reason:N,callFrames:m,hitBreakpoints:N==="breakpoint"?[""]:[]}})}this.pendingCommands.delete(o);break}default:{t&&t.cdpId!==void 0&&(this.cdp.sendMessage({id:t.cdpId,result:{}}),this.pendingCommands.delete(o));break}}}else if(n.stream){const c=n.stream,a=c.$.type,f=c.$.encoding||"none";let o=typeof c._=="string"?c._:"";f==="base64"&&(o=Buffer.from(o,"base64").toString()),this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:a==="stderr"?"error":"info",text:o,timestamp:Date.now(),stackTrace:{callFrames:[]}}}})}else n.notify}}async function Ii(u){const n=u.cdpPort??9229,c=u.dbgpPort??9003,a=u.cdpHost??"localhost",f=u.phpRoot??process.cwd(),o=u.breakOnFirstLine??!1;ht.log("Starting XDebug Bridge...");const t=new Hn(n);ht.log("Connect Chrome DevTools to CDP at:"),ht.log(`devtools://devtools/bundled/inspector.html?ws=${a}:${n}
55
- `),await new Promise(g=>t.on("clientConnected",g)),await new Promise(g=>setTimeout(g,2e3)),ht.log("Chrome connected! Initializing Xdebug receiver...");const i=new Gn(c);ht.log(`XDebug receiver running on port ${c}`),ht.log("Running a PHP script with Xdebug enabled...");function m(g){const b=[],x=gn(g);for(const O of x){const _=Pt.join(g,O),E=wn(_);E&&E.isDirectory()?b.push(...m(_)):O.endsWith(".php")&&b.push(_)}return b}const N=u.phpInstance?g=>u.phpInstance.readFileAsText(g):u.getPHPFile?u.getPHPFile:g=>Oe(g,"utf-8"),w=m(f);return new vi(i,t,{knownScriptUrls:w,phpRoot:f,getPHPFile:N,breakOnFirstLine:o})}let at=process.argv.slice(2);at.length||(at=["--help"]);const dn=(import.meta||{}).url,Ne=new URL("ca-bundle.crt",dn).pathname;bn(Ne)||Hr(Ne,Tn.join(`
54
+ `)};break}default:o={};break}t&&this.cdp.sendMessage({id:c,result:o})}uriFromBridgeToCDPSyntaxHighlight(n){return`file://PHP.wasm/${n}`}uriFromBridgeToCDP(n){return n=this.scriptIdByUrl.get(n)??"",`file://placeholders/${n}`}uriFromCDPToBridge(n){const c="file://placeholders/";return[...this.scriptIdByUrl.entries()].find(([,a])=>a===n.slice(c.length))?.[0]??""}uriFromBridgeToDBGP(n){return Pt.resolve(process.cwd(),n)}uriFromDBGPToBridge(n){n=n.startsWith("file://")?n.slice(7):n;const c=n.indexOf(this.phpRoot);return c!==-1?n.slice(c):n}async handleDbgpMessage(n){if(n.init){this.breakpoints.forEach(a=>{this.handleCdpMessage({id:a.cdpId,method:"Debugger.setBreakpointByUrl",params:{url:this.uriFromBridgeToCDP(a.fileUri),lineNumber:a.lineNumber-1}})});const c=this.breakOnFirstLine?this.sendDbgpCommand("step_into"):this.sendDbgpCommand("run");this.pendingCommands.set(c,{});return}if(n.response){const c=n.response,a=c.$,f=a.command,o=a.transaction_id,t=this.pendingCommands.get(o);switch(f){case"breakpoint_set":{if(t&&t.cdpId!==void 0&&t.cdpMethod==="Debugger.setBreakpointByUrl"){const i=a.id,m=t.params;if(m){const{breakpointId:N,fileUri:w,lineNumber:g}=m;this.breakpoints.set(N,{cdpId:N,xdebugId:i,fileUri:w,lineNumber:g});const b=this.getOrCreateScriptId(w),x={breakpointId:N,locations:[{scriptId:b,lineNumber:g-1,columnNumber:0}]};this.cdp.sendMessage({id:t.cdpId,result:x})}this.pendingCommands.delete(o)}break}case"breakpoint_remove":{t&&t.cdpId!==void 0&&(this.cdp.sendMessage({id:t.cdpId,result:{}}),this.pendingCommands.delete(o));break}case"run":case"step_into":case"step_over":case"step_out":{const i=a.status;if(c["xdebug:message"]){const m=this.uriFromDBGPToBridge(c["xdebug:message"].$.filename);m&&!this.scriptIdByUrl.has(m)&&await this.sendScriptToCDP(m,this.getOrCreateScriptId(m))}if(i==="break"){const m=this.sendDbgpCommand("stack_get");this.pendingCommands.set(m,{}),this.pendingCommands.delete(o)}else(i==="stopping"||i==="stopped")&&this.cdp.sendMessage({method:"Debugger.resumed",params:{}});break}case"eval":{if(t&&t.cdpId!==void 0){let i;if(c.property){const N=c.property,w=N.$.type,g=N.$.encoding;let b=null;if(Object.prototype.hasOwnProperty.call(N,"_")?b=N._:typeof N.$value<"u"&&(b=N.$value),g==="base64"&&b!==null)try{b=Buffer.from(b,"base64").toString()}catch{}if(w==="string")i={type:"string",value:b??""};else if(w==="int"||w==="float"||w==="bool"||w==="boolen"||w==="integer"||w==="double"){let x=b;w.startsWith("int")||w==="integer"?x=parseInt(b||"0",10):w==="float"||w==="double"?x=parseFloat(b||"0"):w.startsWith("bool")&&(x=b==="1"||b==="true"),i={type:"number",value:x}}else if(w==="array"||w==="object"){const x=N.$.classname||(w==="array"?"Array":"Object"),O=String(this.nextObjectId++),_=N.$.fullname||"";this.objectHandles.set(O,{type:"property",depth:0,contextId:0,fullname:_}),i={type:"object",objectId:O,className:x,description:x}}else w==="null"?i={type:"object",subtype:"null",value:null}:i={type:"undefined",value:void 0}}else i={type:"undefined",value:void 0};const m={result:i};this.cdp.sendMessage({id:t.cdpId,result:m}),this.pendingCommands.delete(o)}break}case"context_get":case"property_get":{if(t&&t.cdpId!==void 0){const i=t.params?.objectId||t.params?.parentObjectId,m=i?this.objectHandles.get(i):null,N=c.property?.property??c.property,w=[];if(N){const g=Array.isArray(N)?N:[N];for(const b of g){const x=b.$.name||b.$.fullname||"";let O=b.$.type||"undefined";const _=b.$.children==="1",E=b.$.encoding;let D=null;if(typeof b._<"u"&&(D=b._),E==="base64"&&D!==null)try{D=Buffer.from(D,"base64").toString()}catch{}if(_){const T=b.$.classname||(O==="array"?"Array":"Object"),p=String(this.nextObjectId++),I=t.cdpMethod==="Runtime.getProperties"&&t.params?.parentObjectId&&this.objectHandles.get(t.params.parentObjectId)?.contextId||0,A=t.cdpMethod==="Runtime.getProperties"&&t.params?.parentObjectId&&this.objectHandles.get(t.params.parentObjectId)?.depth||0;this.objectHandles.set(p,{type:"property",depth:A,contextId:I,fullname:b.$.fullname||x}),w.push({name:b.$.key||x,value:{type:"object",className:T,description:T,objectId:p},writable:!1,configurable:!1,enumerable:!0})}else{let T,p;O==="string"?T=D??"":O==="int"||O==="integer"?T=parseInt(D||"0",10):O==="float"||O==="double"?T=parseFloat(D||"0"):O==="bool"||O==="boolean"?(T=D==="1"||D==="true",O="boolean"):O==="null"?(T=null,p="null"):T=D;const I={type:O==="integer"?"number":O};p&&(I.subtype=p),I.value=T,w.push({name:b.$.key||x,value:I,writable:!1,configurable:!1,enumerable:!0})}}}if(m){const g=(m.aggregatedProps||[]).concat(w),b=32;if(w.length===b){const O=(m.currentPage||0)+1,_={...m,currentPage:O,aggregatedProps:g};this.objectHandles.set(i,_);let E;if(f==="context_get"){const T=m.contextId??0;E=`context_get -d ${m.depth} -c ${T} -p ${O} -m ${b}`}else{const T=m.depth,p=m.fullname,I=this.formatPropertyFullName(p);E=`property_get -d ${T} -n ${I} -p ${O} -m ${b}`}const D=this.sendDbgpCommand(E);this.pendingCommands.set(D,{cdpId:t.cdpId,cdpMethod:t.cdpMethod,params:t.params}),this.pendingCommands.delete(o);return}else{const O={result:g};this.cdp.sendMessage({id:t.cdpId,result:O}),this.pendingCommands.delete(o)}}else{const g={result:w};this.cdp.sendMessage({id:t.cdpId,result:g}),this.pendingCommands.delete(o)}}break}case"stack_get":{if(c.stack){const i=Array.isArray(c.stack)?c.stack:[c.stack],m=[];this.callFramesMap.clear();for(const w of i){const g=this.uriFromDBGPToBridge(w.$.filename),b=this.getOrCreateScriptId(g);this.scriptIdByUrl.has(g)||(this.scriptIdByUrl.set(g,b),await this.sendScriptToCDP(g,b))}for(const w of i){const g=parseInt(w.$.level,10),b=this.uriFromDBGPToBridge(w.$.filename),x=parseInt(w.$.lineno,10),O=w.$.where&&w.$.where!=="{main}"?w.$.where:"(anonymous)",_=`frame:${g}`;this.callFramesMap.set(_,g);const E=[],D=String(this.nextObjectId++);this.objectHandles.set(D,{type:"context",contextId:0,depth:g}),E.push({type:"local",object:{objectId:D,className:"Object",description:"Local"}});const T=String(this.nextObjectId++);this.objectHandles.set(T,{type:"context",contextId:1,depth:g}),E.push({type:"global",object:{objectId:T,className:"Object",description:"Global"}}),m.push({callFrameId:_,functionName:O,location:{scriptId:this.getOrCreateScriptId(b),lineNumber:x-1,columnNumber:0},scopeChain:E,this:{type:"object",className:"Object",description:"Object",objectId:T}})}let N="pause";if(i.length>0){const w=i[0];if(w.$.filename&&w.$.lineno){const g=this.uriFromDBGPToBridge(w.$.filename),b=parseInt(w.$.lineno,10);for(const x of this.breakpoints.values())if(x.fileUri===g&&x.lineNumber===b){N="breakpoint";break}}}this.cdp.sendMessage({method:"Debugger.paused",params:{reason:N,callFrames:m,hitBreakpoints:N==="breakpoint"?[""]:[]}})}this.pendingCommands.delete(o);break}default:{t&&t.cdpId!==void 0&&(this.cdp.sendMessage({id:t.cdpId,result:{}}),this.pendingCommands.delete(o));break}}}else if(n.stream){const c=n.stream,a=c.$.type,f=c.$.encoding||"none";let o=typeof c._=="string"?c._:"";f==="base64"&&(o=Buffer.from(o,"base64").toString()),this.cdp.sendMessage({method:"Log.entryAdded",params:{entry:{source:"other",level:a==="stderr"?"error":"info",text:o,timestamp:Date.now(),stackTrace:{callFrames:[]}}}})}else n.notify}}async function Ii(u){const n=u.cdpPort??9229,c=u.dbgpPort??9003,a=u.cdpHost??"localhost",f=u.phpRoot??process.cwd(),o=u.breakOnFirstLine??!1;ht.log("Starting XDebug Bridge...");const t=new Gn(n);ht.log("Connect Chrome DevTools to CDP at:"),ht.log(`devtools://devtools/bundled/inspector.html?ws=${a}:${n}
55
+ `),await new Promise(g=>t.on("clientConnected",g)),await new Promise(g=>setTimeout(g,2e3)),ht.log("Chrome connected! Initializing Xdebug receiver...");const i=new Yn(c);ht.log(`XDebug receiver running on port ${c}`),ht.log("Running a PHP script with Xdebug enabled...");function m(g){const b=[],x=gn(g);for(const O of x){const _=Pt.join(g,O),E=wn(_);E&&E.isDirectory()?b.push(...m(_)):O.endsWith(".php")&&b.push(_)}return b}const N=u.phpInstance?g=>u.phpInstance.readFileAsText(g):u.getPHPFile?u.getPHPFile:g=>Oe(g,"utf-8"),w=m(f);return new vi(i,t,{knownScriptUrls:w,phpRoot:f,getPHPFile:N,breakOnFirstLine:o})}let at=process.argv.slice(2);at.length||(at=["--help"]);const dn=(import.meta||{}).url,Ne=new URL("ca-bundle.crt",dn).pathname;bn(Ne)||Hr(Ne,Tn.join(`
56
56
  `));at.unshift("-d",`openssl.cafile=${Ne}`);async function Ni(){const u=new URL("php.ini",dn).pathname,n=process.env.PHP||xn;if(!Dn.includes(n))throw new Error(`Unsupported PHP version ${n}`);const c=at.some(g=>g.startsWith("--xdebug"));c&&(at=at.filter(g=>g!=="--xdebug"));const a=at.some(g=>g.startsWith("--experimental-devtools"));a&&(at=at.filter(g=>g!=="--experimental-devtools"));const{TMPDIR:f,...o}=process.env,t=ze(Pt.join(Ye.tmpdir(),"php-wasm-bin"));Hr(`${t}/php`,`#!/bin/sh
57
57
  ${process.argv[0]} ${process.execArgv.join(" ")} ${process.argv[1]}
58
58
  `),En(`${t}/php`,493);const i=ze(Pt.join(Ye.tmpdir(),"php-wasm-sys-tmp")),m=new vn(await In(n,{emscriptenOptions:{fileLockManager:new Nn,processId:1,ENV:{...o,TMPDIR:i,TERM:"xterm",PATH:`${t}:${o.PATH}`}},withXdebug:c}));On(m),a&&c&&(await Ii({breakOnFirstLine:!0})).start(),at.some(g=>g.startsWith("-c"))||at.unshift("-c",u);const w=await m.cli(["php",...at]);w.stderr.pipeTo(new WritableStream({write(g){process.stderr.write(g)}})),w.stdout.pipeTo(new WritableStream({write(g){process.stdout.write(g)}})),await w.exitCode.catch(g=>{throw g.name==="ExitStatus"&&process.exit(g.status===void 0?1:g.status),g}).finally(()=>{setTimeout(()=>{process.exit(0)},100)})}Ni();