@pi-oxide/extension-js 0.12.1 → 0.12.2
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/content-script.js +3 -3
- package/index.js +2 -2
- package/package.json +1 -1
package/content-script.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
(function(){"use strict";const re={debug:0,info:1,warn:2,error:3,none:4};let Rt=re.error;function yr(t){if(!t)return"";const e=[];for(const[r,n]of Object.entries(t)){let a;if(n===null)a="null";else if(n===void 0)a="undefined";else if(typeof n=="string")a=n;else if(typeof n=="number"||typeof n=="boolean")a=String(n);else try{a=JSON.stringify(n)}catch{a="[Circular]"}e.push(`${r}=${a}`)}return e.length>0?` ${e.join(" ")}`:""}function We(t,e,r){if(t<Rt)return;const n=yr(r),a=`[extension-js][content-script] ${e}${n}`;t>=re.error?console.error(a):t===re.warn?console.warn(a):console.log(a)}const be={debug:(t,e)=>{We(re.debug,t,e)},info:(t,e)=>{We(re.info,t,e)},warn:(t,e)=>{We(re.warn,t,e)},error:(t,e)=>{We(re.error,t,e)}};function vr(){window.__jsNotebookSetLogLevel=t=>{Rt=re[t]??re.error}}function _r(t){if(t.startsWith("page_")||t.startsWith("tab_")){const e=t.indexOf("_");if(e>=0)return t.slice(e+1)}return t}const wr="Content script is not connected on this tab. This tab was likely open before the extension loaded (MV3 does not retro-inject).";function kr(t){return[`await page.goto(${JSON.stringify(t||"")})`,"Or ask the user to refresh the target tab, then retry fill/click"]}function Ot(t,e){const r=e||"unknown url",n={message:t!==void 0?`Content script is not connected on tab ${t} (${r}).`:`Content script is not connected on this tab (${r}).`,code:"E_CONTENT_SCRIPT",category:"content-script",hint:wr,recovery:kr(e)};return t!==void 0&&(n.details={tabId:t,url:r}),n}function xr(t,e){var s,o;const r=t?"refId":e!=null&&e.label?"label":null,n=t||(e==null?void 0:e.label)||"";let a=`Element not found${r?` by ${r} "${n}"`:""}`;if(e!=null&&e.label&&((s=e.candidates)!=null&&s.length)){const l=e.candidates.map(d=>d.name||d.refId).filter(Boolean).slice(0,5);l.length>0?a+=`. Candidates: ${l.join(", ")}`:a+=". Candidates: none"}const i={message:a,code:"E_STALE",category:"resource",hint:"RefIds are ephemeral. They are assigned at snapshot time and invalidated when the DOM is replaced (navigation, SPA rerender, autocomplete).",recovery:["const d = await page.snapshot_data(); find the target in d.nodes","Use a fresh refId from that snapshot only","Do not reuse refIds from before press/click/navigation"],details:{staleRefId:t||void 0}};return(o=e==null?void 0:e.candidates)!=null&&o.length&&(i.details={...i.details,candidates:e.candidates}),i}function pe(t,e,r){return{message:`${t} on ${e} returned no effect.`,code:"E_NOT_INTERACTABLE",category:"resource",hint:"Some sites ignore programmatic value assignment; value may not appear in snapshot_data.",recovery:[`await page.click({ refId: ${JSON.stringify(e)} }) then await page.type({ refId: ${JSON.stringify(e)}, text: "..." })`,'Or await page.press({ key: "Enter" }) after fill',"Re-snapshot and confirm URL or node state changed"],details:{refId:e,...r}}}function Ir(t){return{message:`${t} requires a fresh observation before acting.`,code:"E_OBSERVATION_REQUIRED",category:"observation",hint:"Element refIds are only valid after a snapshot. Take a fresh observation and select a refId from its returned nodes.",recovery:["const d = await page.snapshot_data(); find the target in d.nodes","Use a refId from that snapshot only"],details:{action:t}}}function Tr(t){return t.includes("Could not establish connection")||t.includes("Receiving end does not exist")||t.includes("Timeout waiting for content-script ping")||t.includes("content script not available")||t.includes("message port closed before a response was received")}function R(t){const e=new Error(t.message);throw e.code=t.code,t.category&&(e.category=t.category),t.hint&&(e.hint=t.hint),t.recovery&&(e.recovery=t.recovery),t.details&&(e.details=t.details),e}function Te(t,e,r){var i;let n=`Element not found by label "${t}"`;if(e!==void 0){const s=e.map(o=>o.name||o.refId).filter(Boolean).slice(0,5);n+=s.length>0?`. Candidates: ${s.join(", ")}`:". Candidates: none"}const a=(i=r==null?void 0:r.searchedIds)!=null&&i.length?`Searched listbox(es): ${r.searchedIds.join(", ")}. Ignored: ${(r.ignoredIds||[]).join(", ")||"none"}.`:"No element matched this label. Check candidates or snapshot for visible controls.";return{message:n,code:"E_NOT_FOUND",category:"resource",hint:a,recovery:["const d = await page.snapshot_data(); find the target in d.nodes","Try a more specific label or use refId from snapshot"],details:{label:t,...r!=null&&r.targetRefId?{targetRefId:r.targetRefId}:{},...r!=null&&r.targetName?{targetName:r.targetName}:{},...r!=null&&r.searchedIds?{searchedIds:r.searchedIds}:{},...r!=null&&r.ignoredIds?{ignoredIds:r.ignoredIds}:{},...e!=null&&e.length?{candidates:e}:{}}}}function Sr(t){if(!(t instanceof Error))return{};const e=t.name!=="Error"?t.name:void 0,r=t.stack;let n;if(r){const a=r.match(/:(\d+):\d+\)?$/m);a&&(n=parseInt(a[1],10))}return{name:e,stack:r,line:n}}function Dt(t,e){if(typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="string"&&"message"in t&&typeof t.message=="string"){const o=t;return o.hint||o.recovery?o:o.code==="E_CONTENT_SCRIPT"?Ot(e==null?void 0:e.tabId,e==null?void 0:e.url):o}const r=(t instanceof Error?t.message:String(t))||"",{name:n,stack:a,line:i}=Sr(t);if(Tr(r))return Ot(e==null?void 0:e.tabId,e==null?void 0:e.url);if(r.includes("permission")||r.includes("Permission")){const o={message:r,code:"E_PERMISSION",category:"permission"};return(n||a||i)&&(o.details={name:n,stack:a,line:i}),o}if(r.includes("not found")||r.includes("No tab")||r.includes("No active tab")){const o={message:r,code:"E_NOT_FOUND",category:"resource"};return(n||a||i)&&(o.details={name:n,stack:a,line:i}),o}const s={message:r,code:"E_EXTENSION",category:"extension"};return(n||a||i)&&(s.details={name:n,stack:a,line:i}),s}const Er=/^e\d+$/;let qt=0;function lt(){let t=0;for(const e of document.querySelectorAll("[data-ref-id]")){const r=e.getAttribute("data-ref-id");if(!r)continue;const n=parseInt(r.replace(/^e/,""),10);!Number.isNaN(n)&&n>t&&(t=n)}qt=t}function He(t){const e=t.getAttribute("data-ref-id");if(e&&Er.test(e))return e;const r=`e${++qt}`;return t.setAttribute("data-ref-id",r),r}const dt='input, textarea, select, button, a, [role="button"], [role="link"]',Ar=new Set(["script","style","noscript","template"]),Mt=new Set(["p","span","label","footer","header","blockquote","pre","code","figcaption","td","th","li","em","strong","small","cite","q","mark","time","abbr","dfn","kbd","samp","var","sub","sup"]);function Ke(t){const e={};if(t instanceof HTMLInputElement)t.type!=="password"&&t.type!=="hidden"&&(e.value=t.value),(t.type==="checkbox"||t.type==="radio")&&(e.checked=t.checked),e.disabled=t.disabled,e.readOnly=t.readOnly;else if(t instanceof HTMLTextAreaElement)e.value=t.value,e.disabled=t.disabled,e.readOnly=t.readOnly;else if(t instanceof HTMLSelectElement){if(t.multiple){const r=[];for(const n of Array.from(t.options))n.selected&&r.push(n.value);e.value=r.join(",")}else e.value=t.value;e.disabled=t.disabled}else t instanceof HTMLOptionElement&&(e.value=t.value,e.selected=t.selected,e.disabled=t.disabled);return e}function Cr(t,e){const r=t.tagName.toLowerCase();r!=="input"&&r!=="textarea"&&r!=="select"&&r!=="option"||Object.assign(e,Ke(t))}const Nr=new Set(["http:","https:","file:"]);function se(t){if(t)try{const e=new URL(t,window.location.href);return Nr.has(e.protocol)?e.href:void 0}catch{return}}function Pt(t){const e=t.closest("article[data-post-id], [data-post-id]");if(e)return He(e)}function Rr(t){const e=t.querySelector(":scope > h2 a[href], a[data-permalink], a[rel='permalink']");if(e instanceof HTMLAnchorElement)return e;const r=t.querySelector("a[href]");return r instanceof HTMLAnchorElement?r:null}function B(t){const e=t.tagName.toLowerCase(),r=t.getAttribute("role");if(r)return r;if(e==="button"||e==="input"&&t.type==="submit")return"button";if(e==="a")return"link";if(e==="input"){const n=t.type;if(n==="text"||n==="email"||n==="password"||n==="search")return"textbox";if(n==="checkbox")return"checkbox";if(n==="radio")return"radio";if(n==="submit"||n==="button")return"button"}return e==="textarea"?"textbox":e==="select"?"combobox":e==="img"?"img":e==="h1"||e==="h2"||e==="h3"||e==="h4"||e==="h5"||e==="h6"?"heading":e==="li"?"listitem":e==="ul"||e==="ol"?"list":e==="table"?"table":e==="tr"?"row":e==="td"||e==="th"?"cell":e==="nav"?"navigation":e==="main"?"main":e==="article"?"article":e==="section"?"region":e==="aside"?"complementary":e==="form"?"form":e==="dialog"||e==="modal"?"dialog":e==="figure"?"figure":e==="figcaption"?"caption":t.getAttribute("onclick")||t.onclick?"button":"generic"}function Or(t){var e;for(const r of t.childNodes)if(r.nodeType===Node.TEXT_NODE&&((e=r.textContent)==null?void 0:e.trim()))return!0;return!1}function ut(t,e=60){var a,i;const r=[];for(const s of t.childNodes)if(s.nodeType===Node.TEXT_NODE){const o=(a=s.textContent)==null?void 0:a.trim();o&&r.push(o)}if(r.length>0)return r.join(" ").slice(0,e);const n=(i=t.textContent)==null?void 0:i.trim();return n?n.slice(0,e):""}function ge(t){let e=t;for(;e;){if(e.hidden||e.getAttribute("aria-hidden")==="true"||e.inert)return!0;const r=window.getComputedStyle(e);if(r.display==="none"||r.visibility==="hidden")return!0;e=e.parentElement}return!1}function Dr(t){return ge(t)}function Lt(t){var s;const e=t.tagName.toLowerCase();if(Ar.has(e)||Dr(t))return!1;const r=B(t);if(r==="presentation"||r==="none")return!1;if(r!=="generic")return!0;const n=t.getAttribute("aria-live");if(n&&n!=="off")return!0;const a=t.getAttribute("role");return a==="status"||a==="alert"?!0:((s=t.textContent)==null?void 0:s.trim())||""?!!(Mt.has(e)||Or(t)):!1}function oe(t){var s,o,l;const e=t.getAttribute("aria-label");if(e)return e;const r=t.getAttribute("aria-labelledby");if(r){const d=document.getElementById(r);if(d)return((s=d.textContent)==null?void 0:s.slice(0,60))||""}if(t.tagName.toLowerCase()==="img"){const d=t.getAttribute("alt");if(d)return d}const a=t.title;if(a)return a;const i=B(t);if(i!=="generic"&&i!=="list"&&i!=="table"&&i!=="row"&&i!=="region"&&i!=="navigation"&&i!=="main")return((o=t.textContent)==null?void 0:o.trim().slice(0,60))||"";if(i==="generic"&&Lt(t)){const d=ut(t);if(d)return d;const p=t.tagName.toLowerCase();if(Mt.has(p)||t.childElementCount===0)return((l=t.textContent)==null?void 0:l.trim().slice(0,60))||""}return""}function qr(t){return t instanceof HTMLInputElement&&t.type==="file"?!0:Lt(t)}function $t(t){return document.querySelector(`[data-ref-id='${CSS.escape(t)}']`)}function G(t,e){if(t.hasAttribute("disabled")||t.getAttribute("aria-disabled")==="true"){const r=t.getAttribute("data-ref-id")||void 0;R(pe(e,r??"",{reason:"disabled"}))}if(ge(t)){const r=t.getAttribute("data-ref-id")||void 0;R(pe(e,r??"",{reason:"hidden"}))}}function pt(t){var n,a,i;const e=t.toLowerCase().trim();if(!e)return null;const r=Array.from(document.querySelectorAll(dt));for(const s of r){const o=s.getAttribute("aria-label");if(o&&o.toLowerCase().trim()===e)return s;const l=s.placeholder;if(l&&l.toLowerCase().trim()===e)return s;const d=s.id;if(d){const N=document.querySelector(`label[for='${CSS.escape(d)}']`);if(N&&((n=N.textContent)==null?void 0:n.trim().toLowerCase())===e)return s}const p=s.closest("label");if(p&&((a=p.textContent)==null?void 0:a.trim().toLowerCase())===e||(((i=s.textContent)==null?void 0:i.trim().toLowerCase())||"")===e)return s}return null}function Mr(t){var a;const e=t.toLowerCase().trim();if(!e)return[];const r=Array.from(document.querySelectorAll(dt)),n=[];for(const i of r){const s=i.getAttribute("aria-label"),o=i.placeholder,l=((a=i.textContent)==null?void 0:a.trim())||"";if(![s,o,l].filter(Boolean).some(w=>w.toLowerCase().includes(e)))continue;const p=i.getAttribute("data-ref-id");if(p&&(n.push({refId:p,role:B(i),name:oe(i)||void 0}),n.length>=5))break}return n}function ye(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}function Pr(t){const e=document.querySelector(`[data-ref-id='${CSS.escape(t)}']`);let r,n;e&&(r=e.tagName.toLowerCase(),n=B(e));const a=Array.from(document.querySelectorAll(dt)),i=[];for(const s of a){const o=s.getAttribute("data-ref-id");if(o){if(r||n){const l=s.tagName.toLowerCase(),d=B(s);if(l!==r&&d!==n)continue}if(i.push({refId:o,role:B(s),name:oe(s)||void 0}),i.length>=5)break}}return i}function Se(t,e,r=!1){if(t){const n=r?Pr(t):[];R(xr(t,{candidates:n}))}if(e){const n=r?Mr(e):[];R(Te(e,n))}R({message:"Element not found",code:"E_NOT_FOUND",category:"resource"})}function J(t,e){let r=t?$t(t):null;return!r&&e&&(r=pt(e)),r||Se(t,e,!0),r}const jt=8*1024;function Lr(t){const e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function $r(t){let e="";for(let r=0;r<t.length;r+=jt){const n=t.subarray(r,r+jt);for(let a=0;a<n.length;a++)e+=String.fromCharCode(n[a])}return btoa(e)}function jr(t){return t.toLowerCase().split(";")[0].trim()}function Fr(t){return t.startsWith("image/")||t.startsWith("audio/")||t.startsWith("video/")||t==="application/octet-stream"||t==="application/pdf"||t==="application/zip"||t==="application/gzip"||t==="application/x-gzip"||t==="application/x-zip-compressed"?!0:t.startsWith("application/vnd.")}function Ur(t){for(let e=0;e<t.length;e++)if(t[e]===0)return!0;return!1}function Ft(t){return Object.fromEntries(t.headers.entries())}function Ut(t,e,r){return{status:t.status,ok:t.ok,headers:Ft(t),body:$r(e),bodyEncoding:"base64",byteLength:e.length,contentType:r,finalUrl:t.url}}function Zt(t,e,r){return{status:t.status,ok:t.ok,headers:Ft(t),body:e,bodyEncoding:"text",byteLength:new TextEncoder().encode(e).length,contentType:r,finalUrl:t.url}}async function Zr(t){const e=t.headers.get("content-type")||"",r=jr(e);if(Fr(r)){const a=new Uint8Array(await t.arrayBuffer());return Ut(t,a,e)}if(!r||r.startsWith("text/")){const a=new Uint8Array(await t.arrayBuffer());if(Ur(a))return Ut(t,a,e);const i=new TextDecoder().decode(a);return Zt(t,i,e)}const n=await t.text();return Zt(t,n,e)}const Br=new Set(["button","link","textbox","checkbox","radio","combobox","searchbox","switch","menuitem","tab","treeitem"]),Vr=new Set(["a","button","input","textarea","select","details","summary"]);function ze(t){if(t instanceof RegExp)return r=>t.test(r);if(typeof t!="string")return()=>!1;const e=t.toLowerCase();return r=>r.toLowerCase().includes(e)}function Bt(t){return Array.isArray(t)?new Set(t.filter(e=>typeof e=="string").map(e=>e.toLowerCase())):typeof t!="string"?new Set:new Set([t.toLowerCase()])}function Wr(t,e){let r=t;if(e.role){const n=Bt(e.role);r=r.filter(a=>n.has(a.role.toLowerCase()))}if(e.tag){const n=Bt(e.tag);r=r.filter(a=>n.has(a.tag.toLowerCase()))}if(e.text){const n=ze(e.text);r=r.filter(a=>a.text!==void 0&&n(a.text))}if(e.name){const n=ze(e.name);r=r.filter(a=>a.name!==void 0&&n(a.name))}if(e.href){const n=ze(e.href);r=r.filter(a=>a.href!==void 0&&n(a.href))}if(e.src){const n=ze(e.src);r=r.filter(a=>a.src!==void 0&&n(a.src))}return e.interactiveOnly&&(r=r.filter(n=>Br.has(n.role.toLowerCase())||Vr.has(n.tag.toLowerCase()))),e.limit!==void 0&&e.limit>0&&(r=r.slice(0,e.limit)),r}function O(t,e,r){const n=(e==null?void 0:e.getAttribute("data-ref-id"))??void 0;return{ok:!0,action:t,...n?{refId:n}:{},...e?Ke(e):{},...r}}function ft(t,e,r,n){(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.value!==n&&R(pe(t,r,{requested:n,actual:e.value}))}function ht(t){return{tag:t.tagName.toLowerCase(),role:B(t),name:oe(t)}}function Hr(t,e){return t.tag===e.tag&&t.role===e.role&&t.name===e.name}let Ee=!1,Vt=0,Ge,ve=new Map;function Wt(t=[]){Vt+=1,Ge=`obs${Vt}`,Ee=!0,ve=new Map;for(const e of t)ve.set(e.refId,{element:e.element,fingerprint:ht(e.element)});return Ge}function mt(){Ee=!1,Ge=void 0,ve=new Map}function Kr(){return Ee}function Ae(){return Ge}function bt(t,e){Ee||Ht(e);const r=ve.get(t);r||Je(t,"not_in_latest_observation");const{element:n,fingerprint:a}=r;if(!n.isConnected){const s=zr(r);if(s)return ve.set(t,{element:s,fingerprint:ht(s)}),s;Je(t,"disconnected")}const i=ht(n);return Hr(i,a)||Je(t,"fingerprint_changed"),n}function zr(t){const{fingerprint:e}=t,r=e.role,n=e.name.trim().toLowerCase();return Array.from(document.querySelectorAll("*")).find(a=>B(a)===r&&oe(a).toLowerCase().trim()===n)??null}function Ht(t){const e=new Error(`${t} requires a fresh observation before acting.`);throw e.code="E_OBSERVATION_REQUIRED",e.category="observation",e.hint="Element refIds are only valid after a snapshot. Take a fresh observation and select a refId from its returned nodes.",e.recovery=["const d = await page.snapshot_data(); find the target in d.nodes","Use a refId from that snapshot only"],e.details={action:t},e}function Je(t,e){const r=new Error(`Element refId "${t}" is stale (${e}).`);throw r.code="E_STALE",r.category="observation",r.hint="The element changed or was removed after the last observation.",r.recovery=["const d = await page.snapshot_data(); find the target in d.nodes","Use a fresh refId from that snapshot only"],r.details={staleRefId:t,reason:e},r}function Gr(t,e){Ee||Ht(e);const r=t.toLowerCase().trim(),n=[];for(const i of ve.values())oe(i.element).toLowerCase().trim()===r&&n.push(i.element);if(n.length===0)throw new Error(`Element not found by label "${t}"`);n.length>1&&Jr(t);const a=n[0];return a.isConnected||Je(a.getAttribute("data-ref-id")||"","disconnected"),a}function Jr(t){const e=new Error(`Multiple elements match label "${t}". The target is ambiguous.`);throw e.code="E_AMBIGUOUS_TARGET",e.category="observation",e.hint="Use a refId from the latest snapshot_data instead of a label, or narrow the label.",e.recovery=["const d = await page.snapshot_data(); find the target in d.nodes","Use the refId from that snapshot"],e.details={label:t},e}function gt(t){lt();const e=[],r=[];let n=!1,a=!1;const i=typeof MutationObserver<"u"&&document.body?new MutationObserver(()=>{a=!0}):null;i&&document.body&&i.observe(document.body,{childList:!0,subtree:!0});try{let o=function(l,d,p){var hr;if(n)return;if(e.length>=t){n=!0;return}const w=l.tagName.toLowerCase();if(w==="script"||w==="style"||w==="noscript"||w==="template")return;const N=qr(l);let F=d,st=p;if(N){const Ve=He(l),mr=B(l),ot=oe(l),$={refId:Ve,role:mr,tag:w};if(ot&&($.name=ot),$.text=ut(l,100),Cr(l,$),w==="a"){const P=se(l.getAttribute("href"));P&&($.href=P)}if(w==="img"){const P=se(l.getAttribute("src"));P&&($.src=P),$.alt=l.getAttribute("alt")||""}if(w==="input"){const P=l.getAttribute("title");P&&($.title=P);const te=l;if(te.type==="file"){const ct=te.getAttribute("accept");ct&&($.accept=ct),$.filesCount=((hr=te.files)==null?void 0:hr.length)??0}}if(w==="img"||w==="a"){const P=Pt(l);P?$.parentRefId=P:p&&($.parentRefId=p)}const br=l.getAttribute("data-post-id");if(br&&($.postId=br),w!=="a"){const P=Rr(l);if(P){const te=se(P.getAttribute("href"));te&&($.permalink=te)}}if(w!=="img"){const P=l.querySelectorAll("img");if(P.length>0){const te=[];for(const ct of P){const gr=se(ct.getAttribute("src"));gr&&te.push(gr)}te.length>0&&($.imageUrls=te)}}e.push($),st=Ve;const Nt=[`${" ".repeat(d)}- ${mr}`];ot&&Nt.push(`"${ot.replace(/"/g,'\\"')}"`),Nt.push(`[${Ve}]`),r.push(Nt.join(" ")),F=d+1}for(const Ve of l.children){if(n)break;o(Ve,F,st)}};document.body&&o(document.body,0)}finally{i&&(i.takeRecords().length>0&&(a=!0),i.disconnect())}return a&&R({message:"DOM mutated during snapshot collection",code:"E_SNAPSHOT",category:"resource",details:{cause:"dom_mutated_during_snapshot",nodesCollected:e.length},recovery:["Wait for the page to finish rendering before snapshot","Retry with a smaller max_nodes bound","Use page.snapshot_data() after navigation settles"]}),{text:[`URL: ${window.location.href}`,`Title: ${document.title}`,""].concat(r).join(`
|
|
2
|
-
`),nodes:e,url:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight}}}const
|
|
3
|
-
`)}function sn(t){const e=new Map(Array.from(document.querySelectorAll('[role="listbox"]')).map(p=>[p,{hidden:ge(p),sig:zt(p)}]));for(const p of["mouseover","mousedown","mouseup"])t.dispatchEvent(new MouseEvent(p,{bubbles:!0,cancelable:!0}));t.click();const n=`${t.getAttribute("aria-controls")||""} ${t.getAttribute("aria-owns")||""}`.trim().split(/\s+/).filter(Boolean).map(p=>document.getElementById(p)).filter(p=>p instanceof HTMLElement&&p.getAttribute("role")==="listbox"),a=Array.from(document.querySelectorAll('[role="listbox"]')),i=a.filter(p=>{const w=e.get(p);return ge(p)?!1:!w||w.hidden?!0:zt(p)!==w.sig}),s=Array.from(t.querySelectorAll('[role="listbox"]')),o=t.getAttribute("role")==="listbox"?[t]:[],l=[...new Set([...n,...i,...s,...o])],d=l.map(p=>p.id).filter(Boolean);return{roots:l,searchedIds:d,allListboxes:a}}const on={click:t=>{const e=t.refId,r=t.label;let n;return e?n=bt(e,"click"):r?n=Gr(r,"click"):Se(e,r,!0),G(n,"click"),n.click(),O("click",n,{observationId:Ae(),dispatched:!0,verification:"required"})},fill:t=>{const e=t.refId,r=t.label,n=t.value;let a;if(e?a=bt(e,"fill"):r?(a=pt(r),a||Se(e,r,!0)):Se(e,r,!0),G(a,"fill"),a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement){a.value=n;const i=new InputEvent("input",{bubbles:!0});a.dispatchEvent(i);const s=e||a.getAttribute("data-ref-id")||"";return ft("fill",a,s,n),O("fill",a,{value:a.value,observationId:Ae(),dispatched:!0,verification:"required"})}if(a instanceof HTMLElement&&a.isContentEditable){a.innerText=n;const i=new InputEvent("input",{bubbles:!0,inputType:"insertText",data:n});return a.dispatchEvent(i),e||a.getAttribute("data-ref-id"),O("fill",a,{value:a.innerText,observationId:Ae(),dispatched:!0,verification:"required"})}throw new Error("Element is not an input or contenteditable")},set_files:async t=>{var o,l;const e=Yr(t),r=J(t.refId,t.label);let n;if(r instanceof HTMLInputElement&&r.type==="file")n=r;else{const d=r.querySelector('input[type="file"]'),p=(o=r.closest("label"))==null?void 0:o.querySelector('input[type="file"]'),w=r.getAttribute("for"),N=w?(l=document.getElementById(w))==null?void 0:l.querySelector('input[type="file"]'):null,F=d??p??N;if(!F){const st=t.refId??"";R(pe("setFiles",st,{reason:"not_file_input"}))}n=F}const a=new DataTransfer,i=[];for(const d of e){const p=d.kind==="bytes"?en(d):await tn(d);a.items.add(p),i.push(p.name)}n.files=a.files,n.dispatchEvent(new Event("change",{bubbles:!0}));const s=t.refId||n.getAttribute("data-ref-id")||"";return rn(n,s,i),O("setFiles",n,{fileCount:i.length,fileNames:i})},type:t=>{const e=t.refId,r=t.label,n=t.text,a=J(e,r);if(G(a,"type"),a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement){a.value=n;const i=new InputEvent("input",{bubbles:!0});a.dispatchEvent(i);const s=e||a.getAttribute("data-ref-id")||"";return ft("type",a,s,n),O("type",a,{text:a.value})}throw new Error("Element is not an input")},append:t=>{const e=t.refId,r=t.label,n=t.text,a=J(e,r);if(G(a,"append"),a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement){const s=a.value+n;a.value+=n;const o=new InputEvent("input",{bubbles:!0});a.dispatchEvent(o);const l=e||a.getAttribute("data-ref-id")||"";return ft("append",a,l,s),O("append",a,{text:a.value})}throw new Error("Element is not an input")},press:t=>{Kr()||R(Ir("press"));const e=t.key,r=t.refId,n=t.label;let a=document,i=null;(r||n)&&(r?i=bt(r,"press"):n&&(i=pt(n),i||Se(r,n,!0)),G(i,"press"),a=i);const s=new KeyboardEvent("keydown",{key:e,bubbles:!0});a.dispatchEvent(s);const o=new KeyboardEvent("keyup",{key:e,bubbles:!0});return a.dispatchEvent(o),O("press",i,{key:e,observationId:Ae(),dispatched:!0,verification:"required"})},select:t=>{const e=t.refId,r=t.label,n=t.value,a=J(e,r);if(G(a,"select"),a instanceof HTMLSelectElement){if(Array.isArray(n)){const i=new Set(n);let s=0;for(const l of Array.from(a.options)){const d=i.has(l.value);l.selected=d,d&&(s+=1)}!a.multiple&&s>1&&R(pe("select",e??"",{reason:"single_select_multiple_values"})),a.dispatchEvent(new Event("change",{bubbles:!0}));const o=Array.from(a.options).filter(l=>l.selected).map(l=>l.value);return O("select",a,{value:o})}return a.value=n,a.dispatchEvent(new Event("change",{bubbles:!0})),O("select",a,{value:a.value})}throw new Error("Element is not a select")},select_option:t=>{const e=t.value,r=J(t.refId,t.label);if(G(r,"select_option"),r instanceof HTMLSelectElement){const p=Array.from(r.options).find(w=>(w.text||"").trim()===e)||Array.from(r.options).find(w=>(w.text||"").trim().toLowerCase()===e.toLowerCase());if(!p){const w=Array.from(r.options).map((N,F)=>({refId:`opt${F}`,name:(N.text||"").trim()||void 0}));R(Te(e,w))}return r.value=p.value,r.dispatchEvent(new Event("change",{bubbles:!0})),O("select_option",r,{value:p.value})}const n=r,{roots:a,searchedIds:i,allListboxes:s}=sn(n),o=[...new Set(a.flatMap(p=>Array.from(p.querySelectorAll('[role="option"]'))))],l=e.trim().toLowerCase(),d=o.find(p=>(p.textContent||"").trim()===e.trim())||o.find(p=>(p.textContent||"").trim().toLowerCase()===l);if(!d){const p=o.map((N,F)=>({refId:N.getAttribute("data-ref-id")||`opt${F}`,name:(N.textContent||"").trim()||void 0})),w=s.filter(N=>!a.includes(N)&&!ge(N)).map(N=>N.id).filter(Boolean);R(Te(e,p,{searchedIds:i,ignoredIds:w,targetRefId:n.getAttribute("data-ref-id")||void 0,targetName:n.getAttribute("aria-label")||n.getAttribute("data-ref-id")||""}))}for(const p of["mouseover","mousedown","mouseup"])d.dispatchEvent(new MouseEvent(p,{bubbles:!0,cancelable:!0}));return d.click(),O("select_option",r,{value:e})},check:t=>{const e=t.refId,r=t.label,n=t.checked??!0,a=J(e,r);if(G(a,"check"),a instanceof HTMLInputElement&&(a.type==="checkbox"||a.type==="radio"))return a.checked=n,a.dispatchEvent(new Event("change",{bubbles:!0})),O("check",a,{checked:a.checked});throw new Error("Element is not a checkbox or radio")},check_radio:t=>{const e=t.name,r=t.value,n=`input[type="radio"][name="${CSS.escape(e)}"]`,a=Array.from(document.querySelectorAll(n));a.length===0&&R(Te(`radio group "${e}"`,[]));const i=a.find(s=>s.value===r);if(!i){const s=a.map((o,l)=>({refId:`radio${l}`,name:o.value||void 0}));R(Te(`radio value "${r}" in group "${e}"`,s))}return G(i,"check_radio"),i.checked=!0,i.dispatchEvent(new Event("change",{bubbles:!0})),O("check_radio",i,{checked:i.checked,value:i.value})},hover:t=>{const e=t.refId,r=t.label,n=J(e,r);G(n,"hover");const a=new MouseEvent("mouseenter",{bubbles:!0});return n.dispatchEvent(a),O("hover",n)},unhover:()=>{const t=new MouseEvent("mouseleave",{bubbles:!0});return document.body.dispatchEvent(t),O("unhover",null)},submit:t=>{const e=t.refId,r=t.label,n=J(e,r);let a=null;return n instanceof HTMLFormElement?a=n:n.closest("form")&&(a=n.closest("form")),a||R(pe("submit",e??"",{reason:"not_form"})),typeof a.requestSubmit=="function"?a.requestSubmit():a.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0})),O("submit",a,{dispatched:!0,observationId:Ae(),verification:"required"})},scroll:t=>{mt();const e=t.direction,r=t.amount,n=e==="down"?r:e==="up"?-r:0,a=e==="right"?r:e==="left"?-r:0;return window.scrollBy({top:n,left:a,behavior:"smooth"}),O("scroll",null,{direction:e,amount:r})},dblclick:t=>{const e=t.refId,r=t.label,n=J(e,r),a=n;return a.click(),a.click(),a.dispatchEvent(new MouseEvent("dblclick",{bubbles:!0,cancelable:!0})),O("dblclick",n)},forward:()=>(mt(),window.history.forward(),O("forward",null)),scroll_to:t=>{const e=t.refId,r=t.label,n=t.x??0,a=t.y??0;if(e||r){const i=J(e,r);return i.scrollIntoView({behavior:"smooth"}),O("scroll_to",i)}return window.scrollTo({top:a,left:n,behavior:"smooth"}),O("scroll_to",null,{amount:a})},evaluate:t=>{const e=nn(t);return new Function(e)()},back:()=>(mt(),window.history.back(),O("back",null)),ping:()=>({ok:!0}),snapshot:async t=>{document.body||R({message:"Document body not available for snapshot",code:"E_SNAPSHOT",category:"resource",details:{cause:"document.body is null"},recovery:["Wait for the page to load fully before taking a snapshot."]});const e=yt(t);be.debug("snapshot",{maxNodes:e,hasBody:!!document.body});const r=gt(e),n=r.nodes.map(i=>{const s=$t(i.refId);return s?{refId:i.refId,element:s}:null}).filter(i=>i!==null),a=Wt(n);return{...r,observationId:a}},snapshot_text:async t=>{document.body||R({message:"Document body not available for snapshot",code:"E_SNAPSHOT",category:"resource",details:{cause:"document.body is null"},recovery:["Wait for the page to load fully before taking a snapshot."]});const e=yt(t);return gt(e).text},snapshot_query:async t=>{document.body||R({message:"Document body not available for snapshot",code:"E_SNAPSHOT",category:"resource",details:{cause:"document.body is null"},recovery:["Wait for the page to load fully before taking a snapshot."]});const e=yt(t),r=gt(e),n=t.filter??{};return{text:"",nodes:Wr(r.nodes,n),url:r.url,title:r.title,viewport:r.viewport}},find:t=>{lt();const e=t.selector,r=Array.from(document.querySelectorAll(e)),n=[],a=r.map(i=>{var w;const s=He(i);n.push({refId:s,element:i});const o=B(i),l=oe(i),d={tag:i.tagName.toLowerCase(),refId:s,role:o,text:((w=i.textContent)==null?void 0:w.slice(0,100))||"",...Ke(i)};l&&(d.name=l);const p=i.tagName.toLowerCase();if(p==="a"){const N=se(i.getAttribute("href"));N&&(d.href=N)}if(p==="img"){const N=se(i.getAttribute("src"));N&&(d.src=N),d.alt=i.getAttribute("alt")||""}if(p==="input"){const N=i.getAttribute("title");N&&(d.title=N)}if(p==="img"||p==="a"){const N=Pt(i);N&&(d.parentRefId=N)}return d});return Wt(n),a},dom:t=>{lt();const e=t.selector,r=t.depth??2,n=t.includeHidden??!0;return{nodes:Array.from(document.querySelectorAll(e)).map(s=>Kt(s,r,n)).filter(s=>s!==null),url:window.location.href,title:document.title}},wait_for:async(t,e)=>{const r=t.selector,n=Number(t.timeout),a=Date.now();for(;;){if(e!=null&&e.aborted)throw new DOMException("Aborted","AbortError");if(document.querySelector(r))return!0;Date.now()-a>=n&&R({message:`Timeout waiting for selector: ${r}`,code:"E_TIMEOUT",category:"timeout"}),await Xr(Qr,e)}},extract:t=>{var n,a;const e=t.fields,r={};for(const i of e)if(i==="title")r.title=document.title;else if(i==="url")r.url=window.location.href;else if(i==="headings"){const s=Array.from(document.querySelectorAll("h1, h2, h3, h4, h5, h6"));r.headings=s.map(o=>{var l;return{tag:o.tagName,text:((l=o.textContent)==null?void 0:l.trim().slice(0,200))||""}})}else if(i==="links"){const s=Array.from(document.querySelectorAll("a[href]"));r.links=s.map(o=>{var l;return{href:o.getAttribute("href"),text:((l=o.textContent)==null?void 0:l.trim().slice(0,100))||""}})}else i==="text"&&(r.text=((a=(n=document.body)==null?void 0:n.textContent)==null?void 0:a.trim().slice(0,500))||"");return r},fetch:async(t,e)=>{const r=t.url;if(!r)throw new Error("fetch requires a url");const n=t.method.toUpperCase(),a=t.headers,i=t.body,s=Number(t.timeout),o=new AbortController,l=()=>o.abort();if(e){if(e.aborted)throw new DOMException("Aborted","AbortError");e.addEventListener("abort",l,{once:!0})}const d=setTimeout(()=>o.abort(),s);try{const p={method:n,headers:a,signal:o.signal};i!==null&&(p.body=i);const w=await fetch(r,p);return Zr(w)}finally{clearTimeout(d),e==null||e.removeEventListener("abort",l)}}};function Qe(t){return t==null?{}:t instanceof Map?Object.fromEntries([...t.entries()].map(([e,r])=>[e,Qe(r)])):Array.isArray(t)?t.map(Qe):t}var C;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function r(a){throw new Error}t.assertNever=r,t.arrayToEnum=a=>{const i={};for(const s of a)i[s]=s;return i},t.getValidEnumValues=a=>{const i=t.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),s={};for(const o of i)s[o]=a[o];return t.objectValues(s)},t.objectValues=a=>t.objectKeys(a).map(function(i){return a[i]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const i=[];for(const s in a)Object.prototype.hasOwnProperty.call(a,s)&&i.push(s);return i},t.find=(a,i)=>{for(const s of a)if(i(s))return s},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,i=" | "){return a.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(C||(C={}));var Gt;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Gt||(Gt={}));const b=C.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ce=t=>{switch(typeof t){case"undefined":return b.undefined;case"string":return b.string;case"number":return Number.isNaN(t)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(t)?b.array:t===null?b.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?b.promise:typeof Map<"u"&&t instanceof Map?b.map:typeof Set<"u"&&t instanceof Set?b.set:typeof Date<"u"&&t instanceof Date?b.date:b.object;default:return b.unknown}},f=C.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class U extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(i){return i.message},n={_errors:[]},a=i=>{for(const s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(a);else if(s.code==="invalid_return_type")a(s.returnTypeError);else if(s.code==="invalid_arguments")a(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,l=0;for(;l<s.path.length;){const d=s.path[l];l===s.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(r(s))):o[d]=o[d]||{_errors:[]},o=o[d],l++}}};return a(this),n}static assert(e){if(!(e instanceof U))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,C.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const a of this.issues)if(a.path.length>0){const i=a.path[0];r[i]=r[i]||[],r[i].push(e(a))}else n.push(e(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}U.create=t=>new U(t);const Ce=(t,e)=>{let r;switch(t.code){case f.invalid_type:t.received===b.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case f.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,C.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${C.joinValues(t.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${C.joinValues(t.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${C.joinValues(t.options)}, received '${t.received}'`;break;case f.invalid_arguments:r="Invalid function arguments";break;case f.invalid_return_type:r="Invalid function return type";break;case f.invalid_date:r="Invalid date";break;case f.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:C.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case f.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case f.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case f.custom:r="Invalid input";break;case f.invalid_intersection_types:r="Intersection results could not be merged";break;case f.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case f.not_finite:r="Number must be finite";break;default:r=e.defaultError,C.assertNever(t)}return{message:r}};let cn=Ce;function vt(){return cn}const _t=t=>{const{data:e,path:r,errorMaps:n,issueData:a}=t,i=[...r,...a.path||[]],s={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let o="";const l=n.filter(d=>!!d).slice().reverse();for(const d of l)o=d(s,{data:e,defaultError:o}).message;return{...a,path:i,message:o}};function m(t,e){const r=vt(),n=_t({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ce?void 0:Ce].filter(a=>!!a)});t.common.issues.push(n)}class L{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const a of r){if(a.status==="aborted")return k;a.status==="dirty"&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const a of r){const i=await a.key,s=await a.value;n.push({key:i,value:s})}return L.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const a of r){const{key:i,value:s}=a;if(i.status==="aborted"||s.status==="aborted")return k;i.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof s.value<"u"||a.alwaysSet)&&(n[i.value]=s.value)}return{status:e.value,value:n}}}const k=Object.freeze({status:"aborted"}),Ne=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),Jt=t=>t.status==="aborted",Qt=t=>t.status==="dirty",_e=t=>t.status==="valid",Xe=t=>typeof Promise<"u"&&t instanceof Promise;var g;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(g||(g={}));class Q{constructor(e,r,n,a){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const Xt=(t,e)=>{if(_e(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new U(t.common.issues);return this._error=r,this._error}}};function I(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:a}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(s,o)=>{const{message:l}=t;return s.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??n??o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:l??r??o.defaultError}},description:a}}class S{get description(){return this._def.description}_getType(e){return ce(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new L,ctx:{common:e.parent.common,data:e.data,parsedType:ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Xe(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){const n={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ce(e)},a=this._parseSync({data:e,path:n.path,parent:n});return Xt(n,a)}"~validate"(e){var n,a;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ce(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:r});return _e(i)?{value:i.value}:{issues:r.common.issues}}catch(i){(a=(n=i==null?void 0:i.message)==null?void 0:n.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>_e(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ce(e)},a=this._parse({data:e,path:n.path,parent:n}),i=await(Xe(a)?a:Promise.resolve(a));return Xt(n,i)}refine(e,r){const n=a=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(a):r;return this._refinement((a,i)=>{const s=e(a),o=()=>i.addIssue({code:f.custom,...n(a)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,a)=>e(n)?!0:(a.addIssue(typeof r=="function"?r(n,a):r),!1))}_refinement(e){return new ae({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return W.create(this,this._def)}nullable(){return ue.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return V.create(this)}promise(){return xe.create(this,this._def)}or(e){return De.create([this,e],this._def)}and(e){return qe.create(this,e,this._def)}transform(e){return new ae({...I(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new je({...I(this._def),innerType:this,defaultValue:r,typeName:x.ZodDefault})}brand(){return new At({typeName:x.ZodBranded,type:this,...I(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Fe({...I(this._def),innerType:this,catchValue:r,typeName:x.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return rt.create(this,e)}readonly(){return Ue.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ln=/^c[^\s-]{8,}$/i,dn=/^[0-9a-z]+$/,un=/^[0-9A-HJKMNP-TV-Z]{26}$/i,pn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,fn=/^[a-z0-9_-]{21}$/i,hn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,mn=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,bn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,gn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let wt;const yn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,vn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,_n=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,wn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,kn=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,xn=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Yt="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",In=new RegExp(`^${Yt}$`);function er(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Tn(t){return new RegExp(`^${er(t)}$`)}function Sn(t){let e=`${Yt}T${er(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function En(t,e){return!!((e==="v4"||!e)&&yn.test(t)||(e==="v6"||!e)&&_n.test(t))}function An(t,e){if(!hn.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function Cn(t,e){return!!((e==="v4"||!e)&&vn.test(t)||(e==="v6"||!e)&&wn.test(t))}class X extends S{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==b.string){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_type,expected:b.string,received:i.parsedType}),k}const n=new L;let a;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const s=e.data.length>i.value,o=e.data.length<i.value;(s||o)&&(a=this._getOrReturnCtx(e,a),s?m(a,{code:f.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&m(a,{code:f.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")bn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"email",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")wt||(wt=new RegExp(gn,"u")),wt.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"emoji",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")pn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"uuid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")fn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"nanoid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")ln.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"cuid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")dn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"cuid2",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")un.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"ulid",code:f.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),m(a,{validation:"url",code:f.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"regex",code:f.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(e,a),m(a,{code:f.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(a=this._getOrReturnCtx(e,a),m(a,{code:f.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(a=this._getOrReturnCtx(e,a),m(a,{code:f.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Sn(i).test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:f.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?In.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:f.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Tn(i).test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:f.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?mn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"duration",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?En(e.data,i.version)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"ip",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?An(e.data,i.alg)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"jwt",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?Cn(e.data,i.version)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"cidr",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?kn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"base64",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?xn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"base64url",code:f.invalid_string,message:i.message}),n.dirty()):C.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(a=>e.test(a),{validation:r,code:f.invalid_string,...g.errToObj(n)})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...g.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...g.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...g.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...g.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...g.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...g.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...g.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...g.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...g.errToObj(r)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new X({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new X({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new X({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}X.create=t=>new X({checks:[],typeName:x.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...I(t)});function Nn(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,a=r>n?r:n,i=Number.parseInt(t.toFixed(a).replace(".","")),s=Number.parseInt(e.toFixed(a).replace(".",""));return i%s/10**a}class fe extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==b.number){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_type,expected:b.number,received:i.parsedType}),k}let n;const a=new L;for(const i of this._def.checks)i.kind==="int"?C.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:f.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:f.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:f.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?Nn(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),m(n,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:f.not_finite,message:i.message}),a.dirty()):C.assertNever(i);return{status:a.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,g.toString(r))}gt(e,r){return this.setLimit("min",e,!1,g.toString(r))}lte(e,r){return this.setLimit("max",e,!0,g.toString(r))}lt(e,r){return this.setLimit("max",e,!1,g.toString(r))}setLimit(e,r,n,a){return new fe({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(a)}]})}_addCheck(e){return new fe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&C.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}fe.create=t=>new fe({checks:[],typeName:x.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...I(t)});class he extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==b.bigint)return this._getInvalidInput(e);let n;const a=new L;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:f.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:f.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),m(n,{code:f.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):C.assertNever(i);return{status:a.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return m(r,{code:f.invalid_type,expected:b.bigint,received:r.parsedType}),k}gte(e,r){return this.setLimit("min",e,!0,g.toString(r))}gt(e,r){return this.setLimit("min",e,!1,g.toString(r))}lte(e,r){return this.setLimit("max",e,!0,g.toString(r))}lt(e,r){return this.setLimit("max",e,!1,g.toString(r))}setLimit(e,r,n,a){return new he({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(a)}]})}_addCheck(e){return new he({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}he.create=t=>new he({checks:[],typeName:x.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...I(t)});class Ye extends S{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==b.boolean){const n=this._getOrReturnCtx(e);return m(n,{code:f.invalid_type,expected:b.boolean,received:n.parsedType}),k}return j(e.data)}}Ye.create=t=>new Ye({typeName:x.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...I(t)});class Re extends S{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==b.date){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_type,expected:b.date,received:i.parsedType}),k}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_date}),k}const n=new L;let a;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:f.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:f.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):C.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Re({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Re.create=t=>new Re({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:x.ZodDate,...I(t)});class tr extends S{_parse(e){if(this._getType(e)!==b.symbol){const n=this._getOrReturnCtx(e);return m(n,{code:f.invalid_type,expected:b.symbol,received:n.parsedType}),k}return j(e.data)}}tr.create=t=>new tr({typeName:x.ZodSymbol,...I(t)});class et extends S{_parse(e){if(this._getType(e)!==b.undefined){const n=this._getOrReturnCtx(e);return m(n,{code:f.invalid_type,expected:b.undefined,received:n.parsedType}),k}return j(e.data)}}et.create=t=>new et({typeName:x.ZodUndefined,...I(t)});class Oe extends S{_parse(e){if(this._getType(e)!==b.null){const n=this._getOrReturnCtx(e);return m(n,{code:f.invalid_type,expected:b.null,received:n.parsedType}),k}return j(e.data)}}Oe.create=t=>new Oe({typeName:x.ZodNull,...I(t)});class kt extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return j(e.data)}}kt.create=t=>new kt({typeName:x.ZodAny,...I(t)});class me extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return j(e.data)}}me.create=t=>new me({typeName:x.ZodUnknown,...I(t)});class le extends S{_parse(e){const r=this._getOrReturnCtx(e);return m(r,{code:f.invalid_type,expected:b.never,received:r.parsedType}),k}}le.create=t=>new le({typeName:x.ZodNever,...I(t)});class xt extends S{_parse(e){if(this._getType(e)!==b.undefined){const n=this._getOrReturnCtx(e);return m(n,{code:f.invalid_type,expected:b.void,received:n.parsedType}),k}return j(e.data)}}xt.create=t=>new xt({typeName:x.ZodVoid,...I(t)});class V extends S{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),a=this._def;if(r.parsedType!==b.array)return m(r,{code:f.invalid_type,expected:b.array,received:r.parsedType}),k;if(a.exactLength!==null){const s=r.data.length>a.exactLength.value,o=r.data.length<a.exactLength.value;(s||o)&&(m(r,{code:s?f.too_big:f.too_small,minimum:o?a.exactLength.value:void 0,maximum:s?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&r.data.length<a.minLength.value&&(m(r,{code:f.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&r.data.length>a.maxLength.value&&(m(r,{code:f.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>a.type._parseAsync(new Q(r,s,r.path,o)))).then(s=>L.mergeArray(n,s));const i=[...r.data].map((s,o)=>a.type._parseSync(new Q(r,s,r.path,o)));return L.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new V({...this._def,minLength:{value:e,message:g.toString(r)}})}max(e,r){return new V({...this._def,maxLength:{value:e,message:g.toString(r)}})}length(e,r){return new V({...this._def,exactLength:{value:e,message:g.toString(r)}})}nonempty(e){return this.min(1,e)}}V.create=(t,e)=>new V({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...I(e)});function we(t){if(t instanceof D){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=W.create(we(n))}return new D({...t._def,shape:()=>e})}else return t instanceof V?new V({...t._def,type:we(t.element)}):t instanceof W?W.create(we(t.unwrap())):t instanceof ue?ue.create(we(t.unwrap())):t instanceof Y?Y.create(t.items.map(e=>we(e))):t}class D extends S{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=C.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==b.object){const d=this._getOrReturnCtx(e);return m(d,{code:f.invalid_type,expected:b.object,received:d.parsedType}),k}const{status:n,ctx:a}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof le&&this._def.unknownKeys==="strip"))for(const d in a.data)s.includes(d)||o.push(d);const l=[];for(const d of s){const p=i[d],w=a.data[d];l.push({key:{status:"valid",value:d},value:p._parse(new Q(a,w,a.path,d)),alwaysSet:d in a.data})}if(this._def.catchall instanceof le){const d=this._def.unknownKeys;if(d==="passthrough")for(const p of o)l.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(d==="strict")o.length>0&&(m(a,{code:f.unrecognized_keys,keys:o}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const p of o){const w=a.data[p];l.push({key:{status:"valid",value:p},value:d._parse(new Q(a,w,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const d=[];for(const p of l){const w=await p.key,N=await p.value;d.push({key:w,value:N,alwaysSet:p.alwaysSet})}return d}).then(d=>L.mergeObjectSync(n,d)):L.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new D({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,s;const a=((s=(i=this._def).errorMap)==null?void 0:s.call(i,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:g.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new D({...this._def,unknownKeys:"strip"})}passthrough(){return new D({...this._def,unknownKeys:"passthrough"})}extend(e){return new D({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new D({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new D({...this._def,catchall:e})}pick(e){const r={};for(const n of C.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new D({...this._def,shape:()=>r})}omit(e){const r={};for(const n of C.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new D({...this._def,shape:()=>r})}deepPartial(){return we(this)}partial(e){const r={};for(const n of C.objectKeys(this.shape)){const a=this.shape[n];e&&!e[n]?r[n]=a:r[n]=a.optional()}return new D({...this._def,shape:()=>r})}required(e){const r={};for(const n of C.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof W;)i=i._def.innerType;r[n]=i}return new D({...this._def,shape:()=>r})}keyof(){return rr(C.objectKeys(this.shape))}}D.create=(t,e)=>new D({shape:()=>t,unknownKeys:"strip",catchall:le.create(),typeName:x.ZodObject,...I(e)}),D.strictCreate=(t,e)=>new D({shape:()=>t,unknownKeys:"strict",catchall:le.create(),typeName:x.ZodObject,...I(e)}),D.lazycreate=(t,e)=>new D({shape:t,unknownKeys:"strip",catchall:le.create(),typeName:x.ZodObject,...I(e)});class De extends S{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function a(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=i.map(o=>new U(o.ctx.common.issues));return m(r,{code:f.invalid_union,unionErrors:s}),k}if(r.common.async)return Promise.all(n.map(async i=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(a);{let i;const s=[];for(const l of n){const d={...r,common:{...r.common,issues:[]},parent:null},p=l._parseSync({data:r.data,path:r.path,parent:d});if(p.status==="valid")return p;p.status==="dirty"&&!i&&(i={result:p,ctx:d}),d.common.issues.length&&s.push(d.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const o=s.map(l=>new U(l));return m(r,{code:f.invalid_union,unionErrors:o}),k}}get options(){return this._def.options}}De.create=(t,e)=>new De({options:t,typeName:x.ZodUnion,...I(e)});const ne=t=>t instanceof Le?ne(t.schema):t instanceof ae?ne(t.innerType()):t instanceof $e?[t.value]:t instanceof de?t.options:t instanceof St?C.objectValues(t.enum):t instanceof je?ne(t._def.innerType):t instanceof et?[void 0]:t instanceof Oe?[null]:t instanceof W?[void 0,...ne(t.unwrap())]:t instanceof ue?[null,...ne(t.unwrap())]:t instanceof At||t instanceof Ue?ne(t.unwrap()):t instanceof Fe?ne(t._def.innerType):[];class tt extends S{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==b.object)return m(r,{code:f.invalid_type,expected:b.object,received:r.parsedType}),k;const n=this.discriminator,a=r.data[n],i=this.optionsMap.get(a);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(m(r,{code:f.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),k)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const a=new Map;for(const i of r){const s=ne(i.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(a.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);a.set(o,i)}}return new tt({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:a,...I(n)})}}function It(t,e){const r=ce(t),n=ce(e);if(t===e)return{valid:!0,data:t};if(r===b.object&&n===b.object){const a=C.objectKeys(e),i=C.objectKeys(t).filter(o=>a.indexOf(o)!==-1),s={...t,...e};for(const o of i){const l=It(t[o],e[o]);if(!l.valid)return{valid:!1};s[o]=l.data}return{valid:!0,data:s}}else if(r===b.array&&n===b.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let i=0;i<t.length;i++){const s=t[i],o=e[i],l=It(s,o);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return r===b.date&&n===b.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class qe extends S{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),a=(i,s)=>{if(Jt(i)||Jt(s))return k;const o=It(i.value,s.value);return o.valid?((Qt(i)||Qt(s))&&r.dirty(),{status:r.value,value:o.data}):(m(n,{code:f.invalid_intersection_types}),k)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,s])=>a(i,s)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}qe.create=(t,e,r)=>new qe({left:t,right:e,typeName:x.ZodIntersection,...I(r)});class Y extends S{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==b.array)return m(n,{code:f.invalid_type,expected:b.array,received:n.parsedType}),k;if(n.data.length<this._def.items.length)return m(n,{code:f.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),k;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:f.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...n.data].map((s,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new Q(n,s,n.path,o)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>L.mergeArray(r,s)):L.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Y({...this._def,rest:e})}}Y.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Y({items:t,typeName:x.ZodTuple,rest:null,...I(e)})};class Me extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==b.object)return m(n,{code:f.invalid_type,expected:b.object,received:n.parsedType}),k;const a=[],i=this._def.keyType,s=this._def.valueType;for(const o in n.data)a.push({key:i._parse(new Q(n,o,n.path,o)),value:s._parse(new Q(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?L.mergeObjectAsync(r,a):L.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof S?new Me({keyType:e,valueType:r,typeName:x.ZodRecord,...I(n)}):new Me({keyType:X.create(),valueType:e,typeName:x.ZodRecord,...I(r)})}}class Tt extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==b.map)return m(n,{code:f.invalid_type,expected:b.map,received:n.parsedType}),k;const a=this._def.keyType,i=this._def.valueType,s=[...n.data.entries()].map(([o,l],d)=>({key:a._parse(new Q(n,o,n.path,[d,"key"])),value:i._parse(new Q(n,l,n.path,[d,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of s){const d=await l.key,p=await l.value;if(d.status==="aborted"||p.status==="aborted")return k;(d.status==="dirty"||p.status==="dirty")&&r.dirty(),o.set(d.value,p.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const l of s){const d=l.key,p=l.value;if(d.status==="aborted"||p.status==="aborted")return k;(d.status==="dirty"||p.status==="dirty")&&r.dirty(),o.set(d.value,p.value)}return{status:r.value,value:o}}}}Tt.create=(t,e,r)=>new Tt({valueType:e,keyType:t,typeName:x.ZodMap,...I(r)});class ke extends S{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==b.set)return m(n,{code:f.invalid_type,expected:b.set,received:n.parsedType}),k;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(m(n,{code:f.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),r.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(m(n,{code:f.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const i=this._def.valueType;function s(l){const d=new Set;for(const p of l){if(p.status==="aborted")return k;p.status==="dirty"&&r.dirty(),d.add(p.value)}return{status:r.value,value:d}}const o=[...n.data.values()].map((l,d)=>i._parse(new Q(n,l,n.path,d)));return n.common.async?Promise.all(o).then(l=>s(l)):s(o)}min(e,r){return new ke({...this._def,minSize:{value:e,message:g.toString(r)}})}max(e,r){return new ke({...this._def,maxSize:{value:e,message:g.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}ke.create=(t,e)=>new ke({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...I(e)});class Pe extends S{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==b.function)return m(r,{code:f.invalid_type,expected:b.function,received:r.parsedType}),k;function n(o,l){return _t({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,vt(),Ce].filter(d=>!!d),issueData:{code:f.invalid_arguments,argumentsError:l}})}function a(o,l){return _t({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,vt(),Ce].filter(d=>!!d),issueData:{code:f.invalid_return_type,returnTypeError:l}})}const i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof xe){const o=this;return j(async function(...l){const d=new U([]),p=await o._def.args.parseAsync(l,i).catch(F=>{throw d.addIssue(n(l,F)),d}),w=await Reflect.apply(s,this,p);return await o._def.returns._def.type.parseAsync(w,i).catch(F=>{throw d.addIssue(a(w,F)),d})})}else{const o=this;return j(function(...l){const d=o._def.args.safeParse(l,i);if(!d.success)throw new U([n(l,d.error)]);const p=Reflect.apply(s,this,d.data),w=o._def.returns.safeParse(p,i);if(!w.success)throw new U([a(p,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Pe({...this._def,args:Y.create(e).rest(me.create())})}returns(e){return new Pe({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Pe({args:e||Y.create([]).rest(me.create()),returns:r||me.create(),typeName:x.ZodFunction,...I(n)})}}class Le extends S{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Le.create=(t,e)=>new Le({getter:t,typeName:x.ZodLazy,...I(e)});class $e extends S{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return m(r,{received:r.data,code:f.invalid_literal,expected:this._def.value}),k}return{status:"valid",value:e.data}}get value(){return this._def.value}}$e.create=(t,e)=>new $e({value:t,typeName:x.ZodLiteral,...I(e)});function rr(t,e){return new de({values:t,typeName:x.ZodEnum,...I(e)})}class de extends S{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{expected:C.joinValues(n),received:r.parsedType,code:f.invalid_type}),k}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{received:r.data,code:f.invalid_enum_value,options:n}),k}return j(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return de.create(e,{...this._def,...r})}exclude(e,r=this._def){return de.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}de.create=rr;class St extends S{_parse(e){const r=C.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==b.string&&n.parsedType!==b.number){const a=C.objectValues(r);return m(n,{expected:C.joinValues(a),received:n.parsedType,code:f.invalid_type}),k}if(this._cache||(this._cache=new Set(C.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=C.objectValues(r);return m(n,{received:n.data,code:f.invalid_enum_value,options:a}),k}return j(e.data)}get enum(){return this._def.values}}St.create=(t,e)=>new St({values:t,typeName:x.ZodNativeEnum,...I(e)});class xe extends S{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==b.promise&&r.common.async===!1)return m(r,{code:f.invalid_type,expected:b.promise,received:r.parsedType}),k;const n=r.parsedType===b.promise?r.data:Promise.resolve(r.data);return j(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}xe.create=(t,e)=>new xe({type:t,typeName:x.ZodPromise,...I(e)});class ae extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:s=>{m(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){const s=a.transform(n.data,i);if(n.common.async)return Promise.resolve(s).then(async o=>{if(r.value==="aborted")return k;const l=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return l.status==="aborted"?k:l.status==="dirty"||r.value==="dirty"?Ne(l.value):l});{if(r.value==="aborted")return k;const o=this._def.schema._parseSync({data:s,path:n.path,parent:n});return o.status==="aborted"?k:o.status==="dirty"||r.value==="dirty"?Ne(o.value):o}}if(a.type==="refinement"){const s=o=>{const l=a.refinement(o,i);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?k:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?k:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(a.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!_e(s))return k;const o=a.transform(s.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>_e(s)?Promise.resolve(a.transform(s.value,i)).then(o=>({status:r.value,value:o})):k);C.assertNever(a)}}ae.create=(t,e,r)=>new ae({schema:t,typeName:x.ZodEffects,effect:e,...I(r)}),ae.createWithPreprocess=(t,e,r)=>new ae({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...I(r)});class W extends S{_parse(e){return this._getType(e)===b.undefined?j(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}W.create=(t,e)=>new W({innerType:t,typeName:x.ZodOptional,...I(e)});class ue extends S{_parse(e){return this._getType(e)===b.null?j(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ue.create=(t,e)=>new ue({innerType:t,typeName:x.ZodNullable,...I(e)});class je extends S{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===b.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}je.create=(t,e)=>new je({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...I(e)});class Fe extends S{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Xe(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new U(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new U(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Fe.create=(t,e)=>new Fe({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...I(e)});class Et extends S{_parse(e){if(this._getType(e)!==b.nan){const n=this._getOrReturnCtx(e);return m(n,{code:f.invalid_type,expected:b.nan,received:n.parsedType}),k}return{status:"valid",value:e.data}}}Et.create=t=>new Et({typeName:x.ZodNaN,...I(t)});class At extends S{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class rt extends S{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?k:i.status==="dirty"?(r.dirty(),Ne(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?k:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(e,r){return new rt({in:e,out:r,typeName:x.ZodPipeline})}}class Ue extends S{_parse(e){const r=this._def.innerType._parse(e),n=a=>(_e(a)&&(a.value=Object.freeze(a.value)),a);return Xe(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Ue.create=(t,e)=>new Ue({innerType:t,typeName:x.ZodReadonly,...I(e)});var x;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));const c=X.create,h=fe.create,ee=he.create,_=Ye.create,nr=Oe.create,v=me.create;le.create;const E=V.create,u=D.create,T=De.create,Rn=tt.create;qe.create;const On=Y.create,y=Me.create,Dn=Le.create,Ze=$e.create,Be=de.create;xe.create,W.create,ue.create;const ie=ae.createWithPreprocess;function M(t,e=0,r=2){if(e>r)return"...";if(t instanceof D){const n=t.shape,a=Object.keys(n).filter(s=>!s.startsWith("__"));return a.length===0?"{ }":e>=r-1?"{ ... }":`{ ${a.map(s=>{const o=n[s],l=o instanceof W,d=M(l?o.unwrap():o,e+1,r);return`${s}${l?"?":""}: ${d}`}).join(", ")} }`}if(t instanceof De)return t.options.map(n=>M(n,e,r)).join(" or ");if(t instanceof X)return"string";if(t instanceof fe)return"number";if(t instanceof Ye)return"boolean";if(t instanceof he)return"bigint";if(t instanceof Oe)return"null";if(t instanceof V){const n=M(t.element,e+1,r);return n==="unknown"||n==="any"?"array":`${n}[]`}if(t instanceof Y)return`[${t.items.map(n=>M(n,e+1,r)).join(", ")}]`;if(t instanceof Me){const n=M(t._def.valueType,e+1,r);return n==="unknown"||n==="any"?"{ [key: string]: unknown }":`{ [key: string]: ${n} }`}return t instanceof W?`${M(t.unwrap(),e,r)}?`:t instanceof $e?JSON.stringify(t.value):t instanceof de?t.options.map(n=>`"${n}"`).join(" | "):t instanceof kt?"any":t instanceof me?"unknown":t instanceof xt?"void":t instanceof et?"undefined":t instanceof ae?M(t.innerType(),e,r):t instanceof je?M(t.removeDefault(),e,r):t instanceof ue?`${M(t.unwrap(),e,r)} | null`:t instanceof Le?"lazy":t instanceof xe?`Promise<${M(t.unwrap(),e+1,r)}>`:t instanceof Pe?"function":t instanceof Re?"Date":t instanceof Tt?"Map":t instanceof ke?"Set":t instanceof qe?`${M(t._def.left,e,r)} & ${M(t._def.right,e,r)}`:t instanceof tt?t.options.map(n=>M(n,e,r)).join(" or "):t instanceof At?M(t.unwrap(),e,r):t instanceof Et?"NaN":t instanceof Fe?M(t.removeCatch(),e,r):t instanceof rt?M(t._def.in,e,r):t instanceof Ue?`readonly ${M(t.unwrap(),e,r)}`:"unknown"}function qn(t){return t===null?"null":t===void 0?"undefined":Array.isArray(t)?"array":typeof t}function Mn(t,e,r,n){const a=r.filter(o=>o.path.length===0),i=r.filter(o=>o.path.length>0);if(a.length>0&&i.length===0){const o=a.some(d=>d.code==="custom"),l=a.some(d=>d.code!=="invalid_type"&&d.code!=="invalid_literal"&&d.code!=="invalid_union");if(!o&&!l){const d=M(e),p=qn(n);return`Invalid parameters for ${t}: expected ${d}${d==="{ }"?" or no args":""}, received ${p}`}}const s=r.map(o=>`at '${o.path.length>0?o.path.join("."):"root"}': ${o.message}`);return`Invalid parameters for ${t}: ${s.join("; ")}`}async function Pn(t,e,r,n,a){const i=t.safeParse(Qe(n));if(!i.success)return{ok:!1,error:{message:Mn(a,t,i.error.issues,n),code:"E_INVALID_PARAMS",category:"validation"}};try{const s=await r(i.data),o=e.safeParse(s);if(!o.success){const l=o.error.issues.map(d=>{const p=d.path.join(".");return`invalid return value${p?` at '${p}'`:""} (${d.message})`});return{ok:!1,error:{message:`Invalid return value for ${a}: ${l.join("; ")}`,code:"E_INVALID_RETURN",category:"validation"}}}return{ok:!0,value:o.data}}catch(s){const o=Dt(s),l=o.code==="E_EXTENSION"&&(typeof s!="object"||s===null||!("code"in s));return{ok:!1,error:{...o,code:l?"E_HANDLER":o.code,message:`${a}: ${o.message}`}}}}const ar=new Map,nt=new Map;function Ln(t){ar.set(t.registryAction,t)}function at(t){return ar.get(t)}function $n(t){for(const e of t)Ln(e);try{chrome.runtime.sendMessage({type:"contentScriptReady"})}catch{}}function jn(t){const e=nt.get(t);return e?(e.abort(),nt.delete(t),!0):!1}async function Fn(t,e,r,n,a){const i=at(t);if(!i)return{ok:!1,error:{message:`No schema registered for content-script action: ${t}`,code:"E_INTERNAL"}};const s=new AbortController;a&&nt.set(a,s);try{return await Pn(i.params,i.returns,async o=>r(o,s.signal),Qe(n),t)}finally{a&&nt.delete(a)}}function Un(t,e){if(at(t))return t;const r=`page_${e}`;return at(r)?r:t}function Zn(t,e){const r=at(t);return(r==null?void 0:r.handlerKey)??e}function ir(t,e,r,n,a){const i=Un(t,e),s=Zn(i,e),o=on[s];return o?(Fn(i,s,o,r,a).then(d=>{be.debug("dispatch_response",{registryAction:t,handlerAction:s,ok:d.ok}),n(d)}).catch(d=>{const p=Dt(d,{});be.debug("dispatch_error",{registryAction:t,handlerAction:s,error:p.message}),n({ok:!1,error:p})}),!0):(be.debug("no_handler",{action:s,registryAction:t}),n({ok:!1,error:`Unknown content script action: ${s}`}),!1)}function Bn(){chrome.runtime.onMessage.addListener((t,e,r)=>{if(e.id!==chrome.runtime.id)return be.warn("unauthorized_sender",{senderId:e.id,expected:chrome.runtime.id}),r({ok:!1,error:"Unauthorized sender"}),!1;const n=ye(t),a=String(n.type??""),i=String(n.action??"");if(be.debug("received",{messageType:a,action:i,hasParams:!!n.params}),a==="registryCallCancel"){const s=String(n.id??"");return jn(s),r({ok:!0}),!1}if(a==="registryCall"){const s=_r(i),o=typeof n.id=="string"?n.id:void 0;return ir(i,s,n.params,r,o)}return!i&&a==="contract-ping"?(r({ok:!0}),!1):i?i==="ping"?ir("ping","ping",n.params,r):(r({ok:!1,error:"Use registryCall for content-script actions"}),!1):(r({ok:!1,error:"Missing action"}),!1)})}const Z=()=>T([ee(),h().finite()]).transform(t=>BigInt(t));u({key:c().describe("Storage key to retrieve")}),u({key:c().describe("Storage key to set"),value:c().describe("Value to store")}),u({key:c().describe("Storage key to delete")}),u({});const Vn=u({items:y(c()).describe("Record of key-value string pairs to store")});ie(t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!("items"in t)?{items:t}:t,Vn);const Wn=u({keys:E(c()).describe("Array of storage keys to retrieve"),defaults:y(c()).optional().describe("Default string values for missing keys")});ie(t=>Array.isArray(t)?{keys:t}:t,Wn),u({});const Hn=u({keys:E(c()).describe("Array of storage keys to delete")});ie(t=>Array.isArray(t)?{keys:t}:t,Hn),u({}),u({}),T([On([T([u({text:c()}),c()])]),u({text:c().optional(),value:c().optional()})]);const Kn=u({url:c().describe("URL to fetch"),method:c().default("GET").describe("HTTP method (GET, POST, PUT, DELETE, etc.)"),headers:y(c()).default({}).describe("Request headers as key-value pairs"),body:c().nullable().default(null).describe("Request body string"),timeout:Z().default(30000n).describe("Timeout in milliseconds"),store:_().optional().describe("When true, store binary responses as a handle instead of returning body bytes"),options:u({}).passthrough().optional().describe("Fetch options")}).passthrough();u({duration:Z().describe("Duration to sleep in milliseconds")});const H=()=>c().regex(/^(?:f\d+_)?e\d+$/),zn='use { refId: "e2" } or { label: "..." } object form, not positional arguments',Ct=(t,e)=>{if(t.__invalidPositional!==void 0){e.addIssue({code:f.custom,message:zn});return}!t.refId&&!t.label&&e.addIssue({code:f.custom,message:"Either refId or label is required"})},sr=(t,e)=>{t.x!==void 0||t.y!==void 0||Ct(t,e)},q=t=>ie(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,u({__invalidPositional:T([c(),h()]).optional().describe("Internal flag for positional argument rejection"),refId:H().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(Ct)),Ie={tabId:T([h(),ee()]).optional().describe("Target tab ID")},K=t=>ie(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,u({__invalidPositional:T([c(),h()]).optional().describe("Internal flag for positional argument rejection"),...Ie,refId:H().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(Ct));u({}),u({}),u({url:c().describe("URL to navigate to"),timeout:Z().optional().describe("Navigation timeout in milliseconds"),waitUntil:Be(["load","networkidle"]).optional().describe("When to consider navigation complete: 'load' (tab status complete) or 'networkidle' (no in-flight requests for 500ms)")});const Gn=u({}),Jn=u({});u({}),u({duration:Z().default(1000n).describe("Duration to wait in milliseconds")});const Qn=q(),Xn=(t,e)=>{[t.url,t.path,t.handle].filter(n=>typeof n=="string"&&n.length>0).length!==1&&e.addIssue({code:f.custom,message:"Each file entry requires exactly one of url, path, or handle"})},or=u({name:c().optional().describe("File name including extension"),mimeType:c().optional().describe("MIME type (defaults to application/octet-stream)"),url:c().url().optional().describe("HTTP(S) URL to fetch in the target tab"),path:c().min(1).optional().describe("Virtual filesystem path (resolved in worker)"),handle:c().min(1).optional().describe("Binary handle from page.fetch({ store: true })")}).superRefine(Xn),cr=Rn("kind",[u({kind:Ze("bytes"),name:c().min(1),data:c().min(1),mimeType:c().optional()}),u({kind:Ze("url"),url:c().url(),name:c().min(1),mimeType:c().optional()})]),Yn=q({value:c().describe("Value to fill into the element")}),ea=q({files:E(or).min(1).describe("Files to attach to the input")}),ta=q({files:E(cr).min(1).describe("Resolved files for content-script application")}),ra=q({text:c().describe("Text to type into the element")}),na=q({text:c().describe("Text to append into the element")}),aa=u({refId:H().optional().describe("Element reference ID to dispatch the key on (e.g. e2). Omit to dispatch on document."),label:c().optional().describe("Human-readable element label. Omit to dispatch on document."),key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),ia=q({value:T([c().describe("Value to select in the dropdown"),E(c()).describe("Values to select in a multiple dropdown (empty array clears selection)")]).describe("Value (string) or values (array) to select in the dropdown")}),sa=q({value:c().describe("Visible text of the option to select (matched case-insensitively)")}),oa=q({checked:_().optional().describe("Desired checked state (true to check, false to uncheck)")}),ca=u({name:c().min(1).describe("The `name` attribute of the radio group to pick from"),value:c().describe("The `value` of the radio option to check")}),la=q(),da=u({}),ua=q(),pa=u({direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:h().default(300).describe("Pixels to scroll")}),fa=ie(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,u({__invalidPositional:T([c(),h()]).optional().describe("Internal flag for positional argument rejection"),refId:H().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),x:h().optional().describe("X coordinate to scroll to"),y:h().optional().describe("Y coordinate to scroll to")}).superRefine(sr)),ha=q(),ma=u({selector:c().describe("CSS selector to find elements")}),ba=u({selector:c().describe("CSS selector for the root element(s) to introspect"),depth:h().int().min(0).max(10).default(2).describe("How many descendant levels to include (0 = root only)"),includeHidden:_().default(!0).describe("Include elements hidden by CSS/aria (default true — this tool's purpose is to see what the curated snapshot filters out)")}),ga=u({selector:c().describe("CSS selector to wait for"),timeout:Z().default(30000n).describe("Timeout in milliseconds")}),ya=u({fields:E(c()).describe("Array of field names to extract")}),va=ie(t=>Array.isArray(t)?{fields:t}:t,ya);T([h(),E(u({}).passthrough()),u({}).passthrough()]),u({}),u({active:_().optional().describe("Whether the tabs are active"),currentWindow:_().optional().describe("Whether the tabs are in the current window"),url:c().optional().describe("URL pattern to match tabs against")}).passthrough(),ie(t=>typeof t=="string"?{url:t}:t,u({url:c().optional().describe("URL to open in the new tab"),active:_().optional().describe("Whether to focus the new tab")})),T([h(),E(u({id:h().optional(),tabId:h().optional(),tab_id:h().optional()}).passthrough()),u({id:h().optional(),tabId:h().optional(),tab_id:h().optional()}).passthrough()]);const _a=K(),wa=K({value:c().describe("Value to fill into the element")}),ka=K({files:E(or).min(1).describe("Files to attach to the input")}),xa=K({files:E(cr).min(1).describe("Resolved files for content-script application")}),Ia=ie(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,u({__invalidPositional:T([c(),h()]).optional().describe("Internal flag for positional argument rejection"),...Ie,refId:H().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),x:h().optional().describe("X coordinate to scroll to"),y:h().optional().describe("Y coordinate to scroll to")}).superRefine(sr)),Ta=K({text:c().describe("Text to type into the element")}),Sa=u({...Ie,key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),Ea=K({value:c().describe("Value to select in the dropdown")}),Aa=K({value:c().describe("Visible text of the option to select (matched case-insensitively)")}),Ca=K({checked:_().optional().describe("Desired checked state (true to check, false to uncheck)")}),Na=K(),Ra=K(),Oa=u({...Ie,name:c().min(1).describe("The `name` attribute of the radio group to pick from"),value:c().describe("The `value` of the radio option to check")}),Da=u({...Ie}),qa=u({...Ie,direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:h().default(300).describe("Pixels to scroll")}),Ma=K(),Pa=u({tabId:T([h(),ee()]).optional().describe("Target tab ID"),script:c().optional().describe("Script to evaluate"),code:c().optional().describe("Alternative script code"),js:c().optional().describe("Alternative JS code")}).passthrough(),La=u({tabId:T([h(),ee()]).optional().describe("Target tab ID")}).passthrough(),$a=u({tabId:T([h(),ee()]).optional().describe("Target tab ID")}).passthrough();u({tabId:T([h(),ee()]).optional().describe("Target tab ID"),timeout:h().optional().describe("Timeout in milliseconds")}).passthrough();const ja=u({tabId:T([h(),ee()]).optional().describe("Target tab ID"),url:c().optional().describe("URL to fetch"),options:u({}).passthrough().optional().describe("Fetch options")}).passthrough(),Fa=u({tabId:T([h(),ee()]).optional().describe("Target tab ID"),max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Ua=u({tabId:T([h(),ee()]).optional().describe("Target tab ID"),max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Za=u({tabId:T([h(),ee()]).optional().describe("Target tab ID"),max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough();q(),q(),q({value:c().optional().describe("Value to fill into the element")}),q({text:c().optional().describe("Text to type into the element")}),u({key:c().optional().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),q({value:c().optional().describe("Value to select in the dropdown")}),q({checked:_().optional().describe("Desired checked state (true to check, false to uncheck)")}),q(),u({}),u({direction:c().optional().describe("Scroll direction: up, down, left, or right"),amount:h().optional().describe("Pixels to scroll")}),q(),q({text:c().optional().describe("Text to append into the element")}),u({}),u({}),u({duration:Z().default(1000n).describe("Duration to wait in milliseconds")}),u({interactive_only:_().default(!1).describe("Only include interactive elements"),max_nodes:Z().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:_().default(!1).describe("Only include interactive elements"),max_nodes:Z().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:_().default(!1).describe("Only include interactive elements"),max_nodes:Z().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:_().default(!1).describe("Only include interactive elements"),max_nodes:Z().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({snapshot:u({}).passthrough().describe("Raw DOM snapshot data to format"),format:c().optional().describe("Output format (e.g. markdown, html)")});const Ba=u({max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Va=u({max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Wa=u({max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Ha=u({role:T([c(),E(c())]).optional().describe("Filter by ARIA role"),tag:T([c(),E(c())]).optional().describe("Filter by HTML tag"),text:c().optional().describe("Filter by text content (case-insensitive substring)"),name:c().optional().describe("Filter by accessible name (case-insensitive substring)"),interactiveOnly:_().optional().describe("Only include interactive elements"),href:c().optional().describe("Filter by href pattern (case-insensitive substring)"),src:c().optional().describe("Filter by src pattern (case-insensitive substring)"),limit:h().positive().optional().describe("Maximum filtered nodes to return")}).passthrough(),lr=u({filter:Ha.optional().describe("Semantic filter criteria"),max_nodes:h().optional().describe("Maximum nodes to collect before filtering")}).passthrough(),Ka=lr.extend({tabId:h().describe("Tab ID")});u({path:c().describe("File or directory path")}),u({from:c().describe("Source path"),to:c().describe("Destination path")}),u({path:c().describe("File path to write to"),data:c().describe("Data to write")}),u({path:c().describe("File path to read from"),offset:Z().describe("Byte offset to start reading"),len:h().describe("Number of bytes to read")}),u({path:c().describe("File path to update"),offset:Z().describe("Byte offset to start writing"),data:c().describe("Data to write")}),u({path:c().describe("File path to hash"),algo:c().default("sha256").describe("Hash algorithm (e.g. sha256, md5)")}),y(v()),y(v()),y(v()),y(v()),T([h(),y(v())]),T([h(),y(v())]),y(v()),y(v()),y(v()),T([c(),y(v())]),y(v()),y(v()),y(v()),y(v()),y(v()),T([c(),h(),y(v())]),y(v()),y(v()),y(v()),T([h(),y(v())]),y(v()),y(v()),y(v()),y(v()),y(v()),E(v()),T([c(),y(v())]),y(v()),T([c(),y(v())]),y(v()),T([c(),y(v())]),y(v()),T([c(),y(v())]),y(v()),y(v()),T([h(),y(v())]),y(v()),y(v()),T([h(),y(v())]),y(v()),T([c(),h(),y(v())]),y(v()),y(v()),y(v()),y(v()),T([h(),y(v())]),T([h(),y(v())]),T([h(),y(v())]),T([h(),y(v())]),T([h(),y(v())]),y(v()),y(v()),y(v()),u({action:c().describe("Host action name"),params:u({}).passthrough().optional().describe("Parameters for the host action")}).passthrough();const za=T([c(),h(),_(),nr(),E(v()),y(v())]),A=u({ok:Ze(!0).describe("Whether the action succeeded"),action:c().describe("Action identifier (e.g. 'page_fill')"),refId:H().optional().describe("Element reference ID that was acted upon (e.g. e2)"),tag:c().optional().describe("HTML tag name of the element"),role:c().optional().describe("ARIA role of the element"),name:c().optional().describe("Accessible name of the element"),value:T([c(),E(c())]).optional().describe("Final value of the element after the action (string, or string[] for multi-select)"),checked:_().optional().describe("Checked state after the action"),disabled:_().optional().describe("Whether the element is disabled"),readOnly:_().optional().describe("Whether the element is read-only"),text:c().optional().describe("Text content of the element"),key:c().optional().describe("Key that was pressed (for press actions)"),direction:c().optional().describe("Scroll direction (for scroll actions)"),amount:h().optional().describe("Scroll amount in pixels (for scroll actions)"),fileCount:h().optional().describe("Number of files attached (for setFiles actions)"),fileNames:E(c()).optional().describe("Names of attached files (for setFiles actions)"),observationId:c().optional().describe("Opaque ID of the observation lease authorizing this action (snapshot-scoped)"),dispatched:Ze(!0).optional().describe("True if the action was dispatched to the DOM. Does NOT prove the application accepted it."),verification:Ze("required").optional().describe("Always 'required': a fresh observation is required to verify the effect.")});T([A,nr()]);const dr=u({status:h().describe("HTTP response status code"),ok:_().describe("Whether the response status is 2xx"),headers:y(c()).describe("Response headers as key-value pairs"),body:c().optional().describe("Response body (omitted when bodyEncoding is handle)"),bodyEncoding:Be(["text","base64","handle"]).describe("Encoding of the body field"),handle:c().optional().describe("Binary handle when bodyEncoding is handle"),byteLength:h().describe("Length of the body in bytes"),contentType:c().describe("Response Content-Type header"),finalUrl:c().describe("Final URL after redirects")});u({data:u({}).passthrough().describe("Structured snapshot data"),text:c().describe("Plain text representation of the snapshot")}),u({}),u({tabId:h(),url:c(),title:c(),contentScript:Be(["connected","missing"]),domApis:Be(["ok","blocked"]),mutationsReady:_(),hint:c().optional(),recovery:E(c()).optional()});const Ga=za,Ja=u({refId:H().describe("Element reference ID (e.g. e2)"),role:c().describe("ARIA role of the element"),tag:c().describe("HTML tag name"),name:c().optional().describe("Accessible name of the element"),text:c().optional().describe("Visible text content of the element"),value:c().optional().describe("Element value"),checked:_().optional().describe("Checked state"),disabled:_().optional().describe("Whether the element is disabled"),readOnly:_().optional().describe("Whether the element is read-only"),selected:_().optional().describe("For <option>: selected state"),href:c().optional().describe("Absolute URL for link elements"),src:c().optional().describe("Absolute URL for image elements"),alt:c().optional().describe("Alternative text for image elements"),title:c().optional().describe("Title attribute"),parentRefId:H().optional().describe("Reference ID of the parent container element"),postId:c().optional().describe("Stable post identifier from data-post-id attribute"),permalink:c().optional().describe("Stable permalink URL from anchor element"),imageUrls:E(c()).optional().describe("Image URLs contained within this element")}),it=u({text:c().describe("Plain text representation of the page"),nodes:E(Ja).describe("Array of interactive nodes"),url:c().describe("Current page URL"),title:c().describe("Current page title"),viewport:u({width:h().describe("Viewport width in pixels"),height:h().describe("Viewport height in pixels")}).describe("Viewport dimensions"),observationId:c().optional().describe("Opaque ID of the observation lease granted by this snapshot. Pass to subsequent actions to prove they act on fresh observations.")}),ur=u({refId:H().optional(),tag:c(),role:c().optional(),name:c().optional(),text:c().optional(),attributes:y(c()).optional().describe("All HTML attributes (raw)"),hidden:_().optional(),hiddenReason:Be(["display-none","visibility-hidden","aria-hidden","opacity-zero","hidden-attr","inert"]).optional(),value:c().optional(),checked:_().optional(),disabled:_().optional(),readOnly:_().optional(),selected:_().optional().describe("For <option>: selected state"),href:c().optional(),src:c().optional(),alt:c().optional(),accept:c().optional().describe("For input[type=file]: accepted MIME/extensions"),filesCount:h().optional().describe("For input[type=file]: selected file count"),children:E(Dn(()=>ur)).optional().describe("Nested descendants up to `depth`")}),Qa=u({nodes:E(ur),url:c(),title:c()}),pr=u({id:h().optional().describe("Tab ID"),tabId:h().optional().describe("Tab ID (added by runner)"),index:h().optional().describe("Tab index in the window"),windowId:h().optional().describe("Window ID"),url:c().optional().describe("Tab URL"),title:c().optional().describe("Tab title"),status:c().optional().describe("Tab status (loading or complete)"),active:_().optional().describe("Whether the tab is active"),pinned:_().optional().describe("Whether the tab is pinned"),highlighted:_().optional().describe("Whether the tab is highlighted"),incognito:_().optional().describe("Whether the tab is incognito"),favIconUrl:c().optional().describe("Favicon URL"),audible:_().optional().describe("Whether the tab is audible"),groupId:h().optional().describe("Group ID"),openerTabId:h().optional().describe("Opener tab ID"),discarded:_().optional().describe("Whether the tab is discarded"),autoDiscardable:_().optional().describe("Whether the tab is auto-discardable"),width:h().optional().describe("Tab width"),height:h().optional().describe("Tab height"),sessionId:c().optional().describe("Session ID")}).passthrough(),Xa=E(pr),fr=u({id:h().optional().describe("Window ID"),focused:_().optional().describe("Whether the window is focused"),top:h().optional().describe("Window top position"),left:h().optional().describe("Window left position"),width:h().optional().describe("Window width"),height:h().optional().describe("Window height"),tabs:Xa.optional().describe("Array of tabs in the window"),incognito:_().optional().describe("Whether the window is incognito"),type:c().optional().describe("Window type"),state:c().optional().describe("Window state"),alwaysOnTop:_().optional().describe("Whether the window is always on top"),sessionId:c().optional().describe("Session ID")}).passthrough();E(fr);const Ya=u({name:c().describe("Cookie name"),value:c().describe("Cookie value"),domain:c().optional().describe("Cookie domain"),hostOnly:_().optional().describe("Whether the cookie is host-only"),path:c().optional().describe("Cookie path"),secure:_().optional().describe("Whether the cookie is secure"),httpOnly:_().optional().describe("Whether the cookie is HTTP-only"),sameSite:c().optional().describe("SameSite policy"),session:_().optional().describe("Whether the cookie is a session cookie"),expirationDate:h().optional().describe("Expiration date as Unix timestamp"),storeId:c().optional().describe("Store ID")}).nullable();E(Ya.nullable().unwrap());const ei=u({id:c().describe("Bookmark ID"),parentId:c().optional().describe("Parent folder ID"),index:h().optional().describe("Bookmark index"),url:c().optional().describe("Bookmark URL"),title:c().describe("Bookmark title"),dateAdded:h().optional().describe("Date added"),dateGroupModified:h().optional().describe("Date group modified"),children:E(u({id:c()}).passthrough()).optional().describe("Child bookmarks")}).passthrough();E(ei);const ti=u({id:c().describe("History item ID"),url:c().optional().describe("URL"),title:c().optional().describe("Title"),lastVisitTime:h().optional().describe("Last visit time"),visitCount:h().optional().describe("Visit count"),typedCount:h().optional().describe("Typed count")}).passthrough();E(ti);const ri=u({frameId:h().describe("Frame ID"),result:v().optional().describe("Script result")});E(ri),c(),_(),T([c(),h()]),_();const ni=u({id:h().optional().describe("Group ID"),collapsed:_().optional().describe("Whether the group is collapsed"),color:c().optional().describe("Group color"),title:c().optional().describe("Group title"),windowId:h().optional().describe("Window ID")}).passthrough();E(ni);const ai=u({lastModified:h().optional().describe("Last modified time"),tab:pr.optional().describe("Tab info"),window:fr.optional().describe("Window info")}).passthrough(),ii=E(ai),si=u({deviceName:c().optional().describe("Device name"),sessions:ii.optional().describe("Sessions")}).passthrough();E(si);const oi=u({id:h().optional().describe("Download ID"),url:c().optional().describe("Download URL"),filename:c().optional().describe("Filename"),startTime:c().optional().describe("Start time"),endTime:c().optional().describe("End time"),state:c().optional().describe("Download state"),danger:c().optional().describe("Danger type"),paused:_().optional().describe("Whether the download is paused"),error:c().optional().describe("Error message"),bytesReceived:h().optional().describe("Bytes received"),totalBytes:h().optional().describe("Total bytes"),fileSize:h().optional().describe("File size"),mime:c().optional().describe("MIME type"),incognito:_().optional().describe("Whether the download is incognito"),referrer:c().optional().describe("Referrer URL"),byExtensionId:c().optional().describe("Extension ID"),byExtensionName:c().optional().describe("Extension name")}).passthrough();E(oi),h(),u({archName:c().describe("CPU architecture"),modelName:c().describe("CPU model"),numOfProcessors:h().describe("Number of processors"),features:E(c()).describe("CPU features")}),u({capacity:h().describe("Total memory capacity"),availableCapacity:h().describe("Available memory capacity")}),E(u({id:c().describe("Storage ID"),name:c().describe("Storage name"),type:c().describe("Storage type"),capacity:h().describe("Storage capacity")}));const z="Returns a Promise; await before reading the result. For a cell's last line, use `page.snapshot()` without a leading await so the cell returns the settled value.",ci=[{action:"page_back",namespace:"page",name:"back",description:"Go back in the active tab",params:Gn,returns:A,paramTypes:[],returnDoc:"Navigation result",errorCode:"E_NO_TAB",example:"page.back()",handlerKey:"back"},{action:"page_click",namespace:"page",name:"click",description:"Click an element in the active tab",params:Qn,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label to click (label)"}],returnDoc:"{ ok: true, action: 'click', refId? }",errorCode:"E_MISSING_PARAM",example:'page.click({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:[z,"Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.click"]},handlerKey:"click"},{action:"page_fill",namespace:"page",name:"fill",description:"Fill an element in the active tab",params:Yn,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"value",type:"string",required:!1,description:"Value to fill (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'fill', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.fill({ refId: "e2", value: "hello" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:[z,"Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.fill"]},handlerKey:"fill"},{action:"page_set_files",namespace:"page",name:"setFiles",description:"Attach files to a file input in the active tab",params:ea,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"files",type:"{ name?: string, url?: string, path?: string, handle?: string, mimeType?: string }[]",required:!0,description:"Each entry uses exactly one of url, path (vfs), or handle (from page.fetch store:true)"}],returnDoc:"{ ok: true, action: 'setFiles', refId?, fileCount?, fileNames? }",errorCode:"E_MISSING_PARAM",example:'page.setFiles({ refId: "e3", files: [{ url: "https://example.com/photo.jpg", name: "photo.jpg" }] })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:[z,"Target must be input[type=file]; prefer url, vfs path, or fetch handle — bytes are not passed through QuickJS","Use page.fetch({ url, store: true }) then setFiles({ files: [{ handle }] }) for downloaded binaries","Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.setFiles","page.fetch","fs.writeBase64"]},handlerKey:"set_files"},{action:"page_type",namespace:"page",name:"type",description:"Type into an element in the active tab",params:ra,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"text",type:"string",required:!1,description:"Text to type (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'type', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.type({ refId: "e2", text: "hello" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:[z,"Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.type"]},handlerKey:"type"},{action:"page_append",namespace:"page",name:"append",description:"Append text to an element in the active tab",params:na,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"text",type:"string",required:!1,description:"Text to append (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'append', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.append({ refId: "e2", text: " world" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"]},handlerKey:"append"},{action:"page_press",namespace:"page",name:"press",description:"Press a key in the active tab",params:aa,returns:A,fields:["key"],paramTypes:[{name:"key",type:"string",required:!0,description:"Key to press (literal)"}],returnDoc:"{ ok: true, action: 'press', key? }",errorCode:"E_NO_TAB",example:'page.press("Enter")',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.press"]},handlerKey:"press"},{action:"page_select",namespace:"page",name:"select",description:"Select an option in the active tab",params:ia,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"value",type:"string",required:!1,description:"Option value to select (literal)"}],returnDoc:"{ ok: true, action: 'select', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.select({ refId: "e2", value: "option1" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.select"]},handlerKey:"select"},{action:"page_select_option",namespace:"page",name:"select_option",description:"Open a combobox (react-select/listbox) and click the option whose text matches value",params:sa,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"value",type:"string",required:!1,description:"Visible text of the option to select (matched case-insensitively)"}],returnDoc:"{ ok: true, action: 'select_option', refId?, value? }",errorCode:"E_NOT_FOUND",example:'page.select_option({ refId: "e2", value: "Canada" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId","Drives react-select and other ARIA combobox patterns: clicks the control to open, then clicks the matching [role='option']"],tags:["mutation","write"],relatedApis:["web.tab.select_option"]},handlerKey:"select_option"},{action:"page_check",namespace:"page",name:"check",description:"Check/uncheck an element in the active tab",params:oa,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"checked",type:"boolean",required:!1,description:"Whether to check or uncheck (literal)"}],returnDoc:"{ ok: true, action: 'check', refId?, checked? }",errorCode:"E_MISSING_PARAM",example:'page.check({ refId: "e2", checked: true })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.check"]},handlerKey:"check"},{action:"page_hover",namespace:"page",name:"hover",description:"Hover over an element in the active tab",params:la,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'hover', refId? }",errorCode:"E_MISSING_PARAM",example:'page.hover({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.hover"]},handlerKey:"hover"},{action:"page_unhover",namespace:"page",name:"unhover",description:"Unhover in the active tab",params:da,returns:A,paramTypes:[],returnDoc:"{ ok: true, action: 'unhover' }",errorCode:"E_NO_TAB",example:"page.unhover()",agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.unhover"]},handlerKey:"unhover"},{action:"page_submit",namespace:"page",name:"submit",description:"Submit a form in the active tab (calls form.requestSubmit())",params:ua,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID of the form or any element inside it (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'submit', refId?, dispatched: true }",errorCode:"E_MISSING_PARAM",example:'page.submit({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Target a <form> element or any descendant; resolves to the owning form","Uses form.requestSubmit() so submit event listeners fire and validation runs","Same content-script path as web.tab.*"],tags:["mutation","write"],relatedApis:["web.tab.submit","page.click"]},handlerKey:"submit"},{action:"page_check_radio",namespace:"page",name:"checkRadio",description:"Check a radio option by group name and value in the active tab",params:ca,returns:A,paramTypes:[{name:"name",type:"string",required:!0,description:"The name attribute of the radio group"},{name:"value",type:"string",required:!0,description:"The value of the radio option to check"}],returnDoc:"{ ok: true, action: 'check_radio', refId?, checked: true, value }",errorCode:"E_MISSING_PARAM",example:'page.checkRadio({ name: "radio-grp", value: "opt2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Picks a radio by group name + value — no refId needed","Use page.snapshot_data to discover radio values from the DOM","Same content-script path as web.tab.*"],tags:["mutation","write"],relatedApis:["web.tab.checkRadio","page.check","page.snapshot_data"]},handlerKey:"check_radio"},{action:"page_scroll",namespace:"page",name:"scroll",description:"Scroll the active tab",params:pa,returns:A,fields:["direction","amount"],paramTypes:[{name:"direction",type:"string",required:!1,description:"Scroll direction (up or down) (literal)"},{name:"amount",type:"number",required:!1,description:"Scroll amount in pixels (literal)"}],returnDoc:"Scroll result",errorCode:"E_NO_TAB",example:'page.scroll("down", 500)',handlerKey:"scroll"},{action:"page_scroll_to",namespace:"page",name:"scroll_to",description:"Scroll to an element in the active tab",params:fa,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID to scroll to (refId)"},{name:"label",type:"string",required:!1,description:"Element label to scroll to (label)"}],returnDoc:"Scroll to result",errorCode:"E_MISSING_PARAM",example:'page.scroll_to({ refId: "e2" })',handlerKey:"scroll_to"},{action:"page_dblclick",namespace:"page",name:"dblclick",description:"Double-click an element in the active tab",params:ha,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'dblclick', refId? }",errorCode:"E_MISSING_PARAM",example:'page.dblclick({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.dblclick"]},handlerKey:"dblclick"},{action:"tab_click",namespace:"web.tab",name:"click",description:"Click in a tab",params:_a,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'click', refId? }",errorCode:"E_NO_TAB",example:'web.tab.click({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.click"]},handlerKey:"click"},{action:"tab_fill",namespace:"web.tab",name:"fill",description:"Fill in a tab",params:wa,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"value",type:"string",required:!1,description:"Value to fill (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'fill', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.fill({ tabId: 123, refId: "e2", value: "hello" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.fill"]},handlerKey:"fill"},{action:"tab_set_files",namespace:"web.tab",name:"setFiles",description:"Attach files to a file input in a tab",params:ka,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"files",type:"{ name?: string, url?: string, path?: string, handle?: string, mimeType?: string }[]",required:!0,description:"Each entry uses exactly one of url, path (vfs), or handle"}],returnDoc:"{ ok: true, action: 'setFiles', refId?, fileCount?, fileNames? }",errorCode:"E_NO_TAB",example:'web.tab.setFiles({ tabId: 123, refId: "e3", files: [{ url: "https://example.com/photo.jpg" }] })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.setFiles"]},handlerKey:"set_files"},{action:"tab_scroll_to",namespace:"web.tab",name:"scroll_to",description:"Scroll to position in a tab",params:Ia,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"x",type:"number",required:!1,description:"X coordinate (literal)"},{name:"y",type:"number",required:!1,description:"Y coordinate (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"Scroll to result",errorCode:"E_NO_TAB",example:'web.tab.scroll_to({ tabId: 123, refId: "e2" })',handlerKey:"scroll_to"},{action:"tab_type",namespace:"web.tab",name:"type",description:"Type in a tab",params:Ta,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"text",type:"string",required:!1,description:"Text to type (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'type', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.type({ tabId: 123, refId: "e2", text: "hello" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.type"]},handlerKey:"type"},{action:"tab_press",namespace:"web.tab",name:"press",description:"Press a key in a tab",params:Sa,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"key",type:"string",required:!1,description:"Key to press (literal)"}],returnDoc:"{ ok: true, action: 'press', key? }",errorCode:"E_NO_TAB",example:'web.tab.press({ tabId: 123, key: "Enter" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.press"]},handlerKey:"press"},{action:"tab_select",namespace:"web.tab",name:"select",description:"Select an option in a tab",params:Ea,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"value",type:"string",required:!1,description:"Option value to select (literal)"}],returnDoc:"{ ok: true, action: 'select', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.select({ tabId: 123, refId: "e2", value: "option1" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.select"]},handlerKey:"select"},{action:"tab_select_option",namespace:"web.tab",name:"select_option",description:"Open a combobox (react-select/listbox) in a tab and click the option whose text matches value",params:Aa,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"value",type:"string",required:!1,description:"Visible text of the option to select (matched case-insensitively)"}],returnDoc:"{ ok: true, action: 'select_option', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.select_option({ tabId: 123, refId: "e2", value: "Canada" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*","Drives react-select and other ARIA combobox patterns: clicks the control to open, then clicks the matching [role='option']"],tags:["mutation","write"],relatedApis:["page.select_option"]},handlerKey:"select_option"},{action:"tab_check",namespace:"web.tab",name:"check",description:"Check/uncheck in a tab",params:Ca,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"checked",type:"boolean",required:!1,description:"Whether to check or uncheck (literal)"}],returnDoc:"{ ok: true, action: 'check', refId?, checked? }",errorCode:"E_NO_TAB",example:'web.tab.check({ tabId: 123, refId: "e2", checked: true })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.check"]},handlerKey:"check"},{action:"tab_submit",namespace:"web.tab",name:"submit",description:"Submit a form in a tab (calls form.requestSubmit())",params:Ra,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID of the form or any element inside it (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'submit', refId?, dispatched: true }",errorCode:"E_NO_TAB",example:'web.tab.submit({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handler as page.submit"],tags:["mutation","write"],relatedApis:["page.submit"]},handlerKey:"submit"},{action:"tab_check_radio",namespace:"web.tab",name:"checkRadio",description:"Check a radio option by group name and value in a tab",params:Oa,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"name",type:"string",required:!0,description:"The name attribute of the radio group"},{name:"value",type:"string",required:!0,description:"The value of the radio option to check"}],returnDoc:"{ ok: true, action: 'check_radio', refId?, checked: true, value }",errorCode:"E_NO_TAB",example:'web.tab.checkRadio({ tabId: 123, name: "radio-grp", value: "opt2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handler as page.checkRadio"],tags:["mutation","write"],relatedApis:["page.checkRadio"]},handlerKey:"check_radio"},{action:"tab_hover",namespace:"web.tab",name:"hover",description:"Hover in a tab",params:Na,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'hover', refId? }",errorCode:"E_NO_TAB",example:'web.tab.hover({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.hover"]},handlerKey:"hover"},{action:"tab_unhover",namespace:"web.tab",name:"unhover",description:"Unhover in a tab",params:Da,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"{ ok: true, action: 'unhover' }",errorCode:"E_NO_TAB",example:"web.tab.unhover({ tabId: 123 })",agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.unhover"]},handlerKey:"unhover"},{action:"tab_scroll",namespace:"web.tab",name:"scroll",description:"Scroll in a tab",params:qa,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"direction",type:"string",required:!1,description:"Scroll direction (up or down) (literal)"},{name:"amount",type:"number",required:!1,description:"Scroll amount in pixels (literal)"}],returnDoc:"Scroll result",errorCode:"E_NO_TAB",example:'web.tab.scroll({ tabId: 123, direction: "down", amount: 500 })',handlerKey:"scroll"},{action:"tab_dblclick",namespace:"web.tab",name:"dblclick",description:"Double-click in a tab",params:Ma,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'dblclick', refId? }",errorCode:"E_NO_TAB",example:'web.tab.dblclick({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.dblclick"]},handlerKey:"dblclick"},{action:"tab_back",namespace:"web.tab",name:"back",description:"Go back in a tab",params:La,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Back result",errorCode:"E_NO_TAB",example:"web.tab.back({ tabId: 123 })",handlerKey:"back"},{action:"page_forward",namespace:"page",name:"forward",description:"Go forward in the active tab",params:Jn,returns:A,paramTypes:[],returnDoc:"Navigation result",errorCode:"E_NO_TAB",example:"page.forward()",handlerKey:"forward"},{action:"page_snapshot",namespace:"page",name:"snapshot",description:"Capture full DOM snapshot",params:Ba,returns:c(),paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal)"},{name:"options",type:"{ max_nodes?: number }",required:!1,description:"Snapshot options (literal)"}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"page.snapshot()",agentMeta:{notes:[z,"Content-script path; same refIds as mutations"],tags:["snapshot","read"],relatedApis:["page.snapshot_data","web.tab.snapshot"]},handlerKey:"snapshot_text"},{action:"page_snapshot_text",namespace:"page",name:"snapshot_text",description:"Capture DOM snapshot and return text representation",params:Va,returns:c(),paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal)"}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"page.snapshot_text()",handlerKey:"snapshot_text"},{action:"page_snapshot_data",namespace:"page",name:"snapshot_data",description:"Get page snapshot data",params:Wa,returns:it,paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal)"}],returnDoc:"{ text, nodes, url, title, viewport }",errorCode:"E_SNAPSHOT",example:"page.snapshot_data()",agentMeta:{notes:[z,"Content-script path; nodes include refId for targeting","After mutations, call snapshot_data() again to verify state"],tags:["snapshot","read"],relatedApis:["page.click","web.tab.snapshot_data"]},handlerKey:"snapshot"},{action:"page_snapshot_query",namespace:"page",name:"snapshot_query",description:"Query page snapshot with semantic filtering by role, tag, text, name, etc.",params:lr,returns:it,paramTypes:[{name:"filter",type:"{ role?: string | string[], tag?: string | string[], text?: string, name?: string, interactiveOnly?: boolean, href?: string, src?: string, limit?: number }",required:!1,description:"Semantic filter criteria (literal)"},{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to collect before filtering (literal)"}],returnDoc:"{ text, nodes (filtered), url, title, viewport }",errorCode:"E_SNAPSHOT",example:'page.snapshot_query({ filter: { role: "button" } })',agentMeta:{notes:[z,"Content-script path; filters nodes by role, tag, text, name, interactiveOnly, href, src","More efficient than page.snapshot_data() when only specific elements are needed"],tags:["snapshot","read"],relatedApis:["page.snapshot_data","page.find"]},handlerKey:"snapshot_query"},{action:"page_find",namespace:"page",name:"find",description:"Find elements in the active tab using a CSS selector",params:ma,returns:E(u({refId:H(),role:c(),tag:c(),name:c().optional(),text:c().optional(),value:c().optional(),checked:_().optional(),disabled:_().optional(),readOnly:_().optional(),href:c().optional(),src:c().optional(),alt:c().optional(),title:c().optional(),parentRefId:H().optional()})),aliases:[{namespace:"page",name:"query"}],fields:["selector"],paramTypes:[{name:"selector",type:"string",required:!0,description:"CSS selector to find elements (selector)"}],returnDoc:"Array of elements with refId, role, name, href/src, alt, and parentRefId",errorCode:"E_NO_TAB",example:'page.find("h1")',agentMeta:{notes:["Assigns data-ref-id on matched elements when missing so results include actionable refIds"],tags:["read"]},handlerKey:"find"},{action:"page_dom",namespace:"page",name:"dom",description:"Introspect raw DOM subtree by CSS selector — bypasses the curated snapshot's visibility filter. Read-only. Use when page.snapshot/find hide the element you need (e.g. hidden file inputs, shadowed widgets, aria-hidden regions).",params:ba,returns:Qa,paramTypes:[{name:"selector",type:"string",required:!0,description:"CSS selector for root element(s)"},{name:"depth",type:"number",required:!1,description:"Descendant levels (default 2, max 10)"},{name:"includeHidden",type:"boolean",required:!1,description:"Include hidden elements (default true)"}],returnDoc:"{ nodes: [{ refId?, tag, role?, name?, attributes?, hidden?, hiddenReason?, accept?, filesCount?, children? }], url, title }",errorCode:"E_NO_TAB",example:'page.dom({ selector: "input[type=file]", depth: 0 })',agentMeta:{prerequisites:["Active tab with content script ready"],notes:[z,"Read-only: returns DOM structure, never executes code or mutates the page","Bypasses the snapshot visibility filter — use to find hidden/filtered elements the curated snapshot omits","Assigns refIds to returned elements so subsequent page.setFiles/click/fill can target them","Prefer page.snapshot for normal navigation; use page.dom only when the snapshot is insufficient"],tags:["read"],relatedApis:["page.find","page.snapshot_data","page.setFiles"]},handlerKey:"dom"},{action:"page_wait_for",namespace:"page",name:"wait_for",description:"Wait for a selector in the active tab",params:ga,returns:_(),fields:["selector","timeout"],paramTypes:[{name:"selector",type:"string",required:!0,description:"CSS selector to wait for (selector)"},{name:"timeout",type:"number",required:!1,description:"Timeout in milliseconds (literal)"}],returnDoc:"true",errorCode:"E_TIMEOUT",errorCategory:"timeout",example:'page.wait_for("#submit", 5000)',agentMeta:{notes:[z],tags:["read"]},handlerKey:"wait_for"},{action:"page_extract",namespace:"page",name:"extract",description:"Extract data from the active tab",params:va,returns:u({title:c().optional(),url:c().optional(),headings:E(u({tag:c(),text:c()})).optional(),links:E(u({href:c().nullable(),text:c()})).optional(),text:c().optional()}).passthrough(),fields:["fields"],paramTypes:[{name:"fields",type:"array",required:!0,description:"Array of fields to extract (title, url, headings, links, text)"}],returnDoc:"Extracted data",errorCode:"E_NO_TAB",example:'page.extract(["title", "url"])',agentMeta:{notes:[z],tags:["read"]},handlerKey:"extract"},{action:"page_fetch",namespace:"page",name:"fetch",description:"Fetch in the active tab",params:Kn,returns:dr,fields:["url","options"],paramTypes:[{name:"url",type:"string",required:!1,description:"URL to fetch (url)"},{name:"options",type:"{ method?: string, headers?: { [key: string]: string }, body?: string }",required:!1,description:"Fetch options (literal)"}],returnDoc:"DTO with `{ body, headers, ok, status }`",errorCode:"E_NO_TAB",example:'page.fetch({ url: "https://api.example.com/data" })',agentMeta:{notes:[z,"Runtime binary globals available: Uint8Array, ArrayBuffer, TextEncoder, TextDecoder, atob, btoa","For binary responses bodyEncoding is 'base64'; use atob() or fs.writeBase64 to handle bytes"],tags:["read"]},handlerKey:"fetch"},{action:"tab_forward",namespace:"web.tab",name:"forward",description:"Go forward in a tab",params:$a,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Forward result",errorCode:"E_NO_TAB",example:"web.tab.forward({ tabId: 123 })",handlerKey:"forward"},{action:"tab_snapshot",namespace:"web.tab",name:"snapshot",description:"Get tab snapshot",params:Fa,returns:c(),fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal)"}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"web.tab.snapshot({ tabId: 123 })",handlerKey:"snapshot_text"},{action:"tab_snapshot_text",namespace:"web.tab",name:"snapshot_text",description:"Get tab snapshot text",params:Ua,returns:c(),fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"web.tab.snapshot_text({ tabId: 123 })",handlerKey:"snapshot_text"},{action:"tab_snapshot_data",namespace:"web.tab",name:"snapshot_data",description:"Get tab snapshot data",params:Za,returns:it,fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Snapshot data",errorCode:"E_SNAPSHOT",example:"web.tab.snapshot_data({ tabId: 123 })",handlerKey:"snapshot"},{action:"tab_snapshot_query",namespace:"web.tab",name:"snapshot_query",description:"Query tab snapshot with semantic filtering by role, tag, text, name, etc.",params:Ka,returns:it,fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"filter",type:"{ role?: string | string[], tag?: string | string[], text?: string, name?: string, interactiveOnly?: boolean, href?: string, src?: string, limit?: number }",required:!1,description:"Semantic filter criteria (literal)"},{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to collect before filtering (literal)"}],returnDoc:"{ text, nodes (filtered), url, title, viewport }",errorCode:"E_SNAPSHOT",example:'web.tab.snapshot_query({ tabId: 123, filter: { role: "button" } })',agentMeta:{notes:["Explicit tabId required; same handler as page.snapshot_query","Filters nodes by role, tag, text, name, interactiveOnly, href, src"],tags:["snapshot","read"],relatedApis:["page.snapshot_query"]},handlerKey:"snapshot_query"},{action:"tab_fetch",namespace:"web.tab",name:"fetch",description:"Fetch in a tab",params:ja,returns:dr,fields:["tabId","url","options"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"url",type:"string",required:!1,description:"URL to fetch"}],returnDoc:"Fetch result DTO",errorCode:"E_NO_TAB",example:'web.tab.fetch({ tabId: 123, url: "https://api.example.com/data" })',handlerKey:"fetch"},{action:"tab_evaluate",namespace:"web.tab",name:"evaluate",description:"Evaluate script in a tab (content-script context)",params:Pa,returns:Ga,fields:["tabId","script"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"script",type:"string",required:!1,description:"Script to evaluate (literal)"}],returnDoc:"Evaluation result",errorCode:"E_NO_TAB",example:'web.tab.evaluate({ tabId: 123, script: "document.title" })',agentMeta:{notes:["Runs in content-script isolated world, not MAIN-world injection","For MAIN-world access use chrome.scripting.executeScript from a cell"],tags:["read"]},handlerKey:"evaluate"}];function li(){return[{registryAction:"ping",handlerKey:"ping",params:u({}),returns:u({ok:_()})}]}const di=new Set(["page_set_files","tab_set_files"]);function ui(){return ci.map(t=>({registryAction:t.action,handlerKey:t.handlerKey,params:di.has(t.action)?t.action==="tab_set_files"?xa:ta:t.params,returns:t.returns}))}if(vr(),window.__jsNotebookContentScriptInjected)throw new Error("Content script already injected");window.__jsNotebookContentScriptInjected=!0,$n([...ui(),...li()]),Bn()})();
|
|
1
|
+
(function(){"use strict";const re={debug:0,info:1,warn:2,error:3,none:4};let Rt=re.error;function _r(t){if(!t)return"";const e=[];for(const[r,n]of Object.entries(t)){let a;if(n===null)a="null";else if(n===void 0)a="undefined";else if(typeof n=="string")a=n;else if(typeof n=="number"||typeof n=="boolean")a=String(n);else try{a=JSON.stringify(n)}catch{a="[Circular]"}e.push(`${r}=${a}`)}return e.length>0?` ${e.join(" ")}`:""}function We(t,e,r){if(t<Rt)return;const n=_r(r),a=`[extension-js][content-script] ${e}${n}`;t>=re.error?console.error(a):t===re.warn?console.warn(a):console.log(a)}const be={debug:(t,e)=>{We(re.debug,t,e)},info:(t,e)=>{We(re.info,t,e)},warn:(t,e)=>{We(re.warn,t,e)},error:(t,e)=>{We(re.error,t,e)}};function wr(){window.__jsNotebookSetLogLevel=t=>{Rt=re[t]??re.error}}function kr(t){if(t.startsWith("page_")||t.startsWith("tab_")){const e=t.indexOf("_");if(e>=0)return t.slice(e+1)}return t}const xr="Content script is not connected on this tab. This tab was likely open before the extension loaded (MV3 does not retro-inject).";function Ir(t){return[`await page.goto(${JSON.stringify(t||"")})`,"Or ask the user to refresh the target tab, then retry fill/click"]}function Ot(t,e){const r=e||"unknown url",n={message:t!==void 0?`Content script is not connected on tab ${t} (${r}).`:`Content script is not connected on this tab (${r}).`,code:"E_CONTENT_SCRIPT",category:"content-script",hint:xr,recovery:Ir(e)};return t!==void 0&&(n.details={tabId:t,url:r}),n}function Tr(t,e){var s,o;const r=t?"refId":e!=null&&e.label?"label":null,n=t||(e==null?void 0:e.label)||"";let a=`Element not found${r?` by ${r} "${n}"`:""}`;if(e!=null&&e.label&&((s=e.candidates)!=null&&s.length)){const l=e.candidates.map(d=>d.name||d.refId).filter(Boolean).slice(0,5);l.length>0?a+=`. Candidates: ${l.join(", ")}`:a+=". Candidates: none"}const i={message:a,code:"E_STALE",category:"resource",hint:"RefIds are ephemeral. They are assigned at snapshot time and invalidated when the DOM is replaced (navigation, SPA rerender, autocomplete).",recovery:["const d = await page.snapshot_data(); find the target in d.nodes","Use a fresh refId from that snapshot only","Do not reuse refIds from before press/click/navigation"],details:{staleRefId:t||void 0}};return(o=e==null?void 0:e.candidates)!=null&&o.length&&(i.details={...i.details,candidates:e.candidates}),i}function fe(t,e,r){return{message:`${t} on ${e} returned no effect.`,code:"E_NOT_INTERACTABLE",category:"resource",hint:"Some sites ignore programmatic value assignment; value may not appear in snapshot_data.",recovery:[`await page.click({ refId: ${JSON.stringify(e)} }) then await page.type({ refId: ${JSON.stringify(e)}, text: "..." })`,'Or await page.press({ key: "Enter" }) after fill',"Re-snapshot and confirm URL or node state changed"],details:{refId:e,...r}}}function Sr(t){return{message:`${t} requires a fresh observation before acting.`,code:"E_OBSERVATION_REQUIRED",category:"observation",hint:"Element refIds are only valid after a snapshot. Take a fresh observation and select a refId from its returned nodes.",recovery:["const d = await page.snapshot_data(); find the target in d.nodes","Use a refId from that snapshot only"],details:{action:t}}}function Er(t){return t.includes("Could not establish connection")||t.includes("Receiving end does not exist")||t.includes("Timeout waiting for content-script ping")||t.includes("content script not available")||t.includes("message port closed before a response was received")}function R(t){const e=new Error(t.message);throw e.code=t.code,t.category&&(e.category=t.category),t.hint&&(e.hint=t.hint),t.recovery&&(e.recovery=t.recovery),t.details&&(e.details=t.details),e}function Te(t,e,r){var i;let n=`Element not found by label "${t}"`;if(e!==void 0){const s=e.map(o=>o.name||o.refId).filter(Boolean).slice(0,5);n+=s.length>0?`. Candidates: ${s.join(", ")}`:". Candidates: none"}const a=(i=r==null?void 0:r.searchedIds)!=null&&i.length?`Searched listbox(es): ${r.searchedIds.join(", ")}. Ignored: ${(r.ignoredIds||[]).join(", ")||"none"}.`:"No element matched this label. Check candidates or snapshot for visible controls.";return{message:n,code:"E_NOT_FOUND",category:"resource",hint:a,recovery:["const d = await page.snapshot_data(); find the target in d.nodes","Try a more specific label or use refId from snapshot"],details:{label:t,...r!=null&&r.targetRefId?{targetRefId:r.targetRefId}:{},...r!=null&&r.targetName?{targetName:r.targetName}:{},...r!=null&&r.searchedIds?{searchedIds:r.searchedIds}:{},...r!=null&&r.ignoredIds?{ignoredIds:r.ignoredIds}:{},...e!=null&&e.length?{candidates:e}:{}}}}function Ar(t){if(!(t instanceof Error))return{};const e=t.name!=="Error"?t.name:void 0,r=t.stack;let n;if(r){const a=r.match(/:(\d+):\d+\)?$/m);a&&(n=parseInt(a[1],10))}return{name:e,stack:r,line:n}}function Dt(t,e){if(typeof t=="object"&&t!==null&&"code"in t&&typeof t.code=="string"&&"message"in t&&typeof t.message=="string"){const o=t;return o.hint||o.recovery?o:o.code==="E_CONTENT_SCRIPT"?Ot(e==null?void 0:e.tabId,e==null?void 0:e.url):o}const r=(t instanceof Error?t.message:String(t))||"",{name:n,stack:a,line:i}=Ar(t);if(Er(r))return Ot(e==null?void 0:e.tabId,e==null?void 0:e.url);if(r.includes("permission")||r.includes("Permission")){const o={message:r,code:"E_PERMISSION",category:"permission"};return(n||a||i)&&(o.details={name:n,stack:a,line:i}),o}if(r.includes("not found")||r.includes("No tab")||r.includes("No active tab")){const o={message:r,code:"E_NOT_FOUND",category:"resource"};return(n||a||i)&&(o.details={name:n,stack:a,line:i}),o}const s={message:r,code:"E_EXTENSION",category:"extension"};return(n||a||i)&&(s.details={name:n,stack:a,line:i}),s}const Cr=/^e\d+$/;let qt=0;function lt(){let t=0;for(const e of document.querySelectorAll("[data-ref-id]")){const r=e.getAttribute("data-ref-id");if(!r)continue;const n=parseInt(r.replace(/^e/,""),10);!Number.isNaN(n)&&n>t&&(t=n)}qt=t}function He(t){const e=t.getAttribute("data-ref-id");if(e&&Cr.test(e))return e;const r=`e${++qt}`;return t.setAttribute("data-ref-id",r),r}const dt='input, textarea, select, button, a, [role="button"], [role="link"]',Nr=new Set(["script","style","noscript","template"]),Mt=new Set(["p","span","label","footer","header","blockquote","pre","code","figcaption","td","th","li","em","strong","small","cite","q","mark","time","abbr","dfn","kbd","samp","var","sub","sup"]);function Ke(t){const e={};if(t instanceof HTMLInputElement)t.type!=="password"&&t.type!=="hidden"&&(e.value=t.value),(t.type==="checkbox"||t.type==="radio")&&(e.checked=t.checked),e.disabled=t.disabled,e.readOnly=t.readOnly;else if(t instanceof HTMLTextAreaElement)e.value=t.value,e.disabled=t.disabled,e.readOnly=t.readOnly;else if(t instanceof HTMLSelectElement){if(t.multiple){const r=[];for(const n of Array.from(t.options))n.selected&&r.push(n.value);e.value=r.join(",")}else e.value=t.value;e.disabled=t.disabled}else t instanceof HTMLOptionElement&&(e.value=t.value,e.selected=t.selected,e.disabled=t.disabled);return e}function Rr(t,e){const r=t.tagName.toLowerCase();r!=="input"&&r!=="textarea"&&r!=="select"&&r!=="option"||Object.assign(e,Ke(t))}const Or=new Set(["http:","https:","file:"]);function se(t){if(t)try{const e=new URL(t,window.location.href);return Or.has(e.protocol)?e.href:void 0}catch{return}}function Pt(t){const e=t.closest("article[data-post-id], [data-post-id]");if(e)return He(e)}function Dr(t){const e=t.querySelector(":scope > h2 a[href], a[data-permalink], a[rel='permalink']");if(e instanceof HTMLAnchorElement)return e;const r=t.querySelector("a[href]");return r instanceof HTMLAnchorElement?r:null}function B(t){const e=t.tagName.toLowerCase(),r=t.getAttribute("role");if(r)return r;if(e==="button"||e==="input"&&t.type==="submit")return"button";if(e==="a")return"link";if(e==="input"){const n=t.type;if(n==="text"||n==="email"||n==="password"||n==="search")return"textbox";if(n==="checkbox")return"checkbox";if(n==="radio")return"radio";if(n==="submit"||n==="button")return"button"}return e==="textarea"?"textbox":e==="select"?"combobox":e==="img"?"img":e==="h1"||e==="h2"||e==="h3"||e==="h4"||e==="h5"||e==="h6"?"heading":e==="li"?"listitem":e==="ul"||e==="ol"?"list":e==="table"?"table":e==="tr"?"row":e==="td"||e==="th"?"cell":e==="nav"?"navigation":e==="main"?"main":e==="article"?"article":e==="section"?"region":e==="aside"?"complementary":e==="form"?"form":e==="dialog"||e==="modal"?"dialog":e==="figure"?"figure":e==="figcaption"?"caption":t.getAttribute("onclick")||t.onclick?"button":"generic"}function qr(t){var e;for(const r of t.childNodes)if(r.nodeType===Node.TEXT_NODE&&((e=r.textContent)==null?void 0:e.trim()))return!0;return!1}function ut(t,e=60){var a,i;const r=[];for(const s of t.childNodes)if(s.nodeType===Node.TEXT_NODE){const o=(a=s.textContent)==null?void 0:a.trim();o&&r.push(o)}if(r.length>0)return r.join(" ").slice(0,e);const n=(i=t.textContent)==null?void 0:i.trim();return n?n.slice(0,e):""}function ge(t){let e=t;for(;e;){if(e.hidden||e.getAttribute("aria-hidden")==="true"||e.inert)return!0;const r=window.getComputedStyle(e);if(r.display==="none"||r.visibility==="hidden")return!0;e=e.parentElement}return!1}function Mr(t){return ge(t)}function Lt(t){var s;const e=t.tagName.toLowerCase();if(Nr.has(e)||Mr(t))return!1;const r=B(t);if(r==="presentation"||r==="none")return!1;if(r!=="generic")return!0;const n=t.getAttribute("aria-live");if(n&&n!=="off")return!0;const a=t.getAttribute("role");return a==="status"||a==="alert"?!0:((s=t.textContent)==null?void 0:s.trim())||""?!!(Mt.has(e)||qr(t)):!1}function oe(t){var s,o,l;const e=t.getAttribute("aria-label");if(e)return e;const r=t.getAttribute("aria-labelledby");if(r){const d=document.getElementById(r);if(d)return((s=d.textContent)==null?void 0:s.slice(0,60))||""}if(t.tagName.toLowerCase()==="img"){const d=t.getAttribute("alt");if(d)return d}const a=t.title;if(a)return a;const i=B(t);if(i!=="generic"&&i!=="list"&&i!=="table"&&i!=="row"&&i!=="region"&&i!=="navigation"&&i!=="main")return((o=t.textContent)==null?void 0:o.trim().slice(0,60))||"";if(i==="generic"&&Lt(t)){const d=ut(t);if(d)return d;const f=t.tagName.toLowerCase();if(Mt.has(f)||t.childElementCount===0)return((l=t.textContent)==null?void 0:l.trim().slice(0,60))||""}return""}function Pr(t){return t instanceof HTMLInputElement&&t.type==="file"?!0:Lt(t)}function $t(t){return document.querySelector(`[data-ref-id='${CSS.escape(t)}']`)}function G(t,e){if(t.hasAttribute("disabled")||t.getAttribute("aria-disabled")==="true"){const r=t.getAttribute("data-ref-id")||void 0;R(fe(e,r??"",{reason:"disabled"}))}if(ge(t)){const r=t.getAttribute("data-ref-id")||void 0;R(fe(e,r??"",{reason:"hidden"}))}}function ft(t){var n,a,i;const e=t.toLowerCase().trim();if(!e)return null;const r=Array.from(document.querySelectorAll(dt));for(const s of r){const o=s.getAttribute("aria-label");if(o&&o.toLowerCase().trim()===e)return s;const l=s.placeholder;if(l&&l.toLowerCase().trim()===e)return s;const d=s.id;if(d){const N=document.querySelector(`label[for='${CSS.escape(d)}']`);if(N&&((n=N.textContent)==null?void 0:n.trim().toLowerCase())===e)return s}const f=s.closest("label");if(f&&((a=f.textContent)==null?void 0:a.trim().toLowerCase())===e||(((i=s.textContent)==null?void 0:i.trim().toLowerCase())||"")===e)return s}return null}function Lr(t){var a;const e=t.toLowerCase().trim();if(!e)return[];const r=Array.from(document.querySelectorAll(dt)),n=[];for(const i of r){const s=i.getAttribute("aria-label"),o=i.placeholder,l=((a=i.textContent)==null?void 0:a.trim())||"";if(![s,o,l].filter(Boolean).some(w=>w.toLowerCase().includes(e)))continue;const f=i.getAttribute("data-ref-id");if(f&&(n.push({refId:f,role:B(i),name:oe(i)||void 0}),n.length>=5))break}return n}function ye(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}function $r(t){const e=document.querySelector(`[data-ref-id='${CSS.escape(t)}']`);let r,n;e&&(r=e.tagName.toLowerCase(),n=B(e));const a=Array.from(document.querySelectorAll(dt)),i=[];for(const s of a){const o=s.getAttribute("data-ref-id");if(o){if(r||n){const l=s.tagName.toLowerCase(),d=B(s);if(l!==r&&d!==n)continue}if(i.push({refId:o,role:B(s),name:oe(s)||void 0}),i.length>=5)break}}return i}function Se(t,e,r=!1){if(t){const n=r?$r(t):[];R(Tr(t,{candidates:n}))}if(e){const n=r?Lr(e):[];R(Te(e,n))}R({message:"Element not found",code:"E_NOT_FOUND",category:"resource"})}function J(t,e){let r=t?$t(t):null;return!r&&e&&(r=ft(e)),r||Se(t,e,!0),r}const jt=8*1024;function jr(t){const e=atob(t),r=new Uint8Array(e.length);for(let n=0;n<e.length;n++)r[n]=e.charCodeAt(n);return r}function Fr(t){let e="";for(let r=0;r<t.length;r+=jt){const n=t.subarray(r,r+jt);for(let a=0;a<n.length;a++)e+=String.fromCharCode(n[a])}return btoa(e)}function Ur(t){return t.toLowerCase().split(";")[0].trim()}function Zr(t){return t.startsWith("image/")||t.startsWith("audio/")||t.startsWith("video/")||t==="application/octet-stream"||t==="application/pdf"||t==="application/zip"||t==="application/gzip"||t==="application/x-gzip"||t==="application/x-zip-compressed"?!0:t.startsWith("application/vnd.")}function Br(t){for(let e=0;e<t.length;e++)if(t[e]===0)return!0;return!1}function Ft(t){return Object.fromEntries(t.headers.entries())}function Ut(t,e,r){return{status:t.status,ok:t.ok,headers:Ft(t),body:Fr(e),bodyEncoding:"base64",byteLength:e.length,contentType:r,finalUrl:t.url}}function Zt(t,e,r){return{status:t.status,ok:t.ok,headers:Ft(t),body:e,bodyEncoding:"text",byteLength:new TextEncoder().encode(e).length,contentType:r,finalUrl:t.url}}async function Vr(t){const e=t.headers.get("content-type")||"",r=Ur(e);if(Zr(r)){const a=new Uint8Array(await t.arrayBuffer());return Ut(t,a,e)}if(!r||r.startsWith("text/")){const a=new Uint8Array(await t.arrayBuffer());if(Br(a))return Ut(t,a,e);const i=new TextDecoder().decode(a);return Zt(t,i,e)}const n=await t.text();return Zt(t,n,e)}const Wr=new Set(["button","link","textbox","checkbox","radio","combobox","searchbox","switch","menuitem","tab","treeitem"]),Hr=new Set(["a","button","input","textarea","select","details","summary"]);function ze(t){if(t instanceof RegExp)return r=>t.test(r);if(typeof t!="string")return()=>!1;const e=t.toLowerCase();return r=>r.toLowerCase().includes(e)}function Bt(t){return Array.isArray(t)?new Set(t.filter(e=>typeof e=="string").map(e=>e.toLowerCase())):typeof t!="string"?new Set:new Set([t.toLowerCase()])}function Kr(t,e){let r=t;if(e.role){const n=Bt(e.role);r=r.filter(a=>n.has(a.role.toLowerCase()))}if(e.tag){const n=Bt(e.tag);r=r.filter(a=>n.has(a.tag.toLowerCase()))}if(e.text){const n=ze(e.text);r=r.filter(a=>a.text!==void 0&&n(a.text))}if(e.name){const n=ze(e.name);r=r.filter(a=>a.name!==void 0&&n(a.name))}if(e.href){const n=ze(e.href);r=r.filter(a=>a.href!==void 0&&n(a.href))}if(e.src){const n=ze(e.src);r=r.filter(a=>a.src!==void 0&&n(a.src))}return e.interactiveOnly&&(r=r.filter(n=>Wr.has(n.role.toLowerCase())||Hr.has(n.tag.toLowerCase()))),e.limit!==void 0&&e.limit>0&&(r=r.slice(0,e.limit)),r}function O(t,e,r){const n=(e==null?void 0:e.getAttribute("data-ref-id"))??void 0;return{ok:!0,action:t,...n?{refId:n}:{},...e?Ke(e):{},...r}}function pt(t,e,r,n){(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.value!==n&&R(fe(t,r,{requested:n,actual:e.value}))}function ht(t){return{tag:t.tagName.toLowerCase(),role:B(t),name:oe(t)}}function zr(t,e){return t.tag===e.tag&&t.role===e.role&&t.name===e.name}let Ee=!1,Vt=0,Ge,ve=new Map;function Wt(t=[]){Vt+=1,Ge=`obs${Vt}`,Ee=!0,ve=new Map;for(const e of t)ve.set(e.refId,{element:e.element,fingerprint:ht(e.element)});return Ge}function mt(){Ee=!1,Ge=void 0,ve=new Map}function Gr(){return Ee}function Ae(){return Ge}function bt(t,e){Ee||Ht(e);const r=ve.get(t);r||Je(t,"not_in_latest_observation");const{element:n,fingerprint:a}=r;if(!n.isConnected){const s=Jr(r);if(s)return ve.set(t,{element:s,fingerprint:ht(s)}),s;Je(t,"disconnected")}const i=ht(n);return zr(i,a)||Je(t,"fingerprint_changed"),n}function Jr(t){const{fingerprint:e}=t,r=e.role,n=e.name.trim().toLowerCase();return Array.from(document.querySelectorAll("*")).find(a=>B(a)===r&&oe(a).toLowerCase().trim()===n)??null}function Ht(t){const e=new Error(`${t} requires a fresh observation before acting.`);throw e.code="E_OBSERVATION_REQUIRED",e.category="observation",e.hint="Element refIds are only valid after a snapshot. Take a fresh observation and select a refId from its returned nodes.",e.recovery=["const d = await page.snapshot_data(); find the target in d.nodes","Use a refId from that snapshot only"],e.details={action:t},e}function Je(t,e){const r=new Error(`Element refId "${t}" is stale (${e}).`);throw r.code="E_STALE",r.category="observation",r.hint="The element changed or was removed after the last observation.",r.recovery=["const d = await page.snapshot_data(); find the target in d.nodes","Use a fresh refId from that snapshot only"],r.details={staleRefId:t,reason:e},r}function Qr(t,e){Ee||Ht(e);const r=t.toLowerCase().trim(),n=[];for(const i of ve.values())oe(i.element).toLowerCase().trim()===r&&n.push(i.element);if(n.length===0)throw new Error(`Element not found by label "${t}"`);n.length>1&&Xr(t);const a=n[0];return a.isConnected||Je(a.getAttribute("data-ref-id")||"","disconnected"),a}function Xr(t){const e=new Error(`Multiple elements match label "${t}". The target is ambiguous.`);throw e.code="E_AMBIGUOUS_TARGET",e.category="observation",e.hint="Use a refId from the latest snapshot_data instead of a label, or narrow the label.",e.recovery=["const d = await page.snapshot_data(); find the target in d.nodes","Use the refId from that snapshot"],e.details={label:t},e}function gt(t){lt();const e=[],r=[];let n=!1,a=!1;const i=typeof MutationObserver<"u"&&document.body?new MutationObserver(()=>{a=!0}):null;i&&document.body&&i.observe(document.body,{childList:!0,subtree:!0});try{let o=function(l,d,f){var br;if(n)return;if(e.length>=t){n=!0;return}const w=l.tagName.toLowerCase();if(w==="script"||w==="style"||w==="noscript"||w==="template")return;const N=Pr(l);let F=d,st=f;if(N){const Ve=He(l),gr=B(l),ot=oe(l),$={refId:Ve,role:gr,tag:w};if(ot&&($.name=ot),$.text=ut(l,100),Rr(l,$),w==="a"){const P=se(l.getAttribute("href"));P&&($.href=P)}if(w==="img"){const P=se(l.getAttribute("src"));P&&($.src=P),$.alt=l.getAttribute("alt")||""}if(w==="input"){const P=l.getAttribute("title");P&&($.title=P);const te=l;if(te.type==="file"){const ct=te.getAttribute("accept");ct&&($.accept=ct),$.filesCount=((br=te.files)==null?void 0:br.length)??0}}if(w==="img"||w==="a"){const P=Pt(l);P?$.parentRefId=P:f&&($.parentRefId=f)}const yr=l.getAttribute("data-post-id");if(yr&&($.postId=yr),w!=="a"){const P=Dr(l);if(P){const te=se(P.getAttribute("href"));te&&($.permalink=te)}}if(w!=="img"){const P=l.querySelectorAll("img");if(P.length>0){const te=[];for(const ct of P){const vr=se(ct.getAttribute("src"));vr&&te.push(vr)}te.length>0&&($.imageUrls=te)}}e.push($),st=Ve;const Nt=[`${" ".repeat(d)}- ${gr}`];ot&&Nt.push(`"${ot.replace(/"/g,'\\"')}"`),Nt.push(`[${Ve}]`),r.push(Nt.join(" ")),F=d+1}for(const Ve of l.children){if(n)break;o(Ve,F,st)}};document.body&&o(document.body,0)}finally{i&&(i.takeRecords().length>0&&(a=!0),i.disconnect())}return a&&R({message:"DOM mutated during snapshot collection",code:"E_SNAPSHOT",category:"resource",details:{cause:"dom_mutated_during_snapshot",nodesCollected:e.length},recovery:["Wait for the page to finish rendering before snapshot","Retry with a smaller max_nodes bound","Use page.snapshot_data() after navigation settles"]}),{text:[`URL: ${window.location.href}`,`Title: ${document.title}`,""].concat(r).join(`
|
|
2
|
+
`),nodes:e,url:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight}}}const Yr=100;function yt(t){const e=ye(t),n=ye(e.options??e).max_nodes??e.max_nodes;let a=500;return typeof n=="number"&&Number.isFinite(n)?a=n:typeof n=="bigint"&&(a=Number(n)),Math.max(1,Math.min(1e4,Math.floor(a)))}function en(t,e){return e!=null&&e.aborted?Promise.reject(new DOMException("Aborted","AbortError")):new Promise((r,n)=>{const a=setTimeout(()=>{e==null||e.removeEventListener("abort",i),r()},t),i=()=>{clearTimeout(a),e==null||e.removeEventListener("abort",i),n(new DOMException("Aborted","AbortError"))};e==null||e.addEventListener("abort",i,{once:!0})})}function tn(t,e){return{top:t==="down"?e:t==="up"?-e:0,left:t==="right"?e:t==="left"?-e:0}}function Kt(t,e){const r=e==="y"?t.overflowY:t.overflowX;return r==="auto"||r==="scroll"||r==="overlay"}function zt(t,e){const r=window.getComputedStyle(t);return e==="up"||e==="down"?!Kt(r,"y")||t.scrollHeight<=t.clientHeight?!1:e==="down"?t.scrollTop<t.scrollHeight-t.clientHeight:t.scrollTop>0:!Kt(r,"x")||t.scrollWidth<=t.clientWidth?!1:e==="right"?t.scrollLeft<t.scrollWidth-t.clientWidth:t.scrollLeft>0}function rn(t){const e=t.getBoundingClientRect();if(e.width<=0||e.height<=0)return 0;const r=Math.min(e.right,window.innerWidth)-Math.max(e.left,0),n=Math.min(e.bottom,window.innerHeight)-Math.max(e.top,0);return Math.max(0,r)*Math.max(0,n)}function nn(t){const e=document.activeElement;if(e instanceof HTMLElement&&zt(e,t))return e;let r=null,n=0;for(const a of Array.from(document.querySelectorAll("*"))){if(a===document.body||a===document.documentElement||!zt(a,t))continue;const i=rn(a);i>n&&(r=a,n=i)}return r}function an(t){const r=ye(t).files;(!Array.isArray(r)||r.length===0)&&R({message:"setFiles requires a non-empty files array",code:"E_INVALID_PARAMS",category:"validation"});const n=[];for(const a of r){const i=ye(a),s=i.kind;if(s==="bytes"){const o=typeof i.name=="string"?i.name.trim():"",l=typeof i.data=="string"?i.data:"";(!o||!l)&&R({message:"Resolved bytes file requires name and data",code:"E_INVALID_PARAMS",category:"validation"}),n.push({kind:"bytes",name:o,data:l,mimeType:typeof i.mimeType=="string"&&i.mimeType.length>0?i.mimeType:void 0});continue}if(s==="url"){const o=typeof i.url=="string"?i.url:"",l=typeof i.name=="string"?i.name.trim():"";(!o||!l)&&R({message:"Resolved url file requires url and name",code:"E_INVALID_PARAMS",category:"validation"}),n.push({kind:"url",url:o,name:l,mimeType:typeof i.mimeType=="string"&&i.mimeType.length>0?i.mimeType:void 0})}}return n.length!==r.length&&R({message:"setFiles files must be worker-resolved (kind: bytes or url)",code:"E_INVALID_PARAMS",category:"validation"}),n}function sn(t){try{const e=jr(t.data);return new File([e.slice()],t.name,{type:t.mimeType??"application/octet-stream"})}catch{R({message:`Invalid base64 data for file ${t.name}`,code:"E_INVALID_PARAMS",category:"validation"})}}async function on(t){try{const e=await fetch(t.url);e.ok||R({message:`Failed to fetch file URL ${t.url}: HTTP ${e.status}`,code:"E_NETWORK",category:"network"});const r=new Uint8Array(await e.arrayBuffer()),n=t.mimeType||e.headers.get("content-type")||"application/octet-stream";return new File([r.slice()],t.name,{type:n})}catch(e){if(typeof e=="object"&&e!==null&&"code"in e&&typeof e.code=="string")throw e;const r=e instanceof Error?e.message:String(e);R({message:`Failed to fetch file URL ${t.url}: ${r}`,code:"E_NETWORK",category:"network"})}}function cn(t,e,r){var a;const n=Array.from(t.files??[]).map(i=>i.name);((((a=t.files)==null?void 0:a.length)??0)!==r.length||!r.every((i,s)=>n[s]===i))&&R(fe("setFiles",e,{expectedNames:r,actualNames:n}))}function ln(t){const e=ye(t),r=e.script??e.code??e.js??"";if(typeof r!="string"||r.length===0)throw new Error("evaluate requires a string argument");return r}function dn(t){if(t.hidden)return"hidden-attr";if(t.getAttribute("aria-hidden")==="true")return"aria-hidden";if(t.inert)return"inert";const e=window.getComputedStyle(t);if(e.display==="none")return"display-none";if(e.visibility==="hidden")return"visibility-hidden";if(e.opacity==="0")return"opacity-zero"}function Gt(t,e,r){var o;if(!r&&ge(t))return null;const n=t.tagName.toLowerCase(),a={tag:n,refId:He(t),role:B(t),name:oe(t)||void 0,text:ut(t,100)||void 0},i={};for(const l of Array.from(t.attributes))i[l.name]=l.value;Object.keys(i).length&&(a.attributes=i);const s=dn(t);if(s&&(a.hidden=!0,a.hiddenReason=s),Object.assign(a,Ke(t)),t instanceof HTMLInputElement&&t.type==="file"){const l=t.getAttribute("accept");l&&(a.accept=l),a.filesCount=((o=t.files)==null?void 0:o.length)??0}if(n==="a"){const l=se(t.getAttribute("href"));l&&(a.href=l)}if(n==="img"){const l=se(t.getAttribute("src"));l&&(a.src=l),a.alt=t.getAttribute("alt")||void 0}if(e>0){const l=[];for(const d of Array.from(t.children)){const f=Gt(d,e-1,r);f&&l.push(f)}l.length&&(a.children=l)}return a}function Jt(t){return Array.from(t.querySelectorAll('[role="option"]')).map(e=>(e.textContent||"").trim()).join(`
|
|
3
|
+
`)}function un(t){const e=new Map(Array.from(document.querySelectorAll('[role="listbox"]')).map(f=>[f,{hidden:ge(f),sig:Jt(f)}]));for(const f of["mouseover","mousedown","mouseup"])t.dispatchEvent(new MouseEvent(f,{bubbles:!0,cancelable:!0}));t.click();const n=`${t.getAttribute("aria-controls")||""} ${t.getAttribute("aria-owns")||""}`.trim().split(/\s+/).filter(Boolean).map(f=>document.getElementById(f)).filter(f=>f instanceof HTMLElement&&f.getAttribute("role")==="listbox"),a=Array.from(document.querySelectorAll('[role="listbox"]')),i=a.filter(f=>{const w=e.get(f);return ge(f)?!1:!w||w.hidden?!0:Jt(f)!==w.sig}),s=Array.from(t.querySelectorAll('[role="listbox"]')),o=t.getAttribute("role")==="listbox"?[t]:[],l=[...new Set([...n,...i,...s,...o])],d=l.map(f=>f.id).filter(Boolean);return{roots:l,searchedIds:d,allListboxes:a}}const fn={click:t=>{const e=t.refId,r=t.label;let n;return e?n=bt(e,"click"):r?n=Qr(r,"click"):Se(e,r,!0),G(n,"click"),n.click(),O("click",n,{observationId:Ae(),dispatched:!0,verification:"required"})},fill:t=>{const e=t.refId,r=t.label,n=t.value;let a;if(e?a=bt(e,"fill"):r?(a=ft(r),a||Se(e,r,!0)):Se(e,r,!0),G(a,"fill"),a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement){a.value=n;const i=new InputEvent("input",{bubbles:!0});a.dispatchEvent(i);const s=e||a.getAttribute("data-ref-id")||"";return pt("fill",a,s,n),O("fill",a,{value:a.value,observationId:Ae(),dispatched:!0,verification:"required"})}if(a instanceof HTMLElement&&a.isContentEditable){a.innerText=n;const i=new InputEvent("input",{bubbles:!0,inputType:"insertText",data:n});return a.dispatchEvent(i),e||a.getAttribute("data-ref-id"),O("fill",a,{value:a.innerText,observationId:Ae(),dispatched:!0,verification:"required"})}throw new Error("Element is not an input or contenteditable")},set_files:async t=>{var o,l;const e=an(t),r=J(t.refId,t.label);let n;if(r instanceof HTMLInputElement&&r.type==="file")n=r;else{const d=r.querySelector('input[type="file"]'),f=(o=r.closest("label"))==null?void 0:o.querySelector('input[type="file"]'),w=r.getAttribute("for"),N=w?(l=document.getElementById(w))==null?void 0:l.querySelector('input[type="file"]'):null,F=d??f??N;if(!F){const st=t.refId??"";R(fe("setFiles",st,{reason:"not_file_input"}))}n=F}const a=new DataTransfer,i=[];for(const d of e){const f=d.kind==="bytes"?sn(d):await on(d);a.items.add(f),i.push(f.name)}n.files=a.files,n.dispatchEvent(new Event("change",{bubbles:!0}));const s=t.refId||n.getAttribute("data-ref-id")||"";return cn(n,s,i),O("setFiles",n,{fileCount:i.length,fileNames:i})},type:t=>{const e=t.refId,r=t.label,n=t.text,a=J(e,r);if(G(a,"type"),a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement){a.value=n;const i=new InputEvent("input",{bubbles:!0});a.dispatchEvent(i);const s=e||a.getAttribute("data-ref-id")||"";return pt("type",a,s,n),O("type",a,{text:a.value})}throw new Error("Element is not an input")},append:t=>{const e=t.refId,r=t.label,n=t.text,a=J(e,r);if(G(a,"append"),a instanceof HTMLInputElement||a instanceof HTMLTextAreaElement){const s=a.value+n;a.value+=n;const o=new InputEvent("input",{bubbles:!0});a.dispatchEvent(o);const l=e||a.getAttribute("data-ref-id")||"";return pt("append",a,l,s),O("append",a,{text:a.value})}throw new Error("Element is not an input")},press:t=>{Gr()||R(Sr("press"));const e=t.key,r=t.refId,n=t.label;let a=document,i=null;(r||n)&&(r?i=bt(r,"press"):n&&(i=ft(n),i||Se(r,n,!0)),G(i,"press"),a=i);const s=new KeyboardEvent("keydown",{key:e,bubbles:!0});a.dispatchEvent(s);const o=new KeyboardEvent("keyup",{key:e,bubbles:!0});return a.dispatchEvent(o),O("press",i,{key:e,observationId:Ae(),dispatched:!0,verification:"required"})},select:t=>{const e=t.refId,r=t.label,n=t.value,a=J(e,r);if(G(a,"select"),a instanceof HTMLSelectElement){if(Array.isArray(n)){const i=new Set(n);let s=0;for(const l of Array.from(a.options)){const d=i.has(l.value);l.selected=d,d&&(s+=1)}!a.multiple&&s>1&&R(fe("select",e??"",{reason:"single_select_multiple_values"})),a.dispatchEvent(new Event("change",{bubbles:!0}));const o=Array.from(a.options).filter(l=>l.selected).map(l=>l.value);return O("select",a,{value:o})}return a.value=n,a.dispatchEvent(new Event("change",{bubbles:!0})),O("select",a,{value:a.value})}throw new Error("Element is not a select")},select_option:t=>{const e=t.value,r=J(t.refId,t.label);if(G(r,"select_option"),r instanceof HTMLSelectElement){const f=Array.from(r.options).find(w=>(w.text||"").trim()===e)||Array.from(r.options).find(w=>(w.text||"").trim().toLowerCase()===e.toLowerCase());if(!f){const w=Array.from(r.options).map((N,F)=>({refId:`opt${F}`,name:(N.text||"").trim()||void 0}));R(Te(e,w))}return r.value=f.value,r.dispatchEvent(new Event("change",{bubbles:!0})),O("select_option",r,{value:f.value})}const n=r,{roots:a,searchedIds:i,allListboxes:s}=un(n),o=[...new Set(a.flatMap(f=>Array.from(f.querySelectorAll('[role="option"]'))))],l=e.trim().toLowerCase(),d=o.find(f=>(f.textContent||"").trim()===e.trim())||o.find(f=>(f.textContent||"").trim().toLowerCase()===l);if(!d){const f=o.map((N,F)=>({refId:N.getAttribute("data-ref-id")||`opt${F}`,name:(N.textContent||"").trim()||void 0})),w=s.filter(N=>!a.includes(N)&&!ge(N)).map(N=>N.id).filter(Boolean);R(Te(e,f,{searchedIds:i,ignoredIds:w,targetRefId:n.getAttribute("data-ref-id")||void 0,targetName:n.getAttribute("aria-label")||n.getAttribute("data-ref-id")||""}))}for(const f of["mouseover","mousedown","mouseup"])d.dispatchEvent(new MouseEvent(f,{bubbles:!0,cancelable:!0}));return d.click(),O("select_option",r,{value:e})},check:t=>{const e=t.refId,r=t.label,n=t.checked??!0,a=J(e,r);if(G(a,"check"),a instanceof HTMLInputElement&&(a.type==="checkbox"||a.type==="radio"))return a.checked=n,a.dispatchEvent(new Event("change",{bubbles:!0})),O("check",a,{checked:a.checked});throw new Error("Element is not a checkbox or radio")},check_radio:t=>{const e=t.name,r=t.value,n=`input[type="radio"][name="${CSS.escape(e)}"]`,a=Array.from(document.querySelectorAll(n));a.length===0&&R(Te(`radio group "${e}"`,[]));const i=a.find(s=>s.value===r);if(!i){const s=a.map((o,l)=>({refId:`radio${l}`,name:o.value||void 0}));R(Te(`radio value "${r}" in group "${e}"`,s))}return G(i,"check_radio"),i.checked=!0,i.dispatchEvent(new Event("change",{bubbles:!0})),O("check_radio",i,{checked:i.checked,value:i.value})},hover:t=>{const e=t.refId,r=t.label,n=J(e,r);G(n,"hover");const a=new MouseEvent("mouseenter",{bubbles:!0});return n.dispatchEvent(a),O("hover",n)},unhover:()=>{const t=new MouseEvent("mouseleave",{bubbles:!0});return document.body.dispatchEvent(t),O("unhover",null)},submit:t=>{const e=t.refId,r=t.label,n=J(e,r);let a=null;return n instanceof HTMLFormElement?a=n:n.closest("form")&&(a=n.closest("form")),a||R(fe("submit",e??"",{reason:"not_form"})),typeof a.requestSubmit=="function"?a.requestSubmit():a.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0})),O("submit",a,{dispatched:!0,observationId:Ae(),verification:"required"})},scroll:t=>{mt();const e=t.direction,r=t.amount,{top:n,left:a}=tn(e,r),i=nn(e);return i?(i.scrollBy({top:n,left:a,behavior:"smooth"}),O("scroll",i,{direction:e,amount:r})):(window.scrollBy({top:n,left:a,behavior:"smooth"}),O("scroll",null,{direction:e,amount:r}))},dblclick:t=>{const e=t.refId,r=t.label,n=J(e,r),a=n;return a.click(),a.click(),a.dispatchEvent(new MouseEvent("dblclick",{bubbles:!0,cancelable:!0})),O("dblclick",n)},forward:()=>(mt(),window.history.forward(),O("forward",null)),scroll_to:t=>{const e=t.refId,r=t.label,n=t.x??0,a=t.y??0;if(e||r){const i=J(e,r);return i.scrollIntoView({behavior:"smooth"}),O("scroll_to",i)}return window.scrollTo({top:a,left:n,behavior:"smooth"}),O("scroll_to",null,{amount:a})},evaluate:t=>{const e=ln(t);return new Function(e)()},back:()=>(mt(),window.history.back(),O("back",null)),ping:()=>({ok:!0}),snapshot:async t=>{document.body||R({message:"Document body not available for snapshot",code:"E_SNAPSHOT",category:"resource",details:{cause:"document.body is null"},recovery:["Wait for the page to load fully before taking a snapshot."]});const e=yt(t);be.debug("snapshot",{maxNodes:e,hasBody:!!document.body});const r=gt(e),n=r.nodes.map(i=>{const s=$t(i.refId);return s?{refId:i.refId,element:s}:null}).filter(i=>i!==null),a=Wt(n);return{...r,observationId:a}},snapshot_text:async t=>{document.body||R({message:"Document body not available for snapshot",code:"E_SNAPSHOT",category:"resource",details:{cause:"document.body is null"},recovery:["Wait for the page to load fully before taking a snapshot."]});const e=yt(t);return gt(e).text},snapshot_query:async t=>{document.body||R({message:"Document body not available for snapshot",code:"E_SNAPSHOT",category:"resource",details:{cause:"document.body is null"},recovery:["Wait for the page to load fully before taking a snapshot."]});const e=yt(t),r=gt(e),n=t.filter??{};return{text:"",nodes:Kr(r.nodes,n),url:r.url,title:r.title,viewport:r.viewport}},find:t=>{lt();const e=t.selector,r=Array.from(document.querySelectorAll(e)),n=[],a=r.map(i=>{var w;const s=He(i);n.push({refId:s,element:i});const o=B(i),l=oe(i),d={tag:i.tagName.toLowerCase(),refId:s,role:o,text:((w=i.textContent)==null?void 0:w.slice(0,100))||"",...Ke(i)};l&&(d.name=l);const f=i.tagName.toLowerCase();if(f==="a"){const N=se(i.getAttribute("href"));N&&(d.href=N)}if(f==="img"){const N=se(i.getAttribute("src"));N&&(d.src=N),d.alt=i.getAttribute("alt")||""}if(f==="input"){const N=i.getAttribute("title");N&&(d.title=N)}if(f==="img"||f==="a"){const N=Pt(i);N&&(d.parentRefId=N)}return d});return Wt(n),a},dom:t=>{lt();const e=t.selector,r=t.depth??2,n=t.includeHidden??!0;return{nodes:Array.from(document.querySelectorAll(e)).map(s=>Gt(s,r,n)).filter(s=>s!==null),url:window.location.href,title:document.title}},wait_for:async(t,e)=>{const r=t.selector,n=Number(t.timeout),a=Date.now();for(;;){if(e!=null&&e.aborted)throw new DOMException("Aborted","AbortError");if(document.querySelector(r))return!0;Date.now()-a>=n&&R({message:`Timeout waiting for selector: ${r}`,code:"E_TIMEOUT",category:"timeout"}),await en(Yr,e)}},extract:t=>{var n,a;const e=t.fields,r={};for(const i of e)if(i==="title")r.title=document.title;else if(i==="url")r.url=window.location.href;else if(i==="headings"){const s=Array.from(document.querySelectorAll("h1, h2, h3, h4, h5, h6"));r.headings=s.map(o=>{var l;return{tag:o.tagName,text:((l=o.textContent)==null?void 0:l.trim().slice(0,200))||""}})}else if(i==="links"){const s=Array.from(document.querySelectorAll("a[href]"));r.links=s.map(o=>{var l;return{href:o.getAttribute("href"),text:((l=o.textContent)==null?void 0:l.trim().slice(0,100))||""}})}else i==="text"&&(r.text=((a=(n=document.body)==null?void 0:n.textContent)==null?void 0:a.trim().slice(0,500))||"");return r},fetch:async(t,e)=>{const r=t.url;if(!r)throw new Error("fetch requires a url");const n=t.method.toUpperCase(),a=t.headers,i=t.body,s=Number(t.timeout),o=new AbortController,l=()=>o.abort();if(e){if(e.aborted)throw new DOMException("Aborted","AbortError");e.addEventListener("abort",l,{once:!0})}const d=setTimeout(()=>o.abort(),s);try{const f={method:n,headers:a,signal:o.signal};i!==null&&(f.body=i);const w=await fetch(r,f);return Vr(w)}finally{clearTimeout(d),e==null||e.removeEventListener("abort",l)}}};function Qe(t){return t==null?{}:t instanceof Map?Object.fromEntries([...t.entries()].map(([e,r])=>[e,Qe(r)])):Array.isArray(t)?t.map(Qe):t}var C;(function(t){t.assertEqual=a=>{};function e(a){}t.assertIs=e;function r(a){throw new Error}t.assertNever=r,t.arrayToEnum=a=>{const i={};for(const s of a)i[s]=s;return i},t.getValidEnumValues=a=>{const i=t.objectKeys(a).filter(o=>typeof a[a[o]]!="number"),s={};for(const o of i)s[o]=a[o];return t.objectValues(s)},t.objectValues=a=>t.objectKeys(a).map(function(i){return a[i]}),t.objectKeys=typeof Object.keys=="function"?a=>Object.keys(a):a=>{const i=[];for(const s in a)Object.prototype.hasOwnProperty.call(a,s)&&i.push(s);return i},t.find=(a,i)=>{for(const s of a)if(i(s))return s},t.isInteger=typeof Number.isInteger=="function"?a=>Number.isInteger(a):a=>typeof a=="number"&&Number.isFinite(a)&&Math.floor(a)===a;function n(a,i=" | "){return a.map(s=>typeof s=="string"?`'${s}'`:s).join(i)}t.joinValues=n,t.jsonStringifyReplacer=(a,i)=>typeof i=="bigint"?i.toString():i})(C||(C={}));var Qt;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(Qt||(Qt={}));const b=C.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),ce=t=>{switch(typeof t){case"undefined":return b.undefined;case"string":return b.string;case"number":return Number.isNaN(t)?b.nan:b.number;case"boolean":return b.boolean;case"function":return b.function;case"bigint":return b.bigint;case"symbol":return b.symbol;case"object":return Array.isArray(t)?b.array:t===null?b.null:t.then&&typeof t.then=="function"&&t.catch&&typeof t.catch=="function"?b.promise:typeof Map<"u"&&t instanceof Map?b.map:typeof Set<"u"&&t instanceof Set?b.set:typeof Date<"u"&&t instanceof Date?b.date:b.object;default:return b.unknown}},p=C.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]);class U extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};const r=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,r):this.__proto__=r,this.name="ZodError",this.issues=e}format(e){const r=e||function(i){return i.message},n={_errors:[]},a=i=>{for(const s of i.issues)if(s.code==="invalid_union")s.unionErrors.map(a);else if(s.code==="invalid_return_type")a(s.returnTypeError);else if(s.code==="invalid_arguments")a(s.argumentsError);else if(s.path.length===0)n._errors.push(r(s));else{let o=n,l=0;for(;l<s.path.length;){const d=s.path[l];l===s.path.length-1?(o[d]=o[d]||{_errors:[]},o[d]._errors.push(r(s))):o[d]=o[d]||{_errors:[]},o=o[d],l++}}};return a(this),n}static assert(e){if(!(e instanceof U))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,C.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=r=>r.message){const r={},n=[];for(const a of this.issues)if(a.path.length>0){const i=a.path[0];r[i]=r[i]||[],r[i].push(e(a))}else n.push(e(a));return{formErrors:n,fieldErrors:r}}get formErrors(){return this.flatten()}}U.create=t=>new U(t);const Ce=(t,e)=>{let r;switch(t.code){case p.invalid_type:t.received===b.undefined?r="Required":r=`Expected ${t.expected}, received ${t.received}`;break;case p.invalid_literal:r=`Invalid literal value, expected ${JSON.stringify(t.expected,C.jsonStringifyReplacer)}`;break;case p.unrecognized_keys:r=`Unrecognized key(s) in object: ${C.joinValues(t.keys,", ")}`;break;case p.invalid_union:r="Invalid input";break;case p.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${C.joinValues(t.options)}`;break;case p.invalid_enum_value:r=`Invalid enum value. Expected ${C.joinValues(t.options)}, received '${t.received}'`;break;case p.invalid_arguments:r="Invalid function arguments";break;case p.invalid_return_type:r="Invalid function return type";break;case p.invalid_date:r="Invalid date";break;case p.invalid_string:typeof t.validation=="object"?"includes"in t.validation?(r=`Invalid input: must include "${t.validation.includes}"`,typeof t.validation.position=="number"&&(r=`${r} at one or more positions greater than or equal to ${t.validation.position}`)):"startsWith"in t.validation?r=`Invalid input: must start with "${t.validation.startsWith}"`:"endsWith"in t.validation?r=`Invalid input: must end with "${t.validation.endsWith}"`:C.assertNever(t.validation):t.validation!=="regex"?r=`Invalid ${t.validation}`:r="Invalid";break;case p.too_small:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at least":"more than"} ${t.minimum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at least":"over"} ${t.minimum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="bigint"?r=`Number must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${t.minimum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly equal to ":t.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(t.minimum))}`:r="Invalid input";break;case p.too_big:t.type==="array"?r=`Array must contain ${t.exact?"exactly":t.inclusive?"at most":"less than"} ${t.maximum} element(s)`:t.type==="string"?r=`String must contain ${t.exact?"exactly":t.inclusive?"at most":"under"} ${t.maximum} character(s)`:t.type==="number"?r=`Number must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="bigint"?r=`BigInt must be ${t.exact?"exactly":t.inclusive?"less than or equal to":"less than"} ${t.maximum}`:t.type==="date"?r=`Date must be ${t.exact?"exactly":t.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(t.maximum))}`:r="Invalid input";break;case p.custom:r="Invalid input";break;case p.invalid_intersection_types:r="Intersection results could not be merged";break;case p.not_multiple_of:r=`Number must be a multiple of ${t.multipleOf}`;break;case p.not_finite:r="Number must be finite";break;default:r=e.defaultError,C.assertNever(t)}return{message:r}};let pn=Ce;function vt(){return pn}const _t=t=>{const{data:e,path:r,errorMaps:n,issueData:a}=t,i=[...r,...a.path||[]],s={...a,path:i};if(a.message!==void 0)return{...a,path:i,message:a.message};let o="";const l=n.filter(d=>!!d).slice().reverse();for(const d of l)o=d(s,{data:e,defaultError:o}).message;return{...a,path:i,message:o}};function m(t,e){const r=vt(),n=_t({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ce?void 0:Ce].filter(a=>!!a)});t.common.issues.push(n)}class L{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,r){const n=[];for(const a of r){if(a.status==="aborted")return k;a.status==="dirty"&&e.dirty(),n.push(a.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,r){const n=[];for(const a of r){const i=await a.key,s=await a.value;n.push({key:i,value:s})}return L.mergeObjectSync(e,n)}static mergeObjectSync(e,r){const n={};for(const a of r){const{key:i,value:s}=a;if(i.status==="aborted"||s.status==="aborted")return k;i.status==="dirty"&&e.dirty(),s.status==="dirty"&&e.dirty(),i.value!=="__proto__"&&(typeof s.value<"u"||a.alwaysSet)&&(n[i.value]=s.value)}return{status:e.value,value:n}}}const k=Object.freeze({status:"aborted"}),Ne=t=>({status:"dirty",value:t}),j=t=>({status:"valid",value:t}),Xt=t=>t.status==="aborted",Yt=t=>t.status==="dirty",_e=t=>t.status==="valid",Xe=t=>typeof Promise<"u"&&t instanceof Promise;var g;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(g||(g={}));class Q{constructor(e,r,n,a){this._cachedPath=[],this.parent=e,this.data=r,this._path=n,this._key=a}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}}const er=(t,e)=>{if(_e(e))return{success:!0,data:e.value};if(!t.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;const r=new U(t.common.issues);return this._error=r,this._error}}};function I(t){if(!t)return{};const{errorMap:e,invalid_type_error:r,required_error:n,description:a}=t;if(e&&(r||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:a}:{errorMap:(s,o)=>{const{message:l}=t;return s.code==="invalid_enum_value"?{message:l??o.defaultError}:typeof o.data>"u"?{message:l??n??o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:l??r??o.defaultError}},description:a}}class S{get description(){return this._def.description}_getType(e){return ce(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new L,ctx:{common:e.parent.common,data:e.data,parsedType:ce(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Xe(r))throw new Error("Synchronous parse encountered promise.");return r}_parseAsync(e){const r=this._parse(e);return Promise.resolve(r)}parse(e,r){const n=this.safeParse(e,r);if(n.success)return n.data;throw n.error}safeParse(e,r){const n={common:{issues:[],async:(r==null?void 0:r.async)??!1,contextualErrorMap:r==null?void 0:r.errorMap},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ce(e)},a=this._parseSync({data:e,path:n.path,parent:n});return er(n,a)}"~validate"(e){var n,a;const r={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ce(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:r});return _e(i)?{value:i.value}:{issues:r.common.issues}}catch(i){(a=(n=i==null?void 0:i.message)==null?void 0:n.toLowerCase())!=null&&a.includes("encountered")&&(this["~standard"].async=!0),r.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:r}).then(i=>_e(i)?{value:i.value}:{issues:r.common.issues})}async parseAsync(e,r){const n=await this.safeParseAsync(e,r);if(n.success)return n.data;throw n.error}async safeParseAsync(e,r){const n={common:{issues:[],contextualErrorMap:r==null?void 0:r.errorMap,async:!0},path:(r==null?void 0:r.path)||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:ce(e)},a=this._parse({data:e,path:n.path,parent:n}),i=await(Xe(a)?a:Promise.resolve(a));return er(n,i)}refine(e,r){const n=a=>typeof r=="string"||typeof r>"u"?{message:r}:typeof r=="function"?r(a):r;return this._refinement((a,i)=>{const s=e(a),o=()=>i.addIssue({code:p.custom,...n(a)});return typeof Promise<"u"&&s instanceof Promise?s.then(l=>l?!0:(o(),!1)):s?!0:(o(),!1)})}refinement(e,r){return this._refinement((n,a)=>e(n)?!0:(a.addIssue(typeof r=="function"?r(n,a):r),!1))}_refinement(e){return new ae({schema:this,typeName:x.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:r=>this["~validate"](r)}}optional(){return W.create(this,this._def)}nullable(){return ue.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return V.create(this)}promise(){return xe.create(this,this._def)}or(e){return De.create([this,e],this._def)}and(e){return qe.create(this,e,this._def)}transform(e){return new ae({...I(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new je({...I(this._def),innerType:this,defaultValue:r,typeName:x.ZodDefault})}brand(){return new At({typeName:x.ZodBranded,type:this,...I(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Fe({...I(this._def),innerType:this,catchValue:r,typeName:x.ZodCatch})}describe(e){const r=this.constructor;return new r({...this._def,description:e})}pipe(e){return rt.create(this,e)}readonly(){return Ue.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const hn=/^c[^\s-]{8,}$/i,mn=/^[0-9a-z]+$/,bn=/^[0-9A-HJKMNP-TV-Z]{26}$/i,gn=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,yn=/^[a-z0-9_-]{21}$/i,vn=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,_n=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,wn=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,kn="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let wt;const xn=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,In=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Tn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Sn=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,En=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,An=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,tr="((\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-((0[13578]|1[02])-(0[1-9]|[12]\\d|3[01])|(0[469]|11)-(0[1-9]|[12]\\d|30)|(02)-(0[1-9]|1\\d|2[0-8])))",Cn=new RegExp(`^${tr}$`);function rr(t){let e="[0-5]\\d";t.precision?e=`${e}\\.\\d{${t.precision}}`:t.precision==null&&(e=`${e}(\\.\\d+)?`);const r=t.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${r}`}function Nn(t){return new RegExp(`^${rr(t)}$`)}function Rn(t){let e=`${tr}T${rr(t)}`;const r=[];return r.push(t.local?"Z?":"Z"),t.offset&&r.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${r.join("|")})`,new RegExp(`^${e}$`)}function On(t,e){return!!((e==="v4"||!e)&&xn.test(t)||(e==="v6"||!e)&&Tn.test(t))}function Dn(t,e){if(!vn.test(t))return!1;try{const[r]=t.split(".");if(!r)return!1;const n=r.replace(/-/g,"+").replace(/_/g,"/").padEnd(r.length+(4-r.length%4)%4,"="),a=JSON.parse(atob(n));return!(typeof a!="object"||a===null||"typ"in a&&(a==null?void 0:a.typ)!=="JWT"||!a.alg||e&&a.alg!==e)}catch{return!1}}function qn(t,e){return!!((e==="v4"||!e)&&In.test(t)||(e==="v6"||!e)&&Sn.test(t))}class X extends S{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==b.string){const i=this._getOrReturnCtx(e);return m(i,{code:p.invalid_type,expected:b.string,received:i.parsedType}),k}const n=new L;let a;for(const i of this._def.checks)if(i.kind==="min")e.data.length<i.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:p.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="max")e.data.length>i.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:p.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!1,message:i.message}),n.dirty());else if(i.kind==="length"){const s=e.data.length>i.value,o=e.data.length<i.value;(s||o)&&(a=this._getOrReturnCtx(e,a),s?m(a,{code:p.too_big,maximum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}):o&&m(a,{code:p.too_small,minimum:i.value,type:"string",inclusive:!0,exact:!0,message:i.message}),n.dirty())}else if(i.kind==="email")wn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"email",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="emoji")wt||(wt=new RegExp(kn,"u")),wt.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"emoji",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="uuid")gn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"uuid",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="nanoid")yn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"nanoid",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid")hn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"cuid",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="cuid2")mn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"cuid2",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="ulid")bn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"ulid",code:p.invalid_string,message:i.message}),n.dirty());else if(i.kind==="url")try{new URL(e.data)}catch{a=this._getOrReturnCtx(e,a),m(a,{validation:"url",code:p.invalid_string,message:i.message}),n.dirty()}else i.kind==="regex"?(i.regex.lastIndex=0,i.regex.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"regex",code:p.invalid_string,message:i.message}),n.dirty())):i.kind==="trim"?e.data=e.data.trim():i.kind==="includes"?e.data.includes(i.value,i.position)||(a=this._getOrReturnCtx(e,a),m(a,{code:p.invalid_string,validation:{includes:i.value,position:i.position},message:i.message}),n.dirty()):i.kind==="toLowerCase"?e.data=e.data.toLowerCase():i.kind==="toUpperCase"?e.data=e.data.toUpperCase():i.kind==="startsWith"?e.data.startsWith(i.value)||(a=this._getOrReturnCtx(e,a),m(a,{code:p.invalid_string,validation:{startsWith:i.value},message:i.message}),n.dirty()):i.kind==="endsWith"?e.data.endsWith(i.value)||(a=this._getOrReturnCtx(e,a),m(a,{code:p.invalid_string,validation:{endsWith:i.value},message:i.message}),n.dirty()):i.kind==="datetime"?Rn(i).test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:p.invalid_string,validation:"datetime",message:i.message}),n.dirty()):i.kind==="date"?Cn.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:p.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?Nn(i).test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:p.invalid_string,validation:"time",message:i.message}),n.dirty()):i.kind==="duration"?_n.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"duration",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?On(e.data,i.version)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"ip",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="jwt"?Dn(e.data,i.alg)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"jwt",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="cidr"?qn(e.data,i.version)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"cidr",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="base64"?En.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"base64",code:p.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?An.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"base64url",code:p.invalid_string,message:i.message}),n.dirty()):C.assertNever(i);return{status:n.value,value:e.data}}_regex(e,r,n){return this.refinement(a=>e.test(a),{validation:r,code:p.invalid_string,...g.errToObj(n)})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...g.errToObj(e)})}url(e){return this._addCheck({kind:"url",...g.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...g.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...g.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...g.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...g.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...g.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...g.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...g.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...g.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...g.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...g.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...g.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,offset:(e==null?void 0:e.offset)??!1,local:(e==null?void 0:e.local)??!1,...g.errToObj(e==null?void 0:e.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof(e==null?void 0:e.precision)>"u"?null:e==null?void 0:e.precision,...g.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...g.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...g.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...g.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...g.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...g.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...g.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...g.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...g.errToObj(r)})}nonempty(e){return this.min(1,g.errToObj(e))}trim(){return new X({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new X({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new X({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxLength(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}X.create=t=>new X({checks:[],typeName:x.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...I(t)});function Mn(t,e){const r=(t.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,a=r>n?r:n,i=Number.parseInt(t.toFixed(a).replace(".","")),s=Number.parseInt(e.toFixed(a).replace(".",""));return i%s/10**a}class pe extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==b.number){const i=this._getOrReturnCtx(e);return m(i,{code:p.invalid_type,expected:b.number,received:i.parsedType}),k}let n;const a=new L;for(const i of this._def.checks)i.kind==="int"?C.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:p.invalid_type,expected:"integer",received:"float",message:i.message}),a.dirty()):i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:p.too_small,minimum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:p.too_big,maximum:i.value,type:"number",inclusive:i.inclusive,exact:!1,message:i.message}),a.dirty()):i.kind==="multipleOf"?Mn(e.data,i.value)!==0&&(n=this._getOrReturnCtx(e,n),m(n,{code:p.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):i.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:p.not_finite,message:i.message}),a.dirty()):C.assertNever(i);return{status:a.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,g.toString(r))}gt(e,r){return this.setLimit("min",e,!1,g.toString(r))}lte(e,r){return this.setLimit("max",e,!0,g.toString(r))}lt(e,r){return this.setLimit("max",e,!1,g.toString(r))}setLimit(e,r,n,a){return new pe({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(a)}]})}_addCheck(e){return new pe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:g.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:g.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:g.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:g.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:g.toString(e)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&C.isInteger(e.value))}get isFinite(){let e=null,r=null;for(const n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(r===null||n.value>r)&&(r=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(r)&&Number.isFinite(e)}}pe.create=t=>new pe({checks:[],typeName:x.ZodNumber,coerce:(t==null?void 0:t.coerce)||!1,...I(t)});class he extends S{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==b.bigint)return this._getInvalidInput(e);let n;const a=new L;for(const i of this._def.checks)i.kind==="min"?(i.inclusive?e.data<i.value:e.data<=i.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:p.too_small,type:"bigint",minimum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="max"?(i.inclusive?e.data>i.value:e.data>=i.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:p.too_big,type:"bigint",maximum:i.value,inclusive:i.inclusive,message:i.message}),a.dirty()):i.kind==="multipleOf"?e.data%i.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),m(n,{code:p.not_multiple_of,multipleOf:i.value,message:i.message}),a.dirty()):C.assertNever(i);return{status:a.value,value:e.data}}_getInvalidInput(e){const r=this._getOrReturnCtx(e);return m(r,{code:p.invalid_type,expected:b.bigint,received:r.parsedType}),k}gte(e,r){return this.setLimit("min",e,!0,g.toString(r))}gt(e,r){return this.setLimit("min",e,!1,g.toString(r))}lte(e,r){return this.setLimit("max",e,!0,g.toString(r))}lt(e,r){return this.setLimit("max",e,!1,g.toString(r))}setLimit(e,r,n,a){return new he({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:g.toString(a)}]})}_addCheck(e){return new he({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:g.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:g.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:g.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:g.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:g.toString(r)})}get minValue(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e}get maxValue(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e}}he.create=t=>new he({checks:[],typeName:x.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...I(t)});class Ye extends S{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==b.boolean){const n=this._getOrReturnCtx(e);return m(n,{code:p.invalid_type,expected:b.boolean,received:n.parsedType}),k}return j(e.data)}}Ye.create=t=>new Ye({typeName:x.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...I(t)});class Re extends S{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==b.date){const i=this._getOrReturnCtx(e);return m(i,{code:p.invalid_type,expected:b.date,received:i.parsedType}),k}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return m(i,{code:p.invalid_date}),k}const n=new L;let a;for(const i of this._def.checks)i.kind==="min"?e.data.getTime()<i.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:p.too_small,message:i.message,inclusive:!0,exact:!1,minimum:i.value,type:"date"}),n.dirty()):i.kind==="max"?e.data.getTime()>i.value&&(a=this._getOrReturnCtx(e,a),m(a,{code:p.too_big,message:i.message,inclusive:!0,exact:!1,maximum:i.value,type:"date"}),n.dirty()):C.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Re({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:g.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:g.toString(r)})}get minDate(){let e=null;for(const r of this._def.checks)r.kind==="min"&&(e===null||r.value>e)&&(e=r.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(const r of this._def.checks)r.kind==="max"&&(e===null||r.value<e)&&(e=r.value);return e!=null?new Date(e):null}}Re.create=t=>new Re({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:x.ZodDate,...I(t)});class nr extends S{_parse(e){if(this._getType(e)!==b.symbol){const n=this._getOrReturnCtx(e);return m(n,{code:p.invalid_type,expected:b.symbol,received:n.parsedType}),k}return j(e.data)}}nr.create=t=>new nr({typeName:x.ZodSymbol,...I(t)});class et extends S{_parse(e){if(this._getType(e)!==b.undefined){const n=this._getOrReturnCtx(e);return m(n,{code:p.invalid_type,expected:b.undefined,received:n.parsedType}),k}return j(e.data)}}et.create=t=>new et({typeName:x.ZodUndefined,...I(t)});class Oe extends S{_parse(e){if(this._getType(e)!==b.null){const n=this._getOrReturnCtx(e);return m(n,{code:p.invalid_type,expected:b.null,received:n.parsedType}),k}return j(e.data)}}Oe.create=t=>new Oe({typeName:x.ZodNull,...I(t)});class kt extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return j(e.data)}}kt.create=t=>new kt({typeName:x.ZodAny,...I(t)});class me extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return j(e.data)}}me.create=t=>new me({typeName:x.ZodUnknown,...I(t)});class le extends S{_parse(e){const r=this._getOrReturnCtx(e);return m(r,{code:p.invalid_type,expected:b.never,received:r.parsedType}),k}}le.create=t=>new le({typeName:x.ZodNever,...I(t)});class xt extends S{_parse(e){if(this._getType(e)!==b.undefined){const n=this._getOrReturnCtx(e);return m(n,{code:p.invalid_type,expected:b.void,received:n.parsedType}),k}return j(e.data)}}xt.create=t=>new xt({typeName:x.ZodVoid,...I(t)});class V extends S{_parse(e){const{ctx:r,status:n}=this._processInputParams(e),a=this._def;if(r.parsedType!==b.array)return m(r,{code:p.invalid_type,expected:b.array,received:r.parsedType}),k;if(a.exactLength!==null){const s=r.data.length>a.exactLength.value,o=r.data.length<a.exactLength.value;(s||o)&&(m(r,{code:s?p.too_big:p.too_small,minimum:o?a.exactLength.value:void 0,maximum:s?a.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:a.exactLength.message}),n.dirty())}if(a.minLength!==null&&r.data.length<a.minLength.value&&(m(r,{code:p.too_small,minimum:a.minLength.value,type:"array",inclusive:!0,exact:!1,message:a.minLength.message}),n.dirty()),a.maxLength!==null&&r.data.length>a.maxLength.value&&(m(r,{code:p.too_big,maximum:a.maxLength.value,type:"array",inclusive:!0,exact:!1,message:a.maxLength.message}),n.dirty()),r.common.async)return Promise.all([...r.data].map((s,o)=>a.type._parseAsync(new Q(r,s,r.path,o)))).then(s=>L.mergeArray(n,s));const i=[...r.data].map((s,o)=>a.type._parseSync(new Q(r,s,r.path,o)));return L.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new V({...this._def,minLength:{value:e,message:g.toString(r)}})}max(e,r){return new V({...this._def,maxLength:{value:e,message:g.toString(r)}})}length(e,r){return new V({...this._def,exactLength:{value:e,message:g.toString(r)}})}nonempty(e){return this.min(1,e)}}V.create=(t,e)=>new V({type:t,minLength:null,maxLength:null,exactLength:null,typeName:x.ZodArray,...I(e)});function we(t){if(t instanceof D){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=W.create(we(n))}return new D({...t._def,shape:()=>e})}else return t instanceof V?new V({...t._def,type:we(t.element)}):t instanceof W?W.create(we(t.unwrap())):t instanceof ue?ue.create(we(t.unwrap())):t instanceof Y?Y.create(t.items.map(e=>we(e))):t}class D extends S{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;const e=this._def.shape(),r=C.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==b.object){const d=this._getOrReturnCtx(e);return m(d,{code:p.invalid_type,expected:b.object,received:d.parsedType}),k}const{status:n,ctx:a}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof le&&this._def.unknownKeys==="strip"))for(const d in a.data)s.includes(d)||o.push(d);const l=[];for(const d of s){const f=i[d],w=a.data[d];l.push({key:{status:"valid",value:d},value:f._parse(new Q(a,w,a.path,d)),alwaysSet:d in a.data})}if(this._def.catchall instanceof le){const d=this._def.unknownKeys;if(d==="passthrough")for(const f of o)l.push({key:{status:"valid",value:f},value:{status:"valid",value:a.data[f]}});else if(d==="strict")o.length>0&&(m(a,{code:p.unrecognized_keys,keys:o}),n.dirty());else if(d!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const d=this._def.catchall;for(const f of o){const w=a.data[f];l.push({key:{status:"valid",value:f},value:d._parse(new Q(a,w,a.path,f)),alwaysSet:f in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const d=[];for(const f of l){const w=await f.key,N=await f.value;d.push({key:w,value:N,alwaysSet:f.alwaysSet})}return d}).then(d=>L.mergeObjectSync(n,d)):L.mergeObjectSync(n,l)}get shape(){return this._def.shape()}strict(e){return g.errToObj,new D({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(r,n)=>{var i,s;const a=((s=(i=this._def).errorMap)==null?void 0:s.call(i,r,n).message)??n.defaultError;return r.code==="unrecognized_keys"?{message:g.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new D({...this._def,unknownKeys:"strip"})}passthrough(){return new D({...this._def,unknownKeys:"passthrough"})}extend(e){return new D({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new D({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:x.ZodObject})}setKey(e,r){return this.augment({[e]:r})}catchall(e){return new D({...this._def,catchall:e})}pick(e){const r={};for(const n of C.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new D({...this._def,shape:()=>r})}omit(e){const r={};for(const n of C.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new D({...this._def,shape:()=>r})}deepPartial(){return we(this)}partial(e){const r={};for(const n of C.objectKeys(this.shape)){const a=this.shape[n];e&&!e[n]?r[n]=a:r[n]=a.optional()}return new D({...this._def,shape:()=>r})}required(e){const r={};for(const n of C.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof W;)i=i._def.innerType;r[n]=i}return new D({...this._def,shape:()=>r})}keyof(){return ar(C.objectKeys(this.shape))}}D.create=(t,e)=>new D({shape:()=>t,unknownKeys:"strip",catchall:le.create(),typeName:x.ZodObject,...I(e)}),D.strictCreate=(t,e)=>new D({shape:()=>t,unknownKeys:"strict",catchall:le.create(),typeName:x.ZodObject,...I(e)}),D.lazycreate=(t,e)=>new D({shape:t,unknownKeys:"strip",catchall:le.create(),typeName:x.ZodObject,...I(e)});class De extends S{_parse(e){const{ctx:r}=this._processInputParams(e),n=this._def.options;function a(i){for(const o of i)if(o.result.status==="valid")return o.result;for(const o of i)if(o.result.status==="dirty")return r.common.issues.push(...o.ctx.common.issues),o.result;const s=i.map(o=>new U(o.ctx.common.issues));return m(r,{code:p.invalid_union,unionErrors:s}),k}if(r.common.async)return Promise.all(n.map(async i=>{const s={...r,common:{...r.common,issues:[]},parent:null};return{result:await i._parseAsync({data:r.data,path:r.path,parent:s}),ctx:s}})).then(a);{let i;const s=[];for(const l of n){const d={...r,common:{...r.common,issues:[]},parent:null},f=l._parseSync({data:r.data,path:r.path,parent:d});if(f.status==="valid")return f;f.status==="dirty"&&!i&&(i={result:f,ctx:d}),d.common.issues.length&&s.push(d.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const o=s.map(l=>new U(l));return m(r,{code:p.invalid_union,unionErrors:o}),k}}get options(){return this._def.options}}De.create=(t,e)=>new De({options:t,typeName:x.ZodUnion,...I(e)});const ne=t=>t instanceof Le?ne(t.schema):t instanceof ae?ne(t.innerType()):t instanceof $e?[t.value]:t instanceof de?t.options:t instanceof St?C.objectValues(t.enum):t instanceof je?ne(t._def.innerType):t instanceof et?[void 0]:t instanceof Oe?[null]:t instanceof W?[void 0,...ne(t.unwrap())]:t instanceof ue?[null,...ne(t.unwrap())]:t instanceof At||t instanceof Ue?ne(t.unwrap()):t instanceof Fe?ne(t._def.innerType):[];class tt extends S{_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==b.object)return m(r,{code:p.invalid_type,expected:b.object,received:r.parsedType}),k;const n=this.discriminator,a=r.data[n],i=this.optionsMap.get(a);return i?r.common.async?i._parseAsync({data:r.data,path:r.path,parent:r}):i._parseSync({data:r.data,path:r.path,parent:r}):(m(r,{code:p.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),k)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,r,n){const a=new Map;for(const i of r){const s=ne(i.shape[e]);if(!s.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(const o of s){if(a.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);a.set(o,i)}}return new tt({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:a,...I(n)})}}function It(t,e){const r=ce(t),n=ce(e);if(t===e)return{valid:!0,data:t};if(r===b.object&&n===b.object){const a=C.objectKeys(e),i=C.objectKeys(t).filter(o=>a.indexOf(o)!==-1),s={...t,...e};for(const o of i){const l=It(t[o],e[o]);if(!l.valid)return{valid:!1};s[o]=l.data}return{valid:!0,data:s}}else if(r===b.array&&n===b.array){if(t.length!==e.length)return{valid:!1};const a=[];for(let i=0;i<t.length;i++){const s=t[i],o=e[i],l=It(s,o);if(!l.valid)return{valid:!1};a.push(l.data)}return{valid:!0,data:a}}else return r===b.date&&n===b.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class qe extends S{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),a=(i,s)=>{if(Xt(i)||Xt(s))return k;const o=It(i.value,s.value);return o.valid?((Yt(i)||Yt(s))&&r.dirty(),{status:r.value,value:o.data}):(m(n,{code:p.invalid_intersection_types}),k)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([i,s])=>a(i,s)):a(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}}qe.create=(t,e,r)=>new qe({left:t,right:e,typeName:x.ZodIntersection,...I(r)});class Y extends S{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==b.array)return m(n,{code:p.invalid_type,expected:b.array,received:n.parsedType}),k;if(n.data.length<this._def.items.length)return m(n,{code:p.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),k;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:p.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),r.dirty());const i=[...n.data].map((s,o)=>{const l=this._def.items[o]||this._def.rest;return l?l._parse(new Q(n,s,n.path,o)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>L.mergeArray(r,s)):L.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new Y({...this._def,rest:e})}}Y.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Y({items:t,typeName:x.ZodTuple,rest:null,...I(e)})};class Me extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==b.object)return m(n,{code:p.invalid_type,expected:b.object,received:n.parsedType}),k;const a=[],i=this._def.keyType,s=this._def.valueType;for(const o in n.data)a.push({key:i._parse(new Q(n,o,n.path,o)),value:s._parse(new Q(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?L.mergeObjectAsync(r,a):L.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof S?new Me({keyType:e,valueType:r,typeName:x.ZodRecord,...I(n)}):new Me({keyType:X.create(),valueType:e,typeName:x.ZodRecord,...I(r)})}}class Tt extends S{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==b.map)return m(n,{code:p.invalid_type,expected:b.map,received:n.parsedType}),k;const a=this._def.keyType,i=this._def.valueType,s=[...n.data.entries()].map(([o,l],d)=>({key:a._parse(new Q(n,o,n.path,[d,"key"])),value:i._parse(new Q(n,l,n.path,[d,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const l of s){const d=await l.key,f=await l.value;if(d.status==="aborted"||f.status==="aborted")return k;(d.status==="dirty"||f.status==="dirty")&&r.dirty(),o.set(d.value,f.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const l of s){const d=l.key,f=l.value;if(d.status==="aborted"||f.status==="aborted")return k;(d.status==="dirty"||f.status==="dirty")&&r.dirty(),o.set(d.value,f.value)}return{status:r.value,value:o}}}}Tt.create=(t,e,r)=>new Tt({valueType:e,keyType:t,typeName:x.ZodMap,...I(r)});class ke extends S{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.parsedType!==b.set)return m(n,{code:p.invalid_type,expected:b.set,received:n.parsedType}),k;const a=this._def;a.minSize!==null&&n.data.size<a.minSize.value&&(m(n,{code:p.too_small,minimum:a.minSize.value,type:"set",inclusive:!0,exact:!1,message:a.minSize.message}),r.dirty()),a.maxSize!==null&&n.data.size>a.maxSize.value&&(m(n,{code:p.too_big,maximum:a.maxSize.value,type:"set",inclusive:!0,exact:!1,message:a.maxSize.message}),r.dirty());const i=this._def.valueType;function s(l){const d=new Set;for(const f of l){if(f.status==="aborted")return k;f.status==="dirty"&&r.dirty(),d.add(f.value)}return{status:r.value,value:d}}const o=[...n.data.values()].map((l,d)=>i._parse(new Q(n,l,n.path,d)));return n.common.async?Promise.all(o).then(l=>s(l)):s(o)}min(e,r){return new ke({...this._def,minSize:{value:e,message:g.toString(r)}})}max(e,r){return new ke({...this._def,maxSize:{value:e,message:g.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}ke.create=(t,e)=>new ke({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...I(e)});class Pe extends S{constructor(){super(...arguments),this.validate=this.implement}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==b.function)return m(r,{code:p.invalid_type,expected:b.function,received:r.parsedType}),k;function n(o,l){return _t({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,vt(),Ce].filter(d=>!!d),issueData:{code:p.invalid_arguments,argumentsError:l}})}function a(o,l){return _t({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,vt(),Ce].filter(d=>!!d),issueData:{code:p.invalid_return_type,returnTypeError:l}})}const i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof xe){const o=this;return j(async function(...l){const d=new U([]),f=await o._def.args.parseAsync(l,i).catch(F=>{throw d.addIssue(n(l,F)),d}),w=await Reflect.apply(s,this,f);return await o._def.returns._def.type.parseAsync(w,i).catch(F=>{throw d.addIssue(a(w,F)),d})})}else{const o=this;return j(function(...l){const d=o._def.args.safeParse(l,i);if(!d.success)throw new U([n(l,d.error)]);const f=Reflect.apply(s,this,d.data),w=o._def.returns.safeParse(f,i);if(!w.success)throw new U([a(f,w.error)]);return w.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new Pe({...this._def,args:Y.create(e).rest(me.create())})}returns(e){return new Pe({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new Pe({args:e||Y.create([]).rest(me.create()),returns:r||me.create(),typeName:x.ZodFunction,...I(n)})}}class Le extends S{get schema(){return this._def.getter()}_parse(e){const{ctx:r}=this._processInputParams(e);return this._def.getter()._parse({data:r.data,path:r.path,parent:r})}}Le.create=(t,e)=>new Le({getter:t,typeName:x.ZodLazy,...I(e)});class $e extends S{_parse(e){if(e.data!==this._def.value){const r=this._getOrReturnCtx(e);return m(r,{received:r.data,code:p.invalid_literal,expected:this._def.value}),k}return{status:"valid",value:e.data}}get value(){return this._def.value}}$e.create=(t,e)=>new $e({value:t,typeName:x.ZodLiteral,...I(e)});function ar(t,e){return new de({values:t,typeName:x.ZodEnum,...I(e)})}class de extends S{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{expected:C.joinValues(n),received:r.parsedType,code:p.invalid_type}),k}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){const r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{received:r.data,code:p.invalid_enum_value,options:n}),k}return j(e.data)}get options(){return this._def.values}get enum(){const e={};for(const r of this._def.values)e[r]=r;return e}get Values(){const e={};for(const r of this._def.values)e[r]=r;return e}get Enum(){const e={};for(const r of this._def.values)e[r]=r;return e}extract(e,r=this._def){return de.create(e,{...this._def,...r})}exclude(e,r=this._def){return de.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}de.create=ar;class St extends S{_parse(e){const r=C.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==b.string&&n.parsedType!==b.number){const a=C.objectValues(r);return m(n,{expected:C.joinValues(a),received:n.parsedType,code:p.invalid_type}),k}if(this._cache||(this._cache=new Set(C.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=C.objectValues(r);return m(n,{received:n.data,code:p.invalid_enum_value,options:a}),k}return j(e.data)}get enum(){return this._def.values}}St.create=(t,e)=>new St({values:t,typeName:x.ZodNativeEnum,...I(e)});class xe extends S{unwrap(){return this._def.type}_parse(e){const{ctx:r}=this._processInputParams(e);if(r.parsedType!==b.promise&&r.common.async===!1)return m(r,{code:p.invalid_type,expected:b.promise,received:r.parsedType}),k;const n=r.parsedType===b.promise?r.data:Promise.resolve(r.data);return j(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}xe.create=(t,e)=>new xe({type:t,typeName:x.ZodPromise,...I(e)});class ae extends S{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===x.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){const{status:r,ctx:n}=this._processInputParams(e),a=this._def.effect||null,i={addIssue:s=>{m(n,s),s.fatal?r.abort():r.dirty()},get path(){return n.path}};if(i.addIssue=i.addIssue.bind(i),a.type==="preprocess"){const s=a.transform(n.data,i);if(n.common.async)return Promise.resolve(s).then(async o=>{if(r.value==="aborted")return k;const l=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return l.status==="aborted"?k:l.status==="dirty"||r.value==="dirty"?Ne(l.value):l});{if(r.value==="aborted")return k;const o=this._def.schema._parseSync({data:s,path:n.path,parent:n});return o.status==="aborted"?k:o.status==="dirty"||r.value==="dirty"?Ne(o.value):o}}if(a.type==="refinement"){const s=o=>{const l=a.refinement(o,i);if(n.common.async)return Promise.resolve(l);if(l instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){const o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?k:(o.status==="dirty"&&r.dirty(),s(o.value),{status:r.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?k:(o.status==="dirty"&&r.dirty(),s(o.value).then(()=>({status:r.value,value:o.value}))))}if(a.type==="transform")if(n.common.async===!1){const s=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!_e(s))return k;const o=a.transform(s.value,i);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:r.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(s=>_e(s)?Promise.resolve(a.transform(s.value,i)).then(o=>({status:r.value,value:o})):k);C.assertNever(a)}}ae.create=(t,e,r)=>new ae({schema:t,typeName:x.ZodEffects,effect:e,...I(r)}),ae.createWithPreprocess=(t,e,r)=>new ae({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...I(r)});class W extends S{_parse(e){return this._getType(e)===b.undefined?j(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}W.create=(t,e)=>new W({innerType:t,typeName:x.ZodOptional,...I(e)});class ue extends S{_parse(e){return this._getType(e)===b.null?j(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ue.create=(t,e)=>new ue({innerType:t,typeName:x.ZodNullable,...I(e)});class je extends S{_parse(e){const{ctx:r}=this._processInputParams(e);let n=r.data;return r.parsedType===b.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:r.path,parent:r})}removeDefault(){return this._def.innerType}}je.create=(t,e)=>new je({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...I(e)});class Fe extends S{_parse(e){const{ctx:r}=this._processInputParams(e),n={...r,common:{...r.common,issues:[]}},a=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return Xe(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new U(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new U(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}Fe.create=(t,e)=>new Fe({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...I(e)});class Et extends S{_parse(e){if(this._getType(e)!==b.nan){const n=this._getOrReturnCtx(e);return m(n,{code:p.invalid_type,expected:b.nan,received:n.parsedType}),k}return{status:"valid",value:e.data}}}Et.create=t=>new Et({typeName:x.ZodNaN,...I(t)});class At extends S{_parse(e){const{ctx:r}=this._processInputParams(e),n=r.data;return this._def.type._parse({data:n,path:r.path,parent:r})}unwrap(){return this._def.type}}class rt extends S{_parse(e){const{status:r,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{const i=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return i.status==="aborted"?k:i.status==="dirty"?(r.dirty(),Ne(i.value)):this._def.out._parseAsync({data:i.value,path:n.path,parent:n})})();{const a=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?k:a.status==="dirty"?(r.dirty(),{status:"dirty",value:a.value}):this._def.out._parseSync({data:a.value,path:n.path,parent:n})}}static create(e,r){return new rt({in:e,out:r,typeName:x.ZodPipeline})}}class Ue extends S{_parse(e){const r=this._def.innerType._parse(e),n=a=>(_e(a)&&(a.value=Object.freeze(a.value)),a);return Xe(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Ue.create=(t,e)=>new Ue({innerType:t,typeName:x.ZodReadonly,...I(e)});var x;(function(t){t.ZodString="ZodString",t.ZodNumber="ZodNumber",t.ZodNaN="ZodNaN",t.ZodBigInt="ZodBigInt",t.ZodBoolean="ZodBoolean",t.ZodDate="ZodDate",t.ZodSymbol="ZodSymbol",t.ZodUndefined="ZodUndefined",t.ZodNull="ZodNull",t.ZodAny="ZodAny",t.ZodUnknown="ZodUnknown",t.ZodNever="ZodNever",t.ZodVoid="ZodVoid",t.ZodArray="ZodArray",t.ZodObject="ZodObject",t.ZodUnion="ZodUnion",t.ZodDiscriminatedUnion="ZodDiscriminatedUnion",t.ZodIntersection="ZodIntersection",t.ZodTuple="ZodTuple",t.ZodRecord="ZodRecord",t.ZodMap="ZodMap",t.ZodSet="ZodSet",t.ZodFunction="ZodFunction",t.ZodLazy="ZodLazy",t.ZodLiteral="ZodLiteral",t.ZodEnum="ZodEnum",t.ZodEffects="ZodEffects",t.ZodNativeEnum="ZodNativeEnum",t.ZodOptional="ZodOptional",t.ZodNullable="ZodNullable",t.ZodDefault="ZodDefault",t.ZodCatch="ZodCatch",t.ZodPromise="ZodPromise",t.ZodBranded="ZodBranded",t.ZodPipeline="ZodPipeline",t.ZodReadonly="ZodReadonly"})(x||(x={}));const c=X.create,h=pe.create,ee=he.create,_=Ye.create,ir=Oe.create,v=me.create;le.create;const E=V.create,u=D.create,T=De.create,Pn=tt.create;qe.create;const Ln=Y.create,y=Me.create,$n=Le.create,Ze=$e.create,Be=de.create;xe.create,W.create,ue.create;const ie=ae.createWithPreprocess;function M(t,e=0,r=2){if(e>r)return"...";if(t instanceof D){const n=t.shape,a=Object.keys(n).filter(s=>!s.startsWith("__"));return a.length===0?"{ }":e>=r-1?"{ ... }":`{ ${a.map(s=>{const o=n[s],l=o instanceof W,d=M(l?o.unwrap():o,e+1,r);return`${s}${l?"?":""}: ${d}`}).join(", ")} }`}if(t instanceof De)return t.options.map(n=>M(n,e,r)).join(" or ");if(t instanceof X)return"string";if(t instanceof pe)return"number";if(t instanceof Ye)return"boolean";if(t instanceof he)return"bigint";if(t instanceof Oe)return"null";if(t instanceof V){const n=M(t.element,e+1,r);return n==="unknown"||n==="any"?"array":`${n}[]`}if(t instanceof Y)return`[${t.items.map(n=>M(n,e+1,r)).join(", ")}]`;if(t instanceof Me){const n=M(t._def.valueType,e+1,r);return n==="unknown"||n==="any"?"{ [key: string]: unknown }":`{ [key: string]: ${n} }`}return t instanceof W?`${M(t.unwrap(),e,r)}?`:t instanceof $e?JSON.stringify(t.value):t instanceof de?t.options.map(n=>`"${n}"`).join(" | "):t instanceof kt?"any":t instanceof me?"unknown":t instanceof xt?"void":t instanceof et?"undefined":t instanceof ae?M(t.innerType(),e,r):t instanceof je?M(t.removeDefault(),e,r):t instanceof ue?`${M(t.unwrap(),e,r)} | null`:t instanceof Le?"lazy":t instanceof xe?`Promise<${M(t.unwrap(),e+1,r)}>`:t instanceof Pe?"function":t instanceof Re?"Date":t instanceof Tt?"Map":t instanceof ke?"Set":t instanceof qe?`${M(t._def.left,e,r)} & ${M(t._def.right,e,r)}`:t instanceof tt?t.options.map(n=>M(n,e,r)).join(" or "):t instanceof At?M(t.unwrap(),e,r):t instanceof Et?"NaN":t instanceof Fe?M(t.removeCatch(),e,r):t instanceof rt?M(t._def.in,e,r):t instanceof Ue?`readonly ${M(t.unwrap(),e,r)}`:"unknown"}function jn(t){return t===null?"null":t===void 0?"undefined":Array.isArray(t)?"array":typeof t}function Fn(t,e,r,n){const a=r.filter(o=>o.path.length===0),i=r.filter(o=>o.path.length>0);if(a.length>0&&i.length===0){const o=a.some(d=>d.code==="custom"),l=a.some(d=>d.code!=="invalid_type"&&d.code!=="invalid_literal"&&d.code!=="invalid_union");if(!o&&!l){const d=M(e),f=jn(n);return`Invalid parameters for ${t}: expected ${d}${d==="{ }"?" or no args":""}, received ${f}`}}const s=r.map(o=>`at '${o.path.length>0?o.path.join("."):"root"}': ${o.message}`);return`Invalid parameters for ${t}: ${s.join("; ")}`}async function Un(t,e,r,n,a){const i=t.safeParse(Qe(n));if(!i.success)return{ok:!1,error:{message:Fn(a,t,i.error.issues,n),code:"E_INVALID_PARAMS",category:"validation"}};try{const s=await r(i.data),o=e.safeParse(s);if(!o.success){const l=o.error.issues.map(d=>{const f=d.path.join(".");return`invalid return value${f?` at '${f}'`:""} (${d.message})`});return{ok:!1,error:{message:`Invalid return value for ${a}: ${l.join("; ")}`,code:"E_INVALID_RETURN",category:"validation"}}}return{ok:!0,value:o.data}}catch(s){const o=Dt(s),l=o.code==="E_EXTENSION"&&(typeof s!="object"||s===null||!("code"in s));return{ok:!1,error:{...o,code:l?"E_HANDLER":o.code,message:`${a}: ${o.message}`}}}}const sr=new Map,nt=new Map;function Zn(t){sr.set(t.registryAction,t)}function at(t){return sr.get(t)}function Bn(t){for(const e of t)Zn(e);try{chrome.runtime.sendMessage({type:"contentScriptReady"})}catch{}}function Vn(t){const e=nt.get(t);return e?(e.abort(),nt.delete(t),!0):!1}async function Wn(t,e,r,n,a){const i=at(t);if(!i)return{ok:!1,error:{message:`No schema registered for content-script action: ${t}`,code:"E_INTERNAL"}};const s=new AbortController;a&&nt.set(a,s);try{return await Un(i.params,i.returns,async o=>r(o,s.signal),Qe(n),t)}finally{a&&nt.delete(a)}}function Hn(t,e){if(at(t))return t;const r=`page_${e}`;return at(r)?r:t}function Kn(t,e){const r=at(t);return(r==null?void 0:r.handlerKey)??e}function or(t,e,r,n,a){const i=Hn(t,e),s=Kn(i,e),o=fn[s];return o?(Wn(i,s,o,r,a).then(d=>{be.debug("dispatch_response",{registryAction:t,handlerAction:s,ok:d.ok}),n(d)}).catch(d=>{const f=Dt(d,{});be.debug("dispatch_error",{registryAction:t,handlerAction:s,error:f.message}),n({ok:!1,error:f})}),!0):(be.debug("no_handler",{action:s,registryAction:t}),n({ok:!1,error:`Unknown content script action: ${s}`}),!1)}function zn(){chrome.runtime.onMessage.addListener((t,e,r)=>{if(e.id!==chrome.runtime.id)return be.warn("unauthorized_sender",{senderId:e.id,expected:chrome.runtime.id}),r({ok:!1,error:"Unauthorized sender"}),!1;const n=ye(t),a=String(n.type??""),i=String(n.action??"");if(be.debug("received",{messageType:a,action:i,hasParams:!!n.params}),a==="registryCallCancel"){const s=String(n.id??"");return Vn(s),r({ok:!0}),!1}if(a==="registryCall"){const s=kr(i),o=typeof n.id=="string"?n.id:void 0;return or(i,s,n.params,r,o)}return!i&&a==="contract-ping"?(r({ok:!0}),!1):i?i==="ping"?or("ping","ping",n.params,r):(r({ok:!1,error:"Use registryCall for content-script actions"}),!1):(r({ok:!1,error:"Missing action"}),!1)})}const Z=()=>T([ee(),h().finite()]).transform(t=>BigInt(t));u({key:c().describe("Storage key to retrieve")}),u({key:c().describe("Storage key to set"),value:c().describe("Value to store")}),u({key:c().describe("Storage key to delete")}),u({});const Gn=u({items:y(c()).describe("Record of key-value string pairs to store")});ie(t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!("items"in t)?{items:t}:t,Gn);const Jn=u({keys:E(c()).describe("Array of storage keys to retrieve"),defaults:y(c()).optional().describe("Default string values for missing keys")});ie(t=>Array.isArray(t)?{keys:t}:t,Jn),u({});const Qn=u({keys:E(c()).describe("Array of storage keys to delete")});ie(t=>Array.isArray(t)?{keys:t}:t,Qn),u({}),u({}),T([Ln([T([u({text:c()}),c()])]),u({text:c().optional(),value:c().optional()})]);const Xn=u({url:c().describe("URL to fetch"),method:c().default("GET").describe("HTTP method (GET, POST, PUT, DELETE, etc.)"),headers:y(c()).default({}).describe("Request headers as key-value pairs"),body:c().nullable().default(null).describe("Request body string"),timeout:Z().default(30000n).describe("Timeout in milliseconds"),store:_().optional().describe("When true, store binary responses as a handle instead of returning body bytes"),options:u({}).passthrough().optional().describe("Fetch options")}).passthrough();u({duration:Z().describe("Duration to sleep in milliseconds")});const H=()=>c().regex(/^(?:f\d+_)?e\d+$/),Yn='use { refId: "e2" } or { label: "..." } object form, not positional arguments',Ct=(t,e)=>{if(t.__invalidPositional!==void 0){e.addIssue({code:p.custom,message:Yn});return}!t.refId&&!t.label&&e.addIssue({code:p.custom,message:"Either refId or label is required"})},cr=(t,e)=>{t.x!==void 0||t.y!==void 0||Ct(t,e)},q=t=>ie(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,u({__invalidPositional:T([c(),h()]).optional().describe("Internal flag for positional argument rejection"),refId:H().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(Ct)),Ie={tabId:T([h(),ee()]).optional().describe("Target tab ID")},K=t=>ie(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,u({__invalidPositional:T([c(),h()]).optional().describe("Internal flag for positional argument rejection"),...Ie,refId:H().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(Ct));u({}),u({}),u({url:c().describe("URL to navigate to"),timeout:Z().optional().describe("Navigation timeout in milliseconds"),waitUntil:Be(["load","networkidle"]).optional().describe("When to consider navigation complete: 'load' (tab status complete) or 'networkidle' (no in-flight requests for 500ms)")});const ea=u({}),ta=u({});u({}),u({duration:Z().default(1000n).describe("Duration to wait in milliseconds")});const ra=q(),na=(t,e)=>{[t.url,t.path,t.handle].filter(n=>typeof n=="string"&&n.length>0).length!==1&&e.addIssue({code:p.custom,message:"Each file entry requires exactly one of url, path, or handle"})},lr=u({name:c().optional().describe("File name including extension"),mimeType:c().optional().describe("MIME type (defaults to application/octet-stream)"),url:c().url().optional().describe("HTTP(S) URL to fetch in the target tab"),path:c().min(1).optional().describe("Virtual filesystem path (resolved in worker)"),handle:c().min(1).optional().describe("Binary handle from page.fetch({ store: true })")}).superRefine(na),dr=Pn("kind",[u({kind:Ze("bytes"),name:c().min(1),data:c().min(1),mimeType:c().optional()}),u({kind:Ze("url"),url:c().url(),name:c().min(1),mimeType:c().optional()})]),aa=q({value:c().describe("Value to fill into the element")}),ia=q({files:E(lr).min(1).describe("Files to attach to the input")}),sa=q({files:E(dr).min(1).describe("Resolved files for content-script application")}),oa=q({text:c().describe("Text to type into the element")}),ca=q({text:c().describe("Text to append into the element")}),la=u({refId:H().optional().describe("Element reference ID to dispatch the key on (e.g. e2). Omit to dispatch on document."),label:c().optional().describe("Human-readable element label. Omit to dispatch on document."),key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),da=q({value:T([c().describe("Value to select in the dropdown"),E(c()).describe("Values to select in a multiple dropdown (empty array clears selection)")]).describe("Value (string) or values (array) to select in the dropdown")}),ua=q({value:c().describe("Visible text of the option to select (matched case-insensitively)")}),fa=q({checked:_().optional().describe("Desired checked state (true to check, false to uncheck)")}),pa=u({name:c().min(1).describe("The `name` attribute of the radio group to pick from"),value:c().describe("The `value` of the radio option to check")}),ha=q(),ma=u({}),ba=q(),ga=u({direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:h().default(300).describe("Pixels to scroll")}),ya=ie(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,u({__invalidPositional:T([c(),h()]).optional().describe("Internal flag for positional argument rejection"),refId:H().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),x:h().optional().describe("X coordinate to scroll to"),y:h().optional().describe("Y coordinate to scroll to")}).superRefine(cr)),va=q(),_a=u({selector:c().describe("CSS selector to find elements")}),wa=u({selector:c().describe("CSS selector for the root element(s) to introspect"),depth:h().int().min(0).max(10).default(2).describe("How many descendant levels to include (0 = root only)"),includeHidden:_().default(!0).describe("Include elements hidden by CSS/aria (default true — this tool's purpose is to see what the curated snapshot filters out)")}),ka=u({selector:c().describe("CSS selector to wait for"),timeout:Z().default(30000n).describe("Timeout in milliseconds")}),xa=u({fields:E(c()).describe("Array of field names to extract")}),Ia=ie(t=>Array.isArray(t)?{fields:t}:t,xa);T([h(),E(u({}).passthrough()),u({}).passthrough()]),u({}),u({active:_().optional().describe("Whether the tabs are active"),currentWindow:_().optional().describe("Whether the tabs are in the current window"),url:c().optional().describe("URL pattern to match tabs against")}).passthrough(),ie(t=>typeof t=="string"?{url:t}:t,u({url:c().optional().describe("URL to open in the new tab"),active:_().optional().describe("Whether to focus the new tab")})),T([h(),E(u({id:h().optional(),tabId:h().optional(),tab_id:h().optional()}).passthrough()),u({id:h().optional(),tabId:h().optional(),tab_id:h().optional()}).passthrough()]);const Ta=K(),Sa=K({value:c().describe("Value to fill into the element")}),Ea=K({files:E(lr).min(1).describe("Files to attach to the input")}),Aa=K({files:E(dr).min(1).describe("Resolved files for content-script application")}),Ca=ie(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,u({__invalidPositional:T([c(),h()]).optional().describe("Internal flag for positional argument rejection"),...Ie,refId:H().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),x:h().optional().describe("X coordinate to scroll to"),y:h().optional().describe("Y coordinate to scroll to")}).superRefine(cr)),Na=K({text:c().describe("Text to type into the element")}),Ra=u({...Ie,key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),Oa=K({value:c().describe("Value to select in the dropdown")}),Da=K({value:c().describe("Visible text of the option to select (matched case-insensitively)")}),qa=K({checked:_().optional().describe("Desired checked state (true to check, false to uncheck)")}),Ma=K(),Pa=K(),La=u({...Ie,name:c().min(1).describe("The `name` attribute of the radio group to pick from"),value:c().describe("The `value` of the radio option to check")}),$a=u({...Ie}),ja=u({...Ie,direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:h().default(300).describe("Pixels to scroll")}),Fa=K(),Ua=u({tabId:T([h(),ee()]).optional().describe("Target tab ID"),script:c().optional().describe("Script to evaluate"),code:c().optional().describe("Alternative script code"),js:c().optional().describe("Alternative JS code")}).passthrough(),Za=u({tabId:T([h(),ee()]).optional().describe("Target tab ID")}).passthrough(),Ba=u({tabId:T([h(),ee()]).optional().describe("Target tab ID")}).passthrough();u({tabId:T([h(),ee()]).optional().describe("Target tab ID"),timeout:h().optional().describe("Timeout in milliseconds")}).passthrough();const Va=u({tabId:T([h(),ee()]).optional().describe("Target tab ID"),url:c().optional().describe("URL to fetch"),options:u({}).passthrough().optional().describe("Fetch options")}).passthrough(),Wa=u({tabId:T([h(),ee()]).optional().describe("Target tab ID"),max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Ha=u({tabId:T([h(),ee()]).optional().describe("Target tab ID"),max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Ka=u({tabId:T([h(),ee()]).optional().describe("Target tab ID"),max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough();q(),q(),q({value:c().optional().describe("Value to fill into the element")}),q({text:c().optional().describe("Text to type into the element")}),u({key:c().optional().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),q({value:c().optional().describe("Value to select in the dropdown")}),q({checked:_().optional().describe("Desired checked state (true to check, false to uncheck)")}),q(),u({}),u({direction:c().optional().describe("Scroll direction: up, down, left, or right"),amount:h().optional().describe("Pixels to scroll")}),q(),q({text:c().optional().describe("Text to append into the element")}),u({}),u({}),u({duration:Z().default(1000n).describe("Duration to wait in milliseconds")}),u({interactive_only:_().default(!1).describe("Only include interactive elements"),max_nodes:Z().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:_().default(!1).describe("Only include interactive elements"),max_nodes:Z().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:_().default(!1).describe("Only include interactive elements"),max_nodes:Z().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:_().default(!1).describe("Only include interactive elements"),max_nodes:Z().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({snapshot:u({}).passthrough().describe("Raw DOM snapshot data to format"),format:c().optional().describe("Output format (e.g. markdown, html)")});const za=u({max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Ga=u({max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Ja=u({max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Qa=u({role:T([c(),E(c())]).optional().describe("Filter by ARIA role"),tag:T([c(),E(c())]).optional().describe("Filter by HTML tag"),text:c().optional().describe("Filter by text content (case-insensitive substring)"),name:c().optional().describe("Filter by accessible name (case-insensitive substring)"),interactiveOnly:_().optional().describe("Only include interactive elements"),href:c().optional().describe("Filter by href pattern (case-insensitive substring)"),src:c().optional().describe("Filter by src pattern (case-insensitive substring)"),limit:h().positive().optional().describe("Maximum filtered nodes to return")}).passthrough(),ur=u({filter:Qa.optional().describe("Semantic filter criteria"),max_nodes:h().optional().describe("Maximum nodes to collect before filtering")}).passthrough(),Xa=ur.extend({tabId:h().describe("Tab ID")});u({path:c().describe("File or directory path")}),u({from:c().describe("Source path"),to:c().describe("Destination path")}),u({path:c().describe("File path to write to"),data:c().describe("Data to write")}),u({path:c().describe("File path to read from"),offset:Z().describe("Byte offset to start reading"),len:h().describe("Number of bytes to read")}),u({path:c().describe("File path to update"),offset:Z().describe("Byte offset to start writing"),data:c().describe("Data to write")}),u({path:c().describe("File path to hash"),algo:c().default("sha256").describe("Hash algorithm (e.g. sha256, md5)")}),y(v()),y(v()),y(v()),y(v()),T([h(),y(v())]),T([h(),y(v())]),y(v()),y(v()),y(v()),T([c(),y(v())]),y(v()),y(v()),y(v()),y(v()),y(v()),T([c(),h(),y(v())]),y(v()),y(v()),y(v()),T([h(),y(v())]),y(v()),y(v()),y(v()),y(v()),y(v()),E(v()),T([c(),y(v())]),y(v()),T([c(),y(v())]),y(v()),T([c(),y(v())]),y(v()),T([c(),y(v())]),y(v()),y(v()),T([h(),y(v())]),y(v()),y(v()),T([h(),y(v())]),y(v()),T([c(),h(),y(v())]),y(v()),y(v()),y(v()),y(v()),T([h(),y(v())]),T([h(),y(v())]),T([h(),y(v())]),T([h(),y(v())]),T([h(),y(v())]),y(v()),y(v()),y(v()),u({action:c().describe("Host action name"),params:u({}).passthrough().optional().describe("Parameters for the host action")}).passthrough();const Ya=T([c(),h(),_(),ir(),E(v()),y(v())]),A=u({ok:Ze(!0).describe("Whether the action succeeded"),action:c().describe("Action identifier (e.g. 'page_fill')"),refId:H().optional().describe("Element reference ID that was acted upon (e.g. e2)"),tag:c().optional().describe("HTML tag name of the element"),role:c().optional().describe("ARIA role of the element"),name:c().optional().describe("Accessible name of the element"),value:T([c(),E(c())]).optional().describe("Final value of the element after the action (string, or string[] for multi-select)"),checked:_().optional().describe("Checked state after the action"),disabled:_().optional().describe("Whether the element is disabled"),readOnly:_().optional().describe("Whether the element is read-only"),text:c().optional().describe("Text content of the element"),key:c().optional().describe("Key that was pressed (for press actions)"),direction:c().optional().describe("Scroll direction (for scroll actions)"),amount:h().optional().describe("Scroll amount in pixels (for scroll actions)"),fileCount:h().optional().describe("Number of files attached (for setFiles actions)"),fileNames:E(c()).optional().describe("Names of attached files (for setFiles actions)"),observationId:c().optional().describe("Opaque ID of the observation lease authorizing this action (snapshot-scoped)"),dispatched:Ze(!0).optional().describe("True if the action was dispatched to the DOM. Does NOT prove the application accepted it."),verification:Ze("required").optional().describe("Always 'required': a fresh observation is required to verify the effect.")});T([A,ir()]);const fr=u({status:h().describe("HTTP response status code"),ok:_().describe("Whether the response status is 2xx"),headers:y(c()).describe("Response headers as key-value pairs"),body:c().optional().describe("Response body (omitted when bodyEncoding is handle)"),bodyEncoding:Be(["text","base64","handle"]).describe("Encoding of the body field"),handle:c().optional().describe("Binary handle when bodyEncoding is handle"),byteLength:h().describe("Length of the body in bytes"),contentType:c().describe("Response Content-Type header"),finalUrl:c().describe("Final URL after redirects")});u({data:u({}).passthrough().describe("Structured snapshot data"),text:c().describe("Plain text representation of the snapshot")}),u({}),u({tabId:h(),url:c(),title:c(),contentScript:Be(["connected","missing"]),domApis:Be(["ok","blocked"]),mutationsReady:_(),hint:c().optional(),recovery:E(c()).optional()});const ei=Ya,ti=u({refId:H().describe("Element reference ID (e.g. e2)"),role:c().describe("ARIA role of the element"),tag:c().describe("HTML tag name"),name:c().optional().describe("Accessible name of the element"),text:c().optional().describe("Visible text content of the element"),value:c().optional().describe("Element value"),checked:_().optional().describe("Checked state"),disabled:_().optional().describe("Whether the element is disabled"),readOnly:_().optional().describe("Whether the element is read-only"),selected:_().optional().describe("For <option>: selected state"),href:c().optional().describe("Absolute URL for link elements"),src:c().optional().describe("Absolute URL for image elements"),alt:c().optional().describe("Alternative text for image elements"),title:c().optional().describe("Title attribute"),parentRefId:H().optional().describe("Reference ID of the parent container element"),postId:c().optional().describe("Stable post identifier from data-post-id attribute"),permalink:c().optional().describe("Stable permalink URL from anchor element"),imageUrls:E(c()).optional().describe("Image URLs contained within this element")}),it=u({text:c().describe("Plain text representation of the page"),nodes:E(ti).describe("Array of interactive nodes"),url:c().describe("Current page URL"),title:c().describe("Current page title"),viewport:u({width:h().describe("Viewport width in pixels"),height:h().describe("Viewport height in pixels")}).describe("Viewport dimensions"),observationId:c().optional().describe("Opaque ID of the observation lease granted by this snapshot. Pass to subsequent actions to prove they act on fresh observations.")}),pr=u({refId:H().optional(),tag:c(),role:c().optional(),name:c().optional(),text:c().optional(),attributes:y(c()).optional().describe("All HTML attributes (raw)"),hidden:_().optional(),hiddenReason:Be(["display-none","visibility-hidden","aria-hidden","opacity-zero","hidden-attr","inert"]).optional(),value:c().optional(),checked:_().optional(),disabled:_().optional(),readOnly:_().optional(),selected:_().optional().describe("For <option>: selected state"),href:c().optional(),src:c().optional(),alt:c().optional(),accept:c().optional().describe("For input[type=file]: accepted MIME/extensions"),filesCount:h().optional().describe("For input[type=file]: selected file count"),children:E($n(()=>pr)).optional().describe("Nested descendants up to `depth`")}),ri=u({nodes:E(pr),url:c(),title:c()}),hr=u({id:h().optional().describe("Tab ID"),tabId:h().optional().describe("Tab ID (added by runner)"),index:h().optional().describe("Tab index in the window"),windowId:h().optional().describe("Window ID"),url:c().optional().describe("Tab URL"),title:c().optional().describe("Tab title"),status:c().optional().describe("Tab status (loading or complete)"),active:_().optional().describe("Whether the tab is active"),pinned:_().optional().describe("Whether the tab is pinned"),highlighted:_().optional().describe("Whether the tab is highlighted"),incognito:_().optional().describe("Whether the tab is incognito"),favIconUrl:c().optional().describe("Favicon URL"),audible:_().optional().describe("Whether the tab is audible"),groupId:h().optional().describe("Group ID"),openerTabId:h().optional().describe("Opener tab ID"),discarded:_().optional().describe("Whether the tab is discarded"),autoDiscardable:_().optional().describe("Whether the tab is auto-discardable"),width:h().optional().describe("Tab width"),height:h().optional().describe("Tab height"),sessionId:c().optional().describe("Session ID")}).passthrough(),ni=E(hr),mr=u({id:h().optional().describe("Window ID"),focused:_().optional().describe("Whether the window is focused"),top:h().optional().describe("Window top position"),left:h().optional().describe("Window left position"),width:h().optional().describe("Window width"),height:h().optional().describe("Window height"),tabs:ni.optional().describe("Array of tabs in the window"),incognito:_().optional().describe("Whether the window is incognito"),type:c().optional().describe("Window type"),state:c().optional().describe("Window state"),alwaysOnTop:_().optional().describe("Whether the window is always on top"),sessionId:c().optional().describe("Session ID")}).passthrough();E(mr);const ai=u({name:c().describe("Cookie name"),value:c().describe("Cookie value"),domain:c().optional().describe("Cookie domain"),hostOnly:_().optional().describe("Whether the cookie is host-only"),path:c().optional().describe("Cookie path"),secure:_().optional().describe("Whether the cookie is secure"),httpOnly:_().optional().describe("Whether the cookie is HTTP-only"),sameSite:c().optional().describe("SameSite policy"),session:_().optional().describe("Whether the cookie is a session cookie"),expirationDate:h().optional().describe("Expiration date as Unix timestamp"),storeId:c().optional().describe("Store ID")}).nullable();E(ai.nullable().unwrap());const ii=u({id:c().describe("Bookmark ID"),parentId:c().optional().describe("Parent folder ID"),index:h().optional().describe("Bookmark index"),url:c().optional().describe("Bookmark URL"),title:c().describe("Bookmark title"),dateAdded:h().optional().describe("Date added"),dateGroupModified:h().optional().describe("Date group modified"),children:E(u({id:c()}).passthrough()).optional().describe("Child bookmarks")}).passthrough();E(ii);const si=u({id:c().describe("History item ID"),url:c().optional().describe("URL"),title:c().optional().describe("Title"),lastVisitTime:h().optional().describe("Last visit time"),visitCount:h().optional().describe("Visit count"),typedCount:h().optional().describe("Typed count")}).passthrough();E(si);const oi=u({frameId:h().describe("Frame ID"),result:v().optional().describe("Script result")});E(oi),c(),_(),T([c(),h()]),_();const ci=u({id:h().optional().describe("Group ID"),collapsed:_().optional().describe("Whether the group is collapsed"),color:c().optional().describe("Group color"),title:c().optional().describe("Group title"),windowId:h().optional().describe("Window ID")}).passthrough();E(ci);const li=u({lastModified:h().optional().describe("Last modified time"),tab:hr.optional().describe("Tab info"),window:mr.optional().describe("Window info")}).passthrough(),di=E(li),ui=u({deviceName:c().optional().describe("Device name"),sessions:di.optional().describe("Sessions")}).passthrough();E(ui);const fi=u({id:h().optional().describe("Download ID"),url:c().optional().describe("Download URL"),filename:c().optional().describe("Filename"),startTime:c().optional().describe("Start time"),endTime:c().optional().describe("End time"),state:c().optional().describe("Download state"),danger:c().optional().describe("Danger type"),paused:_().optional().describe("Whether the download is paused"),error:c().optional().describe("Error message"),bytesReceived:h().optional().describe("Bytes received"),totalBytes:h().optional().describe("Total bytes"),fileSize:h().optional().describe("File size"),mime:c().optional().describe("MIME type"),incognito:_().optional().describe("Whether the download is incognito"),referrer:c().optional().describe("Referrer URL"),byExtensionId:c().optional().describe("Extension ID"),byExtensionName:c().optional().describe("Extension name")}).passthrough();E(fi),h(),u({archName:c().describe("CPU architecture"),modelName:c().describe("CPU model"),numOfProcessors:h().describe("Number of processors"),features:E(c()).describe("CPU features")}),u({capacity:h().describe("Total memory capacity"),availableCapacity:h().describe("Available memory capacity")}),E(u({id:c().describe("Storage ID"),name:c().describe("Storage name"),type:c().describe("Storage type"),capacity:h().describe("Storage capacity")}));const z="Returns a Promise; await before reading the result. For a cell's last line, use `page.snapshot()` without a leading await so the cell returns the settled value.",pi=[{action:"page_back",namespace:"page",name:"back",description:"Go back in the active tab",params:ea,returns:A,paramTypes:[],returnDoc:"Navigation result",errorCode:"E_NO_TAB",example:"page.back()",handlerKey:"back"},{action:"page_click",namespace:"page",name:"click",description:"Click an element in the active tab",params:ra,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label to click (label)"}],returnDoc:"{ ok: true, action: 'click', refId? }",errorCode:"E_MISSING_PARAM",example:'page.click({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:[z,"Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.click"]},handlerKey:"click"},{action:"page_fill",namespace:"page",name:"fill",description:"Fill an element in the active tab",params:aa,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"value",type:"string",required:!1,description:"Value to fill (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'fill', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.fill({ refId: "e2", value: "hello" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:[z,"Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.fill"]},handlerKey:"fill"},{action:"page_set_files",namespace:"page",name:"setFiles",description:"Attach files to a file input in the active tab",params:ia,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"files",type:"{ name?: string, url?: string, path?: string, handle?: string, mimeType?: string }[]",required:!0,description:"Each entry uses exactly one of url, path (vfs), or handle (from page.fetch store:true)"}],returnDoc:"{ ok: true, action: 'setFiles', refId?, fileCount?, fileNames? }",errorCode:"E_MISSING_PARAM",example:'page.setFiles({ refId: "e3", files: [{ url: "https://example.com/photo.jpg", name: "photo.jpg" }] })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:[z,"Target must be input[type=file]; prefer url, vfs path, or fetch handle — bytes are not passed through QuickJS","Use page.fetch({ url, store: true }) then setFiles({ files: [{ handle }] }) for downloaded binaries","Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.setFiles","page.fetch","fs.writeBase64"]},handlerKey:"set_files"},{action:"page_type",namespace:"page",name:"type",description:"Type into an element in the active tab",params:oa,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"text",type:"string",required:!1,description:"Text to type (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'type', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.type({ refId: "e2", text: "hello" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:[z,"Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.type"]},handlerKey:"type"},{action:"page_append",namespace:"page",name:"append",description:"Append text to an element in the active tab",params:ca,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"text",type:"string",required:!1,description:"Text to append (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'append', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.append({ refId: "e2", text: " world" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"]},handlerKey:"append"},{action:"page_press",namespace:"page",name:"press",description:"Press a key in the active tab",params:la,returns:A,fields:["key"],paramTypes:[{name:"key",type:"string",required:!0,description:"Key to press (literal)"}],returnDoc:"{ ok: true, action: 'press', key? }",errorCode:"E_NO_TAB",example:'page.press("Enter")',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.press"]},handlerKey:"press"},{action:"page_select",namespace:"page",name:"select",description:"Select an option in the active tab",params:da,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"value",type:"string",required:!1,description:"Option value to select (literal)"}],returnDoc:"{ ok: true, action: 'select', refId?, value? }",errorCode:"E_MISSING_PARAM",example:'page.select({ refId: "e2", value: "option1" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.select"]},handlerKey:"select"},{action:"page_select_option",namespace:"page",name:"select_option",description:"Open a combobox (react-select/listbox) and click the option whose text matches value",params:ua,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"value",type:"string",required:!1,description:"Visible text of the option to select (matched case-insensitively)"}],returnDoc:"{ ok: true, action: 'select_option', refId?, value? }",errorCode:"E_NOT_FOUND",example:'page.select_option({ refId: "e2", value: "Canada" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId","Drives react-select and other ARIA combobox patterns: clicks the control to open, then clicks the matching [role='option']"],tags:["mutation","write"],relatedApis:["web.tab.select_option"]},handlerKey:"select_option"},{action:"page_check",namespace:"page",name:"check",description:"Check/uncheck an element in the active tab",params:fa,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"checked",type:"boolean",required:!1,description:"Whether to check or uncheck (literal)"}],returnDoc:"{ ok: true, action: 'check', refId?, checked? }",errorCode:"E_MISSING_PARAM",example:'page.check({ refId: "e2", checked: true })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.check"]},handlerKey:"check"},{action:"page_hover",namespace:"page",name:"hover",description:"Hover over an element in the active tab",params:ha,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'hover', refId? }",errorCode:"E_MISSING_PARAM",example:'page.hover({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.hover"]},handlerKey:"hover"},{action:"page_unhover",namespace:"page",name:"unhover",description:"Unhover in the active tab",params:ma,returns:A,paramTypes:[],returnDoc:"{ ok: true, action: 'unhover' }",errorCode:"E_NO_TAB",example:"page.unhover()",agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.unhover"]},handlerKey:"unhover"},{action:"page_submit",namespace:"page",name:"submit",description:"Submit a form in the active tab (calls form.requestSubmit())",params:ba,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID of the form or any element inside it (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'submit', refId?, dispatched: true }",errorCode:"E_MISSING_PARAM",example:'page.submit({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Target a <form> element or any descendant; resolves to the owning form","Uses form.requestSubmit() so submit event listeners fire and validation runs","Same content-script path as web.tab.*"],tags:["mutation","write"],relatedApis:["web.tab.submit","page.click"]},handlerKey:"submit"},{action:"page_check_radio",namespace:"page",name:"checkRadio",description:"Check a radio option by group name and value in the active tab",params:pa,returns:A,paramTypes:[{name:"name",type:"string",required:!0,description:"The name attribute of the radio group"},{name:"value",type:"string",required:!0,description:"The value of the radio option to check"}],returnDoc:"{ ok: true, action: 'check_radio', refId?, checked: true, value }",errorCode:"E_MISSING_PARAM",example:'page.checkRadio({ name: "radio-grp", value: "opt2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Picks a radio by group name + value — no refId needed","Use page.snapshot_data to discover radio values from the DOM","Same content-script path as web.tab.*"],tags:["mutation","write"],relatedApis:["web.tab.checkRadio","page.check","page.snapshot_data"]},handlerKey:"check_radio"},{action:"page_scroll",namespace:"page",name:"scroll",description:"Scroll the active tab",params:ga,returns:A,fields:["direction","amount"],paramTypes:[{name:"direction",type:"string",required:!1,description:"Scroll direction (up or down) (literal)"},{name:"amount",type:"number",required:!1,description:"Scroll amount in pixels (literal)"}],returnDoc:"Scroll result",errorCode:"E_NO_TAB",example:'page.scroll("down", 500)',handlerKey:"scroll"},{action:"page_scroll_to",namespace:"page",name:"scroll_to",description:"Scroll to an element in the active tab",params:ya,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID to scroll to (refId)"},{name:"label",type:"string",required:!1,description:"Element label to scroll to (label)"}],returnDoc:"Scroll to result",errorCode:"E_MISSING_PARAM",example:'page.scroll_to({ refId: "e2" })',handlerKey:"scroll_to"},{action:"page_dblclick",namespace:"page",name:"dblclick",description:"Double-click an element in the active tab",params:va,returns:A,paramTypes:[{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'dblclick', refId? }",errorCode:"E_MISSING_PARAM",example:'page.dblclick({ refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab is active and the content script is ready before mutating"],notes:["Same content-script path as web.tab.*","Always operates on the active tab; use web.tab.* if you need to target a specific tabId"],tags:["mutation","write"],relatedApis:["web.tab.dblclick"]},handlerKey:"dblclick"},{action:"tab_click",namespace:"web.tab",name:"click",description:"Click in a tab",params:Ta,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'click', refId? }",errorCode:"E_NO_TAB",example:'web.tab.click({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.click"]},handlerKey:"click"},{action:"tab_fill",namespace:"web.tab",name:"fill",description:"Fill in a tab",params:Sa,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"value",type:"string",required:!1,description:"Value to fill (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'fill', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.fill({ tabId: 123, refId: "e2", value: "hello" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.fill"]},handlerKey:"fill"},{action:"tab_set_files",namespace:"web.tab",name:"setFiles",description:"Attach files to a file input in a tab",params:Ea,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"files",type:"{ name?: string, url?: string, path?: string, handle?: string, mimeType?: string }[]",required:!0,description:"Each entry uses exactly one of url, path (vfs), or handle"}],returnDoc:"{ ok: true, action: 'setFiles', refId?, fileCount?, fileNames? }",errorCode:"E_NO_TAB",example:'web.tab.setFiles({ tabId: 123, refId: "e3", files: [{ url: "https://example.com/photo.jpg" }] })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.setFiles"]},handlerKey:"set_files"},{action:"tab_scroll_to",namespace:"web.tab",name:"scroll_to",description:"Scroll to position in a tab",params:Ca,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"x",type:"number",required:!1,description:"X coordinate (literal)"},{name:"y",type:"number",required:!1,description:"Y coordinate (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"Scroll to result",errorCode:"E_NO_TAB",example:'web.tab.scroll_to({ tabId: 123, refId: "e2" })',handlerKey:"scroll_to"},{action:"tab_type",namespace:"web.tab",name:"type",description:"Type in a tab",params:Na,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"text",type:"string",required:!1,description:"Text to type (literal)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'type', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.type({ tabId: 123, refId: "e2", text: "hello" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.type"]},handlerKey:"type"},{action:"tab_press",namespace:"web.tab",name:"press",description:"Press a key in a tab",params:Ra,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"key",type:"string",required:!1,description:"Key to press (literal)"}],returnDoc:"{ ok: true, action: 'press', key? }",errorCode:"E_NO_TAB",example:'web.tab.press({ tabId: 123, key: "Enter" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.press"]},handlerKey:"press"},{action:"tab_select",namespace:"web.tab",name:"select",description:"Select an option in a tab",params:Oa,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"value",type:"string",required:!1,description:"Option value to select (literal)"}],returnDoc:"{ ok: true, action: 'select', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.select({ tabId: 123, refId: "e2", value: "option1" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.select"]},handlerKey:"select"},{action:"tab_select_option",namespace:"web.tab",name:"select_option",description:"Open a combobox (react-select/listbox) in a tab and click the option whose text matches value",params:Da,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"value",type:"string",required:!1,description:"Visible text of the option to select (matched case-insensitively)"}],returnDoc:"{ ok: true, action: 'select_option', refId?, value? }",errorCode:"E_NO_TAB",example:'web.tab.select_option({ tabId: 123, refId: "e2", value: "Canada" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*","Drives react-select and other ARIA combobox patterns: clicks the control to open, then clicks the matching [role='option']"],tags:["mutation","write"],relatedApis:["page.select_option"]},handlerKey:"select_option"},{action:"tab_check",namespace:"web.tab",name:"check",description:"Check/uncheck in a tab",params:qa,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"},{name:"checked",type:"boolean",required:!1,description:"Whether to check or uncheck (literal)"}],returnDoc:"{ ok: true, action: 'check', refId?, checked? }",errorCode:"E_NO_TAB",example:'web.tab.check({ tabId: 123, refId: "e2", checked: true })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.check"]},handlerKey:"check"},{action:"tab_submit",namespace:"web.tab",name:"submit",description:"Submit a form in a tab (calls form.requestSubmit())",params:Pa,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID of the form or any element inside it (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'submit', refId?, dispatched: true }",errorCode:"E_NO_TAB",example:'web.tab.submit({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handler as page.submit"],tags:["mutation","write"],relatedApis:["page.submit"]},handlerKey:"submit"},{action:"tab_check_radio",namespace:"web.tab",name:"checkRadio",description:"Check a radio option by group name and value in a tab",params:La,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"name",type:"string",required:!0,description:"The name attribute of the radio group"},{name:"value",type:"string",required:!0,description:"The value of the radio option to check"}],returnDoc:"{ ok: true, action: 'check_radio', refId?, checked: true, value }",errorCode:"E_NO_TAB",example:'web.tab.checkRadio({ tabId: 123, name: "radio-grp", value: "opt2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handler as page.checkRadio"],tags:["mutation","write"],relatedApis:["page.checkRadio"]},handlerKey:"check_radio"},{action:"tab_hover",namespace:"web.tab",name:"hover",description:"Hover in a tab",params:Ma,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'hover', refId? }",errorCode:"E_NO_TAB",example:'web.tab.hover({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.hover"]},handlerKey:"hover"},{action:"tab_unhover",namespace:"web.tab",name:"unhover",description:"Unhover in a tab",params:$a,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"{ ok: true, action: 'unhover' }",errorCode:"E_NO_TAB",example:"web.tab.unhover({ tabId: 123 })",agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.unhover"]},handlerKey:"unhover"},{action:"tab_scroll",namespace:"web.tab",name:"scroll",description:"Scroll in a tab",params:ja,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"direction",type:"string",required:!1,description:"Scroll direction (up or down) (literal)"},{name:"amount",type:"number",required:!1,description:"Scroll amount in pixels (literal)"}],returnDoc:"Scroll result",errorCode:"E_NO_TAB",example:'web.tab.scroll({ tabId: 123, direction: "down", amount: 500 })',handlerKey:"scroll"},{action:"tab_dblclick",namespace:"web.tab",name:"dblclick",description:"Double-click in a tab",params:Fa,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"refId",type:"string",required:!1,description:"Element reference ID (refId)"},{name:"label",type:"string",required:!1,description:"Element label (label)"}],returnDoc:"{ ok: true, action: 'dblclick', refId? }",errorCode:"E_NO_TAB",example:'web.tab.dblclick({ tabId: 123, refId: "e2" })',agentMeta:{prerequisites:["Ensure the target tab exists and the content script is ready before mutating"],notes:["Explicit tabId required; same handlers as page.*"],tags:["mutation","write"],relatedApis:["page.dblclick"]},handlerKey:"dblclick"},{action:"tab_back",namespace:"web.tab",name:"back",description:"Go back in a tab",params:Za,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Back result",errorCode:"E_NO_TAB",example:"web.tab.back({ tabId: 123 })",handlerKey:"back"},{action:"page_forward",namespace:"page",name:"forward",description:"Go forward in the active tab",params:ta,returns:A,paramTypes:[],returnDoc:"Navigation result",errorCode:"E_NO_TAB",example:"page.forward()",handlerKey:"forward"},{action:"page_snapshot",namespace:"page",name:"snapshot",description:"Capture full DOM snapshot",params:za,returns:c(),paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal)"},{name:"options",type:"{ max_nodes?: number }",required:!1,description:"Snapshot options (literal)"}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"page.snapshot()",agentMeta:{notes:[z,"Content-script path; same refIds as mutations"],tags:["snapshot","read"],relatedApis:["page.snapshot_data","web.tab.snapshot"]},handlerKey:"snapshot_text"},{action:"page_snapshot_text",namespace:"page",name:"snapshot_text",description:"Capture DOM snapshot and return text representation",params:Ga,returns:c(),paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal)"}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"page.snapshot_text()",handlerKey:"snapshot_text"},{action:"page_snapshot_data",namespace:"page",name:"snapshot_data",description:"Get page snapshot data",params:Ja,returns:it,paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal)"}],returnDoc:"{ text, nodes, url, title, viewport }",errorCode:"E_SNAPSHOT",example:"page.snapshot_data()",agentMeta:{notes:[z,"Content-script path; nodes include refId for targeting","After mutations, call snapshot_data() again to verify state"],tags:["snapshot","read"],relatedApis:["page.click","web.tab.snapshot_data"]},handlerKey:"snapshot"},{action:"page_snapshot_query",namespace:"page",name:"snapshot_query",description:"Query page snapshot with semantic filtering by role, tag, text, name, etc.",params:ur,returns:it,paramTypes:[{name:"filter",type:"{ role?: string | string[], tag?: string | string[], text?: string, name?: string, interactiveOnly?: boolean, href?: string, src?: string, limit?: number }",required:!1,description:"Semantic filter criteria (literal)"},{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to collect before filtering (literal)"}],returnDoc:"{ text, nodes (filtered), url, title, viewport }",errorCode:"E_SNAPSHOT",example:'page.snapshot_query({ filter: { role: "button" } })',agentMeta:{notes:[z,"Content-script path; filters nodes by role, tag, text, name, interactiveOnly, href, src","More efficient than page.snapshot_data() when only specific elements are needed"],tags:["snapshot","read"],relatedApis:["page.snapshot_data","page.find"]},handlerKey:"snapshot_query"},{action:"page_find",namespace:"page",name:"find",description:"Find elements in the active tab using a CSS selector",params:_a,returns:E(u({refId:H(),role:c(),tag:c(),name:c().optional(),text:c().optional(),value:c().optional(),checked:_().optional(),disabled:_().optional(),readOnly:_().optional(),href:c().optional(),src:c().optional(),alt:c().optional(),title:c().optional(),parentRefId:H().optional()})),aliases:[{namespace:"page",name:"query"}],fields:["selector"],paramTypes:[{name:"selector",type:"string",required:!0,description:"CSS selector to find elements (selector)"}],returnDoc:"Array of elements with refId, role, name, href/src, alt, and parentRefId",errorCode:"E_NO_TAB",example:'page.find("h1")',agentMeta:{notes:["Assigns data-ref-id on matched elements when missing so results include actionable refIds"],tags:["read"]},handlerKey:"find"},{action:"page_dom",namespace:"page",name:"dom",description:"Introspect raw DOM subtree by CSS selector — bypasses the curated snapshot's visibility filter. Read-only. Use when page.snapshot/find hide the element you need (e.g. hidden file inputs, shadowed widgets, aria-hidden regions).",params:wa,returns:ri,paramTypes:[{name:"selector",type:"string",required:!0,description:"CSS selector for root element(s)"},{name:"depth",type:"number",required:!1,description:"Descendant levels (default 2, max 10)"},{name:"includeHidden",type:"boolean",required:!1,description:"Include hidden elements (default true)"}],returnDoc:"{ nodes: [{ refId?, tag, role?, name?, attributes?, hidden?, hiddenReason?, accept?, filesCount?, children? }], url, title }",errorCode:"E_NO_TAB",example:'page.dom({ selector: "input[type=file]", depth: 0 })',agentMeta:{prerequisites:["Active tab with content script ready"],notes:[z,"Read-only: returns DOM structure, never executes code or mutates the page","Bypasses the snapshot visibility filter — use to find hidden/filtered elements the curated snapshot omits","Assigns refIds to returned elements so subsequent page.setFiles/click/fill can target them","Prefer page.snapshot for normal navigation; use page.dom only when the snapshot is insufficient"],tags:["read"],relatedApis:["page.find","page.snapshot_data","page.setFiles"]},handlerKey:"dom"},{action:"page_wait_for",namespace:"page",name:"wait_for",description:"Wait for a selector in the active tab",params:ka,returns:_(),fields:["selector","timeout"],paramTypes:[{name:"selector",type:"string",required:!0,description:"CSS selector to wait for (selector)"},{name:"timeout",type:"number",required:!1,description:"Timeout in milliseconds (literal)"}],returnDoc:"true",errorCode:"E_TIMEOUT",errorCategory:"timeout",example:'page.wait_for("#submit", 5000)',agentMeta:{notes:[z],tags:["read"]},handlerKey:"wait_for"},{action:"page_extract",namespace:"page",name:"extract",description:"Extract data from the active tab",params:Ia,returns:u({title:c().optional(),url:c().optional(),headings:E(u({tag:c(),text:c()})).optional(),links:E(u({href:c().nullable(),text:c()})).optional(),text:c().optional()}).passthrough(),fields:["fields"],paramTypes:[{name:"fields",type:"array",required:!0,description:"Array of fields to extract (title, url, headings, links, text)"}],returnDoc:"Extracted data",errorCode:"E_NO_TAB",example:'page.extract(["title", "url"])',agentMeta:{notes:[z],tags:["read"]},handlerKey:"extract"},{action:"page_fetch",namespace:"page",name:"fetch",description:"Fetch in the active tab",params:Xn,returns:fr,fields:["url","options"],paramTypes:[{name:"url",type:"string",required:!1,description:"URL to fetch (url)"},{name:"options",type:"{ method?: string, headers?: { [key: string]: string }, body?: string }",required:!1,description:"Fetch options (literal)"}],returnDoc:"DTO with `{ body, headers, ok, status }`",errorCode:"E_NO_TAB",example:'page.fetch({ url: "https://api.example.com/data" })',agentMeta:{notes:[z,"Runtime binary globals available: Uint8Array, ArrayBuffer, TextEncoder, TextDecoder, atob, btoa","For binary responses bodyEncoding is 'base64'; use atob() or fs.writeBase64 to handle bytes"],tags:["read"]},handlerKey:"fetch"},{action:"tab_forward",namespace:"web.tab",name:"forward",description:"Go forward in a tab",params:Ba,returns:A,paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Forward result",errorCode:"E_NO_TAB",example:"web.tab.forward({ tabId: 123 })",handlerKey:"forward"},{action:"tab_snapshot",namespace:"web.tab",name:"snapshot",description:"Get tab snapshot",params:Wa,returns:c(),fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal)"}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"web.tab.snapshot({ tabId: 123 })",handlerKey:"snapshot_text"},{action:"tab_snapshot_text",namespace:"web.tab",name:"snapshot_text",description:"Get tab snapshot text",params:Ha,returns:c(),fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"web.tab.snapshot_text({ tabId: 123 })",handlerKey:"snapshot_text"},{action:"tab_snapshot_data",namespace:"web.tab",name:"snapshot_data",description:"Get tab snapshot data",params:Ka,returns:it,fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"}],returnDoc:"Snapshot data",errorCode:"E_SNAPSHOT",example:"web.tab.snapshot_data({ tabId: 123 })",handlerKey:"snapshot"},{action:"tab_snapshot_query",namespace:"web.tab",name:"snapshot_query",description:"Query tab snapshot with semantic filtering by role, tag, text, name, etc.",params:Xa,returns:it,fields:["tabId"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"filter",type:"{ role?: string | string[], tag?: string | string[], text?: string, name?: string, interactiveOnly?: boolean, href?: string, src?: string, limit?: number }",required:!1,description:"Semantic filter criteria (literal)"},{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to collect before filtering (literal)"}],returnDoc:"{ text, nodes (filtered), url, title, viewport }",errorCode:"E_SNAPSHOT",example:'web.tab.snapshot_query({ tabId: 123, filter: { role: "button" } })',agentMeta:{notes:["Explicit tabId required; same handler as page.snapshot_query","Filters nodes by role, tag, text, name, interactiveOnly, href, src"],tags:["snapshot","read"],relatedApis:["page.snapshot_query"]},handlerKey:"snapshot_query"},{action:"tab_fetch",namespace:"web.tab",name:"fetch",description:"Fetch in a tab",params:Va,returns:fr,fields:["tabId","url","options"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"url",type:"string",required:!1,description:"URL to fetch"}],returnDoc:"Fetch result DTO",errorCode:"E_NO_TAB",example:'web.tab.fetch({ tabId: 123, url: "https://api.example.com/data" })',handlerKey:"fetch"},{action:"tab_evaluate",namespace:"web.tab",name:"evaluate",description:"Evaluate script in a tab (content-script context)",params:Ua,returns:ei,fields:["tabId","script"],paramTypes:[{name:"tabId",type:"number",required:!0,description:"Tab ID (literal)"},{name:"script",type:"string",required:!1,description:"Script to evaluate (literal)"}],returnDoc:"Evaluation result",errorCode:"E_NO_TAB",example:'web.tab.evaluate({ tabId: 123, script: "document.title" })',agentMeta:{notes:["Runs in content-script isolated world, not MAIN-world injection","For MAIN-world access use chrome.scripting.executeScript from a cell"],tags:["read"]},handlerKey:"evaluate"}];function hi(){return[{registryAction:"ping",handlerKey:"ping",params:u({}),returns:u({ok:_()})}]}const mi=new Set(["page_set_files","tab_set_files"]);function bi(){return pi.map(t=>({registryAction:t.action,handlerKey:t.handlerKey,params:mi.has(t.action)?t.action==="tab_set_files"?Aa:sa:t.params,returns:t.returns}))}if(wr(),window.__jsNotebookContentScriptInjected)throw new Error("Content script already injected");window.__jsNotebookContentScriptInjected=!0,Bn([...bi(),...hi()]),zn()})();
|
package/index.js
CHANGED
|
@@ -7689,7 +7689,7 @@ async function So(e, r, n, a) {
|
|
|
7689
7689
|
e.map(async (i) => {
|
|
7690
7690
|
var s;
|
|
7691
7691
|
try {
|
|
7692
|
-
const c =
|
|
7692
|
+
const c = { frameId: i.frameId }, l = await o.tabs.sendMessage(
|
|
7693
7693
|
n,
|
|
7694
7694
|
{
|
|
7695
7695
|
type: "registryCall",
|
|
@@ -8144,7 +8144,7 @@ class Vt {
|
|
|
8144
8144
|
callId: n.call_id,
|
|
8145
8145
|
runId: n.runId
|
|
8146
8146
|
},
|
|
8147
|
-
|
|
8147
|
+
{ frameId: o }
|
|
8148
8148
|
), b = We(h);
|
|
8149
8149
|
return l && b.ok ? b : l ? {
|
|
8150
8150
|
ok: !1,
|