@pi-oxide/extension-js 0.13.0 → 0.13.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.
Files changed (145) hide show
  1. package/content-script.js +3 -3
  2. package/extension_js.d.ts +51 -48
  3. package/extension_js.js +104019 -26171
  4. package/index.js +1067 -949
  5. package/package.json +2 -5
  6. package/worker.js +367 -359
  7. package/content-script/action-result.d.ts +0 -4
  8. package/content-script/dom-tree.d.ts +0 -28
  9. package/content-script/dom-utils.d.ts +0 -37
  10. package/content-script/file-resolution.d.ts +0 -22
  11. package/content-script/form-validation.d.ts +0 -12
  12. package/content-script/handlers.d.ts +0 -3
  13. package/content-script/index.d.ts +0 -6
  14. package/content-script/listbox.d.ts +0 -7
  15. package/content-script/logger.d.ts +0 -12
  16. package/content-script/message-router.d.ts +0 -1
  17. package/content-script/observation-lease.d.ts +0 -55
  18. package/content-script/registry.d.ts +0 -24
  19. package/content-script/schemas.d.ts +0 -5
  20. package/content-script/snapshot.d.ts +0 -3
  21. package/main/index.d.ts +0 -8
  22. package/main/runner/chrome/internals.d.ts +0 -9
  23. package/main/runner/chrome/native.d.ts +0 -6
  24. package/main/runner/command.d.ts +0 -3
  25. package/main/runner/dom/snapshot.d.ts +0 -8
  26. package/main/runner/fetch.d.ts +0 -4
  27. package/main/runner/host.d.ts +0 -3
  28. package/main/runner/index.d.ts +0 -2
  29. package/main/runner/lib/constants.d.ts +0 -14
  30. package/main/runner/lib/host-registry.d.ts +0 -6
  31. package/main/runner/lib/network-tracker.d.ts +0 -16
  32. package/main/runner/lib/params-helpers.d.ts +0 -2
  33. package/main/runner/lib/params.d.ts +0 -5
  34. package/main/runner/lib/types.d.ts +0 -116
  35. package/main/runner/runtime.d.ts +0 -15
  36. package/main/runner/sidepanel/dom.d.ts +0 -6
  37. package/main/runner/snapshot-merge.d.ts +0 -8
  38. package/main/runner/tab/execute.d.ts +0 -24
  39. package/main/runner/tools/aliases.d.ts +0 -1
  40. package/main/runner/tools/chrome/action.d.ts +0 -1
  41. package/main/runner/tools/chrome/alarms.d.ts +0 -1
  42. package/main/runner/tools/chrome/bookmarks.d.ts +0 -1
  43. package/main/runner/tools/chrome/browsing-data.d.ts +0 -1
  44. package/main/runner/tools/chrome/capability.d.ts +0 -30
  45. package/main/runner/tools/chrome/context-menus.d.ts +0 -1
  46. package/main/runner/tools/chrome/cookies.d.ts +0 -1
  47. package/main/runner/tools/chrome/declarative-net-request.d.ts +0 -1
  48. package/main/runner/tools/chrome/desktop-capture.d.ts +0 -1
  49. package/main/runner/tools/chrome/downloads.d.ts +0 -1
  50. package/main/runner/tools/chrome/history.d.ts +0 -1
  51. package/main/runner/tools/chrome/identity.d.ts +0 -1
  52. package/main/runner/tools/chrome/idle.d.ts +0 -1
  53. package/main/runner/tools/chrome/index.d.ts +0 -1
  54. package/main/runner/tools/chrome/management.d.ts +0 -1
  55. package/main/runner/tools/chrome/notifications.d.ts +0 -1
  56. package/main/runner/tools/chrome/offscreen.d.ts +0 -1
  57. package/main/runner/tools/chrome/page-capture.d.ts +0 -1
  58. package/main/runner/tools/chrome/permissions.d.ts +0 -1
  59. package/main/runner/tools/chrome/register-helpers.d.ts +0 -9
  60. package/main/runner/tools/chrome/runtime.d.ts +0 -1
  61. package/main/runner/tools/chrome/scripting.d.ts +0 -1
  62. package/main/runner/tools/chrome/sessions.d.ts +0 -1
  63. package/main/runner/tools/chrome/side-panel.d.ts +0 -1
  64. package/main/runner/tools/chrome/system.d.ts +0 -1
  65. package/main/runner/tools/chrome/tab-groups.d.ts +0 -1
  66. package/main/runner/tools/chrome/tabs.d.ts +0 -1
  67. package/main/runner/tools/chrome/top-sites.d.ts +0 -1
  68. package/main/runner/tools/chrome/windows.d.ts +0 -1
  69. package/main/runner/tools/chrome-storage.d.ts +0 -1
  70. package/main/runner/tools/clipboard.d.ts +0 -1
  71. package/main/runner/tools/dom.d.ts +0 -1
  72. package/main/runner/tools/host-call.d.ts +0 -1
  73. package/main/runner/tools/network.d.ts +0 -1
  74. package/main/runner/tools/page.d.ts +0 -1
  75. package/main/runner/tools/sidepanel.d.ts +0 -1
  76. package/main/runner/tools/storage.d.ts +0 -1
  77. package/main/runner/tools/tab.d.ts +0 -1
  78. package/main/session/extension-session.d.ts +0 -106
  79. package/main/tab-context.d.ts +0 -12
  80. package/shared/array-buffer.d.ts +0 -4
  81. package/shared/collect-inline-snapshot.d.ts +0 -50
  82. package/shared/cross/agent-errors.d.ts +0 -28
  83. package/shared/cross/array-buffer.d.ts +0 -4
  84. package/shared/cross/collect-inline-snapshot.d.ts +0 -58
  85. package/shared/cross/content-script-actions.d.ts +0 -7
  86. package/shared/cross/content-script-tools.d.ts +0 -3
  87. package/shared/cross/dispatch.d.ts +0 -5
  88. package/shared/cross/fetch-response.d.ts +0 -12
  89. package/shared/cross/format-types.d.ts +0 -43
  90. package/shared/cross/fs-types.d.ts +0 -81
  91. package/shared/cross/generated.d.ts +0 -328
  92. package/shared/cross/manifest.d.ts +0 -130
  93. package/shared/cross/normalize-agent-error.d.ts +0 -17
  94. package/shared/cross/page-specs.d.ts +0 -7
  95. package/shared/cross/schemas/chrome.d.ts +0 -56
  96. package/shared/cross/schemas/clipboard.d.ts +0 -19
  97. package/shared/cross/schemas/fs.d.ts +0 -65
  98. package/shared/cross/schemas/helpers.d.ts +0 -71
  99. package/shared/cross/schemas/host.d.ts +0 -15
  100. package/shared/cross/schemas/network.d.ts +0 -34
  101. package/shared/cross/schemas/page.d.ts +0 -494
  102. package/shared/cross/schemas/returns.d.ts +0 -8791
  103. package/shared/cross/schemas/sidepanel.d.ts +0 -284
  104. package/shared/cross/schemas/snapshot.d.ts +0 -272
  105. package/shared/cross/schemas/storage.d.ts +0 -60
  106. package/shared/cross/schemas/tab.d.ts +0 -597
  107. package/shared/cross/schemas.d.ts +0 -12
  108. package/shared/cross/snapshot-filter.d.ts +0 -15
  109. package/shared/cross/tab-specs.d.ts +0 -3
  110. package/shared/cross/types.d.ts +0 -12
  111. package/shared/cross/zod-to-docs.d.ts +0 -28
  112. package/shared/cs/ref-id.d.ts +0 -5
  113. package/shared/cs/snapshot-dom.d.ts +0 -47
  114. package/shared/fetch-response.d.ts +0 -12
  115. package/shared/fs-types.d.ts +0 -81
  116. package/shared/generated.d.ts +0 -241
  117. package/shared/log-levels.d.ts +0 -5
  118. package/shared/logger.d.ts +0 -18
  119. package/shared/main/content-script-response.d.ts +0 -5
  120. package/shared/main/define-content-script-tool.d.ts +0 -7
  121. package/shared/main/log-levels.d.ts +0 -5
  122. package/shared/main/logger.d.ts +0 -18
  123. package/shared/main/routes.d.ts +0 -14
  124. package/shared/main/tool-registry.d.ts +0 -19
  125. package/shared/ref-id.d.ts +0 -5
  126. package/shared/registry/agent-errors.d.ts +0 -27
  127. package/shared/registry/content-script-actions.d.ts +0 -7
  128. package/shared/registry/content-script-response.d.ts +0 -5
  129. package/shared/registry/content-script-tools.d.ts +0 -13
  130. package/shared/registry/define-content-script-tool.d.ts +0 -7
  131. package/shared/registry/dispatch.d.ts +0 -5
  132. package/shared/registry/manifest.d.ts +0 -130
  133. package/shared/registry/normalize-agent-error.d.ts +0 -17
  134. package/shared/registry/routes.d.ts +0 -14
  135. package/shared/registry/types.d.ts +0 -12
  136. package/shared/registry/zod-to-docs.d.ts +0 -28
  137. package/shared/schemas.d.ts +0 -10663
  138. package/shared/snapshot-dom.d.ts +0 -47
  139. package/shared/snapshot-filter.d.ts +0 -15
  140. package/shared/tool-registry.d.ts +0 -19
  141. package/worker/binary-blob-store.d.ts +0 -12
  142. package/worker/fetch-store.d.ts +0 -1
  143. package/worker/resolve-set-files.d.ts +0 -22
  144. package/worker/vfs-write-cache.d.ts +0 -3
  145. package/worker/worker.d.ts +0 -84
