@phosphor-tools/phosphor-mcp 0.1.0-dev.pr78.9 → 0.2.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli.mjs +749 -24
- package/package.json +23 -24
package/dist/cli.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import{createRequire as e}from"node:module";import{Command as t}from"@commander-js/extra-typings";import{homedir as n}from"node:os";import{basename as r,dirname as i,isAbsolute as a,join as o,relative as s,resolve as c}from"node:path";import{mkdir as l,readFile as u,realpath as d,rename as f,rm as p,writeFile as m}from"node:fs/promises";import{execFile as h,execFileSync as g}from"node:child_process";import{PostHog as _}from"posthog-node";import{StdioServerTransport as v}from"@modelcontextprotocol/sdk/server/stdio.js";import{McpServer as y}from"@modelcontextprotocol/sdk/server/mcp.js";import{accessSync as b,constants as x}from"node:fs";import{createHash as S,randomBytes as C}from"node:crypto";import{z as w}from"zod";var T=Object.create,E=Object.defineProperty,ee=Object.getOwnPropertyDescriptor,te=Object.getOwnPropertyNames,ne=Object.getPrototypeOf,D=Object.prototype.hasOwnProperty,O=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),re=(e,t)=>{let n={};for(var r in e)E(n,r,{get:e[r],enumerable:!0});return t||E(n,Symbol.toStringTag,{value:`Module`}),n},ie=(e,t,n,r)=>{if(t&&typeof t==`object`||typeof t==`function`)for(var i=te(t),a=0,o=i.length,s;a<o;a++)s=i[a],!D.call(e,s)&&s!==n&&E(e,s,{get:(e=>t[e]).bind(null,s),enumerable:!(r=ee(t,s))||r.enumerable});return e},ae=(e,t,n)=>(n=e==null?{}:T(ne(e)),ie(t||!e||!e.__esModule?E(n,`default`,{value:e,enumerable:!0}):n,e)),k=e(import.meta.url);function oe(e){let t=e.split(`.`);if(t.length!==3)return null;try{return JSON.parse(Buffer.from(t[1],`base64url`).toString())}catch{return null}}function se(e){let t=oe(e);return!t||typeof t.exp!=`number`?null:t.exp}function ce(e,t){let n=se(e.access_token),r=Number.isFinite(e.expires_in)?e.expires_in:3600,i=n??Math.floor(Date.now()/1e3)+r,a;if(e.id_token){let t=oe(e.id_token);if(t){let e=`${typeof t.given_name==`string`?t.given_name:``} ${typeof t.family_name==`string`?t.family_name:``}`.trim(),n=typeof t.sub==`string`?t.sub:``;n&&(a={id:n,email:typeof t.email==`string`?t.email:``,name:e})}}return{accessToken:e.access_token,refreshToken:e.refresh_token??t??``,expiresAt:i,user:a}}async function A(e,t,n){let r=new URLSearchParams({client_id:e,scope:`openid profile email offline_access`}),i=await fetch(`${t}/oauth2/device_authorization`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:r.toString(),signal:n});if(!i.ok){let e=``;try{let t=await i.json();e=typeof t.error_description==`string`?t.error_description:typeof t.error==`string`?t.error:typeof t.message==`string`?t.message:``}catch{}let n=`${t}/oauth2/device_authorization`,r=e?`${e} (HTTP ${i.status} from ${n})`:`HTTP ${i.status} from ${n}`;throw Error(`Device authorization failed: ${r}`)}return await i.json()}async function le(e,t,n,r,i,a=(e,t)=>new Promise((n,r)=>{if(t?.aborted){r(Error(`Aborted`));return}let i=setTimeout(n,e);t?.addEventListener(`abort`,()=>{clearTimeout(i),r(Error(`Aborted`))},{once:!0})})){let o=`${t}/oauth2/token`,s=r;for(;;){await a(s*1e3,i);let t=new URLSearchParams({client_id:e,grant_type:`urn:ietf:params:oauth:grant-type:device_code`,device_code:n}),r=await fetch(o,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:t.toString(),signal:i});if(r.ok)return ce(await r.json());let c;try{c=await r.json()}catch{throw Error(`Token endpoint returned non-JSON error: HTTP ${r.status}`)}if(c.error!==`authorization_pending`){if(c.error===`slow_down`){s+=5;continue}throw c.error===`expired_token`?Error(`Device code expired. Please restart the login flow.`):c.error===`access_denied`?Error(`Authorization denied by the user.`):Error(`Unexpected error during polling: ${c.error??r.statusText}`)}}}async function ue(e,t,n){try{let r=new URLSearchParams({client_id:e,grant_type:`refresh_token`,refresh_token:n}),i=await fetch(`${t}/oauth2/token`,{method:`POST`,headers:{"Content-Type":`application/x-www-form-urlencoded`},body:r.toString(),signal:AbortSignal.timeout(3e4)});if(i.ok)return{session:ce(await i.json(),n),permanent:!1};let a=i.status===400||i.status===401,o=``;try{o=await i.text()}catch{}return console.error(`[auth] Token refresh failed: HTTP ${i.status} (${a?`permanent`:`transient`})${o?`: ${o}`:``}`),{session:null,permanent:a}}catch(e){return console.error(`[auth] Token refresh failed:`,e instanceof Error?e.message:e),{session:null,permanent:!1}}}function de(){let e=process.env.XDG_CONFIG_HOME?.trim();return o(e||o(n(),`.config`),`phosphor`)}function fe(){let e=process.env.XDG_CACHE_HOME?.trim();return o(e||o(n(),`.cache`),`phosphor`)}function pe(){return o(de(),`session.json`)}async function me(e){let t=e??pe();try{let e=await u(t,`utf-8`),n=JSON.parse(e);return ve(n)?n:null}catch{return null}}async function he(e,t){let n=t??pe();await l(i(n),{recursive:!0}),await m(n,JSON.stringify(e,null,2),{encoding:`utf-8`,mode:384})}async function ge(e){let t=e??pe();try{await p(t)}catch(e){if(e.code!==`ENOENT`)throw e}}async function _e(e){let t=process.env.PHOSPHOR_TOKEN;if(t)return t;let n=e?.sessionPath,r=await me(n);if(!r)return null;let i=Math.floor(Date.now()/1e3);if(r.expiresAt>i)return r.accessToken;if(e?.clientId&&e.baseUrl){let{session:t}=await ue(e.clientId,e.baseUrl,r.refreshToken);if(t)return await he(t,n),t.accessToken}return null}function ve(e){if(typeof e!=`object`||!e)return!1;let t=e;return typeof t.accessToken==`string`&&typeof t.refreshToken==`string`&&typeof t.expiresAt==`number`}async function ye(e){let t=new AbortController,n=()=>{t.abort(),console.log(`
|
|
3
|
-
Login cancelled.`),process.exit(0)};process.on(`SIGINT`,n);try{console.log(`Starting login...`);let n=await A(e.clientId,e.baseUrl,t.signal);console.log(`\nOpen this URL in your browser:\n ${n.verification_uri_complete}`),console.log(`\nOr go to ${n.verification_uri} and enter code: ${n.user_code}\n`),console.log(`Waiting for authorization...`),Ce(n.verification_uri_complete);let r=await le(e.clientId,e.baseUrl,n.device_code,n.interval,t.signal);await he(r),console.log(`\nLogged in as ${r.user?.name??r.user?.email??`unknown`}.`)}finally{process.off(`SIGINT`,n)}}async function be(){await ge(),console.log(`Session cleared.`)}async function xe(e){let t=process.env.PHOSPHOR_TOKEN;if(t){we(t,`(from PHOSPHOR_TOKEN env var)`);return}let n=await me();n||(process.stderr.write(`Not authenticated. Run \`${e.cliName} login\`.\n`),process.exit(1));let{session:r}=await ue(e.clientId,e.baseUrl,n.refreshToken);r||(process.stderr.write(`Session expired and could not be refreshed. Run \`${e.cliName} login\`.\n`),process.exit(1)),await he(r),console.log(`Authenticated as:`),r.user?.name&&console.log(` Name: ${r.user.name}`),r.user?.email&&console.log(` Email: ${r.user.email}`),r.user?.id&&console.log(` ID: ${r.user.id}`)}async function Se(e){return _e({clientId:e.clientId,baseUrl:e.baseUrl})}function Ce(e){process.platform===`win32`?h(`cmd.exe`,[`/c`,`start`,``,e],()=>{}):h(process.platform===`darwin`?`open`:`xdg-open`,[e],()=>{})}function we(e,t){let n=oe(e);if(!n){console.log(`Authenticated ${t}`);return}console.log(`Authenticated ${t}:`),n.sub&&console.log(` User ID: ${String(n.sub)}`),n.email&&console.log(` Email: ${String(n.email)}`),n.org_id&&console.log(` Org ID: ${String(n.org_id)}`);let r=se(e);if(r){let e=new Date(r*1e3);console.log(` Expires: ${e.toISOString()}`)}}const Te=`0.
|
|
3
|
+
Login cancelled.`),process.exit(0)};process.on(`SIGINT`,n);try{console.log(`Starting login...`);let n=await A(e.clientId,e.baseUrl,t.signal);console.log(`\nOpen this URL in your browser:\n ${n.verification_uri_complete}`),console.log(`\nOr go to ${n.verification_uri} and enter code: ${n.user_code}\n`),console.log(`Waiting for authorization...`),Ce(n.verification_uri_complete);let r=await le(e.clientId,e.baseUrl,n.device_code,n.interval,t.signal);await he(r),console.log(`\nLogged in as ${r.user?.name??r.user?.email??`unknown`}.`)}finally{process.off(`SIGINT`,n)}}async function be(){await ge(),console.log(`Session cleared.`)}async function xe(e){let t=process.env.PHOSPHOR_TOKEN;if(t){we(t,`(from PHOSPHOR_TOKEN env var)`);return}let n=await me();n||(process.stderr.write(`Not authenticated. Run \`${e.cliName} login\`.\n`),process.exit(1));let{session:r}=await ue(e.clientId,e.baseUrl,n.refreshToken);r||(process.stderr.write(`Session expired and could not be refreshed. Run \`${e.cliName} login\`.\n`),process.exit(1)),await he(r),console.log(`Authenticated as:`),r.user?.name&&console.log(` Name: ${r.user.name}`),r.user?.email&&console.log(` Email: ${r.user.email}`),r.user?.id&&console.log(` ID: ${r.user.id}`)}async function Se(e){return _e({clientId:e.clientId,baseUrl:e.baseUrl})}function Ce(e){process.platform===`win32`?h(`cmd.exe`,[`/c`,`start`,``,e],()=>{}):h(process.platform===`darwin`?`open`:`xdg-open`,[e],()=>{})}function we(e,t){let n=oe(e);if(!n){console.log(`Authenticated ${t}`);return}console.log(`Authenticated ${t}:`),n.sub&&console.log(` User ID: ${String(n.sub)}`),n.email&&console.log(` Email: ${String(n.email)}`),n.org_id&&console.log(` Org ID: ${String(n.org_id)}`);let r=se(e);if(r){let e=new Date(r*1e3);console.log(` Expires: ${e.toISOString()}`)}}const Te=`0.2.0-rc.1`;let Ee=null,De=null;const Oe=crypto.randomUUID();function ke(){return process.env.DO_NOT_TRACK===`1`?null:(Ee||=new _(`phc_u7SpJkr2pJwaJo9HNQx56N3RQh3tQtZhvwaxNG2d9sRX`,{host:`https://us.i.posthog.com`,enableExceptionAutocapture:!0}),Ee)}async function Ae(){let e=Ee;if(Ee=null,e)try{await e.shutdown()}catch(e){console.error(`[posthog] shutdown failed:`,e)}}async function je(){if(De)return De;let e=await me();return De={distinctId:e?.user?.id??`anonymous`,orgId:e?.organizationId??void 0},De}function Me(){De=null}async function Ne(e,t){try{let n=ke();if(!n)return;let{distinctId:r,orgId:i}=await je();n.capture({distinctId:r,event:e,properties:{...t,org_id:i,$session_id:Oe}})}catch(e){console.error(`[posthog] captureEvent failed:`,e)}}const Pe={cliName:`phosphor-mcp`,clientId:`client_01KQ554GF8931H82MVC7NZY837`,baseUrl:`https://sumptuous-mobile-11.authkit.app`};async function Fe(){await ye(Pe),Me(),await Ne(`login`)}async function Ie(){await Ne(`logout`),await be(),Me()}function Le(){return xe(Pe)}function Re(){return Se(Pe)}const j={"User-Agent":`Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/135.0.0.0 Safari/537.36`,Accept:`text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8`,"Accept-Language":`en-US,en;q=0.9`,"Accept-Encoding":`gzip, deflate, br`,"Sec-Ch-Ua":`"Chromium";v="135", "Not(A:Brand";v="24", "Google Chrome";v="135"`,"Sec-Ch-Ua-Mobile":`?0`,"Sec-Ch-Ua-Platform":`"macOS"`,"Sec-Fetch-Dest":`document`,"Sec-Fetch-Mode":`navigate`,"Sec-Fetch-Site":`none`,"Sec-Fetch-User":`?1`,"Upgrade-Insecure-Requests":`1`};async function ze(e,t){return fetch(e,{headers:t?.headers??j,signal:Be(3e4,t?.abortSignal),redirect:t?.redirect??`follow`})}function Be(e,t){let n=AbortSignal.timeout(e);return t?AbortSignal.any([n,t]):n}async function Ve(e,t){let n=e.body?.getReader();if(!n){let n=await e.arrayBuffer();return n.byteLength>t?null:new Uint8Array(n)}let r=[],i=0;try{for(;;){let{done:e,value:a}=await n.read();if(e)break;if(i+=a.byteLength,i>t)return await n.cancel(),null;r.push(a)}}catch(e){if(e instanceof DOMException&&(e.name===`AbortError`||e.name===`TimeoutError`))return null;throw e}let a=new Uint8Array(i),o=0;for(let e of r)a.set(e,o),o+=e.byteLength;return a}function He(e){return e.path.length*2+(e.type===`file`?1:0)}function Ue(e){return[...e].sort((e,t)=>He(t)-He(e))}function We(e){return{cwd:e,scratch:e,paths:[]}}function Ge(e,t){return a(e)?c(e):c(t.cwd,e)}function Ke(e,t){if(e===t)return!0;let n=s(t,e);return n.length===0?!0:!n.startsWith(`..`)&&!a(n)}function qe(e,t){for(let n of Ue(t.paths)){if(n.type===`file`){if(e===n.path)return n;continue}if(Ke(e,n.path))return n}return null}function Je(e){return typeof e==`object`&&!!e&&`code`in e&&(e.code===`ENOENT`||e.code===`ENOTDIR`)}async function Ye(e){try{return await d(e)}catch(t){if(!Je(t))throw t;return e}}async function Xe(e){let[t,n,r]=await Promise.all([Ye(e.cwd),Ye(e.scratch),Promise.all(e.paths.map(async e=>({...e,path:await Ye(e.path)})))]);return{cwd:t,scratch:n,paths:Ue(r)}}async function Ze(e){let t=[],n=e;for(;;)try{let e=await d(n);return t.length===0?e:c(e,...t.reverse())}catch(e){if(!Je(e))throw e;let a=i(n);if(a===n)throw e;t.push(r(n)),n=a}}function M(e,t){if(Ke(e,t.scratch))return`rw`;let n=qe(e,t);if(n)return n.access;throw Error(`Path is outside allowed paths: ${e}`)}function Qe(e,t){if(M(e,t)!==`rw`)throw Error(`Path is read-only: ${e}`)}async function $e(e,t,n){let r=Ge(e,t);n?Qe(r,t):M(r,t);let i=await Ze(r),a=await Xe(t);return n?Qe(i,a):M(i,a),i}async function N(e,t){return $e(e,t,!1)}const P=/^[0-9a-f]{64}$/;function et(e){if(!P.test(e))throw Error(`Invalid docId: expected 64-char lowercase hex string, got "${e.slice(0,80)}"`)}function tt(){return o(fe(),`documents`)}function nt(e){return et(e),o(tt(),e)}async function rt(e){try{let t=await u(o(nt(e),`meta.json`),`utf-8`);return JSON.parse(t)}catch{return null}}async function it(e){let t=nt(e.docId);await l(t,{recursive:!0});let n=o(t,`meta.json`),r=`${n}.${Date.now()}.tmp`;await m(r,JSON.stringify(e,null,2)),await f(r,n)}async function at(e,t){let n=nt(e);await l(n,{recursive:!0}),await m(o(n,`source.pdf`),t)}async function ot(e){try{return await u(o(nt(e),`source.pdf`))}catch{return null}}async function st(e,t){try{let n=await u(o(o(nt(e),`pages`),`${t}.json`),`utf-8`);return JSON.parse(n)}catch{return null}}async function F(e,t){let n=o(nt(e),`pages`);await l(n,{recursive:!0}),await m(o(n,`${t.page}.json`),JSON.stringify(t))}function ct(e){return S(`sha256`).update(e).digest(`hex`)}function lt(){let e=globalThis;if(e.DOMMatrix!==void 0)return;class t{a;b;c;d;e;f;constructor(e){this.a=1,this.b=0,this.c=0,this.d=1,this.e=0,this.f=0,Array.isArray(e)&&e.length===6&&([this.a,this.b,this.c,this.d,this.e,this.f]=e)}get m11(){return this.a}set m11(e){this.a=e}get m12(){return this.b}set m12(e){this.b=e}get m21(){return this.c}set m21(e){this.c=e}get m22(){return this.d}set m22(e){this.d=e}get m41(){return this.e}set m41(e){this.e=e}get m42(){return this.f}set m42(e){this.f=e}get is2D(){return!0}get isIdentity(){return this.a===1&&this.b===0&&this.c===0&&this.d===1&&this.e===0&&this.f===0}multiply(e){return new t([this.a*e.a+this.c*e.b,this.b*e.a+this.d*e.b,this.a*e.c+this.c*e.d,this.b*e.c+this.d*e.d,this.a*e.e+this.c*e.f+this.e,this.b*e.e+this.d*e.f+this.f])}multiplySelf(e){let t=this.multiply(e);return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.e=t.e,this.f=t.f,this}preMultiplySelf(e){let t=e.multiply(this);return this.a=t.a,this.b=t.b,this.c=t.c,this.d=t.d,this.e=t.e,this.f=t.f,this}invertSelf(){let e=this.a*this.d-this.b*this.c;if(e!==0){let t=this.d/e,n=-this.b/e,r=-this.c/e,i=this.a/e,a=(this.c*this.f-this.d*this.e)/e,o=(this.b*this.e-this.a*this.f)/e;this.a=t,this.b=n,this.c=r,this.d=i,this.e=a,this.f=o}return this}translate(e,n){return new t([this.a,this.b,this.c,this.d,this.a*e+this.c*n+this.e,this.b*e+this.d*n+this.f])}scale(e,n=e){return new t([this.a*e,this.b*e,this.c*n,this.d*n,this.e,this.f])}transformPoint(e){return{x:this.a*e.x+this.c*e.y+this.e,y:this.b*e.x+this.d*e.y+this.f,z:0,w:1}}toString(){return`matrix(${this.a}, ${this.b}, ${this.c}, ${this.d}, ${this.e}, ${this.f})`}static fromMatrix(e){return new t([e.a??1,e.b??0,e.c??0,e.d??1,e.e??0,e.f??0])}}e.DOMMatrix=t}async function ut(){return lt(),await import(`pdfjs-dist/legacy/build/pdf.mjs`)}async function I(e){return(await ut()).getDocument({data:e,verbosity:0}).promise}async function dt(e){let t=await e.getOutline();if(!t||t.length===0)return[];let n=[];async function r(t,i){for(let a of t){let t=null;try{if(a.dest){let n=typeof a.dest==`string`?await e.getDestination(a.dest):a.dest;n&&n[0]&&(t=await e.getPageIndex(n[0]))}}catch{}n.push({title:a.title,page:t,depth:i}),a.items?.length&&await r(a.items,i+1)}}await r(t,0);let i=e.numPages-1;return n.map((e,t)=>{let r=i;for(let i=t+1;i<n.length;i++)if(n[i].depth<=e.depth&&n[i].page!==null){r=n[i].page-1;break}return e.page!==null&&r<e.page&&(r=e.page),{title:e.title,pageStart:e.page,pageEnd:r,depth:e.depth}})}function ft(e){if(e.length===0)return``;let t=e[0].str;for(let n=1;n<e.length;n++){let r=e[n-1],i=e[n];if(`hasEOL`in r&&r.hasEOL)t+=`
|
|
4
4
|
`;else if(`transform`in r&&`transform`in i&&`width`in r&&Array.isArray(r.transform)&&Array.isArray(i.transform)&&typeof r.width==`number`){let e=r.transform[4]+r.width,n=i.transform[4],a=Math.abs(i.transform[0]);(Math.abs(r.transform[5]-i.transform[5])>a*.5||n-e>a*.25)&&(t+=` `)}else t+=` `;t+=i.str}return t.trim()}async function pt(e,t,n){let r=[],i=Math.max(1,Math.min(t,e.numPages)),a=Math.max(1,Math.min(n,e.numPages));for(let t=i;t<=a;t++){let n=await e.getPage(t),i=ft((await n.getTextContent()).items.filter(e=>`str`in e&&typeof e.str==`string`));r.push({pageNum:t-1,text:i}),n.cleanup(),t%100==0&&e.cleanup()}return r}function mt(e,t){let n=ht(e),r=new Map;for(let e=0;e<t;e++){let i=null,a=-1;for(let r of n)r.pageStart!==null&&e>=r.pageStart&&e<=(r.pageEnd??t-1)&&r.depth>a&&(a=r.depth,i=r.path);i&&r.set(e,i)}return r}function ht(e){let t=[],n=[];for(let r of e){for(;n.length>r.depth;)n.pop();let e=n.length>0?`${n.join(` > `)} > ${r.title}`:r.title;t.push({path:e,pageStart:r.pageStart,pageEnd:r.pageEnd,depth:r.depth}),n.push(r.title)}return t}function gt(){let e=`s`;for(;e.length<vt+1;){let t=C(16);for(let n=0;n<t.length&&e.length<vt+1;n++){let r=t[n];r!==void 0&&r<yt&&(e+=_t.charAt(r%_t.length))}}return e}const _t=`0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz`,vt=8,yt=248;function bt(e,t){let n=t?.title??xt(t)??`doc-${e.slice(0,8)}`;return{id:gt(),type:`pdf`,title:n,contentKey:e,docId:e,...t?.path!==void 0&&{path:t.path},...t?.url!==void 0&&{url:t.url}}}function xt(e){if(e?.path)return r(e.path);if(e?.url)try{let t=new URL(e.url).pathname.split(`/`).filter(Boolean).pop();if(t)return t}catch{}}async function St(e,t){if(t&&(t.path!==void 0||t.url!==void 0))return bt(e,{...t.path!==void 0&&{path:t.path},...t.url!==void 0&&{url:t.url}});let n=await rt(e);return bt(e,{...n?.sourceUrl&&{url:n.sourceUrl},...n?.filePath&&{path:n.filePath}})}const Ct=100*1024*1024;async function wt(e,t){let n=new URL(e);if(![`http:`,`https:`].includes(n.protocol))throw Error(`Unsupported protocol: ${n.protocol}`);let r=await ze(e,{headers:{...j,Accept:`application/pdf,*/*`},abortSignal:t});if(!r.ok)throw Error(`HTTP ${r.status} ${r.statusText}`);let i=r.headers.get(`content-length`);if(i&&parseInt(i,10)>Ct)throw Error(`PDF exceeds ${Ct/1024/1024}MB size limit`);let a=await Ve(r,Ct);if(a===null)throw Error(`PDF exceeds ${Ct/1024/1024}MB size limit`);return a}async function L(e,t){return St(e,{...t.url!==void 0&&{url:t.url},...t.filePath!==void 0&&{path:t.filePath}})}async function Tt(e,t,n){if(!t.url&&!t.filePath)throw Error(`Either url or filePath is required`);if(t.url&&t.filePath)throw Error(`Provide exactly one of url or filePath`);let r;if(t.url)r=await wt(t.url,n);else{if(!e)throw Error(`resources is required when filePath is provided`);let n=await u(await N(t.filePath,e));if(r=new Uint8Array(n),r.byteLength>Ct)throw Error(`PDF exceeds ${Ct/1024/1024}MB size limit`)}let i=ct(r),a=await rt(i);if(a){let e=!1;return t.url&&!a.sourceUrl&&(a.sourceUrl=t.url,e=!0),t.filePath&&!a.filePath&&(a.filePath=t.filePath,e=!0),e&&await it(a),{docId:a.docId,pageCount:a.pageCount,outline:a.outline.map(e=>({title:e.title,pageStart:e.pageStart,depth:e.depth})),_sources:[await L(a.docId,t)]}}let o=new Uint8Array(r);n?.throwIfAborted();let s=await I(r);try{let e=await dt(s),n=await pt(s,1,s.numPages),r=mt(e,s.numPages),a=n.map(e=>({page:e.pageNum,text:e.text,section:r.get(e.pageNum)??null})),c={docId:i,sourceUrl:t.url??null,filePath:t.filePath??null,pageCount:s.numPages,outline:e,pages:a};return await at(i,o),await it(c),{docId:c.docId,pageCount:c.pageCount,outline:c.outline.map(e=>({title:e.title,pageStart:e.pageStart,depth:e.depth})),_sources:[await L(c.docId,t)]}}finally{s.destroy()}}const Et={name:`open_document`,description:`Open a PDF from a URL or local file path. Extracts text and table of contents. Returns a doc_id for use with grep_document and read_document.`,inputSchema:w.object({url:w.string().url().max(4096).optional().describe(`URL of the PDF to open`),filePath:w.string().max(4096).optional().describe(`Local file path of the PDF to open`)})};function Dt(e){if(!e)return{};let t={"x-posthog-trace-id":e.traceId};return e.sessionId&&(t[`x-posthog-ai-session-id`]=e.sessionId),e.appSessionId&&(t[`x-posthog-session-id`]=e.appSessionId),t}async function Ot(e,t){let n=await I(new Uint8Array(e));try{return await n.extractPages([{document:null,includePages:t}])}finally{await n.destroy()}}function kt(e){let t=e.split(`-`),n=parseInt(t[0],10),r=t.length>1?parseInt(t[1],10):n;if(Number.isNaN(n)||Number.isNaN(r))throw Error(`Invalid page range format: "${e}"`);return{start:n,end:r}}async function At(e,t,n,r){r?.throwIfAborted();let i=await Ot(t,n);return r?.throwIfAborted(),{pages:(await Mt(e,i,n.length===1?`0`:`0-${n.length-1}`,r)).pages.map(e=>({...e,page:n[e.page],blocks:e.blocks.map(e=>({...e,page:n[e.page]}))}))}}async function jt(e,t,n){let r=await rt(t.docId);if(!r)throw Error(`Unknown document: ${t.docId}`);let{start:i,end:a}=kt(t.pageRange);if(i<0||a>=r.pageCount||i>a)throw Error(`Invalid page range "${t.pageRange}" for document with ${r.pageCount} pages (0-indexed)`);let o=Array.from({length:a-i+1},(e,t)=>i+t),s=[],c=[];for(let e of o){n?.throwIfAborted();let r=await st(t.docId,e);r?s.push(r):c.push(e)}if(c.length===0)return{pages:s};let l=await ot(t.docId);if(!l)throw Error(`Cached PDF not found for document ${t.docId}. Re-open the document.`);let u=await At(e,l,c,n);for(let e of u.pages)await F(t.docId,e);return{pages:[...s,...u.pages].sort((e,t)=>e.page-t.page)}}async function Mt(e,t,n,r){let i=new FormData;i.append(`file`,new Blob([t],{type:`application/pdf`}),`document.pdf`),i.append(`pageRange`,n);let a=await e.resolveToken(),o=await fetch(`${e.proxyUrl}/proxy/read_pdf`,{method:`POST`,headers:{authorization:`Bearer ${a}`,...Dt(e.traceContext)},body:i,signal:Be(12e4,r)});if(!o.ok){let e=await o.text().catch(()=>``);throw Error(`Proxy read_pdf failed (${o.status}): ${e.slice(0,500)}`)}return await o.json()}const Nt={name:`read_document`,description:`Extract structured content (tables, formatted text) from specific pages of an opened document. Returns HTML blocks per page. Use open_document first to get a doc_id.`,inputSchema:w.object({docId:w.string().regex(/^[0-9a-f]{64}$/).describe(`Document ID returned by open_document`),pageRange:w.string().max(20).regex(/^\d+(-\d+)?$/).describe(`Page range to read (0-indexed, e.g. '0' for first page, '0-4' for first 5 pages)`)})};var R=O((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),z=O((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.types=void 0,(function(e){e[e.ROOT=0]=`ROOT`,e[e.GROUP=1]=`GROUP`,e[e.POSITION=2]=`POSITION`,e[e.SET=3]=`SET`,e[e.RANGE=4]=`RANGE`,e[e.REPETITION=5]=`REPETITION`,e[e.REFERENCE=6]=`REFERENCE`,e[e.CHAR=7]=`CHAR`})(e.types||={})})),Pt=O((e=>{Object.defineProperty(e,`__esModule`,{value:!0})})),Ft=O((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),n(R(),e),n(z(),e),n(Pt(),e)})),It=O((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.anyChar=e.notWhitespace=e.whitespace=e.notInts=e.ints=e.notWords=e.words=void 0;let t=Ft(),n=()=>[{type:t.types.RANGE,from:48,to:57}],r=()=>[{type:t.types.CHAR,value:95},{type:t.types.RANGE,from:97,to:122},{type:t.types.RANGE,from:65,to:90},{type:t.types.RANGE,from:48,to:57}],i=()=>[{type:t.types.CHAR,value:9},{type:t.types.CHAR,value:10},{type:t.types.CHAR,value:11},{type:t.types.CHAR,value:12},{type:t.types.CHAR,value:13},{type:t.types.CHAR,value:32},{type:t.types.CHAR,value:160},{type:t.types.CHAR,value:5760},{type:t.types.RANGE,from:8192,to:8202},{type:t.types.CHAR,value:8232},{type:t.types.CHAR,value:8233},{type:t.types.CHAR,value:8239},{type:t.types.CHAR,value:8287},{type:t.types.CHAR,value:12288},{type:t.types.CHAR,value:65279}],a=()=>[{type:t.types.CHAR,value:10},{type:t.types.CHAR,value:13},{type:t.types.CHAR,value:8232},{type:t.types.CHAR,value:8233}];e.words=()=>({type:t.types.SET,set:r(),not:!1}),e.notWords=()=>({type:t.types.SET,set:r(),not:!0}),e.ints=()=>({type:t.types.SET,set:n(),not:!1}),e.notInts=()=>({type:t.types.SET,set:n(),not:!0}),e.whitespace=()=>({type:t.types.SET,set:i(),not:!1}),e.notWhitespace=()=>({type:t.types.SET,set:i(),not:!0}),e.anyChar=()=>({type:t.types.SET,set:a(),not:!0})})),Lt=O((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,`__esModule`,{value:!0}),e.tokenizeClass=e.strToChars=void 0;let i=Ft(),a=r(It());e.strToChars=e=>e.replace(/(\[\\b\])|(\\)?\\(?:u([A-F0-9]{4})|x([A-F0-9]{2})|c([@A-Z[\\\]^?])|([0tnvfr]))/g,(e,t,n,r,i,a,o)=>{if(n)return e;let s=t?8:r?parseInt(r,16):i?parseInt(i,16):a?`@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\\]^ ?`.indexOf(a):{0:0,t:9,n:10,v:11,f:12,r:13}[o],c=String.fromCharCode(s);return/[[\]{}^$.|?*+()]/.test(c)?`\\${c}`:c}),e.tokenizeClass=(e,t)=>{let n=[],r,o,s=/\\(?:(w)|(d)|(s)|(W)|(D)|(S))|((?:(?:\\)(.)|([^\]\\]))-(((?:\\)])|(((?:\\)?([^\]])))))|(\])|(?:\\)?([^])/g;for(;(r=s.exec(e))!==null;){let e=(r[1]&&a.words())??(r[2]&&a.ints())??(r[3]&&a.whitespace())??(r[4]&&a.notWords())??(r[5]&&a.notInts())??(r[6]&&a.notWhitespace())??(r[7]&&{type:i.types.RANGE,from:(r[8]||r[9]).charCodeAt(0),to:(o=r[10]).charCodeAt(o.length-1)})??((o=r[16])&&{type:i.types.CHAR,value:o.charCodeAt(0)});if(e)n.push(e);else return[n,s.lastIndex]}throw SyntaxError(`Invalid regular expression: /${t}/: Unterminated character class`)}})),Rt=O((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,`__esModule`,{value:!0}),e.tokenizer=void 0;let i=r(Lt()),a=Ft(),o=r(It()),s=/^[a-zA-Z_$]$/i,c=/^[a-zA-Z0-9_$]$/i,l=/\d/;e.tokenizer=e=>{let t=0,n,r={type:a.types.ROOT,stack:[]},d=r,f=r.stack,p=[],m=[],h=0,g=t=>{throw SyntaxError(`Invalid regular expression: /${e}/: Nothing to repeat at column ${t-1}`)},_=i.strToChars(e);for(;t<_.length;)switch(n=_[t++]){case`\\`:if(t===_.length)throw SyntaxError(`Invalid regular expression: /${e}/: \\ at end of pattern`);switch(n=_[t++]){case`b`:f.push({type:a.types.POSITION,value:`b`});break;case`B`:f.push({type:a.types.POSITION,value:`B`});break;case`w`:f.push(o.words());break;case`W`:f.push(o.notWords());break;case`d`:f.push(o.ints());break;case`D`:f.push(o.notInts());break;case`s`:f.push(o.whitespace());break;case`S`:f.push(o.notWhitespace());break;default:if(l.test(n)){let e=n;for(;t<_.length&&l.test(_[t]);)e+=_[t++];let r=parseInt(e,10),i={type:a.types.REFERENCE,value:r};f.push(i),m.push({reference:i,stack:f,index:f.length-1})}else f.push({type:a.types.CHAR,value:n.charCodeAt(0)})}break;case`^`:f.push({type:a.types.POSITION,value:`^`});break;case`$`:f.push({type:a.types.POSITION,value:`$`});break;case`[`:{let n;_[t]===`^`?(n=!0,t++):n=!1;let r=i.tokenizeClass(_.slice(t),e);t+=r[1],f.push({type:a.types.SET,set:r[0],not:n});break}case`.`:f.push(o.anyChar());break;case`(`:{let r={type:a.types.GROUP,stack:[],remember:!0};if(_[t]===`?`)if(n=_[t+1],t+=2,n===`=`)r.followedBy=!0,r.remember=!1;else if(n===`!`)r.notFollowedBy=!0,r.remember=!1;else if(n===`<`){let n=``;if(s.test(_[t]))n+=_[t],t++;else throw SyntaxError(`Invalid regular expression: /${e}/: Invalid capture group name, character '${_[t]}' after '<' at column ${t+1}`);for(;t<_.length&&c.test(_[t]);)n+=_[t],t++;if(!n)throw SyntaxError(`Invalid regular expression: /${e}/: Invalid capture group name, character '${_[t]}' after '<' at column ${t+1}`);if(_[t]!==`>`)throw SyntaxError(`Invalid regular expression: /${e}/: Unclosed capture group name, expected '>', found '${_[t]}' at column ${t+1}`);r.name=n,t++}else if(n===`:`)r.remember=!1;else throw SyntaxError(`Invalid regular expression: /${e}/: Invalid group, character '${n}' after '?' at column ${t-1}`);else h+=1;f.push(r),p.push(d),d=r,f=r.stack;break}case`)`:if(p.length===0)throw SyntaxError(`Invalid regular expression: /${e}/: Unmatched ) at column ${t-1}`);d=p.pop(),f=d.options?d.options[d.options.length-1]:d.stack;break;case`|`:{d.options||(d.options=[d.stack],delete d.stack);let e=[];d.options.push(e),f=e;break}case`{`:{let e=/^(\d+)(,(\d+)?)?\}/.exec(_.slice(t)),n,r;e===null?f.push({type:a.types.CHAR,value:123}):(f.length===0&&g(t),n=parseInt(e[1],10),r=e[2]?e[3]?parseInt(e[3],10):1/0:n,t+=e[0].length,f.push({type:a.types.REPETITION,min:n,max:r,value:f.pop()}));break}case`?`:f.length===0&&g(t),f.push({type:a.types.REPETITION,min:0,max:1,value:f.pop()});break;case`+`:f.length===0&&g(t),f.push({type:a.types.REPETITION,min:1,max:1/0,value:f.pop()});break;case`*`:f.length===0&&g(t),f.push({type:a.types.REPETITION,min:0,max:1/0,value:f.pop()});break;default:f.push({type:a.types.CHAR,value:n.charCodeAt(0)})}if(p.length!==0)throw SyntaxError(`Invalid regular expression: /${e}/: Unterminated group`);return u(m,h),r};function u(e,t){for(let n of e.reverse())if(t<n.reference.value){n.reference.type=a.types.CHAR;let e=n.reference.value.toString();if(n.reference.value=parseInt(e,8),!/^[0-7]+$/.test(e)){let t=0;for(;e[t]!==`8`&&e[t]!==`9`;)t+=1;if(t===0?(n.reference.value=e.charCodeAt(0),t+=1):n.reference.value=parseInt(e.slice(0,t),8),e.length>t){let r=n.stack.splice(n.index+1);for(let r of e.slice(t))n.stack.push({type:a.types.CHAR,value:r.charCodeAt(0)});n.stack.push(...r)}}}}})),B=O((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,`__esModule`,{value:!0}),e.NOTANYCHAR=e.WHITESPACE=e.WORDS=e.INTS=void 0;let i=r(It()),a=Ft();function o(e){let t={},n=0;for(let r of e)r.type===a.types.CHAR&&(t[r.value]=!0),r.type===a.types.RANGE&&(t[`${r.from}-${r.to}`]=!0),n+=1;return{lookup:()=>Object.assign({},t),len:n}}e.INTS=o(i.ints().set),e.WORDS=o(i.words().set),e.WHITESPACE=o(i.whitespace().set),e.NOTANYCHAR=o(i.anyChar().set)})),zt=O((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__setModuleDefault||(Object.create?(function(e,t){Object.defineProperty(e,`default`,{enumerable:!0,value:t})}):function(e,t){e.default=t}),r=e&&e.__importStar||function(e){if(e&&e.__esModule)return e;var r={};if(e!=null)for(var i in e)i!==`default`&&Object.prototype.hasOwnProperty.call(e,i)&&t(r,e,i);return n(r,e),r};Object.defineProperty(e,`__esModule`,{value:!0}),e.writeSetTokens=e.setChar=void 0;let i=Ft(),a=r(B());function o(e){return e===94?`\\^`:e===92?`\\\\`:e===93?`\\]`:e===45?`\\-`:String.fromCharCode(e)}e.setChar=o;function s(e,{lookup:t,len:n}){if(n!==e.length)return!1;let r=t();for(let t of e){if(t.type===i.types.SET)return!1;let e=t.type===i.types.CHAR?t.value:`${t.from}-${t.to}`;if(r[e])r[e]=!1;else return!1}return!0}function c(e,t=!1){if(s(e.set,a.INTS))return e.not?`\\D`:`\\d`;if(s(e.set,a.WORDS))return e.not?`\\W`:`\\w`;if(e.not&&s(e.set,a.NOTANYCHAR))return`.`;if(s(e.set,a.WHITESPACE))return e.not?`\\S`:`\\s`;let n=``;for(let t=0;t<e.set.length;t++){let r=e.set[t];n+=l(r)}let r=`${e.not?`^`:``}${n}`;return t?r:`[${r}]`}e.writeSetTokens=c;function l(e){return e.type===i.types.CHAR?o(e.value):e.type===i.types.RANGE?`${o(e.from)}-${o(e.to)}`:c(e,!0)}})),Bt=O((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.reconstruct=void 0;let t=Ft(),n=zt(),r=t=>t.map(e.reconstruct).join(``),i=e=>{if(`options`in e)return e.options.map(r).join(`|`);if(`stack`in e)return r(e.stack);throw Error(`options or stack must be Root or Group token`)};e.reconstruct=r=>{switch(r.type){case t.types.ROOT:return i(r);case t.types.CHAR:{let e=String.fromCharCode(r.value);return(/[[\\{}$^.|?*+()]/.test(e)?`\\`:``)+e}case t.types.POSITION:return r.value===`^`||r.value===`$`?r.value:`\\${r.value}`;case t.types.REFERENCE:return`\\${r.value}`;case t.types.SET:return n.writeSetTokens(r);case t.types.GROUP:return`(${r.name?`?<${r.name}>`:r.remember?``:r.followedBy?`?=`:r.notFollowedBy?`?!`:`?:`}${i(r)})`;case t.types.REPETITION:{let{min:t,max:n}=r,i;return i=t===0&&n===1?`?`:t===1&&n===1/0?`+`:t===0&&n===1/0?`*`:n===1/0?`{${t},}`:t===n?`{${t}}`:`{${t},${n}}`,`${e.reconstruct(r.value)}${i}`}case t.types.RANGE:return`${n.setChar(r.from)}-${n.setChar(r.to)}`;default:throw Error(`Invalid token type ${r}`)}}})),Vt=O(((e,t)=>{var n=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n),Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[n]}})}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),r=e&&e.__exportStar||function(e,t){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(t,r)&&n(t,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.types=void 0;let i=Ft();Object.defineProperty(e,`types`,{enumerable:!0,get:function(){return i.types}}),r(Rt(),e),r(Bt(),e);let a=Rt(),o=Bt();r(Ft(),e),e.default=a.tokenizer,t.exports=a.tokenizer,t.exports.types=i.types,t.exports.reconstruct=o.reconstruct})),Ht=ae(O(((e,t)=>{let n=Vt(),{types:r}=Vt();function i(e,t,n){let a,o,s;if(e.type===r.REPETITION&&(n++,t.reps++,n>1||t.reps>t.limit))return!1;if(e.options){for(a=0,s=e.options.length;a<s;a++)if(o=i({stack:e.options[a]},t,n),!o)return!1}let c=e.stack||e.value?.stack;if(!c)return!0;for(a=0,s=c.length;a<s;a++)if(o=i(c[a],t,n),!o)return!1;return!0}function a(e,t){let r={reps:0,limit:t?.limit??25};o(e)?e=e.source:typeof e!=`string`&&(e=String(e));try{return i(n(e),r,0)}catch{return!1}}function o(e){return Object.prototype.toString.call(e)===`[object RegExp]`}t.exports=a,t.exports.default=a,t.exports.safeRegex=a}))(),1);async function Ut(e,t){let n=await rt(e.docId);if(!n)throw Error(`Unknown document: ${e.docId}`);let r=e.pattern.trim();if(!r)return{hits:[],_sources:[await St(e.docId)]};if(r.length>500)throw Error(`Pattern too long (${r.length} chars, max 500)`);let i;try{i=new RegExp(r,`i`)}catch(e){throw Error(`Invalid regex pattern: ${e.message}`)}if(!(0,Ht.default)(i))throw Error(`Regex pattern rejected: potentially vulnerable to ReDoS. Simplify the pattern.`);if(e.pageStart!==void 0&&e.pageEnd!==void 0&&e.pageStart>e.pageEnd)throw Error(`pageEnd (${e.pageEnd}) must be >= pageStart (${e.pageStart})`);let a=e.limit??20,o=[];for(let r of n.pages){if(t?.throwIfAborted(),e.pageStart!==void 0&&r.page<e.pageStart||e.pageEnd!==void 0&&r.page>e.pageEnd)continue;let n=r.text.replace(/\s+/g,` `),s=0;for(;s<n.length;){let e=n.slice(s),t=i.exec(e);if(!t)break;let c=s+t.index,l=t[0].length,u=Math.max(0,c-80),d=Math.min(n.length,c+l+80),f=n.slice(u,d);if(u>0&&(f=`...${f}`),d<n.length&&(f=`${f}...`),o.push({page:r.page,snippet:f,section:r.section}),o.length>=a)break;s=c+Math.max(1,l)}if(o.length>=a)break}return{hits:o,_sources:[await St(e.docId)]}}const Wt={name:`grep_document`,description:`Search within an opened document using a regex pattern. Returns matching pages with snippets and section context. Use open_document first to get a doc_id.`,inputSchema:w.object({docId:w.string().regex(/^[0-9a-f]{64}$/).describe(`Document ID returned by open_document`),pattern:w.string().trim().min(1).max(500).describe(`Regex pattern to search for (case-insensitive)`),pageStart:w.number().int().min(0).optional().describe(`Start page (0-indexed, inclusive)`),pageEnd:w.number().int().min(0).optional().describe(`End page (0-indexed, inclusive)`),limit:w.number().int().min(1).max(100).optional().describe(`Maximum number of results (default 20)`)})};var Gt=O(((e,t)=>{function n(e,t){if(t&&t.documentElement)e=t,t=arguments[2];else if(!e||!e.documentElement)throw Error(`First argument to Readability constructor should be a document object.`);if(t||={},this._doc=e,this._docJSDOMParser=this._doc.firstChild.__JSDOMParser__,this._articleTitle=null,this._articleByline=null,this._articleDir=null,this._articleSiteName=null,this._attempts=[],this._metadata={},this._debug=!!t.debug,this._maxElemsToParse=t.maxElemsToParse||this.DEFAULT_MAX_ELEMS_TO_PARSE,this._nbTopCandidates=t.nbTopCandidates||this.DEFAULT_N_TOP_CANDIDATES,this._charThreshold=t.charThreshold||this.DEFAULT_CHAR_THRESHOLD,this._classesToPreserve=this.CLASSES_TO_PRESERVE.concat(t.classesToPreserve||[]),this._keepClasses=!!t.keepClasses,this._serializer=t.serializer||function(e){return e.innerHTML},this._disableJSONLD=!!t.disableJSONLD,this._allowedVideoRegex=t.allowedVideoRegex||this.REGEXPS.videos,this._linkDensityModifier=t.linkDensityModifier||0,this._flags=this.FLAG_STRIP_UNLIKELYS|this.FLAG_WEIGHT_CLASSES|this.FLAG_CLEAN_CONDITIONALLY,this._debug){let e=function(e){if(e.nodeType==e.TEXT_NODE)return`${e.nodeName} ("${e.textContent}")`;let t=Array.from(e.attributes||[],function(e){return`${e.name}="${e.value}"`}).join(` `);return`<${e.localName} ${t}>`};this.log=function(){if(typeof console<`u`){let t=Array.from(arguments,t=>t&&t.nodeType==this.ELEMENT_NODE?e(t):t);t.unshift(`Reader: (Readability)`),console.log(...t)}else if(typeof dump<`u`){var t=Array.prototype.map.call(arguments,function(t){return t&&t.nodeName?e(t):t}).join(` `);dump(`Reader: (Readability) `+t+`
|
|
5
5
|
`)}}}else this.log=function(){}}n.prototype={FLAG_STRIP_UNLIKELYS:1,FLAG_WEIGHT_CLASSES:2,FLAG_CLEAN_CONDITIONALLY:4,ELEMENT_NODE:1,TEXT_NODE:3,DEFAULT_MAX_ELEMS_TO_PARSE:0,DEFAULT_N_TOP_CANDIDATES:5,DEFAULT_TAGS_TO_SCORE:`SECTION,H2,H3,H4,H5,H6,P,TD,PRE`.split(`,`),DEFAULT_CHAR_THRESHOLD:500,REGEXPS:{unlikelyCandidates:/-ad-|ai2html|banner|breadcrumbs|combx|comment|community|cover-wrap|disqus|extra|footer|gdpr|header|legends|menu|related|remark|replies|rss|shoutbox|sidebar|skyscraper|social|sponsor|supplemental|ad-break|agegate|pagination|pager|popup|yom-remote/i,okMaybeItsACandidate:/and|article|body|column|content|main|shadow/i,positive:/article|body|content|entry|hentry|h-entry|main|page|pagination|post|text|blog|story/i,negative:/-ad-|hidden|^hid$| hid$| hid |^hid |banner|combx|comment|com-|contact|footer|gdpr|masthead|media|meta|outbrain|promo|related|scroll|share|shoutbox|sidebar|skyscraper|sponsor|shopping|tags|widget/i,extraneous:/print|archive|comment|discuss|e[\-]?mail|share|reply|all|login|sign|single|utility/i,byline:/byline|author|dateline|writtenby|p-author/i,replaceFonts:/<(\/?)font[^>]*>/gi,normalize:/\s{2,}/g,videos:/\/\/(www\.)?((dailymotion|youtube|youtube-nocookie|player\.vimeo|v\.qq)\.com|(archive|upload\.wikimedia)\.org|player\.twitch\.tv)/i,shareElements:/(\b|_)(share|sharedaddy)(\b|_)/i,nextLink:/(next|weiter|continue|>([^\|]|$)|»([^\|]|$))/i,prevLink:/(prev|earl|old|new|<|«)/i,tokenize:/\W+/g,whitespace:/^\s*$/,hasContent:/\S$/,hashUrl:/^#.+/,srcsetUrl:/(\S+)(\s+[\d.]+[xw])?(\s*(?:,|$))/g,b64DataUrl:/^data:\s*([^\s;,]+)\s*;\s*base64\s*,/i,commas:/\u002C|\u060C|\uFE50|\uFE10|\uFE11|\u2E41|\u2E34|\u2E32|\uFF0C/g,jsonLdArticleTypes:/^Article|AdvertiserContentArticle|NewsArticle|AnalysisNewsArticle|AskPublicNewsArticle|BackgroundNewsArticle|OpinionNewsArticle|ReportageNewsArticle|ReviewNewsArticle|Report|SatiricalArticle|ScholarlyArticle|MedicalScholarlyArticle|SocialMediaPosting|BlogPosting|LiveBlogPosting|DiscussionForumPosting|TechArticle|APIReference$/,adWords:/^(ad(vertising|vertisement)?|pub(licité)?|werb(ung)?|广告|Реклама|Anuncio)$/iu,loadingWords:/^((loading|正在加载|Загрузка|chargement|cargando)(…|\.\.\.)?)$/iu},UNLIKELY_ROLES:[`menu`,`menubar`,`complementary`,`navigation`,`alert`,`alertdialog`,`dialog`],DIV_TO_P_ELEMS:new Set([`BLOCKQUOTE`,`DL`,`DIV`,`IMG`,`OL`,`P`,`PRE`,`TABLE`,`UL`]),ALTER_TO_DIV_EXCEPTIONS:[`DIV`,`ARTICLE`,`SECTION`,`P`,`OL`,`UL`],PRESENTATIONAL_ATTRIBUTES:[`align`,`background`,`bgcolor`,`border`,`cellpadding`,`cellspacing`,`frame`,`hspace`,`rules`,`style`,`valign`,`vspace`],DEPRECATED_SIZE_ATTRIBUTE_ELEMS:[`TABLE`,`TH`,`TD`,`HR`,`PRE`],PHRASING_ELEMS:`ABBR.AUDIO.B.BDO.BR.BUTTON.CITE.CODE.DATA.DATALIST.DFN.EM.EMBED.I.IMG.INPUT.KBD.LABEL.MARK.MATH.METER.NOSCRIPT.OBJECT.OUTPUT.PROGRESS.Q.RUBY.SAMP.SCRIPT.SELECT.SMALL.SPAN.STRONG.SUB.SUP.TEXTAREA.TIME.VAR.WBR`.split(`.`),CLASSES_TO_PRESERVE:[`page`],HTML_ESCAPE_MAP:{lt:`<`,gt:`>`,amp:`&`,quot:`"`,apos:`'`},_postProcessContent(e){this._fixRelativeUris(e),this._simplifyNestedElements(e),this._keepClasses||this._cleanClasses(e)},_removeNodes(e,t){if(this._docJSDOMParser&&e._isLiveNodeList)throw Error(`Do not pass live node lists to _removeNodes`);for(var n=e.length-1;n>=0;n--){var r=e[n],i=r.parentNode;i&&(!t||t.call(this,r,n,e))&&i.removeChild(r)}},_replaceNodeTags(e,t){if(this._docJSDOMParser&&e._isLiveNodeList)throw Error(`Do not pass live node lists to _replaceNodeTags`);for(let n of e)this._setNodeTag(n,t)},_forEachNode(e,t){Array.prototype.forEach.call(e,t,this)},_findNode(e,t){return Array.prototype.find.call(e,t,this)},_someNode(e,t){return Array.prototype.some.call(e,t,this)},_everyNode(e,t){return Array.prototype.every.call(e,t,this)},_getAllNodesWithTag(e,t){return e.querySelectorAll?e.querySelectorAll(t.join(`,`)):[].concat.apply([],t.map(function(t){var n=e.getElementsByTagName(t);return Array.isArray(n)?n:Array.from(n)}))},_cleanClasses(e){var t=this._classesToPreserve,n=(e.getAttribute(`class`)||``).split(/\s+/).filter(e=>t.includes(e)).join(` `);for(n?e.setAttribute(`class`,n):e.removeAttribute(`class`),e=e.firstElementChild;e;e=e.nextElementSibling)this._cleanClasses(e)},_isUrl(e){try{return new URL(e),!0}catch{return!1}},_fixRelativeUris(e){var t=this._doc.baseURI,n=this._doc.documentURI;function r(e){if(t==n&&e.charAt(0)==`#`)return e;try{return new URL(e,t).href}catch{}return e}var i=this._getAllNodesWithTag(e,[`a`]);this._forEachNode(i,function(e){var t=e.getAttribute(`href`);if(t)if(t.indexOf(`javascript:`)===0)if(e.childNodes.length===1&&e.childNodes[0].nodeType===this.TEXT_NODE){var n=this._doc.createTextNode(e.textContent);e.parentNode.replaceChild(n,e)}else{for(var i=this._doc.createElement(`span`);e.firstChild;)i.appendChild(e.firstChild);e.parentNode.replaceChild(i,e)}else e.setAttribute(`href`,r(t))});var a=this._getAllNodesWithTag(e,[`img`,`picture`,`figure`,`video`,`audio`,`source`]);this._forEachNode(a,function(e){var t=e.getAttribute(`src`),n=e.getAttribute(`poster`),i=e.getAttribute(`srcset`);if(t&&e.setAttribute(`src`,r(t)),n&&e.setAttribute(`poster`,r(n)),i){var a=i.replace(this.REGEXPS.srcsetUrl,function(e,t,n,i){return r(t)+(n||``)+i});e.setAttribute(`srcset`,a)}})},_simplifyNestedElements(e){for(var t=e;t;){if(t.parentNode&&[`DIV`,`SECTION`].includes(t.tagName)&&!(t.id&&t.id.startsWith(`readability`))){if(this._isElementWithoutContent(t)){t=this._removeAndGetNext(t);continue}else if(this._hasSingleTagInsideElement(t,`DIV`)||this._hasSingleTagInsideElement(t,`SECTION`)){for(var n=t.children[0],r=0;r<t.attributes.length;r++)n.setAttributeNode(t.attributes[r].cloneNode());t.parentNode.replaceChild(n,t),t=n;continue}}t=this._getNextNode(t)}},_getArticleTitle(){var e=this._doc,t=``,n=``;try{t=n=e.title.trim(),typeof t!=`string`&&(t=n=this._getInnerText(e.getElementsByTagName(`title`)[0]))}catch{}var r=!1;function i(e){return e.split(/\s+/).length}if(/ [\|\-\\\/>»] /.test(t)){r=/ [\\\/>»] /.test(t);let e=Array.from(n.matchAll(/ [\|\-\\\/>»] /gi));t=n.substring(0,e.pop().index),i(t)<3&&(t=n.replace(/^[^\|\-\\\/>»]*[\|\-\\\/>»]/gi,``))}else if(t.includes(`: `)){var a=this._getAllNodesWithTag(e,[`h1`,`h2`]),o=t.trim();this._someNode(a,function(e){return e.textContent.trim()===o})||(t=n.substring(n.lastIndexOf(`:`)+1),i(t)<3?t=n.substring(n.indexOf(`:`)+1):i(n.substr(0,n.indexOf(`:`)))>5&&(t=n))}else if(t.length>150||t.length<15){var s=e.getElementsByTagName(`h1`);s.length===1&&(t=this._getInnerText(s[0]))}t=t.trim().replace(this.REGEXPS.normalize,` `);var c=i(t);return c<=4&&(!r||c!=i(n.replace(/[\|\-\\\/>»]+/g,``))-1)&&(t=n),t},_prepDocument(){var e=this._doc;this._removeNodes(this._getAllNodesWithTag(e,[`style`])),e.body&&this._replaceBrs(e.body),this._replaceNodeTags(this._getAllNodesWithTag(e,[`font`]),`SPAN`)},_nextNode(e){for(var t=e;t&&t.nodeType!=this.ELEMENT_NODE&&this.REGEXPS.whitespace.test(t.textContent);)t=t.nextSibling;return t},_replaceBrs(e){this._forEachNode(this._getAllNodesWithTag(e,[`br`]),function(e){for(var t=e.nextSibling,n=!1;(t=this._nextNode(t))&&t.tagName==`BR`;){n=!0;var r=t.nextSibling;t.remove(),t=r}if(n){var i=this._doc.createElement(`p`);for(e.parentNode.replaceChild(i,e),t=i.nextSibling;t;){if(t.tagName==`BR`){var a=this._nextNode(t.nextSibling);if(a&&a.tagName==`BR`)break}if(!this._isPhrasingContent(t))break;var o=t.nextSibling;i.appendChild(t),t=o}for(;i.lastChild&&this._isWhitespace(i.lastChild);)i.lastChild.remove();i.parentNode.tagName===`P`&&this._setNodeTag(i.parentNode,`DIV`)}})},_setNodeTag(e,t){if(this.log(`_setNodeTag`,e,t),this._docJSDOMParser)return e.localName=t.toLowerCase(),e.tagName=t.toUpperCase(),e;for(var n=e.ownerDocument.createElement(t);e.firstChild;)n.appendChild(e.firstChild);e.parentNode.replaceChild(n,e),e.readability&&(n.readability=e.readability);for(var r=0;r<e.attributes.length;r++)n.setAttributeNode(e.attributes[r].cloneNode());return n},_prepArticle(e){this._cleanStyles(e),this._markDataTables(e),this._fixLazyImages(e),this._cleanConditionally(e,`form`),this._cleanConditionally(e,`fieldset`),this._clean(e,`object`),this._clean(e,`embed`),this._clean(e,`footer`),this._clean(e,`link`),this._clean(e,`aside`);var t=this.DEFAULT_CHAR_THRESHOLD;this._forEachNode(e.children,function(e){this._cleanMatchedNodes(e,function(e,n){return this.REGEXPS.shareElements.test(n)&&e.textContent.length<t})}),this._clean(e,`iframe`),this._clean(e,`input`),this._clean(e,`textarea`),this._clean(e,`select`),this._clean(e,`button`),this._cleanHeaders(e),this._cleanConditionally(e,`table`),this._cleanConditionally(e,`ul`),this._cleanConditionally(e,`div`),this._replaceNodeTags(this._getAllNodesWithTag(e,[`h1`]),`h2`),this._removeNodes(this._getAllNodesWithTag(e,[`p`]),function(e){return this._getAllNodesWithTag(e,[`img`,`embed`,`object`,`iframe`]).length===0&&!this._getInnerText(e,!1)}),this._forEachNode(this._getAllNodesWithTag(e,[`br`]),function(e){var t=this._nextNode(e.nextSibling);t&&t.tagName==`P`&&e.remove()}),this._forEachNode(this._getAllNodesWithTag(e,[`table`]),function(e){var t=this._hasSingleTagInsideElement(e,`TBODY`)?e.firstElementChild:e;if(this._hasSingleTagInsideElement(t,`TR`)){var n=t.firstElementChild;if(this._hasSingleTagInsideElement(n,`TD`)){var r=n.firstElementChild;r=this._setNodeTag(r,this._everyNode(r.childNodes,this._isPhrasingContent)?`P`:`DIV`),e.parentNode.replaceChild(r,e)}}})},_initializeNode(e){switch(e.readability={contentScore:0},e.tagName){case`DIV`:e.readability.contentScore+=5;break;case`PRE`:case`TD`:case`BLOCKQUOTE`:e.readability.contentScore+=3;break;case`ADDRESS`:case`OL`:case`UL`:case`DL`:case`DD`:case`DT`:case`LI`:case`FORM`:e.readability.contentScore-=3;break;case`H1`:case`H2`:case`H3`:case`H4`:case`H5`:case`H6`:case`TH`:e.readability.contentScore-=5;break}e.readability.contentScore+=this._getClassWeight(e)},_removeAndGetNext(e){var t=this._getNextNode(e,!0);return e.remove(),t},_getNextNode(e,t){if(!t&&e.firstElementChild)return e.firstElementChild;if(e.nextElementSibling)return e.nextElementSibling;do e=e.parentNode;while(e&&!e.nextElementSibling);return e&&e.nextElementSibling},_textSimilarity(e,t){var n=e.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean),r=t.toLowerCase().split(this.REGEXPS.tokenize).filter(Boolean);return!n.length||!r.length?0:1-r.filter(e=>!n.includes(e)).join(` `).length/r.join(` `).length},_isValidByline(e,t){var n=e.getAttribute(`rel`),r=e.getAttribute(`itemprop`),i=e.textContent.trim().length;return(n===`author`||r&&r.includes(`author`)||this.REGEXPS.byline.test(t))&&!!i&&i<100},_getNodeAncestors(e,t){t||=0;for(var n=0,r=[];e.parentNode&&(r.push(e.parentNode),!(t&&++n===t));)e=e.parentNode;return r},_grabArticle(e){this.log(`**** grabArticle ****`);var t=this._doc,n=e!==null;if(e||=this._doc.body,!e)return this.log(`No body found in document. Abort.`),null;for(var r=e.innerHTML;;){this.log(`Starting grabArticle loop`);var i=this._flagIsActive(this.FLAG_STRIP_UNLIKELYS),a=[],o=this._doc.documentElement;let ye=!0;for(;o;){o.tagName===`HTML`&&(this._articleLang=o.getAttribute(`lang`));var s=o.className+` `+o.id;if(!this._isProbablyVisible(o)){this.log(`Removing hidden node - `+s),o=this._removeAndGetNext(o);continue}if(o.getAttribute(`aria-modal`)==`true`&&o.getAttribute(`role`)==`dialog`){o=this._removeAndGetNext(o);continue}if(!this._articleByline&&!this._metadata.byline&&this._isValidByline(o,s)){for(var c=this._getNextNode(o,!0),l=this._getNextNode(o),u=null;l&&l!=c;){var d=l.getAttribute(`itemprop`);if(d&&d.includes(`name`)){u=l;break}else l=this._getNextNode(l)}this._articleByline=(u??o).textContent.trim(),o=this._removeAndGetNext(o);continue}if(ye&&this._headerDuplicatesTitle(o)){this.log(`Removing header: `,o.textContent.trim(),this._articleTitle.trim()),ye=!1,o=this._removeAndGetNext(o);continue}if(i){if(this.REGEXPS.unlikelyCandidates.test(s)&&!this.REGEXPS.okMaybeItsACandidate.test(s)&&!this._hasAncestorTag(o,`table`)&&!this._hasAncestorTag(o,`code`)&&o.tagName!==`BODY`&&o.tagName!==`A`){this.log(`Removing unlikely candidate - `+s),o=this._removeAndGetNext(o);continue}if(this.UNLIKELY_ROLES.includes(o.getAttribute(`role`))){this.log(`Removing content with role `+o.getAttribute(`role`)+` - `+s),o=this._removeAndGetNext(o);continue}}if((o.tagName===`DIV`||o.tagName===`SECTION`||o.tagName===`HEADER`||o.tagName===`H1`||o.tagName===`H2`||o.tagName===`H3`||o.tagName===`H4`||o.tagName===`H5`||o.tagName===`H6`)&&this._isElementWithoutContent(o)){o=this._removeAndGetNext(o);continue}if(this.DEFAULT_TAGS_TO_SCORE.includes(o.tagName)&&a.push(o),o.tagName===`DIV`){for(var f=null,p=o.firstChild;p;){var m=p.nextSibling;if(this._isPhrasingContent(p))f===null?this._isWhitespace(p)||(f=t.createElement(`p`),o.replaceChild(f,p),f.appendChild(p)):f.appendChild(p);else if(f!==null){for(;f.lastChild&&this._isWhitespace(f.lastChild);)f.lastChild.remove();f=null}p=m}if(this._hasSingleTagInsideElement(o,`P`)&&this._getLinkDensity(o)<.25){var h=o.children[0];o.parentNode.replaceChild(h,o),o=h,a.push(o)}else this._hasChildBlockElement(o)||(o=this._setNodeTag(o,`P`),a.push(o))}o=this._getNextNode(o)}var g=[];this._forEachNode(a,function(e){if(!(!e.parentNode||e.parentNode.tagName===void 0)){var t=this._getInnerText(e);if(!(t.length<25)){var n=this._getNodeAncestors(e,5);if(n.length!==0){var r=0;r+=1,r+=t.split(this.REGEXPS.commas).length,r+=Math.min(Math.floor(t.length/100),3),this._forEachNode(n,function(e,t){if(!(!e.tagName||!e.parentNode||e.parentNode.tagName===void 0)){if(e.readability===void 0&&(this._initializeNode(e),g.push(e)),t===0)var n=1;else n=t===1?2:t*3;e.readability.contentScore+=r/n}})}}}});for(var _=[],v=0,y=g.length;v<y;v+=1){var b=g[v],x=b.readability.contentScore*(1-this._getLinkDensity(b));b.readability.contentScore=x,this.log(`Candidate:`,b,`with score `+x);for(var S=0;S<this._nbTopCandidates;S++){var C=_[S];if(!C||x>C.readability.contentScore){_.splice(S,0,b),_.length>this._nbTopCandidates&&_.pop();break}}}var w=_[0]||null,T=!1,E;if(w===null||w.tagName===`BODY`){for(w=t.createElement(`DIV`),T=!0;e.firstChild;)this.log(`Moving child out:`,e.firstChild),w.appendChild(e.firstChild);e.appendChild(w),this._initializeNode(w)}else if(w){for(var ee=[],te=1;te<_.length;te++)_[te].readability.contentScore/w.readability.contentScore>=.75&&ee.push(this._getNodeAncestors(_[te]));var ne=3;if(ee.length>=ne)for(E=w.parentNode;E.tagName!==`BODY`;){for(var D=0,O=0;O<ee.length&&D<ne;O++)D+=Number(ee[O].includes(E));if(D>=ne){w=E;break}E=E.parentNode}w.readability||this._initializeNode(w),E=w.parentNode;for(var re=w.readability.contentScore,ie=re/3;E.tagName!==`BODY`;){if(!E.readability){E=E.parentNode;continue}var ae=E.readability.contentScore;if(ae<ie)break;if(ae>re){w=E;break}re=E.readability.contentScore,E=E.parentNode}for(E=w.parentNode;E.tagName!=`BODY`&&E.children.length==1;)w=E,E=w.parentNode;w.readability||this._initializeNode(w)}var k=t.createElement(`DIV`);n&&(k.id=`readability-content`);var oe=Math.max(10,w.readability.contentScore*.2);E=w.parentNode;for(var se=E.children,ce=0,A=se.length;ce<A;ce++){var le=se[ce],ue=!1;if(this.log(`Looking at sibling node:`,le,le.readability?`with score `+le.readability.contentScore:``),this.log(`Sibling has score`,le.readability?le.readability.contentScore:`Unknown`),le===w)ue=!0;else{var de=0;if(le.className===w.className&&w.className!==``&&(de+=w.readability.contentScore*.2),le.readability&&le.readability.contentScore+de>=oe)ue=!0;else if(le.nodeName===`P`){var fe=this._getLinkDensity(le),pe=this._getInnerText(le),me=pe.length;(me>80&&fe<.25||me<80&&me>0&&fe===0&&pe.search(/\.( |$)/)!==-1)&&(ue=!0)}}ue&&(this.log(`Appending node:`,le),this.ALTER_TO_DIV_EXCEPTIONS.includes(le.nodeName)||(this.log(`Altering sibling:`,le,`to div.`),le=this._setNodeTag(le,`DIV`)),k.appendChild(le),se=E.children,--ce,--A)}if(this._debug&&this.log(`Article content pre-prep: `+k.innerHTML),this._prepArticle(k),this._debug&&this.log(`Article content post-prep: `+k.innerHTML),T)w.id=`readability-page-1`,w.className=`page`;else{var he=t.createElement(`DIV`);for(he.id=`readability-page-1`,he.className=`page`;k.firstChild;)he.appendChild(k.firstChild);k.appendChild(he)}this._debug&&this.log(`Article content after paging: `+k.innerHTML);var ge=!0,_e=this._getInnerText(k,!0).length;if(_e<this._charThreshold)if(ge=!1,e.innerHTML=r,this._attempts.push({articleContent:k,textLength:_e}),this._flagIsActive(this.FLAG_STRIP_UNLIKELYS))this._removeFlag(this.FLAG_STRIP_UNLIKELYS);else if(this._flagIsActive(this.FLAG_WEIGHT_CLASSES))this._removeFlag(this.FLAG_WEIGHT_CLASSES);else if(this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY))this._removeFlag(this.FLAG_CLEAN_CONDITIONALLY);else{if(this._attempts.sort(function(e,t){return t.textLength-e.textLength}),!this._attempts[0].textLength)return null;k=this._attempts[0].articleContent,ge=!0}if(ge){var ve=[E,w].concat(this._getNodeAncestors(E));return this._someNode(ve,function(e){if(!e.tagName)return!1;var t=e.getAttribute(`dir`);return t?(this._articleDir=t,!0):!1}),k}}},_unescapeHtmlEntities(e){if(!e)return e;var t=this.HTML_ESCAPE_MAP;return e.replace(/&(quot|amp|apos|lt|gt);/g,function(e,n){return t[n]}).replace(/&#(?:x([0-9a-f]+)|([0-9]+));/gi,function(e,t,n){var r=parseInt(t||n,t?16:10);return(r==0||r>1114111||r>=55296&&r<=57343)&&(r=65533),String.fromCodePoint(r)})},_getJSONLD(e){var t=this._getAllNodesWithTag(e,[`script`]),n;return this._forEachNode(t,function(e){if(!n&&e.getAttribute(`type`)===`application/ld+json`)try{var t=e.textContent.replace(/^\s*<!\[CDATA\[|\]\]>\s*$/g,``),r=JSON.parse(t);if(Array.isArray(r)&&(r=r.find(e=>e[`@type`]&&e[`@type`].match(this.REGEXPS.jsonLdArticleTypes)),!r))return;var i=/^https?\:\/\/schema\.org\/?$/;if(!(typeof r[`@context`]==`string`&&r[`@context`].match(i)||typeof r[`@context`]==`object`&&typeof r[`@context`][`@vocab`]==`string`&&r[`@context`][`@vocab`].match(i))||(!r[`@type`]&&Array.isArray(r[`@graph`])&&(r=r[`@graph`].find(e=>(e[`@type`]||``).match(this.REGEXPS.jsonLdArticleTypes))),!r||!r[`@type`]||!r[`@type`].match(this.REGEXPS.jsonLdArticleTypes)))return;if(n={},typeof r.name==`string`&&typeof r.headline==`string`&&r.name!==r.headline){var a=this._getArticleTitle(),o=this._textSimilarity(r.name,a)>.75;this._textSimilarity(r.headline,a)>.75&&!o?n.title=r.headline:n.title=r.name}else typeof r.name==`string`?n.title=r.name.trim():typeof r.headline==`string`&&(n.title=r.headline.trim());r.author&&(typeof r.author.name==`string`?n.byline=r.author.name.trim():Array.isArray(r.author)&&r.author[0]&&typeof r.author[0].name==`string`&&(n.byline=r.author.filter(function(e){return e&&typeof e.name==`string`}).map(function(e){return e.name.trim()}).join(`, `))),typeof r.description==`string`&&(n.excerpt=r.description.trim()),r.publisher&&typeof r.publisher.name==`string`&&(n.siteName=r.publisher.name.trim()),typeof r.datePublished==`string`&&(n.datePublished=r.datePublished.trim())}catch(e){this.log(e.message)}}),n||{}},_getArticleMetadata(e){var t={},n={},r=this._doc.getElementsByTagName(`meta`),i=/\s*(article|dc|dcterm|og|twitter)\s*:\s*(author|creator|description|published_time|title|site_name)\s*/gi,a=/^\s*(?:(dc|dcterm|og|twitter|parsely|weibo:(article|webpage))\s*[-\.:]\s*)?(author|creator|pub-date|description|title|site_name)\s*$/i;this._forEachNode(r,function(e){var t=e.getAttribute(`name`),r=e.getAttribute(`property`),o=e.getAttribute(`content`);if(o){var s=null,c=null;r&&(s=r.match(i),s&&(c=s[0].toLowerCase().replace(/\s/g,``),n[c]=o.trim())),!s&&t&&a.test(t)&&(c=t,o&&(c=c.toLowerCase().replace(/\s/g,``).replace(/\./g,`:`),n[c]=o.trim()))}}),t.title=e.title||n[`dc:title`]||n[`dcterm:title`]||n[`og:title`]||n[`weibo:article:title`]||n[`weibo:webpage:title`]||n.title||n[`twitter:title`]||n[`parsely-title`],t.title||=this._getArticleTitle();let o=typeof n[`article:author`]==`string`&&!this._isUrl(n[`article:author`])?n[`article:author`]:void 0;return t.byline=e.byline||n[`dc:creator`]||n[`dcterm:creator`]||n.author||n[`parsely-author`]||o,t.excerpt=e.excerpt||n[`dc:description`]||n[`dcterm:description`]||n[`og:description`]||n[`weibo:article:description`]||n[`weibo:webpage:description`]||n.description||n[`twitter:description`],t.siteName=e.siteName||n[`og:site_name`],t.publishedTime=e.datePublished||n[`article:published_time`]||n[`parsely-pub-date`]||null,t.title=this._unescapeHtmlEntities(t.title),t.byline=this._unescapeHtmlEntities(t.byline),t.excerpt=this._unescapeHtmlEntities(t.excerpt),t.siteName=this._unescapeHtmlEntities(t.siteName),t.publishedTime=this._unescapeHtmlEntities(t.publishedTime),t},_isSingleImage(e){for(;e;){if(e.tagName===`IMG`)return!0;if(e.children.length!==1||e.textContent.trim()!==``)return!1;e=e.children[0]}return!1},_unwrapNoscriptImages(e){var t=Array.from(e.getElementsByTagName(`img`));this._forEachNode(t,function(e){for(var t=0;t<e.attributes.length;t++){var n=e.attributes[t];switch(n.name){case`src`:case`srcset`:case`data-src`:case`data-srcset`:return}if(/\.(jpg|jpeg|png|webp)/i.test(n.value))return}e.remove()});var n=Array.from(e.getElementsByTagName(`noscript`));this._forEachNode(n,function(t){if(this._isSingleImage(t)){var n=e.createElement(`div`);n.innerHTML=t.innerHTML;var r=t.previousElementSibling;if(r&&this._isSingleImage(r)){var i=r;i.tagName!==`IMG`&&(i=r.getElementsByTagName(`img`)[0]);for(var a=n.getElementsByTagName(`img`)[0],o=0;o<i.attributes.length;o++){var s=i.attributes[o];if(s.value!==``&&(s.name===`src`||s.name===`srcset`||/\.(jpg|jpeg|png|webp)/i.test(s.value))){if(a.getAttribute(s.name)===s.value)continue;var c=s.name;a.hasAttribute(c)&&(c=`data-old-`+c),a.setAttribute(c,s.value)}}t.parentNode.replaceChild(n.firstElementChild,r)}}})},_removeScripts(e){this._removeNodes(this._getAllNodesWithTag(e,[`script`,`noscript`]))},_hasSingleTagInsideElement(e,t){return e.children.length!=1||e.children[0].tagName!==t?!1:!this._someNode(e.childNodes,function(e){return e.nodeType===this.TEXT_NODE&&this.REGEXPS.hasContent.test(e.textContent)})},_isElementWithoutContent(e){return e.nodeType===this.ELEMENT_NODE&&!e.textContent.trim().length&&(!e.children.length||e.children.length==e.getElementsByTagName(`br`).length+e.getElementsByTagName(`hr`).length)},_hasChildBlockElement(e){return this._someNode(e.childNodes,function(e){return this.DIV_TO_P_ELEMS.has(e.tagName)||this._hasChildBlockElement(e)})},_isPhrasingContent(e){return e.nodeType===this.TEXT_NODE||this.PHRASING_ELEMS.includes(e.tagName)||(e.tagName===`A`||e.tagName===`DEL`||e.tagName===`INS`)&&this._everyNode(e.childNodes,this._isPhrasingContent)},_isWhitespace(e){return e.nodeType===this.TEXT_NODE&&e.textContent.trim().length===0||e.nodeType===this.ELEMENT_NODE&&e.tagName===`BR`},_getInnerText(e,t){t=t===void 0?!0:t;var n=e.textContent.trim();return t?n.replace(this.REGEXPS.normalize,` `):n},_getCharCount(e,t){return t||=`,`,this._getInnerText(e).split(t).length-1},_cleanStyles(e){if(!(!e||e.tagName.toLowerCase()===`svg`)){for(var t=0;t<this.PRESENTATIONAL_ATTRIBUTES.length;t++)e.removeAttribute(this.PRESENTATIONAL_ATTRIBUTES[t]);this.DEPRECATED_SIZE_ATTRIBUTE_ELEMS.includes(e.tagName)&&(e.removeAttribute(`width`),e.removeAttribute(`height`));for(var n=e.firstElementChild;n!==null;)this._cleanStyles(n),n=n.nextElementSibling}},_getLinkDensity(e){var t=this._getInnerText(e).length;if(t===0)return 0;var n=0;return this._forEachNode(e.getElementsByTagName(`a`),function(e){var t=e.getAttribute(`href`),r=t&&this.REGEXPS.hashUrl.test(t)?.3:1;n+=this._getInnerText(e).length*r}),n/t},_getClassWeight(e){if(!this._flagIsActive(this.FLAG_WEIGHT_CLASSES))return 0;var t=0;return typeof e.className==`string`&&e.className!==``&&(this.REGEXPS.negative.test(e.className)&&(t-=25),this.REGEXPS.positive.test(e.className)&&(t+=25)),typeof e.id==`string`&&e.id!==``&&(this.REGEXPS.negative.test(e.id)&&(t-=25),this.REGEXPS.positive.test(e.id)&&(t+=25)),t},_clean(e,t){var n=[`object`,`embed`,`iframe`].includes(t);this._removeNodes(this._getAllNodesWithTag(e,[t]),function(e){if(n){for(var t=0;t<e.attributes.length;t++)if(this._allowedVideoRegex.test(e.attributes[t].value))return!1;if(e.tagName===`object`&&this._allowedVideoRegex.test(e.innerHTML))return!1}return!0})},_hasAncestorTag(e,t,n,r){n||=3,t=t.toUpperCase();for(var i=0;e.parentNode;){if(n>0&&i>n)return!1;if(e.parentNode.tagName===t&&(!r||r(e.parentNode)))return!0;e=e.parentNode,i++}return!1},_getRowAndColumnCount(e){for(var t=0,n=0,r=e.getElementsByTagName(`tr`),i=0;i<r.length;i++){var a=r[i].getAttribute(`rowspan`)||0;a&&=parseInt(a,10),t+=a||1;for(var o=0,s=r[i].getElementsByTagName(`td`),c=0;c<s.length;c++){var l=s[c].getAttribute(`colspan`)||0;l&&=parseInt(l,10),o+=l||1}n=Math.max(n,o)}return{rows:t,columns:n}},_markDataTables(e){for(var t=e.getElementsByTagName(`table`),n=0;n<t.length;n++){var r=t[n];if(r.getAttribute(`role`)==`presentation`){r._readabilityDataTable=!1;continue}if(r.getAttribute(`datatable`)==`0`){r._readabilityDataTable=!1;continue}if(r.getAttribute(`summary`)){r._readabilityDataTable=!0;continue}var i=r.getElementsByTagName(`caption`)[0];if(i&&i.childNodes.length){r._readabilityDataTable=!0;continue}if([`col`,`colgroup`,`tfoot`,`thead`,`th`].some(function(e){return!!r.getElementsByTagName(e)[0]})){this.log(`Data table because found data-y descendant`),r._readabilityDataTable=!0;continue}if(r.getElementsByTagName(`table`)[0]){r._readabilityDataTable=!1;continue}var a=this._getRowAndColumnCount(r);if(a.columns==1||a.rows==1){r._readabilityDataTable=!1;continue}if(a.rows>=10||a.columns>4){r._readabilityDataTable=!0;continue}r._readabilityDataTable=a.rows*a.columns>10}},_fixLazyImages(e){this._forEachNode(this._getAllNodesWithTag(e,[`img`,`picture`,`figure`]),function(e){if(e.src&&this.REGEXPS.b64DataUrl.test(e.src)){var t=this.REGEXPS.b64DataUrl.exec(e.src);if(t[1]===`image/svg+xml`)return;for(var n=!1,r=0;r<e.attributes.length;r++){var i=e.attributes[r];if(i.name!==`src`&&/\.(jpg|jpeg|png|webp)/i.test(i.value)){n=!0;break}}if(n){var a=t[0].length;e.src.length-a<133&&e.removeAttribute(`src`)}}if(!((e.src||e.srcset&&e.srcset!=`null`)&&!e.className.toLowerCase().includes(`lazy`))){for(var o=0;o<e.attributes.length;o++)if(i=e.attributes[o],!(i.name===`src`||i.name===`srcset`||i.name===`alt`)){var s=null;if(/\.(jpg|jpeg|png|webp)\s+\d/.test(i.value)?s=`srcset`:/^\s*\S+\.(jpg|jpeg|png|webp)\S*\s*$/.test(i.value)&&(s=`src`),s){if(e.tagName===`IMG`||e.tagName===`PICTURE`)e.setAttribute(s,i.value);else if(e.tagName===`FIGURE`&&!this._getAllNodesWithTag(e,[`img`,`picture`]).length){var c=this._doc.createElement(`img`);c.setAttribute(s,i.value),e.appendChild(c)}}}}})},_getTextDensity(e,t){var n=this._getInnerText(e,!0).length;if(n===0)return 0;var r=0,i=this._getAllNodesWithTag(e,t);return this._forEachNode(i,e=>r+=this._getInnerText(e,!0).length),r/n},_cleanConditionally(e,t){this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY)&&this._removeNodes(this._getAllNodesWithTag(e,[t]),function(e){var n=function(e){return e._readabilityDataTable},r=t===`ul`||t===`ol`;if(!r){var i=0,a=this._getAllNodesWithTag(e,[`ul`,`ol`]);this._forEachNode(a,e=>i+=this._getInnerText(e).length),r=i/this._getInnerText(e).length>.9}if(t===`table`&&n(e)||this._hasAncestorTag(e,`table`,-1,n)||this._hasAncestorTag(e,`code`)||[...e.getElementsByTagName(`table`)].some(e=>e._readabilityDataTable))return!1;var o=this._getClassWeight(e);if(this.log(`Cleaning Conditionally`,e),o+0<0)return!0;if(this._getCharCount(e,`,`)<10){for(var s=e.getElementsByTagName(`p`).length,c=e.getElementsByTagName(`img`).length,l=e.getElementsByTagName(`li`).length-100,u=e.getElementsByTagName(`input`).length,d=this._getTextDensity(e,[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`]),f=0,p=this._getAllNodesWithTag(e,[`object`,`embed`,`iframe`]),m=0;m<p.length;m++){for(var h=0;h<p[m].attributes.length;h++)if(this._allowedVideoRegex.test(p[m].attributes[h].value))return!1;if(p[m].tagName===`object`&&this._allowedVideoRegex.test(p[m].innerHTML))return!1;f++}var g=this._getInnerText(e);if(this.REGEXPS.adWords.test(g)||this.REGEXPS.loadingWords.test(g))return!0;var _=g.length,v=this._getLinkDensity(e),y=[`SPAN`,`LI`,`TD`].concat(Array.from(this.DIV_TO_P_ELEMS)),b=this._getTextDensity(e,y),x=this._hasAncestorTag(e,`figure`),S=(()=>{let e=[];return!x&&c>1&&s/c<.5&&e.push(`Bad p to img ratio (img=${c}, p=${s})`),!r&&l>s&&e.push(`Too many li's outside of a list. (li=${l} > p=${s})`),u>Math.floor(s/3)&&e.push(`Too many inputs per p. (input=${u}, p=${s})`),!r&&!x&&d<.9&&_<25&&(c===0||c>2)&&v>0&&e.push(`Suspiciously short. (headingDensity=${d}, img=${c}, linkDensity=${v})`),!r&&o<25&&v>.2+this._linkDensityModifier&&e.push(`Low weight and a little linky. (linkDensity=${v})`),o>=25&&v>.5+this._linkDensityModifier&&e.push(`High weight and mostly links. (linkDensity=${v})`),(f===1&&_<75||f>1)&&e.push(`Suspicious embed. (embedCount=${f}, contentLength=${_})`),c===0&&b===0&&e.push(`No useful content. (img=${c}, textDensity=${b})`),e.length?(this.log(`Checks failed`,e),!0):!1})();if(r&&S){for(var C=0;C<e.children.length;C++)if(e.children[C].children.length>1)return S;if(c==e.getElementsByTagName(`li`).length)return!1}return S}return!1})},_cleanMatchedNodes(e,t){for(var n=this._getNextNode(e,!0),r=this._getNextNode(e);r&&r!=n;)r=t.call(this,r,r.className+` `+r.id)?this._removeAndGetNext(r):this._getNextNode(r)},_cleanHeaders(e){let t=this._getAllNodesWithTag(e,[`h1`,`h2`]);this._removeNodes(t,function(e){let t=this._getClassWeight(e)<0;return t&&this.log(`Removing header with low class weight:`,e),t})},_headerDuplicatesTitle(e){if(e.tagName!=`H1`&&e.tagName!=`H2`)return!1;var t=this._getInnerText(e,!1);return this.log(`Evaluating similarity of header:`,t,this._articleTitle),this._textSimilarity(this._articleTitle,t)>.75},_flagIsActive(e){return(this._flags&e)>0},_removeFlag(e){this._flags&=~e},_isProbablyVisible(e){return(!e.style||e.style.display!=`none`)&&(!e.style||e.style.visibility!=`hidden`)&&!e.hasAttribute(`hidden`)&&(!e.hasAttribute(`aria-hidden`)||e.getAttribute(`aria-hidden`)!=`true`||e.className&&e.className.includes&&e.className.includes(`fallback-image`))},parse(){if(this._maxElemsToParse>0){var e=this._doc.getElementsByTagName(`*`).length;if(e>this._maxElemsToParse)throw Error(`Aborting parsing document; `+e+` elements found`)}this._unwrapNoscriptImages(this._doc);var t=this._disableJSONLD?{}:this._getJSONLD(this._doc);this._removeScripts(this._doc),this._prepDocument();var n=this._getArticleMetadata(t);this._metadata=n,this._articleTitle=n.title;var r=this._grabArticle();if(!r)return null;if(this.log(`Grabbed: `+r.innerHTML),this._postProcessContent(r),!n.excerpt){var i=r.getElementsByTagName(`p`);i.length&&(n.excerpt=i[0].textContent.trim())}var a=r.textContent;return{title:this._articleTitle,byline:n.byline||this._articleByline,dir:this._articleDir,lang:this._articleLang,content:this._serializer(r),textContent:a,length:a.length,excerpt:n.excerpt,siteName:n.siteName||this._articleSiteName,publishedTime:n.publishedTime}}},typeof t==`object`&&(t.exports=n)})),Kt=O(((e,t)=>{var n={unlikelyCandidates:/-ad-|ai2html|banner|breadcrumbs|combx|comment|community|cover-wrap|disqus|extra|footer|gdpr|header|legends|menu|related|remark|replies|rss|shoutbox|sidebar|skyscraper|social|sponsor|supplemental|ad-break|agegate|pagination|pager|popup|yom-remote/i,okMaybeItsACandidate:/and|article|body|column|content|main|shadow/i};function r(e){return(!e.style||e.style.display!=`none`)&&!e.hasAttribute(`hidden`)&&(!e.hasAttribute(`aria-hidden`)||e.getAttribute(`aria-hidden`)!=`true`||e.className&&e.className.includes&&e.className.includes(`fallback-image`))}function i(e,t={}){typeof t==`function`&&(t={visibilityChecker:t}),t=Object.assign({minScore:20,minContentLength:140,visibilityChecker:r},t);var i=e.querySelectorAll(`p, pre, article`),a=e.querySelectorAll(`div > br`);if(a.length){var o=new Set(i);[].forEach.call(a,function(e){o.add(e.parentNode)}),i=Array.from(o)}var s=0;return[].some.call(i,function(e){if(!t.visibilityChecker(e))return!1;var r=e.className+` `+e.id;if(n.unlikelyCandidates.test(r)&&!n.okMaybeItsACandidate.test(r)||e.matches(`li p`))return!1;var i=e.textContent.trim().length;return i<t.minContentLength?!1:(s+=Math.sqrt(i-t.minContentLength),s>t.minScore)})}typeof t==`object`&&(t.exports=i)}));O(((e,t)=>{t.exports={Readability:Gt(),isProbablyReaderable:Kt()}}))();const qt=Symbol(`changed`),Jt=Symbol(`classList`),Yt=Symbol(`CustomElements`),Xt=Symbol(`content`),Zt=Symbol(`dataset`),V=Symbol(`doctype`),H=Symbol(`DOMParser`),U=Symbol(`end`),Qt=Symbol(`EventTarget`),$t=Symbol(`globals`),en=Symbol(`image`),tn=Symbol(`mime`),nn=Symbol(`MutationObserver`),W=Symbol(`next`),rn=Symbol(`ownerElement`),an=Symbol(`prev`),on=Symbol(`private`),sn=Symbol(`sheet`),cn=Symbol(`start`),ln=Symbol(`style`),un=Symbol(`upgrade`),dn=Symbol(`value`),fn=new Map([[0,65533],[128,8364],[130,8218],[131,402],[132,8222],[133,8230],[134,8224],[135,8225],[136,710],[137,8240],[138,352],[139,8249],[140,338],[142,381],[145,8216],[146,8217],[147,8220],[148,8221],[149,8226],[150,8211],[151,8212],[152,732],[153,8482],[154,353],[155,8250],[156,339],[158,382],[159,376]]),pn=String.fromCodePoint??(e=>{let t=``;return e>65535&&(e-=65536,t+=String.fromCharCode(e>>>10&1023|55296),e=56320|e&1023),t+=String.fromCharCode(e),t});function mn(e){return e>=55296&&e<=57343||e>1114111?65533:fn.get(e)??e}function hn(e){let t=typeof atob==`function`?atob(e):typeof Buffer.from==`function`?Buffer.from(e,`base64`).toString(`binary`):new Buffer(e,`base64`).toString(`binary`),n=t.length&-2,r=new Uint16Array(n/2);for(let e=0,i=0;e<n;e+=2){let n=t.charCodeAt(e),a=t.charCodeAt(e+1);r[i++]=n|a<<8}return r}const gn=hn(`QR08ALkAAgH6AYsDNQR2BO0EPgXZBQEGLAbdBxMISQrvCmQLfQurDKQNLw4fD4YPpA+6D/IPAAAAAAAAAAAAAAAAKhBMEY8TmxUWF2EYLBkxGuAa3RsJHDscWR8YIC8jSCSIJc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JhAHQA6ABqD2MAcgAA4DXYzNzjCuQRUC4AAFQuAABYLmIuAAAAAGMubS5wLnQuAAAAAIguki4AAJouJxIqEnQAcgDpAB0ScgAA4DXYNd0AAUFhWy5eLnIA8gDnAnIA8gCTB75jAAFBYWYuaS5yAPIA4AJyAPIAjAdhAPAAeh5pAHMAAKD7IoABZHB0APgReS6DLgABZmx9LoAuAOA12GnddQDzAP8RaQBtAOUABBIAAUFhiy6OLnIA8gDuAnIA8gCaBwABY3GVLgoScgAA4DXYzdwAAXB0nS6hLmwAdQDzACUScgDpACASAARhY2VmaW9zdbEuvC7ELsguzC7PLtQu2S5jAAABdXm2LrsudABlADuA/QD9QE9kAAFpecAuwy5yAGMAd2FLZG4AO4ClAKVAcgAA4DXYNt1jAHkAV2RwAGYAAOA12GrdYwByAADgNdjO3AABY23dLt8ueQBOZGwAO4D/AP9AAAVhY2RlZmhpb3N38y73Lv8uAi8MLxAvEy8YLx0vIi9jInV0ZQB6YQABYXn7Lv4u8iFvbn5hN2RvAHQAfGEAAWV0Bi8KL3QAcgDmAB8QYQC2Y3IAAOA12DfdYwB5ADZk5yJyYXJyAKDdIXAAZgAA4DXYa91jAHIAAOA12M/cAAFqbiYvKC8AoA0gagAAoAwg`),_n=hn(`AAJhZ2xxBwARABMAFQBtAg0AAAAAAA8AcAAmYG8AcwAnYHQAPmB0ADxg9SFvdCJg`);var vn;(function(e){e[e.VALUE_LENGTH=49152]=`VALUE_LENGTH`,e[e.FLAG13=8192]=`FLAG13`,e[e.BRANCH_LENGTH=8064]=`BRANCH_LENGTH`,e[e.JUMP_TABLE=127]=`JUMP_TABLE`})(vn||={});var yn;(function(e){e[e.NUM=35]=`NUM`,e[e.SEMI=59]=`SEMI`,e[e.EQUALS=61]=`EQUALS`,e[e.ZERO=48]=`ZERO`,e[e.NINE=57]=`NINE`,e[e.LOWER_A=97]=`LOWER_A`,e[e.LOWER_F=102]=`LOWER_F`,e[e.LOWER_X=120]=`LOWER_X`,e[e.LOWER_Z=122]=`LOWER_Z`,e[e.UPPER_A=65]=`UPPER_A`,e[e.UPPER_F=70]=`UPPER_F`,e[e.UPPER_Z=90]=`UPPER_Z`})(yn||={});function bn(e){return e>=yn.ZERO&&e<=yn.NINE}function xn(e){return e>=yn.UPPER_A&&e<=yn.UPPER_F||e>=yn.LOWER_A&&e<=yn.LOWER_F}function Sn(e){return e>=yn.UPPER_A&&e<=yn.UPPER_Z||e>=yn.LOWER_A&&e<=yn.LOWER_Z||bn(e)}function Cn(e){return e===yn.EQUALS||Sn(e)}var wn;(function(e){e[e.EntityStart=0]=`EntityStart`,e[e.NumericStart=1]=`NumericStart`,e[e.NumericDecimal=2]=`NumericDecimal`,e[e.NumericHex=3]=`NumericHex`,e[e.NamedEntity=4]=`NamedEntity`})(wn||={});var Tn;(function(e){e[e.Legacy=0]=`Legacy`,e[e.Strict=1]=`Strict`,e[e.Attribute=2]=`Attribute`})(Tn||={});var En=class{constructor(e,t,n){this.decodeTree=e,this.emitCodePoint=t,this.errors=n,this.state=wn.EntityStart,this.consumed=1,this.result=0,this.treeIndex=0,this.excess=1,this.decodeMode=Tn.Strict,this.runConsumed=0}startEntity(e){this.decodeMode=e,this.state=wn.EntityStart,this.result=0,this.treeIndex=0,this.excess=1,this.consumed=1,this.runConsumed=0}write(e,t){switch(this.state){case wn.EntityStart:return e.charCodeAt(t)===yn.NUM?(this.state=wn.NumericStart,this.consumed+=1,this.stateNumericStart(e,t+1)):(this.state=wn.NamedEntity,this.stateNamedEntity(e,t));case wn.NumericStart:return this.stateNumericStart(e,t);case wn.NumericDecimal:return this.stateNumericDecimal(e,t);case wn.NumericHex:return this.stateNumericHex(e,t);case wn.NamedEntity:return this.stateNamedEntity(e,t)}}stateNumericStart(e,t){return t>=e.length?-1:(e.charCodeAt(t)|32)===yn.LOWER_X?(this.state=wn.NumericHex,this.consumed+=1,this.stateNumericHex(e,t+1)):(this.state=wn.NumericDecimal,this.stateNumericDecimal(e,t))}stateNumericHex(e,t){for(;t<e.length;){let n=e.charCodeAt(t);if(bn(n)||xn(n)){let e=n<=yn.NINE?n-yn.ZERO:(n|32)-yn.LOWER_A+10;this.result=this.result*16+e,this.consumed++,t++}else return this.emitNumericEntity(n,3)}return-1}stateNumericDecimal(e,t){for(;t<e.length;){let n=e.charCodeAt(t);if(bn(n))this.result=this.result*10+(n-yn.ZERO),this.consumed++,t++;else return this.emitNumericEntity(n,2)}return-1}emitNumericEntity(e,t){var n;if(this.consumed<=t)return(n=this.errors)==null||n.absenceOfDigitsInNumericCharacterReference(this.consumed),0;if(e===yn.SEMI)this.consumed+=1;else if(this.decodeMode===Tn.Strict)return 0;return this.emitCodePoint(mn(this.result),this.consumed),this.errors&&(e!==yn.SEMI&&this.errors.missingSemicolonAfterCharacterReference(),this.errors.validateNumericCharacterReference(this.result)),this.consumed}stateNamedEntity(e,t){let{decodeTree:n}=this,r=n[this.treeIndex],i=(r&vn.VALUE_LENGTH)>>14;for(;t<e.length;){if(i===0&&(r&vn.FLAG13)!==0){let a=(r&vn.BRANCH_LENGTH)>>7;if(this.runConsumed===0){let n=r&vn.JUMP_TABLE;if(e.charCodeAt(t)!==n)return this.result===0?0:this.emitNotTerminatedNamedEntity();t++,this.excess++,this.runConsumed++}for(;this.runConsumed<a;){if(t>=e.length)return-1;let r=this.runConsumed-1,i=n[this.treeIndex+1+(r>>1)],a=r%2==0?i&255:i>>8&255;if(e.charCodeAt(t)!==a)return this.runConsumed=0,this.result===0?0:this.emitNotTerminatedNamedEntity();t++,this.excess++,this.runConsumed++}this.runConsumed=0,this.treeIndex+=1+(a>>1),r=n[this.treeIndex],i=(r&vn.VALUE_LENGTH)>>14}if(t>=e.length)break;let a=e.charCodeAt(t);if(a===yn.SEMI&&i!==0&&(r&vn.FLAG13)!==0)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);if(this.treeIndex=Dn(n,r,this.treeIndex+Math.max(1,i),a),this.treeIndex<0)return this.result===0||this.decodeMode===Tn.Attribute&&(i===0||Cn(a))?0:this.emitNotTerminatedNamedEntity();if(r=n[this.treeIndex],i=(r&vn.VALUE_LENGTH)>>14,i!==0){if(a===yn.SEMI)return this.emitNamedEntityData(this.treeIndex,i,this.consumed+this.excess);this.decodeMode!==Tn.Strict&&(r&vn.FLAG13)===0&&(this.result=this.treeIndex,this.consumed+=this.excess,this.excess=0)}t++,this.excess++}return-1}emitNotTerminatedNamedEntity(){var e;let{result:t,decodeTree:n}=this,r=(n[t]&vn.VALUE_LENGTH)>>14;return this.emitNamedEntityData(t,r,this.consumed),(e=this.errors)==null||e.missingSemicolonAfterCharacterReference(),this.consumed}emitNamedEntityData(e,t,n){let{decodeTree:r}=this;return this.emitCodePoint(t===1?r[e]&~(vn.VALUE_LENGTH|vn.FLAG13):r[e+1],n),t===3&&this.emitCodePoint(r[e+2],n),n}end(){var e;switch(this.state){case wn.NamedEntity:return this.result!==0&&(this.decodeMode!==Tn.Attribute||this.result===this.treeIndex)?this.emitNotTerminatedNamedEntity():0;case wn.NumericDecimal:return this.emitNumericEntity(0,2);case wn.NumericHex:return this.emitNumericEntity(0,3);case wn.NumericStart:return(e=this.errors)==null||e.absenceOfDigitsInNumericCharacterReference(this.consumed),0;case wn.EntityStart:return 0}}};function Dn(e,t,n,r){let i=(t&vn.BRANCH_LENGTH)>>7,a=t&vn.JUMP_TABLE;if(i===0)return a!==0&&r===a?n:-1;if(a){let t=r-a;return t<0||t>=i?-1:e[n+t]-1}let o=i+1>>1,s=0,c=i-1;for(;s<=c;){let t=s+c>>>1,i=e[n+(t>>1)]>>(t&1)*8&255;if(i<r)s=t+1;else if(i>r)c=t-1;else return e[n+o+t]}return-1}var G;(function(e){e[e.Tab=9]=`Tab`,e[e.NewLine=10]=`NewLine`,e[e.FormFeed=12]=`FormFeed`,e[e.CarriageReturn=13]=`CarriageReturn`,e[e.Space=32]=`Space`,e[e.ExclamationMark=33]=`ExclamationMark`,e[e.Number=35]=`Number`,e[e.Amp=38]=`Amp`,e[e.SingleQuote=39]=`SingleQuote`,e[e.DoubleQuote=34]=`DoubleQuote`,e[e.Dash=45]=`Dash`,e[e.Slash=47]=`Slash`,e[e.Zero=48]=`Zero`,e[e.Nine=57]=`Nine`,e[e.Semi=59]=`Semi`,e[e.Lt=60]=`Lt`,e[e.Eq=61]=`Eq`,e[e.Gt=62]=`Gt`,e[e.Questionmark=63]=`Questionmark`,e[e.UpperA=65]=`UpperA`,e[e.LowerA=97]=`LowerA`,e[e.UpperF=70]=`UpperF`,e[e.LowerF=102]=`LowerF`,e[e.UpperZ=90]=`UpperZ`,e[e.LowerZ=122]=`LowerZ`,e[e.LowerX=120]=`LowerX`,e[e.OpeningSquareBracket=91]=`OpeningSquareBracket`})(G||={});var K;(function(e){e[e.Text=1]=`Text`,e[e.BeforeTagName=2]=`BeforeTagName`,e[e.InTagName=3]=`InTagName`,e[e.InSelfClosingTag=4]=`InSelfClosingTag`,e[e.BeforeClosingTagName=5]=`BeforeClosingTagName`,e[e.InClosingTagName=6]=`InClosingTagName`,e[e.AfterClosingTagName=7]=`AfterClosingTagName`,e[e.BeforeAttributeName=8]=`BeforeAttributeName`,e[e.InAttributeName=9]=`InAttributeName`,e[e.AfterAttributeName=10]=`AfterAttributeName`,e[e.BeforeAttributeValue=11]=`BeforeAttributeValue`,e[e.InAttributeValueDq=12]=`InAttributeValueDq`,e[e.InAttributeValueSq=13]=`InAttributeValueSq`,e[e.InAttributeValueNq=14]=`InAttributeValueNq`,e[e.BeforeDeclaration=15]=`BeforeDeclaration`,e[e.InDeclaration=16]=`InDeclaration`,e[e.InProcessingInstruction=17]=`InProcessingInstruction`,e[e.BeforeComment=18]=`BeforeComment`,e[e.CDATASequence=19]=`CDATASequence`,e[e.InSpecialComment=20]=`InSpecialComment`,e[e.InCommentLike=21]=`InCommentLike`,e[e.BeforeSpecialS=22]=`BeforeSpecialS`,e[e.BeforeSpecialT=23]=`BeforeSpecialT`,e[e.SpecialStartSequence=24]=`SpecialStartSequence`,e[e.InSpecialTag=25]=`InSpecialTag`,e[e.InEntity=26]=`InEntity`})(K||={});function On(e){return e===G.Space||e===G.NewLine||e===G.Tab||e===G.FormFeed||e===G.CarriageReturn}function kn(e){return e===G.Slash||e===G.Gt||On(e)}function An(e){return e>=G.LowerA&&e<=G.LowerZ||e>=G.UpperA&&e<=G.UpperZ}var jn;(function(e){e[e.NoValue=0]=`NoValue`,e[e.Unquoted=1]=`Unquoted`,e[e.Single=2]=`Single`,e[e.Double=3]=`Double`})(jn||={});const Mn={Cdata:new Uint8Array([67,68,65,84,65,91]),CdataEnd:new Uint8Array([93,93,62]),CommentEnd:new Uint8Array([45,45,62]),ScriptEnd:new Uint8Array([60,47,115,99,114,105,112,116]),StyleEnd:new Uint8Array([60,47,115,116,121,108,101]),TitleEnd:new Uint8Array([60,47,116,105,116,108,101]),TextareaEnd:new Uint8Array([60,47,116,101,120,116,97,114,101,97]),XmpEnd:new Uint8Array([60,47,120,109,112])};var Nn=class{constructor({xmlMode:e=!1,decodeEntities:t=!0},n){this.cbs=n,this.state=K.Text,this.buffer=``,this.sectionStart=0,this.index=0,this.entityStart=0,this.baseState=K.Text,this.isSpecial=!1,this.running=!0,this.offset=0,this.currentSequence=void 0,this.sequenceIndex=0,this.xmlMode=e,this.decodeEntities=t,this.entityDecoder=new En(e?_n:gn,(e,t)=>this.emitCodePoint(e,t))}reset(){this.state=K.Text,this.buffer=``,this.sectionStart=0,this.index=0,this.baseState=K.Text,this.currentSequence=void 0,this.running=!0,this.offset=0}write(e){this.offset+=this.buffer.length,this.buffer=e,this.parse()}end(){this.running&&this.finish()}pause(){this.running=!1}resume(){this.running=!0,this.index<this.buffer.length+this.offset&&this.parse()}stateText(e){e===G.Lt||!this.decodeEntities&&this.fastForwardTo(G.Lt)?(this.index>this.sectionStart&&this.cbs.ontext(this.sectionStart,this.index),this.state=K.BeforeTagName,this.sectionStart=this.index):this.decodeEntities&&e===G.Amp&&this.startEntity()}stateSpecialStartSequence(e){let t=this.sequenceIndex===this.currentSequence.length;if(!(t?kn(e):(e|32)===this.currentSequence[this.sequenceIndex]))this.isSpecial=!1;else if(!t){this.sequenceIndex++;return}this.sequenceIndex=0,this.state=K.InTagName,this.stateInTagName(e)}stateInSpecialTag(e){if(this.sequenceIndex===this.currentSequence.length){if(e===G.Gt||On(e)){let t=this.index-this.currentSequence.length;if(this.sectionStart<t){let e=this.index;this.index=t,this.cbs.ontext(this.sectionStart,t),this.index=e}this.isSpecial=!1,this.sectionStart=t+2,this.stateInClosingTagName(e);return}this.sequenceIndex=0}(e|32)===this.currentSequence[this.sequenceIndex]?this.sequenceIndex+=1:this.sequenceIndex===0?this.currentSequence===Mn.TitleEnd?this.decodeEntities&&e===G.Amp&&this.startEntity():this.fastForwardTo(G.Lt)&&(this.sequenceIndex=1):this.sequenceIndex=Number(e===G.Lt)}stateCDATASequence(e){e===Mn.Cdata[this.sequenceIndex]?++this.sequenceIndex===Mn.Cdata.length&&(this.state=K.InCommentLike,this.currentSequence=Mn.CdataEnd,this.sequenceIndex=0,this.sectionStart=this.index+1):(this.sequenceIndex=0,this.state=K.InDeclaration,this.stateInDeclaration(e))}fastForwardTo(e){for(;++this.index<this.buffer.length+this.offset;)if(this.buffer.charCodeAt(this.index-this.offset)===e)return!0;return this.index=this.buffer.length+this.offset-1,!1}stateInCommentLike(e){e===this.currentSequence[this.sequenceIndex]?++this.sequenceIndex===this.currentSequence.length&&(this.currentSequence===Mn.CdataEnd?this.cbs.oncdata(this.sectionStart,this.index,2):this.cbs.oncomment(this.sectionStart,this.index,2),this.sequenceIndex=0,this.sectionStart=this.index+1,this.state=K.Text):this.sequenceIndex===0?this.fastForwardTo(this.currentSequence[0])&&(this.sequenceIndex=1):e!==this.currentSequence[this.sequenceIndex-1]&&(this.sequenceIndex=0)}isTagStartChar(e){return this.xmlMode?!kn(e):An(e)}startSpecial(e,t){this.isSpecial=!0,this.currentSequence=e,this.sequenceIndex=t,this.state=K.SpecialStartSequence}stateBeforeTagName(e){if(e===G.ExclamationMark)this.state=K.BeforeDeclaration,this.sectionStart=this.index+1;else if(e===G.Questionmark)this.state=K.InProcessingInstruction,this.sectionStart=this.index+1;else if(this.isTagStartChar(e)){let t=e|32;this.sectionStart=this.index,this.xmlMode?this.state=K.InTagName:t===Mn.ScriptEnd[2]?this.state=K.BeforeSpecialS:t===Mn.TitleEnd[2]||t===Mn.XmpEnd[2]?this.state=K.BeforeSpecialT:this.state=K.InTagName}else e===G.Slash?this.state=K.BeforeClosingTagName:(this.state=K.Text,this.stateText(e))}stateInTagName(e){kn(e)&&(this.cbs.onopentagname(this.sectionStart,this.index),this.sectionStart=-1,this.state=K.BeforeAttributeName,this.stateBeforeAttributeName(e))}stateBeforeClosingTagName(e){On(e)||(e===G.Gt?this.state=K.Text:(this.state=this.isTagStartChar(e)?K.InClosingTagName:K.InSpecialComment,this.sectionStart=this.index))}stateInClosingTagName(e){(e===G.Gt||On(e))&&(this.cbs.onclosetag(this.sectionStart,this.index),this.sectionStart=-1,this.state=K.AfterClosingTagName,this.stateAfterClosingTagName(e))}stateAfterClosingTagName(e){(e===G.Gt||this.fastForwardTo(G.Gt))&&(this.state=K.Text,this.sectionStart=this.index+1)}stateBeforeAttributeName(e){e===G.Gt?(this.cbs.onopentagend(this.index),this.isSpecial?(this.state=K.InSpecialTag,this.sequenceIndex=0):this.state=K.Text,this.sectionStart=this.index+1):e===G.Slash?this.state=K.InSelfClosingTag:On(e)||(this.state=K.InAttributeName,this.sectionStart=this.index)}stateInSelfClosingTag(e){e===G.Gt?(this.cbs.onselfclosingtag(this.index),this.state=K.Text,this.sectionStart=this.index+1,this.isSpecial=!1):On(e)||(this.state=K.BeforeAttributeName,this.stateBeforeAttributeName(e))}stateInAttributeName(e){(e===G.Eq||kn(e))&&(this.cbs.onattribname(this.sectionStart,this.index),this.sectionStart=this.index,this.state=K.AfterAttributeName,this.stateAfterAttributeName(e))}stateAfterAttributeName(e){e===G.Eq?this.state=K.BeforeAttributeValue:e===G.Slash||e===G.Gt?(this.cbs.onattribend(jn.NoValue,this.sectionStart),this.sectionStart=-1,this.state=K.BeforeAttributeName,this.stateBeforeAttributeName(e)):On(e)||(this.cbs.onattribend(jn.NoValue,this.sectionStart),this.state=K.InAttributeName,this.sectionStart=this.index)}stateBeforeAttributeValue(e){e===G.DoubleQuote?(this.state=K.InAttributeValueDq,this.sectionStart=this.index+1):e===G.SingleQuote?(this.state=K.InAttributeValueSq,this.sectionStart=this.index+1):On(e)||(this.sectionStart=this.index,this.state=K.InAttributeValueNq,this.stateInAttributeValueNoQuotes(e))}handleInAttributeValue(e,t){e===t||!this.decodeEntities&&this.fastForwardTo(t)?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(t===G.DoubleQuote?jn.Double:jn.Single,this.index+1),this.state=K.BeforeAttributeName):this.decodeEntities&&e===G.Amp&&this.startEntity()}stateInAttributeValueDoubleQuotes(e){this.handleInAttributeValue(e,G.DoubleQuote)}stateInAttributeValueSingleQuotes(e){this.handleInAttributeValue(e,G.SingleQuote)}stateInAttributeValueNoQuotes(e){On(e)||e===G.Gt?(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=-1,this.cbs.onattribend(jn.Unquoted,this.index),this.state=K.BeforeAttributeName,this.stateBeforeAttributeName(e)):this.decodeEntities&&e===G.Amp&&this.startEntity()}stateBeforeDeclaration(e){e===G.OpeningSquareBracket?(this.state=K.CDATASequence,this.sequenceIndex=0):this.state=e===G.Dash?K.BeforeComment:K.InDeclaration}stateInDeclaration(e){(e===G.Gt||this.fastForwardTo(G.Gt))&&(this.cbs.ondeclaration(this.sectionStart,this.index),this.state=K.Text,this.sectionStart=this.index+1)}stateInProcessingInstruction(e){(e===G.Gt||this.fastForwardTo(G.Gt))&&(this.cbs.onprocessinginstruction(this.sectionStart,this.index),this.state=K.Text,this.sectionStart=this.index+1)}stateBeforeComment(e){e===G.Dash?(this.state=K.InCommentLike,this.currentSequence=Mn.CommentEnd,this.sequenceIndex=2,this.sectionStart=this.index+1):this.state=K.InDeclaration}stateInSpecialComment(e){(e===G.Gt||this.fastForwardTo(G.Gt))&&(this.cbs.oncomment(this.sectionStart,this.index,0),this.state=K.Text,this.sectionStart=this.index+1)}stateBeforeSpecialS(e){let t=e|32;t===Mn.ScriptEnd[3]?this.startSpecial(Mn.ScriptEnd,4):t===Mn.StyleEnd[3]?this.startSpecial(Mn.StyleEnd,4):(this.state=K.InTagName,this.stateInTagName(e))}stateBeforeSpecialT(e){switch(e|32){case Mn.TitleEnd[3]:this.startSpecial(Mn.TitleEnd,4);break;case Mn.TextareaEnd[3]:this.startSpecial(Mn.TextareaEnd,4);break;case Mn.XmpEnd[3]:this.startSpecial(Mn.XmpEnd,4);break;default:this.state=K.InTagName,this.stateInTagName(e)}}startEntity(){this.baseState=this.state,this.state=K.InEntity,this.entityStart=this.index,this.entityDecoder.startEntity(this.xmlMode?Tn.Strict:this.baseState===K.Text||this.baseState===K.InSpecialTag?Tn.Legacy:Tn.Attribute)}stateInEntity(){let e=this.index-this.offset,t=this.entityDecoder.write(this.buffer,e);if(t>=0)this.state=this.baseState,t===0&&--this.index;else{if(e<this.buffer.length&&this.buffer.charCodeAt(e)===G.Amp){this.state=this.baseState,--this.index;return}this.index=this.offset+this.buffer.length-1}}cleanup(){this.running&&this.sectionStart!==this.index&&(this.state===K.Text||this.state===K.InSpecialTag&&this.sequenceIndex===0?(this.cbs.ontext(this.sectionStart,this.index),this.sectionStart=this.index):(this.state===K.InAttributeValueDq||this.state===K.InAttributeValueSq||this.state===K.InAttributeValueNq)&&(this.cbs.onattribdata(this.sectionStart,this.index),this.sectionStart=this.index))}shouldContinue(){return this.index<this.buffer.length+this.offset&&this.running}parse(){for(;this.shouldContinue();){let e=this.buffer.charCodeAt(this.index-this.offset);switch(this.state){case K.Text:this.stateText(e);break;case K.SpecialStartSequence:this.stateSpecialStartSequence(e);break;case K.InSpecialTag:this.stateInSpecialTag(e);break;case K.CDATASequence:this.stateCDATASequence(e);break;case K.InAttributeValueDq:this.stateInAttributeValueDoubleQuotes(e);break;case K.InAttributeName:this.stateInAttributeName(e);break;case K.InCommentLike:this.stateInCommentLike(e);break;case K.InSpecialComment:this.stateInSpecialComment(e);break;case K.BeforeAttributeName:this.stateBeforeAttributeName(e);break;case K.InTagName:this.stateInTagName(e);break;case K.InClosingTagName:this.stateInClosingTagName(e);break;case K.BeforeTagName:this.stateBeforeTagName(e);break;case K.AfterAttributeName:this.stateAfterAttributeName(e);break;case K.InAttributeValueSq:this.stateInAttributeValueSingleQuotes(e);break;case K.BeforeAttributeValue:this.stateBeforeAttributeValue(e);break;case K.BeforeClosingTagName:this.stateBeforeClosingTagName(e);break;case K.AfterClosingTagName:this.stateAfterClosingTagName(e);break;case K.BeforeSpecialS:this.stateBeforeSpecialS(e);break;case K.BeforeSpecialT:this.stateBeforeSpecialT(e);break;case K.InAttributeValueNq:this.stateInAttributeValueNoQuotes(e);break;case K.InSelfClosingTag:this.stateInSelfClosingTag(e);break;case K.InDeclaration:this.stateInDeclaration(e);break;case K.BeforeDeclaration:this.stateBeforeDeclaration(e);break;case K.BeforeComment:this.stateBeforeComment(e);break;case K.InProcessingInstruction:this.stateInProcessingInstruction(e);break;case K.InEntity:this.stateInEntity();break}this.index++}this.cleanup()}finish(){this.state===K.InEntity&&(this.entityDecoder.end(),this.state=this.baseState),this.handleTrailingData(),this.cbs.onend()}handleTrailingData(){let e=this.buffer.length+this.offset;this.sectionStart>=e||(this.state===K.InCommentLike?this.currentSequence===Mn.CdataEnd?this.cbs.oncdata(this.sectionStart,e,0):this.cbs.oncomment(this.sectionStart,e,0):this.state===K.InTagName||this.state===K.BeforeAttributeName||this.state===K.BeforeAttributeValue||this.state===K.AfterAttributeName||this.state===K.InAttributeName||this.state===K.InAttributeValueSq||this.state===K.InAttributeValueDq||this.state===K.InAttributeValueNq||this.state===K.InClosingTagName||this.cbs.ontext(this.sectionStart,e))}emitCodePoint(e,t){this.baseState!==K.Text&&this.baseState!==K.InSpecialTag?(this.sectionStart<this.entityStart&&this.cbs.onattribdata(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+t,this.index=this.sectionStart-1,this.cbs.onattribentity(e)):(this.sectionStart<this.entityStart&&this.cbs.ontext(this.sectionStart,this.entityStart),this.sectionStart=this.entityStart+t,this.index=this.sectionStart-1,this.cbs.ontextentity(e,this.sectionStart))}};const Pn=new Set([`input`,`option`,`optgroup`,`select`,`button`,`datalist`,`textarea`]),Fn=new Set([`p`]),In=new Set([`thead`,`tbody`]),Ln=new Set([`dd`,`dt`]),Rn=new Set([`rt`,`rp`]),zn=new Map([[`tr`,new Set([`tr`,`th`,`td`])],[`th`,new Set([`th`])],[`td`,new Set([`thead`,`th`,`td`])],[`body`,new Set([`head`,`link`,`script`])],[`li`,new Set([`li`])],[`p`,Fn],[`h1`,Fn],[`h2`,Fn],[`h3`,Fn],[`h4`,Fn],[`h5`,Fn],[`h6`,Fn],[`select`,Pn],[`input`,Pn],[`output`,Pn],[`button`,Pn],[`datalist`,Pn],[`textarea`,Pn],[`option`,new Set([`option`])],[`optgroup`,new Set([`optgroup`,`option`])],[`dd`,Ln],[`dt`,Ln],[`address`,Fn],[`article`,Fn],[`aside`,Fn],[`blockquote`,Fn],[`details`,Fn],[`div`,Fn],[`dl`,Fn],[`fieldset`,Fn],[`figcaption`,Fn],[`figure`,Fn],[`footer`,Fn],[`form`,Fn],[`header`,Fn],[`hr`,Fn],[`main`,Fn],[`nav`,Fn],[`ol`,Fn],[`pre`,Fn],[`section`,Fn],[`table`,Fn],[`ul`,Fn],[`rt`,Rn],[`rp`,Rn],[`tbody`,In],[`tfoot`,In]]),Bn=new Set([`area`,`base`,`basefont`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`img`,`input`,`isindex`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]),Vn=new Set([`math`,`svg`]),Hn=new Set([`mi`,`mo`,`mn`,`ms`,`mtext`,`annotation-xml`,`foreignobject`,`desc`,`title`]),Un=/\s|\//;var Wn=class{constructor(e,t={}){var n,r;this.options=t,this.startIndex=0,this.endIndex=0,this.openTagStart=0,this.tagname=``,this.attribname=``,this.attribvalue=``,this.attribs=null,this.stack=[],this.buffers=[],this.bufferOffset=0,this.writeIndex=0,this.ended=!1,this.cbs=e??{},this.htmlMode=!this.options.xmlMode,this.lowerCaseTagNames=t.lowerCaseTags??this.htmlMode,this.lowerCaseAttributeNames=t.lowerCaseAttributeNames??this.htmlMode,this.recognizeSelfClosing=t.recognizeSelfClosing??!this.htmlMode,this.tokenizer=new(t.Tokenizer??Nn)(this.options,this),this.foreignContext=[!this.htmlMode],(r=(n=this.cbs).onparserinit)==null||r.call(n,this)}ontext(e,t){var n,r;let i=this.getSlice(e,t);this.endIndex=t-1,(r=(n=this.cbs).ontext)==null||r.call(n,i),this.startIndex=t}ontextentity(e,t){var n,r;this.endIndex=t-1,(r=(n=this.cbs).ontext)==null||r.call(n,pn(e)),this.startIndex=t}isVoidElement(e){return this.htmlMode&&Bn.has(e)}onopentagname(e,t){this.endIndex=t;let n=this.getSlice(e,t);this.lowerCaseTagNames&&(n=n.toLowerCase()),this.emitOpenTag(n)}emitOpenTag(e){var t,n,r,i;this.openTagStart=this.startIndex,this.tagname=e;let a=this.htmlMode&&zn.get(e);if(a)for(;this.stack.length>0&&a.has(this.stack[0]);){let e=this.stack.shift();(n=(t=this.cbs).onclosetag)==null||n.call(t,e,!0)}this.isVoidElement(e)||(this.stack.unshift(e),this.htmlMode&&(Vn.has(e)?this.foreignContext.unshift(!0):Hn.has(e)&&this.foreignContext.unshift(!1))),(i=(r=this.cbs).onopentagname)==null||i.call(r,e),this.cbs.onopentag&&(this.attribs={})}endOpenTag(e){var t,n;this.startIndex=this.openTagStart,this.attribs&&=((n=(t=this.cbs).onopentag)==null||n.call(t,this.tagname,this.attribs,e),null),this.cbs.onclosetag&&this.isVoidElement(this.tagname)&&this.cbs.onclosetag(this.tagname,!0),this.tagname=``}onopentagend(e){this.endIndex=e,this.endOpenTag(!1),this.startIndex=e+1}onclosetag(e,t){var n,r,i,a,o,s,c,l;this.endIndex=t;let u=this.getSlice(e,t);if(this.lowerCaseTagNames&&(u=u.toLowerCase()),this.htmlMode&&(Vn.has(u)||Hn.has(u))&&this.foreignContext.shift(),this.isVoidElement(u))this.htmlMode&&u===`br`&&((a=(i=this.cbs).onopentagname)==null||a.call(i,`br`),(s=(o=this.cbs).onopentag)==null||s.call(o,`br`,{},!0),(l=(c=this.cbs).onclosetag)==null||l.call(c,`br`,!1));else{let e=this.stack.indexOf(u);if(e!==-1)for(let t=0;t<=e;t++){let i=this.stack.shift();(r=(n=this.cbs).onclosetag)==null||r.call(n,i,t!==e)}else this.htmlMode&&u===`p`&&(this.emitOpenTag(`p`),this.closeCurrentTag(!0))}this.startIndex=t+1}onselfclosingtag(e){this.endIndex=e,this.recognizeSelfClosing||this.foreignContext[0]?(this.closeCurrentTag(!1),this.startIndex=e+1):this.onopentagend(e)}closeCurrentTag(e){var t,n;let r=this.tagname;this.endOpenTag(e),this.stack[0]===r&&((n=(t=this.cbs).onclosetag)==null||n.call(t,r,!e),this.stack.shift())}onattribname(e,t){this.startIndex=e;let n=this.getSlice(e,t);this.attribname=this.lowerCaseAttributeNames?n.toLowerCase():n}onattribdata(e,t){this.attribvalue+=this.getSlice(e,t)}onattribentity(e){this.attribvalue+=pn(e)}onattribend(e,t){var n,r;this.endIndex=t,(r=(n=this.cbs).onattribute)==null||r.call(n,this.attribname,this.attribvalue,e===jn.Double?`"`:e===jn.Single?`'`:e===jn.NoValue?void 0:null),this.attribs&&!Object.prototype.hasOwnProperty.call(this.attribs,this.attribname)&&(this.attribs[this.attribname]=this.attribvalue),this.attribvalue=``}getInstructionName(e){let t=e.search(Un),n=t<0?e:e.substr(0,t);return this.lowerCaseTagNames&&(n=n.toLowerCase()),n}ondeclaration(e,t){this.endIndex=t;let n=this.getSlice(e,t);if(this.cbs.onprocessinginstruction){let e=this.getInstructionName(n);this.cbs.onprocessinginstruction(`!${e}`,`!${n}`)}this.startIndex=t+1}onprocessinginstruction(e,t){this.endIndex=t;let n=this.getSlice(e,t);if(this.cbs.onprocessinginstruction){let e=this.getInstructionName(n);this.cbs.onprocessinginstruction(`?${e}`,`?${n}`)}this.startIndex=t+1}oncomment(e,t,n){var r,i,a,o;this.endIndex=t,(i=(r=this.cbs).oncomment)==null||i.call(r,this.getSlice(e,t-n)),(o=(a=this.cbs).oncommentend)==null||o.call(a),this.startIndex=t+1}oncdata(e,t,n){var r,i,a,o,s,c,l,u,d,f;this.endIndex=t;let p=this.getSlice(e,t-n);!this.htmlMode||this.options.recognizeCDATA?((i=(r=this.cbs).oncdatastart)==null||i.call(r),(o=(a=this.cbs).ontext)==null||o.call(a,p),(c=(s=this.cbs).oncdataend)==null||c.call(s)):((u=(l=this.cbs).oncomment)==null||u.call(l,`[CDATA[${p}]]`),(f=(d=this.cbs).oncommentend)==null||f.call(d)),this.startIndex=t+1}onend(){var e,t;if(this.cbs.onclosetag){this.endIndex=this.startIndex;for(let e=0;e<this.stack.length;e++)this.cbs.onclosetag(this.stack[e],!0)}(t=(e=this.cbs).onend)==null||t.call(e)}reset(){var e,t,n,r;(t=(e=this.cbs).onreset)==null||t.call(e),this.tokenizer.reset(),this.tagname=``,this.attribname=``,this.attribs=null,this.stack.length=0,this.startIndex=0,this.endIndex=0,(r=(n=this.cbs).onparserinit)==null||r.call(n,this),this.buffers.length=0,this.foreignContext.length=0,this.foreignContext.unshift(!this.htmlMode),this.bufferOffset=0,this.writeIndex=0,this.ended=!1}parseComplete(e){this.reset(),this.end(e)}getSlice(e,t){for(;e-this.bufferOffset>=this.buffers[0].length;)this.shiftBuffer();let n=this.buffers[0].slice(e-this.bufferOffset,t-this.bufferOffset);for(;t-this.bufferOffset>this.buffers[0].length;)this.shiftBuffer(),n+=this.buffers[0].slice(0,t-this.bufferOffset);return n}shiftBuffer(){this.bufferOffset+=this.buffers[0].length,this.writeIndex--,this.buffers.shift()}write(e){var t,n;if(this.ended){(n=(t=this.cbs).onerror)==null||n.call(t,Error(`.write() after done!`));return}this.buffers.push(e),this.tokenizer.running&&(this.tokenizer.write(e),this.writeIndex++)}end(e){var t,n;if(this.ended){(n=(t=this.cbs).onerror)==null||n.call(t,Error(`.end() after done!`));return}e&&this.write(e),this.ended=!0,this.tokenizer.end()}pause(){this.tokenizer.pause()}resume(){for(this.tokenizer.resume();this.tokenizer.running&&this.writeIndex<this.buffers.length;)this.tokenizer.write(this.buffers[this.writeIndex++]);this.ended&&this.tokenizer.end()}parseChunk(e){this.write(e)}done(e){this.end(e)}},Gn=re({CDATA:()=>er,Comment:()=>Xn,Directive:()=>Yn,Doctype:()=>tr,ElementType:()=>q,Root:()=>qn,Script:()=>Zn,Style:()=>Qn,Tag:()=>$n,Text:()=>Jn,isTag:()=>Kn}),q;(function(e){e.Root=`root`,e.Text=`text`,e.Directive=`directive`,e.Comment=`comment`,e.Script=`script`,e.Style=`style`,e.Tag=`tag`,e.CDATA=`cdata`,e.Doctype=`doctype`})(q||={});function Kn(e){return e.type===q.Tag||e.type===q.Script||e.type===q.Style}const qn=q.Root,Jn=q.Text,Yn=q.Directive,Xn=q.Comment,Zn=q.Script,Qn=q.Style,$n=q.Tag,er=q.CDATA,tr=q.Doctype;var nr=class{constructor(){this.parent=null,this.prev=null,this.next=null,this.startIndex=null,this.endIndex=null}get parentNode(){return this.parent}set parentNode(e){this.parent=e}get previousSibling(){return this.prev}set previousSibling(e){this.prev=e}get nextSibling(){return this.next}set nextSibling(e){this.next=e}cloneNode(e=!1){return vr(this,e)}},rr=class extends nr{constructor(e){super(),this.data=e}get nodeValue(){return this.data}set nodeValue(e){this.data=e}},ir=class extends rr{constructor(){super(...arguments),this.type=q.Text}get nodeType(){return 3}},ar=class extends rr{constructor(){super(...arguments),this.type=q.Comment}get nodeType(){return 8}},or=class extends rr{constructor(e,t){super(t),this.name=e,this.type=q.Directive}get nodeType(){return 1}},sr=class extends nr{constructor(e){super(),this.children=e}get firstChild(){return this.children[0]??null}get lastChild(){return this.children.length>0?this.children[this.children.length-1]:null}get childNodes(){return this.children}set childNodes(e){this.children=e}},cr=class extends sr{constructor(){super(...arguments),this.type=q.CDATA}get nodeType(){return 4}},lr=class extends sr{constructor(){super(...arguments),this.type=q.Root}get nodeType(){return 9}},ur=class extends sr{constructor(e,t,n=[],r=e===`script`?q.Script:e===`style`?q.Style:q.Tag){super(n),this.name=e,this.attribs=t,this.type=r}get nodeType(){return 1}get tagName(){return this.name}set tagName(e){this.name=e}get attributes(){return Object.keys(this.attribs).map(e=>({name:e,value:this.attribs[e],namespace:this[`x-attribsNamespace`]?.[e],prefix:this[`x-attribsPrefix`]?.[e]}))}};function dr(e){return Kn(e)}function fr(e){return e.type===q.CDATA}function pr(e){return e.type===q.Text}function mr(e){return e.type===q.Comment}function hr(e){return e.type===q.Directive}function gr(e){return e.type===q.Root}function _r(e){return Object.prototype.hasOwnProperty.call(e,`children`)}function vr(e,t=!1){let n;if(pr(e))n=new ir(e.data);else if(mr(e))n=new ar(e.data);else if(dr(e)){let r=t?yr(e.children):[],i=new ur(e.name,{...e.attribs},r);r.forEach(e=>e.parent=i),e.namespace!=null&&(i.namespace=e.namespace),e[`x-attribsNamespace`]&&(i[`x-attribsNamespace`]={...e[`x-attribsNamespace`]}),e[`x-attribsPrefix`]&&(i[`x-attribsPrefix`]={...e[`x-attribsPrefix`]}),n=i}else if(fr(e)){let r=t?yr(e.children):[],i=new cr(r);r.forEach(e=>e.parent=i),n=i}else if(gr(e)){let r=t?yr(e.children):[],i=new lr(r);r.forEach(e=>e.parent=i),e[`x-mode`]&&(i[`x-mode`]=e[`x-mode`]),n=i}else if(hr(e)){let t=new or(e.name,e.data);e[`x-name`]!=null&&(t[`x-name`]=e[`x-name`],t[`x-publicId`]=e[`x-publicId`],t[`x-systemId`]=e[`x-systemId`]),n=t}else throw Error(`Not implemented yet: ${e.type}`);return n.startIndex=e.startIndex,n.endIndex=e.endIndex,e.sourceCodeLocation!=null&&(n.sourceCodeLocation=e.sourceCodeLocation),n}function yr(e){let t=e.map(e=>vr(e,!0));for(let e=1;e<t.length;e++)t[e].prev=t[e-1],t[e-1].next=t[e];return t}const br={withStartIndices:!1,withEndIndices:!1,xmlMode:!1};var xr=class{constructor(e,t,n){this.dom=[],this.root=new lr(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null,typeof t==`function`&&(n=t,t=br),typeof e==`object`&&(t=e,e=void 0),this.callback=e??null,this.options=t??br,this.elementCB=n??null}onparserinit(e){this.parser=e}onreset(){this.dom=[],this.root=new lr(this.dom),this.done=!1,this.tagStack=[this.root],this.lastNode=null,this.parser=null}onend(){this.done||(this.done=!0,this.parser=null,this.handleCallback(null))}onerror(e){this.handleCallback(e)}onclosetag(){this.lastNode=null;let e=this.tagStack.pop();this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),this.elementCB&&this.elementCB(e)}onopentag(e,t){let n=new ur(e,t,void 0,this.options.xmlMode?q.Tag:void 0);this.addNode(n),this.tagStack.push(n)}ontext(e){let{lastNode:t}=this;if(t&&t.type===q.Text)t.data+=e,this.options.withEndIndices&&(t.endIndex=this.parser.endIndex);else{let t=new ir(e);this.addNode(t),this.lastNode=t}}oncomment(e){if(this.lastNode&&this.lastNode.type===q.Comment){this.lastNode.data+=e;return}let t=new ar(e);this.addNode(t),this.lastNode=t}oncommentend(){this.lastNode=null}oncdatastart(){let e=new ir(``),t=new cr([e]);this.addNode(t),e.parent=t,this.lastNode=e}oncdataend(){this.lastNode=null}onprocessinginstruction(e,t){let n=new or(e,t);this.addNode(n)}handleCallback(e){if(typeof this.callback==`function`)this.callback(e,this.dom);else if(e)throw e}addNode(e){let t=this.tagStack[this.tagStack.length-1],n=t.children[t.children.length-1];this.options.withStartIndices&&(e.startIndex=this.parser.startIndex),this.options.withEndIndices&&(e.endIndex=this.parser.endIndex),t.children.push(e),n&&(e.prev=n,n.next=e),e.parent=t,this.lastNode=null}};const Sr=/["&'<>$\x80-\uFFFF]/g,Cr=new Map([[34,`"`],[38,`&`],[39,`'`],[60,`<`],[62,`>`]]),wr=String.prototype.codePointAt==null?(e,t)=>(e.charCodeAt(t)&64512)==55296?(e.charCodeAt(t)-55296)*1024+e.charCodeAt(t+1)-56320+65536:e.charCodeAt(t):(e,t)=>e.codePointAt(t);function J(e){let t=``,n=0,r;for(;(r=Sr.exec(e))!==null;){let i=r.index,a=e.charCodeAt(i),o=Cr.get(a);o===void 0?(t+=`${e.substring(n,i)}&#x${wr(e,i).toString(16)};`,n=Sr.lastIndex+=Number((a&64512)==55296)):(t+=e.substring(n,i)+o,n=i+1)}return t+e.substr(n)}function Tr(e,t){return function(n){let r,i=0,a=``;for(;r=e.exec(n);)i!==r.index&&(a+=n.substring(i,r.index)),a+=t.get(r[0].charCodeAt(0)),i=r.index+1;return a+n.substring(i)}}const Er=Tr(/["&\u00A0]/g,new Map([[34,`"`],[38,`&`],[160,` `]])),Dr=Tr(/[&<>\u00A0]/g,new Map([[38,`&`],[60,`<`],[62,`>`],[160,` `]])),Or=new Map(`altGlyph.altGlyphDef.altGlyphItem.animateColor.animateMotion.animateTransform.clipPath.feBlend.feColorMatrix.feComponentTransfer.feComposite.feConvolveMatrix.feDiffuseLighting.feDisplacementMap.feDistantLight.feDropShadow.feFlood.feFuncA.feFuncB.feFuncG.feFuncR.feGaussianBlur.feImage.feMerge.feMergeNode.feMorphology.feOffset.fePointLight.feSpecularLighting.feSpotLight.feTile.feTurbulence.foreignObject.glyphRef.linearGradient.radialGradient.textPath`.split(`.`).map(e=>[e.toLowerCase(),e])),kr=new Map(`definitionURL.attributeName.attributeType.baseFrequency.baseProfile.calcMode.clipPathUnits.diffuseConstant.edgeMode.filterUnits.glyphRef.gradientTransform.gradientUnits.kernelMatrix.kernelUnitLength.keyPoints.keySplines.keyTimes.lengthAdjust.limitingConeAngle.markerHeight.markerUnits.markerWidth.maskContentUnits.maskUnits.numOctaves.pathLength.patternContentUnits.patternTransform.patternUnits.pointsAtX.pointsAtY.pointsAtZ.preserveAlpha.preserveAspectRatio.primitiveUnits.refX.refY.repeatCount.repeatDur.requiredExtensions.requiredFeatures.specularConstant.specularExponent.spreadMethod.startOffset.stdDeviation.stitchTiles.surfaceScale.systemLanguage.tableValues.targetX.targetY.textLength.viewBox.viewTarget.xChannelSelector.yChannelSelector.zoomAndPan`.split(`.`).map(e=>[e.toLowerCase(),e])),Ar=new Set([`style`,`script`,`xmp`,`iframe`,`noembed`,`noframes`,`plaintext`,`noscript`]);function jr(e){return e.replace(/"/g,`"`)}function Mr(e,t){if(!e)return;let n=(t.encodeEntities??t.decodeEntities)===!1?jr:t.xmlMode||t.encodeEntities!==`utf8`?J:Er;return Object.keys(e).map(r=>{let i=e[r]??``;return t.xmlMode===`foreign`&&(r=kr.get(r)??r),!t.emptyAttrs&&!t.xmlMode&&i===``?r:`${r}="${n(i)}"`}).join(` `)}const Nr=new Set([`area`,`base`,`basefont`,`br`,`col`,`command`,`embed`,`frame`,`hr`,`img`,`input`,`isindex`,`keygen`,`link`,`meta`,`param`,`source`,`track`,`wbr`]);function Pr(e,t={}){let n=`length`in e?e:[e],r=``;for(let e=0;e<n.length;e++)r+=Fr(n[e],t);return r}function Fr(e,t){switch(e.type){case qn:return Pr(e.children,t);case tr:case Yn:return zr(e);case Xn:return Hr(e);case er:return Vr(e);case Zn:case Qn:case $n:return Rr(e,t);case Jn:return Br(e,t)}}const Ir=new Set([`mi`,`mo`,`mn`,`ms`,`mtext`,`annotation-xml`,`foreignObject`,`desc`,`title`]),Lr=new Set([`svg`,`math`]);function Rr(e,t){t.xmlMode===`foreign`&&(e.name=Or.get(e.name)??e.name,e.parent&&Ir.has(e.parent.name)&&(t={...t,xmlMode:!1})),!t.xmlMode&&Lr.has(e.name)&&(t={...t,xmlMode:`foreign`});let n=`<${e.name}`,r=Mr(e.attribs,t);return r&&(n+=` ${r}`),e.children.length===0&&(t.xmlMode?t.selfClosingTags!==!1:t.selfClosingTags&&Nr.has(e.name))?(t.xmlMode||(n+=` `),n+=`/>`):(n+=`>`,e.children.length>0&&(n+=Pr(e.children,t)),(t.xmlMode||!Nr.has(e.name))&&(n+=`</${e.name}>`)),n}function zr(e){return`<${e.data}>`}function Br(e,t){let n=e.data||``;return(t.encodeEntities??t.decodeEntities)!==!1&&!(!t.xmlMode&&e.parent&&Ar.has(e.parent.name))&&(n=t.xmlMode||t.encodeEntities!==`utf8`?J(n):Dr(n)),n}function Vr(e){return`<![CDATA[${e.children[0].data}]]>`}function Hr(e){return`<!--${e.data}-->`}function Ur(e,t){return Pr(e,t)}function Wr(e,t){return _r(e)?e.children.map(e=>Ur(e,t)).join(``):``}function Gr(e){return Array.isArray(e)?e.map(Gr).join(``):dr(e)?e.name===`br`?`
|
|
6
6
|
`:Gr(e.children):fr(e)?Gr(e.children):pr(e)?e.data:``}function Kr(e){return Array.isArray(e)?e.map(Kr).join(``):_r(e)&&!mr(e)?Kr(e.children):pr(e)?e.data:``}function qr(e){return Array.isArray(e)?e.map(qr).join(``):_r(e)&&(e.type===q.Tag||fr(e))?qr(e.children):pr(e)?e.data:``}function Jr(e){return _r(e)?e.children:[]}function Yr(e){return e.parent||null}function Xr(e){let t=Yr(e);if(t!=null)return Jr(t);let n=[e],{prev:r,next:i}=e;for(;r!=null;)n.unshift(r),{prev:r}=r;for(;i!=null;)n.push(i),{next:i}=i;return n}function Zr(e,t){return e.attribs?.[t]}function Qr(e,t){return e.attribs!=null&&Object.prototype.hasOwnProperty.call(e.attribs,t)&&e.attribs[t]!=null}function $r(e){return e.name}function ei(e){let{next:t}=e;for(;t!==null&&!dr(t);)({next:t}=t);return t}function ti(e){let{prev:t}=e;for(;t!==null&&!dr(t);)({prev:t}=t);return t}function ni(e){if(e.prev&&(e.prev.next=e.next),e.next&&(e.next.prev=e.prev),e.parent){let t=e.parent.children,n=t.lastIndexOf(e);n>=0&&t.splice(n,1)}e.next=null,e.prev=null,e.parent=null}function ri(e,t){let n=t.prev=e.prev;n&&(n.next=t);let r=t.next=e.next;r&&(r.prev=t);let i=t.parent=e.parent;if(i){let n=i.children;n[n.lastIndexOf(e)]=t,e.parent=null}}function ii(e,t){if(ni(t),t.next=null,t.parent=e,e.children.push(t)>1){let n=e.children[e.children.length-2];n.next=t,t.prev=n}else t.prev=null}function ai(e,t){ni(t);let{parent:n}=e,r=e.next;if(t.next=r,t.prev=e,e.next=t,t.parent=n,r){if(r.prev=t,n){let e=n.children;e.splice(e.lastIndexOf(r),0,t)}}else n&&n.children.push(t)}function oi(e,t){if(ni(t),t.parent=e,t.prev=null,e.children.unshift(t)!==1){let n=e.children[1];n.prev=t,t.next=n}else t.next=null}function si(e,t){ni(t);let{parent:n}=e;if(n){let r=n.children;r.splice(r.indexOf(e),0,t)}e.prev&&(e.prev.next=t),t.parent=n,t.prev=e.prev,t.next=e,e.prev=t}function ci(e,t,n=!0,r=1/0){return li(e,Array.isArray(t)?t:[t],n,r)}function li(e,t,n,r){let i=[],a=[Array.isArray(t)?t:[t]],o=[0];for(;;){if(o[0]>=a[0].length){if(o.length===1)return i;a.shift(),o.shift();continue}let t=a[0][o[0]++];if(e(t)&&(i.push(t),--r<=0))return i;n&&_r(t)&&t.children.length>0&&(o.unshift(0),a.unshift(t.children))}}function ui(e,t){return t.find(e)}function di(e,t,n=!0){let r=Array.isArray(t)?t:[t];for(let t=0;t<r.length;t++){let i=r[t];if(dr(i)&&e(i))return i;if(n&&_r(i)&&i.children.length>0){let t=di(e,i.children,!0);if(t)return t}}return null}function fi(e,t){return(Array.isArray(t)?t:[t]).some(t=>dr(t)&&e(t)||_r(t)&&fi(e,t.children))}function pi(e,t){let n=[],r=[Array.isArray(t)?t:[t]],i=[0];for(;;){if(i[0]>=r[0].length){if(r.length===1)return n;r.shift(),i.shift();continue}let t=r[0][i[0]++];dr(t)&&e(t)&&n.push(t),_r(t)&&t.children.length>0&&(i.unshift(0),r.unshift(t.children))}}const mi={tag_name(e){return typeof e==`function`?t=>dr(t)&&e(t.name):e===`*`?dr:t=>dr(t)&&t.name===e},tag_type(e){return typeof e==`function`?t=>e(t.type):t=>t.type===e},tag_contains(e){return typeof e==`function`?t=>pr(t)&&e(t.data):t=>pr(t)&&t.data===e}};function hi(e,t){return typeof t==`function`?n=>dr(n)&&t(n.attribs[e]):n=>dr(n)&&n.attribs[e]===t}function gi(e,t){return n=>e(n)||t(n)}function _i(e){let t=Object.keys(e).map(t=>{let n=e[t];return Object.prototype.hasOwnProperty.call(mi,t)?mi[t](n):hi(t,n)});return t.length===0?null:t.reduce(gi)}function vi(e,t){let n=_i(e);return n?n(t):!0}function yi(e,t,n,r=1/0){let i=_i(e);return i?ci(i,t,n,r):[]}function bi(e,t,n=!0){return Array.isArray(t)||(t=[t]),di(hi(`id`,e),t,n)}function xi(e,t,n=!0,r=1/0){return ci(mi.tag_name(e),t,n,r)}function Si(e,t,n=!0,r=1/0){return ci(hi(`class`,e),t,n,r)}function Ci(e,t,n=!0,r=1/0){return ci(mi.tag_type(e),t,n,r)}function wi(e){let t=e.length;for(;--t>=0;){let n=e[t];if(t>0&&e.lastIndexOf(n,t-1)>=0){e.splice(t,1);continue}for(let r=n.parent;r;r=r.parent)if(e.includes(r)){e.splice(t,1);break}}return e}var Ti;(function(e){e[e.DISCONNECTED=1]=`DISCONNECTED`,e[e.PRECEDING=2]=`PRECEDING`,e[e.FOLLOWING=4]=`FOLLOWING`,e[e.CONTAINS=8]=`CONTAINS`,e[e.CONTAINED_BY=16]=`CONTAINED_BY`})(Ti||={});function Ei(e,t){let n=[],r=[];if(e===t)return 0;let i=_r(e)?e:e.parent;for(;i;)n.unshift(i),i=i.parent;for(i=_r(t)?t:t.parent;i;)r.unshift(i),i=i.parent;let a=Math.min(n.length,r.length),o=0;for(;o<a&&n[o]===r[o];)o++;if(o===0)return Ti.DISCONNECTED;let s=n[o-1],c=s.children,l=n[o],u=r[o];return c.indexOf(l)>c.indexOf(u)?s===t?Ti.FOLLOWING|Ti.CONTAINED_BY:Ti.FOLLOWING:s===e?Ti.PRECEDING|Ti.CONTAINS:Ti.PRECEDING}function Di(e){return e=e.filter((e,t,n)=>!n.includes(e,t+1)),e.sort((e,t)=>{let n=Ei(e,t);return n&Ti.PRECEDING?-1:n&Ti.FOLLOWING?1:0}),e}function Oi(e){let t=Pi(Li,e);return t?t.name===`feed`?ki(t):Ai(t):null}function ki(e){let t=e.children,n={type:`atom`,items:xi(`entry`,t).map(e=>{let{children:t}=e,n={media:Ni(t)};Ii(n,`id`,`id`,t),Ii(n,`title`,`title`,t);let r=Pi(`link`,t)?.attribs.href;r&&(n.link=r);let i=Fi(`summary`,t)||Fi(`content`,t);i&&(n.description=i);let a=Fi(`updated`,t);return a&&(n.pubDate=new Date(a)),n})};Ii(n,`id`,`id`,t),Ii(n,`title`,`title`,t);let r=Pi(`link`,t)?.attribs.href;r&&(n.link=r),Ii(n,`description`,`subtitle`,t);let i=Fi(`updated`,t);return i&&(n.updated=new Date(i)),Ii(n,`author`,`email`,t,!0),n}function Ai(e){let t=Pi(`channel`,e.children)?.children??[],n={type:e.name.substr(0,3),id:``,items:xi(`item`,e.children).map(e=>{let{children:t}=e,n={media:Ni(t)};Ii(n,`id`,`guid`,t),Ii(n,`title`,`title`,t),Ii(n,`link`,`link`,t),Ii(n,`description`,`description`,t);let r=Fi(`pubDate`,t)||Fi(`dc:date`,t);return r&&(n.pubDate=new Date(r)),n})};Ii(n,`title`,`title`,t),Ii(n,`link`,`link`,t),Ii(n,`description`,`description`,t);let r=Fi(`lastBuildDate`,t);return r&&(n.updated=new Date(r)),Ii(n,`author`,`managingEditor`,t,!0),n}const ji=[`url`,`type`,`lang`],Mi=[`fileSize`,`bitrate`,`framerate`,`samplingrate`,`channels`,`duration`,`height`,`width`];function Ni(e){return xi(`media:content`,e).map(e=>{let{attribs:t}=e,n={medium:t.medium,isDefault:!!t.isDefault};for(let e of ji)t[e]&&(n[e]=t[e]);for(let e of Mi)t[e]&&(n[e]=parseInt(t[e],10));return t.expression&&(n.expression=t.expression),n})}function Pi(e,t){return xi(e,t,!0,1)[0]}function Fi(e,t,n=!1){return Kr(xi(e,t,n,1)).trim()}function Ii(e,t,n,r,i=!1){let a=Fi(n,r,i);a&&(e[t]=a)}function Li(e){return e===`rss`||e===`feed`||e===`rdf:RDF`}var Ri=re({DocumentPosition:()=>Ti,append:()=>ai,appendChild:()=>ii,compareDocumentPosition:()=>Ei,existsOne:()=>fi,filter:()=>ci,find:()=>li,findAll:()=>pi,findOne:()=>di,findOneChild:()=>ui,getAttributeValue:()=>Zr,getChildren:()=>Jr,getElementById:()=>bi,getElements:()=>yi,getElementsByClassName:()=>Si,getElementsByTagName:()=>xi,getElementsByTagType:()=>Ci,getFeed:()=>Oi,getInnerHTML:()=>Wr,getName:()=>$r,getOuterHTML:()=>Ur,getParent:()=>Yr,getSiblings:()=>Xr,getText:()=>Gr,hasAttrib:()=>Qr,hasChildren:()=>_r,innerText:()=>qr,isCDATA:()=>fr,isComment:()=>mr,isDocument:()=>gr,isTag:()=>dr,isText:()=>pr,nextElementSibling:()=>ei,prepend:()=>si,prependChild:()=>oi,prevElementSibling:()=>ti,removeElement:()=>ni,removeSubsets:()=>wi,replaceElement:()=>ri,testElement:()=>vi,textContent:()=>Kr,uniqueSort:()=>Di}),zi=re({DefaultHandler:()=>xr,DomHandler:()=>xr,DomUtils:()=>Ri,ElementType:()=>Gn,Parser:()=>Wn,QuoteType:()=>jn,Tokenizer:()=>Nn,createDocumentStream:()=>Hi,createDomStream:()=>Ui,getFeed:()=>Oi,parseDOM:()=>Vi,parseDocument:()=>Bi,parseFeed:()=>Gi});function Bi(e,t){let n=new xr(void 0,t);return new Wn(n,t).end(e),n.root}function Vi(e,t){return Bi(e,t).children}function Hi(e,t,n){let r=new xr(t=>e(t,r.root),t,n);return new Wn(r,t)}function Ui(e,t,n){return new Wn(new xr(e,t,n),t)}const Wi={xmlMode:!0};function Gi(e,t=Wi){return Oi(Vi(e,t))}const Ki=new Set(`ARTICLE.ASIDE.BLOCKQUOTE.BODY.BR.BUTTON.CANVAS.CAPTION.COL.COLGROUP.DD.DIV.DL.DT.EMBED.FIELDSET.FIGCAPTION.FIGURE.FOOTER.FORM.H1.H2.H3.H4.H5.H6.LI.UL.OL.P`.split(`.`)),qi=`http://www.w3.org/2000/svg`,{assign:Ji,create:Yi,defineProperties:Xi,entries:Zi,getOwnPropertyDescriptors:Qi,keys:$i,setPrototypeOf:ea}=Object,ta=String,na=e=>e.nodeType===1?e[U]:e,ra=({ownerDocument:e})=>e[tn].ignoreCase,ia=(e,t)=>{e[W]=t,t[an]=e},aa=(e,t,n)=>{ia(e,t),ia(na(t),n)},oa=(e,t,n,r)=>{ia(e,t),ia(na(n),r)},sa=(e,t,n)=>{ia(e,t),ia(t,n)},ca=({localName:e,ownerDocument:t})=>t[tn].ignoreCase?e.toUpperCase():e,la=(e,t)=>{e&&(e[W]=t),t&&(t[an]=e)},ua=(e,t)=>{let n=e.createDocumentFragment(),r=e.createElement(``);r.innerHTML=t;let{firstChild:i,lastChild:a}=r;if(i){oa(n,i,a,n[U]);let e=i;do e.parentNode=n;while(e!==a&&(e=na(e)[W]))}return n},da=new WeakMap;let fa=!1;const pa=new WeakMap,ma=new WeakMap,ha=(e,t,n,r)=>{fa&&ma.has(e)&&e.attributeChangedCallback&&e.constructor.observedAttributes.includes(t)&&e.attributeChangedCallback(t,n,r)},ga=(e,t)=>n=>{if(ma.has(n)){let r=ma.get(n);r.connected!==t&&n.isConnected===t&&(r.connected=t,e in n&&n[e]())}},_a=ga(`connectedCallback`,!0),va=e=>{if(fa){_a(e),da.has(e)&&(e=da.get(e).shadowRoot);let{[W]:t,[U]:n}=e;for(;t!==n;)t.nodeType===1&&_a(t),t=t[W]}},ya=ga(`disconnectedCallback`,!1),ba=e=>{if(fa){ya(e),da.has(e)&&(e=da.get(e).shadowRoot);let{[W]:t,[U]:n}=e;for(;t!==n;)t.nodeType===1&&ya(t),t=t[W]}};var xa=class{constructor(e){this.ownerDocument=e,this.registry=new Map,this.waiting=new Map,this.active=!1}define(e,t,n={}){let{ownerDocument:r,registry:i,waiting:a}=this;if(i.has(e))throw Error(`unable to redefine `+e);if(pa.has(t))throw Error(`unable to redefine the same class: `+t);this.active=fa=!0;let{extends:o}=n;pa.set(t,{ownerDocument:r,options:{is:o?e:``},localName:o||e});let s=o?t=>t.localName===o&&t.getAttribute(`is`)===e:t=>t.localName===e;if(i.set(e,{Class:t,check:s}),a.has(e)){for(let n of a.get(e))n(t);a.delete(e)}r.querySelectorAll(o?`${o}[is="${e}"]`:e).forEach(this.upgrade,this)}upgrade(e){if(ma.has(e))return;let{ownerDocument:t,registry:n}=this,r=e.getAttribute(`is`)||e.localName;if(n.has(r)){let{Class:i,check:a}=n.get(r);if(a(e)){let{attributes:n,isConnected:a}=e;for(let t of n)e.removeAttributeNode(t);let o=Zi(e);for(let[t]of o)delete e[t];ea(e,i.prototype),t[un]={element:e,values:o},new i(t,r),ma.set(e,{connected:a});for(let t of n)e.setAttributeNode(t);a&&e.connectedCallback&&e.connectedCallback()}}}whenDefined(e){let{registry:t,waiting:n}=this;return new Promise(r=>{t.has(e)?r(t.get(e).Class):(n.has(e)||n.set(e,[]),n.get(e).push(r))})}get(e){let t=this.registry.get(e);return t&&t.Class}getName(e){if(pa.has(e)){let{localName:t}=pa.get(e);return t}return null}};const{Parser:Sa}=zi,Ca=(e,t,n)=>{let r=e[U];return t.parentNode=e,aa(r[an],t,r),n&&t.nodeType===1&&va(t),t},wa=(e,t,n,r,i)=>{n[dn]=r,n.ownerElement=e,sa(t[an],n,t),n.name===`class`&&(e.className=r),i&&ha(e,n.name,null,r)},Ta=(e,t,n)=>{let{active:r,registry:i}=e[Yt],a=e,o=null,s=!1,c=new Sa({onprocessinginstruction(t,n){t.toLowerCase()===`!doctype`&&(e.doctype=n.slice(t.length).trim())},onopentag(n,s){let c=!0;if(t){if(o)a=Ca(a,e.createElementNS(qi,n),r),a.ownerSVGElement=o,c=!1;else if(n===`svg`||n===`SVG`)o=e.createElementNS(qi,n),a=Ca(a,o,r),c=!1;else if(r){let e=n.includes(`-`)?n:s.is||``;if(e&&i.has(e)){let{Class:t}=i.get(e);a=Ca(a,new t,r),delete s.is,c=!1}}}c&&(a=Ca(a,e.createElement(n),!1));let l=a[U];for(let t of $i(s))wa(a,l,e.createAttribute(t),s[t],r)},oncomment(t){Ca(a,e.createComment(t),r)},ontext(t){s?Ca(a,e.createCDATASection(t),r):Ca(a,e.createTextNode(t),r)},oncdatastart(){s=!0},oncdataend(){s=!1},onclosetag(){t&&a===o&&(o=null),a=a.parentNode}},{lowerCaseAttributeNames:!1,decodeEntities:!0,xmlMode:!t});return c.write(n),c.end(),e},Ea=new Map,Da=(e,t)=>{for(let n of[].concat(e))Ea.set(n,t),Ea.set(n.toUpperCase(),t)},Oa=({[W]:e,[U]:t},n)=>{for(;e!==t;){switch(e.nodeType){case 2:ka(e,n);break;case 3:case 8:case 4:Aa(e,n);break;case 1:Na(e,n),e=na(e);break;case 10:Ma(e,n);break}e=e[W]}let r=n.length-1,i=n[r];typeof i==`number`&&i<0?n[r]+=-1:n.push(-1)},ka=(e,t)=>{t.push(2,e.name);let n=e[dn].trim();n&&t.push(n)},Aa=(e,t)=>{let n=e[dn];n.trim()&&t.push(e.nodeType,n)},ja=(e,t)=>{t.push(e.nodeType),Oa(e,t)},Ma=({name:e,publicId:t,systemId:n},r)=>{r.push(10,e),t&&r.push(t),n&&r.push(n)},Na=(e,t)=>{t.push(1,e.localName),Oa(e,t)},Pa=(e,t,n,r,i,a,o)=>({type:e,target:t,addedNodes:r,removedNodes:i,attributeName:a,oldValue:o,previousSibling:n?.previousSibling||null,nextSibling:n?.nextSibling||null}),Fa=(e,t,n,r,i,a)=>{if(!r||r.includes(n)){let{callback:r,records:o,scheduled:s}=e;o.push(Pa(`attributes`,t,null,[],[],n,i?a:void 0)),s||(e.scheduled=!0,Promise.resolve().then(()=>{e.scheduled=!1,r(o.splice(0),e)}))}},Ia=(e,t,n)=>{let{ownerDocument:r}=e,{active:i,observers:a}=r[nn];if(i){for(let i of a)for(let[a,{childList:o,subtree:s,attributes:c,attributeFilter:l,attributeOldValue:u}]of i.nodes)if(o){if(s&&(a===r||a.contains(e))||!s&&a.children.includes(e)){Fa(i,e,t,l,u,n);break}}else if(c&&a===e){Fa(i,e,t,l,u,n);break}}},La=(e,t)=>{let{ownerDocument:n}=e,{active:r,observers:i}=n[nn];if(r){for(let r of i)for(let[i,{subtree:a,childList:o,characterData:s}]of r.nodes)if(o&&(t&&(i===t||a&&i.contains(t))||!t&&(a&&(i===n||i.contains(e))||!a&&i[s?`childNodes`:`children`].includes(e)))){let{callback:n,records:a,scheduled:o}=r;a.push(Pa(`childList`,i,e,t?[]:[e],t?[e]:[])),o||(r.scheduled=!0,Promise.resolve().then(()=>{r.scheduled=!1,n(a.splice(0),r)}));break}}};var Ra=class{constructor(e){let t=new Set;this.observers=t,this.active=!1,this.class=class{constructor(e){this.callback=e,this.nodes=new Map,this.records=[],this.scheduled=!1}disconnect(){this.records.splice(0),this.nodes.clear(),t.delete(this),e[nn].active=!!t.size}observe(n,r={subtree:!1,childList:!1,attributes:!1,attributeFilter:null,attributeOldValue:!1,characterData:!1}){(`attributeOldValue`in r||`attributeFilter`in r)&&(r.attributes=!0),r.childList=!!r.childList,r.subtree=!!r.subtree,this.nodes.set(n,r),t.add(this),e[nn].active=!0}takeRecords(){return this.records.splice(0)}}}};const za=new Set(`allowfullscreen.allowpaymentrequest.async.autofocus.autoplay.checked.class.contenteditable.controls.default.defer.disabled.draggable.formnovalidate.hidden.id.ismap.itemscope.loop.multiple.muted.nomodule.novalidate.open.playsinline.readonly.required.reversed.selected.style.truespeed`.split(`.`)),Ba=(e,t)=>{let{[dn]:n,name:r}=t;t.ownerElement=e,sa(e,t,e[W]),r===`class`&&(e.className=n),Ia(e,r,null),ha(e,r,null,n)},Va=(e,t)=>{let{[dn]:n,name:r}=t;ia(t[an],t[W]),t.ownerElement=t[an]=t[W]=null,r===`class`&&(e[Jt]=null),Ia(e,r,n),ha(e,r,n,null)},Ha={get(e,t){return e.hasAttribute(t)},set(e,t,n){n?e.setAttribute(t,``):e.removeAttribute(t)}},Ua={get(e,t){return parseFloat(e.getAttribute(t)||0)},set(e,t,n){e.setAttribute(t,n)}},Y={get(e,t){return e.getAttribute(t)||``},set(e,t,n){e.setAttribute(t,n)}},Wa=new WeakMap;function Ga(e,t){return typeof t==`function`?t.call(e.target,e):t.handleEvent(e),e._stopImmediatePropagationFlag}function Ka({currentTarget:e,target:t}){let n=Wa.get(e);if(n&&n.has(this.type)){let r=n.get(this.type);e===t?this.eventPhase=this.AT_TARGET:this.eventPhase=this.BUBBLING_PHASE,this.currentTarget=e,this.target=t;for(let[e,t]of r)if(t&&t.once&&r.delete(e),Ga(this,e))break;return delete this.currentTarget,delete this.target,this.cancelBubble}}var qa=class{constructor(){Wa.set(this,new Map)}_getParent(){return null}addEventListener(e,t,n){let r=Wa.get(this);r.has(e)||r.set(e,new Map),r.get(e).set(t,n)}removeEventListener(e,t){let n=Wa.get(this);if(n.has(e)){let r=n.get(e);r.delete(t)&&!r.size&&n.delete(e)}}dispatchEvent(e){let t=this;for(e.eventPhase=e.CAPTURING_PHASE;t;)t.dispatchEvent&&e._path.push({currentTarget:t,target:this}),t=e.bubbles&&t._getParent&&t._getParent();return e._path.some(Ka,e),e._path=[],e.eventPhase=e.NONE,!e.defaultPrevented}},Ja=class extends Array{item(e){return e<this.length?this[e]:null}};const Ya=({parentNode:e})=>{let t=0;for(;e;)t++,e=e.parentNode;return t};var Xa=class extends qa{static get ELEMENT_NODE(){return 1}static get ATTRIBUTE_NODE(){return 2}static get TEXT_NODE(){return 3}static get CDATA_SECTION_NODE(){return 4}static get COMMENT_NODE(){return 8}static get DOCUMENT_NODE(){return 9}static get DOCUMENT_FRAGMENT_NODE(){return 11}static get DOCUMENT_TYPE_NODE(){return 10}constructor(e,t,n){super(),this.ownerDocument=e,this.localName=t,this.nodeType=n,this.parentNode=null,this[W]=null,this[an]=null}get ELEMENT_NODE(){return 1}get ATTRIBUTE_NODE(){return 2}get TEXT_NODE(){return 3}get CDATA_SECTION_NODE(){return 4}get COMMENT_NODE(){return 8}get DOCUMENT_NODE(){return 9}get DOCUMENT_FRAGMENT_NODE(){return 11}get DOCUMENT_TYPE_NODE(){return 10}get baseURI(){let e=this.nodeType===9?this:this.ownerDocument;if(e){let t=e.querySelector(`base`);if(t)return t.getAttribute(`href`);let{location:n}=e.defaultView;if(n)return n.href}return null}get isConnected(){return!1}get nodeName(){return this.localName}get parentElement(){return null}get previousSibling(){return null}get previousElementSibling(){return null}get nextSibling(){return null}get nextElementSibling(){return null}get childNodes(){return new Ja}get firstChild(){return null}get lastChild(){return null}get nodeValue(){return null}set nodeValue(e){}get textContent(){return null}set textContent(e){}normalize(){}cloneNode(){return null}contains(){return!1}insertBefore(e,t){return e}appendChild(e){return e}replaceChild(e,t){return t}removeChild(e){return e}toString(){return``}hasChildNodes(){return!!this.lastChild}isSameNode(e){return this===e}compareDocumentPosition(e){let t=0;if(this!==e){let n=Ya(this),r=Ya(e);if(n<r)t+=4,this.contains(e)&&(t+=16);else if(r<n)t+=2,e.contains(this)&&(t+=8);else if(n&&r){let{childNodes:n}=this.parentNode;n.indexOf(this)<n.indexOf(e)?t+=4:t+=2}(!n||!r)&&(t+=32,t+=1)}return t}isEqualNode(e){if(this===e)return!0;if(this.nodeType===e.nodeType){switch(this.nodeType){case 9:case 11:{let t=this.childNodes,n=e.childNodes;return t.length===n.length&&t.every((e,t)=>e.isEqualNode(n[t]))}}return this.toString()===e.toString()}return!1}_getParent(){return this.parentNode}getRootNode(){let e=this;for(;e.parentNode;)e=e.parentNode;return e}};const{replace:Za}=``,Qa=/[<>&\xA0]/g,$a={"\xA0":` `,"&":`&`,"<":`<`,">":`>`},eo=e=>$a[e],to=e=>Za.call(e,Qa,eo),no=/"/g;var ro=class e extends Xa{constructor(e,t,n=``){super(e,t,2),this.ownerElement=null,this.name=ta(t),this[dn]=ta(n),this[qt]=!1}get value(){return this[dn]}set value(e){let{[dn]:t,name:n,ownerElement:r}=this;this[dn]=ta(e),this[qt]=!0,r&&(Ia(r,n,t),ha(r,n,t,this[dn]))}cloneNode(){let{ownerDocument:t,name:n,[dn]:r}=this;return new e(t,n,r)}toString(){let{name:e,[dn]:t}=this;return za.has(e)&&!t?ra(this)?e:`${e}=""`:`${e}="${(ra(this)?t:to(t)).replace(no,`"`)}"`}toJSON(){let e=[];return ka(this,e),e}};const io=({ownerDocument:e,parentNode:t})=>{for(;t;){if(t===e)return!0;t=t.parentNode||t.host}return!1},ao=({parentNode:e})=>{if(e)switch(e.nodeType){case 9:case 11:return null}return e},oo=({[an]:e})=>{switch(e?e.nodeType:0){case-1:return e[cn];case 3:case 8:case 4:return e}return null},so=e=>{let t=na(e)[W];return t&&(t.nodeType===-1?null:t)},co=e=>{let t=so(e);for(;t&&t.nodeType!==1;)t=so(t);return t},lo=e=>{let t=oo(e);for(;t&&t.nodeType!==1;)t=oo(t);return t},uo=(e,t)=>{let n=e.createDocumentFragment();return n.append(...t),n},fo=(e,t)=>{let{ownerDocument:n,parentNode:r}=e;r&&r.insertBefore(uo(n,t),e)},po=(e,t)=>{let{ownerDocument:n,parentNode:r}=e;r&&r.insertBefore(uo(n,t),na(e)[W])},mo=(e,t)=>{let{ownerDocument:n,parentNode:r}=e;r&&(t.includes(e)&&mo(e,[e=e.cloneNode()]),r.insertBefore(uo(n,t),e),e.remove())},ho=(e,t,n)=>{let{parentNode:r,nodeType:i}=t;(e||n)&&(la(e,n),t[an]=null,na(t)[W]=null),r&&(t.parentNode=null,La(t,r),i===1&&ba(t))};var go=class extends Xa{constructor(e,t,n,r){super(e,t,n),this[dn]=ta(r)}get isConnected(){return io(this)}get parentElement(){return ao(this)}get previousSibling(){return oo(this)}get nextSibling(){return so(this)}get previousElementSibling(){return lo(this)}get nextElementSibling(){return co(this)}before(...e){fo(this,e)}after(...e){po(this,e)}replaceWith(...e){mo(this,e)}remove(){ho(this[an],this,this[W])}get data(){return this[dn]}set data(e){this[dn]=ta(e),La(this,this.parentNode)}get nodeValue(){return this.data}set nodeValue(e){this.data=e}get textContent(){return this.data}set textContent(e){this.data=e}get length(){return this.data.length}substringData(e,t){return this.data.substr(e,t)}appendData(e){this.data+=e}insertData(e,t){let{data:n}=this;this.data=n.slice(0,e)+t+n.slice(e)}deleteData(e,t){let{data:n}=this;this.data=n.slice(0,e)+n.slice(e+t)}replaceData(e,t,n){let{data:r}=this;this.data=r.slice(0,e)+n+r.slice(e+t)}toJSON(){let e=[];return Aa(this,e),e}},_o=class e extends go{constructor(e,t=``){super(e,`#cdatasection`,4,t)}cloneNode(){let{ownerDocument:t,[dn]:n}=this;return new e(t,n)}toString(){return`<![CDATA[${this[dn]}]]>`}},vo=class e extends go{constructor(e,t=``){super(e,`#comment`,8,t)}cloneNode(){let{ownerDocument:t,[dn]:n}=this;return new e(t,n)}toString(){return`<!--${this[dn]}-->`}},yo=O(((e,t)=>{t.exports={trueFunc:function(){return!0},falseFunc:function(){return!1}}})),bo=O((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.AttributeAction=e.IgnoreCaseMode=e.SelectorType=void 0,(function(e){e.Attribute=`attribute`,e.Pseudo=`pseudo`,e.PseudoElement=`pseudo-element`,e.Tag=`tag`,e.Universal=`universal`,e.Adjacent=`adjacent`,e.Child=`child`,e.Descendant=`descendant`,e.Parent=`parent`,e.Sibling=`sibling`,e.ColumnCombinator=`column-combinator`})(e.SelectorType||={}),e.IgnoreCaseMode={Unknown:null,QuirksMode:`quirks`,IgnoreCase:!0,CaseSensitive:!1},(function(e){e.Any=`any`,e.Element=`element`,e.End=`end`,e.Equals=`equals`,e.Exists=`exists`,e.Hyphen=`hyphen`,e.Not=`not`,e.Start=`start`})(e.AttributeAction||={})})),xo=O((e=>{Object.defineProperty(e,`__esModule`,{value:!0}),e.parse=e.isTraversal=void 0;var t=bo(),n=/^[^\\#]?(?:\\(?:[\da-f]{1,6}\s?|.)|[\w\-\u00b0-\uFFFF])+/,r=/\\([\da-f]{1,6}\s?|(\s)|.)/gi,i=new Map([[126,t.AttributeAction.Element],[94,t.AttributeAction.Start],[36,t.AttributeAction.End],[42,t.AttributeAction.Any],[33,t.AttributeAction.Not],[124,t.AttributeAction.Hyphen]]),a=new Set([`has`,`not`,`matches`,`is`,`where`,`host`,`host-context`]);function o(e){switch(e.type){case t.SelectorType.Adjacent:case t.SelectorType.Child:case t.SelectorType.Descendant:case t.SelectorType.Parent:case t.SelectorType.Sibling:case t.SelectorType.ColumnCombinator:return!0;default:return!1}}e.isTraversal=o;var s=new Set([`contains`,`icontains`]);function c(e,t,n){var r=parseInt(t,16)-65536;return r!==r||n?t:r<0?String.fromCharCode(r+65536):String.fromCharCode(r>>10|55296,r&1023|56320)}function l(e){return e.replace(r,c)}function u(e){return e===39||e===34}function d(e){return e===32||e===9||e===10||e===12||e===13}function f(e){var t=[],n=p(t,`${e}`,0);if(n<e.length)throw Error(`Unmatched selector: ${e.slice(n)}`);return t}e.parse=f;function p(e,r,c){var f=[];function m(e){var t=r.slice(c+e).match(n);if(!t)throw Error(`Expected name, found ${r.slice(c)}`);var i=t[0];return c+=e+i.length,l(i)}function h(e){for(c+=e;c<r.length&&d(r.charCodeAt(c));)c++}function g(){c+=1;for(var e=c,t=1;t>0&&c<r.length;c++)r.charCodeAt(c)===40&&!_(c)?t++:r.charCodeAt(c)===41&&!_(c)&&t--;if(t)throw Error(`Parenthesis not matched`);return l(r.slice(e,c-1))}function _(e){for(var t=0;r.charCodeAt(--e)===92;)t++;return(t&1)==1}function v(){if(f.length>0&&o(f[f.length-1]))throw Error(`Did not expect successive traversals.`)}function y(e){if(f.length>0&&f[f.length-1].type===t.SelectorType.Descendant){f[f.length-1].type=e;return}v(),f.push({type:e})}function b(e,n){f.push({type:t.SelectorType.Attribute,name:e,action:n,value:m(1),namespace:null,ignoreCase:`quirks`})}function x(){if(f.length&&f[f.length-1].type===t.SelectorType.Descendant&&f.pop(),f.length===0)throw Error(`Empty sub-selector`);e.push(f)}if(h(0),r.length===c)return c;loop:for(;c<r.length;){var S=r.charCodeAt(c);switch(S){case 32:case 9:case 10:case 12:case 13:(f.length===0||f[0].type!==t.SelectorType.Descendant)&&(v(),f.push({type:t.SelectorType.Descendant})),h(1);break;case 62:y(t.SelectorType.Child),h(1);break;case 60:y(t.SelectorType.Parent),h(1);break;case 126:y(t.SelectorType.Sibling),h(1);break;case 43:y(t.SelectorType.Adjacent),h(1);break;case 46:b(`class`,t.AttributeAction.Element);break;case 35:b(`id`,t.AttributeAction.Equals);break;case 91:h(1);var C=void 0,w=null;r.charCodeAt(c)===124?C=m(1):r.startsWith(`*|`,c)?(w=`*`,C=m(2)):(C=m(0),r.charCodeAt(c)===124&&r.charCodeAt(c+1)!==61&&(w=C,C=m(1))),h(0);var T=t.AttributeAction.Exists,E=i.get(r.charCodeAt(c));if(E){if(T=E,r.charCodeAt(c+1)!==61)throw Error("Expected `=`");h(2)}else r.charCodeAt(c)===61&&(T=t.AttributeAction.Equals,h(1));var ee=``,te=null;if(T!==`exists`){if(u(r.charCodeAt(c))){for(var ne=r.charCodeAt(c),D=c+1;D<r.length&&(r.charCodeAt(D)!==ne||_(D));)D+=1;if(r.charCodeAt(D)!==ne)throw Error(`Attribute value didn't end`);ee=l(r.slice(c+1,D)),c=D+1}else{for(var O=c;c<r.length&&(!d(r.charCodeAt(c))&&r.charCodeAt(c)!==93||_(c));)c+=1;ee=l(r.slice(O,c))}h(0);var re=r.charCodeAt(c)|32;re===115?(te=!1,h(1)):re===105&&(te=!0,h(1))}if(r.charCodeAt(c)!==93)throw Error(`Attribute selector didn't terminate`);c+=1;var ie={type:t.SelectorType.Attribute,name:C,action:T,value:ee,namespace:w,ignoreCase:te};f.push(ie);break;case 58:if(r.charCodeAt(c+1)===58){f.push({type:t.SelectorType.PseudoElement,name:m(2).toLowerCase(),data:r.charCodeAt(c)===40?g():null});continue}var ae=m(1).toLowerCase(),k=null;if(r.charCodeAt(c)===40)if(a.has(ae)){if(u(r.charCodeAt(c+1)))throw Error(`Pseudo-selector ${ae} cannot be quoted`);if(k=[],c=p(k,r,c+1),r.charCodeAt(c)!==41)throw Error(`Missing closing parenthesis in :${ae} (${r})`);c+=1}else{if(k=g(),s.has(ae)){var oe=k.charCodeAt(0);oe===k.charCodeAt(k.length-1)&&u(oe)&&(k=k.slice(1,-1))}k=l(k)}f.push({type:t.SelectorType.Pseudo,name:ae,data:k});break;case 44:x(),f=[],h(1);break;default:if(r.startsWith(`/*`,c)){var se=r.indexOf(`*/`,c+2);if(se<0)throw Error(`Comment was not terminated`);c=se+2,f.length===0&&h(0);break}var w=null,ce=void 0;if(S===42)c+=1,ce=`*`;else if(S===124){if(ce=``,r.charCodeAt(c+1)===124){y(t.SelectorType.ColumnCombinator),h(2);break}}else if(n.test(r.slice(c)))ce=m(0);else break loop;r.charCodeAt(c)===124&&r.charCodeAt(c+1)!==124&&(w=ce,r.charCodeAt(c+1)===42?(ce=`*`,c+=2):ce=m(1)),f.push(ce===`*`?{type:t.SelectorType.Universal,namespace:w}:{type:t.SelectorType.Tag,name:ce,namespace:w})}}return x(),c}})),So=O((e=>{var t=e&&e.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var r=0,i=t.length,a;r<i;r++)(a||!(r in t))&&(a||=Array.prototype.slice.call(t,0,r),a[r]=t[r]);return e.concat(a||Array.prototype.slice.call(t))};Object.defineProperty(e,`__esModule`,{value:!0}),e.stringify=void 0;var n=bo(),r=[`\\`,`"`],i=t(t([],r,!0),[`(`,`)`],!1),a=new Set(r.map(function(e){return e.charCodeAt(0)})),o=new Set(i.map(function(e){return e.charCodeAt(0)})),s=new Set(t(t([],i,!0),[`~`,`^`,`$`,`*`,`+`,`!`,`|`,`:`,`[`,`]`,` `,`.`],!1).map(function(e){return e.charCodeAt(0)}));function c(e){return e.map(function(e){return e.map(l).join(``)}).join(`, `)}e.stringify=c;function l(e,t,r){switch(e.type){case n.SelectorType.Child:return t===0?`> `:` > `;case n.SelectorType.Parent:return t===0?`< `:` < `;case n.SelectorType.Sibling:return t===0?`~ `:` ~ `;case n.SelectorType.Adjacent:return t===0?`+ `:` + `;case n.SelectorType.Descendant:return` `;case n.SelectorType.ColumnCombinator:return t===0?`|| `:` || `;case n.SelectorType.Universal:return e.namespace===`*`&&t+1<r.length&&`name`in r[t+1]?``:`${f(e.namespace)}*`;case n.SelectorType.Tag:return d(e);case n.SelectorType.PseudoElement:return`::${p(e.name,s)}${e.data===null?``:`(${p(e.data,o)})`}`;case n.SelectorType.Pseudo:return`:${p(e.name,s)}${e.data===null?``:`(${typeof e.data==`string`?p(e.data,o):c(e.data)})`}`;case n.SelectorType.Attribute:if(e.name===`id`&&e.action===n.AttributeAction.Equals&&e.ignoreCase===`quirks`&&!e.namespace)return`#${p(e.value,s)}`;if(e.name===`class`&&e.action===n.AttributeAction.Element&&e.ignoreCase===`quirks`&&!e.namespace)return`.${p(e.value,s)}`;var i=d(e);return e.action===n.AttributeAction.Exists?`[${i}]`:`[${i}${u(e.action)}="${p(e.value,a)}"${e.ignoreCase===null?``:e.ignoreCase?` i`:` s`}]`}}function u(e){switch(e){case n.AttributeAction.Equals:return``;case n.AttributeAction.Element:return`~`;case n.AttributeAction.Start:return`^`;case n.AttributeAction.End:return`$`;case n.AttributeAction.Any:return`*`;case n.AttributeAction.Not:return`!`;case n.AttributeAction.Hyphen:return`|`;case n.AttributeAction.Exists:throw Error(`Shouldn't be here`)}}function d(e){return`${f(e.namespace)}${p(e.name,s)}`}function f(e){return e===null?``:`${e===`*`?`*`:p(e,s)}|`}function p(e,t){for(var n=0,r=``,i=0;i<e.length;i++)t.has(e.charCodeAt(i))&&(r+=`${e.slice(n,i)}\\${e.charAt(i)}`,n=i+1);return r.length>0?r+e.slice(n):e}})),Co=O((e=>{var t=e&&e.__createBinding||(Object.create?(function(e,t,n,r){r===void 0&&(r=n);var i=Object.getOwnPropertyDescriptor(t,n);(!i||(`get`in i?!t.__esModule:i.writable||i.configurable))&&(i={enumerable:!0,get:function(){return t[n]}}),Object.defineProperty(e,r,i)}):(function(e,t,n,r){r===void 0&&(r=n),e[r]=t[n]})),n=e&&e.__exportStar||function(e,n){for(var r in e)r!==`default`&&!Object.prototype.hasOwnProperty.call(n,r)&&t(n,e,r)};Object.defineProperty(e,`__esModule`,{value:!0}),e.stringify=e.parse=e.isTraversal=void 0,n(bo(),e);var r=xo();Object.defineProperty(e,`isTraversal`,{enumerable:!0,get:function(){return r.isTraversal}}),Object.defineProperty(e,`parse`,{enumerable:!0,get:function(){return r.parse}});var i=So();Object.defineProperty(e,`stringify`,{enumerable:!0,get:function(){return i.stringify}})})),X=ae(yo(),1),Z=Co();const wo=new Map([[Z.SelectorType.Universal,50],[Z.SelectorType.Tag,30],[Z.SelectorType.Attribute,1],[Z.SelectorType.Pseudo,0]]);function To(e){return!wo.has(e.type)}const Eo=new Map([[Z.AttributeAction.Exists,10],[Z.AttributeAction.Equals,8],[Z.AttributeAction.Not,7],[Z.AttributeAction.Start,6],[Z.AttributeAction.End,6],[Z.AttributeAction.Any,5]]);function Do(e){let t=e.map(Oo);for(let n=1;n<e.length;n++){let r=t[n];if(!(r<0))for(let i=n-1;i>=0&&r<t[i];i--){let n=e[i+1];e[i+1]=e[i],e[i]=n,t[i+1]=t[i],t[i]=r}}}function Oo(e){let t=wo.get(e.type)??-1;return e.type===Z.SelectorType.Attribute?(t=Eo.get(e.action)??4,e.action===Z.AttributeAction.Equals&&e.name===`id`&&(t=9),e.ignoreCase&&(t>>=1)):e.type===Z.SelectorType.Pseudo&&(e.data?e.name===`has`||e.name===`contains`?t=0:Array.isArray(e.data)?(t=Math.min(...e.data.map(e=>Math.min(...e.map(Oo)))),t<0&&(t=0)):t=2:t=3),t}const ko=/[-[\]{}()*+?.,\\^$|#\s]/g;function Ao(e){return e.replace(ko,`\\$&`)}const jo=new Set(`accept.accept-charset.align.alink.axis.bgcolor.charset.checked.clear.codetype.color.compact.declare.defer.dir.direction.disabled.enctype.face.frame.hreflang.http-equiv.lang.language.link.media.method.multiple.nohref.noresize.noshade.nowrap.readonly.rel.rev.rules.scope.scrolling.selected.shape.target.text.type.valign.valuetype.vlink`.split(`.`));function Mo(e,t){return typeof e.ignoreCase==`boolean`?e.ignoreCase:e.ignoreCase===`quirks`?!!t.quirksMode:!t.xmlMode&&jo.has(e.name)}const No={equals(e,t,n){let{adapter:r}=n,{name:i}=t,{value:a}=t;return Mo(t,n)?(a=a.toLowerCase(),t=>{let n=r.getAttributeValue(t,i);return n!=null&&n.length===a.length&&n.toLowerCase()===a&&e(t)}):t=>r.getAttributeValue(t,i)===a&&e(t)},hyphen(e,t,n){let{adapter:r}=n,{name:i}=t,{value:a}=t,o=a.length;return Mo(t,n)?(a=a.toLowerCase(),function(t){let n=r.getAttributeValue(t,i);return n!=null&&(n.length===o||n.charAt(o)===`-`)&&n.substr(0,o).toLowerCase()===a&&e(t)}):function(t){let n=r.getAttributeValue(t,i);return n!=null&&(n.length===o||n.charAt(o)===`-`)&&n.substr(0,o)===a&&e(t)}},element(e,t,n){let{adapter:r}=n,{name:i,value:a}=t;if(/\s/.test(a))return X.default.falseFunc;let o=RegExp(`(?:^|\\s)${Ao(a)}(?:$|\\s)`,Mo(t,n)?`i`:``);return function(t){let n=r.getAttributeValue(t,i);return n!=null&&n.length>=a.length&&o.test(n)&&e(t)}},exists(e,{name:t},{adapter:n}){return r=>n.hasAttrib(r,t)&&e(r)},start(e,t,n){let{adapter:r}=n,{name:i}=t,{value:a}=t,o=a.length;return o===0?X.default.falseFunc:Mo(t,n)?(a=a.toLowerCase(),t=>{let n=r.getAttributeValue(t,i);return n!=null&&n.length>=o&&n.substr(0,o).toLowerCase()===a&&e(t)}):t=>!!r.getAttributeValue(t,i)?.startsWith(a)&&e(t)},end(e,t,n){let{adapter:r}=n,{name:i}=t,{value:a}=t,o=-a.length;return o===0?X.default.falseFunc:Mo(t,n)?(a=a.toLowerCase(),t=>r.getAttributeValue(t,i)?.substr(o).toLowerCase()===a&&e(t)):t=>!!r.getAttributeValue(t,i)?.endsWith(a)&&e(t)},any(e,t,n){let{adapter:r}=n,{name:i,value:a}=t;if(a===``)return X.default.falseFunc;if(Mo(t,n)){let t=new RegExp(Ao(a),`i`);return function(n){let o=r.getAttributeValue(n,i);return o!=null&&o.length>=a.length&&t.test(o)&&e(n)}}return t=>!!r.getAttributeValue(t,i)?.includes(a)&&e(t)},not(e,t,n){let{adapter:r}=n,{name:i}=t,{value:a}=t;return a===``?t=>!!r.getAttributeValue(t,i)&&e(t):Mo(t,n)?(a=a.toLowerCase(),t=>{let n=r.getAttributeValue(t,i);return(n==null||n.length!==a.length||n.toLowerCase()!==a)&&e(t)}):t=>r.getAttributeValue(t,i)!==a&&e(t)}},Po=new Set([9,10,12,13,32]);function Fo(e){if(e=e.trim().toLowerCase(),e===`even`)return[2,0];if(e===`odd`)return[2,1];let t=0,n=0,r=a(),i=o();if(t<e.length&&e.charAt(t)===`n`&&(t++,n=r*(i??1),s(),t<e.length?(r=a(),s(),i=o()):r=i=0),i===null||t<e.length)throw Error(`n-th rule couldn't be parsed ('${e}')`);return[n,r*i];function a(){return e.charAt(t)===`-`?(t++,-1):(e.charAt(t)===`+`&&t++,1)}function o(){let n=t,r=0;for(;t<e.length&&e.charCodeAt(t)>=48&&e.charCodeAt(t)<=57;)r=r*10+(e.charCodeAt(t)-48),t++;return t===n?null:r}function s(){for(;t<e.length&&Po.has(e.charCodeAt(t));)t++}}function Io(e){let t=e[0],n=e[1]-1;if(n<0&&t<=0)return X.default.falseFunc;if(t===-1)return e=>e<=n;if(t===0)return e=>e===n;if(t===1)return n<0?X.default.trueFunc:e=>e>=n;let r=Math.abs(t),i=(n%r+r)%r;return t>1?e=>e>=n&&e%r===i:e=>e<=n&&e%r===i}function Lo(e){return Io(Fo(e))}function Ro(e,t){return n=>{let r=t.getParent(n);return r!=null&&t.isTag(r)&&e(n)}}const zo={contains(e,t,{adapter:n}){return function(r){return e(r)&&n.getText(r).includes(t)}},icontains(e,t,{adapter:n}){let r=t.toLowerCase();return function(t){return e(t)&&n.getText(t).toLowerCase().includes(r)}},"nth-child"(e,t,{adapter:n,equals:r}){let i=Lo(t);return i===X.default.falseFunc?X.default.falseFunc:i===X.default.trueFunc?Ro(e,n):function(t){let a=n.getSiblings(t),o=0;for(let e=0;e<a.length&&!r(t,a[e]);e++)n.isTag(a[e])&&o++;return i(o)&&e(t)}},"nth-last-child"(e,t,{adapter:n,equals:r}){let i=Lo(t);return i===X.default.falseFunc?X.default.falseFunc:i===X.default.trueFunc?Ro(e,n):function(t){let a=n.getSiblings(t),o=0;for(let e=a.length-1;e>=0&&!r(t,a[e]);e--)n.isTag(a[e])&&o++;return i(o)&&e(t)}},"nth-of-type"(e,t,{adapter:n,equals:r}){let i=Lo(t);return i===X.default.falseFunc?X.default.falseFunc:i===X.default.trueFunc?Ro(e,n):function(t){let a=n.getSiblings(t),o=0;for(let e=0;e<a.length;e++){let i=a[e];if(r(t,i))break;n.isTag(i)&&n.getName(i)===n.getName(t)&&o++}return i(o)&&e(t)}},"nth-last-of-type"(e,t,{adapter:n,equals:r}){let i=Lo(t);return i===X.default.falseFunc?X.default.falseFunc:i===X.default.trueFunc?Ro(e,n):function(t){let a=n.getSiblings(t),o=0;for(let e=a.length-1;e>=0;e--){let i=a[e];if(r(t,i))break;n.isTag(i)&&n.getName(i)===n.getName(t)&&o++}return i(o)&&e(t)}},root(e,t,{adapter:n}){return t=>{let r=n.getParent(t);return(r==null||!n.isTag(r))&&e(t)}},scope(e,t,n,r){let{equals:i}=n;return!r||r.length===0?zo.root(e,t,n):r.length===1?t=>i(r[0],t)&&e(t):t=>r.includes(t)&&e(t)},hover:Bo(`isHovered`),visited:Bo(`isVisited`),active:Bo(`isActive`)};function Bo(e){return function(t,n,{adapter:r}){let i=r[e];return typeof i==`function`?function(e){return i(e)&&t(e)}:X.default.falseFunc}}const Vo={empty(e,{adapter:t}){return!t.getChildren(e).some(e=>t.isTag(e)||t.getText(e)!==``)},"first-child"(e,{adapter:t,equals:n}){if(t.prevElementSibling)return t.prevElementSibling(e)==null;let r=t.getSiblings(e).find(e=>t.isTag(e));return r!=null&&n(e,r)},"last-child"(e,{adapter:t,equals:n}){let r=t.getSiblings(e);for(let i=r.length-1;i>=0;i--){if(n(e,r[i]))return!0;if(t.isTag(r[i]))break}return!1},"first-of-type"(e,{adapter:t,equals:n}){let r=t.getSiblings(e),i=t.getName(e);for(let a=0;a<r.length;a++){let o=r[a];if(n(e,o))return!0;if(t.isTag(o)&&t.getName(o)===i)break}return!1},"last-of-type"(e,{adapter:t,equals:n}){let r=t.getSiblings(e),i=t.getName(e);for(let a=r.length-1;a>=0;a--){let o=r[a];if(n(e,o))return!0;if(t.isTag(o)&&t.getName(o)===i)break}return!1},"only-of-type"(e,{adapter:t,equals:n}){let r=t.getName(e);return t.getSiblings(e).every(i=>n(e,i)||!t.isTag(i)||t.getName(i)!==r)},"only-child"(e,{adapter:t,equals:n}){return t.getSiblings(e).every(r=>n(e,r)||!t.isTag(r))}};function Ho(e,t,n,r){if(n===null){if(e.length>r)throw Error(`Pseudo-class :${t} requires an argument`)}else if(e.length===r)throw Error(`Pseudo-class :${t} doesn't have any arguments`)}const Uo={"any-link":`:is(a, area, link)[href]`,link:`:any-link:not(:visited)`,disabled:`:is(
|
|
@@ -289,37 +289,764 @@ TP=test point.
|
|
|
289
289
|
**Multi-page designs:** Ports bridge nets across pages. Same net name on
|
|
290
290
|
multiple pages = same electrical connection.
|
|
291
291
|
|
|
292
|
-
|
|
292
|
+
**Page names are organizational, not architectural.** They help humans navigate
|
|
293
|
+
the schematic but carry no technical authority. The same subcircuit can be
|
|
294
|
+
renamed, split across pages, or merged — only connectivity proves what a
|
|
295
|
+
section of the design actually does.
|
|
293
296
|
|
|
294
|
-
|
|
297
|
+
## Exploring a design
|
|
298
|
+
|
|
299
|
+
A schematic is a connectivity graph. Understanding a design means understanding
|
|
300
|
+
which components talk to each other, through what signals, and what crosses
|
|
301
|
+
the board boundary. Parts lists and page names are a starting point — not the
|
|
302
|
+
answer.
|
|
303
|
+
|
|
304
|
+
### \`list\` is discovery, \`show\` is understanding
|
|
305
|
+
|
|
306
|
+
\`list\` commands tell you what exists — names, counts, pages. They are indexes.
|
|
307
|
+
You don't understand a connector until you've seen its pinout (\`show
|
|
308
|
+
component\`). You don't understand a page until you've seen what's on it, what
|
|
309
|
+
its engineering notes say, and what signals bridge to other pages (\`show
|
|
310
|
+
page\`). You don't understand a net until you've seen every pin on it (\`show
|
|
311
|
+
net\`).
|
|
312
|
+
|
|
313
|
+
Never write a summary or draw a conclusion from \`list\` output alone. Every
|
|
314
|
+
\`list\` that surfaces something interesting must be followed by \`show\` to
|
|
315
|
+
understand what it actually is.
|
|
316
|
+
|
|
317
|
+
### When you are ready to write
|
|
318
|
+
|
|
319
|
+
You are not ready to write a summary until you can answer these questions from
|
|
320
|
+
\`show\` output — not from \`list\` output, not from page names, not from
|
|
321
|
+
assumptions:
|
|
322
|
+
|
|
323
|
+
- What does each connector carry? (\`show component\` on every non-trivial J)
|
|
324
|
+
- What is on each page that isn't self-explanatory? (\`show page\`)
|
|
325
|
+
- Which ICs talk to each other, and through what signals? (\`list nets -c\`,
|
|
326
|
+
\`trace\`)
|
|
327
|
+
|
|
328
|
+
If your understanding comes entirely from \`list\` output, you are not done
|
|
329
|
+
investigating. Go back and run the \`show\` commands.
|
|
330
|
+
|
|
331
|
+
### Build understanding from connectivity, not metadata
|
|
332
|
+
|
|
333
|
+
The order matters: boundaries first, then topology, then details. Each step
|
|
334
|
+
has two phases — discover (what exists) then understand (how it connects).
|
|
335
|
+
|
|
336
|
+
**1. System boundaries — connectors and external interfaces**
|
|
337
|
+
|
|
338
|
+
Connectors (J-prefix) define what enters and leaves the board. They reveal the
|
|
339
|
+
system context: what's on-board vs. off-board, what external modules exist,
|
|
340
|
+
what signals are meant to be probed/accessed.
|
|
295
341
|
|
|
296
342
|
\`\`\`sh
|
|
297
|
-
|
|
298
|
-
list components --
|
|
299
|
-
|
|
343
|
+
# Discover
|
|
344
|
+
list components --prefix J <FILE>
|
|
345
|
+
|
|
346
|
+
# Understand — for each non-trivial connector:
|
|
347
|
+
show component J8 <FILE> # what signals does this connector carry?
|
|
300
348
|
\`\`\`
|
|
301
349
|
|
|
302
|
-
|
|
350
|
+
A connector's part number tells you its form factor. Its *pinout* tells you
|
|
351
|
+
its role. A 26-pin board-to-board receptacle is meaningless until you see it
|
|
352
|
+
carries LVDS, I2C, and dedicated power rails for a specific subsystem — that
|
|
353
|
+
tells you something lives off-board.
|
|
354
|
+
|
|
355
|
+
**2. Page contents — what's actually on each page**
|
|
356
|
+
|
|
357
|
+
\`list pages\` gives you the table of contents. It does not tell you what each
|
|
358
|
+
page does. Use \`show page\` to see the actual components, the internal page
|
|
359
|
+
title (which often preserves design intent better than the navigation label),
|
|
360
|
+
engineering notes, and the nets that cross the page boundary.
|
|
303
361
|
|
|
304
362
|
\`\`\`sh
|
|
305
|
-
|
|
306
|
-
list
|
|
363
|
+
# Discover
|
|
364
|
+
list pages <FILE>
|
|
365
|
+
|
|
366
|
+
# Understand — for pages that aren't self-explanatory:
|
|
367
|
+
show page "Metis IO" <FILE> # components, page title, notes, nets
|
|
368
|
+
\`\`\`
|
|
369
|
+
|
|
370
|
+
\`show page\` surfaces text annotations placed on the schematic sheet —
|
|
371
|
+
revision notes, design rationale, change history, and configuration
|
|
372
|
+
documentation left by the engineer. These notes often explain *why* the
|
|
373
|
+
design looks the way it does, not just what's connected.
|
|
374
|
+
|
|
375
|
+
Don't assume a page's role from its name in the TOC. A page named "Lattice
|
|
376
|
+
FPGA" might contain interface circuitry that also touches other subsystems.
|
|
377
|
+
Read it.
|
|
378
|
+
|
|
379
|
+
**3. Inter-component topology — who talks to whom**
|
|
380
|
+
|
|
381
|
+
Use signal nets (not power) to understand which ICs form functional groups:
|
|
382
|
+
|
|
383
|
+
\`\`\`sh
|
|
384
|
+
# Discover
|
|
385
|
+
list nets -c U5 --no-power <FILE> # what signals touch U5?
|
|
386
|
+
|
|
387
|
+
# Understand
|
|
388
|
+
list nets -c U1 -c U5 --trace <FILE> # shared signals between MCU and FPGA
|
|
389
|
+
trace U1 U5 <FILE> # direct paths between them
|
|
390
|
+
\`\`\`
|
|
391
|
+
|
|
392
|
+
This reveals subsystem relationships that page names might obscure. Two
|
|
393
|
+
components on different pages sharing many signal nets are tightly coupled.
|
|
394
|
+
A component whose signals only reach a connector is an interface to something
|
|
395
|
+
off-board.
|
|
396
|
+
|
|
397
|
+
**4. Power architecture — rails and domains**
|
|
398
|
+
|
|
399
|
+
\`\`\`sh
|
|
400
|
+
list nets --power <FILE>
|
|
401
|
+
list components --page "Power" --no-passive <FILE>
|
|
402
|
+
show net P3V3 <FILE> # what's powered by this rail?
|
|
307
403
|
\`\`\`
|
|
308
404
|
|
|
309
|
-
|
|
405
|
+
Power domains reveal which subsystems are independently powered, which share
|
|
406
|
+
rails, and where isolation boundaries exist.
|
|
310
407
|
|
|
311
|
-
|
|
408
|
+
**5. Detailed pinout — when you need specifics**
|
|
312
409
|
|
|
313
410
|
\`\`\`sh
|
|
314
|
-
|
|
315
|
-
list
|
|
316
|
-
diff /tmp/a.txt /tmp/b.txt
|
|
411
|
+
show component U1 <FILE> # full pinout with traced destinations
|
|
412
|
+
list nets -c U1 --no-power <FILE> # signal net summary
|
|
317
413
|
\`\`\`
|
|
318
414
|
|
|
319
|
-
|
|
320
|
-
|
|
415
|
+
Cross-reference shunt annotations (\`(R50 to P3V3)\`) with passive values from
|
|
416
|
+
\`show component\` to understand pull-ups, termination, and biasing.
|
|
417
|
+
|
|
418
|
+
### Common pitfalls
|
|
419
|
+
|
|
420
|
+
- **Don't infer architecture from page names.** A page called "ASIC Interface"
|
|
421
|
+
might contain the interface circuitry *to* an ASIC (level shifters, buffers,
|
|
422
|
+
connectors), not the ASIC itself. Verify by checking what components are
|
|
423
|
+
actually on the page and what they connect to.
|
|
424
|
+
- **The BOM alone doesn't explain the design.** A component list tells you
|
|
425
|
+
what parts are on the board, but not how they're used or how they relate to
|
|
426
|
+
each other. The netlist and board hierarchy carry that context — which ICs
|
|
427
|
+
form a subsystem, which signals cross the board boundary, which functions are
|
|
428
|
+
on-board vs. off-board. Always query connectivity before drawing conclusions
|
|
429
|
+
about what a design does or how it changed.
|
|
430
|
+
- **A \`list\` command is not the end of a question, it's the beginning.** If
|
|
431
|
+
you ran \`list components --prefix J\` and see a Hirose connector, you still
|
|
432
|
+
don't know what it's for. Run \`show component\` on it. If you ran \`list
|
|
433
|
+
pages\` and see "Metis IO", you still don't know what's on that page. Run
|
|
434
|
+
\`show page\`. Conclusions require connectivity data, not just existence.
|
|
435
|
+
- **If you only ran \`list\` commands, you are not done.** Running several
|
|
436
|
+
\`list\` queries in parallel produces a broad index of the design — names,
|
|
437
|
+
counts, page structure. It does not produce understanding. Before writing
|
|
438
|
+
any summary, check: did I run \`show\` on the connectors, the non-obvious
|
|
439
|
+
pages, and the key ICs? If not, go back.
|
|
440
|
+
`;process.platform,process.platform;const nf=w.object({id:w.number().int().min(0),supported:w.boolean(),confidence:w.enum([`high`,`medium`,`low`]),reason:w.string().max(500)});w.object({verdicts:w.array(nf)});function rf(e){let t=e.split(`
|
|
321
441
|
`);if(t[0]?.trim()!==`---`)throw Error(`Skill markdown must start with frontmatter (---)`);let n=-1;for(let e=1;e<t.length;e++)if(t[e]?.trim()===`---`){n=e;break}if(n===-1)throw Error(`Skill markdown is missing closing frontmatter delimiter (---)`);let{name:r,description:i}=af(t.slice(1,n));return{name:r,description:i,instructions:t.slice(n+1).join(`
|
|
322
442
|
`).trim()}}function af(e){let t=``,n=``,r=0;for(;r<e.length;){let i=e[r];if(i.startsWith(`name:`))t=i.slice(5).trim(),r++;else if(i.startsWith(`description:`)){let t=i.slice(12).trim();if(t===`>`||t===`|`){let t=[];for(r++;r<e.length&&/^\s+/.test(e[r]);)t.push(e[r].trim()),r++;n=t.join(` `)}else n=t,r++}else r++}if(!t)throw Error(`Skill frontmatter is missing required field: name`);if(!n)throw Error(`Skill frontmatter is missing required field: description`);return{name:t,description:n}}rf(`---
|
|
443
|
+
name: instrument-control
|
|
444
|
+
description: >
|
|
445
|
+
Drive benchtop instruments (scopes, PSUs, DMMs, function generators, counters)
|
|
446
|
+
over SCPI/PyVISA. Use when the user asks to take measurements, drive a
|
|
447
|
+
stimulus, or capture data from a real instrument.
|
|
448
|
+
---
|
|
449
|
+
|
|
450
|
+
# Instrument Control
|
|
451
|
+
|
|
452
|
+
Control lab instruments over SCPI using \`pyvisa\` with the \`pyvisa-py\` backend.
|
|
453
|
+
No NI-VISA is installed — all communication uses pyvisa-py (USB-TMC, TCP/IP
|
|
454
|
+
raw socket, serial).
|
|
455
|
+
|
|
456
|
+
## Philosophy
|
|
457
|
+
|
|
458
|
+
**Ground yourself in real documentation.** Every vendor implements SCPI
|
|
459
|
+
differently. Do not generate SCPI commands from training memory — use the
|
|
460
|
+
programming manuals as the source of truth. You understand SCPI; the risk is
|
|
461
|
+
vendor-specific dialect, not the protocol itself.
|
|
462
|
+
|
|
463
|
+
**Verify command syntax in the manual before any write.** Parameter separators
|
|
464
|
+
(space vs comma), enable keywords (ON/OFF vs 1/0 vs a dedicated subcommand),
|
|
465
|
+
and query/write asymmetry vary between vendors — and sometimes between
|
|
466
|
+
subsystems on the same instrument. Never assume; always look it up.
|
|
467
|
+
|
|
468
|
+
**Reads are cheap; writes can do damage.** Querying an instrument never hurts
|
|
469
|
+
it. Writing settings can, and enabling output or sourcing energy can damage
|
|
470
|
+
hardware in milliseconds. The permission model reflects this asymmetry.
|
|
471
|
+
|
|
472
|
+
**The instrument's state is the only source of truth.** Never assume a
|
|
473
|
+
command succeeded — read back the setting and verify the instrument is in the
|
|
474
|
+
state you expect. The user can press a button on the front panel at any
|
|
475
|
+
moment, a previous command can silently fail, or the instrument can reject a
|
|
476
|
+
value that's out of range without raising an error. Every write must be
|
|
477
|
+
followed by a read that independently confirms the result.
|
|
478
|
+
|
|
479
|
+
**Protection limits are sacred.** Once set, never change OVP/OCP/compliance
|
|
480
|
+
without a direct user command.
|
|
481
|
+
|
|
482
|
+
## Programming manual index
|
|
483
|
+
|
|
484
|
+
An index of programming manuals for supported instruments is at
|
|
485
|
+
\`{{COMMAND_TABLES_DIR}}/index.json\`. This is a JSON array of entries:
|
|
486
|
+
|
|
487
|
+
\`\`\`json
|
|
488
|
+
{
|
|
489
|
+
"vendor": "rigol",
|
|
490
|
+
"model": "DP800/DP800A",
|
|
491
|
+
"doc": "Programming Guide",
|
|
492
|
+
"category": "dc_power_supply",
|
|
493
|
+
"url": "https://..."
|
|
494
|
+
}
|
|
495
|
+
\`\`\`
|
|
496
|
+
|
|
497
|
+
The \`model\` field is a series or family name (e.g. "DP800/DP800A",
|
|
498
|
+
"MSO1000Z/DS1000Z", "912xA Series"), not an exact model number. Match the
|
|
499
|
+
\`*IDN?\` response against the index by vendor and model family — for example,
|
|
500
|
+
a "DS1054Z" belongs to the "MSO1000Z/DS1000Z" entry.
|
|
501
|
+
|
|
502
|
+
### Lookup workflow
|
|
503
|
+
|
|
504
|
+
1. After \`*IDN?\`, read \`{{COMMAND_TABLES_DIR}}/index.json\`.
|
|
505
|
+
2. Find the entry matching the instrument's vendor and model family.
|
|
506
|
+
3. Call \`open_document\` on the \`url\` to load the programming manual.
|
|
507
|
+
4. Use \`grep_document\` to find the SCPI subsystem you need (e.g.
|
|
508
|
+
\`:VOLTage\`, \`:WAVeform\`, \`:MEASure\`), then \`read_document\` to get
|
|
509
|
+
the exact command syntax, parameters, and return formats.
|
|
510
|
+
5. Use the manual as your authoritative reference. Do not improvise
|
|
511
|
+
SCPI commands from training memory.
|
|
512
|
+
|
|
513
|
+
If the instrument is not in the index, fall back to \`web_search\` to find
|
|
514
|
+
the programming guide (search for the exact model number and "programming
|
|
515
|
+
guide" or "SCPI reference"), then open it the same way.
|
|
516
|
+
|
|
517
|
+
Training memory is the last resort. If you must use it, tell the user you're
|
|
518
|
+
working from general SCPI knowledge rather than a verified source, and
|
|
519
|
+
read back the instrument's response to confirm the command worked.
|
|
520
|
+
|
|
521
|
+
## Workflow
|
|
522
|
+
|
|
523
|
+
### 1. Discover
|
|
524
|
+
|
|
525
|
+
Enumerate connected instruments:
|
|
526
|
+
|
|
527
|
+
\`\`\`python
|
|
528
|
+
import pyvisa
|
|
529
|
+
|
|
530
|
+
rm = pyvisa.ResourceManager("@py")
|
|
531
|
+
resources = rm.list_resources("?*") # ?* includes USB RAW and TCPIP SOCKET
|
|
532
|
+
print(resources)
|
|
533
|
+
\`\`\`
|
|
534
|
+
|
|
535
|
+
**Pass \`"?*"\` to \`list_resources\`.** The default filter excludes USB RAW and
|
|
536
|
+
TCPIP SOCKET resources. Without it, many instruments are invisible.
|
|
537
|
+
|
|
538
|
+
If the list is empty:
|
|
539
|
+
- **macOS:** pyvisa-py has known issues on Apple Silicon. Check that the
|
|
540
|
+
instrument is visible via \`system_profiler SPUSBDataType\`. Try connecting
|
|
541
|
+
via TCP/IP (\`TCPIP::<ip>::<port>::SOCKET\`) if USB doesn't work.
|
|
542
|
+
- **Linux:** USB-TMC requires udev rules. Check \`lsusb\` to confirm the device
|
|
543
|
+
is visible, then verify \`/dev/usbtmc*\` or the udev rule exists.
|
|
544
|
+
- **Windows:** USB instruments often need the WinUSB driver installed via
|
|
545
|
+
Zadig. The vendor's native driver may block pyvisa-py access.
|
|
546
|
+
|
|
547
|
+
Surface the resource list to the user before proceeding.
|
|
548
|
+
|
|
549
|
+
### 2. Identify
|
|
550
|
+
|
|
551
|
+
\`\`\`python
|
|
552
|
+
with rm.open_resource(resource_string) as inst:
|
|
553
|
+
idn = inst.query("*IDN?")
|
|
554
|
+
print(idn) # e.g. "RIGOL TECHNOLOGIES,DS1054Z,DS1ZA1234,00.04.04.SP4"
|
|
555
|
+
\`\`\`
|
|
556
|
+
|
|
557
|
+
Parse vendor, model, serial, and firmware from the \`*IDN?\` response. Tell the
|
|
558
|
+
user what you found. This determines which manual to use.
|
|
559
|
+
|
|
560
|
+
**\`*IDN?\` is the only command you may send before reading the manual.** Do not
|
|
561
|
+
query settings, do not write configuration, do not send any other SCPI
|
|
562
|
+
commands. Every instrument has vendor-specific syntax, and sending commands
|
|
563
|
+
based on assumptions or training memory risks silent misconfiguration.
|
|
564
|
+
|
|
565
|
+
### 3. Download and read the programming manual
|
|
566
|
+
|
|
567
|
+
Read \`{{COMMAND_TABLES_DIR}}/index.json\` and find the entry matching the
|
|
568
|
+
instrument's vendor and model family. **Download the manual now** — call
|
|
569
|
+
\`open_document\` on its \`url\`. If the instrument isn't in the index, use
|
|
570
|
+
\`web_search\` to find the programming guide (search for the exact model
|
|
571
|
+
number and "programming guide" or "SCPI reference") and open it the same
|
|
572
|
+
way.
|
|
573
|
+
|
|
574
|
+
This is not optional and cannot be deferred. You need the manual open before
|
|
575
|
+
sending any commands beyond \`*IDN?\`.
|
|
576
|
+
|
|
577
|
+
**Verify the manual covers your instrument.** After opening the document,
|
|
578
|
+
confirm it is actually the programming manual (or SCPI reference) for the
|
|
579
|
+
model returned by \`*IDN?\`. Check the title page, introduction, or
|
|
580
|
+
applicability section. Manuals for a different model in the same family,
|
|
581
|
+
a user manual without SCPI commands, or a general product brochure are
|
|
582
|
+
not acceptable. If the manual does not match:
|
|
583
|
+
|
|
584
|
+
1. Do not proceed with commands from the wrong manual.
|
|
585
|
+
2. Search for the correct manual — try \`web_search\` with the exact model
|
|
586
|
+
number and "programming guide" or "SCPI reference."
|
|
587
|
+
3. If you cannot find the correct programming manual, **stop and ask the
|
|
588
|
+
user.** Do not attempt to work around the problem by guessing commands,
|
|
589
|
+
using a similar model's manual, or falling back to training memory.
|
|
590
|
+
|
|
591
|
+
For every SCPI subsystem you intend to use, find it in the manual with
|
|
592
|
+
\`grep_document\`, then read the relevant pages with \`read_document\` to get
|
|
593
|
+
the exact command syntax, parameters, and return formats. Specifically
|
|
594
|
+
verify before writing any command:
|
|
595
|
+
|
|
596
|
+
- Parameter separators (space, comma, or no separator)
|
|
597
|
+
- Enable/disable keywords (ON/OFF, 1/0, or a dedicated subcommand)
|
|
598
|
+
- Query response format (string, numeric, boolean — needed for readback)
|
|
599
|
+
- Command dependencies (some settings only apply in specific modes)
|
|
600
|
+
|
|
601
|
+
### 4. Set up protection (source instruments only)
|
|
602
|
+
|
|
603
|
+
For any instrument that can source energy — power supplies, function
|
|
604
|
+
generators, SMUs — establish a safety envelope **before planning or
|
|
605
|
+
discussing any other actions**. This is a standalone phase: agree on
|
|
606
|
+
protection values with the user, set them, confirm them, and report —
|
|
607
|
+
then and only then move on to the actual task.
|
|
608
|
+
|
|
609
|
+
No output may be enabled until this ritual completes successfully. Do not
|
|
610
|
+
combine protection setup with other configuration or planning.
|
|
611
|
+
|
|
612
|
+
**Phase A — Agree on limits:**
|
|
613
|
+
|
|
614
|
+
1. **Ask the user** for the maximum safe voltage and current (or amplitude
|
|
615
|
+
and offset, for function generators) that their setup can tolerate.
|
|
616
|
+
Discuss sensible values — these should protect the DUT and wiring, not
|
|
617
|
+
just match the instrument's max rating. Wait for explicit agreement
|
|
618
|
+
before proceeding.
|
|
619
|
+
|
|
620
|
+
**Phase B — Set and verify (based on manual-confirmed capabilities):**
|
|
621
|
+
|
|
622
|
+
2. **Look up protection capabilities** in the manual. Not all source
|
|
623
|
+
instruments expose the same protection features — what you search for
|
|
624
|
+
depends on the instrument type:
|
|
625
|
+
- **Power supplies:** Search for \`:VOLTage:PROTection\` and
|
|
626
|
+
\`:CURRent:PROTection\` subsystems (or vendor equivalents like
|
|
627
|
+
\`:OUTPut:OVP\`/\`:OUTPut:OCP\`). These are hardware trip points that
|
|
628
|
+
shut down the output if exceeded — **not** the channel output commands
|
|
629
|
+
(\`:VOLTage\`, \`:CURRent\`), which set the working setpoints. Do not
|
|
630
|
+
confuse the two.
|
|
631
|
+
- **SMUs:** Search for compliance commands (current compliance for
|
|
632
|
+
voltage-sourcing mode, voltage compliance for current-sourcing mode).
|
|
633
|
+
- **Function generators:** Most do not have OVP/OCP or separate
|
|
634
|
+
protection subsystems. Search the manual for output protection,
|
|
635
|
+
amplitude limits, or load impedance settings. If the manual exposes
|
|
636
|
+
any form of output limiting, use it. If the manual does not expose
|
|
637
|
+
any protection or limiting capability, **stop and warn the user**
|
|
638
|
+
that there is no hardware safety net — explain what you searched for
|
|
639
|
+
and that the instrument lacks it. Do not proceed until the user
|
|
640
|
+
explicitly acknowledges and accepts the risk.
|
|
641
|
+
Record exactly which protection features the manual documents. Only
|
|
642
|
+
configure protections the instrument actually supports — do not
|
|
643
|
+
synthesize commands from other instrument families.
|
|
644
|
+
3. **Set the protection limits** the manual supports to the agreed values.
|
|
645
|
+
4. **Enable the protection** if it requires a separate enable command (many
|
|
646
|
+
power supplies have separate \`OVP:VAL\` and \`OVP:STAT ON\` commands).
|
|
647
|
+
5. **Read back each protection setting and its enable state** with separate
|
|
648
|
+
query commands. Parse the response using the format you found in the
|
|
649
|
+
manual. Confirm the readback values match what you set. Command success
|
|
650
|
+
alone is not sufficient — the readback must independently verify the
|
|
651
|
+
state.
|
|
652
|
+
|
|
653
|
+
**Phase C — Report:**
|
|
654
|
+
|
|
655
|
+
6. **Report the confirmed settings** to the user. Show the readback values,
|
|
656
|
+
not just "protection is set." Wait for acknowledgement before moving on.
|
|
657
|
+
7. **Never change these limits** unless the user directly asks you to.
|
|
658
|
+
|
|
659
|
+
This is the single most important safety step. It caps the damage an incorrect
|
|
660
|
+
setting can do. Do not skip it, abbreviate it, or combine it with other
|
|
661
|
+
work.
|
|
662
|
+
|
|
663
|
+
### 5. Plan and ask
|
|
664
|
+
|
|
665
|
+
Before sending any commands that change instrument state:
|
|
666
|
+
|
|
667
|
+
- **Reads** (queries, measurements): proceed without asking.
|
|
668
|
+
- **Settings within the protection envelope**: summarise what you intend to
|
|
669
|
+
change (e.g. "I'll set CH1 to 3.3V / 0.5A, within your 12V / 2A limits").
|
|
670
|
+
Proceed unless the user objects.
|
|
671
|
+
- **Output-enable, source-on, any command that releases energy**: get explicit
|
|
672
|
+
confirmation. Every time.
|
|
673
|
+
- **Protection limit changes**: never. Only on direct user command.
|
|
674
|
+
|
|
675
|
+
### 6. Execute
|
|
676
|
+
|
|
677
|
+
For every SCPI command you send, follow this loop:
|
|
678
|
+
|
|
679
|
+
1. **Look up the command** in the manual. Confirm the exact syntax,
|
|
680
|
+
parameters, and the format of the query response. Do not send a command
|
|
681
|
+
you have not verified in the manual for this specific instrument.
|
|
682
|
+
2. **Send the command.**
|
|
683
|
+
3. **Read back the setting** with the corresponding query. Do not assume
|
|
684
|
+
the write succeeded — the instrument may silently reject out-of-range
|
|
685
|
+
values, the user may have changed something on the front panel, or a
|
|
686
|
+
mode dependency may prevent the setting from taking effect.
|
|
687
|
+
4. **Verify the readback** matches your intent. Parse the response using
|
|
688
|
+
the format from the manual (ON/OFF, 1/0, numeric — don't assume). If
|
|
689
|
+
the readback doesn't match, stop and diagnose before sending more
|
|
690
|
+
commands.
|
|
691
|
+
5. **Drain the error queue** after each logical block of commands.
|
|
692
|
+
|
|
693
|
+
This applies to every write, not just safety-critical ones. Instrument
|
|
694
|
+
state can change at any time, and silent failures are the norm in SCPI —
|
|
695
|
+
errors don't raise Python exceptions.
|
|
696
|
+
|
|
697
|
+
\`\`\`python
|
|
698
|
+
with rm.open_resource(resource_string) as inst:
|
|
699
|
+
inst.timeout = 10_000 # ms — adjust per operation
|
|
700
|
+
inst.read_termination = "\\n"
|
|
701
|
+
inst.write_termination = "\\n"
|
|
702
|
+
|
|
703
|
+
# Example: set voltage, then verify
|
|
704
|
+
inst.write(":VOLT 3.300")
|
|
705
|
+
actual = inst.query(":VOLT?")
|
|
706
|
+
print(f"Requested 3.300 V, instrument reports: {actual}")
|
|
707
|
+
|
|
708
|
+
# Drain error queue
|
|
709
|
+
while True:
|
|
710
|
+
err = inst.query("SYST:ERR?")
|
|
711
|
+
if err.startswith("0,") or err.startswith("+0,"):
|
|
712
|
+
break
|
|
713
|
+
print(f"Instrument error: {err}")
|
|
714
|
+
\`\`\`
|
|
715
|
+
|
|
716
|
+
Always use a context manager. Never leave a session open — a dropped process
|
|
717
|
+
locks the USB endpoint until reboot.
|
|
718
|
+
|
|
719
|
+
## Safety
|
|
720
|
+
|
|
721
|
+
### Power supplies
|
|
722
|
+
|
|
723
|
+
- **OVP/OCP are not channel settings.** OVP (\`:VOLTage:PROTection\`) is the
|
|
724
|
+
trip point that shuts down the output — it is distinct from the channel
|
|
725
|
+
voltage (\`:VOLTage\`). OCP (\`:CURRent:PROTection\`) is the trip point for
|
|
726
|
+
current — distinct from the channel current limit (\`:CURRent\`). Set the
|
|
727
|
+
protection trip points first via the step-4 ritual; configure the channel
|
|
728
|
+
operating values later.
|
|
729
|
+
- Set OVP and OCP **before** enabling output.
|
|
730
|
+
- Never enable output without confirming voltage, current limit, and that the
|
|
731
|
+
intended load is connected.
|
|
732
|
+
- Read back voltage and current after enabling output to verify.
|
|
733
|
+
- If the instrument reports a protection trip, stop and tell the user.
|
|
734
|
+
|
|
735
|
+
### Oscilloscopes
|
|
736
|
+
|
|
737
|
+
- Confirm probe attenuation matches the physical probe. A 10x probe with 1x
|
|
738
|
+
software setting gives readings that are 10x wrong but look coherent.
|
|
739
|
+
- Check coupling (AC/DC) and bandwidth limit — both affect measurements.
|
|
740
|
+
- Oscilloscopes are read-only with respect to the DUT. The damage path is
|
|
741
|
+
misinterpreting data, not the instrument itself.
|
|
742
|
+
- **Timebase offset sign convention:** a positive offset moves the trigger
|
|
743
|
+
point to the **left** of the screen (more post-trigger time visible). A
|
|
744
|
+
negative offset moves it to the **right** (more pre-trigger time). This
|
|
745
|
+
is universal across Rigol, Keysight, Siglent, and Tektronix. To capture
|
|
746
|
+
a startup transient after a power-on trigger, you need a **positive**
|
|
747
|
+
offset — not negative. Getting this backwards puts the event off-screen.
|
|
748
|
+
- **Verify the trigger is on-screen** after setting the timebase. Compute:
|
|
749
|
+
\`|offset| < 5 × scale\` (the visible window is ±5 divisions from center).
|
|
750
|
+
If the trigger point is outside this range, the event won't be captured.
|
|
751
|
+
Also, if the instrument's built-in measurements return a "no valid
|
|
752
|
+
measurement" sentinel (e.g. \`9.9E37\` on Rigol) after a capture, suspect
|
|
753
|
+
the trigger is off-screen before debugging anything else.
|
|
754
|
+
|
|
755
|
+
### Function generators
|
|
756
|
+
|
|
757
|
+
- Enable output **last**, after verifying amplitude, frequency, offset, and
|
|
758
|
+
load impedance setting.
|
|
759
|
+
- Treat output-enable as energy-releasing — always ask the user first.
|
|
760
|
+
- If the instrument has a high-Z / 50-ohm output impedance setting, confirm
|
|
761
|
+
it matches the actual load.
|
|
762
|
+
|
|
763
|
+
### Source-measure units
|
|
764
|
+
|
|
765
|
+
- Never source without compliance set first. An SMU with no compliance limit
|
|
766
|
+
will rail to full output and can destroy the DUT instantly.
|
|
767
|
+
- Most cheap benchtop gear is not an SMU. If the user has a Keithley
|
|
768
|
+
2400-series or similar, the compliance rules apply strictly.
|
|
769
|
+
|
|
770
|
+
### Multimeters and frequency counters
|
|
771
|
+
|
|
772
|
+
- Read-only with respect to the DUT. Safe to query freely.
|
|
773
|
+
|
|
774
|
+
### Readback type contract
|
|
775
|
+
|
|
776
|
+
When reading back a setting to verify it, first check the manual for the
|
|
777
|
+
response format. Instruments return enable states as \`ON\`/\`OFF\`, \`1\`/\`0\`,
|
|
778
|
+
or a numeric value — and it varies by vendor, by instrument, and sometimes
|
|
779
|
+
by subsystem. Before comparing a readback value, know what type the
|
|
780
|
+
instrument returns and parse accordingly. A string comparison of \`"1"\` against
|
|
781
|
+
\`"ON"\` is a silent verification failure.
|
|
782
|
+
|
|
783
|
+
### State machine preflight
|
|
784
|
+
|
|
785
|
+
For any multi-instrument sequence where one instrument triggers or stimulates
|
|
786
|
+
and another captures:
|
|
787
|
+
|
|
788
|
+
1. Confirm the stimulus source is in its **initial state** (output off,
|
|
789
|
+
trigger idle) before arming the capture instrument.
|
|
790
|
+
2. Arm the capture (e.g. scope single-trigger mode).
|
|
791
|
+
3. Only then enable the stimulus.
|
|
792
|
+
|
|
793
|
+
The required order is: DUT off → capture armed → stimulus enabled. Reversing
|
|
794
|
+
this risks missing the event or capturing a partial transient.
|
|
795
|
+
|
|
796
|
+
### General rule
|
|
797
|
+
|
|
798
|
+
Every write gets a readback. This is not optional and not limited to
|
|
799
|
+
safety-critical settings — see the execute loop in step 6. The instrument's
|
|
800
|
+
actual state is the only thing that matters; your command history is not
|
|
801
|
+
reliable evidence of what the instrument is doing right now.
|
|
802
|
+
|
|
803
|
+
### When results don't match expectations
|
|
804
|
+
|
|
805
|
+
**Do not invent a physical explanation for unexpected results.** If a
|
|
806
|
+
measurement or capture doesn't match what you expected, assume your
|
|
807
|
+
instrument configuration is wrong until proven otherwise. The base rate
|
|
808
|
+
for "I set it up wrong" is far higher than "the circuit is doing
|
|
809
|
+
something unexpected" — especially on the first capture.
|
|
810
|
+
|
|
811
|
+
Diagnose in this order:
|
|
812
|
+
|
|
813
|
+
1. **Check the instrument configuration.** Read back every relevant setting
|
|
814
|
+
from the instrument (timebase, trigger level, channel scale, offset,
|
|
815
|
+
coupling, probe attenuation, output voltage/current). Compare each
|
|
816
|
+
readback to your intent. Do not review your command history — re-read
|
|
817
|
+
the settings from the instrument, because the actual state may differ
|
|
818
|
+
from what you sent.
|
|
819
|
+
2. **Check the signal path.** Is the probe connected to the right channel?
|
|
820
|
+
Is the channel enabled? Is the coupling correct (AC vs DC)? Is the
|
|
821
|
+
impedance setting correct (50Ω vs 1MΩ)? Is the bandwidth limit on?
|
|
822
|
+
3. **Check your data interpretation.** Are the units correct? Is the
|
|
823
|
+
probe attenuation factor applied? Is the vertical offset accounted for?
|
|
824
|
+
Are you looking at the right channel's data?
|
|
825
|
+
4. **Only after 1–3 are exhausted:** consider whether the circuit is
|
|
826
|
+
doing something unexpected. Report your verified instrument settings
|
|
827
|
+
to the user and ask for their interpretation.
|
|
828
|
+
|
|
829
|
+
Never skip to step 4. A flat line is more likely a trigger offset error
|
|
830
|
+
than a dead circuit. A noisy signal is more likely a coupling or bandwidth
|
|
831
|
+
issue than a bad component. A reading of zero is more likely a disconnected
|
|
832
|
+
probe than a shorted output.
|
|
833
|
+
|
|
834
|
+
## Bus discipline
|
|
835
|
+
|
|
836
|
+
### Session lifecycle
|
|
837
|
+
|
|
838
|
+
Always use a context manager:
|
|
839
|
+
|
|
840
|
+
\`\`\`python
|
|
841
|
+
with rm.open_resource(resource_string) as inst:
|
|
842
|
+
...
|
|
843
|
+
\`\`\`
|
|
844
|
+
|
|
845
|
+
Never use bare \`rm.open_resource()\` without a \`with\` block. A dropped Python
|
|
846
|
+
process that doesn't close the session will lock the instrument's USB endpoint.
|
|
847
|
+
The only recovery is rebooting the instrument or the host.
|
|
848
|
+
|
|
849
|
+
### Timeouts
|
|
850
|
+
|
|
851
|
+
The default pyvisa timeout is 2000 ms. This is wrong for:
|
|
852
|
+
- Deep memory captures (10k+ points)
|
|
853
|
+
- Frequency sweeps
|
|
854
|
+
- Self-calibration (\`*CAL?\`)
|
|
855
|
+
- Any operation that takes more than a second
|
|
856
|
+
|
|
857
|
+
Set \`inst.timeout\` before long operations. If you're using \`*OPC?\` to wait
|
|
858
|
+
for completion, the VISA timeout must be **longer** than the operation time —
|
|
859
|
+
otherwise the timeout fires while the instrument is still working, and the
|
|
860
|
+
USBTMC abort sequence can lock the bus.
|
|
861
|
+
|
|
862
|
+
### Termination characters
|
|
863
|
+
|
|
864
|
+
Termination characters vary by transport. Getting this wrong is the most
|
|
865
|
+
common silent failure:
|
|
866
|
+
- **TCP/IP raw socket**: usually \`\\n\`
|
|
867
|
+
- **USB-TMC**: usually \`\\n\`, but some instruments use none (message-based)
|
|
868
|
+
- **Serial (RS-232)**: usually \`\\r\` or \`\\r\\n\`
|
|
869
|
+
- **GPIB**: no termination character (uses EOI line)
|
|
870
|
+
|
|
871
|
+
Check the command table or manual for the instrument's expected termination.
|
|
872
|
+
|
|
873
|
+
### Write/query pairing
|
|
874
|
+
|
|
875
|
+
Every \`write\` that expects a response must use \`query\` instead. Every \`query\`
|
|
876
|
+
must be followed by reading the response before sending another command.
|
|
877
|
+
Desyncing the buffer causes the next read to return the *previous* query's
|
|
878
|
+
answer — the classic "why is my voltage reading an IDN string" bug.
|
|
879
|
+
|
|
880
|
+
### Synchronization
|
|
881
|
+
|
|
882
|
+
Three IEEE 488.2 commands handle synchronization. They are **not**
|
|
883
|
+
interchangeable — each has different blocking semantics and failure modes:
|
|
884
|
+
|
|
885
|
+
- **\`*OPC?\`** (Operation Complete Query) — blocks the VISA read until all
|
|
886
|
+
pending operations finish, then returns \`1\`. This is what you want for
|
|
887
|
+
most cases: send a command, then \`inst.query("*OPC?")\` to wait. The
|
|
888
|
+
VISA timeout must be longer than the operation time, or the timeout fires
|
|
889
|
+
while the instrument is still busy and the USBTMC abort can lock the bus.
|
|
890
|
+
**You must read the response** — if you don't, the instrument generates a
|
|
891
|
+
"Query Interrupted" error on the next query.
|
|
892
|
+
- **\`*WAI\`** (Wait-to-Continue) — blocks the instrument's command parser
|
|
893
|
+
until pending operations finish. Does not block Python or the bus
|
|
894
|
+
controller — your script continues immediately after sending \`*WAI\`. This
|
|
895
|
+
means you get no confirmation the operation finished. Useful only when
|
|
896
|
+
you want the instrument to sequence its own commands internally but don't
|
|
897
|
+
need to know when it's done. **Not recommended** for agent use because
|
|
898
|
+
you need confirmation before proceeding.
|
|
899
|
+
- **\`*OPC\`** (Operation Complete) — sets bit 0 in the Event Status Register
|
|
900
|
+
(ESR) when all pending operations finish. Does not block anything. Used
|
|
901
|
+
with status register polling (\`*ESR?\`) or service request (SRQ) callbacks
|
|
902
|
+
for non-blocking async patterns. More complex to implement and rarely
|
|
903
|
+
needed in script-driven automation.
|
|
904
|
+
|
|
905
|
+
**Use \`*OPC?\` as the default.** It's the simplest mechanism that gives you
|
|
906
|
+
a confirmation gate. Do not use \`time.sleep\` — it's either too short (race
|
|
907
|
+
condition) or too long (wasted time), and it never confirms the operation
|
|
908
|
+
actually finished.
|
|
909
|
+
|
|
910
|
+
\`\`\`python
|
|
911
|
+
inst.write(":SINGle") # trigger a single acquisition
|
|
912
|
+
inst.timeout = 30_000 # bump timeout for the wait
|
|
913
|
+
inst.query("*OPC?") # blocks until acquisition completes
|
|
914
|
+
inst.timeout = 10_000 # restore normal timeout
|
|
915
|
+
\`\`\`
|
|
916
|
+
|
|
917
|
+
**Endless waits:** if the trigger condition is never met (e.g. scope in
|
|
918
|
+
single-trigger mode but no signal arrives), \`*OPC?\` will block until the
|
|
919
|
+
VISA timeout fires. For trigger-dependent operations, set a reasonable
|
|
920
|
+
timeout and handle the timeout error explicitly — don't let it hang.
|
|
921
|
+
|
|
922
|
+
### Sequencing
|
|
923
|
+
|
|
924
|
+
Never fire-and-forget a command and move on to the next step. Every
|
|
925
|
+
operation that changes instrument state must be confirmed complete before
|
|
926
|
+
you proceed. This is especially important with multiple instruments,
|
|
927
|
+
where race conditions are easy to create.
|
|
928
|
+
|
|
929
|
+
**Single-instrument sequencing:**
|
|
930
|
+
|
|
931
|
+
For every command that takes time (acquisition, self-cal, output settling):
|
|
932
|
+
|
|
933
|
+
1. Send the command.
|
|
934
|
+
2. Wait for completion with \`*OPC?\`.
|
|
935
|
+
3. Read back the result or state to confirm it matches your intent.
|
|
936
|
+
4. Only then send the next command.
|
|
937
|
+
|
|
938
|
+
Do not batch multiple state-changing commands and wait once at the end —
|
|
939
|
+
if the second command depends on the first having finished, you have a
|
|
940
|
+
race condition.
|
|
941
|
+
|
|
942
|
+
**Multi-instrument sequencing:**
|
|
943
|
+
|
|
944
|
+
When coordinating across instruments (e.g. PSU + scope, function gen +
|
|
945
|
+
DMM), each instrument has its own session and its own command buffer.
|
|
946
|
+
Commands sent to different instruments execute in parallel unless you
|
|
947
|
+
explicitly serialize them.
|
|
948
|
+
|
|
949
|
+
For every step in a multi-instrument sequence:
|
|
950
|
+
|
|
951
|
+
1. Send the command to instrument A.
|
|
952
|
+
2. Confirm completion on instrument A (\`*OPC?\` + readback).
|
|
953
|
+
3. Only then send the dependent command to instrument B.
|
|
954
|
+
4. Confirm completion on instrument B (\`*OPC?\` + readback).
|
|
955
|
+
|
|
956
|
+
Never assume that "I sent the PSU output-on command, so the voltage is
|
|
957
|
+
stable by the time I trigger the scope." Confirm PSU output is stable
|
|
958
|
+
(readback voltage, check it's within tolerance) before arming the scope.
|
|
959
|
+
|
|
960
|
+
### Error-queue drain
|
|
961
|
+
|
|
962
|
+
After every logical block of commands, drain the error queue:
|
|
963
|
+
|
|
964
|
+
\`\`\`python
|
|
965
|
+
while True:
|
|
966
|
+
err = inst.query("SYST:ERR?")
|
|
967
|
+
if err.startswith("0,") or err.startswith("+0,"):
|
|
968
|
+
break
|
|
969
|
+
print(f"Instrument error: {err}")
|
|
970
|
+
\`\`\`
|
|
971
|
+
|
|
972
|
+
Without this, a malformed SCPI command fails silently (errors don't raise
|
|
973
|
+
Python exceptions), and the next command's response looks correct. This is the
|
|
974
|
+
single biggest reliability win.
|
|
975
|
+
|
|
976
|
+
### Binary block transfers
|
|
977
|
+
|
|
978
|
+
Waveform data is usually transferred as IEEE 488.2 binary blocks. Use
|
|
979
|
+
\`query_binary_values\` with the correct dtype and endianness — these are
|
|
980
|
+
vendor-specific. A wrong dtype produces plausible-looking but garbage data.
|
|
981
|
+
|
|
982
|
+
Check the command table or manual for the instrument's binary format (int8,
|
|
983
|
+
int16, uint16, big-endian, little-endian) and any scaling formula needed to
|
|
984
|
+
convert raw ADC values to physical units.
|
|
985
|
+
|
|
986
|
+
**Post-transfer session state:** On some transports (especially USB-TMC),
|
|
987
|
+
querying the instrument immediately after \`query_binary_values\` can timeout
|
|
988
|
+
or return corrupt data — the session needs a moment to recover from the
|
|
989
|
+
bulk transfer. If you see timeouts after a binary read, try a short
|
|
990
|
+
\`time.sleep(0.1)\` before the next query, or close and reopen the resource
|
|
991
|
+
for the follow-up commands.
|
|
992
|
+
|
|
993
|
+
## Data handling
|
|
994
|
+
|
|
995
|
+
**Do not read raw waveform data into your context.** Large numeric arrays
|
|
996
|
+
(thousands of samples) will consume your context window and you will
|
|
997
|
+
hallucinate when trying to interpret them. Similarly, do not try to
|
|
998
|
+
interpret oscilloscope screenshots or instrument display images — you will
|
|
999
|
+
misread values.
|
|
1000
|
+
|
|
1001
|
+
Instead:
|
|
1002
|
+
|
|
1003
|
+
- **For quick measurements:** use the instrument's built-in measurement
|
|
1004
|
+
commands (\`MEAS:VPP?\`, \`MEAS:FREQ?\`, \`MEAS:VRMS?\`, etc.). These return
|
|
1005
|
+
single numbers computed by the instrument's hardware.
|
|
1006
|
+
- **For waveform analysis:** capture the waveform data to a file (CSV or
|
|
1007
|
+
binary), then use numpy/scipy to compute the statistics you need:
|
|
1008
|
+
|
|
1009
|
+
\`\`\`python
|
|
1010
|
+
import numpy as np
|
|
1011
|
+
|
|
1012
|
+
data = np.loadtxt("waveform.csv", delimiter=",")
|
|
1013
|
+
time, voltage = data[:, 0], data[:, 1]
|
|
1014
|
+
|
|
1015
|
+
vpp = np.ptp(voltage)
|
|
1016
|
+
vrms = np.sqrt(np.mean(voltage**2))
|
|
1017
|
+
mean = np.mean(voltage)
|
|
1018
|
+
\`\`\`
|
|
1019
|
+
|
|
1020
|
+
- **For the user:** saving waveforms and screenshots is encouraged. The UI
|
|
1021
|
+
renders them well. Save plots via matplotlib, save raw data to CSV for
|
|
1022
|
+
export.
|
|
1023
|
+
|
|
1024
|
+
## Common failure patterns
|
|
1025
|
+
|
|
1026
|
+
| Symptom | Likely cause | Fix |
|
|
1027
|
+
|---------|-------------|-----|
|
|
1028
|
+
| \`list_resources()\` returns empty | Default filter excludes USB RAW / TCPIP SOCKET | Pass \`"?*"\` to \`list_resources\`. Check udev / Zadig / USB visibility. |
|
|
1029
|
+
| "Resource busy" or "VI_ERROR_RSRC_BUSY" | Previous Python process still holds the endpoint | Restart the instrument, or wait for the OS to release the endpoint. Check for zombie Python processes. |
|
|
1030
|
+
| Waveform data looks like garbage | Wrong dtype or endianness in \`query_binary_values\` | Check the manual for the instrument's binary format. Common: int8, int16 (little-endian for Rigol, big-endian for some Keysight). |
|
|
1031
|
+
| Read returns unexpected string (e.g. IDN when expecting voltage) | Buffer desync — a previous query was not read | Every query must be followed by a read. Check for \`write\` where \`query\` was needed. |
|
|
1032
|
+
| Timeout on a long operation | \`inst.timeout\` shorter than the operation time | Bump timeout before the operation. Use \`*OPC?\` instead of \`time.sleep\`. |
|
|
1033
|
+
| Command accepted but has no effect | Wrong vendor SCPI dialect | Check the command table or manual. Common: Rigol requires absolute paths; Siglent uses different command names. |
|
|
1034
|
+
| "No error" from \`SYST:ERR?\` but wrong behaviour | Command was syntactically valid but semantically wrong for the current mode | Check command dependencies — some commands only work in specific instrument modes (e.g. scope acquisition settings depend on the active acquisition mode). |
|
|
1035
|
+
| Timeout or corrupt data immediately after \`query_binary_values\` | Post-binary-transfer session state on USB-TMC | Add a short \`time.sleep(0.1)\` before the next query, or close and reopen the resource for follow-up commands. |
|
|
1036
|
+
| Readback says \`1\` but you expected \`ON\` (or vice versa) | Vendor-specific response format for enable states | Check the manual for the query's response format. Parse as the correct type before comparing. |
|
|
1037
|
+
|
|
1038
|
+
## Three-strikes rule
|
|
1039
|
+
|
|
1040
|
+
After three failed attempts at the same instrument operation, stop and report
|
|
1041
|
+
to the user:
|
|
1042
|
+
|
|
1043
|
+
1. What you tried (exact SCPI commands sent).
|
|
1044
|
+
2. What happened (exact responses and errors received).
|
|
1045
|
+
3. What the command table or manual says the correct syntax should be.
|
|
1046
|
+
4. What you think is wrong.
|
|
1047
|
+
|
|
1048
|
+
Do not change instrument state or retry further without user approval.
|
|
1049
|
+
`),rf(`---
|
|
323
1050
|
name: simulation
|
|
324
1051
|
description: >
|
|
325
1052
|
Set up and run SPICE circuit simulations using spicelib. Use when the user
|
|
@@ -479,13 +1206,11 @@ If no supported simulator is installed, tell the user which one to install
|
|
|
479
1206
|
and why (based on the model requirements). Provide the install command or
|
|
480
1207
|
download URL. Don't proceed until it's available.
|
|
481
1208
|
|
|
482
|
-
### 4.
|
|
483
|
-
|
|
484
|
-
\`\`\`bash
|
|
485
|
-
uv pip install spicelib schemdraw
|
|
486
|
-
\`\`\`
|
|
1209
|
+
### 4. Verify the simulator binary
|
|
487
1210
|
|
|
488
|
-
|
|
1211
|
+
\`spicelib\` and \`schemdraw\` are pre-installed in the project venv. The SPICE
|
|
1212
|
+
simulator itself (ngspice, LTspice, Xyce, or QSPICE) is a separate binary that
|
|
1213
|
+
must be installed on the system — check it's reachable before proceeding:
|
|
489
1214
|
|
|
490
1215
|
\`\`\`python
|
|
491
1216
|
from spicelib.simulators.ngspice_simulator import NGspiceSimulator
|
|
@@ -773,7 +1498,7 @@ When presenting simulation results:
|
|
|
773
1498
|
- If results look suspicious (gain of 10000, negative resistance, currents
|
|
774
1499
|
in amps for a small-signal circuit), say so. Don't report garbage as if
|
|
775
1500
|
it's valid.
|
|
776
|
-
`)
|
|
1501
|
+
`);const of={darwin:[`~/oss-cad-suite/bin`,`/opt/oss-cad-suite/bin`],linux:[`~/oss-cad-suite/bin`,`/opt/oss-cad-suite/bin`],win32:[`C:\\oss-cad-suite\\bin`,`~\\oss-cad-suite\\bin`]};function sf(e){let t={};for(let[n,r]of Object.entries(of))t[n]=r.map(t=>o(t,e));return t}function cf(...e){let t={};for(let n of e)if(n)for(let[e,r]of Object.entries(n)){let n=e;t[n]=[...t[n]??[],...r]}return t}const lf=(e,t)=>process.platform===`win32`?t??`${e}.exe`:e;[(lf(`LTspice`),o(n(),`AppData`,`Local`,`Programs`,`ADI`,`LTspice`,`LTspice.exe`)),lf(`ngspice`),(o(n(),`QSPICE`,`QSPICE64.exe`),o(n(),`AppData`,`Local`,`Programs`,`Qspice`,`QSPICE64.exe`)),lf(`Xyce`),lf(`kicad-cli`),(lf(`yosys`),cf(sf(lf(`yosys`)),{win32:[`C:\\msys64\\mingw64\\bin\\yosys.exe`]})),(lf(`verilator`),cf(sf(lf(`verilator`)))),(lf(`iverilog`),cf(sf(lf(`iverilog`)),{win32:[`C:\\iverilog\\bin\\iverilog.exe`]})),(lf(`ghdl`),cf(sf(lf(`ghdl`)),{win32:[`C:\\msys64\\mingw64\\bin\\ghdl.exe`]})),(lf(`vivado`,`vivado.bat`),process.platform),(lf(`quartus_sh`),process.platform),...[`ice40`,`ecp5`,`gowin`,`nexus`].map(e=>({name:`nextpnr-${e}`,type:`fpga-pnr`,binary:lf(`nextpnr-${e}`),platformPaths:cf(sf(lf(`nextpnr-${e}`)))})),lf(`octave-cli`),lf(`openscad`,`openscad.com`),lf(`freecadcmd`),lf(`sigrok-cli`),(lf(`gtkwave`),cf(sf(lf(`gtkwave`)),{darwin:[`/Applications/gtkwave.app/Contents/Resources/bin/gtkwave`],win32:[`C:\\msys64\\mingw64\\bin\\gtkwave.exe`,`C:\\msys64\\ucrt64\\bin\\gtkwave.exe`]})),lf(`gerbv`)];const uf={"darwin-arm64":`@phosphor-tools/cli-darwin-arm64`,"darwin-x64":`@phosphor-tools/cli-darwin-x64`,"linux-arm64":`@phosphor-tools/cli-linux-arm64`,"linux-x64":`@phosphor-tools/cli-linux-x64`,"win32-x64":`@phosphor-tools/cli-windows-x64`};function df(e=!0){return ff()??(e?pf():null)}function ff(){let t=uf[`${process.platform}-${process.arch}`];if(!t)return null;try{let n=e(import.meta.url).resolve(`${t}/package.json`),r=process.platform===`win32`?`phosphor-eda.exe`:`phosphor-eda`,a=o(i(n),`bin`,r);return b(a,x.X_OK),a}catch{return null}}function pf(){try{return g(process.platform===`win32`?`where`:`which`,[`phosphor-eda`],{encoding:`utf-8`,timeout:5e3}).trim()}catch{return null}}async function mf(e,t,n,r){let i=`${e}/proxy/${n}`,a;try{a=await fetch(i,{method:`POST`,signal:AbortSignal.timeout(3e4),headers:{"content-type":`application/json`,authorization:`Bearer ${t}`},body:JSON.stringify(r)})}catch(t){let r=t instanceof Error?t.message:String(t);throw await Ne(`proxy_error`,{endpoint:n,error:r}),Error(`Could not connect to Phosphor proxy at ${e}: ${r}`)}if(!a.ok){let e=await a.text().catch(()=>``);throw a.status===401?Error("Session expired or invalid. Run `phosphor-mcp login` to re-authenticate."):a.status===429?Error(`Rate limit exceeded. Please wait and try again.`):(await Ne(`proxy_error`,{endpoint:n,status_code:a.status}),Error(`Proxy ${n} failed (${a.status}): ${e.slice(0,500)}`))}return a.json()}function hf(e,t,n){e.tool(t.name,t.description,t.inputSchema.shape,async e=>{try{let t=await n(e);return{content:[{type:`text`,text:JSON.stringify(t,null,2)}]}}catch(e){return{isError:!0,content:[{type:`text`,text:`${t.name} failed: ${e instanceof Error?e.message:String(e)}`}]}}})}function gf(e){e.tool(`install_schematic_tools`,`Check if the phosphor-eda CLI is installed for querying electronic schematics (Altium, KiCad, Eagle, OrCAD). Call this FIRST when the user asks about schematic connectivity, components, nets, or pin assignments. Returns the CLI path and reference guide.`,async()=>{let e=df(!1);return e?(await Ne(`schematic_tools_installed`,{success:!0}),{content:[{type:`text`,text:[`phosphor-eda CLI found at: ${e}`,``,`---`,``,tf].join(`
|
|
777
1502
|
`)}]}):(await Ne(`schematic_tools_installed`,{success:!1}),{isError:!0,content:[{type:`text`,text:[`The phosphor-eda CLI binary was not found in the expected location.`,`It should be bundled inside the @phosphor-tools/cli-* platform`,`package installed as an optional dependency of this MCP server.`,``,`This usually means the platform package failed to install or`,`is missing for this OS/architecture.`].join(`
|
|
778
1503
|
`)}]})})}function _f(e,t){let n=async()=>{let e=await t.resolveToken();if(!e)throw Error("Not authenticated. Run `phosphor-mcp login` to sign in.");return e},r=async(e,r)=>{let i=await n();return mf(t.proxyUrl,i,e,r)};hf(e,Et,async e=>{let t=await Tt(We(process.cwd()),e);return await Ne(`document_opened`),t}),hf(e,Wt,async e=>{let t=await Ut(e);return await Ne(`document_grepped`),t}),hf(e,Nt,async e=>{let r=await jt({proxyUrl:t.proxyUrl,resolveToken:n},e);return await Ne(`document_read`),r}),hf(e,Zd,async e=>{let t=await r(`datasheet_search`,e);return await Ne(`datasheet_searched`),t}),hf(e,Qd,async e=>{let t=await r(`part_search`,e);return await Ne(`part_searched`),t}),hf(e,$d,async e=>{let t=await r(`part_lookup`,e);return await Ne(`part_looked_up`),t}),hf(e,ef,async e=>{let t=await r(`part_alternatives`,e);return await Ne(`part_alternatives_requested`),t}),gf(e)}function vf(e){let t=new y({name:`phosphor-mcp`,version:Te},{instructions:`phosphor-mcp: tools for electronic hardware design — schematics, datasheets, and documents.
|
|
779
1504
|
|
|
@@ -795,4 +1520,4 @@ When answering hardware questions, always verify claims against CLI output or do
|
|
|
795
1520
|
|
|
796
1521
|
The schematic is authoritative for connectivity (what is wired to what). Interpreting those connections (pin mux, peripheral instance, alternate function) requires the device's reference manual. If you haven't read the reference, say so.
|
|
797
1522
|
|
|
798
|
-
Cite evidence inline: [datasheet p.58: "VDD 1.8–3.6V"]. If you can't cite a source, say what document you'd need.`});return e&&_f(t,e),t}async function yf(){let e=process.env.PHOSPHOR_PROXY_URL??`https://
|
|
1523
|
+
Cite evidence inline: [datasheet p.58: "VDD 1.8–3.6V"]. If you can't cite a source, say what document you'd need.`});return e&&_f(t,e),t}async function yf(){let e=process.env.PHOSPHOR_PROXY_URL??`https://app.phosphor.tools`,t=vf({proxyUrl:e,resolveToken:Re}),n=new v;await t.connect(n),await Ne(`server_started`,{proxy_url:e});let r=!1,i=async()=>{if(!r){r=!0;try{await Ae()}catch(e){console.error(`[mcp] PostHog shutdown error:`,e)}process.exit(0)}};process.on(`SIGINT`,i),process.on(`SIGTERM`,i)}function bf(e){return async(...t)=>{try{await e(...t)}catch(e){process.stderr.write(`Error: ${e instanceof Error?e.message:String(e)}\n`),process.exit(1)}}}const xf=new t().name(`phosphor-mcp`).description(`Phosphor MCP server for electronic hardware design tools`).version(Te).action(bf(yf));xf.command(`login`).description(`Authenticate with Phosphor`).action(bf(Fe)),xf.command(`logout`).description(`Clear stored credentials`).action(bf(Ie)),xf.command(`whoami`).description(`Show current user`).action(bf(Le)),xf.parse();export{};
|