package/content-script.js CHANGED
@@ -1,3 +1,3 @@
1
- (function(){"use strict";const ee={debug:0,info:1,warn:2,error:3,none:4};let Mt=ee.error;function xr(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 Ze(t,e,r){if(t<Mt)return;const n=xr(r),a=`[extension-js][content-script] ${e}${n}`;t>=ee.error?console.error(a):t===ee.warn?console.warn(a):console.log(a)}const me={debug:(t,e)=>{Ze(ee.debug,t,e)},info:(t,e)=>{Ze(ee.info,t,e)},warn:(t,e)=>{Ze(ee.warn,t,e)},error:(t,e)=>{Ze(ee.error,t,e)}};function kr(){window.__jsNotebookSetLogLevel=t=>{Mt=ee[t]??ee.error}}function Ir(t){if(t.startsWith("page_")||t.startsWith("tab_")){const e=t.indexOf("_");if(e>=0)return t.slice(e+1)}return t}const Tr="Content script is not connected on this tab. This tab was likely open before the extension loaded (MV3 does not retro-inject).";function Sr(t){return[`await page.goto(${JSON.stringify(t||"")})`,"Or ask the user to refresh the target tab, then retry fill/click"]}function qt(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:Tr,recovery:Sr(e)};return t!==void 0&&(n.details={tabId:t,url:r}),n}function Er(t,e){var o,d;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&&((o=e.candidates)!=null&&o.length)){const l=e.candidates.map(p=>p.name||p.refId).filter(Boolean).slice(0,5);l.length>0?a+=`. Candidates: ${l.join(", ")}`:a+=". Candidates: none"}const i=(e==null?void 0:e.snapshot)!==void 0,s={message:a,code:"E_STALE",category:"resource",hint:i?"The element changed or was removed after the last observation. A fresh snapshot is attached — re-resolve the target refId and retry.":"RefIds are ephemeral. They are assigned at snapshot time and invalidated when the DOM is replaced (navigation, SPA rerender, autocomplete).",recovery:i?["Read error.details.snapshot.nodes, find the element by role/name, and retry with the new refId","No separate snapshot_data call needed — the attached snapshot already refreshes the lease"]:["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(d=e==null?void 0:e.candidates)!=null&&d.length&&(s.details={...s.details,candidates:e.candidates}),i&&(s.details={...s.details,snapshot:e.snapshot}),s}function ue(t,e,r){const a=(r==null?void 0:r.controlType)==="dropdown"||(r==null?void 0:r.nearbyControlType)==="dropdown"?[`await page.select_option({ refId: ${JSON.stringify(e)}, value: "..." }) — this is a dropdown; fill/type do not work on combobox/proxy inputs`,"Re-snapshot and use select_option with the option's visible text"]:[`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"];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:a,details:{refId:e,...r}}}function Ar(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 Cr(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 ke(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"}let 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 r!=null&&r.isDropdown&&(a=`Target is a dropdown (combobox). ${a}`),{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}:{},...(r==null?void 0:r.ariaControlsBefore)!==void 0?{ariaControlsBefore:r.ariaControlsBefore}:{},...(r==null?void 0:r.ariaControlsAfter)!==void 0?{ariaControlsAfter:r.ariaControlsAfter}:{},...(r==null?void 0:r.isDropdown)!==void 0?{isDropdown:r.isDropdown}:{},...e!=null&&e.length?{candidates:e}:{}}}}function Nr(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"?qt(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}=Nr(t);if(Cr(r))return qt(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 Rr=/^e\d+$/;let Lt=0;function at(){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)}Lt=t}function Ve(t){const e=t.getAttribute("data-ref-id");if(e&&Rr.test(e))return e;const r=`e${++Lt}`;return t.setAttribute("data-ref-id",r),r}const it='input, textarea, select, button, a, [role="button"], [role="link"]',Or=new Set(["script","style","noscript","template"]),Pt=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 He(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,st(t,e);else if(t instanceof HTMLTextAreaElement)e.value=t.value,e.disabled=t.disabled,e.readOnly=t.readOnly,st(t,e);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,st(t,e)}else t instanceof HTMLOptionElement&&(e.value=t.value,e.selected=t.selected,e.disabled=t.disabled);return e}function st(t,e){const r=t.required||t.getAttribute("aria-required")==="true",a=!(t.getAttribute("aria-invalid")==="true")&&t.checkValidity();r&&(e.required=!0),e.valid=a,e.invalid=!a;const i=$t(t);i&&(e.errorMessage=i),!a&&t.validationMessage&&(e.validationMessage=t.validationMessage)}function $t(t){var r;const e=[...(t.getAttribute("aria-errormessage")||"").split(/\s+/),...(t.getAttribute("aria-describedby")||"").split(/\s+/)].filter(Boolean);for(const n of e){const a=document.getElementById(n);if(!a)continue;const i=(r=a.textContent)==null?void 0:r.trim();if(!i)continue;const s=a.getAttribute("role"),o=a.getAttribute("aria-live");if(s==="alert"||o&&o!=="off"||/error|required|select|please|invalid/i.test(i))return i}}function Mr(t,e){const r=t.tagName.toLowerCase();r!=="input"&&r!=="textarea"&&r!=="select"&&r!=="option"||Object.assign(e,He(t))}const qr=new Set(["http:","https:","file:"]);function ie(t){if(t)try{const e=new URL(t,window.location.href);return qr.has(e.protocol)?e.href:void 0}catch{return}}function jt(t){const e=t.closest("article[data-post-id], [data-post-id]");if(e)return Ve(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 F(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"||n==="tel")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 Lr(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 ot(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 se(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 Pr(t){return se(t)}function Ft(t){var o;const e=t.tagName.toLowerCase();if(Or.has(e)||Pr(t))return!1;const r=F(t);if(r!=="generic"&&!(r==="presentation"||r==="none"))return!0;const a=t.getAttribute("aria-live");if(a&&a!=="off")return!0;const i=t.getAttribute("role");return i==="status"||i==="alert"?!0:((o=t.textContent)==null?void 0:o.trim())||""?!!(Pt.has(e)||Lr(t)):!1}function te(t){var s,o,d;const e=t.getAttribute("aria-label");if(e)return e;const r=t.getAttribute("aria-labelledby");if(r){const l=document.getElementById(r);if(l)return((s=l.textContent)==null?void 0:s.slice(0,60))||""}if(t.tagName.toLowerCase()==="img"){const l=t.getAttribute("alt");if(l)return l}const a=t.title;if(a)return a;const i=F(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"&&Ft(t)){const l=ot(t);if(l)return l;const p=t.tagName.toLowerCase();if(Pt.has(p)||t.childElementCount===0)return((d=t.textContent)==null?void 0:d.trim().slice(0,60))||""}return""}function $r(t){return t instanceof HTMLInputElement&&t.type==="file"||jr(t)||ct(t)?!0:Ft(t)}function jr(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement?!t.checkValidity()||t.getAttribute("aria-invalid")==="true":!1}function ct(t){return!(t instanceof HTMLInputElement)||t.closest('[role="combobox"]')===null||!(t.type==="hidden"||t.getAttribute("aria-hidden")==="true"||t.tabIndex===-1)?!1:t.required||t.getAttribute("aria-required")==="true"||(t.getAttribute("aria-describedby")||"").length>0}function Fr(t){return typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/["\\]/g,"\\$&")}function Br(t,e){var r,n,a,i;if(t){const s=t.getAttribute("id");if(s){const p=document.querySelector(`label[for="${Fr(s)}"]`);if((r=p==null?void 0:p.textContent)!=null&&r.trim())return p.textContent.trim()}const o=t.closest("label");if((n=o==null?void 0:o.textContent)!=null&&n.trim())return o.textContent.trim();const d=t.previousElementSibling;if((d==null?void 0:d.tagName)==="LABEL"&&((a=d.textContent)!=null&&a.trim()))return d.textContent.trim();const l=t.parentElement;if(l){const p=l.querySelector("label");if((i=p==null?void 0:p.textContent)!=null&&i.trim())return p.textContent.trim()}}return e}const Ur={script:!0,style:!0,noscript:!0,template:!0},Zr=(t,e)=>Mr(t,e),Vr=(t,e)=>{var n;if(!ct(t))return;e.controlType="validation-proxy",e.actionable=!1;const r=(n=t.closest('[role="combobox"]'))==null?void 0:n.getAttribute("data-ref-id");r&&(e.forControl=r)},Bt=(t,e)=>{if(e.controlType==="validation-proxy"||e.role!=="combobox"&&e.tag!=="select")return;e.controlType="dropdown",e.recommendedAction="select_option",e.controls=t.getAttribute("aria-controls")||t.getAttribute("aria-owns")||void 0;const r=t.getAttribute("aria-expanded");e.expanded=r==="true"?!0:r==="false"?!1:void 0},Hr=(t,e)=>{e.tag==="a"&&(e.href=ie(t.getAttribute("href")))},Wr=(t,e)=>{e.tag==="img"&&(e.src=ie(t.getAttribute("src")),e.alt=t.getAttribute("alt")||"")},Kr=(t,e)=>{var n;if(e.tag!=="input")return;const r=t;e.title=t.getAttribute("title")||void 0,r.type==="file"&&(e.accept=r.getAttribute("accept")||void 0,e.filesCount=((n=r.files)==null?void 0:n.length)??0)},zr=(t,e)=>{e.tag!=="img"&&e.tag!=="a"||(e.parentRefId=jt(t)||e.parentRefId)},Gr=(t,e)=>{e.postId=t.getAttribute("data-post-id")||void 0},Jr=(t,e)=>{if(e.tag==="a")return;const r=Dr(t);r&&(e.permalink=ie(r.getAttribute("href")))},Xr=(t,e)=>{if(e.tag==="img")return;const r=Array.from(t.querySelectorAll("img")).map(n=>ie(n.getAttribute("src"))).filter(n=>!!n);r.length>0&&(e.imageUrls=r)},Qr=(t,e)=>[Zr,Vr,Bt,Hr,Wr,Kr,zr,Gr,Jr,Xr].forEach(r=>r(t,e)),Yr=(t,e,r)=>{const n={refId:Ve(t),role:F(t),tag:t.tagName.toLowerCase(),text:ot(t,100)},a=te(t);return a&&(n.name=a),(n.tag==="img"||n.tag==="a")&&r&&(n.parentRefId=r),Qr(t,n),n},en=(t,e)=>{var a,i,s,o,d,l;const r=t.controlType==="dropdown"?"dropdown":t.controlType==="validation-proxy"?"validation-proxy":t.role,n=[[t.name,`"${(a=t.name)==null?void 0:a.replace(/"/g,'\\"')}"`],[`[${t.refId}]`,`[${t.refId}]`],[t.text&&t.text!==t.name,`text="${(i=t.text)==null?void 0:i.replace(/"/g,'\\"')}"`],[t.value,`value="${(s=t.value)==null?void 0:s.replace(/"/g,'\\"')}"`],[t.required,"required"],[t.invalid,"invalid"],[t.expanded!==void 0,`expanded=${t.expanded}`],[t.controls,`opens="${(o=t.controls)==null?void 0:o.replace(/"/g,'\\"')}"`],[t.recommendedAction,`use="${t.recommendedAction}"`],[t.actionable===!1,"actionable=false"],[t.forControl,`forControl="${t.forControl}"`],[t.errorMessage,`error="${(d=t.errorMessage)==null?void 0:d.replace(/"/g,'\\"')}"`],[!t.errorMessage&&t.validationMessage,`validation="${(l=t.validationMessage)==null?void 0:l.replace(/"/g,'\\"')}"`]];return[`${" ".repeat(e)}- ${r}`,...n.filter(([p])=>p).map(([,p])=>p)].join(" ")},tn=t=>t.filter(e=>(e.invalid||e.errorMessage!==void 0||e.validationMessage!==void 0)&&e.controlType!=="validation-proxy").map(e=>({field:Br(document.querySelector(`[data-ref-id="${e.refId}"]`),e.name||e.refId),error:e.errorMessage||e.validationMessage||"",refId:e.refId})),rn=(...t)=>e=>t.reduce((r,n)=>r.kind==="reject"?r:n(r),e),nn=t=>Ur[t.el.tagName.toLowerCase()]?{kind:"reject",el:t.el,depth:t.depth}:t,an=t=>$r(t.el)?t:{kind:"reject",el:t.el,depth:t.depth},sn=(t,e)=>r=>t>=e?{kind:"reject",el:r.el,depth:r.depth}:r,on=t=>{const e=Yr(t.el,t.depth,t.parentRefId);return{kind:"emit",node:e,line:en(e,t.depth),children:Array.from(t.el.children),childDepth:t.depth+1,childRefId:e.refId}},cn=t=>t.kind==="emit"?{emitted:{node:t.node,line:t.line},children:t.children,childDepth:t.childDepth,childRefId:t.childRefId}:{emitted:null,children:Array.from(t.el.children),childDepth:t.depth,childRefId:""},ln=(t,e)=>{const r=[],n=[],a=(i,s,o)=>{const l=rn(nn,an,sn(r.length,e))({kind:"enter",el:i,depth:s,parentRefId:o}),p=cn(l.kind==="reject"?l:on(l));p.emitted&&(r.push(p.emitted.node),n.push(p.emitted.line));for(const S of p.children){if(r.length>=e)break;a(S,p.childDepth,p.childRefId)}};return a(t,0,""),{nodes:r,lines:n}};function dn(t){let e=!1;const r=typeof MutationObserver<"u"&&document.body?new MutationObserver(()=>{e=!0}):null;r&&document.body&&r.observe(document.body,{childList:!0,subtree:!0});try{return t()}finally{r&&(r.takeRecords().length>0&&(e=!0),r.disconnect()),e&&R({message:"DOM mutated during snapshot collection",code:"E_SNAPSHOT",category:"resource",details:{cause:"dom_mutated_during_snapshot"},recovery:["Wait for the page to finish rendering before snapshot","Retry with a smaller max_nodes bound","Use page.snapshot_data() after navigation settles"]})}}function lt(t){return at(),dn(()=>{const{nodes:e,lines:r}=document.body?ln(document.body,t):{nodes:[],lines:[]};return{text:[`URL: ${window.location.href}`,`Title: ${document.title}`,"",...r].join(`
2
- `),nodes:e,formErrors:tn(e),url:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight}}})}function dt(t){return{tag:t.tagName.toLowerCase(),role:F(t),name:te(t)}}function un(t,e){return t.tag===e.tag&&t.role===e.role&&t.name===e.name}let Ie=!1,Ut=0,We,be=new Map;function ut(t=[]){Ut+=1,We=`obs${Ut}`,Ie=!0,be=new Map;for(const e of t)be.set(e.refId,{element:e.element,fingerprint:dt(e.element)});return We}function pt(){Ie=!1,We=void 0,be=new Map}function pn(){return Ie}function Te(){return We}function ft(t,e){Ie||Zt(e);const r=be.get(t);r||Ke(t,"not_in_latest_observation");const{element:n,fingerprint:a}=r;if(!n.isConnected){const s=fn(r);if(s)return be.set(t,{element:s,fingerprint:dt(s)}),s;Ke(t,"disconnected")}const i=dt(n);return un(i,a)||Ke(t,"fingerprint_changed"),n}function fn(t){const{fingerprint:e}=t,r=e.role,n=e.name.trim().toLowerCase();return Array.from(document.querySelectorAll("*")).find(a=>F(a)===r&&te(a).toLowerCase().trim()===n)??null}function Zt(t){const e=mt(),r=new Error(`${t} requires a fresh observation before acting.`);throw r.code="E_OBSERVATION_REQUIRED",r.category="observation",r.hint="Element refIds are only valid after a snapshot. A fresh snapshot is attached — use a refId from error.details.snapshot.nodes and retry.",r.recovery=["Read error.details.snapshot.nodes, pick the target refId, and retry the action","No separate snapshot_data call needed — the attached snapshot already refreshes the lease"],r.details={action:t,...e?{snapshot:e}:{}},r}function Ke(t,e){const r=mt(),n=new Error(`Element refId "${t}" is stale (${e}).`);throw n.code="E_STALE",n.category="observation",n.hint="The element changed or was removed after the last observation. A fresh snapshot is attached — re-resolve the target refId and retry.",n.recovery=["Read error.details.snapshot.nodes, find the element by role/name, and retry with the new refId","No separate snapshot_data call needed — the attached snapshot already refreshes the lease"],n.details={staleRefId:t,reason:e,...r?{snapshot:r}:{}},n}function hn(t,e){Ie||Zt(e);const r=t.toLowerCase().trim(),n=[];for(const i of be.values())te(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&&mn(t);const a=n[0];return a.isConnected||Ke(a.getAttribute("data-ref-id")||"","disconnected"),a}function mn(t){const e=mt(),r=new Error(`Multiple elements match label "${t}". The target is ambiguous.`);throw r.code="E_AMBIGUOUS_TARGET",r.category="observation",r.hint="Use a refId from error.details.snapshot.nodes instead of a label, or narrow the label.",r.recovery=["Read error.details.snapshot.nodes, pick the intended target by refId, and retry","No separate snapshot_data call needed — the attached snapshot already refreshes the lease"],r.details={label:t,...e?{snapshot:e}:{}},r}function bn(t){return document.querySelector(`[data-ref-id='${CSS.escape(t)}']`)}function ht(t){const e=lt(t),r=e.nodes.map(a=>{const i=bn(a.refId);return i?{refId:a.refId,element:i}:null}).filter(a=>a!==null),n=ut(r);return{...e,observationId:n}}function mt(){try{const t=ht(Number.MAX_SAFE_INTEGER);return{nodes:t.nodes,observationId:t.observationId,url:t.url,title:t.title}}catch{return}}function gn(t){return document.querySelector(`[data-ref-id='${CSS.escape(t)}']`)}function z(t,e){const n=t instanceof HTMLSelectElement||t.getAttribute("role")==="combobox"||se(t)&&t.closest('[role="combobox"]')!==null?"dropdown":void 0;if(t.hasAttribute("disabled")||t.getAttribute("aria-disabled")==="true"){const a=t.getAttribute("data-ref-id")||void 0;R(ue(e,a??"",{reason:"disabled",...n?{controlType:n}:{}}))}if(se(t)){const a=t.getAttribute("data-ref-id")||void 0;R(ue(e,a??"",{reason:"hidden",...n?{controlType:n}:{}}))}}function bt(t){var n,a,i;const e=t.toLowerCase().trim();if(!e)return null;const r=Array.from(document.querySelectorAll(it));for(const s of r){const o=s.getAttribute("aria-label");if(o&&o.toLowerCase().trim()===e)return s;const d=s.placeholder;if(d&&d.toLowerCase().trim()===e)return s;const l=s.id;if(l){const A=document.querySelector(`label[for='${CSS.escape(l)}']`);if(A&&((n=A.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 yn(t){var a;const e=t.toLowerCase().trim();if(!e)return[];const r=Array.from(document.querySelectorAll(it)),n=[];for(const i of r){const s=i.getAttribute("aria-label"),o=i.placeholder,d=((a=i.textContent)==null?void 0:a.trim())||"";if(![s,o,d].filter(Boolean).some(S=>S.toLowerCase().includes(e)))continue;const p=i.getAttribute("data-ref-id");if(p&&(n.push({refId:p,role:F(i),name:te(i)||void 0}),n.length>=5))break}return n}function ge(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}function vn(t){const e=document.querySelector(`[data-ref-id='${CSS.escape(t)}']`);let r,n;e&&(r=e.tagName.toLowerCase(),n=F(e));const a=Array.from(document.querySelectorAll(it)),i=[];for(const s of a){const o=s.getAttribute("data-ref-id");if(o){if(r||n){const d=s.tagName.toLowerCase(),l=F(s);if(d!==r&&l!==n)continue}if(i.push({refId:o,role:F(s),name:te(s)||void 0}),i.length>=5)break}}return i}function _n(){try{return ht(Number.MAX_SAFE_INTEGER)}catch{return}}function Se(t,e,r=!1){const n=_n();if(t){const a=r?vn(t):[];R(Er(t,{candidates:a,snapshot:n}))}if(e){const a=r?yn(e):[];R(ke(e,a))}R({message:"Element not found",code:"E_NOT_FOUND",category:"resource"})}function G(t,e){let r=t?gn(t):null;return!r&&e&&(r=bt(e)),r||Se(t,e,!0),r}const Vt=8*1024;function wn(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 xn(t){let e="";for(let r=0;r<t.length;r+=Vt){const n=t.subarray(r,r+Vt);for(let a=0;a<n.length;a++)e+=String.fromCharCode(n[a])}return btoa(e)}function kn(t){return t.toLowerCase().split(";")[0].trim()}function In(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 Tn(t){for(let e=0;e<t.length;e++)if(t[e]===0)return!0;return!1}function Ht(t){return Object.fromEntries(t.headers.entries())}function Wt(t,e,r){return{status:t.status,ok:t.ok,headers:Ht(t),body:xn(e),bodyEncoding:"base64",byteLength:e.length,contentType:r,finalUrl:t.url}}function Kt(t,e,r){return{status:t.status,ok:t.ok,headers:Ht(t),body:e,bodyEncoding:"text",byteLength:new TextEncoder().encode(e).length,contentType:r,finalUrl:t.url}}async function Sn(t){const e=t.headers.get("content-type")||"",r=kn(e);if(In(r)){const a=new Uint8Array(await t.arrayBuffer());return Wt(t,a,e)}if(!r||r.startsWith("text/")){const a=new Uint8Array(await t.arrayBuffer());if(Tn(a))return Wt(t,a,e);const i=new TextDecoder().decode(a);return Kt(t,i,e)}const n=await t.text();return Kt(t,n,e)}const En=new Set(["button","link","textbox","checkbox","radio","combobox","searchbox","switch","menuitem","tab","treeitem"]),An=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 zt(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 Cn(t,e){let r=t;if(e.role){const n=zt(e.role);r=r.filter(a=>n.has(a.role.toLowerCase()))}if(e.tag){const n=zt(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=>En.has(n.role.toLowerCase())||An.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?He(e):{},...r}}function gt(t,e,r,n){(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.value!==n&&R(ue(t,r,{requested:n,actual:e.value}))}function Nn(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,n){var l;if(!r&&se(t))return null;const a=t.tagName.toLowerCase(),i=Ve(t);n&&n.push({refId:i,element:t});const s={tag:a,refId:i,role:F(t),name:te(t)||void 0,text:ot(t,100)||void 0},o={};for(const p of Array.from(t.attributes))o[p.name]=p.value;Object.keys(o).length&&(s.attributes=o);const d=Nn(t);if(d&&(s.hidden=!0,s.hiddenReason=d),Object.assign(s,He(t)),Bt(t,s),t instanceof HTMLInputElement&&t.type==="file"){const p=t.getAttribute("accept");p&&(s.accept=p),s.filesCount=((l=t.files)==null?void 0:l.length)??0}if(a==="a"){const p=ie(t.getAttribute("href"));p&&(s.href=p)}if(a==="img"){const p=ie(t.getAttribute("src"));p&&(s.src=p),s.alt=t.getAttribute("alt")||void 0}if(e>0){const p=[];for(const S of Array.from(t.children)){const A=Gt(S,e-1,r,n);A&&p.push(A)}p.length&&(s.children=p)}return s}function Ee(t){R({message:t,code:"E_INVALID_PARAMS",category:"validation"})}function Rn(t){const r=ge(t).files;(!Array.isArray(r)||r.length===0)&&Ee("setFiles requires a non-empty files array");const n=[];for(const a of r){const i=ge(a),s=i.kind;if(s==="bytes"){const o=typeof i.name=="string"?i.name.trim():"",d=typeof i.data=="string"?i.data:"";(!o||!d)&&Ee("Resolved bytes file requires name and data"),n.push({kind:"bytes",name:o,data:d,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:"",d=typeof i.name=="string"?i.name.trim():"";(!o||!d)&&Ee("Resolved url file requires url and name"),n.push({kind:"url",url:o,name:d,mimeType:typeof i.mimeType=="string"&&i.mimeType.length>0?i.mimeType:void 0})}}return n.length!==r.length&&Ee("setFiles files must be worker-resolved (kind: bytes or url)"),n}function On(t){try{const e=wn(t.data);return new File([e.slice()],t.name,{type:t.mimeType??"application/octet-stream"})}catch{Ee(`Invalid base64 data for file ${t.name}`)}}async function Mn(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 qn(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(ue("setFiles",e,{expectedNames:r,actualNames:n}))}function Dn(t){return Array.from(t.querySelectorAll("input, textarea, select")).filter(e=>(!e.checkValidity()||e.getAttribute("aria-invalid")==="true")&&!ct(e)).map(e=>{const r=te(e)||void 0,n=Ln(e,r),a=$t(e)||e.validationMessage||"";return{refId:e.getAttribute("data-ref-id")||void 0,tag:e.tagName.toLowerCase(),role:F(e),name:r,field:n,error:a,value:e instanceof HTMLInputElement&&e.type==="password"?void 0:e.value,required:e.required||e.getAttribute("aria-required")==="true",validationMessage:e.validationMessage||void 0}})}function Ln(t,e){var s,o,d,l;if(e)return e;const r=t.getAttribute("id");if(r){const p=typeof CSS<"u"&&CSS.escape?CSS.escape(r):r.replace(/["\\]/g,"\\$&"),S=document.querySelector(`label[for="${p}"]`);if((s=S==null?void 0:S.textContent)!=null&&s.trim())return S.textContent.trim()}const n=t.closest("label");if((o=n==null?void 0:n.textContent)!=null&&o.trim())return n.textContent.trim();const a=t.previousElementSibling;if((a==null?void 0:a.tagName)==="LABEL"&&((d=a.textContent)!=null&&d.trim()))return a.textContent.trim();const i=t.parentElement;if(i){const p=i.querySelector("label");if((l=p==null?void 0:p.textContent)!=null&&l.trim())return p.textContent.trim()}return t.getAttribute("data-ref-id")||void 0}function Jt(t){return Array.from(t.querySelectorAll('[role="option"]')).map(e=>(e.textContent||"").trim()).join(`
3
- `)}const yt=()=>Array.from(document.querySelectorAll('[role="listbox"]')),Pn=t=>[...new Set(t)],Xt=(t,e)=>e.flatMap(r=>(t.getAttribute(r)||"").trim().split(/\s+/)).filter(Boolean),vt=t=>t instanceof HTMLElement&&t.getAttribute("role")==="listbox",$n=t=>{const e=(t.getAttribute("aria-haspopup")||"").toLowerCase().includes("listbox"),r=Xt(t,["aria-controls"]).some(i=>vt(document.getElementById(i))),n=t.hasAttribute("aria-expanded"),a=(t.getAttribute("aria-label")||t.textContent||"").toLowerCase();return e||r||n||/\b(open|show|toggle|expand|menu|options|flyout|dropdown)\b/.test(a)};function jn(t){const e=[];for(let r=t.parentElement,n=0;r&&n<4;r=r.parentElement,n++)e.push(r);return e.flatMap(r=>Array.from(r.querySelectorAll("button"))).find(r=>r!==t&&!se(r)&&$n(r))||null}const Fn=()=>new Map(yt().map(t=>[t,{hidden:se(t),sig:Jt(t)}])),Bn=t=>Xt(t,["aria-controls","aria-owns"]).map(e=>document.getElementById(e)).filter(vt),Un=t=>yt().filter(e=>{const r=t.get(e);return se(e)?!1:!r||r.hidden?!0:Jt(e)!==r.sig}),Zn=t=>Array.from(t.querySelectorAll('[role="listbox"]')),Vn=t=>vt(t)?[t]:[],Qt=t=>{for(const e of["mouseover","mousedown","mouseup"])t.dispatchEvent(new MouseEvent(e,{bubbles:!0,cancelable:!0}));t.click()},Hn=()=>new Promise(t=>requestAnimationFrame(()=>t())),Yt=(t,e)=>({allListboxes:yt(),roots:Pn([...Bn(t),...Un(e),...Zn(t),...Vn(t)])}),er=async(t,e)=>{let r=Yt(t,e);for(let n=0;n<10&&r.roots.length===0;n++)await Hn(),r=Yt(t,e);return r};async function Wn(t){const e=t.getAttribute("aria-controls"),r=Fn();Qt(t);let{roots:n,allListboxes:a}=await er(t,r);if(n.length===0){const o=jn(t);o&&(Qt(o),{roots:n,allListboxes:a}=await er(t,r))}const i=t.getAttribute("aria-controls"),s=n.map(o=>o.id).filter(Boolean);return{roots:n,searchedIds:s,allListboxes:a,ariaControlsBefore:e,ariaControlsAfter:i}}const Kn=100;function _t(t){const e=ge(t),n=ge(e.options??e).max_nodes??e.max_nodes;let a=1e4;return typeof n=="number"&&Number.isFinite(n)?a=n:typeof n=="bigint"&&(a=Number(n)),Math.max(1,Math.min(5e4,Math.floor(a)))}function zn(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 Gn(t,e){return{top:t==="down"?e:t==="up"?-e:0,left:t==="right"?e:t==="left"?-e:0}}function tr(t,e){const r=e==="y"?t.overflowY:t.overflowX;return r==="auto"||r==="scroll"||r==="overlay"}function rr(t,e){const r=window.getComputedStyle(t);return e==="up"||e==="down"?!tr(r,"y")||t.scrollHeight<=t.clientHeight?!1:e==="down"?t.scrollTop<t.scrollHeight-t.clientHeight:t.scrollTop>0:!tr(r,"x")||t.scrollWidth<=t.clientWidth?!1:e==="right"?t.scrollLeft<t.scrollWidth-t.clientWidth:t.scrollLeft>0}function Jn(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 Xn(t){const e=document.activeElement;if(e instanceof HTMLElement&&rr(e,t))return e;let r=null,n=0;for(const a of Array.from(document.querySelectorAll("*"))){if(a===document.body||a===document.documentElement||!rr(a,t))continue;const i=Jn(a);i>n&&(r=a,n=i)}return r}function Qn(t){const e=ge(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}const Yn={click:t=>{const e=t.refId,r=t.label;let n;return e?n=ft(e,"click"):r?n=hn(r,"click"):Se(e,r,!0),z(n,"click"),n.click(),O("click",n,{observationId:Te(),dispatched:!0,verification:"required"})},fill:t=>{const e=t.refId,r=t.label,n=t.value;let a;if(e?a=ft(e,"fill"):r?(a=bt(r),a||Se(e,r,!0)):Se(e,r,!0),z(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 gt("fill",a,s,n),O("fill",a,{value:a.value,observationId:Te(),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:Te(),dispatched:!0,verification:"required"})}throw new Error("Element is not an input or contenteditable")},set_files:async t=>{var o,d;const e=Rn(t),r=G(t.refId,t.label);let n;if(r instanceof HTMLInputElement&&r.type==="file")n=r;else{const l=r.querySelector('input[type="file"]'),p=(o=r.closest("label"))==null?void 0:o.querySelector('input[type="file"]'),S=r.getAttribute("for"),A=S?(d=document.getElementById(S))==null?void 0:d.querySelector('input[type="file"]'):null,$=l??p??A;if(!$){const K=t.refId??"";R(ue("setFiles",K,{reason:"not_file_input"}))}n=$}const a=new DataTransfer,i=[];for(const l of e){const p=l.kind==="bytes"?On(l):await Mn(l);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 qn(n,s,i),O("setFiles",n,{fileCount:i.length,fileNames:i})},type:t=>{const e=t.refId,r=t.label,n=t.text,a=G(e,r);if(z(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 gt("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=G(e,r);if(z(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 d=e||a.getAttribute("data-ref-id")||"";return gt("append",a,d,s),O("append",a,{text:a.value})}throw new Error("Element is not an input")},press:t=>{pn()||R(Ar("press"));const e=t.key,r=t.refId,n=t.label;let a=document,i=null;(r||n)&&(r?i=ft(r,"press"):n&&(i=bt(n),i||Se(r,n,!0)),z(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:Te(),dispatched:!0,verification:"required"})},select:t=>{const e=t.refId,r=t.label,n=t.value,a=G(e,r);if(z(a,"select"),a instanceof HTMLSelectElement){if(Array.isArray(n)){const i=new Set(n);let s=0;for(const d of Array.from(a.options)){const l=i.has(d.value);d.selected=l,l&&(s+=1)}!a.multiple&&s>1&&R(ue("select",e??"",{reason:"single_select_multiple_values"})),a.dispatchEvent(new Event("change",{bubbles:!0}));const o=Array.from(a.options).filter(d=>d.selected).map(d=>d.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:async t=>{const e=t.value,r=G(t.refId,t.label);if(z(r,"select_option"),r instanceof HTMLSelectElement){const A=Array.from(r.options).find($=>($.text||"").trim()===e)||Array.from(r.options).find($=>($.text||"").trim().toLowerCase()===e.toLowerCase());if(!A){const $=Array.from(r.options).map((K,Ot)=>({refId:`opt${Ot}`,name:(K.text||"").trim()||void 0}));R(ke(e,$))}return r.value=A.value,r.dispatchEvent(new Event("change",{bubbles:!0})),O("select_option",r,{value:A.value,selectedText:(A.text||"").trim(),verification:"required"})}const n=r,{roots:a,searchedIds:i,allListboxes:s,ariaControlsBefore:o,ariaControlsAfter:d}=await Wn(n),l=[...new Set(a.flatMap(A=>Array.from(A.querySelectorAll('[role="option"]'))))],p=e.trim().toLowerCase(),S=l.find(A=>(A.textContent||"").trim()===e.trim())||l.find(A=>(A.textContent||"").trim().toLowerCase()===p);if(!S){const A=l.map((K,Ot)=>({refId:K.getAttribute("data-ref-id")||`opt${Ot}`,name:(K.textContent||"").trim()||void 0})),$=s.filter(K=>!a.includes(K)&&!se(K)).map(K=>K.id).filter(Boolean);R(ke(e,A,{searchedIds:i,ignoredIds:$,targetRefId:n.getAttribute("data-ref-id")||void 0,targetName:n.getAttribute("aria-label")||n.getAttribute("data-ref-id")||"",ariaControlsBefore:o,ariaControlsAfter:d,isDropdown:!0}))}for(const A of["mouseover","mousedown","mouseup"])S.dispatchEvent(new MouseEvent(A,{bubbles:!0,cancelable:!0}));return S.click(),O("select_option",r,{value:r instanceof HTMLInputElement?r.value:e,selectedText:(S.textContent||"").trim(),verification:"required"})},check:t=>{const e=t.refId,r=t.label,n=t.checked??!0,a=G(e,r);if(z(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(ke(`radio group "${e}"`,[]));const i=a.find(s=>s.value===r);if(!i){const s=a.map((o,d)=>({refId:`radio${d}`,name:o.value||void 0}));R(ke(`radio value "${r}" in group "${e}"`,s))}return z(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=G(e,r);z(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=G(e,r);let a=null;n instanceof HTMLFormElement?a=n:n.closest("form")&&(a=n.closest("form")),a||R(ue("submit",e??"",{reason:"not_form"})),typeof a.requestSubmit=="function"?a.requestSubmit():a.dispatchEvent(new Event("submit",{bubbles:!0,cancelable:!0}));const i=a.checkValidity();return O("submit",a,{dispatched:!0,valid:i,invalid:!i,invalidControls:Dn(a),observationId:Te(),verification:"required"})},scroll:t=>{pt();const e=t.direction,r=t.amount,{top:n,left:a}=Gn(e,r),i=Xn(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=G(e,r),a=n;return a.click(),a.click(),a.dispatchEvent(new MouseEvent("dblclick",{bubbles:!0,cancelable:!0})),O("dblclick",n)},forward:()=>(pt(),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=G(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=Qn(t);return new Function(e)()},back:()=>(pt(),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=_t(t);return me.debug("snapshot",{maxNodes:e,hasBody:!!document.body}),ht(e)},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=_t(t);return lt(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=_t(t),r=lt(e),n=t.filter??{};return{text:"",nodes:Cn(r.nodes,n),url:r.url,title:r.title,viewport:r.viewport}},find:t=>{at();const e=t.selector,r=Array.from(document.querySelectorAll(e)),n=[],a=r.map(i=>{var S;const s=Ve(i);n.push({refId:s,element:i});const o=F(i),d=te(i),l={tag:i.tagName.toLowerCase(),refId:s,role:o,text:((S=i.textContent)==null?void 0:S.slice(0,100))||"",...He(i)};d&&(l.name=d);const p=i.tagName.toLowerCase();if(p==="a"){const A=ie(i.getAttribute("href"));A&&(l.href=A)}if(p==="img"){const A=ie(i.getAttribute("src"));A&&(l.src=A),l.alt=i.getAttribute("alt")||""}if(p==="input"){const A=i.getAttribute("title");A&&(l.title=A)}if(p==="img"||p==="a"){const A=jt(i);A&&(l.parentRefId=A)}return l});return ut(n),a},dom:t=>{at();const e=t.selector,r=t.depth??2,n=t.includeHidden??!0,a=Array.from(document.querySelectorAll(e)),i=[],s=a.map(o=>Gt(o,r,n,i)).filter(o=>o!==null);return ut(i),{nodes:s,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 zn(Kn,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 d;return{tag:o.tagName,text:((d=o.textContent)==null?void 0:d.trim().slice(0,200))||""}})}else if(i==="links"){const s=Array.from(document.querySelectorAll("a[href]"));r.links=s.map(o=>{var d;return{href:o.getAttribute("href"),text:((d=o.textContent)==null?void 0:d.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,d=()=>o.abort();if(e){if(e.aborted)throw new DOMException("Aborted","AbortError");e.addEventListener("abort",d,{once:!0})}const l=setTimeout(()=>o.abort(),s);try{const p={method:n,headers:a,signal:o.signal};i!==null&&(p.body=i);const S=await fetch(r,p);return Sn(S)}finally{clearTimeout(l),e==null||e.removeEventListener("abort",d)}}};function Ge(t){return t==null?{}:t instanceof Map?Object.fromEntries([...t.entries()].map(([e,r])=>[e,Ge(r)])):Array.isArray(t)?t.map(Ge):t}var N;(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})(N||(N={}));var nr;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(nr||(nr={}));const b=N.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),oe=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=N.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 B 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,d=0;for(;d<s.path.length;){const l=s.path[d];d===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],d++}}};return a(this),n}static assert(e){if(!(e instanceof B))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,N.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()}}B.create=t=>new B(t);const Ae=(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,N.jsonStringifyReplacer)}`;break;case f.unrecognized_keys:r=`Unrecognized key(s) in object: ${N.joinValues(t.keys,", ")}`;break;case f.invalid_union:r="Invalid input";break;case f.invalid_union_discriminator:r=`Invalid discriminator value. Expected ${N.joinValues(t.options)}`;break;case f.invalid_enum_value:r=`Invalid enum value. Expected ${N.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}"`:N.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,N.assertNever(t)}return{message:r}};let ea=Ae;function wt(){return ea}const xt=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 d=n.filter(l=>!!l).slice().reverse();for(const l of d)o=l(s,{data:e,defaultError:o}).message;return{...a,path:i,message:o}};function m(t,e){const r=wt(),n=xt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Ae?void 0:Ae].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 w;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 w;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 w=Object.freeze({status:"aborted"}),Ce=t=>({status:"dirty",value:t}),P=t=>({status:"valid",value:t}),ar=t=>t.status==="aborted",ir=t=>t.status==="dirty",ye=t=>t.status==="valid",Je=t=>typeof Promise<"u"&&t instanceof Promise;var y;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(y||(y={}));class J{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 sr=(t,e)=>{if(ye(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 B(t.common.issues);return this._error=r,this._error}}};function k(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:d}=t;return s.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:d??n??o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:d??r??o.defaultError}},description:a}}class E{get description(){return this._def.description}_getType(e){return oe(e.data)}_getOrReturnCtx(e,r){return r||{common:e.parent.common,data:e.data,parsedType:oe(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:oe(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){const r=this._parse(e);if(Je(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:oe(e)},a=this._parseSync({data:e,path:n.path,parent:n});return sr(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:oe(e)};if(!this["~standard"].async)try{const i=this._parseSync({data:e,path:[],parent:r});return ye(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=>ye(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:oe(e)},a=this._parse({data:e,path:n.path,parent:n}),i=await(Je(a)?a:Promise.resolve(a));return sr(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(d=>d?!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 ne({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 H.create(this,this._def)}nullable(){return de.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return V.create(this)}promise(){return we.create(this,this._def)}or(e){return Oe.create([this,e],this._def)}and(e){return Me.create(this,e,this._def)}transform(e){return new ne({...k(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new $e({...k(this._def),innerType:this,defaultValue:r,typeName:x.ZodDefault})}brand(){return new Nt({typeName:x.ZodBranded,type:this,...k(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new je({...k(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 et.create(this,e)}readonly(){return Fe.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const ta=/^c[^\s-]{8,}$/i,ra=/^[0-9a-z]+$/,na=/^[0-9A-HJKMNP-TV-Z]{26}$/i,aa=/^[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,ia=/^[a-z0-9_-]{21}$/i,sa=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,oa=/^[-+]?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)?)??$/,ca=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,la="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let kt;const da=/^(?:(?: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])$/,ua=/^(?:(?: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])$/,pa=/^(([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]))$/,fa=/^(([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])$/,ha=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ma=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,or="((\\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])))",ba=new RegExp(`^${or}$`);function cr(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 ga(t){return new RegExp(`^${cr(t)}$`)}function ya(t){let e=`${or}T${cr(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 va(t,e){return!!((e==="v4"||!e)&&da.test(t)||(e==="v6"||!e)&&pa.test(t))}function _a(t,e){if(!sa.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 wa(t,e){return!!((e==="v4"||!e)&&ua.test(t)||(e==="v6"||!e)&&fa.test(t))}class X extends E{_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}),w}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")ca.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")kt||(kt=new RegExp(la,"u")),kt.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")aa.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")ia.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")ta.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")ra.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")na.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"?ya(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"?ba.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:f.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?ga(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"?oa.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"duration",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?va(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"?_a(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"?wa(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"?ha.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"base64",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?ma.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"base64url",code:f.invalid_string,message:i.message}),n.dirty()):N.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,...y.errToObj(n)})}_addCheck(e){return new X({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...y.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,...y.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,...y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...y.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...y.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...y.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...y.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...y.errToObj(r)})}nonempty(e){return this.min(1,y.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,...k(t)});function xa(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 E{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}),w}let n;const a=new L;for(const i of this._def.checks)i.kind==="int"?N.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"?xa(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()):N.assertNever(i);return{status:a.value,value:e.data}}gte(e,r){return this.setLimit("min",e,!0,y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,y.toString(r))}setLimit(e,r,n,a){return new pe({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:y.toString(a)}]})}_addCheck(e){return new pe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.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"&&N.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,...k(t)});class fe extends E{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()):N.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}),w}gte(e,r){return this.setLimit("min",e,!0,y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,y.toString(r))}setLimit(e,r,n,a){return new fe({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:y.toString(a)}]})}_addCheck(e){return new fe({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:y.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}}fe.create=t=>new fe({checks:[],typeName:x.ZodBigInt,coerce:(t==null?void 0:t.coerce)??!1,...k(t)});class Xe extends E{_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}),w}return P(e.data)}}Xe.create=t=>new Xe({typeName:x.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...k(t)});class Ne extends E{_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}),w}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_date}),w}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()):N.assertNever(i);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new Ne({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:y.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}}Ne.create=t=>new Ne({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:x.ZodDate,...k(t)});class lr extends E{_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}),w}return P(e.data)}}lr.create=t=>new lr({typeName:x.ZodSymbol,...k(t)});class Qe extends E{_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}),w}return P(e.data)}}Qe.create=t=>new Qe({typeName:x.ZodUndefined,...k(t)});class Re extends E{_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}),w}return P(e.data)}}Re.create=t=>new Re({typeName:x.ZodNull,...k(t)});class It extends E{constructor(){super(...arguments),this._any=!0}_parse(e){return P(e.data)}}It.create=t=>new It({typeName:x.ZodAny,...k(t)});class he extends E{constructor(){super(...arguments),this._unknown=!0}_parse(e){return P(e.data)}}he.create=t=>new he({typeName:x.ZodUnknown,...k(t)});class ce extends E{_parse(e){const r=this._getOrReturnCtx(e);return m(r,{code:f.invalid_type,expected:b.never,received:r.parsedType}),w}}ce.create=t=>new ce({typeName:x.ZodNever,...k(t)});class Tt extends E{_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}),w}return P(e.data)}}Tt.create=t=>new Tt({typeName:x.ZodVoid,...k(t)});class V extends E{_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}),w;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 J(r,s,r.path,o)))).then(s=>L.mergeArray(n,s));const i=[...r.data].map((s,o)=>a.type._parseSync(new J(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:y.toString(r)}})}max(e,r){return new V({...this._def,maxLength:{value:e,message:y.toString(r)}})}length(e,r){return new V({...this._def,exactLength:{value:e,message:y.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,...k(e)});function ve(t){if(t instanceof M){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=H.create(ve(n))}return new M({...t._def,shape:()=>e})}else return t instanceof V?new V({...t._def,type:ve(t.element)}):t instanceof H?H.create(ve(t.unwrap())):t instanceof de?de.create(ve(t.unwrap())):t instanceof Q?Q.create(t.items.map(e=>ve(e))):t}class M extends E{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=N.objectKeys(e);return this._cached={shape:e,keys:r},this._cached}_parse(e){if(this._getType(e)!==b.object){const l=this._getOrReturnCtx(e);return m(l,{code:f.invalid_type,expected:b.object,received:l.parsedType}),w}const{status:n,ctx:a}=this._processInputParams(e),{shape:i,keys:s}=this._getCached(),o=[];if(!(this._def.catchall instanceof ce&&this._def.unknownKeys==="strip"))for(const l in a.data)s.includes(l)||o.push(l);const d=[];for(const l of s){const p=i[l],S=a.data[l];d.push({key:{status:"valid",value:l},value:p._parse(new J(a,S,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof ce){const l=this._def.unknownKeys;if(l==="passthrough")for(const p of o)d.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(l==="strict")o.length>0&&(m(a,{code:f.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const p of o){const S=a.data[p];d.push({key:{status:"valid",value:p},value:l._parse(new J(a,S,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const l=[];for(const p of d){const S=await p.key,A=await p.value;l.push({key:S,value:A,alwaysSet:p.alwaysSet})}return l}).then(l=>L.mergeObjectSync(n,l)):L.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new M({...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:y.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new M({...this._def,unknownKeys:"strip"})}passthrough(){return new M({...this._def,unknownKeys:"passthrough"})}extend(e){return new M({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new M({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 M({...this._def,catchall:e})}pick(e){const r={};for(const n of N.objectKeys(e))e[n]&&this.shape[n]&&(r[n]=this.shape[n]);return new M({...this._def,shape:()=>r})}omit(e){const r={};for(const n of N.objectKeys(this.shape))e[n]||(r[n]=this.shape[n]);return new M({...this._def,shape:()=>r})}deepPartial(){return ve(this)}partial(e){const r={};for(const n of N.objectKeys(this.shape)){const a=this.shape[n];e&&!e[n]?r[n]=a:r[n]=a.optional()}return new M({...this._def,shape:()=>r})}required(e){const r={};for(const n of N.objectKeys(this.shape))if(e&&!e[n])r[n]=this.shape[n];else{let i=this.shape[n];for(;i instanceof H;)i=i._def.innerType;r[n]=i}return new M({...this._def,shape:()=>r})}keyof(){return dr(N.objectKeys(this.shape))}}M.create=(t,e)=>new M({shape:()=>t,unknownKeys:"strip",catchall:ce.create(),typeName:x.ZodObject,...k(e)}),M.strictCreate=(t,e)=>new M({shape:()=>t,unknownKeys:"strict",catchall:ce.create(),typeName:x.ZodObject,...k(e)}),M.lazycreate=(t,e)=>new M({shape:t,unknownKeys:"strip",catchall:ce.create(),typeName:x.ZodObject,...k(e)});class Oe extends E{_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 B(o.ctx.common.issues));return m(r,{code:f.invalid_union,unionErrors:s}),w}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 d of n){const l={...r,common:{...r.common,issues:[]},parent:null},p=d._parseSync({data:r.data,path:r.path,parent:l});if(p.status==="valid")return p;p.status==="dirty"&&!i&&(i={result:p,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const o=s.map(d=>new B(d));return m(r,{code:f.invalid_union,unionErrors:o}),w}}get options(){return this._def.options}}Oe.create=(t,e)=>new Oe({options:t,typeName:x.ZodUnion,...k(e)});const re=t=>t instanceof Le?re(t.schema):t instanceof ne?re(t.innerType()):t instanceof Pe?[t.value]:t instanceof le?t.options:t instanceof At?N.objectValues(t.enum):t instanceof $e?re(t._def.innerType):t instanceof Qe?[void 0]:t instanceof Re?[null]:t instanceof H?[void 0,...re(t.unwrap())]:t instanceof de?[null,...re(t.unwrap())]:t instanceof Nt||t instanceof Fe?re(t.unwrap()):t instanceof je?re(t._def.innerType):[];class Ye extends E{_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}),w;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]}),w)}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=re(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 Ye({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:a,...k(n)})}}function St(t,e){const r=oe(t),n=oe(e);if(t===e)return{valid:!0,data:t};if(r===b.object&&n===b.object){const a=N.objectKeys(e),i=N.objectKeys(t).filter(o=>a.indexOf(o)!==-1),s={...t,...e};for(const o of i){const d=St(t[o],e[o]);if(!d.valid)return{valid:!1};s[o]=d.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],d=St(s,o);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return r===b.date&&n===b.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Me extends E{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),a=(i,s)=>{if(ar(i)||ar(s))return w;const o=St(i.value,s.value);return o.valid?((ir(i)||ir(s))&&r.dirty(),{status:r.value,value:o.data}):(m(n,{code:f.invalid_intersection_types}),w)};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}))}}Me.create=(t,e,r)=>new Me({left:t,right:e,typeName:x.ZodIntersection,...k(r)});class Q extends E{_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}),w;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"}),w;!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 d=this._def.items[o]||this._def.rest;return d?d._parse(new J(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 Q({...this._def,rest:e})}}Q.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Q({items:t,typeName:x.ZodTuple,rest:null,...k(e)})};class qe extends E{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}),w;const a=[],i=this._def.keyType,s=this._def.valueType;for(const o in n.data)a.push({key:i._parse(new J(n,o,n.path,o)),value:s._parse(new J(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 E?new qe({keyType:e,valueType:r,typeName:x.ZodRecord,...k(n)}):new qe({keyType:X.create(),valueType:e,typeName:x.ZodRecord,...k(r)})}}class Et extends E{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}),w;const a=this._def.keyType,i=this._def.valueType,s=[...n.data.entries()].map(([o,d],l)=>({key:a._parse(new J(n,o,n.path,[l,"key"])),value:i._parse(new J(n,d,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of s){const l=await d.key,p=await d.value;if(l.status==="aborted"||p.status==="aborted")return w;(l.status==="dirty"||p.status==="dirty")&&r.dirty(),o.set(l.value,p.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const d of s){const l=d.key,p=d.value;if(l.status==="aborted"||p.status==="aborted")return w;(l.status==="dirty"||p.status==="dirty")&&r.dirty(),o.set(l.value,p.value)}return{status:r.value,value:o}}}}Et.create=(t,e,r)=>new Et({valueType:e,keyType:t,typeName:x.ZodMap,...k(r)});class _e extends E{_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}),w;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(d){const l=new Set;for(const p of d){if(p.status==="aborted")return w;p.status==="dirty"&&r.dirty(),l.add(p.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((d,l)=>i._parse(new J(n,d,n.path,l)));return n.common.async?Promise.all(o).then(d=>s(d)):s(o)}min(e,r){return new _e({...this._def,minSize:{value:e,message:y.toString(r)}})}max(e,r){return new _e({...this._def,maxSize:{value:e,message:y.toString(r)}})}size(e,r){return this.min(e,r).max(e,r)}nonempty(e){return this.min(1,e)}}_e.create=(t,e)=>new _e({valueType:t,minSize:null,maxSize:null,typeName:x.ZodSet,...k(e)});class De extends E{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}),w;function n(o,d){return xt({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,wt(),Ae].filter(l=>!!l),issueData:{code:f.invalid_arguments,argumentsError:d}})}function a(o,d){return xt({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,wt(),Ae].filter(l=>!!l),issueData:{code:f.invalid_return_type,returnTypeError:d}})}const i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof we){const o=this;return P(async function(...d){const l=new B([]),p=await o._def.args.parseAsync(d,i).catch($=>{throw l.addIssue(n(d,$)),l}),S=await Reflect.apply(s,this,p);return await o._def.returns._def.type.parseAsync(S,i).catch($=>{throw l.addIssue(a(S,$)),l})})}else{const o=this;return P(function(...d){const l=o._def.args.safeParse(d,i);if(!l.success)throw new B([n(d,l.error)]);const p=Reflect.apply(s,this,l.data),S=o._def.returns.safeParse(p,i);if(!S.success)throw new B([a(p,S.error)]);return S.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new De({...this._def,args:Q.create(e).rest(he.create())})}returns(e){return new De({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new De({args:e||Q.create([]).rest(he.create()),returns:r||he.create(),typeName:x.ZodFunction,...k(n)})}}class Le extends E{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,...k(e)});class Pe extends E{_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}),w}return{status:"valid",value:e.data}}get value(){return this._def.value}}Pe.create=(t,e)=>new Pe({value:t,typeName:x.ZodLiteral,...k(e)});function dr(t,e){return new le({values:t,typeName:x.ZodEnum,...k(e)})}class le extends E{_parse(e){if(typeof e.data!="string"){const r=this._getOrReturnCtx(e),n=this._def.values;return m(r,{expected:N.joinValues(n),received:r.parsedType,code:f.invalid_type}),w}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}),w}return P(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 le.create(e,{...this._def,...r})}exclude(e,r=this._def){return le.create(this.options.filter(n=>!e.includes(n)),{...this._def,...r})}}le.create=dr;class At extends E{_parse(e){const r=N.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==b.string&&n.parsedType!==b.number){const a=N.objectValues(r);return m(n,{expected:N.joinValues(a),received:n.parsedType,code:f.invalid_type}),w}if(this._cache||(this._cache=new Set(N.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){const a=N.objectValues(r);return m(n,{received:n.data,code:f.invalid_enum_value,options:a}),w}return P(e.data)}get enum(){return this._def.values}}At.create=(t,e)=>new At({values:t,typeName:x.ZodNativeEnum,...k(e)});class we extends E{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}),w;const n=r.parsedType===b.promise?r.data:Promise.resolve(r.data);return P(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}we.create=(t,e)=>new we({type:t,typeName:x.ZodPromise,...k(e)});class ne extends E{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 w;const d=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return d.status==="aborted"?w:d.status==="dirty"||r.value==="dirty"?Ce(d.value):d});{if(r.value==="aborted")return w;const o=this._def.schema._parseSync({data:s,path:n.path,parent:n});return o.status==="aborted"?w:o.status==="dirty"||r.value==="dirty"?Ce(o.value):o}}if(a.type==="refinement"){const s=o=>{const d=a.refinement(o,i);if(n.common.async)return Promise.resolve(d);if(d 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"?w:(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"?w:(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(!ye(s))return w;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=>ye(s)?Promise.resolve(a.transform(s.value,i)).then(o=>({status:r.value,value:o})):w);N.assertNever(a)}}ne.create=(t,e,r)=>new ne({schema:t,typeName:x.ZodEffects,effect:e,...k(r)}),ne.createWithPreprocess=(t,e,r)=>new ne({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...k(r)});class H extends E{_parse(e){return this._getType(e)===b.undefined?P(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}H.create=(t,e)=>new H({innerType:t,typeName:x.ZodOptional,...k(e)});class de extends E{_parse(e){return this._getType(e)===b.null?P(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}de.create=(t,e)=>new de({innerType:t,typeName:x.ZodNullable,...k(e)});class $e extends E{_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}}$e.create=(t,e)=>new $e({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});class je extends E{_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 Je(a)?a.then(i=>({status:"valid",value:i.status==="valid"?i.value:this._def.catchValue({get error(){return new B(n.common.issues)},input:n.data})})):{status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new B(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}}je.create=(t,e)=>new je({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});class Ct extends E{_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}),w}return{status:"valid",value:e.data}}}Ct.create=t=>new Ct({typeName:x.ZodNaN,...k(t)});class Nt extends E{_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 et extends E{_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"?w:i.status==="dirty"?(r.dirty(),Ce(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"?w: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 et({in:e,out:r,typeName:x.ZodPipeline})}}class Fe extends E{_parse(e){const r=this._def.innerType._parse(e),n=a=>(ye(a)&&(a.value=Object.freeze(a.value)),a);return Je(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Fe.create=(t,e)=>new Fe({innerType:t,typeName:x.ZodReadonly,...k(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,Y=fe.create,g=Xe.create,ur=Re.create,_=he.create;ce.create;const T=V.create,u=M.create,I=Oe.create,ka=Ye.create;Me.create;const Ia=Q.create,v=qe.create,Ta=Le.create,Be=Pe.create,Ue=le.create;we.create,H.create,de.create;const ae=ne.createWithPreprocess;function D(t,e=0,r=2){if(e>r)return"...";if(t instanceof M){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],d=o instanceof H,l=D(d?o.unwrap():o,e+1,r);return`${s}${d?"?":""}: ${l}`}).join(", ")} }`}if(t instanceof Oe)return t.options.map(n=>D(n,e,r)).join(" or ");if(t instanceof X)return"string";if(t instanceof pe)return"number";if(t instanceof Xe)return"boolean";if(t instanceof fe)return"bigint";if(t instanceof Re)return"null";if(t instanceof V){const n=D(t.element,e+1,r);return n==="unknown"||n==="any"?"array":`${n}[]`}if(t instanceof Q)return`[${t.items.map(n=>D(n,e+1,r)).join(", ")}]`;if(t instanceof qe){const n=D(t._def.valueType,e+1,r);return n==="unknown"||n==="any"?"{ [key: string]: unknown }":`{ [key: string]: ${n} }`}return t instanceof H?`${D(t.unwrap(),e,r)}?`:t instanceof Pe?JSON.stringify(t.value):t instanceof le?t.options.map(n=>`"${n}"`).join(" | "):t instanceof It?"any":t instanceof he?"unknown":t instanceof Tt?"void":t instanceof Qe?"undefined":t instanceof ne?D(t.innerType(),e,r):t instanceof $e?D(t.removeDefault(),e,r):t instanceof de?`${D(t.unwrap(),e,r)} | null`:t instanceof Le?"lazy":t instanceof we?`Promise<${D(t.unwrap(),e+1,r)}>`:t instanceof De?"function":t instanceof Ne?"Date":t instanceof Et?"Map":t instanceof _e?"Set":t instanceof Me?`${D(t._def.left,e,r)} & ${D(t._def.right,e,r)}`:t instanceof Ye?t.options.map(n=>D(n,e,r)).join(" or "):t instanceof Nt?D(t.unwrap(),e,r):t instanceof Ct?"NaN":t instanceof je?D(t.removeCatch(),e,r):t instanceof et?D(t._def.in,e,r):t instanceof Fe?`readonly ${D(t.unwrap(),e,r)}`:"unknown"}function Sa(t){return t===null?"null":t===void 0?"undefined":Array.isArray(t)?"array":typeof t}function Ea(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(l=>l.code==="custom"),d=a.some(l=>l.code!=="invalid_type"&&l.code!=="invalid_literal"&&l.code!=="invalid_union");if(!o&&!d){const l=D(e),p=Sa(n);return`Invalid parameters for ${t}: expected ${l}${l==="{ }"?" 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 Aa(t,e,r,n,a){const i=t.safeParse(Ge(n));if(!i.success)return{ok:!1,error:{message:Ea(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 d=o.error.issues.map(l=>{const p=l.path.join(".");return`invalid return value${p?` at '${p}'`:""} (${l.message})`});return{ok:!1,error:{message:`Invalid return value for ${a}: ${d.join("; ")}`,code:"E_INVALID_RETURN",category:"validation"}}}return{ok:!0,value:o.data}}catch(s){const o=Dt(s),d=o.code==="E_EXTENSION"&&(typeof s!="object"||s===null||!("code"in s));return{ok:!1,error:{...o,code:d?"E_HANDLER":o.code,message:`${a}: ${o.message}`}}}}const pr=new Map,tt=new Map;function Ca(t){pr.set(t.registryAction,t)}function rt(t){return pr.get(t)}function Na(t){for(const e of t)Ca(e);try{chrome.runtime.sendMessage({type:"contentScriptReady"})}catch{}}function Ra(t){const e=tt.get(t);return e?(e.abort(),tt.delete(t),!0):!1}async function Oa(t,e,r,n,a){const i=rt(t);if(!i)return{ok:!1,error:{message:`No schema registered for content-script action: ${t}`,code:"E_INTERNAL"}};const s=new AbortController;a&&tt.set(a,s);try{return await Aa(i.params,i.returns,async o=>r(o,s.signal),Ge(n),t)}finally{a&&tt.delete(a)}}function Ma(t,e){if(rt(t))return t;const r=`page_${e}`;return rt(r)?r:t}function qa(t,e){const r=rt(t);return(r==null?void 0:r.handlerKey)??e}function fr(t,e,r,n,a){const i=Ma(t,e),s=qa(i,e),o=Yn[s];return o?(Oa(i,s,o,r,a).then(l=>{me.debug("dispatch_response",{registryAction:t,handlerAction:s,ok:l.ok}),n(l)}).catch(l=>{const p=Dt(l,{});me.debug("dispatch_error",{registryAction:t,handlerAction:s,error:p.message}),n({ok:!1,error:p})}),!0):(me.debug("no_handler",{action:s,registryAction:t}),n({ok:!1,error:`Unknown content script action: ${s}`}),!1)}function Da(){chrome.runtime.onMessage.addListener((t,e,r)=>{if(e.id!==chrome.runtime.id)return me.warn("unauthorized_sender",{senderId:e.id,expected:chrome.runtime.id}),r({ok:!1,error:"Unauthorized sender"}),!1;const n=ge(t),a=String(n.type??""),i=String(n.action??"");if(me.debug("received",{messageType:a,action:i,hasParams:!!n.params}),a==="registryCallCancel"){const s=String(n.id??"");return Ra(s),r({ok:!0}),!1}if(a==="registryCall"){const s=Ir(i),o=typeof n.id=="string"?n.id:void 0;return fr(i,s,n.params,r,o)}return!i&&a==="contract-ping"?(r({ok:!0}),!1):i?i==="ping"?fr("ping","ping",n.params,r):(r({ok:!1,error:"Use registryCall for content-script actions"}),!1):(r({ok:!1,error:"Missing action"}),!1)})}v(_()),v(_()),v(_()),v(_()),I([h(),v(_())]),I([h(),v(_())]),v(_()),v(_()),v(_()),I([c(),v(_())]),v(_()),v(_()),v(_()),v(_()),v(_()),I([c(),h(),v(_())]),v(_()),v(_()),v(_()),I([h(),v(_())]),v(_()),v(_()),v(_()),v(_()),v(_()),T(_()),I([c(),v(_())]),v(_()),I([c(),v(_())]),v(_()),I([c(),v(_())]),v(_()),I([c(),v(_())]),v(_()),v(_()),I([h(),v(_())]),v(_()),v(_()),I([h(),v(_())]),v(_()),I([c(),h(),v(_())]),v(_()),v(_()),v(_()),v(_()),I([h(),v(_())]),I([h(),v(_())]),I([h(),v(_())]),I([h(),v(_())]),I([h(),v(_())]),v(_()),v(_()),v(_()),u({}),I([Ia([I([u({text:c()}),c()])]),u({text:c().optional(),value:c().optional()})]);const U=()=>I([Y(),h().finite()]).transform(t=>BigInt(t)),Z=()=>c().regex(/^(?:f\d+_)?e\d+$/),La='use { refId: "e2" } or { label: "..." } object form, not positional arguments',Rt=(t,e)=>{if(t.__invalidPositional!==void 0){e.addIssue({code:f.custom,message:La});return}!t.refId&&!t.label&&e.addIssue({code:f.custom,message:"Either refId or label is required"})},hr=(t,e)=>{t.x!==void 0||t.y!==void 0||Rt(t,e)},q=t=>ae(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,u({__invalidPositional:I([c(),h()]).optional().describe("Internal flag for positional argument rejection"),refId:Z().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(Rt)),xe={tabId:I([h(),Y()]).optional().describe("Target tab ID")},W=t=>ae(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,u({__invalidPositional:I([c(),h()]).optional().describe("Internal flag for positional argument rejection"),...xe,refId:Z().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(Rt));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:U().describe("Byte offset to start reading"),len:h().describe("Number of bytes to read")}),u({path:c().describe("File path to update"),offset:U().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)")}),u({action:c().describe("Host action name"),params:u({}).passthrough().optional().describe("Parameters for the host action")}).passthrough();const Pa=I([c(),h(),g(),ur(),T(_()),v(_())]),$a=u({url:c().describe("URL to fetch"),method:c().default("GET").describe("HTTP method (GET, POST, PUT, DELETE, etc.)"),headers:v(c()).default({}).describe("Request headers as key-value pairs"),body:c().nullable().default(null).describe("Request body string"),timeout:U().default(30000n).describe("Timeout in milliseconds"),store:g().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:U().describe("Duration to sleep in milliseconds")}),u({}),u({}),u({url:c().describe("URL to navigate to"),timeout:U().optional().describe("Navigation timeout in milliseconds"),waitUntil:Ue(["load","networkidle"]).optional().describe("When to consider navigation complete: 'load' (tab status complete) or 'networkidle' (no in-flight requests for 500ms)")});const ja=u({}),Fa=u({});u({}),u({duration:U().default(1000n).describe("Duration to wait in milliseconds")});const Ba=q(),Ua=(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"})},mr=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(Ua),br=ka("kind",[u({kind:Be("bytes"),name:c().min(1),data:c().min(1),mimeType:c().optional()}),u({kind:Be("url"),url:c().url(),name:c().min(1),mimeType:c().optional()})]),Za=q({value:c().describe("Value to fill into the element")}),Va=q({files:T(mr).min(1).describe("Files to attach to the input")}),Ha=q({files:T(br).min(1).describe("Resolved files for content-script application")}),Wa=q({text:c().describe("Text to type into the element")}),Ka=q({text:c().describe("Text to append into the element")}),za=u({refId:Z().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)")}),Ga=q({value:I([c().describe("Value to select in the dropdown"),T(c()).describe("Values to select in a multiple dropdown (empty array clears selection)")]).describe("Value (string) or values (array) to select in the dropdown")}),Ja=q({value:c().describe("Visible text of the option to select (matched case-insensitively)")}),Xa=q({checked:g().optional().describe("Desired checked state (true to check, false to uncheck)")}),Qa=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")}),Ya=q(),ei=u({}),ti=q(),ri=u({direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:h().default(300).describe("Pixels to scroll")}),ni=ae(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,u({__invalidPositional:I([c(),h()]).optional().describe("Internal flag for positional argument rejection"),refId:Z().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(hr)),ai=q(),ii=u({selector:c().describe("CSS selector to find elements")}),si=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:g().default(!0).describe("Include elements hidden by CSS/aria (default true — this tool's purpose is to see what the curated snapshot filters out)")}),oi=u({selector:c().describe("CSS selector to wait for"),timeout:U().default(30000n).describe("Timeout in milliseconds")}),ci=u({fields:T(c()).describe("Array of field names to extract")}),li=ae(t=>Array.isArray(t)?{fields:t}:t,ci);I([h(),T(u({}).passthrough()),u({}).passthrough()]),u({});const C=u({ok:Be(!0).describe("Whether the action succeeded"),action:c().describe("Action identifier (e.g. 'page_fill')"),refId:Z().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:I([c(),T(c())]).optional().describe("Final value of the element after the action (string, or string[] for multi-select)"),checked:g().optional().describe("Checked state after the action"),disabled:g().optional().describe("Whether the element is disabled"),readOnly:g().optional().describe("Whether the element is read-only"),required:g().optional().describe("Whether the element is required"),valid:g().optional().describe("HTML constraint validity after the action, when available"),invalid:g().optional().describe("Inverse validity / aria-invalid state after the action"),validationMessage:c().optional().describe("Browser validation message when the element is invalid"),invalidControls:T(u({refId:Z().optional(),tag:c(),role:c().optional(),name:c().optional(),field:c().optional().describe("Accessible field label or nearest label text"),error:c().optional().describe("Linked visible error text from aria-errormessage/aria-describedby"),value:c().optional(),required:g().optional(),validationMessage:c().optional()})).optional().describe("Invalid form controls after submit, when available"),text:c().optional().describe("Text content of the element"),selectedText:c().optional().describe("Visible option text selected by select_option"),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:T(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:Be(!0).optional().describe("True if the action was dispatched to the DOM. Does NOT prove the application accepted it."),verification:Be("required").optional().describe("Always 'required': a fresh observation is required to verify the effect.")});I([C,ur()]);const gr=u({status:h().describe("HTTP response status code"),ok:g().describe("Whether the response status is 2xx"),headers:v(c()).describe("Response headers as key-value pairs"),body:c().optional().describe("Response body (omitted when bodyEncoding is handle)"),bodyEncoding:Ue(["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:Ue(["connected","missing"]),domApis:Ue(["ok","blocked"]),mutationsReady:g(),hint:c().optional(),recovery:T(c()).optional()});const di=Pa,ui=u({refId:Z().describe("Element reference ID (e.g. e2)"),role:c().describe("ARIA role of the element"),tag:c().describe("HTML tag name"),controlType:c().optional().describe('Plain-language control type, e.g. "dropdown" for combobox/select'),actionable:g().optional().describe("Whether this node can be acted on directly"),forControl:c().optional().describe("refId of the dropdown this validation-proxy belongs to"),recommendedAction:c().optional().describe("Recommended page.* action for this control"),controls:c().optional().describe("ID(s) of controlled popup/listbox elements, when exposed"),expanded:g().optional().describe("Expanded state for popup controls"),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"),required:g().optional().describe("Whether the element is required"),valid:g().optional().describe("Constraint validity state"),invalid:g().optional().describe("Constraint invalidity state"),validationMessage:c().optional().describe("Browser constraint validation message"),errorMessage:c().optional().describe("Visible error text linked to the field"),checked:g().optional().describe("Checked state"),disabled:g().optional().describe("Whether the element is disabled"),readOnly:g().optional().describe("Whether the element is read-only"),selected:g().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:Z().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:T(c()).optional().describe("Image URLs contained within this element")}),nt=u({text:c().describe("Broad text-first representation of the page, including visible text, form values, and validation/error text"),nodes:T(ui).describe("Broad snapshot nodes with refIds where possible; not limited to interactive elements"),formErrors:T(u({field:c().describe("Field label or refId"),error:c().describe("Linked visible error text"),refId:c().describe("refId of the invalid control")})).optional().describe("Visible linked form errors grouped by field"),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.")}),yr=u({refId:Z().optional(),tag:c(),role:c().optional(),name:c().optional(),text:c().optional(),attributes:v(c()).optional().describe("All HTML attributes (raw)"),hidden:g().optional(),hiddenReason:Ue(["display-none","visibility-hidden","aria-hidden","opacity-zero","hidden-attr","inert"]).optional(),value:c().optional(),checked:g().optional(),disabled:g().optional(),readOnly:g().optional(),selected:g().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"),controlType:c().optional(),recommendedAction:c().optional(),controls:c().optional(),expanded:g().optional(),children:T(Ta(()=>yr)).optional().describe("Nested descendants up to `depth`")}),pi=u({nodes:T(yr),url:c(),title:c()}),vr=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:g().optional().describe("Whether the tab is active"),pinned:g().optional().describe("Whether the tab is pinned"),highlighted:g().optional().describe("Whether the tab is highlighted"),incognito:g().optional().describe("Whether the tab is incognito"),favIconUrl:c().optional().describe("Favicon URL"),audible:g().optional().describe("Whether the tab is audible"),groupId:h().optional().describe("Group ID"),openerTabId:h().optional().describe("Opener tab ID"),discarded:g().optional().describe("Whether the tab is discarded"),autoDiscardable:g().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(),fi=T(vr),_r=u({id:h().optional().describe("Window ID"),focused:g().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:fi.optional().describe("Array of tabs in the window"),incognito:g().optional().describe("Whether the window is incognito"),type:c().optional().describe("Window type"),state:c().optional().describe("Window state"),alwaysOnTop:g().optional().describe("Whether the window is always on top"),sessionId:c().optional().describe("Session ID")}).passthrough();T(_r);const hi=u({name:c().describe("Cookie name"),value:c().describe("Cookie value"),domain:c().optional().describe("Cookie domain"),hostOnly:g().optional().describe("Whether the cookie is host-only"),path:c().optional().describe("Cookie path"),secure:g().optional().describe("Whether the cookie is secure"),httpOnly:g().optional().describe("Whether the cookie is HTTP-only"),sameSite:c().optional().describe("SameSite policy"),session:g().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();T(hi.nullable().unwrap());const mi=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:T(u({id:c()}).passthrough()).optional().describe("Child bookmarks")}).passthrough();T(mi);const bi=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();T(bi);const gi=u({frameId:h().describe("Frame ID"),result:_().optional().describe("Script result")});T(gi),c(),g(),I([c(),h()]),g();const yi=u({id:h().optional().describe("Group ID"),collapsed:g().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();T(yi);const vi=u({lastModified:h().optional().describe("Last modified time"),tab:vr.optional().describe("Tab info"),window:_r.optional().describe("Window info")}).passthrough(),_i=T(vi),wi=u({deviceName:c().optional().describe("Device name"),sessions:_i.optional().describe("Sessions")}).passthrough();T(wi);const xi=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:g().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:g().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();T(xi),h(),u({archName:c().describe("CPU architecture"),modelName:c().describe("CPU model"),numOfProcessors:h().describe("Number of processors"),features:T(c()).describe("CPU features")}),u({capacity:h().describe("Total memory capacity"),availableCapacity:h().describe("Available memory capacity")}),T(u({id:c().describe("Storage ID"),name:c().describe("Storage name"),type:c().describe("Storage type"),capacity:h().describe("Storage capacity")})),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:g().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:U().default(1000n).describe("Duration to wait in milliseconds")}),u({interactive_only:g().default(!1).describe("Only include interactive elements"),max_nodes:U().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:g().default(!1).describe("Only include interactive elements"),max_nodes:U().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:g().default(!1).describe("Only include interactive elements"),max_nodes:U().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:g().default(!1).describe("Only include interactive elements"),max_nodes:U().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 ki=u({max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Ii=u({max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Ti=u({max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Si=u({role:I([c(),T(c())]).optional().describe("Filter by ARIA role"),tag:I([c(),T(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:g().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(),wr=u({filter:Si.optional().describe("Semantic filter criteria"),max_nodes:h().optional().describe("Maximum nodes to collect before filtering")}).passthrough(),Ei=wr.extend({tabId:h().describe("Tab ID")});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 Ai=u({items:v(c()).describe("Record of key-value string pairs to store")});ae(t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!("items"in t)?{items:t}:t,Ai);const Ci=u({keys:T(c()).describe("Array of storage keys to retrieve"),defaults:v(c()).optional().describe("Default string values for missing keys")});ae(t=>Array.isArray(t)?{keys:t}:t,Ci),u({});const Ni=u({keys:T(c()).describe("Array of storage keys to delete")});ae(t=>Array.isArray(t)?{keys:t}:t,Ni),u({}),u({active:g().optional().describe("Whether the tabs are active"),currentWindow:g().optional().describe("Whether the tabs are in the current window"),url:c().optional().describe("URL pattern to match tabs against")}).passthrough(),ae(t=>typeof t=="string"?{url:t}:t,u({url:c().optional().describe("URL to open in the new tab"),active:g().optional().describe("Whether to focus the new tab")})),I([h(),T(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 Ri=W(),Oi=W({value:c().describe("Value to fill into the element")}),Mi=W({files:T(mr).min(1).describe("Files to attach to the input")}),qi=W({files:T(br).min(1).describe("Resolved files for content-script application")}),Di=ae(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,u({__invalidPositional:I([c(),h()]).optional().describe("Internal flag for positional argument rejection"),...xe,refId:Z().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(hr)),Li=W({text:c().describe("Text to type into the element")}),Pi=u({...xe,key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),$i=W({value:c().describe("Value to select in the dropdown")}),ji=W({value:c().describe("Visible text of the option to select (matched case-insensitively)")}),Fi=W({checked:g().optional().describe("Desired checked state (true to check, false to uncheck)")}),Bi=W(),Ui=W(),Zi=u({...xe,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")}),Vi=u({...xe}),Hi=u({...xe,direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:h().default(300).describe("Pixels to scroll")}),Wi=W(),Ki=u({tabId:I([h(),Y()]).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(),zi=u({tabId:I([h(),Y()]).optional().describe("Target tab ID")}).passthrough(),Gi=u({tabId:I([h(),Y()]).optional().describe("Target tab ID")}).passthrough();u({tabId:I([h(),Y()]).optional().describe("Target tab ID"),timeout:h().optional().describe("Timeout in milliseconds")}).passthrough();const Ji=u({tabId:I([h(),Y()]).optional().describe("Target tab ID"),url:c().optional().describe("URL to fetch"),options:u({}).passthrough().optional().describe("Fetch options")}).passthrough(),Xi=u({tabId:I([h(),Y()]).optional().describe("Target tab ID"),max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Qi=u({tabId:I([h(),Y()]).optional().describe("Target tab ID"),max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Yi=u({tabId:I([h(),Y()]).optional().describe("Target tab ID"),max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),j="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.",es=[{action:"page_back",namespace:"page",name:"back",description:"Go back in the active tab",params:ja,returns:C,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:Ba,returns:C,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:[j,"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:Za,returns:C,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:[j,"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:Va,returns:C,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:[j,"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:Wa,returns:C,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:[j,"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:Ka,returns:C,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:za,returns:C,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:Ga,returns:C,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:"Select a value from a dropdown/combobox (native select, react-select, ARIA listbox) by clicking the option whose visible text matches value",params:Ja,returns:C,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: degree.refId, value: "Bachelor's Degree" })`,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","RULE: every dropdown (combobox/select/listbox) MUST use page.select_option({refId, value}). NEVER page.fill, page.type, or page.click on a dropdown control or its validation-proxy input.","Use this for snapshot nodes printed as dropdown or nodes with controlType='dropdown'; do not use page.fill/type on those controls","Drives react-select and other ARIA combobox patterns: clicks the control to open, follows the controlled listbox where available, 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:Xa,returns:C,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:Ya,returns:C,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:ei,returns:C,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:ti,returns:C,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:Qa,returns:C,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:ri,returns:C,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:ni,returns:C,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:ai,returns:C,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:"page_forward",namespace:"page",name:"forward",description:"Go forward in the active tab",params:Fa,returns:C,paramTypes:[],returnDoc:"Navigation result",errorCode:"E_NO_TAB",example:"page.forward()",handlerKey:"forward"},{action:"page_snapshot",namespace:"page",name:"snapshot",description:"Capture a broad, text-first page snapshot. Default behavior is intentionally generous: visible text, form values, required/invalid state, and linked field error text are included with actionable refIds where possible.",params:ki,returns:c(),paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal). Defaults high; lower it only when you intentionally want a smaller snapshot."},{name:"options",type:"{ max_nodes?: number }",required:!1,description:"Snapshot options (literal). Use max_nodes only to opt into less output."}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"page.snapshot()",agentMeta:{notes:[j,"Content-script path; same refIds as mutations","Do not assume accessibility-only output: snapshot includes visible text and validation/error text even when it is not interactive","If the needed data, options, hidden input, or attributes are still missing, call page.dom({ selector, depth, includeHidden: true }) directly"],tags:["snapshot","read"],relatedApis:["page.snapshot_data","page.dom","web.tab.snapshot"]},handlerKey:"snapshot_text"},{action:"page_snapshot_text",namespace:"page",name:"snapshot_text",description:"Capture a broad text-first DOM snapshot and return only its text representation",params:Ii,returns:c(),paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal). Defaults high; lower it only when intentionally limiting output."}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"page.snapshot_text()",handlerKey:"snapshot_text"},{action:"page_snapshot_data",namespace:"page",name:"snapshot_data",description:"Get broad page snapshot data. Includes visible text, form values, required/invalid state, linked error text, and actionable refIds where possible.",params:Ti,returns:nt,paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal). Defaults high; lower it only when intentionally limiting output."}],returnDoc:"{ text, nodes, url, title, viewport }",errorCode:"E_SNAPSHOT",example:"page.snapshot_data()",agentMeta:{notes:[j,"Content-script path; nodes include refId for targeting when an element can be acted on","Snapshot is text-first and broad by default; filtering/limiting is opt-in via snapshot_query or max_nodes","After mutations, call snapshot_data() again to verify state","If a widget's raw attributes or hidden nodes matter, inspect them with page.dom({ selector, depth, includeHidden: true })"],tags:["snapshot","read"],relatedApis:["page.click","page.dom","web.tab.snapshot_data"]},handlerKey:"snapshot"},{action:"page_snapshot_query",namespace:"page",name:"snapshot_query",description:"Opt-in filtered snapshot query by role, tag, text, name, etc. Use this only when you intentionally want less than the default broad snapshot.",params:wr,returns:nt,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:[j,"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, but it can hide useful text by design","If filtering hides the data you need, use page.snapshot_data() or page.dom({ selector, depth, includeHidden: true })"],tags:["snapshot","read"],relatedApis:["page.snapshot_data","page.dom","page.find"]},handlerKey:"snapshot_query"},{action:"page_find",namespace:"page",name:"find",description:"Find elements in the active tab using a CSS selector",params:ii,returns:T(u({refId:Z(),role:c(),tag:c(),name:c().optional(),text:c().optional(),value:c().optional(),checked:g().optional(),disabled:g().optional(),readOnly:g().optional(),href:c().optional(),src:c().optional(),alt:c().optional(),title:c().optional(),parentRefId:Z().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","Returned refIds are immediately actionable — call page.click/fill/select_option on them without an intermediate snapshot_data","For dropdowns found via find, use page.select_option — not fill/type"],tags:["read"]},handlerKey:"find"},{action:"page_dom",namespace:"page",name:"dom",description:"Introspect raw DOM subtree by CSS selector. Read-only. Use this whenever snapshot/find do not expose enough data: hidden inputs, validation shims, raw attributes, dropdown/listbox ownership, shadowed widgets, aria-hidden regions, or exact DOM structure.",params:si,returns:pi,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:[j,"Read-only: returns DOM structure, never executes code or mutates the page","Bypasses snapshot filtering and can include hidden nodes by default","Assigns refIds to returned elements; those refIds are immediately actionable by page.click/fill/select_option/setFiles in the same cell — no intermediate snapshot_data needed","Use page.dom immediately when struggling to find data in snapshot output; do not keep guessing selectors from the accessibility tree","If a dom node is a dropdown (role=combobox/tag=select/controlType=dropdown), use page.select_option on its refId"],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:oi,returns:g(),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:[j],tags:["read"]},handlerKey:"wait_for"},{action:"page_extract",namespace:"page",name:"extract",description:"Extract data from the active tab",params:li,returns:u({title:c().optional(),url:c().optional(),headings:T(u({tag:c(),text:c()})).optional(),links:T(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:[j],tags:["read"]},handlerKey:"extract"},{action:"page_fetch",namespace:"page",name:"fetch",description:"Fetch in the active tab",params:$a,returns:gr,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:[j,"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"}],ts=[{action:"tab_click",namespace:"web.tab",name:"click",description:"Click in a tab",params:Ri,returns:C,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:Oi,returns:C,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:Mi,returns:C,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:Di,returns:C,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:Li,returns:C,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:Pi,returns:C,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:$i,returns:C,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:ji,returns:C,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:Fi,returns:C,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:Ui,returns:C,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:Zi,returns:C,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:Bi,returns:C,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:Vi,returns:C,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:Hi,returns:C,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:Wi,returns:C,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:zi,returns:C,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:"tab_forward",namespace:"web.tab",name:"forward",description:"Go forward in a tab",params:Gi,returns:C,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 a broad, text-first tab snapshot. Includes visible text, form values, validation/error text, and actionable refIds where possible.",params:Xi,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). Defaults high; lower it only when intentionally limiting output."}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"web.tab.snapshot({ tabId: 123 })",agentMeta:{notes:[j,"Use web.tab.dom or page.dom if raw attributes, hidden nodes, or exact dropdown ownership are missing"],tags:["snapshot","read"],relatedApis:["web.tab.snapshot_data","page.dom"]},handlerKey:"snapshot_text"},{action:"tab_snapshot_text",namespace:"web.tab",name:"snapshot_text",description:"Get broad, text-first tab snapshot text",params:Qi,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 broad tab snapshot data. Includes visible text, form values, validation/error text, and actionable refIds where possible.",params:Yi,returns:nt,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 })",agentMeta:{notes:[j,"Filtering/limiting is opt-in; this broad snapshot is the default","Use page.dom({ selector, depth, includeHidden: true }) when raw DOM attributes or hidden nodes matter"],tags:["snapshot","read"],relatedApis:["web.tab.snapshot","page.dom"]},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:Ei,returns:nt,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:Ji,returns:gr,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:Ki,returns:di,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"}],rs=[...es,...ts];function ns(){return[{registryAction:"ping",handlerKey:"ping",params:u({}),returns:u({ok:g()})}]}const as=new Set(["page_set_files","tab_set_files"]);function is(){return rs.map(t=>({registryAction:t.action,handlerKey:t.handlerKey,params:as.has(t.action)?t.action==="tab_set_files"?qi:Ha:t.params,returns:t.returns}))}if(kr(),window.__jsNotebookContentScriptInjected)throw new Error("Content script already injected");window.__jsNotebookContentScriptInjected=!0,Na([...is(),...ns()]),Da()})();
1
+ (function(){"use strict";const Y={debug:0,info:1,warn:2,error:3,none:4};let Lt=Y.error;function Tr(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<Lt)return;const n=Tr(r),a=`[extension-js][content-script] ${e}${n}`;t>=Y.error?console.error(a):t===Y.warn?console.warn(a):console.log(a)}const ye={debug:(t,e)=>{We(Y.debug,t,e)},info:(t,e)=>{We(Y.info,t,e)},warn:(t,e)=>{We(Y.warn,t,e)},error:(t,e)=>{We(Y.error,t,e)}};function Sr(){window.__jsNotebookSetLogLevel=t=>{Lt=Y[t]??Y.error}}function Er(t){if(t.startsWith("page_")||t.startsWith("tab_")){const e=t.indexOf("_");if(e>=0)return t.slice(e+1)}return t}const Ar="Content script is not connected on this tab. This tab was likely open before the extension loaded (MV3 does not retro-inject).";function Cr(t){return[`await page.goto(${JSON.stringify(t||"")})`,"Or ask the user to refresh the target tab, then retry fill/click"]}function Pt(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:Ar,recovery:Cr(e)};return t!==void 0&&(n.details={tabId:t,url:r}),n}function Nr(t,e){var o,d;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&&((o=e.candidates)!=null&&o.length)){const l=e.candidates.map(p=>p.name||p.refId).filter(Boolean).slice(0,5);l.length>0?a+=`. Candidates: ${l.join(", ")}`:a+=". Candidates: none"}const i=(e==null?void 0:e.snapshot)!==void 0,s={message:a,code:"E_STALE",category:"resource",hint:i?"The element changed or was removed after the last observation. A fresh snapshot is attached — re-resolve the target refId and retry.":"RefIds are ephemeral. They are assigned at snapshot time and invalidated when the DOM is replaced (navigation, SPA rerender, autocomplete).",recovery:i?["Read error.details.snapshot.nodes, find the element by role/name, and retry with the new refId","No separate snapshot_data call needed — the attached snapshot already refreshes the lease"]:["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(d=e==null?void 0:e.candidates)!=null&&d.length&&(s.details={...s.details,candidates:e.candidates}),i&&(s.details={...s.details,snapshot:e.snapshot}),s}function pe(t,e,r){const a=(r==null?void 0:r.controlType)==="dropdown"||(r==null?void 0:r.nearbyControlType)==="dropdown"?[`await page.select_option({ refId: ${JSON.stringify(e)}, value: "..." }) — this is a dropdown; fill/type do not work on combobox/proxy inputs`,"Re-snapshot and use select_option with the option's visible text"]:[`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"];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:a,details:{refId:e,...r}}}function Rr(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 Or(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 Ee(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"}let 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 r!=null&&r.isDropdown&&(a=`Target is a dropdown (combobox). ${a}`),{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}:{},...(r==null?void 0:r.ariaControlsBefore)!==void 0?{ariaControlsBefore:r.ariaControlsBefore}:{},...(r==null?void 0:r.ariaControlsAfter)!==void 0?{ariaControlsAfter:r.ariaControlsAfter}:{},...(r==null?void 0:r.isDropdown)!==void 0?{isDropdown:r.isDropdown}:{},...e!=null&&e.length?{candidates:e}:{}}}}function Mr(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 $t(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"?Pt(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}=Mr(t);if(Or(r))return Pt(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 qr=/^e\d+$/;let jt=0;function ot(){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)}jt=t}function Ke(t){const e=t.getAttribute("data-ref-id");if(e&&qr.test(e))return e;const r=`e${++jt}`;return t.setAttribute("data-ref-id",r),r}const ct='input, textarea, select, button, a, [role="button"], [role="link"]',Dr=new Set(["script","style","noscript","template"]),Ft=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 ze(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,lt(t,e);else if(t instanceof HTMLTextAreaElement)e.value=t.value,e.disabled=t.disabled,e.readOnly=t.readOnly,lt(t,e);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,lt(t,e)}else t instanceof HTMLOptionElement&&(e.value=t.value,e.selected=t.selected,e.disabled=t.disabled);return e}function lt(t,e){const r=t.required||t.getAttribute("aria-required")==="true",a=!(t.getAttribute("aria-invalid")==="true")&&t.checkValidity();r&&(e.required=!0),e.valid=a,e.invalid=!a;const i=Bt(t);i&&(e.errorMessage=i),!a&&t.validationMessage&&(e.validationMessage=t.validationMessage)}function Bt(t){var r;const e=[...(t.getAttribute("aria-errormessage")||"").split(/\s+/),...(t.getAttribute("aria-describedby")||"").split(/\s+/)].filter(Boolean);for(const n of e){const a=document.getElementById(n);if(!a)continue;const i=(r=a.textContent)==null?void 0:r.trim();if(!i)continue;const s=a.getAttribute("role"),o=a.getAttribute("aria-live");if(s==="alert"||o&&o!=="off"||/error|required|select|please|invalid/i.test(i))return i}}function Lr(t,e){const r=t.tagName.toLowerCase();r!=="input"&&r!=="textarea"&&r!=="select"&&r!=="option"||Object.assign(e,ze(t))}const Pr=new Set(["http:","https:","file:"]);function se(t){if(t)try{const e=new URL(t,window.location.href);return Pr.has(e.protocol)?e.href:void 0}catch{return}}function Ut(t){const e=t.closest("article[data-post-id], [data-post-id]");if(e)return Ke(e)}function $r(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"||n==="tel")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 jr(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 dt(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 oe(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 Fr(t){return oe(t)}function Zt(t){var o;const e=t.tagName.toLowerCase();if(Dr.has(e)||Fr(t))return!1;const r=B(t);if(r!=="generic"&&!(r==="presentation"||r==="none"))return!0;const a=t.getAttribute("aria-live");if(a&&a!=="off")return!0;const i=t.getAttribute("role");return i==="status"||i==="alert"?!0:((o=t.textContent)==null?void 0:o.trim())||""?!!(Ft.has(e)||jr(t)):!1}function ee(t){var s,o,d;const e=t.getAttribute("aria-label");if(e)return e;const r=t.getAttribute("aria-labelledby");if(r){const l=document.getElementById(r);if(l)return((s=l.textContent)==null?void 0:s.slice(0,60))||""}if(t.tagName.toLowerCase()==="img"){const l=t.getAttribute("alt");if(l)return l}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"&&Zt(t)){const l=dt(t);if(l)return l;const p=t.tagName.toLowerCase();if(Ft.has(p)||t.childElementCount===0)return((d=t.textContent)==null?void 0:d.trim().slice(0,60))||""}return""}function Br(t){return t instanceof HTMLInputElement&&t.type==="file"||Ur(t)||ut(t)?!0:Zt(t)}function Ur(t){return t instanceof HTMLInputElement||t instanceof HTMLTextAreaElement||t instanceof HTMLSelectElement?!t.checkValidity()||t.getAttribute("aria-invalid")==="true":!1}function ut(t){return!(t instanceof HTMLInputElement)||t.closest('[role="combobox"]')===null||!(t.type==="hidden"||t.getAttribute("aria-hidden")==="true"||t.tabIndex===-1)?!1:t.required||t.getAttribute("aria-required")==="true"||(t.getAttribute("aria-describedby")||"").length>0}function Zr(t){return typeof CSS<"u"&&CSS.escape?CSS.escape(t):t.replace(/["\\]/g,"\\$&")}function Vr(t,e){var r,n,a,i;if(t){const s=t.getAttribute("id");if(s){const p=document.querySelector(`label[for="${Zr(s)}"]`);if((r=p==null?void 0:p.textContent)!=null&&r.trim())return p.textContent.trim()}const o=t.closest("label");if((n=o==null?void 0:o.textContent)!=null&&n.trim())return o.textContent.trim();const d=t.previousElementSibling;if((d==null?void 0:d.tagName)==="LABEL"&&((a=d.textContent)!=null&&a.trim()))return d.textContent.trim();const l=t.parentElement;if(l){const p=l.querySelector("label");if((i=p==null?void 0:p.textContent)!=null&&i.trim())return p.textContent.trim()}}return e}const Hr={script:!0,style:!0,noscript:!0,template:!0},Wr=(t,e)=>Lr(t,e),Kr=(t,e)=>{var n;if(!ut(t))return;e.controlType="validation-proxy",e.actionable=!1;const r=(n=t.closest('[role="combobox"]'))==null?void 0:n.getAttribute("data-ref-id");r&&(e.forControl=r)},Vt=(t,e)=>{if(e.controlType==="validation-proxy"||e.role!=="combobox"&&e.tag!=="select")return;e.controlType="dropdown",e.recommendedAction="select_option",e.controls=t.getAttribute("aria-controls")||t.getAttribute("aria-owns")||void 0;const r=t.getAttribute("aria-expanded");e.expanded=r==="true"?!0:r==="false"?!1:void 0},zr=(t,e)=>{e.tag==="a"&&(e.href=se(t.getAttribute("href")))},Gr=(t,e)=>{e.tag==="img"&&(e.src=se(t.getAttribute("src")),e.alt=t.getAttribute("alt")||"")},Jr=(t,e)=>{var n;if(e.tag!=="input")return;const r=t;e.title=t.getAttribute("title")||void 0,r.type==="file"&&(e.accept=r.getAttribute("accept")||void 0,e.filesCount=((n=r.files)==null?void 0:n.length)??0)},Xr=(t,e)=>{e.tag!=="img"&&e.tag!=="a"||(e.parentRefId=Ut(t)||e.parentRefId)},Qr=(t,e)=>{e.postId=t.getAttribute("data-post-id")||void 0},Yr=(t,e)=>{if(e.tag==="a")return;const r=$r(t);r&&(e.permalink=se(r.getAttribute("href")))},en=(t,e)=>{if(e.tag==="img")return;const r=Array.from(t.querySelectorAll("img")).map(n=>se(n.getAttribute("src"))).filter(n=>!!n);r.length>0&&(e.imageUrls=r)},tn=(t,e)=>[Wr,Kr,Vt,zr,Gr,Jr,Xr,Qr,Yr,en].forEach(r=>r(t,e)),rn=(t,e,r)=>{const n={refId:Ke(t),role:B(t),tag:t.tagName.toLowerCase(),text:dt(t,100)},a=ee(t);return a&&(n.name=a),(n.tag==="img"||n.tag==="a")&&r&&(n.parentRefId=r),tn(t,n),n},nn=(t,e)=>{var a,i,s,o,d,l;const r=t.controlType==="dropdown"?"dropdown":t.controlType==="validation-proxy"?"validation-proxy":t.role,n=[[t.name,`"${(a=t.name)==null?void 0:a.replace(/"/g,'\\"')}"`],[`[${t.refId}]`,`[${t.refId}]`],[t.text&&t.text!==t.name,`text="${(i=t.text)==null?void 0:i.replace(/"/g,'\\"')}"`],[t.value,`value="${(s=t.value)==null?void 0:s.replace(/"/g,'\\"')}"`],[t.required,"required"],[t.invalid,"invalid"],[t.expanded!==void 0,`expanded=${t.expanded}`],[t.controls,`opens="${(o=t.controls)==null?void 0:o.replace(/"/g,'\\"')}"`],[t.recommendedAction,`use="${t.recommendedAction}"`],[t.actionable===!1,"actionable=false"],[t.forControl,`forControl="${t.forControl}"`],[t.errorMessage,`error="${(d=t.errorMessage)==null?void 0:d.replace(/"/g,'\\"')}"`],[!t.errorMessage&&t.validationMessage,`validation="${(l=t.validationMessage)==null?void 0:l.replace(/"/g,'\\"')}"`]];return[`${" ".repeat(e)}- ${r}`,...n.filter(([p])=>p).map(([,p])=>p)].join(" ")},an=t=>t.filter(e=>(e.invalid||e.errorMessage!==void 0||e.validationMessage!==void 0)&&e.controlType!=="validation-proxy").map(e=>({field:Vr(document.querySelector(`[data-ref-id="${e.refId}"]`),e.name||e.refId),error:e.errorMessage||e.validationMessage||"",refId:e.refId})),sn=(...t)=>e=>t.reduce((r,n)=>r.kind==="reject"?r:n(r),e),on=t=>Hr[t.el.tagName.toLowerCase()]?{kind:"reject",el:t.el,depth:t.depth}:t,cn=t=>Br(t.el)?t:{kind:"reject",el:t.el,depth:t.depth},ln=(t,e)=>r=>t>=e?{kind:"reject",el:r.el,depth:r.depth}:r,dn=t=>{const e=rn(t.el,t.depth,t.parentRefId);return{kind:"emit",node:e,line:nn(e,t.depth),children:Array.from(t.el.children),childDepth:t.depth+1,childRefId:e.refId}},un=t=>t.kind==="emit"?{emitted:{node:t.node,line:t.line},children:t.children,childDepth:t.childDepth,childRefId:t.childRefId}:{emitted:null,children:Array.from(t.el.children),childDepth:t.depth,childRefId:""},pn=(t,e)=>{const r=[],n=[],a=(i,s,o)=>{const l=sn(on,cn,ln(r.length,e))({kind:"enter",el:i,depth:s,parentRefId:o}),p=un(l.kind==="reject"?l:dn(l));p.emitted&&(r.push(p.emitted.node),n.push(p.emitted.line));for(const E of p.children){if(r.length>=e)break;a(E,p.childDepth,p.childRefId)}};return a(t,0,""),{nodes:r,lines:n}};function fn(t){let e=!1;const r=typeof MutationObserver<"u"&&document.body?new MutationObserver(()=>{e=!0}):null;r&&document.body&&r.observe(document.body,{childList:!0,subtree:!0});try{return t()}finally{r&&(r.takeRecords().length>0&&(e=!0),r.disconnect()),e&&R({message:"DOM mutated during snapshot collection",code:"E_SNAPSHOT",category:"resource",details:{cause:"dom_mutated_during_snapshot"},recovery:["Wait for the page to finish rendering before snapshot","Retry with a smaller max_nodes bound","Use page.snapshot_data() after navigation settles"]})}}function pt(t){return ot(),fn(()=>{const{nodes:e,lines:r}=document.body?pn(document.body,t):{nodes:[],lines:[]};return{text:[`URL: ${window.location.href}`,`Title: ${document.title}`,"",...r].join(`
2
+ `),nodes:e,formErrors:an(e),url:window.location.href,title:document.title,viewport:{width:window.innerWidth,height:window.innerHeight}}})}function ft(t){return{tag:t.tagName.toLowerCase(),role:B(t),name:ee(t)}}function hn(t,e){return t.tag===e.tag&&t.role===e.role&&t.name===e.name}let Ae=!1,Ht=0,Ge,ve=new Map;function ht(t=[]){Ht+=1,Ge=`obs${Ht}`,Ae=!0,ve=new Map;for(const e of t)ve.set(e.refId,{element:e.element,fingerprint:ft(e.element)});return Ge}function mt(){Ae=!1,Ge=void 0,ve=new Map}function mn(){return Ae}function Ce(){return Ge}function bt(t,e){Ae||Wt(e);const r=ve.get(t);r||Je(t,"not_in_latest_observation");const{element:n,fingerprint:a}=r;if(!n.isConnected){const s=bn(r);if(s)return ve.set(t,{element:s,fingerprint:ft(s)}),s;Je(t,"disconnected")}const i=ft(n);return hn(i,a)||Je(t,"fingerprint_changed"),n}function bn(t){const{fingerprint:e}=t,r=e.role,n=e.name.trim().toLowerCase();return Array.from(document.querySelectorAll("*")).find(a=>B(a)===r&&ee(a).toLowerCase().trim()===n)??null}function Wt(t){const e=yt(),r=new Error(`${t} requires a fresh observation before acting.`);throw r.code="E_OBSERVATION_REQUIRED",r.category="observation",r.hint="Element refIds are only valid after a snapshot. A fresh snapshot is attached — use a refId from error.details.snapshot.nodes and retry.",r.recovery=["Read error.details.snapshot.nodes, pick the target refId, and retry the action","No separate snapshot_data call needed — the attached snapshot already refreshes the lease"],r.details={action:t,...e?{snapshot:e}:{}},r}function Je(t,e){const r=yt(),n=new Error(`Element refId "${t}" is stale (${e}).`);throw n.code="E_STALE",n.category="observation",n.hint="The element changed or was removed after the last observation. A fresh snapshot is attached — re-resolve the target refId and retry.",n.recovery=["Read error.details.snapshot.nodes, find the element by role/name, and retry with the new refId","No separate snapshot_data call needed — the attached snapshot already refreshes the lease"],n.details={staleRefId:t,reason:e,...r?{snapshot:r}:{}},n}function gn(t,e){Ae||Wt(e);const r=t.toLowerCase().trim(),n=[];for(const i of ve.values())ee(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&&yn(t);const a=n[0];return a.isConnected||Je(a.getAttribute("data-ref-id")||"","disconnected"),a}function yn(t){const e=yt(),r=new Error(`Multiple elements match label "${t}". The target is ambiguous.`);throw r.code="E_AMBIGUOUS_TARGET",r.category="observation",r.hint="Use a refId from error.details.snapshot.nodes instead of a label, or narrow the label.",r.recovery=["Read error.details.snapshot.nodes, pick the intended target by refId, and retry","No separate snapshot_data call needed — the attached snapshot already refreshes the lease"],r.details={label:t,...e?{snapshot:e}:{}},r}function vn(t){return document.querySelector(`[data-ref-id='${CSS.escape(t)}']`)}function gt(t){const e=pt(t),r=e.nodes.map(a=>{const i=vn(a.refId);return i?{refId:a.refId,element:i}:null}).filter(a=>a!==null),n=ht(r);return{...e,observationId:n}}function yt(){try{const t=gt(Number.MAX_SAFE_INTEGER);return{nodes:t.nodes,observationId:t.observationId,url:t.url,title:t.title}}catch{return}}function _n(t){return document.querySelector(`[data-ref-id='${CSS.escape(t)}']`)}function K(t,e){const n=t instanceof HTMLSelectElement||t.getAttribute("role")==="combobox"||oe(t)&&t.closest('[role="combobox"]')!==null?"dropdown":void 0;if(t.hasAttribute("disabled")||t.getAttribute("aria-disabled")==="true"){const a=t.getAttribute("data-ref-id")||void 0;R(pe(e,a??"",{reason:"disabled",...n?{controlType:n}:{}}))}if(oe(t)){const a=t.getAttribute("data-ref-id")||void 0;R(pe(e,a??"",{reason:"hidden",...n?{controlType:n}:{}}))}}function vt(t){var n,a,i;const e=t.toLowerCase().trim();if(!e)return null;const r=Array.from(document.querySelectorAll(ct));for(const s of r){const o=s.getAttribute("aria-label");if(o&&o.toLowerCase().trim()===e)return s;const d=s.placeholder;if(d&&d.toLowerCase().trim()===e)return s;const l=s.id;if(l){const N=document.querySelector(`label[for='${CSS.escape(l)}']`);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 wn(t){var a;const e=t.toLowerCase().trim();if(!e)return[];const r=Array.from(document.querySelectorAll(ct)),n=[];for(const i of r){const s=i.getAttribute("aria-label"),o=i.placeholder,d=((a=i.textContent)==null?void 0:a.trim())||"";if(![s,o,d].filter(Boolean).some(E=>E.toLowerCase().includes(e)))continue;const p=i.getAttribute("data-ref-id");if(p&&(n.push({refId:p,role:B(i),name:ee(i)||void 0}),n.length>=5))break}return n}function _e(t){return typeof t=="object"&&t!==null&&!Array.isArray(t)?t:{}}function xn(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(ct)),i=[];for(const s of a){const o=s.getAttribute("data-ref-id");if(o){if(r||n){const d=s.tagName.toLowerCase(),l=B(s);if(d!==r&&l!==n)continue}if(i.push({refId:o,role:B(s),name:ee(s)||void 0}),i.length>=5)break}}return i}function kn(){try{return gt(Number.MAX_SAFE_INTEGER)}catch{return}}function Ne(t,e,r=!1){const n=kn();if(t){const a=r?xn(t):[];R(Nr(t,{candidates:a,snapshot:n}))}if(e){const a=r?wn(e):[];R(Ee(e,a))}R({message:"Element not found",code:"E_NOT_FOUND",category:"resource"})}function z(t,e){let r=t?_n(t):null;return!r&&e&&(r=vt(e)),r||Ne(t,e,!0),r}const Kt=8*1024;function In(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 Tn(t){let e="";for(let r=0;r<t.length;r+=Kt){const n=t.subarray(r,r+Kt);for(let a=0;a<n.length;a++)e+=String.fromCharCode(n[a])}return btoa(e)}function Sn(t){return t.toLowerCase().split(";")[0].trim()}function En(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 An(t){for(let e=0;e<t.length;e++)if(t[e]===0)return!0;return!1}function zt(t){return Object.fromEntries(t.headers.entries())}function Gt(t,e,r){return{status:t.status,ok:t.ok,headers:zt(t),body:Tn(e),bodyEncoding:"base64",byteLength:e.length,contentType:r,finalUrl:t.url}}function Jt(t,e,r){return{status:t.status,ok:t.ok,headers:zt(t),body:e,bodyEncoding:"text",byteLength:new TextEncoder().encode(e).length,contentType:r,finalUrl:t.url}}async function Cn(t){const e=t.headers.get("content-type")||"",r=Sn(e);if(En(r)){const a=new Uint8Array(await t.arrayBuffer());return Gt(t,a,e)}if(!r||r.startsWith("text/")){const a=new Uint8Array(await t.arrayBuffer());if(An(a))return Gt(t,a,e);const i=new TextDecoder().decode(a);return Jt(t,i,e)}const n=await t.text();return Jt(t,n,e)}const Nn=new Set(["button","link","textbox","checkbox","radio","combobox","searchbox","switch","menuitem","tab","treeitem"]),Rn=new Set(["a","button","input","textarea","select","details","summary"]);function Xe(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 Xt(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 On(t,e){let r=t;if(e.role){const n=Xt(e.role);r=r.filter(a=>n.has(a.role.toLowerCase()))}if(e.tag){const n=Xt(e.tag);r=r.filter(a=>n.has(a.tag.toLowerCase()))}if(e.text){const n=Xe(e.text);r=r.filter(a=>a.text!==void 0&&n(a.text))}if(e.name){const n=Xe(e.name);r=r.filter(a=>a.name!==void 0&&n(a.name))}if(e.href){const n=Xe(e.href);r=r.filter(a=>a.href!==void 0&&n(a.href))}if(e.src){const n=Xe(e.src);r=r.filter(a=>a.src!==void 0&&n(a.src))}return e.interactiveOnly&&(r=r.filter(n=>Nn.has(n.role.toLowerCase())||Rn.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?ze(e):{},...r}}function _t(t,e,r,n){(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement)&&e.value!==n&&R(pe(t,r,{requested:n,actual:e.value}))}function Mn(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 Qt(t,e,r,n){var l;if(!r&&oe(t))return null;const a=t.tagName.toLowerCase(),i=Ke(t);n&&n.push({refId:i,element:t});const s={tag:a,refId:i,role:B(t),name:ee(t)||void 0,text:dt(t,100)||void 0},o={};for(const p of Array.from(t.attributes))o[p.name]=p.value;Object.keys(o).length&&(s.attributes=o);const d=Mn(t);if(d&&(s.hidden=!0,s.hiddenReason=d),Object.assign(s,ze(t)),Vt(t,s),t instanceof HTMLInputElement&&t.type==="file"){const p=t.getAttribute("accept");p&&(s.accept=p),s.filesCount=((l=t.files)==null?void 0:l.length)??0}if(a==="a"){const p=se(t.getAttribute("href"));p&&(s.href=p)}if(a==="img"){const p=se(t.getAttribute("src"));p&&(s.src=p),s.alt=t.getAttribute("alt")||void 0}if(e>0){const p=[];for(const E of Array.from(t.children)){const N=Qt(E,e-1,r,n);N&&p.push(N)}p.length&&(s.children=p)}return s}function Re(t){R({message:t,code:"E_INVALID_PARAMS",category:"validation"})}function qn(t){const r=_e(t).files;(!Array.isArray(r)||r.length===0)&&Re("setFiles requires a non-empty files array");const n=[];for(const a of r){const i=_e(a),s=i.kind;if(s==="bytes"){const o=typeof i.name=="string"?i.name.trim():"",d=typeof i.data=="string"?i.data:"";(!o||!d)&&Re("Resolved bytes file requires name and data"),n.push({kind:"bytes",name:o,data:d,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:"",d=typeof i.name=="string"?i.name.trim():"";(!o||!d)&&Re("Resolved url file requires url and name"),n.push({kind:"url",url:o,name:d,mimeType:typeof i.mimeType=="string"&&i.mimeType.length>0?i.mimeType:void 0})}}return n.length!==r.length&&Re("setFiles files must be worker-resolved (kind: bytes or url)"),n}function Dn(t){try{const e=In(t.data);return new File([e.slice()],t.name,{type:t.mimeType??"application/octet-stream"})}catch{Re(`Invalid base64 data for file ${t.name}`)}}async function Ln(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 Pn(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(pe("setFiles",e,{expectedNames:r,actualNames:n}))}function $n(t){return Array.from(t.querySelectorAll("input, textarea, select")).filter(e=>(!e.checkValidity()||e.getAttribute("aria-invalid")==="true")&&!ut(e)).map(e=>{const r=ee(e)||void 0,n=jn(e,r),a=Bt(e)||e.validationMessage||"";return{refId:e.getAttribute("data-ref-id")||void 0,tag:e.tagName.toLowerCase(),role:B(e),name:r,field:n,error:a,value:e instanceof HTMLInputElement&&e.type==="password"?void 0:e.value,required:e.required||e.getAttribute("aria-required")==="true",validationMessage:e.validationMessage||void 0}})}function jn(t,e){var s,o,d,l;if(e)return e;const r=t.getAttribute("id");if(r){const p=typeof CSS<"u"&&CSS.escape?CSS.escape(r):r.replace(/["\\]/g,"\\$&"),E=document.querySelector(`label[for="${p}"]`);if((s=E==null?void 0:E.textContent)!=null&&s.trim())return E.textContent.trim()}const n=t.closest("label");if((o=n==null?void 0:n.textContent)!=null&&o.trim())return n.textContent.trim();const a=t.previousElementSibling;if((a==null?void 0:a.tagName)==="LABEL"&&((d=a.textContent)!=null&&d.trim()))return a.textContent.trim();const i=t.parentElement;if(i){const p=i.querySelector("label");if((l=p==null?void 0:p.textContent)!=null&&l.trim())return p.textContent.trim()}return t.getAttribute("data-ref-id")||void 0}function Yt(t){return Array.from(t.querySelectorAll('[role="option"]')).map(e=>(e.textContent||"").trim()).join(`
3
+ `)}const wt=()=>Array.from(document.querySelectorAll('[role="listbox"]')),Fn=t=>[...new Set(t)],er=(t,e)=>e.flatMap(r=>(t.getAttribute(r)||"").trim().split(/\s+/)).filter(Boolean),xt=t=>t instanceof HTMLElement&&t.getAttribute("role")==="listbox",Bn=t=>{const e=(t.getAttribute("aria-haspopup")||"").toLowerCase().includes("listbox"),r=er(t,["aria-controls"]).some(i=>xt(document.getElementById(i))),n=t.hasAttribute("aria-expanded"),a=(t.getAttribute("aria-label")||t.textContent||"").toLowerCase();return e||r||n||/\b(open|show|toggle|expand|menu|options|flyout|dropdown)\b/.test(a)};function Un(t){const e=[];for(let r=t.parentElement,n=0;r&&n<4;r=r.parentElement,n++)e.push(r);return e.flatMap(r=>Array.from(r.querySelectorAll("button"))).find(r=>r!==t&&!oe(r)&&Bn(r))||null}const Zn=()=>new Map(wt().map(t=>[t,{hidden:oe(t),sig:Yt(t)}])),Vn=t=>er(t,["aria-controls","aria-owns"]).map(e=>document.getElementById(e)).filter(xt),Hn=t=>wt().filter(e=>{const r=t.get(e);return oe(e)?!1:!r||r.hidden?!0:Yt(e)!==r.sig}),Wn=t=>Array.from(t.querySelectorAll('[role="listbox"]')),Kn=t=>xt(t)?[t]:[],tr=t=>{for(const e of["mouseover","mousedown","mouseup"])t.dispatchEvent(new MouseEvent(e,{bubbles:!0,cancelable:!0}));t.click()},zn=()=>new Promise(t=>requestAnimationFrame(()=>t())),rr=(t,e)=>({allListboxes:wt(),roots:Fn([...Vn(t),...Hn(e),...Wn(t),...Kn(t)])}),nr=async(t,e)=>{let r=rr(t,e);const n=a=>a.some(i=>i.querySelector('[role="option"]'));for(let a=0;a<10&&!n(r.roots);a++)await zn(),r=rr(t,e);return r};async function Gn(t){const e=t.getAttribute("aria-controls"),r=Zn();tr(t);let{roots:n,allListboxes:a}=await nr(t,r);if(n.length===0){const o=Un(t);o&&(tr(o),{roots:n,allListboxes:a}=await nr(t,r))}const i=t.getAttribute("aria-controls"),s=n.map(o=>o.id).filter(Boolean);return{roots:n,searchedIds:s,allListboxes:a,ariaControlsBefore:e,ariaControlsAfter:i}}const Jn=100;function kt(t){const e=_e(t),n=_e(e.options??e).max_nodes??e.max_nodes;let a=1e4;return typeof n=="number"&&Number.isFinite(n)?a=n:typeof n=="bigint"&&(a=Number(n)),Math.max(1,Math.min(5e4,Math.floor(a)))}function Xn(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 Qn(t,e){return{top:t==="down"?e:t==="up"?-e:0,left:t==="right"?e:t==="left"?-e:0}}function ar(t,e){const r=e==="y"?t.overflowY:t.overflowX;return r==="auto"||r==="scroll"||r==="overlay"}function ir(t,e){const r=window.getComputedStyle(t);return e==="up"||e==="down"?!ar(r,"y")||t.scrollHeight<=t.clientHeight?!1:e==="down"?t.scrollTop<t.scrollHeight-t.clientHeight:t.scrollTop>0:!ar(r,"x")||t.scrollWidth<=t.clientWidth?!1:e==="right"?t.scrollLeft<t.scrollWidth-t.clientWidth:t.scrollLeft>0}function Yn(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 ea(t){const e=document.activeElement;if(e instanceof HTMLElement&&ir(e,t))return e;let r=null,n=0;for(const a of Array.from(document.querySelectorAll("*"))){if(a===document.body||a===document.documentElement||!ir(a,t))continue;const i=Yn(a);i>n&&(r=a,n=i)}return r}function ta(t){const e=_e(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}const ra={click:t=>{const e=t.refId,r=t.label;let n;return e?n=bt(e,"click"):r?n=gn(r,"click"):Ne(e,r,!0),K(n,"click"),n.click(),O("click",n,{observationId:Ce(),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=vt(r),a||Ne(e,r,!0)):Ne(e,r,!0),K(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 _t("fill",a,s,n),O("fill",a,{value:a.value,observationId:Ce(),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:Ce(),dispatched:!0,verification:"required"})}throw new Error("Element is not an input or contenteditable")},set_files:async t=>{var o,d;const e=qn(t),r=z(t.refId,t.label);let n;if(r instanceof HTMLInputElement&&r.type==="file")n=r;else{const l=r.querySelector('input[type="file"]'),p=(o=r.closest("label"))==null?void 0:o.querySelector('input[type="file"]'),E=r.getAttribute("for"),N=E?(d=document.getElementById(E))==null?void 0:d.querySelector('input[type="file"]'):null,ae=l??p??N;if(!ae){const Se=t.refId??"";R(pe("setFiles",Se,{reason:"not_file_input"}))}n=ae}const a=new DataTransfer,i=[];for(const l of e){const p=l.kind==="bytes"?Dn(l):await Ln(l);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 Pn(n,s,i),O("setFiles",n,{fileCount:i.length,fileNames:i})},type:t=>{const e=t.refId,r=t.label,n=t.text,a=z(e,r);if(K(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 _t("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=z(e,r);if(K(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 d=e||a.getAttribute("data-ref-id")||"";return _t("append",a,d,s),O("append",a,{text:a.value})}throw new Error("Element is not an input")},press:t=>{mn()||R(Rr("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=vt(n),i||Ne(r,n,!0)),K(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:Ce(),dispatched:!0,verification:"required"})},select:t=>{const e=t.refId,r=t.label,n=t.value,a=z(e,r);if(K(a,"select"),a instanceof HTMLSelectElement){if(Array.isArray(n)){const i=new Set(n);let s=0;for(const d of Array.from(a.options)){const l=i.has(d.value);d.selected=l,l&&(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(d=>d.selected).map(d=>d.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:async t=>{const e=t.value,r=z(t.refId,t.label);if(K(r,"select_option"),r instanceof HTMLSelectElement){const M=Array.from(r.options).find(ge=>(ge.text||"").trim()===e)||Array.from(r.options).find(ge=>(ge.text||"").trim().toLowerCase()===e.toLowerCase());if(!M){const ge=Array.from(r.options).map((ie,Dt)=>({refId:`opt${Dt}`,name:(ie.text||"").trim()||void 0}));R(Ee(e,ge))}return r.value=M.value,r.dispatchEvent(new Event("change",{bubbles:!0})),O("select_option",r,{value:M.value,selectedText:(M.text||"").trim(),verification:"required"})}const n=r,{roots:a,searchedIds:i,allListboxes:s,ariaControlsBefore:o,ariaControlsAfter:d}=await Gn(n),l=[...new Set(a.flatMap(M=>Array.from(M.querySelectorAll('[role="option"]'))))],p=e.trim().toLowerCase(),E=M=>(M.textContent||"").trim(),N=M=>M.startsWith(`${p} `)||M.startsWith(`${p},`)||M.startsWith(`${p}+`),ae=l.filter(M=>N(E(M).toLowerCase())),Se=l.find(M=>E(M)===e.trim())||l.find(M=>E(M).toLowerCase()===p)||(ae.length===1?ae[0]:void 0);if(!Se){const M=l.map((ie,Dt)=>({refId:ie.getAttribute("data-ref-id")||`opt${Dt}`,name:(ie.textContent||"").trim()||void 0})),ge=s.filter(ie=>!a.includes(ie)&&!oe(ie)).map(ie=>ie.id).filter(Boolean);R(Ee(e,M,{searchedIds:i,ignoredIds:ge,targetRefId:n.getAttribute("data-ref-id")||void 0,targetName:n.getAttribute("aria-label")||n.getAttribute("data-ref-id")||"",ariaControlsBefore:o,ariaControlsAfter:d,isDropdown:!0}))}for(const M of["mouseover","mousedown","mouseup"])Se.dispatchEvent(new MouseEvent(M,{bubbles:!0,cancelable:!0}));return Se.click(),O("select_option",r,{value:r instanceof HTMLInputElement?r.value:e,selectedText:(Se.textContent||"").trim(),verification:"required"})},check:t=>{const e=t.refId,r=t.label,n=t.checked??!0,a=z(e,r);if(K(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(Ee(`radio group "${e}"`,[]));const i=a.find(s=>s.value===r);if(!i){const s=a.map((o,d)=>({refId:`radio${d}`,name:o.value||void 0}));R(Ee(`radio value "${r}" in group "${e}"`,s))}return K(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=z(e,r);K(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=z(e,r);let a=null;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}));const i=a.checkValidity();return O("submit",a,{dispatched:!0,valid:i,invalid:!i,invalidControls:$n(a),observationId:Ce(),verification:"required"})},scroll:t=>{mt();const e=t.direction,r=t.amount,{top:n,left:a}=Qn(e,r),i=ea(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=z(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=z(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=ta(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=kt(t);return ye.debug("snapshot",{maxNodes:e,hasBody:!!document.body}),gt(e)},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=kt(t);return pt(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=kt(t),r=pt(e),n=t.filter??{};return{text:"",nodes:On(r.nodes,n),url:r.url,title:r.title,viewport:r.viewport}},find:t=>{ot();const e=t.selector,r=Array.from(document.querySelectorAll(e)),n=[],a=r.map(i=>{var E;const s=Ke(i);n.push({refId:s,element:i});const o=B(i),d=ee(i),l={tag:i.tagName.toLowerCase(),refId:s,role:o,text:((E=i.textContent)==null?void 0:E.slice(0,100))||"",...ze(i)};d&&(l.name=d);const p=i.tagName.toLowerCase();if(p==="a"){const N=se(i.getAttribute("href"));N&&(l.href=N)}if(p==="img"){const N=se(i.getAttribute("src"));N&&(l.src=N),l.alt=i.getAttribute("alt")||""}if(p==="input"){const N=i.getAttribute("title");N&&(l.title=N)}if(p==="img"||p==="a"){const N=Ut(i);N&&(l.parentRefId=N)}return l});return ht(n),a},dom:t=>{ot();const e=t.selector,r=t.depth??2,n=t.includeHidden??!0,a=Array.from(document.querySelectorAll(e)),i=[],s=a.map(o=>Qt(o,r,n,i)).filter(o=>o!==null);return ht(i),{nodes:s,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 Xn(Jn,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 d;return{tag:o.tagName,text:((d=o.textContent)==null?void 0:d.trim().slice(0,200))||""}})}else if(i==="links"){const s=Array.from(document.querySelectorAll("a[href]"));r.links=s.map(o=>{var d;return{href:o.getAttribute("href"),text:((d=o.textContent)==null?void 0:d.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,d=()=>o.abort();if(e){if(e.aborted)throw new DOMException("Aborted","AbortError");e.addEventListener("abort",d,{once:!0})}const l=setTimeout(()=>o.abort(),s);try{const p={method:n,headers:a,signal:o.signal};i!==null&&(p.body=i);const E=await fetch(r,p);return Cn(E)}finally{clearTimeout(l),e==null||e.removeEventListener("abort",d)}}};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 sr;(function(t){t.mergeShapes=(e,r)=>({...e,...r})})(sr||(sr={}));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,d=0;for(;d<s.path.length;){const l=s.path[d];d===s.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(r(s))):o[l]=o[l]||{_errors:[]},o=o[l],d++}}};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 Oe=(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 na=Oe;function It(){return na}const Tt=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 d=n.filter(l=>!!l).slice().reverse();for(const l of d)o=l(s,{data:e,defaultError:o}).message;return{...a,path:i,message:o}};function m(t,e){const r=It(),n=Tt({issueData:e,data:t.data,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,r,r===Oe?void 0:Oe].filter(a=>!!a)});t.common.issues.push(n)}class P{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 w;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 P.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 w;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 w=Object.freeze({status:"aborted"}),Me=t=>({status:"dirty",value:t}),$=t=>({status:"valid",value:t}),or=t=>t.status==="aborted",cr=t=>t.status==="dirty",we=t=>t.status==="valid",Ye=t=>typeof Promise<"u"&&t instanceof Promise;var y;(function(t){t.errToObj=e=>typeof e=="string"?{message:e}:e||{},t.toString=e=>typeof e=="string"?e:e==null?void 0:e.message})(y||(y={}));class G{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 lr=(t,e)=>{if(we(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 k(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:d}=t;return s.code==="invalid_enum_value"?{message:d??o.defaultError}:typeof o.data>"u"?{message:d??n??o.defaultError}:s.code!=="invalid_type"?{message:o.defaultError}:{message:d??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 P,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(Ye(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 lr(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 we(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=>we(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(Ye(a)?a:Promise.resolve(a));return lr(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(d=>d?!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 re({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 H.create(this,this._def)}nullable(){return ue.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return V.create(this)}promise(){return Ie.create(this,this._def)}or(e){return Le.create([this,e],this._def)}and(e){return Pe.create(this,e,this._def)}transform(e){return new re({...k(this._def),schema:this,typeName:x.ZodEffects,effect:{type:"transform",transform:e}})}default(e){const r=typeof e=="function"?e:()=>e;return new Ue({...k(this._def),innerType:this,defaultValue:r,typeName:x.ZodDefault})}brand(){return new Mt({typeName:x.ZodBranded,type:this,...k(this._def)})}catch(e){const r=typeof e=="function"?e:()=>e;return new Ze({...k(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 nt.create(this,e)}readonly(){return Ve.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}}const aa=/^c[^\s-]{8,}$/i,ia=/^[0-9a-z]+$/,sa=/^[0-9A-HJKMNP-TV-Z]{26}$/i,oa=/^[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,ca=/^[a-z0-9_-]{21}$/i,la=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,da=/^[-+]?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)?)??$/,ua=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,pa="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";let St;const fa=/^(?:(?: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])$/,ha=/^(?:(?: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])$/,ma=/^(([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]))$/,ba=/^(([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])$/,ga=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,ya=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,dr="((\\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])))",va=new RegExp(`^${dr}$`);function ur(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 _a(t){return new RegExp(`^${ur(t)}$`)}function wa(t){let e=`${dr}T${ur(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 xa(t,e){return!!((e==="v4"||!e)&&fa.test(t)||(e==="v6"||!e)&&ma.test(t))}function ka(t,e){if(!la.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 Ia(t,e){return!!((e==="v4"||!e)&&ha.test(t)||(e==="v6"||!e)&&ba.test(t))}class J 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}),w}const n=new P;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")ua.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")St||(St=new RegExp(pa,"u")),St.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")oa.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")ca.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")aa.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")ia.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")sa.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"?wa(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"?va.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{code:f.invalid_string,validation:"date",message:i.message}),n.dirty()):i.kind==="time"?_a(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"?da.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"duration",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="ip"?xa(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"?ka(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"?Ia(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"?ga.test(e.data)||(a=this._getOrReturnCtx(e,a),m(a,{validation:"base64",code:f.invalid_string,message:i.message}),n.dirty()):i.kind==="base64url"?ya.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,...y.errToObj(n)})}_addCheck(e){return new J({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...y.errToObj(e)})}url(e){return this._addCheck({kind:"url",...y.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...y.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...y.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...y.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...y.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...y.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...y.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...y.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...y.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...y.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...y.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...y.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,...y.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,...y.errToObj(e==null?void 0:e.message)})}duration(e){return this._addCheck({kind:"duration",...y.errToObj(e)})}regex(e,r){return this._addCheck({kind:"regex",regex:e,...y.errToObj(r)})}includes(e,r){return this._addCheck({kind:"includes",value:e,position:r==null?void 0:r.position,...y.errToObj(r==null?void 0:r.message)})}startsWith(e,r){return this._addCheck({kind:"startsWith",value:e,...y.errToObj(r)})}endsWith(e,r){return this._addCheck({kind:"endsWith",value:e,...y.errToObj(r)})}min(e,r){return this._addCheck({kind:"min",value:e,...y.errToObj(r)})}max(e,r){return this._addCheck({kind:"max",value:e,...y.errToObj(r)})}length(e,r){return this._addCheck({kind:"length",value:e,...y.errToObj(r)})}nonempty(e){return this.min(1,y.errToObj(e))}trim(){return new J({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new J({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new J({...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}}J.create=t=>new J({checks:[],typeName:x.ZodString,coerce:(t==null?void 0:t.coerce)??!1,...k(t)});function Ta(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}),w}let n;const a=new P;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"?Ta(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,y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,y.toString(r))}setLimit(e,r,n,a){return new fe({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:y.toString(a)}]})}_addCheck(e){return new fe({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:y.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:y.toString(r)})}finite(e){return this._addCheck({kind:"finite",message:y.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:y.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:y.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,...k(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 P;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}),w}gte(e,r){return this.setLimit("min",e,!0,y.toString(r))}gt(e,r){return this.setLimit("min",e,!1,y.toString(r))}lte(e,r){return this.setLimit("max",e,!0,y.toString(r))}lt(e,r){return this.setLimit("max",e,!1,y.toString(r))}setLimit(e,r,n,a){return new he({...this._def,checks:[...this._def.checks,{kind:e,value:r,inclusive:n,message:y.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:y.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:y.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:y.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:y.toString(e)})}multipleOf(e,r){return this._addCheck({kind:"multipleOf",value:e,message:y.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,...k(t)});class et 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}),w}return $(e.data)}}et.create=t=>new et({typeName:x.ZodBoolean,coerce:(t==null?void 0:t.coerce)||!1,...k(t)});class qe 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}),w}if(Number.isNaN(e.data.getTime())){const i=this._getOrReturnCtx(e);return m(i,{code:f.invalid_date}),w}const n=new P;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 qe({...this._def,checks:[...this._def.checks,e]})}min(e,r){return this._addCheck({kind:"min",value:e.getTime(),message:y.toString(r)})}max(e,r){return this._addCheck({kind:"max",value:e.getTime(),message:y.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}}qe.create=t=>new qe({checks:[],coerce:(t==null?void 0:t.coerce)||!1,typeName:x.ZodDate,...k(t)});class pr 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}),w}return $(e.data)}}pr.create=t=>new pr({typeName:x.ZodSymbol,...k(t)});class tt 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}),w}return $(e.data)}}tt.create=t=>new tt({typeName:x.ZodUndefined,...k(t)});class De 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}),w}return $(e.data)}}De.create=t=>new De({typeName:x.ZodNull,...k(t)});class Et extends S{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}}Et.create=t=>new Et({typeName:x.ZodAny,...k(t)});class me extends S{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}}me.create=t=>new me({typeName:x.ZodUnknown,...k(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}),w}}le.create=t=>new le({typeName:x.ZodNever,...k(t)});class At 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}),w}return $(e.data)}}At.create=t=>new At({typeName:x.ZodVoid,...k(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}),w;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 G(r,s,r.path,o)))).then(s=>P.mergeArray(n,s));const i=[...r.data].map((s,o)=>a.type._parseSync(new G(r,s,r.path,o)));return P.mergeArray(n,i)}get element(){return this._def.type}min(e,r){return new V({...this._def,minLength:{value:e,message:y.toString(r)}})}max(e,r){return new V({...this._def,maxLength:{value:e,message:y.toString(r)}})}length(e,r){return new V({...this._def,exactLength:{value:e,message:y.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,...k(e)});function xe(t){if(t instanceof q){const e={};for(const r in t.shape){const n=t.shape[r];e[r]=H.create(xe(n))}return new q({...t._def,shape:()=>e})}else return t instanceof V?new V({...t._def,type:xe(t.element)}):t instanceof H?H.create(xe(t.unwrap())):t instanceof ue?ue.create(xe(t.unwrap())):t instanceof X?X.create(t.items.map(e=>xe(e))):t}class q 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 l=this._getOrReturnCtx(e);return m(l,{code:f.invalid_type,expected:b.object,received:l.parsedType}),w}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 l in a.data)s.includes(l)||o.push(l);const d=[];for(const l of s){const p=i[l],E=a.data[l];d.push({key:{status:"valid",value:l},value:p._parse(new G(a,E,a.path,l)),alwaysSet:l in a.data})}if(this._def.catchall instanceof le){const l=this._def.unknownKeys;if(l==="passthrough")for(const p of o)d.push({key:{status:"valid",value:p},value:{status:"valid",value:a.data[p]}});else if(l==="strict")o.length>0&&(m(a,{code:f.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{const l=this._def.catchall;for(const p of o){const E=a.data[p];d.push({key:{status:"valid",value:p},value:l._parse(new G(a,E,a.path,p)),alwaysSet:p in a.data})}}return a.common.async?Promise.resolve().then(async()=>{const l=[];for(const p of d){const E=await p.key,N=await p.value;l.push({key:E,value:N,alwaysSet:p.alwaysSet})}return l}).then(l=>P.mergeObjectSync(n,l)):P.mergeObjectSync(n,d)}get shape(){return this._def.shape()}strict(e){return y.errToObj,new q({...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:y.errToObj(e).message??a}:{message:a}}}:{}})}strip(){return new q({...this._def,unknownKeys:"strip"})}passthrough(){return new q({...this._def,unknownKeys:"passthrough"})}extend(e){return new q({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new q({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 q({...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 q({...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 q({...this._def,shape:()=>r})}deepPartial(){return xe(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 q({...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 H;)i=i._def.innerType;r[n]=i}return new q({...this._def,shape:()=>r})}keyof(){return fr(C.objectKeys(this.shape))}}q.create=(t,e)=>new q({shape:()=>t,unknownKeys:"strip",catchall:le.create(),typeName:x.ZodObject,...k(e)}),q.strictCreate=(t,e)=>new q({shape:()=>t,unknownKeys:"strict",catchall:le.create(),typeName:x.ZodObject,...k(e)}),q.lazycreate=(t,e)=>new q({shape:t,unknownKeys:"strip",catchall:le.create(),typeName:x.ZodObject,...k(e)});class Le 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}),w}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 d of n){const l={...r,common:{...r.common,issues:[]},parent:null},p=d._parseSync({data:r.data,path:r.path,parent:l});if(p.status==="valid")return p;p.status==="dirty"&&!i&&(i={result:p,ctx:l}),l.common.issues.length&&s.push(l.common.issues)}if(i)return r.common.issues.push(...i.ctx.common.issues),i.result;const o=s.map(d=>new U(d));return m(r,{code:f.invalid_union,unionErrors:o}),w}}get options(){return this._def.options}}Le.create=(t,e)=>new Le({options:t,typeName:x.ZodUnion,...k(e)});const te=t=>t instanceof Fe?te(t.schema):t instanceof re?te(t.innerType()):t instanceof Be?[t.value]:t instanceof de?t.options:t instanceof Rt?C.objectValues(t.enum):t instanceof Ue?te(t._def.innerType):t instanceof tt?[void 0]:t instanceof De?[null]:t instanceof H?[void 0,...te(t.unwrap())]:t instanceof ue?[null,...te(t.unwrap())]:t instanceof Mt||t instanceof Ve?te(t.unwrap()):t instanceof Ze?te(t._def.innerType):[];class rt 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}),w;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]}),w)}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=te(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 rt({typeName:x.ZodDiscriminatedUnion,discriminator:e,options:r,optionsMap:a,...k(n)})}}function Ct(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 d=Ct(t[o],e[o]);if(!d.valid)return{valid:!1};s[o]=d.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],d=Ct(s,o);if(!d.valid)return{valid:!1};a.push(d.data)}return{valid:!0,data:a}}else return r===b.date&&n===b.date&&+t==+e?{valid:!0,data:t}:{valid:!1}}class Pe extends S{_parse(e){const{status:r,ctx:n}=this._processInputParams(e),a=(i,s)=>{if(or(i)||or(s))return w;const o=Ct(i.value,s.value);return o.valid?((cr(i)||cr(s))&&r.dirty(),{status:r.value,value:o.data}):(m(n,{code:f.invalid_intersection_types}),w)};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}))}}Pe.create=(t,e,r)=>new Pe({left:t,right:e,typeName:x.ZodIntersection,...k(r)});class X 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}),w;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"}),w;!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 d=this._def.items[o]||this._def.rest;return d?d._parse(new G(n,s,n.path,o)):null}).filter(s=>!!s);return n.common.async?Promise.all(i).then(s=>P.mergeArray(r,s)):P.mergeArray(r,i)}get items(){return this._def.items}rest(e){return new X({...this._def,rest:e})}}X.create=(t,e)=>{if(!Array.isArray(t))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new X({items:t,typeName:x.ZodTuple,rest:null,...k(e)})};class $e 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}),w;const a=[],i=this._def.keyType,s=this._def.valueType;for(const o in n.data)a.push({key:i._parse(new G(n,o,n.path,o)),value:s._parse(new G(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?P.mergeObjectAsync(r,a):P.mergeObjectSync(r,a)}get element(){return this._def.valueType}static create(e,r,n){return r instanceof S?new $e({keyType:e,valueType:r,typeName:x.ZodRecord,...k(n)}):new $e({keyType:J.create(),valueType:e,typeName:x.ZodRecord,...k(r)})}}class Nt 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}),w;const a=this._def.keyType,i=this._def.valueType,s=[...n.data.entries()].map(([o,d],l)=>({key:a._parse(new G(n,o,n.path,[l,"key"])),value:i._parse(new G(n,d,n.path,[l,"value"]))}));if(n.common.async){const o=new Map;return Promise.resolve().then(async()=>{for(const d of s){const l=await d.key,p=await d.value;if(l.status==="aborted"||p.status==="aborted")return w;(l.status==="dirty"||p.status==="dirty")&&r.dirty(),o.set(l.value,p.value)}return{status:r.value,value:o}})}else{const o=new Map;for(const d of s){const l=d.key,p=d.value;if(l.status==="aborted"||p.status==="aborted")return w;(l.status==="dirty"||p.status==="dirty")&&r.dirty(),o.set(l.value,p.value)}return{status:r.value,value:o}}}}Nt.create=(t,e,r)=>new Nt({valueType:e,keyType:t,typeName:x.ZodMap,...k(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}),w;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(d){const l=new Set;for(const p of d){if(p.status==="aborted")return w;p.status==="dirty"&&r.dirty(),l.add(p.value)}return{status:r.value,value:l}}const o=[...n.data.values()].map((d,l)=>i._parse(new G(n,d,n.path,l)));return n.common.async?Promise.all(o).then(d=>s(d)):s(o)}min(e,r){return new ke({...this._def,minSize:{value:e,message:y.toString(r)}})}max(e,r){return new ke({...this._def,maxSize:{value:e,message:y.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,...k(e)});class je 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}),w;function n(o,d){return Tt({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,It(),Oe].filter(l=>!!l),issueData:{code:f.invalid_arguments,argumentsError:d}})}function a(o,d){return Tt({data:o,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,It(),Oe].filter(l=>!!l),issueData:{code:f.invalid_return_type,returnTypeError:d}})}const i={errorMap:r.common.contextualErrorMap},s=r.data;if(this._def.returns instanceof Ie){const o=this;return $(async function(...d){const l=new U([]),p=await o._def.args.parseAsync(d,i).catch(ae=>{throw l.addIssue(n(d,ae)),l}),E=await Reflect.apply(s,this,p);return await o._def.returns._def.type.parseAsync(E,i).catch(ae=>{throw l.addIssue(a(E,ae)),l})})}else{const o=this;return $(function(...d){const l=o._def.args.safeParse(d,i);if(!l.success)throw new U([n(d,l.error)]);const p=Reflect.apply(s,this,l.data),E=o._def.returns.safeParse(p,i);if(!E.success)throw new U([a(p,E.error)]);return E.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new je({...this._def,args:X.create(e).rest(me.create())})}returns(e){return new je({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,r,n){return new je({args:e||X.create([]).rest(me.create()),returns:r||me.create(),typeName:x.ZodFunction,...k(n)})}}class Fe 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})}}Fe.create=(t,e)=>new Fe({getter:t,typeName:x.ZodLazy,...k(e)});class Be 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}),w}return{status:"valid",value:e.data}}get value(){return this._def.value}}Be.create=(t,e)=>new Be({value:t,typeName:x.ZodLiteral,...k(e)});function fr(t,e){return new de({values:t,typeName:x.ZodEnum,...k(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}),w}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}),w}return $(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=fr;class Rt 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}),w}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}),w}return $(e.data)}get enum(){return this._def.values}}Rt.create=(t,e)=>new Rt({values:t,typeName:x.ZodNativeEnum,...k(e)});class Ie 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}),w;const n=r.parsedType===b.promise?r.data:Promise.resolve(r.data);return $(n.then(a=>this._def.type.parseAsync(a,{path:r.path,errorMap:r.common.contextualErrorMap})))}}Ie.create=(t,e)=>new Ie({type:t,typeName:x.ZodPromise,...k(e)});class re 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 w;const d=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return d.status==="aborted"?w:d.status==="dirty"||r.value==="dirty"?Me(d.value):d});{if(r.value==="aborted")return w;const o=this._def.schema._parseSync({data:s,path:n.path,parent:n});return o.status==="aborted"?w:o.status==="dirty"||r.value==="dirty"?Me(o.value):o}}if(a.type==="refinement"){const s=o=>{const d=a.refinement(o,i);if(n.common.async)return Promise.resolve(d);if(d 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"?w:(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"?w:(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(!we(s))return w;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=>we(s)?Promise.resolve(a.transform(s.value,i)).then(o=>({status:r.value,value:o})):w);C.assertNever(a)}}re.create=(t,e,r)=>new re({schema:t,typeName:x.ZodEffects,effect:e,...k(r)}),re.createWithPreprocess=(t,e,r)=>new re({schema:e,effect:{type:"preprocess",transform:t},typeName:x.ZodEffects,...k(r)});class H extends S{_parse(e){return this._getType(e)===b.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}H.create=(t,e)=>new H({innerType:t,typeName:x.ZodOptional,...k(e)});class ue extends S{_parse(e){return this._getType(e)===b.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}}ue.create=(t,e)=>new ue({innerType:t,typeName:x.ZodNullable,...k(e)});class Ue 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}}Ue.create=(t,e)=>new Ue({innerType:t,typeName:x.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...k(e)});class Ze 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 Ye(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}}Ze.create=(t,e)=>new Ze({innerType:t,typeName:x.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...k(e)});class Ot 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}),w}return{status:"valid",value:e.data}}}Ot.create=t=>new Ot({typeName:x.ZodNaN,...k(t)});class Mt 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 nt 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"?w:i.status==="dirty"?(r.dirty(),Me(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"?w: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 nt({in:e,out:r,typeName:x.ZodPipeline})}}class Ve extends S{_parse(e){const r=this._def.innerType._parse(e),n=a=>(we(a)&&(a.value=Object.freeze(a.value)),a);return Ye(r)?r.then(a=>n(a)):n(r)}unwrap(){return this._def.innerType}}Ve.create=(t,e)=>new Ve({innerType:t,typeName:x.ZodReadonly,...k(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=J.create,h=fe.create,Q=he.create,g=et.create,hr=De.create,_=me.create;le.create;const T=V.create,u=q.create,I=Le.create,Sa=rt.create;Pe.create;const Ea=X.create,v=$e.create,Aa=Fe.create,He=Be.create,Te=de.create;Ie.create,H.create,ue.create;const ne=re.createWithPreprocess;function L(t,e=0,r=2){if(e>r)return"...";if(t instanceof q){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],d=o instanceof H,l=L(d?o.unwrap():o,e+1,r);return`${s}${d?"?":""}: ${l}`}).join(", ")} }`}if(t instanceof Le)return t.options.map(n=>L(n,e,r)).join(" or ");if(t instanceof J)return"string";if(t instanceof fe)return"number";if(t instanceof et)return"boolean";if(t instanceof he)return"bigint";if(t instanceof De)return"null";if(t instanceof V){const n=L(t.element,e+1,r);return n==="unknown"||n==="any"?"array":`${n}[]`}if(t instanceof X)return`[${t.items.map(n=>L(n,e+1,r)).join(", ")}]`;if(t instanceof $e){const n=L(t._def.valueType,e+1,r);return n==="unknown"||n==="any"?"{ [key: string]: unknown }":`{ [key: string]: ${n} }`}return t instanceof H?`${L(t.unwrap(),e,r)}?`:t instanceof Be?JSON.stringify(t.value):t instanceof de?t.options.map(n=>`"${n}"`).join(" | "):t instanceof Et?"any":t instanceof me?"unknown":t instanceof At?"void":t instanceof tt?"undefined":t instanceof re?L(t.innerType(),e,r):t instanceof Ue?L(t.removeDefault(),e,r):t instanceof ue?`${L(t.unwrap(),e,r)} | null`:t instanceof Fe?"lazy":t instanceof Ie?`Promise<${L(t.unwrap(),e+1,r)}>`:t instanceof je?"function":t instanceof qe?"Date":t instanceof Nt?"Map":t instanceof ke?"Set":t instanceof Pe?`${L(t._def.left,e,r)} & ${L(t._def.right,e,r)}`:t instanceof rt?t.options.map(n=>L(n,e,r)).join(" or "):t instanceof Mt?L(t.unwrap(),e,r):t instanceof Ot?"NaN":t instanceof Ze?L(t.removeCatch(),e,r):t instanceof nt?L(t._def.in,e,r):t instanceof Ve?`readonly ${L(t.unwrap(),e,r)}`:"unknown"}function Ca(t){return t===null?"null":t===void 0?"undefined":Array.isArray(t)?"array":typeof t}function Na(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(l=>l.code==="custom"),d=a.some(l=>l.code!=="invalid_type"&&l.code!=="invalid_literal"&&l.code!=="invalid_union");if(!o&&!d){const l=L(e),p=Ca(n);return`Invalid parameters for ${t}: expected ${l}${l==="{ }"?" 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 Ra(t,e,r,n,a){const i=t.safeParse(Qe(n));if(!i.success)return{ok:!1,error:{message:Na(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 d=o.error.issues.map(l=>{const p=l.path.join(".");return`invalid return value${p?` at '${p}'`:""} (${l.message})`});return{ok:!1,error:{message:`Invalid return value for ${a}: ${d.join("; ")}`,code:"E_INVALID_RETURN",category:"validation"}}}return{ok:!0,value:o.data}}catch(s){const o=$t(s),d=o.code==="E_EXTENSION"&&(typeof s!="object"||s===null||!("code"in s));return{ok:!1,error:{...o,code:d?"E_HANDLER":o.code,message:`${a}: ${o.message}`}}}}const mr=new Map,at=new Map;function Oa(t){mr.set(t.registryAction,t)}function it(t){return mr.get(t)}function Ma(t){for(const e of t)Oa(e);try{chrome.runtime.sendMessage({type:"contentScriptReady"})}catch{}}function qa(t){const e=at.get(t);return e?(e.abort(),at.delete(t),!0):!1}async function Da(t,e,r,n,a){const i=it(t);if(!i)return{ok:!1,error:{message:`No schema registered for content-script action: ${t}`,code:"E_INTERNAL"}};const s=new AbortController;a&&at.set(a,s);try{return await Ra(i.params,i.returns,async o=>r(o,s.signal),Qe(n),t)}finally{a&&at.delete(a)}}function La(t,e){if(it(t))return t;const r=`page_${e}`;return it(r)?r:t}function Pa(t,e){const r=it(t);return(r==null?void 0:r.handlerKey)??e}function br(t,e,r,n,a){const i=La(t,e),s=Pa(i,e),o=ra[s];return o?(Da(i,s,o,r,a).then(l=>{ye.debug("dispatch_response",{registryAction:t,handlerAction:s,ok:l.ok}),n(l)}).catch(l=>{const p=$t(l,{});ye.debug("dispatch_error",{registryAction:t,handlerAction:s,error:p.message}),n({ok:!1,error:p})}),!0):(ye.debug("no_handler",{action:s,registryAction:t}),n({ok:!1,error:`Unknown content script action: ${s}`}),!1)}function $a(){chrome.runtime.onMessage.addListener((t,e,r)=>{if(e.id!==chrome.runtime.id)return ye.warn("unauthorized_sender",{senderId:e.id,expected:chrome.runtime.id}),r({ok:!1,error:"Unauthorized sender"}),!1;const n=_e(t),a=String(n.type??""),i=String(n.action??"");if(ye.debug("received",{messageType:a,action:i,hasParams:!!n.params}),a==="registryCallCancel"){const s=String(n.id??"");return qa(s),r({ok:!0}),!1}if(a==="registryCall"){const s=Er(i),o=typeof n.id=="string"?n.id:void 0;return br(i,s,n.params,r,o)}return!i&&a==="contract-ping"?(r({ok:!0}),!1):i?i==="ping"?br("ping","ping",n.params,r):(r({ok:!1,error:"Use registryCall for content-script actions"}),!1):(r({ok:!1,error:"Missing action"}),!1)})}v(_()),v(_()),v(_()),v(_()),I([h(),v(_())]),I([h(),v(_())]),v(_()),v(_()),v(_()),I([c(),v(_())]),v(_()),v(_()),v(_()),v(_()),v(_()),I([c(),h(),v(_())]),v(_()),v(_()),v(_()),I([h(),v(_())]),v(_()),v(_()),v(_()),v(_()),v(_()),T(_()),I([c(),v(_())]),v(_()),I([c(),v(_())]),v(_()),I([c(),v(_())]),v(_()),I([c(),v(_())]),v(_()),v(_()),I([h(),v(_())]),v(_()),v(_()),I([h(),v(_())]),v(_()),I([c(),h(),v(_())]),v(_()),v(_()),v(_()),v(_()),I([h(),v(_())]),I([h(),v(_())]),I([h(),v(_())]),I([h(),v(_())]),I([h(),v(_())]),v(_()),v(_()),v(_()),u({}),I([Ea([I([u({text:c()}),c()])]),u({text:c().optional(),value:c().optional()})]);const j=()=>I([Q(),h().finite()]).transform(t=>BigInt(t)),Z=()=>c().regex(/^(?:f\d+_)?e\d+$/),ja='use { refId: "e2" } or { label: "..." } object form, not positional arguments',qt=(t,e)=>{if(t.__invalidPositional!==void 0){e.addIssue({code:f.custom,message:ja});return}!t.refId&&!t.label&&e.addIssue({code:f.custom,message:"Either refId or label is required"})},gr=(t,e)=>{t.x!==void 0||t.y!==void 0||qt(t,e)},D=t=>ne(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,u({__invalidPositional:I([c(),h()]).optional().describe("Internal flag for positional argument rejection"),refId:Z().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(qt)),be={tabId:I([h(),Q()]).optional().describe("Target tab ID")},W=t=>ne(e=>typeof e=="string"||typeof e=="number"?{__invalidPositional:e}:e,u({__invalidPositional:I([c(),h()]).optional().describe("Internal flag for positional argument rejection"),...be,refId:Z().optional().describe("Element reference ID (e.g. e2)"),label:c().optional().describe("Human-readable element label"),...t}).superRefine(qt));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:j().describe("Byte offset to start reading"),len:h().describe("Number of bytes to read")}),u({path:c().describe("File path to update"),offset:j().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)")}),u({action:c().describe("Host action name"),params:u({}).passthrough().optional().describe("Parameters for the host action")}).passthrough();const Fa=I([c(),h(),g(),hr(),T(_()),v(_())]),Ba=u({url:c().describe("URL to fetch"),method:c().default("GET").describe("HTTP method (GET, POST, PUT, DELETE, etc.)"),headers:v(c()).default({}).describe("Request headers as key-value pairs"),body:c().nullable().default(null).describe("Request body string"),timeout:j().default(30000n).describe("Timeout in milliseconds"),store:g().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:j().describe("Duration to sleep in milliseconds")}),u({}),u({}),u({url:c().describe("URL to navigate to"),timeout:j().optional().describe("Navigation timeout in milliseconds"),waitUntil:Te(["load","networkidle"]).optional().describe("When to consider navigation complete: 'load' (tab status complete) or 'networkidle' (no in-flight requests for 500ms)")});const Ua=u({}),Za=u({});u({}),u({duration:j().default(1000n).describe("Duration to wait in milliseconds")});const Va=D(),Ha=(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"})},yr=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(Ha),vr=Sa("kind",[u({kind:He("bytes"),name:c().min(1),data:c().min(1),mimeType:c().optional()}),u({kind:He("url"),url:c().url(),name:c().min(1),mimeType:c().optional()})]),Wa=D({value:c().describe("Value to fill into the element")}),Ka=D({files:T(yr).min(1).describe("Files to attach to the input")}),za=D({files:T(vr).min(1).describe("Resolved files for content-script application")}),Ga=D({text:c().describe("Text to type into the element")}),Ja=D({text:c().describe("Text to append into the element")}),Xa=u({refId:Z().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)")}),Qa=D({value:I([c().describe("Value to select in the dropdown"),T(c()).describe("Values to select in a multiple dropdown (empty array clears selection)")]).describe("Value (string) or values (array) to select in the dropdown")}),Ya=D({value:c().describe("Visible text of the option to select (matched case-insensitively)")}),ei=D({checked:g().optional().describe("Desired checked state (true to check, false to uncheck)")}),ti=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")}),ri=D(),ni=u({}),ai=D(),ii=u({direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:h().default(300).describe("Pixels to scroll")}),si=ne(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,u({__invalidPositional:I([c(),h()]).optional().describe("Internal flag for positional argument rejection"),refId:Z().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(gr)),oi=D(),ci=u({selector:c().describe("CSS selector to find elements")}),li=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:g().default(!0).describe("Include elements hidden by CSS/aria (default true — this tool's purpose is to see what the curated snapshot filters out)")}),di=u({selector:c().describe("CSS selector to wait for"),timeout:j().default(30000n).describe("Timeout in milliseconds")}),ui=u({fields:T(c()).describe("Array of field names to extract")}),pi=ne(t=>Array.isArray(t)?{fields:t}:t,ui);I([h(),T(u({}).passthrough()),u({}).passthrough()]),u({});const A=u({ok:He(!0).describe("Whether the action succeeded"),action:c().describe("Action identifier (e.g. 'page_fill')"),refId:Z().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:I([c(),T(c())]).optional().describe("Final value of the element after the action (string, or string[] for multi-select)"),checked:g().optional().describe("Checked state after the action"),disabled:g().optional().describe("Whether the element is disabled"),readOnly:g().optional().describe("Whether the element is read-only"),required:g().optional().describe("Whether the element is required"),valid:g().optional().describe("HTML constraint validity after the action, when available"),invalid:g().optional().describe("Inverse validity / aria-invalid state after the action"),validationMessage:c().optional().describe("Browser validation message when the element is invalid"),invalidControls:T(u({refId:Z().optional(),tag:c(),role:c().optional(),name:c().optional(),field:c().optional().describe("Accessible field label or nearest label text"),error:c().optional().describe("Linked visible error text from aria-errormessage/aria-describedby"),value:c().optional(),required:g().optional(),validationMessage:c().optional()})).optional().describe("Invalid form controls after submit, when available"),text:c().optional().describe("Text content of the element"),selectedText:c().optional().describe("Visible option text selected by select_option"),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:T(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:He(!0).optional().describe("True if the action was dispatched to the DOM. Does NOT prove the application accepted it."),verification:He("required").optional().describe("Always 'required': a fresh observation is required to verify the effect.")});I([A,hr()]);const _r=u({status:h().describe("HTTP response status code"),ok:g().describe("Whether the response status is 2xx"),headers:v(c()).describe("Response headers as key-value pairs"),body:c().optional().describe("Response body (omitted when bodyEncoding is handle)"),bodyEncoding:Te(["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:Te(["connected","missing"]),domApis:Te(["ok","blocked"]),mutationsReady:g(),hint:c().optional(),recovery:T(c()).optional()});const fi=Fa,hi=u({refId:Z().describe("Element reference ID (e.g. e2)"),role:c().describe("ARIA role of the element"),tag:c().describe("HTML tag name"),controlType:c().optional().describe('Plain-language control type, e.g. "dropdown" for combobox/select'),actionable:g().optional().describe("Whether this node can be acted on directly"),forControl:c().optional().describe("refId of the dropdown this validation-proxy belongs to"),recommendedAction:c().optional().describe("Recommended page.* action for this control"),controls:c().optional().describe("ID(s) of controlled popup/listbox elements, when exposed"),expanded:g().optional().describe("Expanded state for popup controls"),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"),required:g().optional().describe("Whether the element is required"),valid:g().optional().describe("Constraint validity state"),invalid:g().optional().describe("Constraint invalidity state"),validationMessage:c().optional().describe("Browser constraint validation message"),errorMessage:c().optional().describe("Visible error text linked to the field"),checked:g().optional().describe("Checked state"),disabled:g().optional().describe("Whether the element is disabled"),readOnly:g().optional().describe("Whether the element is read-only"),selected:g().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:Z().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:T(c()).optional().describe("Image URLs contained within this element")}),st=u({text:c().describe("Broad text-first representation of the page, including visible text, form values, and validation/error text"),nodes:T(hi).describe("Broad snapshot nodes with refIds where possible; not limited to interactive elements"),formErrors:T(u({field:c().describe("Field label or refId"),error:c().describe("Linked visible error text"),refId:c().describe("refId of the invalid control")})).optional().describe("Visible linked form errors grouped by field"),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.")}),wr=u({refId:Z().optional(),tag:c(),role:c().optional(),name:c().optional(),text:c().optional(),attributes:v(c()).optional().describe("All HTML attributes (raw)"),hidden:g().optional(),hiddenReason:Te(["display-none","visibility-hidden","aria-hidden","opacity-zero","hidden-attr","inert"]).optional(),value:c().optional(),checked:g().optional(),disabled:g().optional(),readOnly:g().optional(),selected:g().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"),controlType:c().optional(),recommendedAction:c().optional(),controls:c().optional(),expanded:g().optional(),children:T(Aa(()=>wr)).optional().describe("Nested descendants up to `depth`")}),mi=u({nodes:T(wr),url:c(),title:c()}),xr=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:g().optional().describe("Whether the tab is active"),pinned:g().optional().describe("Whether the tab is pinned"),highlighted:g().optional().describe("Whether the tab is highlighted"),incognito:g().optional().describe("Whether the tab is incognito"),favIconUrl:c().optional().describe("Favicon URL"),audible:g().optional().describe("Whether the tab is audible"),groupId:h().optional().describe("Group ID"),openerTabId:h().optional().describe("Opener tab ID"),discarded:g().optional().describe("Whether the tab is discarded"),autoDiscardable:g().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(),bi=T(xr),kr=u({id:h().optional().describe("Window ID"),focused:g().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:bi.optional().describe("Array of tabs in the window"),incognito:g().optional().describe("Whether the window is incognito"),type:c().optional().describe("Window type"),state:c().optional().describe("Window state"),alwaysOnTop:g().optional().describe("Whether the window is always on top"),sessionId:c().optional().describe("Session ID")}).passthrough();T(kr);const gi=u({name:c().describe("Cookie name"),value:c().describe("Cookie value"),domain:c().optional().describe("Cookie domain"),hostOnly:g().optional().describe("Whether the cookie is host-only"),path:c().optional().describe("Cookie path"),secure:g().optional().describe("Whether the cookie is secure"),httpOnly:g().optional().describe("Whether the cookie is HTTP-only"),sameSite:c().optional().describe("SameSite policy"),session:g().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();T(gi.nullable().unwrap());const yi=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:T(u({id:c()}).passthrough()).optional().describe("Child bookmarks")}).passthrough();T(yi);const vi=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();T(vi);const _i=u({frameId:h().describe("Frame ID"),result:_().optional().describe("Script result")});T(_i),c(),g(),I([c(),h()]),g();const wi=u({id:h().optional().describe("Group ID"),collapsed:g().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();T(wi);const xi=u({lastModified:h().optional().describe("Last modified time"),tab:xr.optional().describe("Tab info"),window:kr.optional().describe("Window info")}).passthrough(),ki=T(xi),Ii=u({deviceName:c().optional().describe("Device name"),sessions:ki.optional().describe("Sessions")}).passthrough();T(Ii);const Ti=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:g().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:g().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();T(Ti),h(),u({archName:c().describe("CPU architecture"),modelName:c().describe("CPU model"),numOfProcessors:h().describe("Number of processors"),features:T(c()).describe("CPU features")}),u({capacity:h().describe("Total memory capacity"),availableCapacity:h().describe("Available memory capacity")}),T(u({id:c().describe("Storage ID"),name:c().describe("Storage name"),type:c().describe("Storage type"),capacity:h().describe("Storage capacity")})),D(),D(),D({value:c().optional().describe("Value to fill into the element")}),D({text:c().optional().describe("Text to type into the element")}),u({key:c().optional().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),D({value:c().optional().describe("Value to select in the dropdown")}),D({checked:g().optional().describe("Desired checked state (true to check, false to uncheck)")}),D(),u({}),u({direction:c().optional().describe("Scroll direction: up, down, left, or right"),amount:h().optional().describe("Pixels to scroll")}),D(),D({text:c().optional().describe("Text to append into the element")}),u({}),u({}),u({duration:j().default(1000n).describe("Duration to wait in milliseconds")}),u({interactive_only:g().default(!1).describe("Only include interactive elements"),max_nodes:j().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:g().default(!1).describe("Only include interactive elements"),max_nodes:j().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:g().default(!1).describe("Only include interactive elements"),max_nodes:j().default(500n).describe("Maximum number of nodes to include in snapshot")}),u({interactive_only:g().default(!1).describe("Only include interactive elements"),max_nodes:j().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 Si=u({max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Ei=u({max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Ai=u({max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),Ci=u({role:I([c(),T(c())]).optional().describe("Filter by ARIA role"),tag:I([c(),T(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:g().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(),Ir=u({filter:Ci.optional().describe("Semantic filter criteria"),max_nodes:h().optional().describe("Maximum nodes to collect before filtering")}).passthrough(),Ni=Ir.extend({tabId:h().describe("Tab ID")});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 Ri=u({items:v(c()).describe("Record of key-value string pairs to store")});ne(t=>t!==null&&typeof t=="object"&&!Array.isArray(t)&&!("items"in t)?{items:t}:t,Ri);const Oi=u({keys:T(c()).describe("Array of storage keys to retrieve"),defaults:v(c()).optional().describe("Default string values for missing keys")});ne(t=>Array.isArray(t)?{keys:t}:t,Oi),u({});const Mi=u({keys:T(c()).describe("Array of storage keys to delete")});ne(t=>Array.isArray(t)?{keys:t}:t,Mi),u({}),u({active:g().optional().describe("Whether the tabs are active"),currentWindow:g().optional().describe("Whether the tabs are in the current window"),url:c().optional().describe("URL pattern to match tabs against")}).passthrough(),ne(t=>typeof t=="string"?{url:t}:t,u({url:c().optional().describe("URL to open in the new tab"),active:g().optional().describe("Whether to focus the new tab")})),I([h(),T(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 qi=W(),Di=W({value:c().describe("Value to fill into the element")}),Li=W({files:T(yr).min(1).describe("Files to attach to the input")}),Pi=W({files:T(vr).min(1).describe("Resolved files for content-script application")}),$i=ne(t=>typeof t=="string"||typeof t=="number"?{__invalidPositional:t}:t,u({__invalidPositional:I([c(),h()]).optional().describe("Internal flag for positional argument rejection"),...be,refId:Z().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(gr)),ji=W({text:c().describe("Text to type into the element")}),Fi=u({...be,key:c().describe("Key to press (e.g. Enter, Escape, ArrowDown)")}),Bi=W({value:c().describe("Value to select in the dropdown")}),Ui=W({value:c().describe("Visible text of the option to select (matched case-insensitively)")}),Zi=W({checked:g().optional().describe("Desired checked state (true to check, false to uncheck)")}),Vi=W(),Hi=W(),Wi=u({...be,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")}),Ki=u({...be}),zi=u({...be,direction:c().default("down").describe("Scroll direction: up, down, left, or right"),amount:h().default(300).describe("Pixels to scroll")}),Gi=W(),Ji=u({tabId:I([h(),Q()]).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(),Xi=u({tabId:I([h(),Q()]).optional().describe("Target tab ID")}).passthrough(),Qi=u({tabId:I([h(),Q()]).optional().describe("Target tab ID")}).passthrough();u({tabId:I([h(),Q()]).optional().describe("Target tab ID"),timeout:h().optional().describe("Timeout in milliseconds")}).passthrough();const Yi=u({tabId:I([h(),Q()]).optional().describe("Target tab ID"),url:c().optional().describe("URL to fetch"),options:u({}).passthrough().optional().describe("Fetch options")}).passthrough(),es=u({tabId:I([h(),Q()]).optional().describe("Target tab ID"),max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),ts=u({tabId:I([h(),Q()]).optional().describe("Target tab ID"),max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough(),rs=u({tabId:I([h(),Q()]).optional().describe("Target tab ID"),max_nodes:h().optional().describe("Maximum nodes to include"),options:u({}).passthrough().optional().describe("Snapshot options")}).passthrough();u({...be,url:c().describe("URL to navigate the tab to"),timeout:j().optional().describe("Navigation timeout in milliseconds"),waitUntil:Te(["load","networkidle"]).optional().describe("When to consider navigation complete: 'load' (tab status complete) or 'networkidle' (no in-flight requests for 500ms)")}).passthrough();const F="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.",ns=[{action:"page_back",namespace:"page",name:"back",description:"Go back in the active tab",params:Ua,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:Va,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:[F,"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:Wa,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:[F,"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:Ka,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:[F,"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:Ga,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:[F,"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:Ja,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:Xa,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:Qa,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:"Select a value from a dropdown/combobox (native select, react-select, ARIA listbox) by clicking the option whose visible text matches value",params:Ya,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: degree.refId, value: "Bachelor's Degree" })`,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","RULE: every dropdown (combobox/select/listbox) MUST use page.select_option({refId, value}). NEVER page.fill, page.type, or page.click on a dropdown control or its validation-proxy input.","Use this for snapshot nodes printed as dropdown or nodes with controlType='dropdown'; do not use page.fill/type on those controls","Drives react-select and other ARIA combobox patterns: clicks the control to open, follows the controlled listbox where available, 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:ei,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:ri,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:ni,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:ai,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:ti,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:ii,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:si,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:oi,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:"page_forward",namespace:"page",name:"forward",description:"Go forward in the active tab",params:Za,returns:A,paramTypes:[],returnDoc:"Navigation result",errorCode:"E_NO_TAB",example:"page.forward()",handlerKey:"forward"},{action:"page_snapshot",namespace:"page",name:"snapshot",description:"Capture a broad, text-first page snapshot. Default behavior is intentionally generous: visible text, form values, required/invalid state, and linked field error text are included with actionable refIds where possible.",params:Si,returns:c(),paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal). Defaults high; lower it only when you intentionally want a smaller snapshot."},{name:"options",type:"{ max_nodes?: number }",required:!1,description:"Snapshot options (literal). Use max_nodes only to opt into less output."}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"page.snapshot()",agentMeta:{notes:[F,"Content-script path; same refIds as mutations","Do not assume accessibility-only output: snapshot includes visible text and validation/error text even when it is not interactive","If the needed data, options, hidden input, or attributes are still missing, call page.dom({ selector, depth, includeHidden: true }) directly"],tags:["snapshot","read"],relatedApis:["page.snapshot_data","page.dom","web.tab.snapshot"]},handlerKey:"snapshot_text"},{action:"page_snapshot_text",namespace:"page",name:"snapshot_text",description:"Capture a broad text-first DOM snapshot and return only its text representation",params:Ei,returns:c(),paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal). Defaults high; lower it only when intentionally limiting output."}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"page.snapshot_text()",handlerKey:"snapshot_text"},{action:"page_snapshot_data",namespace:"page",name:"snapshot_data",description:"Get broad page snapshot data. Includes visible text, form values, required/invalid state, linked error text, and actionable refIds where possible.",params:Ai,returns:st,paramTypes:[{name:"max_nodes",type:"number",required:!1,description:"Maximum nodes to include (literal). Defaults high; lower it only when intentionally limiting output."}],returnDoc:"{ text, nodes, url, title, viewport }",errorCode:"E_SNAPSHOT",example:"page.snapshot_data()",agentMeta:{notes:[F,"Content-script path; nodes include refId for targeting when an element can be acted on","Snapshot is text-first and broad by default; filtering/limiting is opt-in via snapshot_query or max_nodes","After mutations, call snapshot_data() again to verify state","If a widget's raw attributes or hidden nodes matter, inspect them with page.dom({ selector, depth, includeHidden: true })"],tags:["snapshot","read"],relatedApis:["page.click","page.dom","web.tab.snapshot_data"]},handlerKey:"snapshot"},{action:"page_snapshot_query",namespace:"page",name:"snapshot_query",description:"Opt-in filtered snapshot query by role, tag, text, name, etc. Use this only when you intentionally want less than the default broad snapshot.",params:Ir,returns:st,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:[F,"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, but it can hide useful text by design","If filtering hides the data you need, use page.snapshot_data() or page.dom({ selector, depth, includeHidden: true })"],tags:["snapshot","read"],relatedApis:["page.snapshot_data","page.dom","page.find"]},handlerKey:"snapshot_query"},{action:"page_find",namespace:"page",name:"find",description:"Find elements in the active tab using a CSS selector",params:ci,returns:T(u({refId:Z(),role:c(),tag:c(),name:c().optional(),text:c().optional(),value:c().optional(),checked:g().optional(),disabled:g().optional(),readOnly:g().optional(),href:c().optional(),src:c().optional(),alt:c().optional(),title:c().optional(),parentRefId:Z().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","Returned refIds are immediately actionable — call page.click/fill/select_option on them without an intermediate snapshot_data","For dropdowns found via find, use page.select_option — not fill/type"],tags:["read"]},handlerKey:"find"},{action:"page_dom",namespace:"page",name:"dom",description:"Introspect raw DOM subtree by CSS selector. Read-only. Use this whenever snapshot/find do not expose enough data: hidden inputs, validation shims, raw attributes, dropdown/listbox ownership, shadowed widgets, aria-hidden regions, or exact DOM structure.",params:li,returns:mi,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:[F,"Read-only: returns DOM structure, never executes code or mutates the page","Bypasses snapshot filtering and can include hidden nodes by default","Assigns refIds to returned elements; those refIds are immediately actionable by page.click/fill/select_option/setFiles in the same cell — no intermediate snapshot_data needed","Use page.dom immediately when struggling to find data in snapshot output; do not keep guessing selectors from the accessibility tree","If a dom node is a dropdown (role=combobox/tag=select/controlType=dropdown), use page.select_option on its refId"],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:di,returns:g(),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:[F],tags:["read"]},handlerKey:"wait_for"},{action:"page_extract",namespace:"page",name:"extract",description:"Extract data from the active tab",params:pi,returns:u({title:c().optional(),url:c().optional(),headings:T(u({tag:c(),text:c()})).optional(),links:T(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:[F],tags:["read"]},handlerKey:"extract"},{action:"page_fetch",namespace:"page",name:"fetch",description:"Fetch in the active tab",params:Ba,returns:_r,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:[F,"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"}],as=[{action:"tab_click",namespace:"web.tab",name:"click",description:"Click in a tab",params:qi,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:Di,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:Li,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:$i,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:ji,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:Fi,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:Bi,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:Ui,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:Zi,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:Hi,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:Wi,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:Vi,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:Ki,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:zi,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:Gi,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:Xi,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:"tab_forward",namespace:"web.tab",name:"forward",description:"Go forward in a tab",params:Qi,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 a broad, text-first tab snapshot. Includes visible text, form values, validation/error text, and actionable refIds where possible.",params:es,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). Defaults high; lower it only when intentionally limiting output."}],returnDoc:"Snapshot text",errorCode:"E_SNAPSHOT",example:"web.tab.snapshot({ tabId: 123 })",agentMeta:{notes:[F,"Use web.tab.dom or page.dom if raw attributes, hidden nodes, or exact dropdown ownership are missing"],tags:["snapshot","read"],relatedApis:["web.tab.snapshot_data","page.dom"]},handlerKey:"snapshot_text"},{action:"tab_snapshot_text",namespace:"web.tab",name:"snapshot_text",description:"Get broad, text-first tab snapshot text",params:ts,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 broad tab snapshot data. Includes visible text, form values, validation/error text, and actionable refIds where possible.",params:rs,returns:st,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 })",agentMeta:{notes:[F,"Filtering/limiting is opt-in; this broad snapshot is the default","Use page.dom({ selector, depth, includeHidden: true }) when raw DOM attributes or hidden nodes matter"],tags:["snapshot","read"],relatedApis:["web.tab.snapshot","page.dom"]},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:Ni,returns:st,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:Yi,returns:_r,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:Ji,returns:fi,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"}],is=[...ns,...as];function ss(){return[{registryAction:"ping",handlerKey:"ping",params:u({}),returns:u({ok:g()})}]}const os=new Set(["page_set_files","tab_set_files"]);function cs(){return is.map(t=>({registryAction:t.action,handlerKey:t.handlerKey,params:os.has(t.action)?t.action==="tab_set_files"?Pi:za:t.params,returns:t.returns}))}if(Sr(),window.__jsNotebookContentScriptInjected)throw new Error("Content script already injected");window.__jsNotebookContentScriptInjected=!0,Ma([...cs(),...ss()]),$a()})();