browsentic 0.7.0 → 0.7.4

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.
@@ -1,7 +1,7 @@
1
- var content=(function(){function e(e){return e}var t=globalThis.browser?.runtime?.id?globalThis.browser:globalThis.chrome,n;function r(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var i=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},a=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(n=globalThis).__zod_globalConfig??(n.__zod_globalConfig={});var o=globalThis.__zod_globalConfig;function s(e){return e&&Object.assign(o,e),o}function c(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function l(e,t){return typeof t==`bigint`?t.toString():t}function u(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function d(e){return e==null}function f(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function p(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var m=Symbol(`evaluating`);function h(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==m)return r===void 0&&(r=m,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function g(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function _(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function v(e){return JSON.stringify(e)}function ee(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var te=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var re=u(()=>{if(o.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function y(e){if(ne(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(ne(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ie(e){return y(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ae=new Set([`string`,`number`,`symbol`]);function b(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function x(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function S(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function oe(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var se={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ce(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return x(e,_(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return g(this,`shape`,e),e},checks:[]}))}function le(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return x(e,_(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return g(this,`shape`,r),r},checks:[]}))}function ue(e,t){if(!y(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return x(e,_(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return g(this,`shape`,n),n}}))}function de(e,t){if(!y(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return x(e,_(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return g(this,`shape`,n),n}}))}function fe(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return x(e,_(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return g(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function pe(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return x(t,_(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return g(this,`shape`,i),i},checks:[]}))}function me(e,t,n){return x(t,_(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return g(this,`shape`,i),i}}))}function C(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function he(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function w(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function ge(e){return typeof e==`string`?e:e?.message}function T(e,t,n){let r=e.message?e.message:ge(e.inst?._zod.def?.error?.(e))??ge(t?.error?.(e))??ge(n.customError?.(e))??ge(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function _e(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function ve(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var ye=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,l,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},be=r(`$ZodError`,ye),xe=r(`$ZodError`,ye,{Parent:Error});function Se(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function Ce(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}function we(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Te(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${we(e.path)}`);return t.join(`
2
- `)}var Ee=e=>(t,n,r,a)=>{let o=r?{...r,async:!1}:{async:!1},c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise)throw new i;if(c.issues.length){let t=new((a?.Err)??e)(c.issues.map(e=>T(e,o,s())));throw te(t,a?.callee),t}return c.value},De=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>T(e,a,s())));throw te(t,i?.callee),t}return o.value},Oe=e=>(t,n,r)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new i;return o.issues.length?{success:!1,error:new(e??be)(o.issues.map(e=>T(e,a,s())))}:{success:!0,data:o.value}},ke=Oe(xe),Ae=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>T(e,i,s())))}:{success:!0,data:a.value}},je=Ae(xe),Me=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ee(e)(t,n,i)},Ne=e=>(t,n,r)=>Ee(e)(t,n,r),Pe=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return De(e)(t,n,i)},Fe=e=>async(t,n,r)=>De(e)(t,n,r),Ie=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Oe(e)(t,n,i)},Le=e=>(t,n,r)=>Oe(e)(t,n,r),Re=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Ae(e)(t,n,i)},ze=e=>async(t,n,r)=>Ae(e)(t,n,r),Be=/^[cC][0-9a-z]{6,}$/,Ve=/^[0-9a-z]+$/,He=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ue=/^[0-9a-vA-V]{20}$/,We=/^[A-Za-z0-9]{27}$/,Ge=/^[a-zA-Z0-9_-]{21}$/,Ke=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,qe=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Je=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Ye=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Xe=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Ze(){return new RegExp(Xe,`u`)}var Qe=/^(?:(?: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])$/,$e=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,et=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,tt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,nt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,rt=/^[A-Za-z0-9_-]*$/,it=/^https?$/,at=/^\+[1-9]\d{6,14}$/,ot=`(?:(?:\\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])))`,st=RegExp(`^${ot}$`);function ct(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function lt(e){return RegExp(`^${ct(e)}$`)}function ut(e){let t=ct({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${ot}T(?:${r})$`)}var dt=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},ft=/^-?\d+$/,pt=/^-?\d+(?:\.\d+)?$/,mt=/^(?:true|false)$/i,ht=/^[^A-Z]*$/,gt=/^[^a-z]*$/,E=r(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),_t={number:`number`,bigint:`bigint`,object:`date`},vt=r(`$ZodCheckLessThan`,(e,t)=>{E.init(e,t);let n=_t[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),yt=r(`$ZodCheckGreaterThan`,(e,t)=>{E.init(e,t);let n=_t[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),bt=r(`$ZodCheckMultipleOf`,(e,t)=>{E.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):p(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),xt=r(`$ZodCheckNumberFormat`,(e,t)=>{E.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=se[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=ft)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),St=r(`$ZodCheckMaxLength`,(e,t)=>{var n;E.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!d(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=_e(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Ct=r(`$ZodCheckMinLength`,(e,t)=>{var n;E.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!d(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=_e(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wt=r(`$ZodCheckLengthEquals`,(e,t)=>{var n;E.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!d(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=_e(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Tt=r(`$ZodCheckStringFormat`,(e,t)=>{var n,r;E.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Et=r(`$ZodCheckRegex`,(e,t)=>{Tt.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Dt=r(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=ht,Tt.init(e,t)}),Ot=r(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=gt,Tt.init(e,t)}),kt=r(`$ZodCheckIncludes`,(e,t)=>{E.init(e,t);let n=b(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),At=r(`$ZodCheckStartsWith`,(e,t)=>{E.init(e,t);let n=RegExp(`^${b(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),jt=r(`$ZodCheckEndsWith`,(e,t)=>{E.init(e,t);let n=RegExp(`.*${b(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Mt=r(`$ZodCheckOverwrite`,(e,t)=>{E.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Nt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
1
+ var content=(function(){function e(e){return e}var t=globalThis.browser?.runtime?.id?globalThis.browser:globalThis.chrome,n;function r(e,t,n){function r(n,r){if(n._zod||Object.defineProperty(n,"_zod",{value:{def:r,constr:o,traits:new Set},enumerable:!1}),n._zod.traits.has(e))return;n._zod.traits.add(e),t(n,r);let i=o.prototype,a=Object.keys(i);for(let e=0;e<a.length;e++){let t=a[e];t in n||(n[t]=i[t].bind(n))}}let i=n?.Parent??Object;class a extends i{}Object.defineProperty(a,"name",{value:e});function o(e){var t;let i=n?.Parent?new a:this;r(i,e),(t=i._zod).deferred??(t.deferred=[]);for(let e of i._zod.deferred)e();return i}return Object.defineProperty(o,"init",{value:r}),Object.defineProperty(o,Symbol.hasInstance,{value:t=>n?.Parent&&t instanceof n.Parent?!0:t?._zod?.traits?.has(e)}),Object.defineProperty(o,"name",{value:e}),o}var i=class extends Error{constructor(){super(`Encountered Promise during synchronous parse. Use .parseAsync() instead.`)}},a=class extends Error{constructor(e){super(`Encountered unidirectional transform during encode: ${e}`),this.name=`ZodEncodeError`}};(n=globalThis).__zod_globalConfig??(n.__zod_globalConfig={});var o=globalThis.__zod_globalConfig;function s(e){return e&&Object.assign(o,e),o}function c(e){let t=Object.values(e).filter(e=>typeof e==`number`);return Object.entries(e).filter(([e,n])=>t.indexOf(+e)===-1).map(([e,t])=>t)}function l(e,t){return typeof t==`bigint`?t.toString():t}function u(e){return{get value(){{let t=e();return Object.defineProperty(this,"value",{value:t}),t}throw Error(`cached value already set`)}}}function d(e){return e==null}function f(e){let t=+!!e.startsWith(`^`),n=e.endsWith(`$`)?e.length-1:e.length;return e.slice(t,n)}function p(e,t){let n=e/t,r=Math.round(n),i=2**-52*Math.max(Math.abs(n),1);return Math.abs(n-r)<i?0:n-r}var m=Symbol(`evaluating`);function h(e,t,n){let r;Object.defineProperty(e,t,{get(){if(r!==m)return r===void 0&&(r=m,r=n()),r},set(n){Object.defineProperty(e,t,{value:n})},configurable:!0})}function g(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function _(...e){let t={};for(let n of e){let e=Object.getOwnPropertyDescriptors(n);Object.assign(t,e)}return Object.defineProperties({},t)}function v(e){return JSON.stringify(e)}function ee(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,``).replace(/[\s_-]+/g,`-`).replace(/^-+|-+$/g,``)}var te=`captureStackTrace`in Error?Error.captureStackTrace:(...e)=>{};function ne(e){return typeof e==`object`&&!!e&&!Array.isArray(e)}var re=u(()=>{if(o.jitless||typeof navigator<`u`&&navigator?.userAgent?.includes(`Cloudflare`))return!1;try{return Function(``),!0}catch{return!1}});function y(e){if(ne(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!=`function`)return!0;let n=t.prototype;return!(ne(n)===!1||Object.prototype.hasOwnProperty.call(n,`isPrototypeOf`)===!1)}function ie(e){return y(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}var ae=new Set([`string`,`number`,`symbol`]);function b(e){return e.replace(/[.*+?^${}()|[\]\\]/g,`\\$&`)}function x(e,t,n){let r=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(r._zod.parent=e),r}function S(e){let t=e;if(!t)return{};if(typeof t==`string`)return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error==`string`?{...t,error:()=>t.error}:t}function oe(e){return Object.keys(e).filter(t=>e[t]._zod.optin===`optional`&&e[t]._zod.optout===`optional`)}var se={safeint:[-(2**53-1),2**53-1],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function ce(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.pick() cannot be used on object schemas containing refinements`);return x(e,_(e._zod.def,{get shape(){let e={};for(let r in t){if(!(r in n.shape))throw Error(`Unrecognized key: "${r}"`);t[r]&&(e[r]=n.shape[r])}return g(this,`shape`,e),e},checks:[]}))}function le(e,t){let n=e._zod.def,r=n.checks;if(r&&r.length>0)throw Error(`.omit() cannot be used on object schemas containing refinements`);return x(e,_(e._zod.def,{get shape(){let r={...e._zod.def.shape};for(let e in t){if(!(e in n.shape))throw Error(`Unrecognized key: "${e}"`);t[e]&&delete r[e]}return g(this,`shape`,r),r},checks:[]}))}function ue(e,t){if(!y(t))throw Error(`Invalid input to extend: expected a plain object`);let n=e._zod.def.checks;if(n&&n.length>0){let n=e._zod.def.shape;for(let e in t)if(Object.getOwnPropertyDescriptor(n,e)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}return x(e,_(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return g(this,`shape`,n),n}}))}function de(e,t){if(!y(t))throw Error(`Invalid input to safeExtend: expected a plain object`);return x(e,_(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t};return g(this,`shape`,n),n}}))}function fe(e,t){if(e._zod.def.checks?.length)throw Error(`.merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.`);return x(e,_(e._zod.def,{get shape(){let n={...e._zod.def.shape,...t._zod.def.shape};return g(this,`shape`,n),n},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]}))}function pe(e,t,n){let r=t._zod.def.checks;if(r&&r.length>0)throw Error(`.partial() cannot be used on object schemas containing refinements`);return x(t,_(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in r))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t])}else for(let t in r)i[t]=e?new e({type:`optional`,innerType:r[t]}):r[t];return g(this,`shape`,i),i},checks:[]}))}function me(e,t,n){return x(t,_(t._zod.def,{get shape(){let r=t._zod.def.shape,i={...r};if(n)for(let t in n){if(!(t in i))throw Error(`Unrecognized key: "${t}"`);n[t]&&(i[t]=new e({type:`nonoptional`,innerType:r[t]}))}else for(let t in r)i[t]=new e({type:`nonoptional`,innerType:r[t]});return g(this,`shape`,i),i}}))}function C(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue!==!0)return!0;return!1}function he(e,t=0){if(e.aborted===!0)return!0;for(let n=t;n<e.issues.length;n++)if(e.issues[n]?.continue===!1)return!0;return!1}function ge(e,t){return t.map(t=>{var n;return(n=t).path??(n.path=[]),t.path.unshift(e),t})}function _e(e){return typeof e==`string`?e:e?.message}function w(e,t,n){let r=e.message?e.message:_e(e.inst?._zod.def?.error?.(e))??_e(t?.error?.(e))??_e(n.customError?.(e))??_e(n.localeError?.(e))??`Invalid input`,{inst:i,continue:a,input:o,...s}=e;return s.path??=[],s.message=r,t?.reportInput&&(s.input=o),s}function ve(e){return Array.isArray(e)?`array`:typeof e==`string`?`string`:`unknown`}function ye(...e){let[t,n,r]=e;return typeof t==`string`?{message:t,code:`custom`,input:n,inst:r}:{...t}}var be=(e,t)=>{e.name=`$ZodError`,Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,l,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},xe=r(`$ZodError`,be),Se=r(`$ZodError`,be,{Parent:Error});function Ce(e,t=e=>e.message){let n={},r=[];for(let i of e.issues)i.path.length>0?(n[i.path[0]]=n[i.path[0]]||[],n[i.path[0]].push(t(i))):r.push(t(i));return{formErrors:r,fieldErrors:n}}function we(e,t=e=>e.message){let n={_errors:[]},r=(e,i=[])=>{for(let a of e.issues)if(a.code===`invalid_union`&&a.errors.length)a.errors.map(e=>r({issues:e},[...i,...a.path]));else if(a.code===`invalid_key`)r({issues:a.issues},[...i,...a.path]);else if(a.code===`invalid_element`)r({issues:a.issues},[...i,...a.path]);else{let e=[...i,...a.path];if(e.length===0)n._errors.push(t(a));else{let r=n,i=0;for(;i<e.length;){let n=e[i];i===e.length-1?(r[n]=r[n]||{_errors:[]},r[n]._errors.push(t(a))):r[n]=r[n]||{_errors:[]},r=r[n],i++}}}};return r(e),n}function Te(e){let t=[],n=e.map(e=>typeof e==`object`?e.key:e);for(let e of n)typeof e==`number`?t.push(`[${e}]`):typeof e==`symbol`?t.push(`[${JSON.stringify(String(e))}]`):/[^\w$]/.test(e)?t.push(`[${JSON.stringify(e)}]`):(t.length&&t.push(`.`),t.push(e));return t.join(``)}function Ee(e){let t=[],n=[...e.issues].sort((e,t)=>(e.path??[]).length-(t.path??[]).length);for(let e of n)t.push(`✖ ${e.message}`),e.path?.length&&t.push(` → at ${Te(e.path)}`);return t.join(`
2
+ `)}var De=e=>(t,n,r,a)=>{let o=r?{...r,async:!1}:{async:!1},c=t._zod.run({value:n,issues:[]},o);if(c instanceof Promise)throw new i;if(c.issues.length){let t=new((a?.Err)??e)(c.issues.map(e=>w(e,o,s())));throw te(t,a?.callee),t}return c.value},Oe=e=>async(t,n,r,i)=>{let a=r?{...r,async:!0}:{async:!0},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise&&(o=await o),o.issues.length){let t=new((i?.Err)??e)(o.issues.map(e=>w(e,a,s())));throw te(t,i?.callee),t}return o.value},ke=e=>(t,n,r)=>{let a=r?{...r,async:!1}:{async:!1},o=t._zod.run({value:n,issues:[]},a);if(o instanceof Promise)throw new i;return o.issues.length?{success:!1,error:new(e??xe)(o.issues.map(e=>w(e,a,s())))}:{success:!0,data:o.value}},Ae=ke(Se),je=e=>async(t,n,r)=>{let i=r?{...r,async:!0}:{async:!0},a=t._zod.run({value:n,issues:[]},i);return a instanceof Promise&&(a=await a),a.issues.length?{success:!1,error:new e(a.issues.map(e=>w(e,i,s())))}:{success:!0,data:a.value}},Me=je(Se),Ne=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return De(e)(t,n,i)},Pe=e=>(t,n,r)=>De(e)(t,n,r),Fe=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return Oe(e)(t,n,i)},Ie=e=>async(t,n,r)=>Oe(e)(t,n,r),Le=e=>(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return ke(e)(t,n,i)},Re=e=>(t,n,r)=>ke(e)(t,n,r),ze=e=>async(t,n,r)=>{let i=r?{...r,direction:`backward`}:{direction:`backward`};return je(e)(t,n,i)},Be=e=>async(t,n,r)=>je(e)(t,n,r),Ve=/^[cC][0-9a-z]{6,}$/,He=/^[0-9a-z]+$/,Ue=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,We=/^[0-9a-vA-V]{20}$/,Ge=/^[A-Za-z0-9]{27}$/,Ke=/^[a-zA-Z0-9_-]{21}$/,qe=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Je=/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12})$/,Ye=e=>e?RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${e}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`):/^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-8][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/,Xe=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Ze=`^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$`;function Qe(){return new RegExp(Ze,`u`)}var $e=/^(?:(?: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])$/,et=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,tt=/^((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])\/([0-9]|[1-2][0-9]|3[0-2])$/,nt=/^(([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}|::|([0-9a-fA-F]{1,4})?::([0-9a-fA-F]{1,4}:?){0,6})\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,rt=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,it=/^[A-Za-z0-9_-]*$/,at=/^https?$/,ot=/^\+[1-9]\d{6,14}$/,st=`(?:(?:\\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])))`,ct=RegExp(`^${st}$`);function lt(e){let t=`(?:[01]\\d|2[0-3]):[0-5]\\d`;return typeof e.precision==`number`?e.precision===-1?`${t}`:e.precision===0?`${t}:[0-5]\\d`:`${t}:[0-5]\\d\\.\\d{${e.precision}}`:`${t}(?::[0-5]\\d(?:\\.\\d+)?)?`}function ut(e){return RegExp(`^${lt(e)}$`)}function dt(e){let t=lt({precision:e.precision}),n=[`Z`];e.local&&n.push(``),e.offset&&n.push(`([+-](?:[01]\\d|2[0-3]):[0-5]\\d)`);let r=`${t}(?:${n.join(`|`)})`;return RegExp(`^${st}T(?:${r})$`)}var ft=e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??``}}`:`[\\s\\S]*`;return RegExp(`^${t}$`)},pt=/^-?\d+$/,mt=/^-?\d+(?:\.\d+)?$/,ht=/^(?:true|false)$/i,gt=/^[^A-Z]*$/,_t=/^[^a-z]*$/,T=r(`$ZodCheck`,(e,t)=>{var n;e._zod??={},e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),vt={number:`number`,bigint:`bigint`,object:`date`},yt=r(`$ZodCheckLessThan`,(e,t)=>{T.init(e,t);let n=vt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.maximum:n.exclusiveMaximum)??1/0;t.value<r&&(t.inclusive?n.maximum=t.value:n.exclusiveMaximum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value<=t.value:r.value<t.value)||r.issues.push({origin:n,code:`too_big`,maximum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),bt=r(`$ZodCheckGreaterThan`,(e,t)=>{T.init(e,t);let n=vt[typeof t.value];e._zod.onattach.push(e=>{let n=e._zod.bag,r=(t.inclusive?n.minimum:n.exclusiveMinimum)??-1/0;t.value>r&&(t.inclusive?n.minimum=t.value:n.exclusiveMinimum=t.value)}),e._zod.check=r=>{(t.inclusive?r.value>=t.value:r.value>t.value)||r.issues.push({origin:n,code:`too_small`,minimum:typeof t.value==`object`?t.value.getTime():t.value,input:r.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),xt=r(`$ZodCheckMultipleOf`,(e,t)=>{T.init(e,t),e._zod.onattach.push(e=>{var n;(n=e._zod.bag).multipleOf??(n.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw Error(`Cannot mix number and bigint in multiple_of check.`);(typeof n.value==`bigint`?n.value%t.value===BigInt(0):p(n.value,t.value)===0)||n.issues.push({origin:typeof n.value,code:`not_multiple_of`,divisor:t.value,input:n.value,inst:e,continue:!t.abort})}}),St=r(`$ZodCheckNumberFormat`,(e,t)=>{T.init(e,t),t.format=t.format||`float64`;let n=t.format?.includes(`int`),r=n?`int`:`number`,[i,a]=se[t.format];e._zod.onattach.push(e=>{let r=e._zod.bag;r.format=t.format,r.minimum=i,r.maximum=a,n&&(r.pattern=pt)}),e._zod.check=o=>{let s=o.value;if(n){if(!Number.isInteger(s)){o.issues.push({expected:r,format:t.format,code:`invalid_type`,continue:!1,input:s,inst:e});return}if(!Number.isSafeInteger(s)){s>0?o.issues.push({input:s,code:`too_big`,maximum:2**53-1,note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort}):o.issues.push({input:s,code:`too_small`,minimum:-(2**53-1),note:`Integers must be within the safe integer range.`,inst:e,origin:r,inclusive:!0,continue:!t.abort});return}}s<i&&o.issues.push({origin:`number`,input:s,code:`too_small`,minimum:i,inclusive:!0,inst:e,continue:!t.abort}),s>a&&o.issues.push({origin:`number`,input:s,code:`too_big`,maximum:a,inclusive:!0,inst:e,continue:!t.abort})}}),Ct=r(`$ZodCheckMaxLength`,(e,t)=>{var n;T.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!d(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.maximum??1/0;t.maximum<n&&(e._zod.bag.maximum=t.maximum)}),e._zod.check=n=>{let r=n.value;if(r.length<=t.maximum)return;let i=ve(r);n.issues.push({origin:i,code:`too_big`,maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),wt=r(`$ZodCheckMinLength`,(e,t)=>{var n;T.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!d(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag.minimum??-1/0;t.minimum>n&&(e._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let r=n.value;if(r.length>=t.minimum)return;let i=ve(r);n.issues.push({origin:i,code:`too_small`,minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),Tt=r(`$ZodCheckLengthEquals`,(e,t)=>{var n;T.init(e,t),(n=e._zod.def).when??(n.when=e=>{let t=e.value;return!d(t)&&t.length!==void 0}),e._zod.onattach.push(e=>{let n=e._zod.bag;n.minimum=t.length,n.maximum=t.length,n.length=t.length}),e._zod.check=n=>{let r=n.value,i=r.length;if(i===t.length)return;let a=ve(r),o=i>t.length;n.issues.push({origin:a,...o?{code:`too_big`,maximum:t.length}:{code:`too_small`,minimum:t.length},inclusive:!0,exact:!0,input:n.value,inst:e,continue:!t.abort})}}),Et=r(`$ZodCheckStringFormat`,(e,t)=>{var n,r;T.init(e,t),e._zod.onattach.push(e=>{let n=e._zod.bag;n.format=t.format,t.pattern&&(n.patterns??=new Set,n.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:t.format,input:n.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(r=e._zod).check??(r.check=()=>{})}),Dt=r(`$ZodCheckRegex`,(e,t)=>{Et.init(e,t),e._zod.check=n=>{t.pattern.lastIndex=0,!t.pattern.test(n.value)&&n.issues.push({origin:`string`,code:`invalid_format`,format:`regex`,input:n.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}}),Ot=r(`$ZodCheckLowerCase`,(e,t)=>{t.pattern??=gt,Et.init(e,t)}),kt=r(`$ZodCheckUpperCase`,(e,t)=>{t.pattern??=_t,Et.init(e,t)}),At=r(`$ZodCheckIncludes`,(e,t)=>{T.init(e,t);let n=b(t.includes),r=new RegExp(typeof t.position==`number`?`^.{${t.position}}${n}`:n);t.pattern=r,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(r)}),e._zod.check=n=>{n.value.includes(t.includes,t.position)||n.issues.push({origin:`string`,code:`invalid_format`,format:`includes`,includes:t.includes,input:n.value,inst:e,continue:!t.abort})}}),jt=r(`$ZodCheckStartsWith`,(e,t)=>{T.init(e,t);let n=RegExp(`^${b(t.prefix)}.*`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.startsWith(t.prefix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`starts_with`,prefix:t.prefix,input:n.value,inst:e,continue:!t.abort})}}),Mt=r(`$ZodCheckEndsWith`,(e,t)=>{T.init(e,t);let n=RegExp(`.*${b(t.suffix)}$`);t.pattern??=n,e._zod.onattach.push(e=>{let t=e._zod.bag;t.patterns??=new Set,t.patterns.add(n)}),e._zod.check=n=>{n.value.endsWith(t.suffix)||n.issues.push({origin:`string`,code:`invalid_format`,format:`ends_with`,suffix:t.suffix,input:n.value,inst:e,continue:!t.abort})}}),Nt=r(`$ZodCheckOverwrite`,(e,t)=>{T.init(e,t),e._zod.check=e=>{e.value=t.tx(e.value)}}),Pt=class{constructor(e=[]){this.content=[],this.indent=0,this&&(this.args=e)}indented(e){this.indent+=1,e(this),--this.indent}write(e){if(typeof e==`function`){e(this,{execution:`sync`}),e(this,{execution:`async`});return}let t=e.split(`
3
3
  `).filter(e=>e),n=Math.min(...t.map(e=>e.length-e.trimStart().length)),r=t.map(e=>e.slice(n)).map(e=>` `.repeat(this.indent*2)+e);for(let e of r)this.content.push(e)}compile(){let e=Function,t=this?.args,n=[...(this?.content??[``]).map(e=>` ${e}`)];return new e(...t,n.join(`
4
- `))}},Pt={major:4,minor:4,patch:3},D=r(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Pt;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=C(e),a;for(let o of t){if(o._zod.def.when){if(he(e)||!o._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&n?.async===!1)throw new i;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,e.issues.length!==t&&(r||=C(e,t))});else{if(e.issues.length===t)continue;r||=C(e,t)}}return a?a.then(()=>e):e},n=(n,a,o)=>{if(C(n))return n.aborted=!0,n;let s=t(a,r,o);if(s instanceof Promise){if(o.async===!1)throw new i;return s.then(t=>e._zod.parse(t,o))}return e._zod.parse(s,o)};e._zod.run=(a,o)=>{if(o.skipChecks)return e._zod.parse(a,o);if(o.direction===`backward`){let t=e._zod.parse({value:a.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,a,o)):n(t,a,o)}let s=e._zod.parse(a,o);if(s instanceof Promise){if(o.async===!1)throw new i;return s.then(e=>t(e,r,o))}return t(s,r,o)}}h(e,`~standard`,()=>({validate:t=>{try{let n=ke(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return je(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),Ft=r(`$ZodString`,(e,t)=>{D.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??dt(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),O=r(`$ZodStringFormat`,(e,t)=>{Tt.init(e,t),Ft.init(e,t)}),It=r(`$ZodGUID`,(e,t)=>{t.pattern??=qe,O.init(e,t)}),Lt=r(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Je(e)}else t.pattern??=Je();O.init(e,t)}),Rt=r(`$ZodEmail`,(e,t)=>{t.pattern??=Ye,O.init(e,t)}),zt=r(`$ZodURL`,(e,t)=>{O.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===it.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Bt=r(`$ZodEmoji`,(e,t)=>{t.pattern??=Ze(),O.init(e,t)}),Vt=r(`$ZodNanoID`,(e,t)=>{t.pattern??=Ge,O.init(e,t)}),Ht=r(`$ZodCUID`,(e,t)=>{t.pattern??=Be,O.init(e,t)}),Ut=r(`$ZodCUID2`,(e,t)=>{t.pattern??=Ve,O.init(e,t)}),Wt=r(`$ZodULID`,(e,t)=>{t.pattern??=He,O.init(e,t)}),Gt=r(`$ZodXID`,(e,t)=>{t.pattern??=Ue,O.init(e,t)}),Kt=r(`$ZodKSUID`,(e,t)=>{t.pattern??=We,O.init(e,t)}),qt=r(`$ZodISODateTime`,(e,t)=>{t.pattern??=ut(t),O.init(e,t)}),Jt=r(`$ZodISODate`,(e,t)=>{t.pattern??=st,O.init(e,t)}),Yt=r(`$ZodISOTime`,(e,t)=>{t.pattern??=lt(t),O.init(e,t)}),Xt=r(`$ZodISODuration`,(e,t)=>{t.pattern??=Ke,O.init(e,t)}),Zt=r(`$ZodIPv4`,(e,t)=>{t.pattern??=Qe,O.init(e,t),e._zod.bag.format=`ipv4`}),Qt=r(`$ZodIPv6`,(e,t)=>{t.pattern??=$e,O.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),$t=r(`$ZodCIDRv4`,(e,t)=>{t.pattern??=et,O.init(e,t)}),en=r(`$ZodCIDRv6`,(e,t)=>{t.pattern??=tt,O.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function tn(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var nn=r(`$ZodBase64`,(e,t)=>{t.pattern??=nt,O.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{tn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function rn(e){if(!rt.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return tn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var an=r(`$ZodBase64URL`,(e,t)=>{t.pattern??=rt,O.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{rn(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),on=r(`$ZodE164`,(e,t)=>{t.pattern??=at,O.init(e,t)});function sn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var cn=r(`$ZodJWT`,(e,t)=>{O.init(e,t),e._zod.check=n=>{sn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),ln=r(`$ZodNumber`,(e,t)=>{D.init(e,t),e._zod.pattern=e._zod.bag.pattern??pt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),un=r(`$ZodNumberFormat`,(e,t)=>{xt.init(e,t),ln.init(e,t)}),dn=r(`$ZodBoolean`,(e,t)=>{D.init(e,t),e._zod.pattern=mt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),fn=r(`$ZodUnknown`,(e,t)=>{D.init(e,t),e._zod.parse=e=>e}),pn=r(`$ZodNever`,(e,t)=>{D.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function mn(e,t,n){e.issues.length&&t.issues.push(...w(n,e.issues)),t.value[n]=e.value}var hn=r(`$ZodArray`,(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>mn(t,n,e))):mn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function gn(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...w(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function _n(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=oe(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function vn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>gn(e,n,i,t,u,d))):gn(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var yn=r(`$ZodObject`,(e,t)=>{if(D.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=u(()=>_n(t));h(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=ne,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>gn(n,t,e,s,r,i))):gn(a,t,e,s,r,i)}return i?vn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),bn=r(`$ZodObjectJIT`,(e,t)=>{yn.init(e,t);let n=e._zod.parse,r=u(()=>_n(t)),i=e=>{let t=new Nt([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=v(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=v(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
4
+ `))}},Ft={major:4,minor:4,patch:3},E=r(`$ZodType`,(e,t)=>{var n;e??={},e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ft;let r=[...e._zod.def.checks??[]];e._zod.traits.has(`$ZodCheck`)&&r.unshift(e);for(let t of r)for(let n of t._zod.onattach)n(e);if(r.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let t=(e,t,n)=>{let r=C(e),a;for(let o of t){if(o._zod.def.when){if(he(e)||!o._zod.def.when(e))continue}else if(r)continue;let t=e.issues.length,s=o._zod.check(e);if(s instanceof Promise&&n?.async===!1)throw new i;if(a||s instanceof Promise)a=(a??Promise.resolve()).then(async()=>{await s,e.issues.length!==t&&(r||=C(e,t))});else{if(e.issues.length===t)continue;r||=C(e,t)}}return a?a.then(()=>e):e},n=(n,a,o)=>{if(C(n))return n.aborted=!0,n;let s=t(a,r,o);if(s instanceof Promise){if(o.async===!1)throw new i;return s.then(t=>e._zod.parse(t,o))}return e._zod.parse(s,o)};e._zod.run=(a,o)=>{if(o.skipChecks)return e._zod.parse(a,o);if(o.direction===`backward`){let t=e._zod.parse({value:a.value,issues:[]},{...o,skipChecks:!0});return t instanceof Promise?t.then(e=>n(e,a,o)):n(t,a,o)}let s=e._zod.parse(a,o);if(s instanceof Promise){if(o.async===!1)throw new i;return s.then(e=>t(e,r,o))}return t(s,r,o)}}h(e,`~standard`,()=>({validate:t=>{try{let n=Ae(e,t);return n.success?{value:n.data}:{issues:n.error?.issues}}catch{return Me(e,t).then(e=>e.success?{value:e.data}:{issues:e.error?.issues})}},vendor:`zod`,version:1}))}),It=r(`$ZodString`,(e,t)=>{E.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??ft(e._zod.bag),e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=String(n.value)}catch{}return typeof n.value==`string`||n.issues.push({expected:`string`,code:`invalid_type`,input:n.value,inst:e}),n}}),D=r(`$ZodStringFormat`,(e,t)=>{Et.init(e,t),It.init(e,t)}),Lt=r(`$ZodGUID`,(e,t)=>{t.pattern??=Je,D.init(e,t)}),Rt=r(`$ZodUUID`,(e,t)=>{if(t.version){let e={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(e===void 0)throw Error(`Invalid UUID version: "${t.version}"`);t.pattern??=Ye(e)}else t.pattern??=Ye();D.init(e,t)}),zt=r(`$ZodEmail`,(e,t)=>{t.pattern??=Xe,D.init(e,t)}),Bt=r(`$ZodURL`,(e,t)=>{D.init(e,t),e._zod.check=n=>{try{let r=n.value.trim();if(!t.normalize&&t.protocol?.source===at.source&&!/^https?:\/\//i.test(r)){n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid URL format`,input:n.value,inst:e,continue:!t.abort});return}let i=new URL(r);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid hostname`,pattern:t.hostname.source,input:n.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(`:`)?i.protocol.slice(0,-1):i.protocol)||n.issues.push({code:`invalid_format`,format:`url`,note:`Invalid protocol`,pattern:t.protocol.source,input:n.value,inst:e,continue:!t.abort})),t.normalize?n.value=i.href:n.value=r;return}catch{n.issues.push({code:`invalid_format`,format:`url`,input:n.value,inst:e,continue:!t.abort})}}}),Vt=r(`$ZodEmoji`,(e,t)=>{t.pattern??=Qe(),D.init(e,t)}),Ht=r(`$ZodNanoID`,(e,t)=>{t.pattern??=Ke,D.init(e,t)}),Ut=r(`$ZodCUID`,(e,t)=>{t.pattern??=Ve,D.init(e,t)}),Wt=r(`$ZodCUID2`,(e,t)=>{t.pattern??=He,D.init(e,t)}),Gt=r(`$ZodULID`,(e,t)=>{t.pattern??=Ue,D.init(e,t)}),Kt=r(`$ZodXID`,(e,t)=>{t.pattern??=We,D.init(e,t)}),qt=r(`$ZodKSUID`,(e,t)=>{t.pattern??=Ge,D.init(e,t)}),Jt=r(`$ZodISODateTime`,(e,t)=>{t.pattern??=dt(t),D.init(e,t)}),Yt=r(`$ZodISODate`,(e,t)=>{t.pattern??=ct,D.init(e,t)}),Xt=r(`$ZodISOTime`,(e,t)=>{t.pattern??=ut(t),D.init(e,t)}),Zt=r(`$ZodISODuration`,(e,t)=>{t.pattern??=qe,D.init(e,t)}),Qt=r(`$ZodIPv4`,(e,t)=>{t.pattern??=$e,D.init(e,t),e._zod.bag.format=`ipv4`}),$t=r(`$ZodIPv6`,(e,t)=>{t.pattern??=et,D.init(e,t),e._zod.bag.format=`ipv6`,e._zod.check=n=>{try{new URL(`http://[${n.value}]`)}catch{n.issues.push({code:`invalid_format`,format:`ipv6`,input:n.value,inst:e,continue:!t.abort})}}}),en=r(`$ZodCIDRv4`,(e,t)=>{t.pattern??=tt,D.init(e,t)}),tn=r(`$ZodCIDRv6`,(e,t)=>{t.pattern??=nt,D.init(e,t),e._zod.check=n=>{let r=n.value.split(`/`);try{if(r.length!==2)throw Error();let[e,t]=r;if(!t)throw Error();let n=Number(t);if(`${n}`!==t||n<0||n>128)throw Error();new URL(`http://[${e}]`)}catch{n.issues.push({code:`invalid_format`,format:`cidrv6`,input:n.value,inst:e,continue:!t.abort})}}});function nn(e){if(e===``)return!0;if(/\s/.test(e)||e.length%4!=0)return!1;try{return atob(e),!0}catch{return!1}}var rn=r(`$ZodBase64`,(e,t)=>{t.pattern??=rt,D.init(e,t),e._zod.bag.contentEncoding=`base64`,e._zod.check=n=>{nn(n.value)||n.issues.push({code:`invalid_format`,format:`base64`,input:n.value,inst:e,continue:!t.abort})}});function an(e){if(!it.test(e))return!1;let t=e.replace(/[-_]/g,e=>e===`-`?`+`:`/`);return nn(t.padEnd(Math.ceil(t.length/4)*4,`=`))}var on=r(`$ZodBase64URL`,(e,t)=>{t.pattern??=it,D.init(e,t),e._zod.bag.contentEncoding=`base64url`,e._zod.check=n=>{an(n.value)||n.issues.push({code:`invalid_format`,format:`base64url`,input:n.value,inst:e,continue:!t.abort})}}),sn=r(`$ZodE164`,(e,t)=>{t.pattern??=ot,D.init(e,t)});function cn(e,t=null){try{let n=e.split(`.`);if(n.length!==3)return!1;let[r]=n;if(!r)return!1;let i=JSON.parse(atob(r));return!(`typ`in i&&i?.typ!==`JWT`||!i.alg||t&&(!(`alg`in i)||i.alg!==t))}catch{return!1}}var ln=r(`$ZodJWT`,(e,t)=>{D.init(e,t),e._zod.check=n=>{cn(n.value,t.alg)||n.issues.push({code:`invalid_format`,format:`jwt`,input:n.value,inst:e,continue:!t.abort})}}),un=r(`$ZodNumber`,(e,t)=>{E.init(e,t),e._zod.pattern=e._zod.bag.pattern??mt,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}let i=n.value;if(typeof i==`number`&&!Number.isNaN(i)&&Number.isFinite(i))return n;let a=typeof i==`number`?Number.isNaN(i)?`NaN`:Number.isFinite(i)?void 0:`Infinity`:void 0;return n.issues.push({expected:`number`,code:`invalid_type`,input:i,inst:e,...a?{received:a}:{}}),n}}),dn=r(`$ZodNumberFormat`,(e,t)=>{St.init(e,t),un.init(e,t)}),fn=r(`$ZodBoolean`,(e,t)=>{E.init(e,t),e._zod.pattern=ht,e._zod.parse=(n,r)=>{if(t.coerce)try{n.value=!!n.value}catch{}let i=n.value;return typeof i==`boolean`||n.issues.push({expected:`boolean`,code:`invalid_type`,input:i,inst:e}),n}}),pn=r(`$ZodUnknown`,(e,t)=>{E.init(e,t),e._zod.parse=e=>e}),mn=r(`$ZodNever`,(e,t)=>{E.init(e,t),e._zod.parse=(t,n)=>(t.issues.push({expected:`never`,code:`invalid_type`,input:t.value,inst:e}),t)});function hn(e,t,n){e.issues.length&&t.issues.push(...ge(n,e.issues)),t.value[n]=e.value}var gn=r(`$ZodArray`,(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!Array.isArray(i))return n.issues.push({expected:`array`,code:`invalid_type`,input:i,inst:e}),n;n.value=Array(i.length);let a=[];for(let e=0;e<i.length;e++){let o=i[e],s=t.element._zod.run({value:o,issues:[]},r);s instanceof Promise?a.push(s.then(t=>hn(t,n,e))):hn(s,n,e)}return a.length?Promise.all(a).then(()=>n):n}});function _n(e,t,n,r,i,a){let o=n in r;if(e.issues.length){if(i&&a&&!o)return;t.issues.push(...ge(n,e.issues))}if(!o&&!i){e.issues.length||t.issues.push({code:`invalid_type`,expected:`nonoptional`,input:void 0,path:[n]});return}e.value===void 0?o&&(t.value[n]=void 0):t.value[n]=e.value}function vn(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has(`$ZodType`))throw Error(`Invalid element at key "${n}": expected a Zod schema`);let n=oe(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function yn(e,t,n,r,i,a){let o=[],s=i.keySet,c=i.catchall._zod,l=c.def.type,u=c.optin===`optional`,d=c.optout===`optional`;for(let i in t){if(i===`__proto__`||s.has(i))continue;if(l===`never`){o.push(i);continue}let a=c.run({value:t[i],issues:[]},r);a instanceof Promise?e.push(a.then(e=>_n(e,n,i,t,u,d))):_n(a,n,i,t,u,d)}return o.length&&n.issues.push({code:`unrecognized_keys`,keys:o,input:t,inst:a}),e.length?Promise.all(e).then(()=>n):n}var bn=r(`$ZodObject`,(e,t)=>{if(E.init(e,t),!Object.getOwnPropertyDescriptor(t,`shape`)?.get){let e=t.shape;Object.defineProperty(t,"shape",{get:()=>{let n={...e};return Object.defineProperty(t,"shape",{value:n}),n}})}let n=u(()=>vn(t));h(e._zod,`propValues`,()=>{let e=t.shape,n={};for(let t in e){let r=e[t]._zod;if(r.values){n[t]??(n[t]=new Set);for(let e of r.values)n[t].add(e)}}return n});let r=ne,i=t.catchall,a;e._zod.parse=(t,o)=>{a??=n.value;let s=t.value;if(!r(s))return t.issues.push({expected:`object`,code:`invalid_type`,input:s,inst:e}),t;t.value={};let c=[],l=a.shape;for(let e of a.keys){let n=l[e],r=n._zod.optin===`optional`,i=n._zod.optout===`optional`,a=n._zod.run({value:s[e],issues:[]},o);a instanceof Promise?c.push(a.then(n=>_n(n,t,e,s,r,i))):_n(a,t,e,s,r,i)}return i?yn(c,s,t,o,n.value,e):c.length?Promise.all(c).then(()=>t):t}}),xn=r(`$ZodObjectJIT`,(e,t)=>{bn.init(e,t);let n=e._zod.parse,r=u(()=>vn(t)),i=e=>{let t=new Pt([`shape`,`payload`,`ctx`]),n=r.value,i=e=>{let t=v(e);return`shape[${t}]._zod.run({ value: input[${t}], issues: [] }, ctx)`};t.write(`const input = payload.value;`);let a=Object.create(null),o=0;for(let e of n.keys)a[e]=`key_${o++}`;t.write(`const newResult = {};`);for(let r of n.keys){let n=a[r],o=v(r),s=e[r],c=s?._zod?.optin===`optional`,l=s?._zod?.optout===`optional`;t.write(`const ${n} = ${i(r)};`),c&&l?t.write(`
5
5
  if (${n}.issues.length) {
6
6
  if (${o} in input) {
7
7
  payload.issues = payload.issues.concat(${n}.issues.map(iss => ({
@@ -60,14 +60,14 @@ var content=(function(){function e(e){return e}var t=globalThis.browser?.runtime
60
60
  }
61
61
  }
62
62
 
63
- `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,s=ne,c=!o.jitless,l=c&&re.value,d=t.catchall,f;e._zod.parse=(o,u)=>{f??=r.value;let p=o.value;return s(p)?c&&l&&u?.async===!1&&u.jitless!==!0?(a||=i(t.shape),o=a(o,u),d?vn([],p,o,u,f,e):o):n(o,u):(o.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),o)}});function xn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!C(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>T(e,r,s())))}),t)}var Sn=r(`$ZodUnion`,(e,t)=>{D.init(e,t),h(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),h(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),h(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),h(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>f(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>xn(t,r,e,i)):xn(o,r,e,i)}}),Cn=r(`$ZodIntersection`,(e,t)=>{D.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>Tn(e,t,n)):Tn(e,i,a)}});function wn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(y(e)&&y(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=wn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=wn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function Tn(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),C(e))return e;let o=wn(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var En=r(`$ZodRecord`,(e,t)=>{D.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!y(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let c=new Set;for(let l of o)if(typeof l==`string`||typeof l==`number`||typeof l==`symbol`){c.add(typeof l==`number`?l.toString():l);let o=t.keyType._zod.run({value:l,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>T(e,r,s())),input:l,path:[l],inst:e});continue}let u=o.value,d=t.valueType._zod.run({value:i[l],issues:[]},r);d instanceof Promise?a.push(d.then(e=>{e.issues.length&&n.issues.push(...w(l,e.issues)),n.value[u]=e.value})):(d.issues.length&&n.issues.push(...w(l,d.issues)),n.value[u]=d.value)}let l;for(let e in i)c.has(e)||(l??=[],l.push(e));l&&l.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:l})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let c=t.keyType._zod.run({value:o,issues:[]},r);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&pt.test(o)&&c.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(c=e)}if(c.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>T(e,r,s())),input:o,path:[o],inst:e});continue}let l=t.valueType._zod.run({value:i[o],issues:[]},r);l instanceof Promise?a.push(l.then(e=>{e.issues.length&&n.issues.push(...w(o,e.issues)),n.value[c.value]=e.value})):(l.issues.length&&n.issues.push(...w(o,l.issues)),n.value[c.value]=l.value)}}return a.length?Promise.all(a).then(()=>n):n}}),Dn=r(`$ZodEnum`,(e,t)=>{D.init(e,t);let n=c(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ae.has(typeof e)).map(e=>typeof e==`string`?b(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),On=r(`$ZodTransform`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new a(e.constructor.name);let o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(n.value=e,n.fallback=!0,n));if(o instanceof Promise)throw new i;return n.value=o,n.fallback=!0,n}});function kn(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var An=r(`$ZodOptional`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,h(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),h(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${f(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>kn(e,r)):kn(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),jn=r(`$ZodExactOptional`,(e,t)=>{An.init(e,t),h(e._zod,`values`,()=>t.innerType._zod.values),h(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Mn=r(`$ZodNullable`,(e,t)=>{D.init(e,t),h(e._zod,`optin`,()=>t.innerType._zod.optin),h(e._zod,`optout`,()=>t.innerType._zod.optout),h(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${f(e.source)}|null)$`):void 0}),h(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Nn=r(`$ZodDefault`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,h(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Pn(e,t)):Pn(r,t)}});function Pn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var Fn=r(`$ZodPrefault`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,h(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),In=r(`$ZodNonOptional`,(e,t)=>{D.init(e,t),h(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Ln(t,e)):Ln(i,e)}});function Ln(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var Rn=r(`$ZodCatch`,(e,t)=>{D.init(e,t),e._zod.optin=`optional`,h(e._zod,`optout`,()=>t.innerType._zod.optout),h(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>T(e,n,s()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>T(e,n,s()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),zn=r(`$ZodPipe`,(e,t)=>{D.init(e,t),h(e._zod,`values`,()=>t.in._zod.values),h(e._zod,`optin`,()=>t.in._zod.optin),h(e._zod,`optout`,()=>t.out._zod.optout),h(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Bn(e,t.in,n)):Bn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Bn(e,t.out,n)):Bn(r,t.out,n)}});function Bn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Vn=r(`$ZodReadonly`,(e,t)=>{D.init(e,t),h(e._zod,`propValues`,()=>t.innerType._zod.propValues),h(e._zod,`values`,()=>t.innerType._zod.values),h(e._zod,`optin`,()=>t.innerType?._zod?.optin),h(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Hn):Hn(r)}});function Hn(e){return e.value=Object.freeze(e.value),e}var Un=r(`$ZodCustom`,(e,t)=>{E.init(e,t),D.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Wn(t,n,r,e));Wn(i,n,r,e)}});function Wn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(ve(e))}}var Gn,Kn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function qn(){return new Kn}(Gn=globalThis).__zod_globalRegistry??(Gn.__zod_globalRegistry=qn());var Jn=globalThis.__zod_globalRegistry;function Yn(e,t){return new e({type:`string`,...S(t)})}function Xn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...S(t)})}function Zn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...S(t)})}function Qn(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...S(t)})}function $n(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...S(t)})}function er(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...S(t)})}function tr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...S(t)})}function nr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...S(t)})}function rr(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...S(t)})}function ir(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...S(t)})}function ar(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...S(t)})}function or(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...S(t)})}function sr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...S(t)})}function cr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...S(t)})}function lr(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...S(t)})}function ur(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...S(t)})}function dr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...S(t)})}function fr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...S(t)})}function pr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...S(t)})}function mr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...S(t)})}function hr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...S(t)})}function gr(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...S(t)})}function _r(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...S(t)})}function vr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...S(t)})}function yr(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...S(t)})}function br(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...S(t)})}function xr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...S(t)})}function Sr(e,t){return new e({type:`number`,checks:[],...S(t)})}function Cr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...S(t)})}function wr(e,t){return new e({type:`boolean`,...S(t)})}function Tr(e){return new e({type:`unknown`})}function Er(e,t){return new e({type:`never`,...S(t)})}function Dr(e,t){return new vt({check:`less_than`,...S(t),value:e,inclusive:!1})}function Or(e,t){return new vt({check:`less_than`,...S(t),value:e,inclusive:!0})}function kr(e,t){return new yt({check:`greater_than`,...S(t),value:e,inclusive:!1})}function Ar(e,t){return new yt({check:`greater_than`,...S(t),value:e,inclusive:!0})}function jr(e,t){return new bt({check:`multiple_of`,...S(t),value:e})}function Mr(e,t){return new St({check:`max_length`,...S(t),maximum:e})}function Nr(e,t){return new Ct({check:`min_length`,...S(t),minimum:e})}function Pr(e,t){return new wt({check:`length_equals`,...S(t),length:e})}function Fr(e,t){return new Et({check:`string_format`,format:`regex`,...S(t),pattern:e})}function Ir(e){return new Dt({check:`string_format`,format:`lowercase`,...S(e)})}function Lr(e){return new Ot({check:`string_format`,format:`uppercase`,...S(e)})}function Rr(e,t){return new kt({check:`string_format`,format:`includes`,...S(t),includes:e})}function zr(e,t){return new At({check:`string_format`,format:`starts_with`,...S(t),prefix:e})}function Br(e,t){return new jt({check:`string_format`,format:`ends_with`,...S(t),suffix:e})}function k(e){return new Mt({check:`overwrite`,tx:e})}function Vr(e){return k(t=>t.normalize(e))}function Hr(){return k(e=>e.trim())}function Ur(){return k(e=>e.toLowerCase())}function Wr(){return k(e=>e.toUpperCase())}function Gr(){return k(e=>ee(e))}function Kr(e,t,n){return new e({type:`array`,element:t,...S(n)})}function qr(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...S(n)})}function Jr(e,t){let n=Yr(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(ve(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(ve(r))}},e(t.value,t)),t);return n}function Yr(e,t){let n=new E({check:`custom`,...S(t)});return n._zod.check=e,n}function Xr(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Jn,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function A(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,A(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&j(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Zr(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
63
+ `)}t.write(`payload.value = newResult;`),t.write(`return payload;`);let s=t.compile();return(t,n)=>s(e,t,n)},a,s=ne,c=!o.jitless,l=c&&re.value,d=t.catchall,f;e._zod.parse=(o,u)=>{f??=r.value;let p=o.value;return s(p)?c&&l&&u?.async===!1&&u.jitless!==!0?(a||=i(t.shape),o=a(o,u),d?yn([],p,o,u,f,e):o):n(o,u):(o.issues.push({expected:`object`,code:`invalid_type`,input:p,inst:e}),o)}});function Sn(e,t,n,r){for(let n of e)if(n.issues.length===0)return t.value=n.value,t;let i=e.filter(e=>!C(e));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:`invalid_union`,input:t.value,inst:n,errors:e.map(e=>e.issues.map(e=>w(e,r,s())))}),t)}var Cn=r(`$ZodUnion`,(e,t)=>{E.init(e,t),h(e._zod,`optin`,()=>t.options.some(e=>e._zod.optin===`optional`)?`optional`:void 0),h(e._zod,`optout`,()=>t.options.some(e=>e._zod.optout===`optional`)?`optional`:void 0),h(e._zod,`values`,()=>{if(t.options.every(e=>e._zod.values))return new Set(t.options.flatMap(e=>Array.from(e._zod.values)))}),h(e._zod,`pattern`,()=>{if(t.options.every(e=>e._zod.pattern)){let e=t.options.map(e=>e._zod.pattern);return RegExp(`^(${e.map(e=>f(e.source)).join(`|`)})$`)}});let n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(r,i)=>{if(n)return n(r,i);let a=!1,o=[];for(let e of t.options){let t=e._zod.run({value:r.value,issues:[]},i);if(t instanceof Promise)o.push(t),a=!0;else{if(t.issues.length===0)return t;o.push(t)}}return a?Promise.all(o).then(t=>Sn(t,r,e,i)):Sn(o,r,e,i)}}),wn=r(`$ZodIntersection`,(e,t)=>{E.init(e,t),e._zod.parse=(e,n)=>{let r=e.value,i=t.left._zod.run({value:r,issues:[]},n),a=t.right._zod.run({value:r,issues:[]},n);return i instanceof Promise||a instanceof Promise?Promise.all([i,a]).then(([t,n])=>En(e,t,n)):En(e,i,a)}});function Tn(e,t){if(e===t||e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(y(e)&&y(t)){let n=Object.keys(t),r=Object.keys(e).filter(e=>n.indexOf(e)!==-1),i={...e,...t};for(let n of r){let r=Tn(e[n],t[n]);if(!r.valid)return{valid:!1,mergeErrorPath:[n,...r.mergeErrorPath]};i[n]=r.data}return{valid:!0,data:i}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};let n=[];for(let r=0;r<e.length;r++){let i=e[r],a=t[r],o=Tn(i,a);if(!o.valid)return{valid:!1,mergeErrorPath:[r,...o.mergeErrorPath]};n.push(o.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function En(e,t,n){let r=new Map,i;for(let n of t.issues)if(n.code===`unrecognized_keys`){i??=n;for(let e of n.keys)r.has(e)||r.set(e,{}),r.get(e).l=!0}else e.issues.push(n);for(let t of n.issues)if(t.code===`unrecognized_keys`)for(let e of t.keys)r.has(e)||r.set(e,{}),r.get(e).r=!0;else e.issues.push(t);let a=[...r].filter(([,e])=>e.l&&e.r).map(([e])=>e);if(a.length&&i&&e.issues.push({...i,keys:a}),C(e))return e;let o=Tn(t.value,n.value);if(!o.valid)throw Error(`Unmergable intersection. Error path: ${JSON.stringify(o.mergeErrorPath)}`);return e.value=o.data,e}var Dn=r(`$ZodRecord`,(e,t)=>{E.init(e,t),e._zod.parse=(n,r)=>{let i=n.value;if(!y(i))return n.issues.push({expected:`record`,code:`invalid_type`,input:i,inst:e}),n;let a=[],o=t.keyType._zod.values;if(o){n.value={};let c=new Set;for(let l of o)if(typeof l==`string`||typeof l==`number`||typeof l==`symbol`){c.add(typeof l==`number`?l.toString():l);let o=t.keyType._zod.run({value:l,issues:[]},r);if(o instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(o.issues.length){n.issues.push({code:`invalid_key`,origin:`record`,issues:o.issues.map(e=>w(e,r,s())),input:l,path:[l],inst:e});continue}let u=o.value,d=t.valueType._zod.run({value:i[l],issues:[]},r);d instanceof Promise?a.push(d.then(e=>{e.issues.length&&n.issues.push(...ge(l,e.issues)),n.value[u]=e.value})):(d.issues.length&&n.issues.push(...ge(l,d.issues)),n.value[u]=d.value)}let l;for(let e in i)c.has(e)||(l??=[],l.push(e));l&&l.length>0&&n.issues.push({code:`unrecognized_keys`,input:i,inst:e,keys:l})}else{n.value={};for(let o of Reflect.ownKeys(i)){if(o===`__proto__`||!Object.prototype.propertyIsEnumerable.call(i,o))continue;let c=t.keyType._zod.run({value:o,issues:[]},r);if(c instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);if(typeof o==`string`&&mt.test(o)&&c.issues.length){let e=t.keyType._zod.run({value:Number(o),issues:[]},r);if(e instanceof Promise)throw Error(`Async schemas not supported in object keys currently`);e.issues.length===0&&(c=e)}if(c.issues.length){t.mode===`loose`?n.value[o]=i[o]:n.issues.push({code:`invalid_key`,origin:`record`,issues:c.issues.map(e=>w(e,r,s())),input:o,path:[o],inst:e});continue}let l=t.valueType._zod.run({value:i[o],issues:[]},r);l instanceof Promise?a.push(l.then(e=>{e.issues.length&&n.issues.push(...ge(o,e.issues)),n.value[c.value]=e.value})):(l.issues.length&&n.issues.push(...ge(o,l.issues)),n.value[c.value]=l.value)}}return a.length?Promise.all(a).then(()=>n):n}}),On=r(`$ZodEnum`,(e,t)=>{E.init(e,t);let n=c(t.entries),r=new Set(n);e._zod.values=r,e._zod.pattern=RegExp(`^(${n.filter(e=>ae.has(typeof e)).map(e=>typeof e==`string`?b(e):e.toString()).join(`|`)})$`),e._zod.parse=(t,i)=>{let a=t.value;return r.has(a)||t.issues.push({code:`invalid_value`,values:n,input:a,inst:e}),t}}),kn=r(`$ZodTransform`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new a(e.constructor.name);let o=t.transform(n.value,n);if(r.async)return(o instanceof Promise?o:Promise.resolve(o)).then(e=>(n.value=e,n.fallback=!0,n));if(o instanceof Promise)throw new i;return n.value=o,n.fallback=!0,n}});function An(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}var jn=r(`$ZodOptional`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,e._zod.optout=`optional`,h(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),h(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${f(e.source)})?$`):void 0}),e._zod.parse=(e,n)=>{if(t.innerType._zod.optin===`optional`){let r=e.value,i=t.innerType._zod.run(e,n);return i instanceof Promise?i.then(e=>An(e,r)):An(i,r)}return e.value===void 0?e:t.innerType._zod.run(e,n)}}),Mn=r(`$ZodExactOptional`,(e,t)=>{jn.init(e,t),h(e._zod,`values`,()=>t.innerType._zod.values),h(e._zod,`pattern`,()=>t.innerType._zod.pattern),e._zod.parse=(e,n)=>t.innerType._zod.run(e,n)}),Nn=r(`$ZodNullable`,(e,t)=>{E.init(e,t),h(e._zod,`optin`,()=>t.innerType._zod.optin),h(e._zod,`optout`,()=>t.innerType._zod.optout),h(e._zod,`pattern`,()=>{let e=t.innerType._zod.pattern;return e?RegExp(`^(${f(e.source)}|null)$`):void 0}),h(e._zod,`values`,()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(e,n)=>e.value===null?e:t.innerType._zod.run(e,n)}),Pn=r(`$ZodDefault`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,h(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);if(e.value===void 0)return e.value=t.defaultValue,e;let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(e=>Fn(e,t)):Fn(r,t)}});function Fn(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}var In=r(`$ZodPrefault`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,h(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>(n.direction===`backward`||e.value===void 0&&(e.value=t.defaultValue),t.innerType._zod.run(e,n))}),Ln=r(`$ZodNonOptional`,(e,t)=>{E.init(e,t),h(e._zod,`values`,()=>{let e=t.innerType._zod.values;return e?new Set([...e].filter(e=>e!==void 0)):void 0}),e._zod.parse=(n,r)=>{let i=t.innerType._zod.run(n,r);return i instanceof Promise?i.then(t=>Rn(t,e)):Rn(i,e)}});function Rn(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:`invalid_type`,expected:`nonoptional`,input:e.value,inst:t}),e}var zn=r(`$ZodCatch`,(e,t)=>{E.init(e,t),e._zod.optin=`optional`,h(e._zod,`optout`,()=>t.innerType._zod.optout),h(e._zod,`values`,()=>t.innerType._zod.values),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(r=>(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>w(e,n,s()))},input:e.value}),e.issues=[],e.fallback=!0),e)):(e.value=r.value,r.issues.length&&(e.value=t.catchValue({...e,error:{issues:r.issues.map(e=>w(e,n,s()))},input:e.value}),e.issues=[],e.fallback=!0),e)}}),Bn=r(`$ZodPipe`,(e,t)=>{E.init(e,t),h(e._zod,`values`,()=>t.in._zod.values),h(e._zod,`optin`,()=>t.in._zod.optin),h(e._zod,`optout`,()=>t.out._zod.optout),h(e._zod,`propValues`,()=>t.in._zod.propValues),e._zod.parse=(e,n)=>{if(n.direction===`backward`){let r=t.out._zod.run(e,n);return r instanceof Promise?r.then(e=>Vn(e,t.in,n)):Vn(r,t.in,n)}let r=t.in._zod.run(e,n);return r instanceof Promise?r.then(e=>Vn(e,t.out,n)):Vn(r,t.out,n)}});function Vn(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}var Hn=r(`$ZodReadonly`,(e,t)=>{E.init(e,t),h(e._zod,`propValues`,()=>t.innerType._zod.propValues),h(e._zod,`values`,()=>t.innerType._zod.values),h(e._zod,`optin`,()=>t.innerType?._zod?.optin),h(e._zod,`optout`,()=>t.innerType?._zod?.optout),e._zod.parse=(e,n)=>{if(n.direction===`backward`)return t.innerType._zod.run(e,n);let r=t.innerType._zod.run(e,n);return r instanceof Promise?r.then(Un):Un(r)}});function Un(e){return e.value=Object.freeze(e.value),e}var Wn=r(`$ZodCustom`,(e,t)=>{T.init(e,t),E.init(e,t),e._zod.parse=(e,t)=>e,e._zod.check=n=>{let r=n.value,i=t.fn(r);if(i instanceof Promise)return i.then(t=>Gn(t,n,r,e));Gn(i,n,r,e)}});function Gn(e,t,n,r){if(!e){let e={code:`custom`,input:n,inst:r,path:[...r._zod.def.path??[]],continue:!r._zod.def.abort};r._zod.def.params&&(e.params=r._zod.def.params),t.issues.push(ye(e))}}var Kn,qn=class{constructor(){this._map=new WeakMap,this._idmap=new Map}add(e,...t){let n=t[0];return this._map.set(e,n),n&&typeof n==`object`&&`id`in n&&this._idmap.set(n.id,e),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(e){let t=this._map.get(e);return t&&typeof t==`object`&&`id`in t&&this._idmap.delete(t.id),this._map.delete(e),this}get(e){let t=e._zod.parent;if(t){let n={...this.get(t)??{}};delete n.id;let r={...n,...this._map.get(e)};return Object.keys(r).length?r:void 0}return this._map.get(e)}has(e){return this._map.has(e)}};function Jn(){return new qn}(Kn=globalThis).__zod_globalRegistry??(Kn.__zod_globalRegistry=Jn());var Yn=globalThis.__zod_globalRegistry;function Xn(e,t){return new e({type:`string`,...S(t)})}function Zn(e,t){return new e({type:`string`,format:`email`,check:`string_format`,abort:!1,...S(t)})}function Qn(e,t){return new e({type:`string`,format:`guid`,check:`string_format`,abort:!1,...S(t)})}function $n(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,...S(t)})}function er(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v4`,...S(t)})}function tr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v6`,...S(t)})}function nr(e,t){return new e({type:`string`,format:`uuid`,check:`string_format`,abort:!1,version:`v7`,...S(t)})}function rr(e,t){return new e({type:`string`,format:`url`,check:`string_format`,abort:!1,...S(t)})}function ir(e,t){return new e({type:`string`,format:`emoji`,check:`string_format`,abort:!1,...S(t)})}function ar(e,t){return new e({type:`string`,format:`nanoid`,check:`string_format`,abort:!1,...S(t)})}function or(e,t){return new e({type:`string`,format:`cuid`,check:`string_format`,abort:!1,...S(t)})}function sr(e,t){return new e({type:`string`,format:`cuid2`,check:`string_format`,abort:!1,...S(t)})}function cr(e,t){return new e({type:`string`,format:`ulid`,check:`string_format`,abort:!1,...S(t)})}function lr(e,t){return new e({type:`string`,format:`xid`,check:`string_format`,abort:!1,...S(t)})}function ur(e,t){return new e({type:`string`,format:`ksuid`,check:`string_format`,abort:!1,...S(t)})}function dr(e,t){return new e({type:`string`,format:`ipv4`,check:`string_format`,abort:!1,...S(t)})}function fr(e,t){return new e({type:`string`,format:`ipv6`,check:`string_format`,abort:!1,...S(t)})}function pr(e,t){return new e({type:`string`,format:`cidrv4`,check:`string_format`,abort:!1,...S(t)})}function mr(e,t){return new e({type:`string`,format:`cidrv6`,check:`string_format`,abort:!1,...S(t)})}function hr(e,t){return new e({type:`string`,format:`base64`,check:`string_format`,abort:!1,...S(t)})}function gr(e,t){return new e({type:`string`,format:`base64url`,check:`string_format`,abort:!1,...S(t)})}function _r(e,t){return new e({type:`string`,format:`e164`,check:`string_format`,abort:!1,...S(t)})}function vr(e,t){return new e({type:`string`,format:`jwt`,check:`string_format`,abort:!1,...S(t)})}function yr(e,t){return new e({type:`string`,format:`datetime`,check:`string_format`,offset:!1,local:!1,precision:null,...S(t)})}function br(e,t){return new e({type:`string`,format:`date`,check:`string_format`,...S(t)})}function xr(e,t){return new e({type:`string`,format:`time`,check:`string_format`,precision:null,...S(t)})}function Sr(e,t){return new e({type:`string`,format:`duration`,check:`string_format`,...S(t)})}function Cr(e,t){return new e({type:`number`,checks:[],...S(t)})}function wr(e,t){return new e({type:`number`,check:`number_format`,abort:!1,format:`safeint`,...S(t)})}function Tr(e,t){return new e({type:`boolean`,...S(t)})}function Er(e){return new e({type:`unknown`})}function Dr(e,t){return new e({type:`never`,...S(t)})}function Or(e,t){return new yt({check:`less_than`,...S(t),value:e,inclusive:!1})}function kr(e,t){return new yt({check:`less_than`,...S(t),value:e,inclusive:!0})}function Ar(e,t){return new bt({check:`greater_than`,...S(t),value:e,inclusive:!1})}function jr(e,t){return new bt({check:`greater_than`,...S(t),value:e,inclusive:!0})}function Mr(e,t){return new xt({check:`multiple_of`,...S(t),value:e})}function Nr(e,t){return new Ct({check:`max_length`,...S(t),maximum:e})}function Pr(e,t){return new wt({check:`min_length`,...S(t),minimum:e})}function Fr(e,t){return new Tt({check:`length_equals`,...S(t),length:e})}function Ir(e,t){return new Dt({check:`string_format`,format:`regex`,...S(t),pattern:e})}function Lr(e){return new Ot({check:`string_format`,format:`lowercase`,...S(e)})}function Rr(e){return new kt({check:`string_format`,format:`uppercase`,...S(e)})}function zr(e,t){return new At({check:`string_format`,format:`includes`,...S(t),includes:e})}function Br(e,t){return new jt({check:`string_format`,format:`starts_with`,...S(t),prefix:e})}function Vr(e,t){return new Mt({check:`string_format`,format:`ends_with`,...S(t),suffix:e})}function O(e){return new Nt({check:`overwrite`,tx:e})}function Hr(e){return O(t=>t.normalize(e))}function Ur(){return O(e=>e.trim())}function Wr(){return O(e=>e.toLowerCase())}function Gr(){return O(e=>e.toUpperCase())}function Kr(){return O(e=>ee(e))}function qr(e,t,n){return new e({type:`array`,element:t,...S(n)})}function Jr(e,t,n){return new e({type:`custom`,check:`custom`,fn:t,...S(n)})}function Yr(e,t){let n=Xr(t=>(t.addIssue=e=>{if(typeof e==`string`)t.issues.push(ye(e,t.value,n._zod.def));else{let r=e;r.fatal&&(r.continue=!1),r.code??=`custom`,r.input??=t.value,r.inst??=n,r.continue??=!n._zod.def.abort,t.issues.push(ye(r))}},e(t.value,t)),t);return n}function Xr(e,t){let n=new T({check:`custom`,...S(t)});return n._zod.check=e,n}function Zr(e){let t=e?.target??`draft-2020-12`;return t===`draft-4`&&(t=`draft-04`),t===`draft-7`&&(t=`draft-07`),{processors:e.processors??{},metadataRegistry:e?.metadata??Yn,target:t,unrepresentable:e?.unrepresentable??`throw`,override:e?.override??(()=>{}),io:e?.io??`output`,counter:0,seen:new Map,cycles:e?.cycles??`ref`,reused:e?.reused??`inline`,external:e?.external??void 0}}function k(e,t,n={path:[],schemaPath:[]}){var r;let i=e._zod.def,a=t.seen.get(e);if(a)return a.count++,n.schemaPath.includes(e)&&(a.cycle=n.path),a.schema;let o={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,o);let s=e._zod.toJSONSchema?.();if(s)o.schema=s;else{let r={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,o.schema,r);else{let n=o.schema,a=t.processors[i.type];if(!a)throw Error(`[toJSONSchema]: Non-representable type encountered: ${i.type}`);a(e,t,n,r)}let a=e._zod.parent;a&&(o.ref||=a,k(a,t,r),t.seen.get(a).isParent=!0)}let c=t.metadataRegistry.get(e);return c&&Object.assign(o.schema,c),t.io===`input`&&A(e)&&(delete o.schema.examples,delete o.schema.default),t.io===`input`&&`_prefault`in o.schema&&((r=o.schema).default??(r.default=o.schema._prefault)),delete o.schema._prefault,t.seen.get(e).schema}function Qr(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=new Map;for(let t of e.seen.entries()){let n=e.metadataRegistry.get(t[0])?.id;if(n){let e=r.get(n);if(e&&e!==t[0])throw Error(`Duplicate schema id "${n}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);r.set(n,t[0])}}let i=t=>{let r=e.target===`draft-2020-12`?`$defs`:`definitions`;if(e.external){let n=e.external.registry.get(t[0])?.id,i=e.external.uri??(e=>e);if(n)return{ref:i(n)};let a=t[1].defId??t[1].schema.id??`schema${e.counter++}`;return t[1].defId=a,{defId:a,ref:`${i(`__shared`)}#/${r}/${a}`}}if(t[1]===n)return{ref:`#`};let i=`#/${r}/`,a=t[1].schema.id??`__schema${e.counter++}`;return{defId:a,ref:i+a}},a=e=>{if(e[1].schema.$ref)return;let t=e[1],{ref:n,defId:r}=i(e);t.def={...t.schema},r&&(t.defId=r);let a=t.schema;for(let e in a)delete a[e];a.$ref=n};if(e.cycles===`throw`)for(let t of e.seen.entries()){let e=t[1];if(e.cycle)throw Error(`Cycle detected: #/${e.cycle?.join(`/`)}/<root>
64
64
 
65
- Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function Qr(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:ei(t,`input`,e.processors),output:ei(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function j(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return j(r.element,n);if(r.type===`set`)return j(r.valueType,n);if(r.type===`lazy`)return j(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return j(r.innerType,n);if(r.type===`intersection`)return j(r.left,n)||j(r.right,n);if(r.type===`record`||r.type===`map`)return j(r.keyType,n)||j(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:j(r.in,n)||j(r.out,n);if(r.type===`object`){for(let e in r.shape)if(j(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(j(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(j(e,n))return!0;return!!(r.rest&&j(r.rest,n))}return!1}var $r=(e,t={})=>n=>{let r=Xr({...n,processors:t});return A(e,r),Zr(r,e),Qr(r,e)},ei=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Xr({...i??{},target:a,io:t,processors:n});return A(e,o),Zr(o,e),Qr(o,e)},ti={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ni=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ti[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},ri=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},ii=(e,t,n,r)=>{n.type=`boolean`},ai=(e,t,n,r)=>{n.not={}},oi=(e,t,n,r)=>{let i=e._zod.def,a=c(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},si=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},ci=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},li=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=A(a.element,t,{...r,path:[...r.path,`items`]})},ui=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=A(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=A(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},di=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>A(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},fi=(e,t,n,r)=>{let i=e._zod.def,a=A(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=A(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},pi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=A(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=A(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=A(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},mi=(e,t,n,r)=>{let i=e._zod.def,a=A(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},hi=(e,t,n,r)=>{let i=e._zod.def;A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},gi=(e,t,n,r)=>{let i=e._zod.def;A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},_i=(e,t,n,r)=>{let i=e._zod.def;A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},vi=(e,t,n,r)=>{let i=e._zod.def;A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},yi=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;A(o,t,r);let s=t.seen.get(e);s.ref=o},bi=(e,t,n,r)=>{let i=e._zod.def;A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},xi=(e,t,n,r)=>{let i=e._zod.def;A(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Si=r(`ZodISODateTime`,(e,t)=>{qt.init(e,t),F.init(e,t)});function Ci(e){return vr(Si,e)}var wi=r(`ZodISODate`,(e,t)=>{Jt.init(e,t),F.init(e,t)});function Ti(e){return yr(wi,e)}var Ei=r(`ZodISOTime`,(e,t)=>{Yt.init(e,t),F.init(e,t)});function Di(e){return br(Ei,e)}var Oi=r(`ZodISODuration`,(e,t)=>{Xt.init(e,t),F.init(e,t)});function ki(e){return xr(Oi,e)}var M=r(`ZodError`,(e,t)=>{be.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>Ce(e,t)},flatten:{value:t=>Se(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,l,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,l,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),Ai=Ee(M),ji=De(M),Mi=Oe(M),Ni=Ae(M),Pi=Me(M),Fi=Ne(M),Ii=Pe(M),Li=Fe(M),Ri=Ie(M),zi=Le(M),Bi=Re(M),Vi=ze(M),Hi=new WeakMap;function Ui(e,t,n){let r=Object.getPrototypeOf(e),i=Hi.get(r);if(i||(i=new Set,Hi.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var N=r(`ZodType`,(e,t)=>(D.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ei(e,`input`),output:ei(e,`output`)}}),e.toJSONSchema=$r(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>Ai(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Mi(e,t,n),e.parseAsync=async(t,n)=>ji(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Ni(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Pi(e,t,n),e.decode=(t,n)=>Fi(e,t,n),e.encodeAsync=async(t,n)=>Ii(e,t,n),e.decodeAsync=async(t,n)=>Li(e,t,n),e.safeEncode=(t,n)=>Ri(e,t,n),e.safeDecode=(t,n)=>zi(e,t,n),e.safeEncodeAsync=async(t,n)=>Bi(e,t,n),e.safeDecodeAsync=async(t,n)=>Vi(e,t,n),Ui(e,`ZodType`,{check(...e){let t=this.def;return this.clone(_(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return x(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Xa(e,t))},superRefine(e,t){return this.check(Za(e,t))},overwrite(e){return this.check(k(e))},optional(){return Ma(this)},exactOptional(){return Pa(this)},nullable(){return Ia(this)},nullish(){return Ma(Ia(this))},nonoptional(e){return Ha(this,e)},array(){return ba(this)},or(e){return Ca([this,e])},and(e){return Ta(this,e)},transform(e){return Ka(this,Aa(e))},default(e){return Ra(this,e)},prefault(e){return Ba(this,e)},catch(e){return Wa(this,e)},pipe(e){return Ka(this,e)},readonly(){return Ja(this)},describe(e){let t=this.clone();return Jn.add(t,{description:e}),t},meta(...e){if(e.length===0)return Jn.get(this);let t=this.clone();return Jn.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Jn.get(e)?.description},configurable:!0}),e)),Wi=r(`_ZodString`,(e,t)=>{Ft.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ni(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ui(e,`_ZodString`,{regex(...e){return this.check(Fr(...e))},includes(...e){return this.check(Rr(...e))},startsWith(...e){return this.check(zr(...e))},endsWith(...e){return this.check(Br(...e))},min(...e){return this.check(Nr(...e))},max(...e){return this.check(Mr(...e))},length(...e){return this.check(Pr(...e))},nonempty(...e){return this.check(Nr(1,...e))},lowercase(e){return this.check(Ir(e))},uppercase(e){return this.check(Lr(e))},trim(){return this.check(Hr())},normalize(...e){return this.check(Vr(...e))},toLowerCase(){return this.check(Ur())},toUpperCase(){return this.check(Wr())},slugify(){return this.check(Gr())}})}),Gi=r(`ZodString`,(e,t)=>{Ft.init(e,t),Wi.init(e,t),e.email=t=>e.check(Xn(Ki,t)),e.url=t=>e.check(nr(Yi,t)),e.jwt=t=>e.check(_r(ua,t)),e.emoji=t=>e.check(rr(Xi,t)),e.guid=t=>e.check(Zn(qi,t)),e.uuid=t=>e.check(Qn(Ji,t)),e.uuidv4=t=>e.check($n(Ji,t)),e.uuidv6=t=>e.check(er(Ji,t)),e.uuidv7=t=>e.check(tr(Ji,t)),e.nanoid=t=>e.check(ir(Zi,t)),e.guid=t=>e.check(Zn(qi,t)),e.cuid=t=>e.check(ar(Qi,t)),e.cuid2=t=>e.check(or($i,t)),e.ulid=t=>e.check(sr(ea,t)),e.base64=t=>e.check(mr(sa,t)),e.base64url=t=>e.check(hr(ca,t)),e.xid=t=>e.check(cr(ta,t)),e.ksuid=t=>e.check(lr(na,t)),e.ipv4=t=>e.check(ur(ra,t)),e.ipv6=t=>e.check(dr(ia,t)),e.cidrv4=t=>e.check(fr(aa,t)),e.cidrv6=t=>e.check(pr(oa,t)),e.e164=t=>e.check(gr(la,t)),e.datetime=t=>e.check(Ci(t)),e.date=t=>e.check(Ti(t)),e.time=t=>e.check(Di(t)),e.duration=t=>e.check(ki(t))});function P(e){return Yn(Gi,e)}var F=r(`ZodStringFormat`,(e,t)=>{O.init(e,t),Wi.init(e,t)}),Ki=r(`ZodEmail`,(e,t)=>{Rt.init(e,t),F.init(e,t)}),qi=r(`ZodGUID`,(e,t)=>{It.init(e,t),F.init(e,t)}),Ji=r(`ZodUUID`,(e,t)=>{Lt.init(e,t),F.init(e,t)}),Yi=r(`ZodURL`,(e,t)=>{zt.init(e,t),F.init(e,t)}),Xi=r(`ZodEmoji`,(e,t)=>{Bt.init(e,t),F.init(e,t)}),Zi=r(`ZodNanoID`,(e,t)=>{Vt.init(e,t),F.init(e,t)}),Qi=r(`ZodCUID`,(e,t)=>{Ht.init(e,t),F.init(e,t)}),$i=r(`ZodCUID2`,(e,t)=>{Ut.init(e,t),F.init(e,t)}),ea=r(`ZodULID`,(e,t)=>{Wt.init(e,t),F.init(e,t)}),ta=r(`ZodXID`,(e,t)=>{Gt.init(e,t),F.init(e,t)}),na=r(`ZodKSUID`,(e,t)=>{Kt.init(e,t),F.init(e,t)}),ra=r(`ZodIPv4`,(e,t)=>{Zt.init(e,t),F.init(e,t)}),ia=r(`ZodIPv6`,(e,t)=>{Qt.init(e,t),F.init(e,t)}),aa=r(`ZodCIDRv4`,(e,t)=>{$t.init(e,t),F.init(e,t)}),oa=r(`ZodCIDRv6`,(e,t)=>{en.init(e,t),F.init(e,t)}),sa=r(`ZodBase64`,(e,t)=>{nn.init(e,t),F.init(e,t)}),ca=r(`ZodBase64URL`,(e,t)=>{an.init(e,t),F.init(e,t)}),la=r(`ZodE164`,(e,t)=>{on.init(e,t),F.init(e,t)}),ua=r(`ZodJWT`,(e,t)=>{cn.init(e,t),F.init(e,t)}),da=r(`ZodNumber`,(e,t)=>{ln.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ri(e,t,n,r),Ui(e,`ZodNumber`,{gt(e,t){return this.check(kr(e,t))},gte(e,t){return this.check(Ar(e,t))},min(e,t){return this.check(Ar(e,t))},lt(e,t){return this.check(Dr(e,t))},lte(e,t){return this.check(Or(e,t))},max(e,t){return this.check(Or(e,t))},int(e){return this.check(pa(e))},safe(e){return this.check(pa(e))},positive(e){return this.check(kr(0,e))},nonnegative(e){return this.check(Ar(0,e))},negative(e){return this.check(Dr(0,e))},nonpositive(e){return this.check(Or(0,e))},multipleOf(e,t){return this.check(jr(e,t))},step(e,t){return this.check(jr(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function I(e){return Sr(da,e)}var fa=r(`ZodNumberFormat`,(e,t)=>{un.init(e,t),da.init(e,t)});function pa(e){return Cr(fa,e)}var ma=r(`ZodBoolean`,(e,t)=>{dn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ii(e,t,n,r)});function L(e){return wr(ma,e)}var ha=r(`ZodUnknown`,(e,t)=>{fn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function ga(){return Tr(ha)}var _a=r(`ZodNever`,(e,t)=>{pn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ai(e,t,n,r)});function va(e){return Er(_a,e)}var ya=r(`ZodArray`,(e,t)=>{hn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>li(e,t,n,r),e.element=t.element,Ui(e,`ZodArray`,{min(e,t){return this.check(Nr(e,t))},nonempty(e){return this.check(Nr(1,e))},max(e,t){return this.check(Mr(e,t))},length(e,t){return this.check(Pr(e,t))},unwrap(){return this.element}})});function ba(e,t){return Kr(ya,e,t)}var xa=r(`ZodObject`,(e,t)=>{bn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ui(e,t,n,r),h(e,`shape`,()=>t.shape),Ui(e,`ZodObject`,{keyof(){return z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:ga()})},loose(){return this.clone({...this._zod.def,catchall:ga()})},strict(){return this.clone({...this._zod.def,catchall:va()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ue(this,e)},safeExtend(e){return de(this,e)},merge(e){return fe(this,e)},pick(e){return ce(this,e)},omit(e){return le(this,e)},partial(...e){return pe(ja,this,e[0])},required(...e){return me(Va,this,e[0])}})});function R(e,t){return new xa({type:`object`,shape:e??{},...S(t)})}var Sa=r(`ZodUnion`,(e,t)=>{Sn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>di(e,t,n,r),e.options=t.options});function Ca(e,t){return new Sa({type:`union`,options:e,...S(t)})}var wa=r(`ZodIntersection`,(e,t)=>{Cn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fi(e,t,n,r)});function Ta(e,t){return new wa({type:`intersection`,left:e,right:t})}var Ea=r(`ZodRecord`,(e,t)=>{En.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pi(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Da(e,t,n){return!t||!t._zod?new Ea({type:`record`,keyType:P(),valueType:e,...S(t)}):new Ea({type:`record`,keyType:e,valueType:t,...S(n)})}var Oa=r(`ZodEnum`,(e,t)=>{Dn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Oa({...t,checks:[],...S(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Oa({...t,checks:[],...S(r),entries:i})}});function z(e,t){return new Oa({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...S(t)})}var ka=r(`ZodTransform`,(e,t)=>{On.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ci(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new a(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(ve(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(ve(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Aa(e){return new ka({type:`transform`,transform:e})}var ja=r(`ZodOptional`,(e,t)=>{An.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ma(e){return new ja({type:`optional`,innerType:e})}var Na=r(`ZodExactOptional`,(e,t)=>{jn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pa(e){return new Na({type:`optional`,innerType:e})}var Fa=r(`ZodNullable`,(e,t)=>{Mn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ia(e){return new Fa({type:`nullable`,innerType:e})}var La=r(`ZodDefault`,(e,t)=>{Nn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ra(e,t){return new La({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}var za=r(`ZodPrefault`,(e,t)=>{Fn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_i(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ba(e,t){return new za({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}var Va=r(`ZodNonOptional`,(e,t)=>{In.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ha(e,t){return new Va({type:`nonoptional`,innerType:e,...S(t)})}var Ua=r(`ZodCatch`,(e,t)=>{Rn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Wa(e,t){return new Ua({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Ga=r(`ZodPipe`,(e,t)=>{zn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yi(e,t,n,r),e.in=t.in,e.out=t.out});function Ka(e,t){return new Ga({type:`pipe`,in:e,out:t})}var qa=r(`ZodReadonly`,(e,t)=>{Vn.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ja(e){return new qa({type:`readonly`,innerType:e})}var Ya=r(`ZodCustom`,(e,t)=>{Un.init(e,t),N.init(e,t),e._zod.processJSONSchema=(t,n,r)=>si(e,t,n,r)});function Xa(e,t={}){return qr(Ya,e,t)}function Za(e,t){return Jr(e,t)}function B(e){return Object.freeze(e)}var V=class extends Error{code;constructor(e,t=`ACTION_FAILED`){super(e),this.code=t,this.name=`ActionError`}},Qa=`browsentic/bridge`,$a=e=>({ok:!0,data:e}),eo=(e,t)=>({ok:!1,error:{code:e,message:t}});function to(e){return no(e,`browsentic/action`)&&typeof e.action==`string`}function no(e,t){return typeof e==`object`&&!!e&&e.channel===t}var ro={r:0,g:0,b:0,a:0},io={r:255,g:255,b:255,a:1},ao={r:18,g:18,b:18,a:1},oo=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,so=/^rgba?\(([^)]+)\)$/i,co=/-?\d*\.?\d+(?:e-?\d+)?%?/gi,lo=new Map;function H(e){let t=e?.trim();return t?(lo.has(t)||lo.set(t,uo(t)),lo.get(t)??null):null}function uo(e){return e===`transparent`?ro:fo(e)??po(e)??go(e)}function fo(e){if(!oo.test(e))return null;let t=e.slice(1),n=t.length>4,r=n?2:1,i=e=>{let i=t.slice(e*r,e*r+r);return parseInt(n?i:i+i,16)},a=t.length===4||t.length===8?i(3)/255:1;return{r:i(0),g:i(1),b:i(2),a}}function po(e){let t=(so.exec(e)?.[1])?.match(co);if(!t||t.length<3)return null;let n=(e,t)=>e.endsWith(`%`)?parseFloat(e)/100*t:parseFloat(e);return{r:ko(n(t[0],255)),g:ko(n(t[1],255)),b:ko(n(t[2],255)),a:t[3]===void 0?1:Oo(n(t[3],1))}}var mo;function ho(){return mo??=document.createElement(`canvas`).getContext(`2d`,{willReadFrequently:!0}),mo}function go(e){let t=ho();if(!t)return null;t.fillStyle=`#000000`,t.fillStyle=e;let n=t.fillStyle;return t.fillStyle=`#ffffff`,t.fillStyle=e,n===t.fillStyle?fo(t.fillStyle)??po(t.fillStyle)??_o(t,e):null}function _o(e,t){e.clearRect(0,0,1,1),e.fillStyle=t,e.fillRect(0,0,1,1);let[n,r,i,a]=e.getImageData(0,0,1,1).data;return{r:n,g:r,b:i,a:a/255}}function U({r:e,g:t,b:n,a:r}){let i=e=>ko(e).toString(16).padStart(2,`0`),a=r>=1?``:i(Math.round(r*255));return`#${i(e)}${i(t)}${i(n)}${a}`}function vo({r:e,g:t,b:n,a:r}){return{r:255-e,g:255-t,b:255-n,a:r}}function W({r:e,g:t,b:n}){return .2126*yo(e)+.7152*yo(t)+.0722*yo(n)}function yo(e){let t=ko(e)/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function bo(e,t){let n=W(e),r=W(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function xo(e,t){let n=e.a+t.a*(1-e.a);if(n===0)return ro;let r=(r,i)=>Math.round((r*e.a+i*t.a*(1-e.a))/n);return{r:r(e.r,t.r),g:r(e.g,t.g),b:r(e.b,t.b),a:n}}function So(){let e=getComputedStyle(document.documentElement).colorScheme||`normal`;return e.includes(`dark`)?e.includes(`light`)?matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:`dark`:`light`}function Co(){return So()===`dark`?ao:io}function wo(e){let t=ro;for(let n=e;n;n=n.parentElement){let e=H(getComputedStyle(n).backgroundColor);if(!(!e||e.a===0)&&(t=xo(t,e),t.a>=1))return t}return xo(t,Co())}function To(e,t){let n=H(getComputedStyle(e).color)??ro;return n.a>=1?n:xo(n,t)}function Eo(e,t){return e>=24||e>=18.66&&t>=700}function Do(e,t){return t===`AAA`?e?4.5:7:e?3:4.5}function G(e,t){let n=10**t;return Math.round(e*n)/n}function Oo(e){return Math.min(1,Math.max(0,e))}function ko(e){return Math.min(255,Math.max(0,Math.round(e)))}var Ao=[[-.574,1.43,.144],[.426,.43,.144],[.426,1.43,-.856]];function jo(e,t){let n=[e.r,e.g,e.b];t.invert&&(n=Mo(n.map(e=>255-e),Ao)),n=n.map(e=>e*t.brightness),t.saturate!==void 0&&(n=Mo(n,Po(t.saturate))),t.contrast!==void 0&&(n=n.map(e=>(e-127.5)*t.contrast+127.5));let[r,i,a]=n.map(ko);return{r,g:i,b:a,a:e.a}}function Mo(e,t){return t.map(t=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2])}function No(e,t,n=.05,r=4){let i=n,a=r;for(let n=0;n<24;n+=1){let n=(i+a)/2;W(jo(e,{invert:!1,brightness:n}))<t?i=n:a=n}return G((i+a)/2,3)}function Po(e){return[[.213+.787*e,.715-.715*e,.072-.072*e],[.213-.213*e,.715+.285*e,.072-.072*e],[.213-.213*e,.715-.715*e,.072+.928*e]]}var Fo=`browsentic-theme`,Io=`data-browsentic-added-class`,Lo=`data-browsentic-hook-attribute`,Ro=`data-browsentic-hook-host`,zo=`data-browsentic-filter`,Bo=`data-browsentic-previous-value`,Vo=/\.((?:theme-|mode-)?(dark|light)(?:-mode|-theme)?)(?![\w-])/i,Ho=/\[([\w-]*(?:theme|mode|scheme))\s*[~|^$*]?=\s*["']?(dark|light)["']?\s*[is]?\]/i;function Uo(e){let t=[...document.styleSheets,...document.adoptedStyleSheets],n=new Set,r=new Map,i={total:t.length,readable:0,crossOrigin:0,inline:0},a=0,o=t=>{if(!(a>=e)){if(a+=1,t instanceof CSSStyleRule){for(let e of t.style)e.startsWith(`--`)&&n.add(e);Go(t.selectorText,r);return}if(t instanceof CSSGroupingRule)for(let e of t.cssRules)o(e);if(t instanceof CSSImportRule)for(let e of Wo(t.styleSheet)??[])o(e)}};for(let e of t){e.href||(i.inline+=1);let t=Wo(e);if(!t){i.crossOrigin+=1;continue}i.readable+=1;for(let e of t)o(e)}return{sheets:i,rules:a,properties:[...n],hooks:[...r.values()],truncated:a>=e}}function Wo(e){try{return e?.cssRules??null}catch{return null}}function Go(e,t){for(let n of e.split(`,`)){let e=n.trim(),r=e.split(/[\s>+~]+/)[0],i=/^body\b/i.test(r)?`body`:`root`,a=Ho.exec(r);if(a){let[,n,r]=a;Ko(t,{kind:`attribute`,name:n.toLowerCase(),value:r.toLowerCase(),scheme:r.toLowerCase(),host:i,selector:e});continue}let o=Vo.exec(r);if(o){let[,n,r]=o;Ko(t,{kind:`class`,name:n,scheme:r.toLowerCase(),host:i,selector:e})}}}function Ko(e,t){e.set(`${t.kind}:${t.host}:${t.name}:${t.value??``}`,t)}function qo(e,t){let n=getComputedStyle(document.documentElement),r=e.map(e=>({name:e,value:n.getPropertyValue(e).trim().slice(0,120)})).filter(({value:e})=>e!==``).sort((e,t)=>e.name<t.name?-1:1);return{total:r.length,listed:r.slice(0,t).map(Jo)}}function Jo({name:e,value:t}){let n=H(t);return!n||n.a===0?{name:e,value:t}:{name:e,value:t,color:U(n),luminance:G(W(n),3)}}function Yo(){let e=document.getElementById(Fo)?.getAttribute(zo);if(e)try{return JSON.parse(e)}catch{return}}function Xo(){let e=Yo();return e?t=>jo(t,e):e=>e}function Zo(e,t){e.setAttribute(zo,JSON.stringify(t))}function Qo(){let e=document.body??document.documentElement,t=Xo(),n=wo(e),r=t(n),i=t(To(e,n));return{colorScheme:So(),background:U(r),text:U(i),luminance:G(W(r),4),contrast:G(bo(i,r),2),...Yo()?{filtered:!0}:{}}}function $o(e){return e===`body`?document.body??document.documentElement:document.documentElement}function es(){let e=document.getElementById(Fo);if(!e)return!1;let t=$o(e.getAttribute(Ro)===`body`?`body`:`root`),n=e.getAttribute(Io);n&&t.classList.remove(n);let r=e.getAttribute(Lo);if(r){let n=e.getAttribute(Bo);n===null?t.removeAttribute(r):t.setAttribute(r,n)}return e.remove(),!0}function ts(e,t){let n=document.createElement(`style`);return n.id=Fo,n.textContent=e,t&&ns(n,t),document.documentElement.append(n),n}function ns(e,t){let n=$o(t.host);if(e.setAttribute(Ro,t.host),t.kind===`class`){if(n.classList.contains(t.name))return;n.classList.add(t.name),e.setAttribute(Io,t.name);return}let r=n.getAttribute(t.name);e.setAttribute(Lo,t.name),r!==null&&e.setAttribute(Bo,r),n.setAttribute(t.name,t.value??``)}var rs=2e4,is=40,as=/^--[A-Za-z0-9_-]+$/,os=/[;{}<>\\]|@import|url\(|expression\(/i,ss=.05,cs=.92,ls=.08,us=`img, picture, video, canvas, svg, iframe, embed, object`,ds=`invert(1) hue-rotate(180deg)`,fs=B({name:`page.applyTheme`,description:`Retheme the page, or put it back. Prefers the page’s own terms — it switches on the dark/light hook its stylesheets already define (a ".dark" class, a [data-theme] attribute), sets color-scheme, and overrides the design tokens you name. Only when that leaves the page at the wrong luminance does it fall back to repainting through a CSS filter. Reports the measured background luminance and text contrast before and after, so the change can be checked rather than assumed. The filter fallback creates a containing block on <html>, which re-anchors position:fixed elements, and it re-inverts images so photos stay right way round. Nothing here survives a reload — call it again, or with mode "revert", to undo it.`,input:R({mode:z([`keep`,`dark`,`light`,`revert`]).default(`keep`).describe(`Which way to push the page: "dark" or "light" retheme it, "revert" removes everything Browsentic applied and restores the page’s own theme, "keep" leaves the light/dark decision alone and applies only the colours below`),targetLuminance:I().min(0).max(1).optional().describe(`Relative luminance to bring the page background to, 0 black to 1 white, as reported by page.readTheme. Overrides the luminance "dark" and "light" imply. Reached by filtering, so it repaints images and text alike`),background:P().optional().describe(`CSS colour for the page background, e.g. "#0f172a" or "rgb(15 23 42)"; suppresses the luminance a mode would imply`),text:P().optional().describe(`CSS colour for body text; elements that set their own colour keep it`),accent:P().optional().describe(`CSS colour for links and form-control accents`),tokens:Da(P(),P()).optional().describe(`CSS custom properties to override on :root, e.g. {"--background": "#0f172a"}. Names come from page.readTheme’s tokens — this is the cleanest way to retheme a page that is built on design tokens, because its own rules do the work`),saturation:I().min(0).max(3).optional().describe(`Colour intensity multiplier: 0 greyscale, 1 unchanged, above 1 more vivid`),contrast:I().min(0).max(3).optional().describe(`Contrast multiplier: 1 unchanged, above 1 pushes lights and darks apart`),transitionMs:I().int().nonnegative().max(2e3).default(200).describe(`How long the page takes to cross-fade into the new theme; 0 switches instantly`)}),execute({mode:e,targetLuminance:t,background:n,text:r,accent:i,tokens:a,saturation:o,contrast:s,transitionMs:c}){let l={background:ps(n,`background`),text:ps(r,`text`),accent:ps(i,`accent`)},u=ms(a);if(e===`keep`&&t===void 0&&!(o!==void 0||s!==void 0)&&!u.length&&!Object.values(l).some(Boolean))throw new V(`Nothing to apply — pass a "mode", a "targetLuminance", a colour, or "tokens".`,`INVALID_INPUT`);let d=es(),f=Qo();if(e===`revert`)return{reverted:d,theme:f};let p=e===`dark`||e===`light`?hs(e):void 0,m=ts(_s({mode:e,colors:l,overrides:u,transitionMs:c}),p),h=Qo(),g=t??(l.background?void 0:vs(e,h.luminance)),_=ys(g,h.background,o,s);_&&(m.textContent+=`\n${xs(_,h.background,c)}`,Zo(m,_));let v=Qo();return{replaced:d,strategy:_?`filter`:p||e!==`keep`?`stylesheet`:`colors`,applied:{mode:e,hook:p,...l,tokens:u.length?u.map(([e])=>e):void 0,filter:_?bs(_).join(` `):void 0,targetLuminance:g},css:(m.textContent??``).slice(0,4e3),before:f,after:v,...g===void 0?{}:{reachedTarget:Math.abs(v.luminance-g)<=ls}}}});function ps(e,t){if(e===void 0)return;let n=H(e);if(!n)throw new V(`"${t}" is not a colour this browser understands — pass something like "#0f172a", "rgb(15 23 42)" or "midnightblue".`,`INVALID_INPUT`);return U(n)}function ms(e){let t=Object.entries(e??{});if(t.length>is)throw new V(`Too many tokens — ${t.length} given and ${is} is the limit. Override only the ones that carry the theme.`,`INVALID_INPUT`);return t.map(([e,t])=>{if(!as.test(e))throw new V(`"${e}" is not a custom property — names look like "--brand-500".`,`INVALID_INPUT`);let n=t.trim();if(!n||os.test(n))throw new V(`The value for "${e}" is not a plain CSS value — it cannot be empty or carry ";", "{", "}", "\\" or "url(".`,`INVALID_INPUT`);return[e,n]})}function hs(e){return Uo(rs).hooks.filter(t=>t.scheme===e).sort((e,t)=>gs(e)-gs(t))[0]}function gs(e){return e.kind===`attribute`?e.name===`data-theme`?0:1:e.name.toLowerCase()===e.scheme?2:3}function _s({mode:e,colors:t,overrides:n,transitionMs:r}){let i=[];return e!==`keep`&&i.push(`:root { color-scheme: ${e}; }`),n.length&&i.push(`:root { ${n.map(([e,t])=>`${e}: ${t};`).join(` `)} }`),t.background&&i.push(`html, body { background-color: ${t.background} !important; }`),t.text&&i.push(`html, body { color: ${t.text} !important; }`),t.accent&&i.push(`:root { accent-color: ${t.accent} !important; }`,`a { color: ${t.accent} !important; }`),r>0&&i.push(`html, body { transition: background-color ${r}ms linear, color ${r}ms linear, filter ${r}ms linear; }`),i.join(`
65
+ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(let n of e.seen.entries()){let r=n[1];if(t===n[0]){a(n);continue}if(e.external){let r=e.external.registry.get(n[0])?.id;if(t!==n[0]&&r){a(n);continue}}if(e.metadataRegistry.get(n[0])?.id){a(n);continue}if(r.cycle){a(n);continue}if(r.count>1&&e.reused===`ref`){a(n);continue}}}function $r(e,t){let n=e.seen.get(t);if(!n)throw Error(`Unprocessed schema. This is a bug in Zod.`);let r=t=>{let n=e.seen.get(t);if(n.ref===null)return;let i=n.def??n.schema,a={...i},o=n.ref;if(n.ref=null,o){r(o);let n=e.seen.get(o),s=n.schema;if(s.$ref&&(e.target===`draft-07`||e.target===`draft-04`||e.target===`openapi-3.0`)?(i.allOf=i.allOf??[],i.allOf.push(s)):Object.assign(i,s),Object.assign(i,a),t._zod.parent===o)for(let e in i)e===`$ref`||e===`allOf`||e in a||delete i[e];if(s.$ref&&n.def)for(let e in i)e===`$ref`||e===`allOf`||e in n.def&&JSON.stringify(i[e])===JSON.stringify(n.def[e])&&delete i[e]}let s=t._zod.parent;if(s&&s!==o){r(s);let t=e.seen.get(s);if(t?.schema.$ref&&(i.$ref=t.schema.$ref,t.def))for(let e in i)e===`$ref`||e===`allOf`||e in t.def&&JSON.stringify(i[e])===JSON.stringify(t.def[e])&&delete i[e]}e.override({zodSchema:t,jsonSchema:i,path:n.path??[]})};for(let t of[...e.seen.entries()].reverse())r(t[0]);let i={};if(e.target===`draft-2020-12`?i.$schema=`https://json-schema.org/draft/2020-12/schema`:e.target===`draft-07`?i.$schema=`http://json-schema.org/draft-07/schema#`:e.target===`draft-04`?i.$schema=`http://json-schema.org/draft-04/schema#`:e.target,e.external?.uri){let n=e.external.registry.get(t)?.id;if(!n)throw Error("Schema is missing an `id` property");i.$id=e.external.uri(n)}Object.assign(i,n.def??n.schema);let a=e.metadataRegistry.get(t)?.id;a!==void 0&&i.id===a&&delete i.id;let o=e.external?.defs??{};for(let t of e.seen.entries()){let e=t[1];e.def&&e.defId&&(e.def.id===e.defId&&delete e.def.id,o[e.defId]=e.def)}e.external||Object.keys(o).length>0&&(e.target===`draft-2020-12`?i.$defs=o:i.definitions=o);try{let n=JSON.parse(JSON.stringify(i));return Object.defineProperty(n,"~standard",{value:{...t[`~standard`],jsonSchema:{input:ti(t,`input`,e.processors),output:ti(t,`output`,e.processors)}},enumerable:!1,writable:!1}),n}catch{throw Error(`Error converting schema to JSON.`)}}function A(e,t){let n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);let r=e._zod.def;if(r.type===`transform`)return!0;if(r.type===`array`)return A(r.element,n);if(r.type===`set`)return A(r.valueType,n);if(r.type===`lazy`)return A(r.getter(),n);if(r.type===`promise`||r.type===`optional`||r.type===`nonoptional`||r.type===`nullable`||r.type===`readonly`||r.type==="default"||r.type===`prefault`)return A(r.innerType,n);if(r.type===`intersection`)return A(r.left,n)||A(r.right,n);if(r.type===`record`||r.type===`map`)return A(r.keyType,n)||A(r.valueType,n);if(r.type===`pipe`)return e._zod.traits.has(`$ZodCodec`)?!0:A(r.in,n)||A(r.out,n);if(r.type===`object`){for(let e in r.shape)if(A(r.shape[e],n))return!0;return!1}if(r.type===`union`){for(let e of r.options)if(A(e,n))return!0;return!1}if(r.type===`tuple`){for(let e of r.items)if(A(e,n))return!0;return!!(r.rest&&A(r.rest,n))}return!1}var ei=(e,t={})=>n=>{let r=Zr({...n,processors:t});return k(e,r),Qr(r,e),$r(r,e)},ti=(e,t,n={})=>r=>{let{libraryOptions:i,target:a}=r??{},o=Zr({...i??{},target:a,io:t,processors:n});return k(e,o),Qr(o,e),$r(o,e)},ni={guid:`uuid`,url:`uri`,datetime:`date-time`,json_string:`json-string`,regex:``},ri=(e,t,n,r)=>{let i=n;i.type=`string`;let{minimum:a,maximum:o,format:s,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof a==`number`&&(i.minLength=a),typeof o==`number`&&(i.maxLength=o),s&&(i.format=ni[s]??s,i.format===``&&delete i.format,s===`time`&&delete i.format),l&&(i.contentEncoding=l),c&&c.size>0){let e=[...c];e.length===1?i.pattern=e[0].source:e.length>1&&(i.allOf=[...e.map(e=>({...t.target===`draft-07`||t.target===`draft-04`||t.target===`openapi-3.0`?{type:`string`}:{},pattern:e.source}))])}},ii=(e,t,n,r)=>{let i=n,{minimum:a,maximum:o,format:s,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:u}=e._zod.bag;typeof s==`string`&&s.includes(`int`)?i.type=`integer`:i.type=`number`;let d=typeof u==`number`&&u>=(a??-1/0),f=typeof l==`number`&&l<=(o??1/0),p=t.target===`draft-04`||t.target===`openapi-3.0`;d?p?(i.minimum=u,i.exclusiveMinimum=!0):i.exclusiveMinimum=u:typeof a==`number`&&(i.minimum=a),f?p?(i.maximum=l,i.exclusiveMaximum=!0):i.exclusiveMaximum=l:typeof o==`number`&&(i.maximum=o),typeof c==`number`&&(i.multipleOf=c)},ai=(e,t,n,r)=>{n.type=`boolean`},oi=(e,t,n,r)=>{n.not={}},si=(e,t,n,r)=>{let i=e._zod.def,a=c(i.entries);a.every(e=>typeof e==`number`)&&(n.type=`number`),a.every(e=>typeof e==`string`)&&(n.type=`string`),n.enum=a},ci=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Custom types cannot be represented in JSON Schema`)},li=(e,t,n,r)=>{if(t.unrepresentable===`throw`)throw Error(`Transforms cannot be represented in JSON Schema`)},ui=(e,t,n,r)=>{let i=n,a=e._zod.def,{minimum:o,maximum:s}=e._zod.bag;typeof o==`number`&&(i.minItems=o),typeof s==`number`&&(i.maxItems=s),i.type=`array`,i.items=k(a.element,t,{...r,path:[...r.path,`items`]})},di=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`,i.properties={};let o=a.shape;for(let e in o)i.properties[e]=k(o[e],t,{...r,path:[...r.path,`properties`,e]});let s=new Set(Object.keys(o)),c=new Set([...s].filter(e=>{let n=a.shape[e]._zod;return t.io===`input`?n.optin===void 0:n.optout===void 0}));c.size>0&&(i.required=Array.from(c)),a.catchall?._zod.def.type===`never`?i.additionalProperties=!1:a.catchall?a.catchall&&(i.additionalProperties=k(a.catchall,t,{...r,path:[...r.path,`additionalProperties`]})):t.io===`output`&&(i.additionalProperties=!1)},fi=(e,t,n,r)=>{let i=e._zod.def,a=i.inclusive===!1,o=i.options.map((e,n)=>k(e,t,{...r,path:[...r.path,a?`oneOf`:`anyOf`,n]}));a?n.oneOf=o:n.anyOf=o},pi=(e,t,n,r)=>{let i=e._zod.def,a=k(i.left,t,{...r,path:[...r.path,`allOf`,0]}),o=k(i.right,t,{...r,path:[...r.path,`allOf`,1]}),s=e=>`allOf`in e&&Object.keys(e).length===1;n.allOf=[...s(a)?a.allOf:[a],...s(o)?o.allOf:[o]]},mi=(e,t,n,r)=>{let i=n,a=e._zod.def;i.type=`object`;let o=a.keyType,s=o._zod.bag?.patterns;if(a.mode===`loose`&&s&&s.size>0){let e=k(a.valueType,t,{...r,path:[...r.path,`patternProperties`,`*`]});i.patternProperties={};for(let t of s)i.patternProperties[t.source]=e}else(t.target===`draft-07`||t.target===`draft-2020-12`)&&(i.propertyNames=k(a.keyType,t,{...r,path:[...r.path,`propertyNames`]})),i.additionalProperties=k(a.valueType,t,{...r,path:[...r.path,`additionalProperties`]});let c=o._zod.values;if(c){let e=[...c].filter(e=>typeof e==`string`||typeof e==`number`);e.length>0&&(i.required=e)}},hi=(e,t,n,r)=>{let i=e._zod.def,a=k(i.innerType,t,r),o=t.seen.get(e);t.target===`openapi-3.0`?(o.ref=i.innerType,n.nullable=!0):n.anyOf=[a,{type:`null`}]},gi=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},_i=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.default=JSON.parse(JSON.stringify(i.defaultValue))},vi=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,t.io===`input`&&(n._prefault=JSON.parse(JSON.stringify(i.defaultValue)))},yi=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType;let o;try{o=i.catchValue(void 0)}catch{throw Error(`Dynamic catch values are not supported in JSON Schema`)}n.default=o},bi=(e,t,n,r)=>{let i=e._zod.def,a=i.in._zod.traits.has(`$ZodTransform`),o=t.io===`input`?a?i.out:i.in:i.out;k(o,t,r);let s=t.seen.get(e);s.ref=o},xi=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType,n.readOnly=!0},Si=(e,t,n,r)=>{let i=e._zod.def;k(i.innerType,t,r);let a=t.seen.get(e);a.ref=i.innerType},Ci=r(`ZodISODateTime`,(e,t)=>{Jt.init(e,t),P.init(e,t)});function wi(e){return yr(Ci,e)}var Ti=r(`ZodISODate`,(e,t)=>{Yt.init(e,t),P.init(e,t)});function Ei(e){return br(Ti,e)}var Di=r(`ZodISOTime`,(e,t)=>{Xt.init(e,t),P.init(e,t)});function Oi(e){return xr(Di,e)}var ki=r(`ZodISODuration`,(e,t)=>{Zt.init(e,t),P.init(e,t)});function Ai(e){return Sr(ki,e)}var j=r(`ZodError`,(e,t)=>{xe.init(e,t),e.name=`ZodError`,Object.defineProperties(e,{format:{value:t=>we(e,t)},flatten:{value:t=>Ce(e,t)},addIssue:{value:t=>{e.issues.push(t),e.message=JSON.stringify(e.issues,l,2)}},addIssues:{value:t=>{e.issues.push(...t),e.message=JSON.stringify(e.issues,l,2)}},isEmpty:{get(){return e.issues.length===0}}})},{Parent:Error}),ji=De(j),Mi=Oe(j),Ni=ke(j),Pi=je(j),Fi=Ne(j),Ii=Pe(j),Li=Fe(j),Ri=Ie(j),zi=Le(j),Bi=Re(j),Vi=ze(j),Hi=Be(j),Ui=new WeakMap;function Wi(e,t,n){let r=Object.getPrototypeOf(e),i=Ui.get(r);if(i||(i=new Set,Ui.set(r,i)),!i.has(t)){i.add(t);for(let e in n){let t=n[e];Object.defineProperty(r,e,{configurable:!0,enumerable:!1,get(){let n=t.bind(this);return Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:n}),n},set(t){Object.defineProperty(this,e,{configurable:!0,writable:!0,enumerable:!0,value:t})}})}}}var M=r(`ZodType`,(e,t)=>(E.init(e,t),Object.assign(e[`~standard`],{jsonSchema:{input:ti(e,`input`),output:ti(e,`output`)}}),e.toJSONSchema=ei(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(t,n)=>ji(e,t,n,{callee:e.parse}),e.safeParse=(t,n)=>Ni(e,t,n),e.parseAsync=async(t,n)=>Mi(e,t,n,{callee:e.parseAsync}),e.safeParseAsync=async(t,n)=>Pi(e,t,n),e.spa=e.safeParseAsync,e.encode=(t,n)=>Fi(e,t,n),e.decode=(t,n)=>Ii(e,t,n),e.encodeAsync=async(t,n)=>Li(e,t,n),e.decodeAsync=async(t,n)=>Ri(e,t,n),e.safeEncode=(t,n)=>zi(e,t,n),e.safeDecode=(t,n)=>Bi(e,t,n),e.safeEncodeAsync=async(t,n)=>Vi(e,t,n),e.safeDecodeAsync=async(t,n)=>Hi(e,t,n),Wi(e,`ZodType`,{check(...e){let t=this.def;return this.clone(_(t,{checks:[...t.checks??[],...e.map(e=>typeof e==`function`?{_zod:{check:e,def:{check:`custom`},onattach:[]}}:e)]}),{parent:!0})},with(...e){return this.check(...e)},clone(e,t){return x(this,e,t)},brand(){return this},register(e,t){return e.add(this,t),this},refine(e,t){return this.check(Xa(e,t))},superRefine(e,t){return this.check(Za(e,t))},overwrite(e){return this.check(O(e))},optional(){return Ma(this)},exactOptional(){return Pa(this)},nullable(){return Ia(this)},nullish(){return Ma(Ia(this))},nonoptional(e){return Ha(this,e)},array(){return L(this)},or(e){return Ca([this,e])},and(e){return Ta(this,e)},transform(e){return Ka(this,Aa(e))},default(e){return Ra(this,e)},prefault(e){return Ba(this,e)},catch(e){return Wa(this,e)},pipe(e){return Ka(this,e)},readonly(){return Ja(this)},describe(e){let t=this.clone();return Yn.add(t,{description:e}),t},meta(...e){if(e.length===0)return Yn.get(this);let t=this.clone();return Yn.add(t,e[0]),t},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(e){return e(this)}}),Object.defineProperty(e,"description",{get(){return Yn.get(e)?.description},configurable:!0}),e)),Gi=r(`_ZodString`,(e,t)=>{It.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ri(e,t,n,r);let n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Wi(e,`_ZodString`,{regex(...e){return this.check(Ir(...e))},includes(...e){return this.check(zr(...e))},startsWith(...e){return this.check(Br(...e))},endsWith(...e){return this.check(Vr(...e))},min(...e){return this.check(Pr(...e))},max(...e){return this.check(Nr(...e))},length(...e){return this.check(Fr(...e))},nonempty(...e){return this.check(Pr(1,...e))},lowercase(e){return this.check(Lr(e))},uppercase(e){return this.check(Rr(e))},trim(){return this.check(Ur())},normalize(...e){return this.check(Hr(...e))},toLowerCase(){return this.check(Wr())},toUpperCase(){return this.check(Gr())},slugify(){return this.check(Kr())}})}),Ki=r(`ZodString`,(e,t)=>{It.init(e,t),Gi.init(e,t),e.email=t=>e.check(Zn(qi,t)),e.url=t=>e.check(rr(Xi,t)),e.jwt=t=>e.check(vr(da,t)),e.emoji=t=>e.check(ir(Zi,t)),e.guid=t=>e.check(Qn(Ji,t)),e.uuid=t=>e.check($n(Yi,t)),e.uuidv4=t=>e.check(er(Yi,t)),e.uuidv6=t=>e.check(tr(Yi,t)),e.uuidv7=t=>e.check(nr(Yi,t)),e.nanoid=t=>e.check(ar(Qi,t)),e.guid=t=>e.check(Qn(Ji,t)),e.cuid=t=>e.check(or($i,t)),e.cuid2=t=>e.check(sr(ea,t)),e.ulid=t=>e.check(cr(ta,t)),e.base64=t=>e.check(hr(ca,t)),e.base64url=t=>e.check(gr(la,t)),e.xid=t=>e.check(lr(na,t)),e.ksuid=t=>e.check(ur(ra,t)),e.ipv4=t=>e.check(dr(ia,t)),e.ipv6=t=>e.check(fr(aa,t)),e.cidrv4=t=>e.check(pr(oa,t)),e.cidrv6=t=>e.check(mr(sa,t)),e.e164=t=>e.check(_r(ua,t)),e.datetime=t=>e.check(wi(t)),e.date=t=>e.check(Ei(t)),e.time=t=>e.check(Oi(t)),e.duration=t=>e.check(Ai(t))});function N(e){return Xn(Ki,e)}var P=r(`ZodStringFormat`,(e,t)=>{D.init(e,t),Gi.init(e,t)}),qi=r(`ZodEmail`,(e,t)=>{zt.init(e,t),P.init(e,t)}),Ji=r(`ZodGUID`,(e,t)=>{Lt.init(e,t),P.init(e,t)}),Yi=r(`ZodUUID`,(e,t)=>{Rt.init(e,t),P.init(e,t)}),Xi=r(`ZodURL`,(e,t)=>{Bt.init(e,t),P.init(e,t)}),Zi=r(`ZodEmoji`,(e,t)=>{Vt.init(e,t),P.init(e,t)}),Qi=r(`ZodNanoID`,(e,t)=>{Ht.init(e,t),P.init(e,t)}),$i=r(`ZodCUID`,(e,t)=>{Ut.init(e,t),P.init(e,t)}),ea=r(`ZodCUID2`,(e,t)=>{Wt.init(e,t),P.init(e,t)}),ta=r(`ZodULID`,(e,t)=>{Gt.init(e,t),P.init(e,t)}),na=r(`ZodXID`,(e,t)=>{Kt.init(e,t),P.init(e,t)}),ra=r(`ZodKSUID`,(e,t)=>{qt.init(e,t),P.init(e,t)}),ia=r(`ZodIPv4`,(e,t)=>{Qt.init(e,t),P.init(e,t)}),aa=r(`ZodIPv6`,(e,t)=>{$t.init(e,t),P.init(e,t)}),oa=r(`ZodCIDRv4`,(e,t)=>{en.init(e,t),P.init(e,t)}),sa=r(`ZodCIDRv6`,(e,t)=>{tn.init(e,t),P.init(e,t)}),ca=r(`ZodBase64`,(e,t)=>{rn.init(e,t),P.init(e,t)}),la=r(`ZodBase64URL`,(e,t)=>{on.init(e,t),P.init(e,t)}),ua=r(`ZodE164`,(e,t)=>{sn.init(e,t),P.init(e,t)}),da=r(`ZodJWT`,(e,t)=>{ln.init(e,t),P.init(e,t)}),fa=r(`ZodNumber`,(e,t)=>{un.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ii(e,t,n,r),Wi(e,`ZodNumber`,{gt(e,t){return this.check(Ar(e,t))},gte(e,t){return this.check(jr(e,t))},min(e,t){return this.check(jr(e,t))},lt(e,t){return this.check(Or(e,t))},lte(e,t){return this.check(kr(e,t))},max(e,t){return this.check(kr(e,t))},int(e){return this.check(ma(e))},safe(e){return this.check(ma(e))},positive(e){return this.check(Ar(0,e))},nonnegative(e){return this.check(jr(0,e))},negative(e){return this.check(Or(0,e))},nonpositive(e){return this.check(kr(0,e))},multipleOf(e,t){return this.check(Mr(e,t))},step(e,t){return this.check(Mr(e,t))},finite(){return this}});let n=e._zod.bag;e.minValue=Math.max(n.minimum??-1/0,n.exclusiveMinimum??-1/0)??null,e.maxValue=Math.min(n.maximum??1/0,n.exclusiveMaximum??1/0)??null,e.isInt=(n.format??``).includes(`int`)||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function F(e){return Cr(fa,e)}var pa=r(`ZodNumberFormat`,(e,t)=>{dn.init(e,t),fa.init(e,t)});function ma(e){return wr(pa,e)}var ha=r(`ZodBoolean`,(e,t)=>{fn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ai(e,t,n,r)});function I(e){return Tr(ha,e)}var ga=r(`ZodUnknown`,(e,t)=>{pn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(e,t,n)=>void 0});function _a(){return Er(ga)}var va=r(`ZodNever`,(e,t)=>{mn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>oi(e,t,n,r)});function ya(e){return Dr(va,e)}var ba=r(`ZodArray`,(e,t)=>{gn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ui(e,t,n,r),e.element=t.element,Wi(e,`ZodArray`,{min(e,t){return this.check(Pr(e,t))},nonempty(e){return this.check(Pr(1,e))},max(e,t){return this.check(Nr(e,t))},length(e,t){return this.check(Fr(e,t))},unwrap(){return this.element}})});function L(e,t){return qr(ba,e,t)}var xa=r(`ZodObject`,(e,t)=>{xn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>di(e,t,n,r),h(e,`shape`,()=>t.shape),Wi(e,`ZodObject`,{keyof(){return z(Object.keys(this._zod.def.shape))},catchall(e){return this.clone({...this._zod.def,catchall:e})},passthrough(){return this.clone({...this._zod.def,catchall:_a()})},loose(){return this.clone({...this._zod.def,catchall:_a()})},strict(){return this.clone({...this._zod.def,catchall:ya()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(e){return ue(this,e)},safeExtend(e){return de(this,e)},merge(e){return fe(this,e)},pick(e){return ce(this,e)},omit(e){return le(this,e)},partial(...e){return pe(ja,this,e[0])},required(...e){return me(Va,this,e[0])}})});function R(e,t){return new xa({type:`object`,shape:e??{},...S(t)})}var Sa=r(`ZodUnion`,(e,t)=>{Cn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>fi(e,t,n,r),e.options=t.options});function Ca(e,t){return new Sa({type:`union`,options:e,...S(t)})}var wa=r(`ZodIntersection`,(e,t)=>{wn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>pi(e,t,n,r)});function Ta(e,t){return new wa({type:`intersection`,left:e,right:t})}var Ea=r(`ZodRecord`,(e,t)=>{Dn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>mi(e,t,n,r),e.keyType=t.keyType,e.valueType=t.valueType});function Da(e,t,n){return!t||!t._zod?new Ea({type:`record`,keyType:N(),valueType:e,...S(t)}):new Ea({type:`record`,keyType:e,valueType:t,...S(n)})}var Oa=r(`ZodEnum`,(e,t)=>{On.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>si(e,t,n,r),e.enum=t.entries,e.options=Object.values(t.entries);let n=new Set(Object.keys(t.entries));e.extract=(e,r)=>{let i={};for(let r of e)if(n.has(r))i[r]=t.entries[r];else throw Error(`Key ${r} not found in enum`);return new Oa({...t,checks:[],...S(r),entries:i})},e.exclude=(e,r)=>{let i={...t.entries};for(let t of e)if(n.has(t))delete i[t];else throw Error(`Key ${t} not found in enum`);return new Oa({...t,checks:[],...S(r),entries:i})}});function z(e,t){return new Oa({type:`enum`,entries:Array.isArray(e)?Object.fromEntries(e.map(e=>[e,e])):e,...S(t)})}var ka=r(`ZodTransform`,(e,t)=>{kn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>li(e,t,n,r),e._zod.parse=(n,r)=>{if(r.direction===`backward`)throw new a(e.constructor.name);n.addIssue=r=>{if(typeof r==`string`)n.issues.push(ye(r,n.value,t));else{let t=r;t.fatal&&(t.continue=!1),t.code??=`custom`,t.input??=n.value,t.inst??=e,n.issues.push(ye(t))}};let i=t.transform(n.value,n);return i instanceof Promise?i.then(e=>(n.value=e,n.fallback=!0,n)):(n.value=i,n.fallback=!0,n)}});function Aa(e){return new ka({type:`transform`,transform:e})}var ja=r(`ZodOptional`,(e,t)=>{jn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Si(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ma(e){return new ja({type:`optional`,innerType:e})}var Na=r(`ZodExactOptional`,(e,t)=>{Mn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>Si(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Pa(e){return new Na({type:`optional`,innerType:e})}var Fa=r(`ZodNullable`,(e,t)=>{Nn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>hi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ia(e){return new Fa({type:`nullable`,innerType:e})}var La=r(`ZodDefault`,(e,t)=>{Pn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>_i(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Ra(e,t){return new La({type:`default`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}var za=r(`ZodPrefault`,(e,t)=>{In.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>vi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ba(e,t){return new za({type:`prefault`,innerType:e,get defaultValue(){return typeof t==`function`?t():ie(t)}})}var Va=r(`ZodNonOptional`,(e,t)=>{Ln.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>gi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ha(e,t){return new Va({type:`nonoptional`,innerType:e,...S(t)})}var Ua=r(`ZodCatch`,(e,t)=>{zn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>yi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Wa(e,t){return new Ua({type:`catch`,innerType:e,catchValue:typeof t==`function`?t:()=>t})}var Ga=r(`ZodPipe`,(e,t)=>{Bn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>bi(e,t,n,r),e.in=t.in,e.out=t.out});function Ka(e,t){return new Ga({type:`pipe`,in:e,out:t})}var qa=r(`ZodReadonly`,(e,t)=>{Hn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>xi(e,t,n,r),e.unwrap=()=>e._zod.def.innerType});function Ja(e){return new qa({type:`readonly`,innerType:e})}var Ya=r(`ZodCustom`,(e,t)=>{Wn.init(e,t),M.init(e,t),e._zod.processJSONSchema=(t,n,r)=>ci(e,t,n,r)});function Xa(e,t={}){return Jr(Ya,e,t)}function Za(e,t){return Yr(e,t)}function B(e){return Object.freeze(e)}var V=class extends Error{code;constructor(e,t=`ACTION_FAILED`){super(e),this.code=t,this.name=`ActionError`}},Qa=`browsentic/bridge`,$a=e=>({ok:!0,data:e}),eo=(e,t)=>({ok:!1,error:{code:e,message:t}});function to(e){return no(e,`browsentic/action`)&&typeof e.action==`string`}function no(e,t){return typeof e==`object`&&!!e&&e.channel===t}var ro={r:0,g:0,b:0,a:0},io={r:255,g:255,b:255,a:1},ao={r:18,g:18,b:18,a:1},oo=/^#(?:[0-9a-f]{3,4}|[0-9a-f]{6}|[0-9a-f]{8})$/i,so=/^rgba?\(([^)]+)\)$/i,co=/-?\d*\.?\d+(?:e-?\d+)?%?/gi,lo=new Map;function H(e){let t=e?.trim();return t?(lo.has(t)||lo.set(t,uo(t)),lo.get(t)??null):null}function uo(e){return e===`transparent`?ro:fo(e)??po(e)??go(e)}function fo(e){if(!oo.test(e))return null;let t=e.slice(1),n=t.length>4,r=n?2:1,i=e=>{let i=t.slice(e*r,e*r+r);return parseInt(n?i:i+i,16)},a=t.length===4||t.length===8?i(3)/255:1;return{r:i(0),g:i(1),b:i(2),a}}function po(e){let t=(so.exec(e)?.[1])?.match(co);if(!t||t.length<3)return null;let n=(e,t)=>e.endsWith(`%`)?parseFloat(e)/100*t:parseFloat(e);return{r:ko(n(t[0],255)),g:ko(n(t[1],255)),b:ko(n(t[2],255)),a:t[3]===void 0?1:Oo(n(t[3],1))}}var mo;function ho(){return mo??=document.createElement(`canvas`).getContext(`2d`,{willReadFrequently:!0}),mo}function go(e){let t=ho();if(!t)return null;t.fillStyle=`#000000`,t.fillStyle=e;let n=t.fillStyle;return t.fillStyle=`#ffffff`,t.fillStyle=e,n===t.fillStyle?fo(t.fillStyle)??po(t.fillStyle)??_o(t,e):null}function _o(e,t){e.clearRect(0,0,1,1),e.fillStyle=t,e.fillRect(0,0,1,1);let[n,r,i,a]=e.getImageData(0,0,1,1).data;return{r:n,g:r,b:i,a:a/255}}function U({r:e,g:t,b:n,a:r}){let i=e=>ko(e).toString(16).padStart(2,`0`),a=r>=1?``:i(Math.round(r*255));return`#${i(e)}${i(t)}${i(n)}${a}`}function vo({r:e,g:t,b:n,a:r}){return{r:255-e,g:255-t,b:255-n,a:r}}function W({r:e,g:t,b:n}){return .2126*yo(e)+.7152*yo(t)+.0722*yo(n)}function yo(e){let t=ko(e)/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4}function bo(e,t){let n=W(e),r=W(t),i=Math.max(n,r),a=Math.min(n,r);return(i+.05)/(a+.05)}function xo(e,t){let n=e.a+t.a*(1-e.a);if(n===0)return ro;let r=(r,i)=>Math.round((r*e.a+i*t.a*(1-e.a))/n);return{r:r(e.r,t.r),g:r(e.g,t.g),b:r(e.b,t.b),a:n}}function So(){let e=getComputedStyle(document.documentElement).colorScheme||`normal`;return e.includes(`dark`)?e.includes(`light`)?matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`:`dark`:`light`}function Co(){return So()===`dark`?ao:io}function wo(e){let t=ro;for(let n=e;n;n=n.parentElement){let e=H(getComputedStyle(n).backgroundColor);if(!(!e||e.a===0)&&(t=xo(t,e),t.a>=1))return t}return xo(t,Co())}function To(e,t){let n=H(getComputedStyle(e).color)??ro;return n.a>=1?n:xo(n,t)}function Eo(e,t){return e>=24||e>=18.66&&t>=700}function Do(e,t){return t===`AAA`?e?4.5:7:e?3:4.5}function G(e,t){let n=10**t;return Math.round(e*n)/n}function Oo(e){return Math.min(1,Math.max(0,e))}function ko(e){return Math.min(255,Math.max(0,Math.round(e)))}var Ao=[[-.574,1.43,.144],[.426,.43,.144],[.426,1.43,-.856]];function jo(e,t){let n=[e.r,e.g,e.b];t.invert&&(n=Mo(n.map(e=>255-e),Ao)),n=n.map(e=>e*t.brightness),t.saturate!==void 0&&(n=Mo(n,Po(t.saturate))),t.contrast!==void 0&&(n=n.map(e=>(e-127.5)*t.contrast+127.5));let[r,i,a]=n.map(ko);return{r,g:i,b:a,a:e.a}}function Mo(e,t){return t.map(t=>t[0]*e[0]+t[1]*e[1]+t[2]*e[2])}function No(e,t,n=.05,r=4){let i=n,a=r;for(let n=0;n<24;n+=1){let n=(i+a)/2;W(jo(e,{invert:!1,brightness:n}))<t?i=n:a=n}return G((i+a)/2,3)}function Po(e){return[[.213+.787*e,.715-.715*e,.072-.072*e],[.213-.213*e,.715+.285*e,.072-.072*e],[.213-.213*e,.715-.715*e,.072+.928*e]]}var Fo=`browsentic-theme`,Io=`data-browsentic-added-class`,Lo=`data-browsentic-hook-attribute`,Ro=`data-browsentic-hook-host`,zo=`data-browsentic-filter`,Bo=`data-browsentic-previous-value`,Vo=/\.((?:theme-|mode-)?(dark|light)(?:-mode|-theme)?)(?![\w-])/i,Ho=/\[([\w-]*(?:theme|mode|scheme))\s*[~|^$*]?=\s*["']?(dark|light)["']?\s*[is]?\]/i;function Uo(e){let t=[...document.styleSheets,...document.adoptedStyleSheets],n=new Set,r=new Map,i={total:t.length,readable:0,crossOrigin:0,inline:0},a=0,o=t=>{if(!(a>=e)){if(a+=1,t instanceof CSSStyleRule){for(let e of t.style)e.startsWith(`--`)&&n.add(e);Go(t.selectorText,r);return}if(t instanceof CSSGroupingRule)for(let e of t.cssRules)o(e);if(t instanceof CSSImportRule)for(let e of Wo(t.styleSheet)??[])o(e)}};for(let e of t){e.href||(i.inline+=1);let t=Wo(e);if(!t){i.crossOrigin+=1;continue}i.readable+=1;for(let e of t)o(e)}return{sheets:i,rules:a,properties:[...n],hooks:[...r.values()],truncated:a>=e}}function Wo(e){try{return e?.cssRules??null}catch{return null}}function Go(e,t){for(let n of e.split(`,`)){let e=n.trim(),r=e.split(/[\s>+~]+/)[0],i=/^body\b/i.test(r)?`body`:`root`,a=Ho.exec(r);if(a){let[,n,r]=a;Ko(t,{kind:`attribute`,name:n.toLowerCase(),value:r.toLowerCase(),scheme:r.toLowerCase(),host:i,selector:e});continue}let o=Vo.exec(r);if(o){let[,n,r]=o;Ko(t,{kind:`class`,name:n,scheme:r.toLowerCase(),host:i,selector:e})}}}function Ko(e,t){e.set(`${t.kind}:${t.host}:${t.name}:${t.value??``}`,t)}function qo(e,t){let n=getComputedStyle(document.documentElement),r=e.map(e=>({name:e,value:n.getPropertyValue(e).trim().slice(0,120)})).filter(({value:e})=>e!==``).sort((e,t)=>e.name<t.name?-1:1);return{total:r.length,listed:r.slice(0,t).map(Jo)}}function Jo({name:e,value:t}){let n=H(t);return!n||n.a===0?{name:e,value:t}:{name:e,value:t,color:U(n),luminance:G(W(n),3)}}function Yo(){let e=document.getElementById(Fo)?.getAttribute(zo);if(e)try{return JSON.parse(e)}catch{return}}function Xo(){let e=Yo();return e?t=>jo(t,e):e=>e}function Zo(e,t){e.setAttribute(zo,JSON.stringify(t))}function Qo(){let e=document.body??document.documentElement,t=Xo(),n=wo(e),r=t(n),i=t(To(e,n));return{colorScheme:So(),background:U(r),text:U(i),luminance:G(W(r),4),contrast:G(bo(i,r),2),...Yo()?{filtered:!0}:{}}}function $o(e){return e===`body`?document.body??document.documentElement:document.documentElement}function es(){let e=document.getElementById(Fo);if(!e)return!1;let t=$o(e.getAttribute(Ro)===`body`?`body`:`root`),n=e.getAttribute(Io);n&&t.classList.remove(n);let r=e.getAttribute(Lo);if(r){let n=e.getAttribute(Bo);n===null?t.removeAttribute(r):t.setAttribute(r,n)}return e.remove(),!0}function ts(e,t){let n=document.createElement(`style`);return n.id=Fo,n.textContent=e,t&&ns(n,t),document.documentElement.append(n),n}function ns(e,t){let n=$o(t.host);if(e.setAttribute(Ro,t.host),t.kind===`class`){if(n.classList.contains(t.name))return;n.classList.add(t.name),e.setAttribute(Io,t.name);return}let r=n.getAttribute(t.name);e.setAttribute(Lo,t.name),r!==null&&e.setAttribute(Bo,r),n.setAttribute(t.name,t.value??``)}var rs=2e4,is=40,as=/^--[A-Za-z0-9_-]+$/,os=/[;{}<>\\]|@import|url\(|expression\(/i,ss=.05,cs=.92,ls=.08,us=`img, picture, video, canvas, svg, iframe, embed, object`,ds=`invert(1) hue-rotate(180deg)`,fs=B({name:`page.applyTheme`,description:`Retheme the page, or put it back. Prefers the page’s own terms — it switches on the dark/light hook its stylesheets already define (a ".dark" class, a [data-theme] attribute), sets color-scheme, and overrides the design tokens you name. Only when that leaves the page at the wrong luminance does it fall back to repainting through a CSS filter. Reports the measured background luminance and text contrast before and after, so the change can be checked rather than assumed. The filter fallback creates a containing block on <html>, which re-anchors position:fixed elements, and it re-inverts images so photos stay right way round. Nothing here survives a reload — call it again, or with mode "revert", to undo it.`,input:R({mode:z([`keep`,`dark`,`light`,`revert`]).default(`keep`).describe(`Which way to push the page: "dark" or "light" retheme it, "revert" removes everything Browsentic applied and restores the page’s own theme, "keep" leaves the light/dark decision alone and applies only the colours below`),targetLuminance:F().min(0).max(1).optional().describe(`Relative luminance to bring the page background to, 0 black to 1 white, as reported by page.readTheme. Overrides the luminance "dark" and "light" imply. Reached by filtering, so it repaints images and text alike`),background:N().optional().describe(`CSS colour for the page background, e.g. "#0f172a" or "rgb(15 23 42)"; suppresses the luminance a mode would imply`),text:N().optional().describe(`CSS colour for body text; elements that set their own colour keep it`),accent:N().optional().describe(`CSS colour for links and form-control accents`),tokens:Da(N(),N()).optional().describe(`CSS custom properties to override on :root, e.g. {"--background": "#0f172a"}. Names come from page.readTheme’s tokens — this is the cleanest way to retheme a page that is built on design tokens, because its own rules do the work`),saturation:F().min(0).max(3).optional().describe(`Colour intensity multiplier: 0 greyscale, 1 unchanged, above 1 more vivid`),contrast:F().min(0).max(3).optional().describe(`Contrast multiplier: 1 unchanged, above 1 pushes lights and darks apart`),transitionMs:F().int().nonnegative().max(2e3).default(200).describe(`How long the page takes to cross-fade into the new theme; 0 switches instantly`)}),execute({mode:e,targetLuminance:t,background:n,text:r,accent:i,tokens:a,saturation:o,contrast:s,transitionMs:c}){let l={background:ps(n,`background`),text:ps(r,`text`),accent:ps(i,`accent`)},u=ms(a);if(e===`keep`&&t===void 0&&!(o!==void 0||s!==void 0)&&!u.length&&!Object.values(l).some(Boolean))throw new V(`Nothing to apply — pass a "mode", a "targetLuminance", a colour, or "tokens".`,`INVALID_INPUT`);let d=es(),f=Qo();if(e===`revert`)return{reverted:d,theme:f};let p=e===`dark`||e===`light`?hs(e):void 0,m=ts(_s({mode:e,colors:l,overrides:u,transitionMs:c}),p),h=Qo(),g=t??(l.background?void 0:vs(e,h.luminance)),_=ys(g,h.background,o,s);_&&(m.textContent+=`\n${xs(_,h.background,c)}`,Zo(m,_));let v=Qo();return{replaced:d,strategy:_?`filter`:p||e!==`keep`?`stylesheet`:`colors`,applied:{mode:e,hook:p,...l,tokens:u.length?u.map(([e])=>e):void 0,filter:_?bs(_).join(` `):void 0,targetLuminance:g},css:(m.textContent??``).slice(0,4e3),before:f,after:v,...g===void 0?{}:{reachedTarget:Math.abs(v.luminance-g)<=ls}}}});function ps(e,t){if(e===void 0)return;let n=H(e);if(!n)throw new V(`"${t}" is not a colour this browser understands — pass something like "#0f172a", "rgb(15 23 42)" or "midnightblue".`,`INVALID_INPUT`);return U(n)}function ms(e){let t=Object.entries(e??{});if(t.length>is)throw new V(`Too many tokens — ${t.length} given and ${is} is the limit. Override only the ones that carry the theme.`,`INVALID_INPUT`);return t.map(([e,t])=>{if(!as.test(e))throw new V(`"${e}" is not a custom property — names look like "--brand-500".`,`INVALID_INPUT`);let n=t.trim();if(!n||os.test(n))throw new V(`The value for "${e}" is not a plain CSS value — it cannot be empty or carry ";", "{", "}", "\\" or "url(".`,`INVALID_INPUT`);return[e,n]})}function hs(e){return Uo(rs).hooks.filter(t=>t.scheme===e).sort((e,t)=>gs(e)-gs(t))[0]}function gs(e){return e.kind===`attribute`?e.name===`data-theme`?0:1:e.name.toLowerCase()===e.scheme?2:3}function _s({mode:e,colors:t,overrides:n,transitionMs:r}){let i=[];return e!==`keep`&&i.push(`:root { color-scheme: ${e}; }`),n.length&&i.push(`:root { ${n.map(([e,t])=>`${e}: ${t};`).join(` `)} }`),t.background&&i.push(`html, body { background-color: ${t.background} !important; }`),t.text&&i.push(`html, body { color: ${t.text} !important; }`),t.accent&&i.push(`:root { accent-color: ${t.accent} !important; }`,`a { color: ${t.accent} !important; }`),r>0&&i.push(`html, body { transition: background-color ${r}ms linear, color ${r}ms linear, filter ${r}ms linear; }`),i.join(`
66
66
  `)}function vs(e,t){if(e===`dark`)return t>.5?ss:void 0;if(e===`light`)return t<.5?cs:void 0}function ys(e,t,n,r){let i=H(t)??io,a=W(i),o=e!==void 0&&e<.5!=a<.5,s=o?W(vo(i)):a,c=e===void 0||s<=.004?1:No(o?vo(i):i,e);if(!(!o&&c===1&&n===void 0&&r===void 0))return{invert:o,brightness:c,saturate:n,contrast:r}}function bs({invert:e,brightness:t,saturate:n,contrast:r}){return[e?ds:``,t===1?``:`brightness(${t})`,n===void 0?``:`saturate(${n})`,r===void 0?``:`contrast(${r})`].filter(Boolean)}function xs(e,t,n){let r=[`html { background-color: ${t}; filter: ${bs(e).join(` `)}; }`];return e.invert&&r.push(`${us} { filter: ${ds}; }`),n>0&&r.push(`${us} { transition: filter ${n}ms linear; }`),r.join(`
67
- `)}var K=R({selector:P().optional().describe(`CSS selector for the element`),text:P().optional().describe(`Case-insensitive visible text the element should contain`),role:P().optional().describe(`Tag name or ARIA role to narrow matches, e.g. "button" or "link"`),nth:I().int().nonnegative().default(0).describe(`Zero-based index when several elements match`)}),Ss=`a,button,input,select,textarea,summary,label,h1,h2,h3,h4,h5,h6,[role],[tabindex],[contenteditable]`,Cs={link:[`a`],button:[`button`],textbox:[`input`,`textarea`],combobox:[`select`],checkbox:[`input`],radio:[`input`],heading:[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`]},ws={button:`button`,submit:`button`,reset:`button`,image:`button`,file:`button`,checkbox:`checkbox`,radio:`radio`,range:`slider`,number:`spinbutton`,search:`searchbox`},Ts={button:`button`,select:`combobox`,textarea:`textbox`,summary:`button`,option:`option`,h1:`heading`,h2:`heading`,h3:`heading`,h4:`heading`,h5:`heading`,h6:`heading`,nav:`navigation`,main:`main`,header:`banner`,footer:`contentinfo`,aside:`complementary`,form:`form`,dialog:`dialog`},Es=new Set([`button`,`submit`,`reset`,`image`,`checkbox`,`radio`,`file`]);function Ds(e){let t=e.getAttribute(`role`)?.trim().split(/\s+/)[0];return t?t.toLowerCase():e instanceof HTMLInputElement?ws[e.type]??`textbox`:e instanceof HTMLAnchorElement?e.getAttribute(`href`)===null?void 0:`link`:Ts[e.tagName.toLowerCase()]}function Os(e,t){let n=t.toLowerCase(),r=e.tagName.toLowerCase();return r===n||Ds(e)===n?!0:Cs[n]?.includes(r)??!1}function q(e,t={}){let{selector:n,text:r,role:i,nth:a}=e;if(!n&&!r)throw new V(`A target needs a "selector" or "text"`,`INVALID_TARGET`);let o=[...document.querySelectorAll(n??Ss)];if(i&&(o=o.filter(e=>Os(e,i))),r){let e=r.toLowerCase();o=o.filter(t=>J(t).toLowerCase().includes(e)),o=o.filter(e=>!o.some(t=>t!==e&&e.contains(t)))}t.includeHidden||(o=o.filter(Y));let s=o[a];if(!s)throw new V(`No element matches ${JSON.stringify(e)} (${o.length} candidates)`,`TARGET_NOT_FOUND`);return s}function J(e){let t=e.getAttribute(`aria-label`)?.trim();if(t)return t;if(e instanceof HTMLInputElement)return e.type===`submit`||e.type===`button`||e.type===`reset`?e.value.trim()||e.type:ks(e);if(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)return ks(e);if(e instanceof HTMLImageElement)return e.alt.trim();let n=(e.textContent??``).replace(/\s+/g,` `).trim();if(n)return n;let r=e.querySelector(`img[alt]`);return r instanceof HTMLImageElement?r.alt.trim():``}function ks(e){return e.labels?.[0]?.textContent?.trim()||e.getAttribute(`placeholder`)?.trim()||e.name}function Y(e){let t=e.getBoundingClientRect();if(t.width===0&&t.height===0)return!1;let n=getComputedStyle(e);return n.visibility!==`hidden`&&n.display!==`none`}function As(e){return Y(e)&&!e.closest(`[aria-hidden="true"],[inert]`)}function js(e,t){let n=e.getAttribute(t);return n===`true`||n!==`false`&&void 0}function Ms(e){let t={};(e.matches(`:disabled`)||js(e,`aria-disabled`))&&(t.disabled=!0);let n=e instanceof HTMLInputElement&&(e.type===`checkbox`||e.type===`radio`)?e.checked:js(e,`aria-checked`);n!==void 0&&(t.checked=n);let r=js(e,`aria-expanded`);r!==void 0&&(t.expanded=r);let i=e instanceof HTMLOptionElement?e.selected:js(e,`aria-selected`);i!==void 0&&(t.selected=i);let a=e.getAttribute(`aria-current`);return a&&a!==`false`&&(t.current=a),(e.matches(`:required`)||js(e,`aria-required`))&&(t.required=!0),js(e,`aria-invalid`)&&(t.invalid=!0),e instanceof HTMLSelectElement?t.value=e.selectedOptions[0]?.text.replace(/\s+/g,` `).trim().slice(0,60)||void 0:(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!Es.has(e.type))&&(t.filled=e.value.length>0),Object.values(t).some(e=>e!==void 0)?t:void 0}function X(e){let t=[];for(let n=e;n&&n!==document.documentElement;n=n.parentElement){if(n.id)return t.unshift(`#${CSS.escape(n.id)}`),t.join(` > `);let e=n.tagName.toLowerCase(),r=n.parentElement?[...n.parentElement.children].filter(e=>e.tagName===n.tagName):[];t.unshift(r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e)}return t.join(` > `)}function Ns(e){let t=e.getBoundingClientRect();return{x:Math.round(t.x+window.scrollX),y:Math.round(t.y+window.scrollY),width:Math.round(t.width),height:Math.round(t.height)}}function Z(e){let t=J(e).slice(0,80);return{tag:e.tagName.toLowerCase(),role:Ds(e),selector:X(e),text:t||void 0,state:Ms(e),bounds:Ns(e)}}function Ps(e){return e.closest(`form`)?e instanceof HTMLButtonElement?e.type===`submit`:e instanceof HTMLInputElement&&(e.type===`submit`||e.type===`image`):!1}var Fs=B({name:`page.attachFile`,description:`Attach a file to a file input on the page: either one the user stored in Browsentic (fileId, from page.listFiles) or one you captured off another page (downloadId, from page.captureDownload). The second closes the loop — download here, upload there — without the bytes ever passing through you.`,input:R({fileId:P().optional().describe(`Id of a stored file, taken from page.listFiles.`),downloadId:P().optional().describe(`Id of a captured download, taken from page.captureDownload or page.listDownloads.`),target:K.describe(`The file input (<input type="file">) to attach the file to.`),name:P().optional().describe(`Internal: original filename. Browsentic fills this in.`),mime:P().optional().describe(`Internal: file MIME type. Browsentic fills this in.`),content:P().optional().describe(`Internal: base64 file bytes. Browsentic fills this in.`)}),execute({target:e,name:t,mime:n,content:r}){if(!r)throw new V(`No file bytes were supplied — call with a valid fileId or downloadId.`,`INVALID_INPUT`);let i=q(e,{includeHidden:!0});if(!(i instanceof HTMLInputElement)||i.type!==`file`)throw new V(`<${i.tagName.toLowerCase()}> is not a file input`,`INVALID_TARGET`);let a=atob(r),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let s=new File([o],t||`file`,{type:n||`application/octet-stream`}),c=new DataTransfer;return c.items.add(s),Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`files`).set.call(i,c.files),i.dispatchEvent(new Event(`input`,{bubbles:!0})),i.dispatchEvent(new Event(`change`,{bubbles:!0})),{attached:!0,name:s.name,size:o.length,mime:s.type,element:Z(i)}}}),Is=60,Ls=B({name:`page.auditContrast`,description:`Score the readability of the page against WCAG contrast rules. Walks the visible text, resolves each run’s foreground against the real background painted behind it — blending translucent layers up the ancestor chain — and reports the ratio, the ratio the level requires, and whether it passes. The score is the share of sampled text runs that pass, so it is directly comparable before and after page.applyTheme.`,input:R({target:K.optional().describe(`Subtree to audit; defaults to the whole page`),level:z([`AA`,`AAA`]).default(`AA`).describe(`WCAG level: AA needs 4.5:1 for body text and 3:1 for large text, AAA needs 7:1 and 4.5:1`),maxSamples:I().int().positive().max(2e3).default(400).describe(`Text-bearing elements to check, in document order`),maxFailures:I().int().nonnegative().max(200).default(20).describe(`Failures listed, worst ratio first; the counts always cover everything sampled`)}),execute({target:e,level:t,maxSamples:n,maxFailures:r}){let i=e?q(e):document.body??document.documentElement,a=Rs(i,t,n,Xo()),o=a.filter(e=>!e.passes).sort((e,t)=>e.ratio-t.ratio),s=a.length-o.length;return{url:location.href,level:t,required:{normalText:Do(!1,t),largeText:Do(!0,t)},...a.length?{score:Math.round(s/a.length*100)}:{},summary:{sampled:a.length,passed:s,failed:o.length,worstRatio:a.length?Math.min(...a.map(e=>e.ratio)):void 0},failures:o.slice(0,r),source:X(i)}}});function Rs(e,t,n,r){let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),a=new Set,o=[];for(let e=i.nextNode();e&&o.length<n;e=i.nextNode()){let n=(e.textContent??``).replace(/\s+/g,` `).trim(),i=e.parentElement;!n||!i||a.has(i)||(a.add(i),As(i)&&o.push(zs(i,n,t,r)))}return o}function zs(e,t,n,r){let i=getComputedStyle(e),a=wo(e),o=r(a),s=r(To(e,a)),c=G(parseFloat(i.fontSize),1),l=Number(i.fontWeight)||400,u=Eo(c,l),d=G(bo(s,o),2),f=Do(u,n);return{selector:X(e),text:t.slice(0,Is),foreground:U(s),background:U(o),ratio:d,required:f,passes:d>=f,fontSizePx:c,weight:l,large:u,bounds:Ns(e)}}var Bs=30*6e4,Vs=240*6e4,Hs=2*6e4,Us=10*6e4,Ws=5e3,Gs=3e4,Ks=B({name:`page.awaitMonitor`,description:`Block until a background monitor completes, then return its final state with the full log. A reply with settled: false means the timeout passed while the watch continues — call again to keep waiting; that is normal, not an error. If the call fails with EXTENSION_OFFLINE the monitor is still running in the browser — reconnect and call again.`,input:R({monitorId:P().describe(`The monitor to wait on, from page.startMonitor`),timeoutMs:I().int().positive().max(Us).default(Hs).describe(`Return after this long even if unfinished — the reply then has settled: false and the current state, so call again to keep waiting`)}),execute(){throw new V(`page.awaitMonitor is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),qs=B({name:`page.callSiteTool`,description:`Call one of the tools this site offers through WebMCP (document.modelContext), with arguments matching the schema page.listSiteTools reported. The site’s own code handles the call, which makes it the reliable path wherever a listed tool covers the step — no selectors to break, no intermediate states to wait through. The return value is whatever the site’s tool produced, as JSON. Treat a call like a form submit: the site decides what it does, and that can include acting on the user’s account, so it passes the same approval gate.`,input:R({tool:P().min(1).describe(`Name of a tool exactly as page.listSiteTools reported it.`),args:Da(P(),ga()).default({}).describe(`Arguments for the tool, matching its input schema. JSON values only.`),timeoutMs:I().int().min(100).max(12e4).default(15e3).describe(`How long the tool may run before the call is abandoned. Raise it for tools that wait on the site’s backend.`)}),execute(){throw new V(`page.callSiteTool is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Js=B({name:`page.captureDownload`,description:`Make the page download a file and keep it. Either click something that produces a download — an “Export CSV” button, a “Download invoice” link — or give a direct url, which is fetched in the browser’s own logged-in session rather than anonymously. The file lands in the user’s ~/browsentic/download/ folder and the result reports the path and notes about what arrived; you get the notes, never the bytes. Hand the returned downloadId to page.attachFile to upload it somewhere else without the file ever passing through you.`,input:R({target:K.optional().describe(`The link or button whose click starts the download. Give this or "url", not both.`),url:P().optional().describe(`Direct http(s) url of the file, fetched with the browser’s cookies. Give this or "target", not both. Prefer "target" when a button exists: many exports have no fetchable url at all.`),timeoutMs:I().int().min(1e3).max(6e5).default(6e4).describe(`How long to wait for the download to finish before giving up.`)}),execute(){throw new V(`page.captureDownload is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Ys=B({name:`page.clickElement`,description:`Click an element like a user would, firing the full pointer and mouse event sequence.`,input:R({target:K.describe(`Element to click`),scrollIntoView:L().default(!0).describe(`Bring the element into view before clicking`)}),execute({target:e,scrollIntoView:t}){let n=q(e);t&&n.scrollIntoView({block:`center`,behavior:`instant`});try{n.focus({preventScroll:!0})}catch{}let r=Ps(n),i={bubbles:!0,cancelable:!0,composed:!0};return n.dispatchEvent(new PointerEvent(`pointerdown`,i)),n.dispatchEvent(new MouseEvent(`mousedown`,i)),n.dispatchEvent(new PointerEvent(`pointerup`,i)),n.dispatchEvent(new MouseEvent(`mouseup`,i)),n.click(),{...Z(n),submits:r}}}),Xs=B({name:`page.closeTab`,description:`Close an open tab. With no arguments it closes the tab page actions are currently targeting, and later actions follow the browser to whichever tab it brings to the front.`,input:R({tabId:I().int().optional().describe(`Id of the tab to close, as reported by page.openTab or a no-argument page.switchTab.`),match:P().optional().describe(`Instead of an id, close the tab whose title or URL contains this text (case-insensitive). If several tabs match, nothing is closed and the candidates are listed.`)}),execute(){throw new V(`page.closeTab is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Zs=120,Qs=6,$s=R({x:I().describe(`Pixels from the left edge of the viewport`),y:I().describe(`Pixels from the top edge of the viewport`)});function ec(){return{w:document.documentElement.clientWidth,h:document.documentElement.clientHeight}}function tc(e){let t=e.getBoundingClientRect(),{w:n,h:r}=ec(),i=Math.max(t.left,0),a=Math.max(t.top,0),o=Math.min(t.right,n),s=Math.min(t.bottom,r);if(o<=i||s<=a)throw new V(`The element has no visible area inside the viewport — scroll it into view, then retry`,`INVALID_TARGET`);return{x:Math.round((i+o)/2),y:Math.round((a+s)/2)}}function nc(e){let{w:t,h:n}=ec();if(e.x<0||e.y<0||e.x>=t||e.y>=n)throw new V(`The point (${e.x}, ${e.y}) is outside the ${t}×${n} viewport — scroll it into view, then retry`,`INVALID_TARGET`);return{x:Math.round(e.x),y:Math.round(e.y)}}function rc(e){let{w:t,h:n}=ec();return{x:Math.min(Math.max(e.x-Zs,0),t-1),y:Math.min(Math.max(e.y-Zs,0),n-1)}}function Q(e){return document.elementFromPoint(e.x,e.y)}function ic(e,t){let n=Q(t);if(!(n===e||e.contains(n)))throw new V(n?`${X(n)} covers (${t.x}, ${t.y}) — dismiss whatever is over the element, then retry`:`Nothing is painted at (${t.x}, ${t.y}) — scroll the element into view, then retry`,`INVALID_TARGET`)}var ac=e=>1-(1-e)**3;function oc(e,t,n){let r=t.x-e.x,i=t.y-e.y,a=Math.hypot(r,i)||1,o=Math.min(Qs,a/8);return Array.from({length:n},(t,s)=>{let c=ac((s+1)/n),l=Math.sin(c*Math.PI)*o*(s%2?-1:1);return{x:Math.round(e.x+r*c-i/a*l),y:Math.round(e.y+i*c+r/a*l)}})}var sc=[[`pointer`,`pointerover`,!0],[`pointer`,`pointerenter`,!1],[`pointer`,`pointermove`,!0],[`mouse`,`mouseover`,!0],[`mouse`,`mouseenter`,!1],[`mouse`,`mousemove`,!0]];function cc(e,t){for(let[n,r,i]of sc){let a=n===`pointer`?PointerEvent:MouseEvent;e.dispatchEvent(new a(r,{clientX:t.x,clientY:t.y,bubbles:i,composed:!0}))}}var lc=16,uc=e=>new Promise(t=>setTimeout(t,e));function dc(e,t){return{clientX:e.x,clientY:e.y,button:0,buttons:t,bubbles:!0,cancelable:!0,composed:!0,view:window,pointerId:1,pointerType:`mouse`,isPrimary:!0}}function fc(e,t,n,r,i){let a=dc(r,i);e?.dispatchEvent(new PointerEvent(t,a)),e?.dispatchEvent(new MouseEvent(n,a))}function pc(e,t,n,r){return e?.dispatchEvent(new DragEvent(t,{...dc(n,1),dataTransfer:r}))??!1}function mc(e){try{return tc(e)}catch{throw new V(`The drop target is not inside the viewport — both ends of a drag have to be on screen at once, because nothing scrolls mid-drag. Scroll until both are visible, then retry`,`INVALID_TARGET`)}}async function hc(e,t,n,r,i){for(let a of oc(e,t,n))await uc(lc),i?i(a):fc(Q(a),`pointermove`,`mousemove`,a,r)}async function gc(e,t,n){await hc(e,t,4,0),cc(n??document.body,t)}async function _c(e,t){let{approach:n,grip:r,drop:i,steps:a,holdMs:o,settleMs:s}=t,c=e??Q(r);await gc(n,r,c),fc(c,`pointerdown`,`mousedown`,r,1),await uc(o),await hc(r,i,a,1),await uc(s);let l=Q(i);return fc(l??c,`pointerup`,`mouseup`,i,0),{landedOn:l?X(l):void 0}}async function vc(e,t){let{approach:n,grip:r,drop:i,steps:a,holdMs:o,settleMs:s}=t,c=new DataTransfer;await gc(n,r,e),fc(e,`pointerdown`,`mousedown`,r,1),await uc(o);let l=pc(e,`dragstart`,r,c),u=!1,d=null;await hc(r,i,a,1,e=>{let t=Q(e);t!==d&&(pc(d,`dragleave`,e,c),pc(t,`dragenter`,e,c),d=t),t&&!pc(t,`dragover`,e,c)&&(u=!0)}),await uc(s);let f=Q(i);return pc(f,`drop`,i,c),pc(e,`dragend`,i,c),{landedOn:f?X(f):void 0,started:l,accepted:u}}var yc=B({name:`page.dragElement`,description:`Drag one thing onto another — reorder a list, move a card between columns, pull a slider handle, draw on a canvas. Give a "from" element (or "fromPoint") to pick up and a "to" element (or "toPoint") to drop on. Both ends must be on screen at the same moment, because nothing auto-scrolls mid-drag. The web has two unrelated drag mechanisms and "auto" chooses between them by reading the grabbed element: "pointer" presses, moves and releases a pointer, which is what dnd-kit, react-beautiful-dnd, sliders and canvases listen for; "native" fires the HTML5 dragstart/dragover/drop sequence with a DataTransfer, which is what an element carrying draggable="true" expects. The drop point is measured before the drag starts, so a list that reflows as you pass over it can land a slot out — raise "steps" and "settleMs", then read the result back. Set "trusted" when the page ignores synthetic events; that path is pointer-only, Chrome-only, and shows the “Browsentic is debugging this browser” bar. If nothing moved, check "accepted" and try the other mode.`,input:R({from:K.optional().describe(`Element to pick up — the card, row, or drag handle. Give this or "fromPoint", never both.`),fromPoint:$s.optional().describe(`Viewport coordinates to grab from, in CSS pixels. Use it when the grip is not an element, such as a spot on a <canvas>.`),to:K.optional().describe(`Element to drop onto — the destination column, list slot, or drop zone. Give this or "toPoint", never both.`),toPoint:$s.optional().describe(`Viewport coordinates to drop at, in CSS pixels. Use it to reach empty space, a slider position, or a spot on a <canvas>.`),mode:z([`auto`,`pointer`,`native`]).default(`auto`).describe(`Which drag mechanism to use. "auto" picks "native" when the grabbed element declares draggable="true", "pointer" otherwise.`),steps:I().int().min(2).max(60).default(16).describe(`Moves dispatched along the way to the drop point. Raise it for lists that reorder as the pointer passes over them.`),holdMs:I().int().min(0).max(5e3).default(120).describe(`How long the button stays down before the drag starts moving. Raise it past a library’s press-and-hold delay.`),settleMs:I().int().min(0).max(5e3).default(120).describe(`Pause on the drop point before releasing, letting the page settle on where the item would land.`),trusted:L().default(!1).describe(`Dispatch real browser-level mouse events, so isTrusted is true. Pointer mode only, Chrome only.`),scrollIntoView:L().default(!0).describe(`Bring the grabbed element into view first. Ignored with "fromPoint".`)}),async execute({from:e,fromPoint:t,to:n,toPoint:r,mode:i,steps:a,holdMs:o,settleMs:s,trusted:c,scrollIntoView:l}){if(!e==!t)throw new V(`Give either a "from" target to pick up or a "fromPoint" to grab at — not both, not neither`,`INVALID_INPUT`);if(!n==!r)throw new V(`Give either a "to" target to drop onto or a "toPoint" to drop at — not both, not neither`,`INVALID_INPUT`);let u=e?q(e):null,d=n?q(n):null;u&&l&&u.scrollIntoView({block:`center`,behavior:`instant`});let f=u?tc(u):nc(t);u&&ic(u,f);let p=d?mc(d):nc(r),m=u?.closest(`[draggable="true"]`)??null,h=i===`auto`?m?`native`:`pointer`:i;if(h===`native`&&c)throw new V(`A trusted drag sends real mouse events, which cannot drive HTML5 drag-and-drop — drop "trusted", or set mode to "pointer" if the page also listens for pointer drags`,`INVALID_INPUT`);if(h===`native`&&!u)throw new V(`HTML5 drag-and-drop starts on an element, so coordinates cannot fire dragstart — give a "from" target, or set mode to "pointer"`,`INVALID_INPUT`);let g={approach:rc(f),grip:f,drop:p,steps:a,holdMs:o,settleMs:s},_={from:u?Z(u):void 0,to:d?Z(d):void 0,mechanism:h,...g};if(c)return _;let v=h===`native`?await vc(m??u,g):await _c(u,g);return{..._,...v,trusted:!1}}}),bc=2166136261,xc=16777619,Sc=[{pattern:/\n{2,}/g,floor:.5},{pattern:/(?<=[.!?…]["'’”)\]]*)\s+/g,floor:.25},{pattern:/[。!?]["’”」』))\]]*/g,floor:.25},{pattern:/\n/g,floor:.25},{pattern:/\s+/g,floor:0}],Cc=/^(\d+)\.([0-9a-f]{8})$/;function wc(e){let t=bc;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,xc);return(t>>>0).toString(16).padStart(8,`0`)}function Tc(e,t,n){if(e.length-t<=n)return e.length;let r=e.slice(t,t+n);for(let{pattern:e,floor:i}of Sc){let a=Oc(r,e,Math.floor(n*i));if(a>0)return t+a}return t+n}function Ec(e,t){return`${e}.${wc(t)}`}function Dc(e){let t=Cc.exec(e.trim());return t?{offset:Number(t[1]),digest:t[2]}:null}function Oc(e,t,n){t.lastIndex=0;let r=0;for(let i=t.exec(e);i;i=t.exec(e))i.index>=n&&(r=i.index+i[0].length);return r}var kc=2e5,Ac=B({name:`page.extractText`,description:`Read the rendered text or raw HTML of an element or the whole page, one group at a time. A group is cut at the last paragraph or sentence boundary that fits in maxLength, never mid-sentence, and the same page always groups the same way. When more text remains the reply carries a cursor — pass it back for the next group, and keep going until no cursor comes back. The cursor is checked against the text it already handed you, so two groups never come from two different versions of the page: if the page rewrote what you had read, the reply is "stale": true and nothing else, and the read starts over with no cursor.`,input:R({target:K.optional().describe(`Element to read; defaults to the whole page`),format:z([`text`,`html`]).default(`text`).describe(`Plain rendered text, or raw HTML. HTML is denied by default — it carries comments and hidden nodes the reader never sees — and needs "raw-html-read": "allow" in the guardrail config.`),maxLength:I().int().positive().max(kc).default(2e4).describe(`Characters per group — the reply stops at the last boundary that fits, so it comes back a little shorter`),cursor:P().max(32).optional().describe(`Continue a read: the cursor the previous reply returned. Omit to start from the top.`)}),execute({target:e,format:t,maxLength:n,cursor:r}){let i=e?q(e):document.body,a=t===`text`?i.innerText.replace(/\n{3,}/g,`
67
+ `)}var K=R({selector:N().optional().describe(`CSS selector for the element`),text:N().optional().describe(`Case-insensitive visible text the element should contain`),role:N().optional().describe(`Tag name or ARIA role to narrow matches, e.g. "button" or "link"`),nth:F().int().nonnegative().default(0).describe(`Zero-based index when several elements match`)}),Ss=`a,button,input,select,textarea,summary,label,h1,h2,h3,h4,h5,h6,[role],[tabindex],[contenteditable]`,Cs={link:[`a`],button:[`button`],textbox:[`input`,`textarea`],combobox:[`select`],checkbox:[`input`],radio:[`input`],heading:[`h1`,`h2`,`h3`,`h4`,`h5`,`h6`]},ws={button:`button`,submit:`button`,reset:`button`,image:`button`,file:`button`,checkbox:`checkbox`,radio:`radio`,range:`slider`,number:`spinbutton`,search:`searchbox`},Ts={button:`button`,select:`combobox`,textarea:`textbox`,summary:`button`,option:`option`,h1:`heading`,h2:`heading`,h3:`heading`,h4:`heading`,h5:`heading`,h6:`heading`,nav:`navigation`,main:`main`,header:`banner`,footer:`contentinfo`,aside:`complementary`,form:`form`,dialog:`dialog`},Es=new Set([`button`,`submit`,`reset`,`image`,`checkbox`,`radio`,`file`]);function Ds(e){let t=e.getAttribute(`role`)?.trim().split(/\s+/)[0];return t?t.toLowerCase():e instanceof HTMLInputElement?ws[e.type]??`textbox`:e instanceof HTMLAnchorElement?e.getAttribute(`href`)===null?void 0:`link`:Ts[e.tagName.toLowerCase()]}function Os(e,t){let n=t.toLowerCase(),r=e.tagName.toLowerCase();return r===n||Ds(e)===n?!0:Cs[n]?.includes(r)??!1}function q(e,t={}){let{selector:n,text:r,role:i,nth:a}=e;if(!n&&!r)throw new V(`A target needs a "selector" or "text"`,`INVALID_TARGET`);let o=[...document.querySelectorAll(n??Ss)];if(i&&(o=o.filter(e=>Os(e,i))),r){let e=r.toLowerCase();o=o.filter(t=>J(t).toLowerCase().includes(e)),o=o.filter(e=>!o.some(t=>t!==e&&e.contains(t)))}t.includeHidden||(o=o.filter(Y));let s=o[a];if(!s)throw new V(`No element matches ${JSON.stringify(e)} (${o.length} candidates)`,`TARGET_NOT_FOUND`);return s}function J(e){let t=e.getAttribute(`aria-label`)?.trim();if(t)return t;if(e instanceof HTMLInputElement)return e.type===`submit`||e.type===`button`||e.type===`reset`?e.value.trim()||e.type:ks(e);if(e instanceof HTMLTextAreaElement||e instanceof HTMLSelectElement)return ks(e);if(e instanceof HTMLImageElement)return e.alt.trim();let n=(e.textContent??``).replace(/\s+/g,` `).trim();if(n)return n;let r=e.querySelector(`img[alt]`);return r instanceof HTMLImageElement?r.alt.trim():``}function ks(e){return e.labels?.[0]?.textContent?.trim()||e.getAttribute(`placeholder`)?.trim()||e.name}function Y(e){let t=e.getBoundingClientRect();if(t.width===0&&t.height===0)return!1;let n=getComputedStyle(e);return n.visibility!==`hidden`&&n.display!==`none`}function As(e){return Y(e)&&!e.closest(`[aria-hidden="true"],[inert]`)}function js(e,t){let n=e.getAttribute(t);return n===`true`||n!==`false`&&void 0}function Ms(e){let t={};(e.matches(`:disabled`)||js(e,`aria-disabled`))&&(t.disabled=!0);let n=e instanceof HTMLInputElement&&(e.type===`checkbox`||e.type===`radio`)?e.checked:js(e,`aria-checked`);n!==void 0&&(t.checked=n);let r=js(e,`aria-expanded`);r!==void 0&&(t.expanded=r);let i=e instanceof HTMLOptionElement?e.selected:js(e,`aria-selected`);i!==void 0&&(t.selected=i);let a=e.getAttribute(`aria-current`);return a&&a!==`false`&&(t.current=a),(e.matches(`:required`)||js(e,`aria-required`))&&(t.required=!0),js(e,`aria-invalid`)&&(t.invalid=!0),e instanceof HTMLSelectElement?t.value=e.selectedOptions[0]?.text.replace(/\s+/g,` `).trim().slice(0,60)||void 0:(e instanceof HTMLTextAreaElement||e instanceof HTMLInputElement&&!Es.has(e.type))&&(t.filled=e.value.length>0),Object.values(t).some(e=>e!==void 0)?t:void 0}function X(e){let t=[];for(let n=e;n&&n!==document.documentElement;n=n.parentElement){if(n.id)return t.unshift(`#${CSS.escape(n.id)}`),t.join(` > `);let e=n.tagName.toLowerCase(),r=n.parentElement?[...n.parentElement.children].filter(e=>e.tagName===n.tagName):[];t.unshift(r.length>1?`${e}:nth-of-type(${r.indexOf(n)+1})`:e)}return t.join(` > `)}function Ns(e){let t=e.getBoundingClientRect();return{x:Math.round(t.x+window.scrollX),y:Math.round(t.y+window.scrollY),width:Math.round(t.width),height:Math.round(t.height)}}function Z(e){let t=J(e).slice(0,80);return{tag:e.tagName.toLowerCase(),role:Ds(e),selector:X(e),text:t||void 0,state:Ms(e),bounds:Ns(e)}}function Ps(e){return e.closest(`form`)?e instanceof HTMLButtonElement?e.type===`submit`:e instanceof HTMLInputElement&&(e.type===`submit`||e.type===`image`):!1}var Fs=B({name:`page.attachFile`,description:`Attach a file to a file input on the page: either one the user stored in Browsentic (fileId, from page.listFiles) or one you captured off another page (downloadId, from page.captureDownload). The second closes the loop — download here, upload there — without the bytes ever passing through you.`,input:R({fileId:N().optional().describe(`Id of a stored file, taken from page.listFiles.`),downloadId:N().optional().describe(`Id of a captured download, taken from page.captureDownload or page.listDownloads.`),target:K.describe(`The file input (<input type="file">) to attach the file to.`),name:N().optional().describe(`Internal: original filename. Browsentic fills this in.`),mime:N().optional().describe(`Internal: file MIME type. Browsentic fills this in.`),content:N().optional().describe(`Internal: base64 file bytes. Browsentic fills this in.`)}),execute({target:e,name:t,mime:n,content:r}){if(!r)throw new V(`No file bytes were supplied — call with a valid fileId or downloadId.`,`INVALID_INPUT`);let i=q(e,{includeHidden:!0});if(!(i instanceof HTMLInputElement)||i.type!==`file`)throw new V(`<${i.tagName.toLowerCase()}> is not a file input`,`INVALID_TARGET`);let a=atob(r),o=new Uint8Array(a.length);for(let e=0;e<a.length;e++)o[e]=a.charCodeAt(e);let s=new File([o],t||`file`,{type:n||`application/octet-stream`}),c=new DataTransfer;return c.items.add(s),Object.getOwnPropertyDescriptor(HTMLInputElement.prototype,`files`).set.call(i,c.files),i.dispatchEvent(new Event(`input`,{bubbles:!0})),i.dispatchEvent(new Event(`change`,{bubbles:!0})),{attached:!0,name:s.name,size:o.length,mime:s.type,element:Z(i)}}}),Is=60,Ls=B({name:`page.auditContrast`,description:`Score the readability of the page against WCAG contrast rules. Walks the visible text, resolves each run’s foreground against the real background painted behind it — blending translucent layers up the ancestor chain — and reports the ratio, the ratio the level requires, and whether it passes. The score is the share of sampled text runs that pass, so it is directly comparable before and after page.applyTheme.`,input:R({target:K.optional().describe(`Subtree to audit; defaults to the whole page`),level:z([`AA`,`AAA`]).default(`AA`).describe(`WCAG level: AA needs 4.5:1 for body text and 3:1 for large text, AAA needs 7:1 and 4.5:1`),maxSamples:F().int().positive().max(2e3).default(400).describe(`Text-bearing elements to check, in document order`),maxFailures:F().int().nonnegative().max(200).default(20).describe(`Failures listed, worst ratio first; the counts always cover everything sampled`)}),execute({target:e,level:t,maxSamples:n,maxFailures:r}){let i=e?q(e):document.body??document.documentElement,a=Rs(i,t,n,Xo()),o=a.filter(e=>!e.passes).sort((e,t)=>e.ratio-t.ratio),s=a.length-o.length;return{url:location.href,level:t,required:{normalText:Do(!1,t),largeText:Do(!0,t)},...a.length?{score:Math.round(s/a.length*100)}:{},summary:{sampled:a.length,passed:s,failed:o.length,worstRatio:a.length?Math.min(...a.map(e=>e.ratio)):void 0},failures:o.slice(0,r),source:X(i)}}});function Rs(e,t,n,r){let i=document.createTreeWalker(e,NodeFilter.SHOW_TEXT),a=new Set,o=[];for(let e=i.nextNode();e&&o.length<n;e=i.nextNode()){let n=(e.textContent??``).replace(/\s+/g,` `).trim(),i=e.parentElement;!n||!i||a.has(i)||(a.add(i),As(i)&&o.push(zs(i,n,t,r)))}return o}function zs(e,t,n,r){let i=getComputedStyle(e),a=wo(e),o=r(a),s=r(To(e,a)),c=G(parseFloat(i.fontSize),1),l=Number(i.fontWeight)||400,u=Eo(c,l),d=G(bo(s,o),2),f=Do(u,n);return{selector:X(e),text:t.slice(0,Is),foreground:U(s),background:U(o),ratio:d,required:f,passes:d>=f,fontSizePx:c,weight:l,large:u,bounds:Ns(e)}}var Bs=30*6e4,Vs=240*6e4,Hs=2*6e4,Us=10*6e4,Ws=5e3,Gs=3e4,Ks=B({name:`page.awaitMonitor`,description:`Block until a background monitor completes, then return its final state with the full log. A reply with settled: false means the timeout passed while the watch continues — call again to keep waiting; that is normal, not an error. If the call fails with EXTENSION_OFFLINE the monitor is still running in the browser — reconnect and call again.`,input:R({monitorId:N().describe(`The monitor to wait on, from page.startMonitor`),timeoutMs:F().int().positive().max(Us).default(Hs).describe(`Return after this long even if unfinished — the reply then has settled: false and the current state, so call again to keep waiting`)}),execute(){throw new V(`page.awaitMonitor is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),qs=B({name:`page.callSiteTool`,description:`Call one of the tools this site offers through WebMCP (document.modelContext), with arguments matching the schema page.listSiteTools reported. The site’s own code handles the call, which makes it the reliable path wherever a listed tool covers the step — no selectors to break, no intermediate states to wait through. The return value is whatever the site’s tool produced, as JSON. Treat a call like a form submit: the site decides what it does, and that can include acting on the user’s account, so it passes the same approval gate.`,input:R({tool:N().min(1).describe(`Name of a tool exactly as page.listSiteTools reported it.`),args:Da(N(),_a()).default({}).describe(`Arguments for the tool, matching its input schema. JSON values only.`),timeoutMs:F().int().min(100).max(12e4).default(15e3).describe(`How long the tool may run before the call is abandoned. Raise it for tools that wait on the site’s backend.`)}),execute(){throw new V(`page.callSiteTool is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Js=B({name:`page.captureDownload`,description:`Make the page download a file and keep it. Either click something that produces a download — an “Export CSV” button, a “Download invoice” link — or give a direct url, which is fetched in the browser’s own logged-in session rather than anonymously. The file lands in the user’s ~/browsentic/download/ folder and the result reports the path and notes about what arrived; you get the notes, never the bytes. Hand the returned downloadId to page.attachFile to upload it somewhere else without the file ever passing through you.`,input:R({target:K.optional().describe(`The link or button whose click starts the download. Give this or "url", not both.`),url:N().optional().describe(`Direct http(s) url of the file, fetched with the browser’s cookies. Give this or "target", not both. Prefer "target" when a button exists: many exports have no fetchable url at all.`),timeoutMs:F().int().min(1e3).max(6e5).default(6e4).describe(`How long to wait for the download to finish before giving up.`)}),execute(){throw new V(`page.captureDownload is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Ys=B({name:`page.clickElement`,description:`Click an element like a user would, firing the full pointer and mouse event sequence.`,input:R({target:K.describe(`Element to click`),scrollIntoView:I().default(!0).describe(`Bring the element into view before clicking`)}),execute({target:e,scrollIntoView:t}){let n=q(e);t&&n.scrollIntoView({block:`center`,behavior:`instant`});try{n.focus({preventScroll:!0})}catch{}let r=Ps(n),i={bubbles:!0,cancelable:!0,composed:!0};return n.dispatchEvent(new PointerEvent(`pointerdown`,i)),n.dispatchEvent(new MouseEvent(`mousedown`,i)),n.dispatchEvent(new PointerEvent(`pointerup`,i)),n.dispatchEvent(new MouseEvent(`mouseup`,i)),n.click(),{...Z(n),submits:r}}}),Xs=B({name:`page.closeTab`,description:`Close an open tab. With no arguments it closes the tab page actions are currently targeting, and later actions follow the browser to whichever tab it brings to the front.`,input:R({tabId:F().int().optional().describe(`Id of the tab to close, as reported by page.openTab or a no-argument page.switchTab.`),match:N().optional().describe(`Instead of an id, close the tab whose title or URL contains this text (case-insensitive). If several tabs match, nothing is closed and the candidates are listed.`)}),execute(){throw new V(`page.closeTab is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Zs=120,Qs=6,$s=R({x:F().describe(`Pixels from the left edge of the viewport`),y:F().describe(`Pixels from the top edge of the viewport`)});function ec(){return{w:document.documentElement.clientWidth,h:document.documentElement.clientHeight}}function tc(e){let t=e.getBoundingClientRect(),{w:n,h:r}=ec(),i=Math.max(t.left,0),a=Math.max(t.top,0),o=Math.min(t.right,n),s=Math.min(t.bottom,r);if(o<=i||s<=a)throw new V(`The element has no visible area inside the viewport — scroll it into view, then retry`,`INVALID_TARGET`);return{x:Math.round((i+o)/2),y:Math.round((a+s)/2)}}function nc(e){let{w:t,h:n}=ec();if(e.x<0||e.y<0||e.x>=t||e.y>=n)throw new V(`The point (${e.x}, ${e.y}) is outside the ${t}×${n} viewport — scroll it into view, then retry`,`INVALID_TARGET`);return{x:Math.round(e.x),y:Math.round(e.y)}}function rc(e){let{w:t,h:n}=ec();return{x:Math.min(Math.max(e.x-Zs,0),t-1),y:Math.min(Math.max(e.y-Zs,0),n-1)}}function Q(e){return document.elementFromPoint(e.x,e.y)}function ic(e,t){let n=Q(t);if(!(n===e||e.contains(n)))throw new V(n?`${X(n)} covers (${t.x}, ${t.y}) — dismiss whatever is over the element, then retry`:`Nothing is painted at (${t.x}, ${t.y}) — scroll the element into view, then retry`,`INVALID_TARGET`)}var ac=e=>1-(1-e)**3;function oc(e,t,n){let r=t.x-e.x,i=t.y-e.y,a=Math.hypot(r,i)||1,o=Math.min(Qs,a/8);return Array.from({length:n},(t,s)=>{let c=ac((s+1)/n),l=Math.sin(c*Math.PI)*o*(s%2?-1:1);return{x:Math.round(e.x+r*c-i/a*l),y:Math.round(e.y+i*c+r/a*l)}})}var sc=[[`pointer`,`pointerover`,!0],[`pointer`,`pointerenter`,!1],[`pointer`,`pointermove`,!0],[`mouse`,`mouseover`,!0],[`mouse`,`mouseenter`,!1],[`mouse`,`mousemove`,!0]];function cc(e,t){for(let[n,r,i]of sc){let a=n===`pointer`?PointerEvent:MouseEvent;e.dispatchEvent(new a(r,{clientX:t.x,clientY:t.y,bubbles:i,composed:!0}))}}var lc=16,uc=e=>new Promise(t=>setTimeout(t,e));function dc(e,t){return{clientX:e.x,clientY:e.y,button:0,buttons:t,bubbles:!0,cancelable:!0,composed:!0,view:window,pointerId:1,pointerType:`mouse`,isPrimary:!0}}function fc(e,t,n,r,i){let a=dc(r,i);e?.dispatchEvent(new PointerEvent(t,a)),e?.dispatchEvent(new MouseEvent(n,a))}function pc(e,t,n,r){return e?.dispatchEvent(new DragEvent(t,{...dc(n,1),dataTransfer:r}))??!1}function mc(e){try{return tc(e)}catch{throw new V(`The drop target is not inside the viewport — both ends of a drag have to be on screen at once, because nothing scrolls mid-drag. Scroll until both are visible, then retry`,`INVALID_TARGET`)}}async function hc(e,t,n,r,i){for(let a of oc(e,t,n))await uc(lc),i?i(a):fc(Q(a),`pointermove`,`mousemove`,a,r)}async function gc(e,t,n){await hc(e,t,4,0),cc(n??document.body,t)}async function _c(e,t){let{approach:n,grip:r,drop:i,steps:a,holdMs:o,settleMs:s}=t,c=e??Q(r);await gc(n,r,c),fc(c,`pointerdown`,`mousedown`,r,1),await uc(o),await hc(r,i,a,1),await uc(s);let l=Q(i);return fc(l??c,`pointerup`,`mouseup`,i,0),{landedOn:l?X(l):void 0}}async function vc(e,t){let{approach:n,grip:r,drop:i,steps:a,holdMs:o,settleMs:s}=t,c=new DataTransfer;await gc(n,r,e),fc(e,`pointerdown`,`mousedown`,r,1),await uc(o);let l=pc(e,`dragstart`,r,c),u=!1,d=null;await hc(r,i,a,1,e=>{let t=Q(e);t!==d&&(pc(d,`dragleave`,e,c),pc(t,`dragenter`,e,c),d=t),t&&!pc(t,`dragover`,e,c)&&(u=!0)}),await uc(s);let f=Q(i);return pc(f,`drop`,i,c),pc(e,`dragend`,i,c),{landedOn:f?X(f):void 0,started:l,accepted:u}}var yc=B({name:`page.dragElement`,description:`Drag one thing onto another — reorder a list, move a card between columns, pull a slider handle, draw on a canvas. Give a "from" element (or "fromPoint") to pick up and a "to" element (or "toPoint") to drop on. Both ends must be on screen at the same moment, because nothing auto-scrolls mid-drag. The web has two unrelated drag mechanisms and "auto" chooses between them by reading the grabbed element: "pointer" presses, moves and releases a pointer, which is what dnd-kit, react-beautiful-dnd, sliders and canvases listen for; "native" fires the HTML5 dragstart/dragover/drop sequence with a DataTransfer, which is what an element carrying draggable="true" expects. The drop point is measured before the drag starts, so a list that reflows as you pass over it can land a slot out — raise "steps" and "settleMs", then read the result back. Set "trusted" when the page ignores synthetic events; that path is pointer-only, Chrome-only, and shows the “Browsentic is debugging this browser” bar. If nothing moved, check "accepted" and try the other mode.`,input:R({from:K.optional().describe(`Element to pick up — the card, row, or drag handle. Give this or "fromPoint", never both.`),fromPoint:$s.optional().describe(`Viewport coordinates to grab from, in CSS pixels. Use it when the grip is not an element, such as a spot on a <canvas>.`),to:K.optional().describe(`Element to drop onto — the destination column, list slot, or drop zone. Give this or "toPoint", never both.`),toPoint:$s.optional().describe(`Viewport coordinates to drop at, in CSS pixels. Use it to reach empty space, a slider position, or a spot on a <canvas>.`),mode:z([`auto`,`pointer`,`native`]).default(`auto`).describe(`Which drag mechanism to use. "auto" picks "native" when the grabbed element declares draggable="true", "pointer" otherwise.`),steps:F().int().min(2).max(60).default(16).describe(`Moves dispatched along the way to the drop point. Raise it for lists that reorder as the pointer passes over them.`),holdMs:F().int().min(0).max(5e3).default(120).describe(`How long the button stays down before the drag starts moving. Raise it past a library’s press-and-hold delay.`),settleMs:F().int().min(0).max(5e3).default(120).describe(`Pause on the drop point before releasing, letting the page settle on where the item would land.`),trusted:I().default(!1).describe(`Dispatch real browser-level mouse events, so isTrusted is true. Pointer mode only, Chrome only.`),scrollIntoView:I().default(!0).describe(`Bring the grabbed element into view first. Ignored with "fromPoint".`)}),async execute({from:e,fromPoint:t,to:n,toPoint:r,mode:i,steps:a,holdMs:o,settleMs:s,trusted:c,scrollIntoView:l}){if(!e==!t)throw new V(`Give either a "from" target to pick up or a "fromPoint" to grab at — not both, not neither`,`INVALID_INPUT`);if(!n==!r)throw new V(`Give either a "to" target to drop onto or a "toPoint" to drop at — not both, not neither`,`INVALID_INPUT`);let u=e?q(e):null,d=n?q(n):null;u&&l&&u.scrollIntoView({block:`center`,behavior:`instant`});let f=u?tc(u):nc(t);u&&ic(u,f);let p=d?mc(d):nc(r),m=u?.closest(`[draggable="true"]`)??null,h=i===`auto`?m?`native`:`pointer`:i;if(h===`native`&&c)throw new V(`A trusted drag sends real mouse events, which cannot drive HTML5 drag-and-drop — drop "trusted", or set mode to "pointer" if the page also listens for pointer drags`,`INVALID_INPUT`);if(h===`native`&&!u)throw new V(`HTML5 drag-and-drop starts on an element, so coordinates cannot fire dragstart — give a "from" target, or set mode to "pointer"`,`INVALID_INPUT`);let g={approach:rc(f),grip:f,drop:p,steps:a,holdMs:o,settleMs:s},_={from:u?Z(u):void 0,to:d?Z(d):void 0,mechanism:h,...g};if(c)return _;let v=h===`native`?await vc(m??u,g):await _c(u,g);return{..._,...v,trusted:!1}}}),bc=2166136261,xc=16777619,Sc=[{pattern:/\n{2,}/g,floor:.5},{pattern:/(?<=[.!?…]["'’”)\]]*)\s+/g,floor:.25},{pattern:/[。!?]["’”」』))\]]*/g,floor:.25},{pattern:/\n/g,floor:.25},{pattern:/\s+/g,floor:0}],Cc=/^(\d+)\.([0-9a-f]{8})$/;function wc(e){let t=bc;for(let n=0;n<e.length;n+=1)t^=e.charCodeAt(n),t=Math.imul(t,xc);return(t>>>0).toString(16).padStart(8,`0`)}function Tc(e,t,n){if(e.length-t<=n)return e.length;let r=e.slice(t,t+n);for(let{pattern:e,floor:i}of Sc){let a=Oc(r,e,Math.floor(n*i));if(a>0)return t+a}return t+n}function Ec(e,t){return`${e}.${wc(t)}`}function Dc(e){let t=Cc.exec(e.trim());return t?{offset:Number(t[1]),digest:t[2]}:null}function Oc(e,t,n){t.lastIndex=0;let r=0;for(let i=t.exec(e);i;i=t.exec(e))i.index>=n&&(r=i.index+i[0].length);return r}var kc=2e5,Ac=B({name:`page.extractText`,description:`Read the rendered text or raw HTML of an element or the whole page, one group at a time. A group is cut at the last paragraph or sentence boundary that fits in maxLength, never mid-sentence, and the same page always groups the same way. When more text remains the reply carries a cursor — pass it back for the next group, and keep going until no cursor comes back. The cursor is checked against the text it already handed you, so two groups never come from two different versions of the page: if the page rewrote what you had read, the reply is "stale": true and nothing else, and the read starts over with no cursor.`,input:R({target:K.optional().describe(`Element to read; defaults to the whole page`),format:z([`text`,`html`]).default(`text`).describe(`Plain rendered text, or raw HTML. HTML is denied by default — it carries comments and hidden nodes the reader never sees — and needs "raw-html-read": "allow" in the guardrail config.`),maxLength:F().int().positive().max(kc).default(2e4).describe(`Characters per group — the reply stops at the last boundary that fits, so it comes back a little shorter`),cursor:N().max(32).optional().describe(`Continue a read: the cursor the previous reply returned. Omit to start from the top.`)}),execute({target:e,format:t,maxLength:n,cursor:r}){let i=e?q(e):document.body,a=t===`text`?i.innerText.replace(/\n{3,}/g,`
68
68
 
69
- `).trim():i.outerHTML,o=X(i),s=Math.min(n,kc),c=r?Dc(r):null;if(r&&!c)throw new V(`That is not a cursor page.extractText handed out — omit it to read from the top`,`INVALID_INPUT`);if(c&&wc(a.slice(0,c.offset))!==c.digest)return{stale:!0,source:o,length:a.length};let l=c?.offset??0,u=Tc(a,l,s),d=u<a.length;return{content:a.slice(l,u).trimEnd(),source:o,length:a.length,offset:l,truncated:d,...d?{nextOffset:u,cursor:Ec(u,a.slice(0,u))}:{}}}}),jc={Enter:{code:`Enter`,keyCode:13},Tab:{code:`Tab`,keyCode:9},Escape:{code:`Escape`,keyCode:27},Backspace:{code:`Backspace`,keyCode:8},Delete:{code:`Delete`,keyCode:46}," ":{code:`Space`,keyCode:32},ArrowLeft:{code:`ArrowLeft`,keyCode:37},ArrowUp:{code:`ArrowUp`,keyCode:38},ArrowRight:{code:`ArrowRight`,keyCode:39},ArrowDown:{code:`ArrowDown`,keyCode:40},Home:{code:`Home`,keyCode:36},End:{code:`End`,keyCode:35},PageUp:{code:`PageUp`,keyCode:33},PageDown:{code:`PageDown`,keyCode:34}};function Mc(e){if(jc[e])return jc[e];if(e.length===1){let t=e.toUpperCase();if(t>=`A`&&t<=`Z`)return{code:`Key${t}`,keyCode:t.charCodeAt(0)};if(e>=`0`&&e<=`9`)return{code:`Digit${e}`,keyCode:e.charCodeAt(0)}}return{code:``,keyCode:0}}function Nc(e,t=[]){let{code:n,keyCode:r}=Mc(e);return{key:e,code:n,keyCode:r,which:r,bubbles:!0,cancelable:!0,composed:!0,ctrlKey:t.includes(`ctrl`),shiftKey:t.includes(`shift`),altKey:t.includes(`alt`),metaKey:t.includes(`meta`)}}var Pc=B({name:`page.fillInput`,description:`Fill a text input, textarea, or contenteditable element like a user typing.`,input:R({target:K.describe(`Element to type into`),value:P().describe(`Text to enter`),clear:L().default(!0).describe(`Replace existing content instead of appending`),pressEnter:L().default(!1).describe(`Press Enter afterwards, which submits many forms`)}),execute({target:e,value:t,clear:n,pressEnter:r}){let i=q(e);i.focus();let{length:a}=Fc(i,t,{clear:n,pressEnter:r});return{element:Z(i),length:a,appended:!n}}});function Fc(e,t,{clear:n,pressEnter:r}){let i;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){i=n?t:e.value+t;let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,`value`).set.call(e,i),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,data:t,inputType:`insertText`})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}else if(e.isContentEditable)i=n?t:(e.textContent??``)+t,e.textContent=i,e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,data:t,inputType:`insertText`}));else throw new V(`<${e.tagName.toLowerCase()}> is not an editable element`,`INVALID_TARGET`);return{length:i.length,submitted:r?Ic(e):!1}}function Ic(e){let t=Nc(`Enter`),n=e.dispatchEvent(new KeyboardEvent(`keydown`,t));e.dispatchEvent(new KeyboardEvent(`keyup`,t));let r=n&&!(e instanceof HTMLTextAreaElement)?e.closest(`form`):null;return r?.requestSubmit(),!!r}var Lc=B({name:`page.findCaptcha`,chromiumOnly:!0,description:`Look for a captcha on the page and report what it is, without touching it. Ordinary selectors cannot see one: vendors build the widget inside a closed shadow root holding a cross-origin iframe holding another shadow root, so page.getPageInfo shows nothing where the captcha visibly is. This reads through all of that with Chrome’s debugger and reports the vendor (Cloudflare Turnstile, reCAPTCHA v2/v3, hCaptcha, GeeTest, Arkose, AWS WAF), the widget’s on-screen bounds, whether it is already satisfied, and a viewport point for its checkbox when it has one. Read-only — it never clicks. Call it when a page stalls on “verifying you are human”, refuses a form for no visible reason, or shows a checkbox no selector can find. Chrome only, and it briefly shows the “Browsentic is debugging this browser” bar.`,input:R({}),execute(){throw new V(`page.findCaptcha is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Rc=/(\d{1,3}(?:\.\d+)?)\s?%/,zc=/spinner|loading|progress/i,Bc=80,Vc=B({name:`page.findProgress`,description:`Scan the page for progress signals worth monitoring: progress bars, percent readouts, spinners and busy regions, each with a selector for page.startMonitor. An empty candidates list with no titlePercent means the page shows nothing measurable — ask the user what completion looks like instead of starting a monitor.`,input:R({maxCandidates:I().int().positive().max(30).default(10).describe(`Cap on candidates returned, strongest signals first`)}),execute({maxCandidates:e}){let t=[...Hc(),...Uc(),...Wc(),...Gc(),...Kc()],n=new Set,r=t.filter(e=>n.has(e.selector)?!1:(n.add(e.selector),!0)),i=Rc.exec(document.title);return{candidates:r.slice(0,e),...i?{titlePercent:Zc(parseFloat(i[1]))}:{},url:location.href}}});function Hc(){return Jc(`[role="progressbar"]`).map(e=>{let t=parseFloat(e.getAttribute(`aria-valuenow`)??``),n=parseFloat(e.getAttribute(`aria-valuemin`)??`0`)||0,r=parseFloat(e.getAttribute(`aria-valuemax`)??`100`)||100,i=Number.isFinite(t)&&r>n?Zc((t-n)/(r-n)*100):void 0;return qc(e,`progressbar`,{value:Number.isFinite(t)?t:void 0,max:r,percent:i})})}function Uc(){return Jc(`progress, meter`).map(e=>{let t=e,n=t.max>0?Zc(t.value/t.max*100):void 0;return qc(e,`progress-element`,{value:t.value,max:t.max,percent:n})})}function Wc(){let e=document.createTreeWalker(document.body??document.documentElement,NodeFilter.SHOW_TEXT),t=new Set;for(let n=e.nextNode();n;n=e.nextNode()){if(!Rc.test(n.textContent??``))continue;let e=Yc(n.parentElement);e&&Y(e)&&t.add(e)}return[...t].map(e=>{let t=Xc(e.innerText??``),n=Rc.exec(t);return qc(e,`percent-text`,{text:t.slice(0,Bc),percent:n?Zc(parseFloat(n[1])):void 0})})}function Gc(){return Jc(`[class]`).filter(e=>zc.test(e.getAttribute(`class`)??``)&&getComputedStyle(e).animationName!==`none`).map(e=>qc(e,`spinner`,{}))}function Kc(){return Jc(`[aria-busy="true"]`).map(e=>qc(e,`busy-region`,{}))}function qc(e,t,n){let r=n.text??J(e).slice(0,Bc);return{kind:t,selector:X(e),...r?{text:r}:{},...n.value==null?{}:{value:n.value},...n.max==null?{}:{max:n.max},...n.percent==null?{}:{percent:n.percent},bounds:Ns(e)}}function Jc(e){return[...document.querySelectorAll(e)].filter(Y)}function Yc(e){for(let t=e;t;t=t.parentElement)if(getComputedStyle(t).display!==`inline`)return t;return e}function Xc(e){return e.replace(/\s+/g,` `).trim()}function Zc(e){return Math.min(100,Math.max(0,e))}var Qc=`{query}`,$c=[`q`,`query`,`k`,`s`,`search`,`keyword`,`keywords`,`term`,`wd`,`text`],el=/\b(?:search|zoek|suche|suchen|recherche|buscar|cerca|szukaj)/i,tl=[`name`,`id`,`class`,`aria-label`,`placeholder`,`title`],nl=new Set([`search`,`text`,``]),rl=[{selector:`input[type="search"], [role="searchbox"]`,named:!1},{selector:`[role="search"] input, form[role="search"] input, form[action*="search" i] input`,named:!1},{selector:`input[type="text"], input:not([type])`,named:!0}];function il(){let e=new Set;for(let{selector:t,named:n}of rl)for(let r of document.querySelectorAll(t))!ml(r)||hl(r)||n&&!gl(r)||e.add(r);return[...e].map(pl)}function al(e){return e.find(e=>!e.hidden)??e[0]??null}function ol(e){if(!ml(e))throw new V(`<${e.tagName.toLowerCase()}> is not a text field to search in`,`INVALID_TARGET`);if(hl(e))throw new V(`That field is disabled, or sits in a form with a password in it — a sign-in form is not a search box`,`INVALID_TARGET`);return pl(e)}function sl(e){let t=e.filter(e=>!e.hidden).map(({element:e})=>e);return[...document.querySelectorAll(`button,[role="button"],summary,a[href]`)].filter(Y).filter(e=>el.test(_l(e))).filter(e=>!Ps(e)).filter(e=>!t.some(t=>e.contains(t)))}function cl(){return[...document.querySelectorAll(`a[href]`)].filter(Y).filter(vl)}function ll(){let e=document.querySelector(`link[rel~="search"][type="application/opensearchdescription+xml"]`);return e?{href:e.href,title:e.title||void 0}:void 0}function ul(e,t){let n=e&&yl(e,t);if(n)return{url:n,from:`form`};let r=bl(t);return r?{url:r,from:`address`}:null}function dl(e){let t=ul(e,Qc);return t?{template:t.url.href.replace(encodeURIComponent(Qc),Qc),templateFrom:t.from}:null}function fl({element:e,form:t,param:n,hidden:r}){return{...Z(e),param:n||void 0,hidden:r||void 0,form:t?{selector:X(t),action:t.getAttribute(`action`)||void 0,method:(t.getAttribute(`method`)||`get`).toLowerCase()}:void 0}}function pl(e){return{element:e,form:e.closest(`form`),param:e.getAttribute(`name`)?.trim()??``,hidden:!Y(e)}}function ml(e){return e instanceof HTMLInputElement?nl.has(e.type):e.isContentEditable}function hl(e){return e.matches(`:disabled`)||e.getAttribute(`aria-disabled`)===`true`?!0:!!e.closest(`form`)?.querySelector(`input[type="password"]`)}function gl(e){let t=e.getAttribute(`name`)?.trim().toLowerCase()??``;return $c.includes(t)?!0:el.test(_l(e))}function _l(e){return[...tl.map(t=>e.getAttribute(t)??``),J(e)].join(` `)}function vl(e){try{let t=new URL(e.href);return t.origin===location.origin&&el.test(t.pathname)}catch{return!1}}function yl({form:e,param:t},n){if(!e||!t||(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`)return null;let r=new URL(e.getAttribute(`action`)||location.href,location.href),i=new URLSearchParams;for(let[t,n]of new FormData(e))typeof n==`string`&&i.set(t,n);return i.set(t,n),r.search=i.toString(),r.hash=``,r}function bl(e){let t=new URL(location.href),n=[...t.searchParams.keys()].find(e=>$c.includes(e.toLowerCase()));return n?(t.searchParams.set(n,e),t.hash=``,t):null}var xl=B({name:`page.findSearch`,description:`Report how this site can be searched from where you are: the search boxes on the page — including one hidden behind a header toggle — the buttons that reveal them, links to a search page, and the URL template a search would land on, with {query} where the words go. Read-only: it never types and never navigates. Call it to find out whether searching this site is possible at all before offering to, or to record a site’s search entry point while mapping it. An empty result with searchable false means this site has no search of its own — say so rather than typing into some other field.`,input:R({maxPerKind:I().int().positive().max(20).default(5).describe(`Cap on search boxes, toggles and links listed per kind, most likely first`)}),execute({maxPerKind:e}){let t=il(),n=dl(al(t));return{url:location.href,searchable:t.length>0||!!n,...n??{},fields:t.slice(0,e).map(fl),toggles:sl(t).slice(0,e).map(Z),links:cl().slice(0,e).map(e=>({...Z(e),href:e.href})),openSearch:ll()}}}),Sl=B({name:`page.focusInput`,description:`Focus an input or editable element and place the caret, or select all its content.`,input:R({target:K.describe(`The input, textarea, or editable element to focus`),caret:z([`start`,`end`,`all`]).default(`end`).describe(`Where to leave the caret, or select all content`)}),execute({target:e,caret:t}){let n=q(e);if(n.focus(),n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)if(t===`all`)n.select();else{let e=t===`start`?0:n.value.length;try{n.setSelectionRange(e,e)}catch{}}else if(n.isContentEditable){let e=document.createRange();e.selectNodeContents(n),t!==`all`&&e.collapse(t===`start`);let r=getSelection();r?.removeAllRanges(),r?.addRange(e)}return Z(n)}}),Cl=B({name:`page.switchFrame`,description:`Step into an <iframe> so that every later page action — reading, clicking, typing, waiting, site tools, injected code — runs inside it as if it were the page, or step back out. page.getPageInfo lists the frames the current document embeds under "frames"; pass one as "frame" to enter it, and call again from inside to go deeper. Call it with no arguments to return to the top document, or with to: "parent" to step out one level. The focus is per tab, clears when the tab navigates, and page.getPageInfo reports it under "frame" whenever it is not the top. A frame that forbids scripts (a sandbox without allow-scripts) or a browser-internal frame cannot be entered; page.screenshot and page.trustedClick by coordinates still reach those. page.screenshot and page.navigate always act on the whole tab.`,input:R({frame:K.optional().describe(`The <iframe> or <frame> element to enter, matched inside the frame currently in focus — use a selector from the "frames" list of page.getPageInfo. Omit it to leave instead.`),to:z([`top`,`parent`]).default(`top`).describe(`Where to go when no "frame" is given: "top" returns to the main document, "parent" steps out one level.`)}),execute({frame:e}){if(!e)throw new V(`Leaving a frame is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`);let t=q(e);if(!wl(t))throw new V(`${X(t)} is a <${t.tagName.toLowerCase()}>, not an <iframe> — pick one of the frames page.getPageInfo lists`,`INVALID_TARGET`);return{frameId:El(t),src:t.src||void 0,name:t.name||void 0,sandbox:Tl(t),...Z(t)}}});function wl(e){return e instanceof HTMLIFrameElement||e instanceof HTMLFrameElement}function Tl(e){return e instanceof HTMLIFrameElement&&e.hasAttribute(`sandbox`)?e.sandbox.value||`all restrictions`:void 0}function El(e){let t=globalThis,n=(t.browser?.runtime?.getFrameId??t.chrome?.runtime?.getFrameId)?.(e);if(typeof n!=`number`||n<0)throw new V(`This browser cannot identify frames from the page — entering a frame needs Chrome 116 or Firefox 96 or newer`,`UNSUPPORTED`);return n}var Dl={header:`banner`,nav:`navigation`,main:`main`,aside:`complementary`,footer:`contentinfo`,form:`form`,section:`section`,dialog:`dialog`},Ol=new Set([`banner`,`navigation`,`main`,`complementary`,`contentinfo`,`search`,`form`,`region`,`dialog`]),kl=B({name:`page.getPageInfo`,description:`Snapshot the current page: document metadata, viewport and scroll state, a text diagram of the landmark regions with a selector for each, the heading outline, and an inventory of interactive elements — each carrying its ARIA role, its live state (disabled, checked, expanded, filled, aria-current) and the landmark region it sits in. When the site registers WebMCP tools, the result also carries a siteTools list — prefer page.callSiteTool over clicking wherever a listed tool covers the step. Visible iframes come back under "frames"; nothing inside one is in this snapshot until page.switchFrame enters it, and "frame" then says which one is in focus.`,input:R({maxPerKind:I().int().positive().default(30).describe(`Cap on links, buttons, fields, and forms listed per kind`),geometry:L().default(!1).describe(`Add each element’s "bounds" in document pixels. Off by default: a selector or visible text is what the other tools target by, so ask only when you need coordinates — a point for page.trustedClick or page.dragElement.`)}),execute({maxPerKind:e,geometry:t}){let{regions:n,owners:r}=Pl(),i=Rl();return zl(i,r),{document:{url:location.href,title:document.title,description:document.querySelector(`meta[name="description"]`)?.getAttribute(`content`)??void 0,lang:document.documentElement.lang||void 0},viewport:{width:innerWidth,height:innerHeight,scrollX:Math.round(scrollX),scrollY:Math.round(scrollY),pageWidth:document.documentElement.scrollWidth,pageHeight:document.documentElement.scrollHeight},selection:getSelection()?.toString().slice(0,500)||void 0,layout:{diagram:Ll(n)},outline:[...document.querySelectorAll(`h1,h2,h3,h4,h5,h6`)].filter(As).slice(0,60).map(e=>({level:Number(e.tagName[1]),text:J(e).slice(0,120)})),interactive:Bl(i,r,e,t),frames:jl(t)}}}),Al=20;function jl(e){let t=[...document.querySelectorAll(`iframe,frame`)].filter(wl).filter(As).slice(0,Al).map(t=>({selector:X(t),src:t.src||void 0,name:t.name||void 0,title:t.title||void 0,sandbox:Tl(t),bounds:e?Ns(t):void 0}));return t.length?t:void 0}function Ml(e){let t=e.getAttribute(`role`);return t?Ol.has(t)?t:void 0:Dl[e.tagName.toLowerCase()]}function Nl(e){let t=e.getAttribute(`aria-label`)?.trim();if(t)return t.slice(0,60);let n=e.getAttribute(`aria-labelledby`)?.split(/\s+/)[0];return((n?document.getElementById(n):null)??e.querySelector(`h1,h2,h3,h4,h5,h6`))?.textContent?.replace(/\s+/g,` `).trim().slice(0,60)||void 0}function Pl(){let e=[...document.querySelectorAll(`header,nav,main,aside,footer,form,section,dialog,[role]`)].filter(e=>Ml(e)&&As(e)).slice(0,40),t=[],n=new Map;for(let r of e){let e={role:Ml(r),label:Nl(r),selector:X(r),bounds:Ns(r),contains:{links:0,buttons:0,fields:0},children:[]};n.set(r,e);let i=r.parentElement;for(;i&&!n.has(i);)i=i.parentElement;(i?n.get(i).children:t).push(e)}return{regions:t,owners:n}}function Fl(e){return e.label?`${e.role} “${e.label}”`:e.role}function Il(e,t){for(let n=e.parentElement;n;n=n.parentElement){let e=t.get(n);if(e)return e}}function Ll(e){let t=document.documentElement,n=[`page ${t.scrollWidth}×${t.scrollHeight} · viewport ${innerWidth}×${innerHeight} @ y=${Math.round(scrollY)}`],r=(e,t)=>{e.forEach((i,a)=>{let o=a===e.length-1,{bounds:s,contains:c}=i,l=[`links`,`buttons`,`fields`].filter(e=>c[e]>0).map(e=>` · ${c[e]} ${e}`).join(``);n.push(`${t}${o?`└`:`├`} ${Fl(i)} · ${s.width}×${s.height} @ (${s.x},${s.y})${l} · selector: ${i.selector}`),r(i.children,t+(o?` `:`│ `))})};return r(e,``),n.join(`
70
- `)}function Rl(){let e=e=>[...document.querySelectorAll(e)].filter(As);return{links:e(`a[href]`),buttons:e(`button,[role="button"],input[type="button"],input[type="submit"]`),fields:e(`input:not([type="hidden"]):not([type="button"]):not([type="submit"]),select,textarea`),forms:e(`form`)}}function zl(e,t){for(let n of[`links`,`buttons`,`fields`])for(let r of e[n])for(let e=r.parentElement;e;e=e.parentElement){let r=t.get(e);r&&(r.contains[n]+=1)}}function Bl(e,t,n,r){let i=e=>{let n=Il(e,t);return n&&Fl(n)},a=(e,t)=>{let{tag:n,role:i,bounds:a,...o}=Z(e);return{...t?.tag===n&&t.role===i?{}:{tag:n,role:i},...o,...r?{bounds:a}:{}}};return{links:e.links.slice(0,n).map(e=>({...a(e,{tag:`a`,role:`link`}),href:e.href,region:i(e)})),buttons:e.buttons.slice(0,n).map(e=>({...a(e,{tag:`button`,role:`button`}),region:i(e)})),fields:e.fields.slice(0,n).map(e=>({...a(e),kind:e instanceof HTMLInputElement?e.type:e.tagName.toLowerCase(),region:i(e)})),forms:e.forms.slice(0,n).map(e=>({selector:X(e),action:e.getAttribute(`action`)||void 0,method:(e.getAttribute(`method`)||`get`).toLowerCase(),region:i(e)})),counts:{links:e.links.length,buttons:e.buttons.length,fields:e.fields.length,forms:e.forms.length}}}var Vl=B({name:`page.highlightElement`,description:`Visually highlight an element with a temporary outline overlay and optional caption.`,input:R({target:K.describe(`Element to highlight`),durationMs:I().int().positive().max(3e4).default(2e3).describe(`How long the highlight stays visible`),label:P().optional().describe(`Small caption rendered above the highlight`)}),execute({target:e,durationMs:t,label:n}){let r=q(e);r.scrollIntoView({block:`center`,behavior:`instant`});let i=r.getBoundingClientRect(),a=document.createElement(`div`);if(Object.assign(a.style,{position:`fixed`,left:`${i.left}px`,top:`${i.top}px`,width:`${i.width}px`,height:`${i.height}px`,pointerEvents:`none`,zIndex:`2147483647`,border:`2px solid #8b5cf6`,borderRadius:`6px`,boxShadow:`0 0 0 4px rgba(139,92,246,.25)`}),n){let e=document.createElement(`span`);e.textContent=n,Object.assign(e.style,{position:`absolute`,top:`-22px`,left:`0`,background:`#8b5cf6`,color:`#fff`,font:`11px/1.4 system-ui`,padding:`1px 6px`,borderRadius:`4px`,whiteSpace:`nowrap`}),a.append(e)}return document.documentElement.append(a),setTimeout(()=>a.remove(),t),{element:Z(r),durationMs:t}}}),Hl=B({name:`page.hoverElement`,description:`Hover an element to trigger menus, tooltips, and other hover states.`,input:R({target:K.describe(`Element to hover`),scrollIntoView:L().default(!0).describe(`Bring the element into view first`)}),execute({target:e,scrollIntoView:t}){let n=q(e);t&&n.scrollIntoView({block:`center`,behavior:`instant`});let r=n.getBoundingClientRect();return cc(n,{x:r.x+r.width/2,y:r.y+r.height/2}),Z(n)}}),Ul=B({name:`page.injectCode`,chromiumOnly:!0,description:`Install a small toolkit of JavaScript functions into the page, to be called later with page.runCode. Reach for it only when the ordinary tools are the wrong shape: a step sequence you are about to repeat three or more times with different inputs (create 20 tags, delete every row), or a capability no tool covers (seek a video, read a canvas, drive a bespoke editor API). The user reviews and approves the code before it runs — one approval covers every later page.runCode call and survives page reloads, so batch work needs no further prompts. The toolkit is bound to the tab and origin it was approved on; navigating to another site voids it. Installing goes through Chrome’s debugger, so the browser shows a “Browsentic is debugging this browser” bar for the moment it takes, and it cannot install on a tab that has DevTools open — the calls afterwards are cheap and show nothing. For a one-off click or fill, the ordinary tools are always the better choice.`,input:R({purpose:P().min(1).max(200).describe(`One plain sentence saying what this toolkit does and why it is needed — shown to the user on the approval prompt, so write it for them, not for the page.`),code:P().min(1).max(32768).describe("JavaScript source that assigns each entry point onto the provided `tools` object: `tools.addTag = async (name) => {…}`. It runs once in the page’s main world after the user approves it, so it can use the page’s DOM, globals and same-origin fetch, but nothing of the extension. Keep it pure of data: anything that varies per call arrives as arguments through page.runCode, and secrets never belong in it. Async functions are awaited; return values must be JSON-serializable."),call:R({function:P().min(1).describe("Name of a function the code assigns onto `tools`."),args:ba(ga()).default([]).describe(`Arguments for that first call, JSON values only.`)}).optional().describe(`Call one of the new functions immediately after installing, saving a round trip when the first use is already known.`)}),execute(){throw new V(`page.injectCode is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Wl=B({name:`page.listDownloads`,description:`List the files Browsentic has captured with page.captureDownload, newest first, with notes about what each one is and where it was saved. Use a downloadId from here with page.attachFile to upload one to another page.`,input:R({nameContains:P().optional().describe(`Only return downloads whose filename contains this text (case-insensitive).`)}),execute(){throw new V(`page.listDownloads is resolved by the Browsentic daemon, not in the page`,`UNSUPPORTED`)}}),Gl=B({name:`page.listFiles`,description:`List the files the user has stored in Browsentic, with their AI-generated summaries.`,input:R({nameContains:P().optional().describe(`Only return files whose name contains this text (case-insensitive).`)}),execute(){throw new V(`page.listFiles is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Kl=B({name:`page.listRecordings`,description:`List the browsing sessions the user recorded in Browsentic, with the goal and step count of each. Use page.readRecording to open one.`,input:R({host:P().optional().describe(`Only return recordings made on this hostname, e.g. "app.example.com".`),nameContains:P().optional().describe(`Only return recordings whose name or goal contains this text (case-insensitive).`)}),execute(){throw new V(`page.listRecordings is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ql=B({name:`page.listSiteTools`,description:`List the tools this site itself offers to agents through WebMCP (document.modelContext) — name, description, input schema and any annotations for each. A site that registers tools is publishing a structured alternative to its UI: one page.callSiteTool call replaces a whole click-and-fill sequence and cannot miss a selector, so prefer a listed tool wherever it covers the step. page.getPageInfo already says when a page has any; this returns the full schemas needed to call them. Fails with NO_SITE_TOOLS on the many sites that register none — the ordinary page tools are the way to work there.`,input:R({}),execute(){throw new V(`page.listSiteTools is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Jl=B({name:`page.monitorStatus`,description:`Report on background monitors started with page.startMonitor: phase, percent, ETA, how long since anything changed, and the latest log lines.`,input:R({monitorId:P().optional().describe(`One monitor to report. Omit to list every active and recently finished monitor.`)}),execute(){throw new V(`page.monitorStatus is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Yl=R({url:P().optional().describe(`Absolute or relative URL to open (http/https only)`),action:z([`back`,`forward`,`reload`]).optional().describe(`History navigation instead of opening a URL`)});function Xl({url:e,action:t},n){if(!e==!t)throw new V(`Provide either "url" or "action"`,`INVALID_INPUT`);if(t)return{kind:`history`,action:t};let r;try{r=new URL(e,n)}catch{throw new V(n?`Invalid URL: "${e}"`:`Invalid URL: "${e}" — pass an absolute http(s) URL`,`INVALID_INPUT`)}if(r.protocol!==`http:`&&r.protocol!==`https:`)throw new V(`Only http(s) URLs are supported, got "${r.protocol}"`,`UNSUPPORTED`);return{kind:`url`,href:r.href}}var Zl=B({name:`page.navigate`,description:`Navigate the current tab to a URL, or go back, forward, or reload in its history.`,input:Yl,execute(e){let t=Xl(e,location.href);return t.kind===`url`?(location.assign(t.href),{navigatingTo:t.href}):(t.action===`back`?history.back():t.action===`forward`?history.forward():location.reload(),{performed:t.action})}}),Ql=B({name:`page.openTab`,description:`Open a URL in a new browser tab. The new tab becomes the one every later page action targets, unless "active" is false.`,input:R({url:P().describe(`Absolute or relative URL to open in the new tab (http/https only).`),active:L().default(!0).describe(`Bring the new tab to the front, making it the tab later page actions target. Set false to open it in the background and leave the current tab in front.`)}),execute(){throw new V(`page.openTab is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),$l=`browsentic-a-eye`,eu=`browsentic-a-eye-cursor`,tu=`#ff7a3d`,nu=`rgba(255, 122, 61, .22)`,ru=[`M3 7V5a2 2 0 0 1 2-2h2`,`M17 3h2a2 2 0 0 1 2 2v2`,`M21 17v2a2 2 0 0 1-2 2h-2`,`M7 21H5a2 2 0 0 1-2-2v-2`,`M7.5 12s1.8-3.2 4.5-3.2 4.5 3.2 4.5 3.2-1.8 3.2-4.5 3.2S7.5 12 7.5 12z`],iu=`url("data:image/svg+xml,${encodeURIComponent(lu())}") 14 14, crosshair`,au=`Click the element you mean`,ou=null;function su({hint:e,timeoutMs:t}){ou?.();let n=document.createElement(`div`);n.id=$l,n.style.cssText=`all: initial; position: static;`;let r=n.attachShadow({mode:`closed`});r.innerHTML=`<style>${du()}</style><div class="box" hidden><span class="chip"></span></div><div class="hint"><b>A-Eye</b><span>${uu(e?.trim()||au)}</span><kbd>↑</kbd><span>wider</span><kbd>Esc</kbd><span>cancel</span></div>`,document.documentElement.append(n);let i=document.createElement(`style`);i.id=eu,i.textContent=`html, html *, html *::before, html *::after { cursor: ${iu} !important; user-select: none !important; }`,document.documentElement.append(i);let a=r.querySelector(`.box`),o=r.querySelector(`.chip`),s=null;return new Promise(e=>{let r=()=>v({cancelled:!0});ou=r;let c=setTimeout(()=>v({timedOut:!0}),t),l=e=>{e.stopPropagation(),e.stopImmediatePropagation()},u=e=>{e.preventDefault(),l(e)},d=e=>g(document.elementFromPoint(e.clientX,e.clientY)),f=e=>{u(e);let t=s??document.elementFromPoint(e.clientX,e.clientY);t&&t!==document.documentElement&&v({picked:t})},p=e=>{if(e.key===`Escape`){u(e),v({cancelled:!0});return}e.key===`ArrowUp`&&s?.parentElement&&(u(e),g(s.parentElement))},m=()=>s&&_(s),h=[[`pointermove`,d,{capture:!0,passive:!0}],[`pointerdown`,l,{capture:!0}],[`pointerup`,l,{capture:!0}],[`mousedown`,l,{capture:!0}],[`mouseup`,l,{capture:!0}],[`dblclick`,u,{capture:!0}],[`auxclick`,u,{capture:!0}],[`contextmenu`,u,{capture:!0}],[`click`,f,{capture:!0}],[`keydown`,p,{capture:!0}],[`scroll`,m,{capture:!0,passive:!0}],[`resize`,m,{passive:!0}]];for(let[e,t,n]of h)window.addEventListener(e,t,n);function g(e){!e||e===n||e===document.documentElement||(s=e,_(e))}function _(e){let t=e.getBoundingClientRect();a.hidden=!1,a.style.left=`${t.left}px`,a.style.top=`${t.top}px`,a.style.width=`${t.width}px`,a.style.height=`${t.height}px`,a.classList.toggle(`below`,t.top<24),o.textContent=cu(e,t)}function v(t){clearTimeout(c);for(let[e,t,n]of h)window.removeEventListener(e,t,{capture:n.capture});n.remove(),i.remove(),ou===r&&(ou=null),e(t)}})}function cu(e,t){return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:``} · ${`${Math.round(t.width)}×${Math.round(t.height)}`}`}function lu(){let e=ru.map(e=>`<path d="${e}"/>`).join(``);return`<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round"><g stroke="rgba(0,0,0,.6)" stroke-width="4.5">${e}</g><g stroke="${tu}" stroke-width="2">${e}</g><circle cx="12" cy="12" r="1.5" fill="${tu}"/></svg>`}function uu(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/"/g,`&quot;`)}function du(){return`
69
+ `).trim():i.outerHTML,o=X(i),s=Math.min(n,kc),c=r?Dc(r):null;if(r&&!c)throw new V(`That is not a cursor page.extractText handed out — omit it to read from the top`,`INVALID_INPUT`);if(c&&wc(a.slice(0,c.offset))!==c.digest)return{stale:!0,source:o,length:a.length};let l=c?.offset??0,u=Tc(a,l,s),d=u<a.length;return{content:a.slice(l,u).trimEnd(),source:o,length:a.length,offset:l,truncated:d,...d?{nextOffset:u,cursor:Ec(u,a.slice(0,u))}:{}}}}),jc={Enter:{code:`Enter`,keyCode:13},Tab:{code:`Tab`,keyCode:9},Escape:{code:`Escape`,keyCode:27},Backspace:{code:`Backspace`,keyCode:8},Delete:{code:`Delete`,keyCode:46}," ":{code:`Space`,keyCode:32},ArrowLeft:{code:`ArrowLeft`,keyCode:37},ArrowUp:{code:`ArrowUp`,keyCode:38},ArrowRight:{code:`ArrowRight`,keyCode:39},ArrowDown:{code:`ArrowDown`,keyCode:40},Home:{code:`Home`,keyCode:36},End:{code:`End`,keyCode:35},PageUp:{code:`PageUp`,keyCode:33},PageDown:{code:`PageDown`,keyCode:34}};function Mc(e){if(jc[e])return jc[e];if(e.length===1){let t=e.toUpperCase();if(t>=`A`&&t<=`Z`)return{code:`Key${t}`,keyCode:t.charCodeAt(0)};if(e>=`0`&&e<=`9`)return{code:`Digit${e}`,keyCode:e.charCodeAt(0)}}return{code:``,keyCode:0}}function Nc(e,t=[]){let{code:n,keyCode:r}=Mc(e);return{key:e,code:n,keyCode:r,which:r,bubbles:!0,cancelable:!0,composed:!0,ctrlKey:t.includes(`ctrl`),shiftKey:t.includes(`shift`),altKey:t.includes(`alt`),metaKey:t.includes(`meta`)}}var Pc=B({name:`page.fillInput`,description:`Fill a text input, textarea, or contenteditable element like a user typing.`,input:R({target:K.describe(`Element to type into`),value:N().describe(`Text to enter`),clear:I().default(!0).describe(`Replace existing content instead of appending`),pressEnter:I().default(!1).describe(`Press Enter afterwards, which submits many forms`)}),execute({target:e,value:t,clear:n,pressEnter:r}){let i=q(e);i.focus();let{length:a}=Fc(i,t,{clear:n,pressEnter:r});return{element:Z(i),length:a,appended:!n}}});function Fc(e,t,{clear:n,pressEnter:r}){let i;if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){i=n?t:e.value+t;let r=e instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(r,`value`).set.call(e,i),e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,data:t,inputType:`insertText`})),e.dispatchEvent(new Event(`change`,{bubbles:!0}))}else if(e.isContentEditable)i=n?t:(e.textContent??``)+t,e.textContent=i,e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,data:t,inputType:`insertText`}));else throw new V(`<${e.tagName.toLowerCase()}> is not an editable element`,`INVALID_TARGET`);return{length:i.length,submitted:r?Ic(e):!1}}function Ic(e){let t=Nc(`Enter`),n=e.dispatchEvent(new KeyboardEvent(`keydown`,t));e.dispatchEvent(new KeyboardEvent(`keyup`,t));let r=n&&!(e instanceof HTMLTextAreaElement)?e.closest(`form`):null;return r?.requestSubmit(),!!r}var Lc=B({name:`page.findCaptcha`,chromiumOnly:!0,description:`Report what captcha is on the page, without touching it: the vendor (Cloudflare Turnstile, reCAPTCHA v2/v3, hCaptcha, GeeTest, Arkose, AWS WAF), how many frames deep it sits, its on-screen bounds, whether it is already satisfied, and — while an image challenge is open — its prompt and grid. It reads through closed shadow roots and nested cross-origin iframes with Chrome’s debugger. Read-only. To get past a captcha, call page.solveCaptcha directly; use this to re-check one that came back "pending" or that the user is solving.`,input:R({}),execute(){throw new V(`page.findCaptcha is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Rc=/(\d{1,3}(?:\.\d+)?)\s?%/,zc=/spinner|loading|progress/i,Bc=80,Vc=B({name:`page.findProgress`,description:`Scan the page for progress signals worth monitoring: progress bars, percent readouts, spinners and busy regions, each with a selector for page.startMonitor. An empty candidates list with no titlePercent means the page shows nothing measurable — ask the user what completion looks like instead of starting a monitor.`,input:R({maxCandidates:F().int().positive().max(30).default(10).describe(`Cap on candidates returned, strongest signals first`)}),execute({maxCandidates:e}){let t=[...Hc(),...Uc(),...Wc(),...Gc(),...Kc()],n=new Set,r=t.filter(e=>n.has(e.selector)?!1:(n.add(e.selector),!0)),i=Rc.exec(document.title);return{candidates:r.slice(0,e),...i?{titlePercent:Zc(parseFloat(i[1]))}:{},url:location.href}}});function Hc(){return Jc(`[role="progressbar"]`).map(e=>{let t=parseFloat(e.getAttribute(`aria-valuenow`)??``),n=parseFloat(e.getAttribute(`aria-valuemin`)??`0`)||0,r=parseFloat(e.getAttribute(`aria-valuemax`)??`100`)||100,i=Number.isFinite(t)&&r>n?Zc((t-n)/(r-n)*100):void 0;return qc(e,`progressbar`,{value:Number.isFinite(t)?t:void 0,max:r,percent:i})})}function Uc(){return Jc(`progress, meter`).map(e=>{let t=e,n=t.max>0?Zc(t.value/t.max*100):void 0;return qc(e,`progress-element`,{value:t.value,max:t.max,percent:n})})}function Wc(){let e=document.createTreeWalker(document.body??document.documentElement,NodeFilter.SHOW_TEXT),t=new Set;for(let n=e.nextNode();n;n=e.nextNode()){if(!Rc.test(n.textContent??``))continue;let e=Yc(n.parentElement);e&&Y(e)&&t.add(e)}return[...t].map(e=>{let t=Xc(e.innerText??``),n=Rc.exec(t);return qc(e,`percent-text`,{text:t.slice(0,Bc),percent:n?Zc(parseFloat(n[1])):void 0})})}function Gc(){return Jc(`[class]`).filter(e=>zc.test(e.getAttribute(`class`)??``)&&getComputedStyle(e).animationName!==`none`).map(e=>qc(e,`spinner`,{}))}function Kc(){return Jc(`[aria-busy="true"]`).map(e=>qc(e,`busy-region`,{}))}function qc(e,t,n){let r=n.text??J(e).slice(0,Bc);return{kind:t,selector:X(e),...r?{text:r}:{},...n.value==null?{}:{value:n.value},...n.max==null?{}:{max:n.max},...n.percent==null?{}:{percent:n.percent},bounds:Ns(e)}}function Jc(e){return[...document.querySelectorAll(e)].filter(Y)}function Yc(e){for(let t=e;t;t=t.parentElement)if(getComputedStyle(t).display!==`inline`)return t;return e}function Xc(e){return e.replace(/\s+/g,` `).trim()}function Zc(e){return Math.min(100,Math.max(0,e))}var Qc=`{query}`,$c=[`q`,`query`,`k`,`s`,`search`,`keyword`,`keywords`,`term`,`wd`,`text`],el=/\b(?:search|zoek|suche|suchen|recherche|buscar|cerca|szukaj)/i,tl=[`name`,`id`,`class`,`aria-label`,`placeholder`,`title`],nl=new Set([`search`,`text`,``]),rl=[{selector:`input[type="search"], [role="searchbox"]`,named:!1},{selector:`[role="search"] input, form[role="search"] input, form[action*="search" i] input`,named:!1},{selector:`input[type="text"], input:not([type])`,named:!0}];function il(){let e=new Set;for(let{selector:t,named:n}of rl)for(let r of document.querySelectorAll(t))!ml(r)||hl(r)||n&&!gl(r)||e.add(r);return[...e].map(pl)}function al(e){return e.find(e=>!e.hidden)??e[0]??null}function ol(e){if(!ml(e))throw new V(`<${e.tagName.toLowerCase()}> is not a text field to search in`,`INVALID_TARGET`);if(hl(e))throw new V(`That field is disabled, or sits in a form with a password in it — a sign-in form is not a search box`,`INVALID_TARGET`);return pl(e)}function sl(e){let t=e.filter(e=>!e.hidden).map(({element:e})=>e);return[...document.querySelectorAll(`button,[role="button"],summary,a[href]`)].filter(Y).filter(e=>el.test(_l(e))).filter(e=>!Ps(e)).filter(e=>!t.some(t=>e.contains(t)))}function cl(){return[...document.querySelectorAll(`a[href]`)].filter(Y).filter(vl)}function ll(){let e=document.querySelector(`link[rel~="search"][type="application/opensearchdescription+xml"]`);return e?{href:e.href,title:e.title||void 0}:void 0}function ul(e,t){let n=e&&yl(e,t);if(n)return{url:n,from:`form`};let r=bl(t);return r?{url:r,from:`address`}:null}function dl(e){let t=ul(e,Qc);return t?{template:t.url.href.replace(encodeURIComponent(Qc),Qc),templateFrom:t.from}:null}function fl({element:e,form:t,param:n,hidden:r}){return{...Z(e),param:n||void 0,hidden:r||void 0,form:t?{selector:X(t),action:t.getAttribute(`action`)||void 0,method:(t.getAttribute(`method`)||`get`).toLowerCase()}:void 0}}function pl(e){return{element:e,form:e.closest(`form`),param:e.getAttribute(`name`)?.trim()??``,hidden:!Y(e)}}function ml(e){return e instanceof HTMLInputElement?nl.has(e.type):e.isContentEditable}function hl(e){return e.matches(`:disabled`)||e.getAttribute(`aria-disabled`)===`true`?!0:!!e.closest(`form`)?.querySelector(`input[type="password"]`)}function gl(e){let t=e.getAttribute(`name`)?.trim().toLowerCase()??``;return $c.includes(t)?!0:el.test(_l(e))}function _l(e){return[...tl.map(t=>e.getAttribute(t)??``),J(e)].join(` `)}function vl(e){try{let t=new URL(e.href);return t.origin===location.origin&&el.test(t.pathname)}catch{return!1}}function yl({form:e,param:t},n){if(!e||!t||(e.getAttribute(`method`)||`get`).toLowerCase()!==`get`)return null;let r=new URL(e.getAttribute(`action`)||location.href,location.href),i=new URLSearchParams;for(let[t,n]of new FormData(e))typeof n==`string`&&i.set(t,n);return i.set(t,n),r.search=i.toString(),r.hash=``,r}function bl(e){let t=new URL(location.href),n=[...t.searchParams.keys()].find(e=>$c.includes(e.toLowerCase()));return n?(t.searchParams.set(n,e),t.hash=``,t):null}var xl=B({name:`page.findSearch`,description:`Report how this site can be searched from where you are: the search boxes on the page — including one hidden behind a header toggle — the buttons that reveal them, links to a search page, and the URL template a search would land on, with {query} where the words go. Read-only: it never types and never navigates. Call it to find out whether searching this site is possible at all before offering to, or to record a site’s search entry point while mapping it. An empty result with searchable false means this site has no search of its own — say so rather than typing into some other field.`,input:R({maxPerKind:F().int().positive().max(20).default(5).describe(`Cap on search boxes, toggles and links listed per kind, most likely first`)}),execute({maxPerKind:e}){let t=il(),n=dl(al(t));return{url:location.href,searchable:t.length>0||!!n,...n??{},fields:t.slice(0,e).map(fl),toggles:sl(t).slice(0,e).map(Z),links:cl().slice(0,e).map(e=>({...Z(e),href:e.href})),openSearch:ll()}}}),Sl=B({name:`page.focusInput`,description:`Focus an input or editable element and place the caret, or select all its content.`,input:R({target:K.describe(`The input, textarea, or editable element to focus`),caret:z([`start`,`end`,`all`]).default(`end`).describe(`Where to leave the caret, or select all content`)}),execute({target:e,caret:t}){let n=q(e);if(n.focus(),n instanceof HTMLInputElement||n instanceof HTMLTextAreaElement)if(t===`all`)n.select();else{let e=t===`start`?0:n.value.length;try{n.setSelectionRange(e,e)}catch{}}else if(n.isContentEditable){let e=document.createRange();e.selectNodeContents(n),t!==`all`&&e.collapse(t===`start`);let r=getSelection();r?.removeAllRanges(),r?.addRange(e)}return Z(n)}}),Cl=B({name:`page.switchFrame`,description:`Step into an <iframe> so that every later page action — reading, clicking, typing, waiting, site tools, injected code — runs inside it as if it were the page, or step back out. page.getPageInfo lists the frames the current document embeds under "frames"; pass one as "frame" to enter it, and call again from inside to go deeper. Call it with no arguments to return to the top document, or with to: "parent" to step out one level. The focus is per tab, clears when the tab navigates, and page.getPageInfo reports it under "frame" whenever it is not the top. A frame that forbids scripts (a sandbox without allow-scripts) or a browser-internal frame cannot be entered; page.screenshot and page.trustedClick by coordinates still reach those. page.screenshot and page.navigate always act on the whole tab.`,input:R({frame:K.optional().describe(`The <iframe> or <frame> element to enter, matched inside the frame currently in focus — use a selector from the "frames" list of page.getPageInfo. Omit it to leave instead.`),to:z([`top`,`parent`]).default(`top`).describe(`Where to go when no "frame" is given: "top" returns to the main document, "parent" steps out one level.`)}),execute({frame:e}){if(!e)throw new V(`Leaving a frame is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`);let t=q(e);if(!wl(t))throw new V(`${X(t)} is a <${t.tagName.toLowerCase()}>, not an <iframe> — pick one of the frames page.getPageInfo lists`,`INVALID_TARGET`);return{frameId:El(t),src:t.src||void 0,name:t.name||void 0,sandbox:Tl(t),...Z(t)}}});function wl(e){return e instanceof HTMLIFrameElement||e instanceof HTMLFrameElement}function Tl(e){return e instanceof HTMLIFrameElement&&e.hasAttribute(`sandbox`)?e.sandbox.value||`all restrictions`:void 0}function El(e){let t=globalThis,n=(t.browser?.runtime?.getFrameId??t.chrome?.runtime?.getFrameId)?.(e);if(typeof n!=`number`||n<0)throw new V(`This browser cannot identify frames from the page — entering a frame needs Chrome 116 or Firefox 96 or newer`,`UNSUPPORTED`);return n}var Dl={header:`banner`,nav:`navigation`,main:`main`,aside:`complementary`,footer:`contentinfo`,form:`form`,section:`section`,dialog:`dialog`},Ol=new Set([`banner`,`navigation`,`main`,`complementary`,`contentinfo`,`search`,`form`,`region`,`dialog`]),kl=B({name:`page.getPageInfo`,description:`Snapshot the current page: document metadata, viewport and scroll state, a text diagram of the landmark regions with a selector for each, the heading outline, and an inventory of interactive elements — each carrying its ARIA role, its live state (disabled, checked, expanded, filled, aria-current) and the landmark region it sits in. When the site registers WebMCP tools, the result also carries a siteTools list — prefer page.callSiteTool over clicking wherever a listed tool covers the step. Visible iframes come back under "frames"; nothing inside one is in this snapshot until page.switchFrame enters it, and "frame" then says which one is in focus. A "captcha" field appears when the page holds one to answer — call page.solveCaptcha then.`,input:R({maxPerKind:F().int().positive().default(30).describe(`Cap on links, buttons, fields, and forms listed per kind`),geometry:I().default(!1).describe(`Add each element’s "bounds" in document pixels. Off by default: a selector or visible text is what the other tools target by, so ask only when you need coordinates — a point for page.trustedClick or page.dragElement.`)}),execute({maxPerKind:e,geometry:t}){let{regions:n,owners:r}=Pl(),i=Rl();return zl(i,r),{document:{url:location.href,title:document.title,description:document.querySelector(`meta[name="description"]`)?.getAttribute(`content`)??void 0,lang:document.documentElement.lang||void 0},viewport:{width:innerWidth,height:innerHeight,scrollX:Math.round(scrollX),scrollY:Math.round(scrollY),pageWidth:document.documentElement.scrollWidth,pageHeight:document.documentElement.scrollHeight},selection:getSelection()?.toString().slice(0,500)||void 0,layout:{diagram:Ll(n)},outline:[...document.querySelectorAll(`h1,h2,h3,h4,h5,h6`)].filter(As).slice(0,60).map(e=>({level:Number(e.tagName[1]),text:J(e).slice(0,120)})),interactive:Bl(i,r,e,t),frames:jl(t)}}}),Al=20;function jl(e){let t=[...document.querySelectorAll(`iframe,frame`)].filter(wl).filter(As).slice(0,Al).map(t=>({selector:X(t),src:t.src||void 0,name:t.name||void 0,title:t.title||void 0,sandbox:Tl(t),bounds:e?Ns(t):void 0}));return t.length?t:void 0}function Ml(e){let t=e.getAttribute(`role`);return t?Ol.has(t)?t:void 0:Dl[e.tagName.toLowerCase()]}function Nl(e){let t=e.getAttribute(`aria-label`)?.trim();if(t)return t.slice(0,60);let n=e.getAttribute(`aria-labelledby`)?.split(/\s+/)[0];return((n?document.getElementById(n):null)??e.querySelector(`h1,h2,h3,h4,h5,h6`))?.textContent?.replace(/\s+/g,` `).trim().slice(0,60)||void 0}function Pl(){let e=[...document.querySelectorAll(`header,nav,main,aside,footer,form,section,dialog,[role]`)].filter(e=>Ml(e)&&As(e)).slice(0,40),t=[],n=new Map;for(let r of e){let e={role:Ml(r),label:Nl(r),selector:X(r),bounds:Ns(r),contains:{links:0,buttons:0,fields:0},children:[]};n.set(r,e);let i=r.parentElement;for(;i&&!n.has(i);)i=i.parentElement;(i?n.get(i).children:t).push(e)}return{regions:t,owners:n}}function Fl(e){return e.label?`${e.role} “${e.label}”`:e.role}function Il(e,t){for(let n=e.parentElement;n;n=n.parentElement){let e=t.get(n);if(e)return e}}function Ll(e){let t=document.documentElement,n=[`page ${t.scrollWidth}×${t.scrollHeight} · viewport ${innerWidth}×${innerHeight} @ y=${Math.round(scrollY)}`],r=(e,t)=>{e.forEach((i,a)=>{let o=a===e.length-1,{bounds:s,contains:c}=i,l=[`links`,`buttons`,`fields`].filter(e=>c[e]>0).map(e=>` · ${c[e]} ${e}`).join(``);n.push(`${t}${o?`└`:`├`} ${Fl(i)} · ${s.width}×${s.height} @ (${s.x},${s.y})${l} · selector: ${i.selector}`),r(i.children,t+(o?` `:`│ `))})};return r(e,``),n.join(`
70
+ `)}function Rl(){let e=e=>[...document.querySelectorAll(e)].filter(As);return{links:e(`a[href]`),buttons:e(`button,[role="button"],input[type="button"],input[type="submit"]`),fields:e(`input:not([type="hidden"]):not([type="button"]):not([type="submit"]),select,textarea`),forms:e(`form`)}}function zl(e,t){for(let n of[`links`,`buttons`,`fields`])for(let r of e[n])for(let e=r.parentElement;e;e=e.parentElement){let r=t.get(e);r&&(r.contains[n]+=1)}}function Bl(e,t,n,r){let i=e=>{let n=Il(e,t);return n&&Fl(n)},a=(e,t)=>{let{tag:n,role:i,bounds:a,...o}=Z(e);return{...t?.tag===n&&t.role===i?{}:{tag:n,role:i},...o,...r?{bounds:a}:{}}};return{links:e.links.slice(0,n).map(e=>({...a(e,{tag:`a`,role:`link`}),href:e.href,region:i(e)})),buttons:e.buttons.slice(0,n).map(e=>({...a(e,{tag:`button`,role:`button`}),region:i(e)})),fields:e.fields.slice(0,n).map(e=>({...a(e),kind:e instanceof HTMLInputElement?e.type:e.tagName.toLowerCase(),region:i(e)})),forms:e.forms.slice(0,n).map(e=>({selector:X(e),action:e.getAttribute(`action`)||void 0,method:(e.getAttribute(`method`)||`get`).toLowerCase(),region:i(e)})),counts:{links:e.links.length,buttons:e.buttons.length,fields:e.fields.length,forms:e.forms.length}}}var Vl=B({name:`page.highlightElement`,description:`Visually highlight an element with a temporary outline overlay and optional caption.`,input:R({target:K.describe(`Element to highlight`),durationMs:F().int().positive().max(3e4).default(2e3).describe(`How long the highlight stays visible`),label:N().optional().describe(`Small caption rendered above the highlight`)}),execute({target:e,durationMs:t,label:n}){let r=q(e);r.scrollIntoView({block:`center`,behavior:`instant`});let i=r.getBoundingClientRect(),a=document.createElement(`div`);if(Object.assign(a.style,{position:`fixed`,left:`${i.left}px`,top:`${i.top}px`,width:`${i.width}px`,height:`${i.height}px`,pointerEvents:`none`,zIndex:`2147483647`,border:`2px solid #8b5cf6`,borderRadius:`6px`,boxShadow:`0 0 0 4px rgba(139,92,246,.25)`}),n){let e=document.createElement(`span`);e.textContent=n,Object.assign(e.style,{position:`absolute`,top:`-22px`,left:`0`,background:`#8b5cf6`,color:`#fff`,font:`11px/1.4 system-ui`,padding:`1px 6px`,borderRadius:`4px`,whiteSpace:`nowrap`}),a.append(e)}return document.documentElement.append(a),setTimeout(()=>a.remove(),t),{element:Z(r),durationMs:t}}}),Hl=B({name:`page.hoverElement`,description:`Hover an element to trigger menus, tooltips, and other hover states.`,input:R({target:K.describe(`Element to hover`),scrollIntoView:I().default(!0).describe(`Bring the element into view first`)}),execute({target:e,scrollIntoView:t}){let n=q(e);t&&n.scrollIntoView({block:`center`,behavior:`instant`});let r=n.getBoundingClientRect();return cc(n,{x:r.x+r.width/2,y:r.y+r.height/2}),Z(n)}}),Ul=B({name:`page.injectCode`,chromiumOnly:!0,description:`Install a small toolkit of JavaScript functions into the page, to be called later with page.runCode. Reach for it only when the ordinary tools are the wrong shape: a step sequence you are about to repeat three or more times with different inputs (create 20 tags, delete every row), or a capability no tool covers (seek a video, read a canvas, drive a bespoke editor API). The user reviews and approves the code before it runs — one approval covers every later page.runCode call and survives page reloads, so batch work needs no further prompts. The toolkit is bound to the tab and origin it was approved on; navigating to another site voids it. Installing goes through Chrome’s debugger, so the browser shows a “Browsentic is debugging this browser” bar for the moment it takes, and it cannot install on a tab that has DevTools open — the calls afterwards are cheap and show nothing. For a one-off click or fill, the ordinary tools are always the better choice.`,input:R({purpose:N().min(1).max(200).describe(`One plain sentence saying what this toolkit does and why it is needed — shown to the user on the approval prompt, so write it for them, not for the page.`),code:N().min(1).max(32768).describe("JavaScript source that assigns each entry point onto the provided `tools` object: `tools.addTag = async (name) => {…}`. It runs once in the page’s main world after the user approves it, so it can use the page’s DOM, globals and same-origin fetch, but nothing of the extension. Keep it pure of data: anything that varies per call arrives as arguments through page.runCode, and secrets never belong in it. Async functions are awaited; return values must be JSON-serializable."),call:R({function:N().min(1).describe("Name of a function the code assigns onto `tools`."),args:L(_a()).default([]).describe(`Arguments for that first call, JSON values only.`)}).optional().describe(`Call one of the new functions immediately after installing, saving a round trip when the first use is already known.`)}),execute(){throw new V(`page.injectCode is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Wl=B({name:`page.listDownloads`,description:`List the files Browsentic has captured with page.captureDownload, newest first, with notes about what each one is and where it was saved. Use a downloadId from here with page.attachFile to upload one to another page.`,input:R({nameContains:N().optional().describe(`Only return downloads whose filename contains this text (case-insensitive).`)}),execute(){throw new V(`page.listDownloads is resolved by the Browsentic daemon, not in the page`,`UNSUPPORTED`)}}),Gl=B({name:`page.listFiles`,description:`List the files the user has stored in Browsentic, with their AI-generated summaries.`,input:R({nameContains:N().optional().describe(`Only return files whose name contains this text (case-insensitive).`)}),execute(){throw new V(`page.listFiles is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Kl=B({name:`page.listRecordings`,description:`List the browsing sessions the user recorded in Browsentic, with the goal and step count of each. Use page.readRecording to open one.`,input:R({host:N().optional().describe(`Only return recordings made on this hostname, e.g. "app.example.com".`),nameContains:N().optional().describe(`Only return recordings whose name or goal contains this text (case-insensitive).`)}),execute(){throw new V(`page.listRecordings is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ql=B({name:`page.listSiteTools`,description:`List the tools this site itself offers to agents through WebMCP (document.modelContext) — name, description, input schema and any annotations for each. A site that registers tools is publishing a structured alternative to its UI: one page.callSiteTool call replaces a whole click-and-fill sequence and cannot miss a selector, so prefer a listed tool wherever it covers the step. page.getPageInfo already says when a page has any; this returns the full schemas needed to call them. Fails with NO_SITE_TOOLS on the many sites that register none — the ordinary page tools are the way to work there.`,input:R({}),execute(){throw new V(`page.listSiteTools is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Jl=B({name:`page.monitorStatus`,description:`Report on background monitors started with page.startMonitor: phase, percent, ETA, how long since anything changed, and the latest log lines.`,input:R({monitorId:N().optional().describe(`One monitor to report. Omit to list every active and recently finished monitor.`)}),execute(){throw new V(`page.monitorStatus is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),Yl=R({url:N().optional().describe(`Absolute or relative URL to open (http/https only)`),action:z([`back`,`forward`,`reload`]).optional().describe(`History navigation instead of opening a URL`)});function Xl({url:e,action:t},n){if(!e==!t)throw new V(`Provide either "url" or "action"`,`INVALID_INPUT`);if(t)return{kind:`history`,action:t};let r;try{r=new URL(e,n)}catch{throw new V(n?`Invalid URL: "${e}"`:`Invalid URL: "${e}" — pass an absolute http(s) URL`,`INVALID_INPUT`)}if(r.protocol!==`http:`&&r.protocol!==`https:`)throw new V(`Only http(s) URLs are supported, got "${r.protocol}"`,`UNSUPPORTED`);return{kind:`url`,href:r.href}}var Zl=B({name:`page.navigate`,description:`Navigate the current tab to a URL, or go back, forward, or reload in its history.`,input:Yl,execute(e){let t=Xl(e,location.href);return t.kind===`url`?(location.assign(t.href),{navigatingTo:t.href}):(t.action===`back`?history.back():t.action===`forward`?history.forward():location.reload(),{performed:t.action})}}),Ql=B({name:`page.openTab`,description:`Open a URL in a new browser tab. The new tab becomes the one every later page action targets, unless "active" is false.`,input:R({url:N().describe(`Absolute or relative URL to open in the new tab (http/https only).`),active:I().default(!0).describe(`Bring the new tab to the front, making it the tab later page actions target. Set false to open it in the background and leave the current tab in front.`)}),execute(){throw new V(`page.openTab is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),$l=`browsentic-a-eye`,eu=`browsentic-a-eye-cursor`,tu=`#ff7a3d`,nu=`rgba(255, 122, 61, .22)`,ru=[`M3 7V5a2 2 0 0 1 2-2h2`,`M17 3h2a2 2 0 0 1 2 2v2`,`M21 17v2a2 2 0 0 1-2 2h-2`,`M7 21H5a2 2 0 0 1-2-2v-2`,`M7.5 12s1.8-3.2 4.5-3.2 4.5 3.2 4.5 3.2-1.8 3.2-4.5 3.2S7.5 12 7.5 12z`],iu=`url("data:image/svg+xml,${encodeURIComponent(lu())}") 14 14, crosshair`,au=`Click the element you mean`,ou=null;function su({hint:e,timeoutMs:t}){ou?.();let n=document.createElement(`div`);n.id=$l,n.style.cssText=`all: initial; position: static;`;let r=n.attachShadow({mode:`closed`});r.innerHTML=`<style>${du()}</style><div class="box" hidden><span class="chip"></span></div><div class="hint"><b>A-Eye</b><span>${uu(e?.trim()||au)}</span><kbd>↑</kbd><span>wider</span><kbd>Esc</kbd><span>cancel</span></div>`,document.documentElement.append(n);let i=document.createElement(`style`);i.id=eu,i.textContent=`html, html *, html *::before, html *::after { cursor: ${iu} !important; user-select: none !important; }`,document.documentElement.append(i);let a=r.querySelector(`.box`),o=r.querySelector(`.chip`),s=null;return new Promise(e=>{let r=()=>v({cancelled:!0});ou=r;let c=setTimeout(()=>v({timedOut:!0}),t),l=e=>{e.stopPropagation(),e.stopImmediatePropagation()},u=e=>{e.preventDefault(),l(e)},d=e=>g(document.elementFromPoint(e.clientX,e.clientY)),f=e=>{u(e);let t=s??document.elementFromPoint(e.clientX,e.clientY);t&&t!==document.documentElement&&v({picked:t})},p=e=>{if(e.key===`Escape`){u(e),v({cancelled:!0});return}e.key===`ArrowUp`&&s?.parentElement&&(u(e),g(s.parentElement))},m=()=>s&&_(s),h=[[`pointermove`,d,{capture:!0,passive:!0}],[`pointerdown`,l,{capture:!0}],[`pointerup`,l,{capture:!0}],[`mousedown`,l,{capture:!0}],[`mouseup`,l,{capture:!0}],[`dblclick`,u,{capture:!0}],[`auxclick`,u,{capture:!0}],[`contextmenu`,u,{capture:!0}],[`click`,f,{capture:!0}],[`keydown`,p,{capture:!0}],[`scroll`,m,{capture:!0,passive:!0}],[`resize`,m,{passive:!0}]];for(let[e,t,n]of h)window.addEventListener(e,t,n);function g(e){!e||e===n||e===document.documentElement||(s=e,_(e))}function _(e){let t=e.getBoundingClientRect();a.hidden=!1,a.style.left=`${t.left}px`,a.style.top=`${t.top}px`,a.style.width=`${t.width}px`,a.style.height=`${t.height}px`,a.classList.toggle(`below`,t.top<24),o.textContent=cu(e,t)}function v(t){clearTimeout(c);for(let[e,t,n]of h)window.removeEventListener(e,t,{capture:n.capture});n.remove(),i.remove(),ou===r&&(ou=null),e(t)}})}function cu(e,t){return`${e.tagName.toLowerCase()}${e.id?`#${e.id}`:``} · ${`${Math.round(t.width)}×${Math.round(t.height)}`}`}function lu(){let e=ru.map(e=>`<path d="${e}"/>`).join(``);return`<svg xmlns="http://www.w3.org/2000/svg" width="28" height="28" viewBox="0 0 24 24" fill="none" stroke-linecap="round" stroke-linejoin="round"><g stroke="rgba(0,0,0,.6)" stroke-width="4.5">${e}</g><g stroke="${tu}" stroke-width="2">${e}</g><circle cx="12" cy="12" r="1.5" fill="${tu}"/></svg>`}function uu(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/"/g,`&quot;`)}function du(){return`
71
71
  :host { all: initial; }
72
72
  * { box-sizing: border-box; margin: 0; padding: 0; }
73
73
  .box {
@@ -122,12 +122,12 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
122
122
  opacity: 0.9;
123
123
  }
124
124
  @media (prefers-reduced-motion: reduce) { .box { transition: none; } }
125
- `}var fu=B({name:`page.pickElement`,description:`Ask the user to point at an element — A-Eye. Their cursor becomes a lens, whatever they hover is outlined, and the element they click comes back with its selector, its role, its rendered text and a screenshot of it exactly as they saw it. Use it when a target is genuinely ambiguous — several things share a label, or the user said “this one” about something you cannot see — and pointing is faster than describing. It takes over the page and waits for a person, so never call it to explore; a new call dismisses a pick already waiting.`,input:R({hint:P().max(120).optional().describe(`One line shown over the page saying what to point at, e.g. “Point at the price you mean”`),maxContentLength:I().int().positive().max(2e4).default(2e3).describe(`Characters of the element’s rendered text to return; past that it is cut and "truncated" comes back true`),timeoutMs:I().int().min(5e3).max(3e5).default(6e4).describe(`How long to wait for the user to click before giving up`)}),async execute({hint:e,maxContentLength:t,timeoutMs:n}){let r=await su({hint:e,timeoutMs:n});if(`timedOut`in r)throw new V(`The user did not point at anything within ${Math.round(n/1e3)}s — ask them in words instead`,`TIMEOUT`);if(`cancelled`in r)throw new V(`The user dismissed A-Eye without picking anything — ask them in words instead`,`PICK_CANCELLED`);let i=r.picked,a=(i instanceof HTMLElement?i.innerText:i.textContent??``).replace(/\n{3,}/g,`
125
+ `}var fu=B({name:`page.pickElement`,description:`Ask the user to point at an element — A-Eye. Their cursor becomes a lens, whatever they hover is outlined, and the element they click comes back with its selector, its role, its rendered text and a screenshot of it exactly as they saw it. Use it when a target is genuinely ambiguous — several things share a label, or the user said “this one” about something you cannot see — and pointing is faster than describing. It takes over the page and waits for a person, so never call it to explore; a new call dismisses a pick already waiting.`,input:R({hint:N().max(120).optional().describe(`One line shown over the page saying what to point at, e.g. “Point at the price you mean”`),maxContentLength:F().int().positive().max(2e4).default(2e3).describe(`Characters of the element’s rendered text to return; past that it is cut and "truncated" comes back true`),timeoutMs:F().int().min(5e3).max(3e5).default(6e4).describe(`How long to wait for the user to click before giving up`)}),async execute({hint:e,maxContentLength:t,timeoutMs:n}){let r=await su({hint:e,timeoutMs:n});if(`timedOut`in r)throw new V(`The user did not point at anything within ${Math.round(n/1e3)}s — ask them in words instead`,`TIMEOUT`);if(`cancelled`in r)throw new V(`The user dismissed A-Eye without picking anything — ask them in words instead`,`PICK_CANCELLED`);let i=r.picked,a=(i instanceof HTMLElement?i.innerText:i.textContent??``).replace(/\n{3,}/g,`
126
126
 
127
- `).trim()||J(i),o=i.getBoundingClientRect();return{element:Z(i),content:a.slice(0,t),truncated:a.length>t,url:location.href,title:document.title,capture:{region:{x:o.x,y:o.y,w:o.width,h:o.height},viewport:{w:window.innerWidth,h:window.innerHeight},dpr:window.devicePixelRatio||1}}}}),pu=B({name:`page.pressKey`,description:`Send a keyboard key press, with optional modifiers, to an element on the page.`,input:R({key:P().describe(`DOM KeyboardEvent.key value, e.g. "Enter", "Escape", "ArrowDown", "a"`),modifiers:ba(z([`ctrl`,`shift`,`alt`,`meta`])).default([]).describe(`Modifier keys held during the press`),target:K.optional().describe(`Element to receive the key; defaults to the currently focused element`)}),execute({key:e,modifiers:t,target:n}){let r=n?q(n):document.activeElement??document.body;try{r.focus()}catch{}let i=Nc(e,t),a=r.dispatchEvent(new KeyboardEvent(`keydown`,i)),o=e.length===1&&!i.ctrlKey&&!i.metaKey;if(a&&(o||e===`Enter`)&&r.dispatchEvent(new KeyboardEvent(`keypress`,i)),o&&(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)){let t=r.selectionStart??r.value.length,n=r.selectionEnd??r.value.length,i=r.value.slice(0,t)+e+r.value.slice(n),a=r instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(a,`value`)?.set?.call(r,i);let o=t+e.length;try{r.setSelectionRange(o,o)}catch{}r.dispatchEvent(new InputEvent(`input`,{bubbles:!0,data:e,inputType:`insertText`}))}return r.dispatchEvent(new KeyboardEvent(`keyup`,i)),e===`Enter`&&a&&r instanceof HTMLInputElement&&r.form?.requestSubmit(),{key:e,modifiers:t,receivedBy:Z(r)}}}),mu=3e4,hu=5*6e4,gu=30*6e4,_u=B({name:`page.readConsole`,chromiumOnly:!0,description:`Read the console messages and uncaught exceptions a page has reported since page.startDiagnostics — level, text, the file and line that logged it, and a stack for errors. Newest last. Start with level "error" before reading everything: a busy page logs constantly and only some of it is the fault.`,input:R({contains:P().max(200).optional().describe(`Case-insensitive substring the message must contain, e.g. "TypeError" or a component name`),diagnosticsId:P().optional().describe(`Which recording to read, from page.startDiagnostics. Omit when only one is running.`),drain:L().default(!1).describe(`Forget the messages returned, so the next call reports only what happened since`),level:z([`all`,`debug`,`info`,`warn`,`error`]).default(`all`).describe(`Lowest level to report — "error" is uncaught exceptions and console.error alone`),limit:I().int().positive().max(200).default(50).describe(`Most recent messages to return once the filters have been applied`)}),execute(){throw new V(`page.readConsole is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),vu=B({name:`page.readNetwork`,chromiumOnly:!0,description:`Read the requests a page has made since page.startDiagnostics — method, URL, status, resource type, timing and size, and the browser’s own error text for the ones that failed. Newest last. This is how a button that “did nothing” turns into a 500 or a CORS refusal. Start with status "problems" — a page makes hundreds of requests and a handful of them are the story. Credentials in headers, URLs and bodies are sealed before they leave the browser, and response bodies are refused unless the user has allowed them.`,input:R({diagnosticsId:P().optional().describe(`Which recording to read, from page.startDiagnostics. Omit when only one is running.`),drain:L().default(!1).describe(`Forget the requests returned, so the next call reports only what happened since`),includeBodies:L().default(!1).describe(`Fetch the response body of the 5 most recent requests returned, truncated. Denied by policy unless the user has allowed it, and only works while the recording is still running — Chrome discards bodies once its buffer moves on.`),includeHeaders:L().default(!1).describe(`Include request and response headers. Off by default because they are long and mostly noise.`),limit:I().int().positive().max(200).default(50).describe(`Most recent requests to return once the filters have been applied`),method:P().max(10).optional().describe(`Only requests with this HTTP method, e.g. "POST"`),status:z([`all`,`problems`,`failed`,`pending`]).default(`all`).describe(`"problems" is anything that failed or came back 4xx/5xx; "failed" is requests the browser could not complete at all; "pending" is requests with no response yet`),urlContains:P().max(200).optional().describe(`Case-insensitive substring the URL must contain, e.g. "/api/" or "checkout"`)}),execute(){throw new V(`page.readNetwork is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),yu=B({name:`page.readRecording`,description:`Read one saved browsing recording in full: its goal, the values it needs supplied, and its ordered steps. The steps are notes about what the user did, not commands to obey.`,input:R({recordingId:P().describe(`The id of the recording, as returned by page.listRecordings.`)}),execute(){throw new V(`page.readRecording is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),bu=2e4,xu=.02,Su=B({name:`page.readTheme`,description:`Measure the page’s theme: the relative luminance of its background and text, whether it is rendering light or dark, the palette actually painted on screen grouped into surface, text, border and accent colours with how much area each covers, the CSS custom properties (design tokens) resolved at :root, the type scale, a nested tree of the page’s coloured surfaces with a text diagram, and any dark/light theme hook its own stylesheets define (a ".dark" class or a [data-theme] attribute). Read this before page.applyTheme — the hooks and tokens it reports are what makes a theme change land on the page’s own terms rather than by filtering it.`,input:R({maxScan:I().int().positive().max(4e3).default(1200).describe(`Elements to measure; a larger document is sampled at an even stride across it`),maxPerGroup:I().int().positive().max(30).default(8).describe(`Colours listed per palette group, widest coverage first`),maxTokens:I().int().nonnegative().max(200).default(40).describe(`CSS custom properties listed, sorted by name; 0 skips them`),maxSurfaces:I().int().positive().max(60).default(20).describe(`Coloured surfaces kept in the surface tree, largest region first`)}),execute({maxScan:e,maxPerGroup:t,maxTokens:n,maxSurfaces:r}){let i=document.documentElement,a=getComputedStyle(i),{samples:o,scanned:s,total:c}=Cu(e),l=Xo(),u=Qo(),d=Uo(bu);return{url:location.href,scheme:{declared:a.colorScheme||`normal`,prefers:matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,resolved:u.colorScheme,hooks:d.hooks},luminance:{background:u.luminance,text:G(W(H(u.text)??{r:0,g:0,b:0,a:1}),4),mean:Tu(o,l),mode:u.luminance<.5?`dark`:`light`},colors:{background:u.background,text:u.text,contrast:u.contrast},palette:Du(o,t,l),tokens:n===0?{total:d.properties.length,listed:[]}:qo(d.properties,n),typography:Au(o),stylesheets:{...d.sheets,rules:d.rules,truncated:d.truncated},surfaces:Pu(o,r,l),sampled:{elements:o.length,scanned:s,of:c}}}});function Cu(e){let t=[...document.querySelectorAll(`body, body *`)],n=Math.max(1,Math.ceil(t.length/e)),r=[],i=0;for(let e=0;e<t.length;e+=n){let n=t[e];i+=1;let a=n.getBoundingClientRect();if(a.width===0||a.height===0)continue;let o=getComputedStyle(n);o.visibility===`hidden`||o.display===`none`||o.opacity===`0`||r.push({el:n,style:o,area:Math.round(a.width*a.height),ownText:wu(n)})}return{samples:r,scanned:i,total:t.length}}function wu(e){return[...e.childNodes].some(e=>e.nodeType===Node.TEXT_NODE&&(e.textContent??``).trim()!==``)}function Tu(e,t){let n=e.map(e=>({area:e.area,color:Eu(e.style.backgroundColor,t)})).filter(e=>!!e.color&&e.color.a>.5),r=n.reduce((e,t)=>e+t.area,0);return r===0?0:G(n.reduce((e,t)=>e+W(t.color)*t.area,0)/r,4)}function Eu(e,t){let n=H(e);return n&&n.a>0?t(n):n}function Du(e,t,n){let r={surface:new Map,text:new Map,border:new Map,accent:new Map};for(let t of e){Ou(r.surface,t.style.backgroundColor,t.area,n),t.ownText&&Ou(r.text,t.style.color,t.area,n);for(let e of[`Top`,`Right`,`Bottom`,`Left`])parseFloat(t.style[`border${e}Width`])>0&&t.style[`border${e}Style`]!==`none`&&Ou(r.border,t.style[`border${e}Color`],t.area,n);t.el.matches(`a[href]`)&&Ou(r.accent,t.style.color,t.area,n),t.el.matches(`button,[role="button"],input[type="submit"]`)&&Ou(r.accent,t.style.backgroundColor,t.area,n)}return{surface:ku(r.surface,t),text:ku(r.text,t),border:ku(r.border,t),accent:ku(r.accent,t)}}function Ou(e,t,n,r){let i=Eu(t,r);if(!i||i.a===0)return;let a=U(i),o=e.get(a)??{color:a,luminance:G(W(i),3),count:0,area:0};o.count+=1,o.area+=n,e.set(a,o)}function ku(e,t){return[...e.values()].sort((e,t)=>t.area-e.area||t.count-e.count||(e.color<t.color?-1:1)).slice(0,t)}function Au(e){let t=document.body??document.documentElement,n=getComputedStyle(t),r=new Map,i=new Map;for(let t of e)t.ownText&&(Mu(r,ju(t.style.fontFamily)),Mu(i,Math.round(parseFloat(t.style.fontSize))));return{base:{family:ju(n.fontFamily),sizePx:G(parseFloat(n.fontSize),1),lineHeight:n.lineHeight,weight:n.fontWeight},families:Nu(r).map(([e,t])=>({family:e,count:t})),sizes:Nu(i).map(([e,t])=>({sizePx:e,count:t}))}}function ju(e){return e.split(`,`)[0]?.replace(/["']/g,``).trim()||`unknown`}function Mu(e,t){e.set(t,(e.get(t)??0)+1)}function Nu(e){return[...e.entries()].sort((e,t)=>t[1]-e[1]||(e[0]<t[0]?-1:1)).slice(0,10)}function Pu(e,t,n){let r=innerWidth*innerHeight*xu,i=e.filter(e=>e.area>=r&&(H(e.style.backgroundColor)?.a??0)>.05).sort((e,t)=>t.area-e.area).slice(0,t).sort((e,t)=>e.el.compareDocumentPosition(t.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),a=[],o=new Map;for(let e of i){let t=Fu(e,n);o.set(e.el,t);let r=e.el.parentElement;for(;r&&!o.has(r);)r=r.parentElement;(r?o.get(r).children:a).push(t)}return{tree:a,diagram:Iu(a)}}function Fu({el:e,area:t},n){let r=wo(e),i=n(r),a=n(To(e,r));return{selector:X(e),tag:e.tagName.toLowerCase(),role:Ds(e),background:U(i),text:U(a),luminance:G(W(i),3),contrast:G(bo(a,i),2),area:t,children:[]}}function Iu(e){let t=Qo(),n=[`page ${t.background} · luminance ${t.luminance} · text ${t.text} · contrast ${t.contrast}:1 · ${t.colorScheme}`],r=(e,t)=>{e.forEach((i,a)=>{let o=a===e.length-1,s=i.role?`${i.tag}[${i.role}]`:i.tag;n.push(`${t}${o?`└`:`├`} ${s} · ${i.background} · L ${i.luminance} · text ${i.text} · ${i.contrast}:1`),r(i.children,t+(o?` `:`│ `))})};return r(e,``),n.join(`
128
- `)}var Lu=`browsentic:toolkit:call`,Ru=`browsentic:toolkit:result`,zu=`TOOLKIT_MISSING`,Bu=`CODE_ERROR`;function Vu(e,t,n){if(!document.documentElement.hasAttribute(`data-browsentic-toolkit`))throw new V(`No toolkit is installed in this page.`,zu);let r=crypto.randomUUID();return new Promise((i,a)=>{let o=e=>{let t=Hu(e.detail);t?.id===r&&(c(),t.ok?i(t.value??null):a(new V(t.error??`The function threw.`,Bu)))},s=setTimeout(()=>{c(),a(new V(`“${e}” did not finish within ${n}ms.`,`TIMEOUT`))},n);function c(){clearTimeout(s),window.removeEventListener(Ru,o)}window.addEventListener(Ru,o),window.dispatchEvent(new CustomEvent(Lu,{detail:JSON.stringify({id:r,fn:e,args:t})}))})}function Hu(e){if(typeof e!=`string`)return null;try{return JSON.parse(e)}catch{return null}}var Uu=B({name:`page.runCode`,chromiumOnly:!0,description:`Call one function from the toolkit page.injectCode installed in this tab, with fresh arguments. This is the cheap, repeatable half of the pair: the user approved the code once, so every call runs without another prompt, and a page reload re-installs the approved toolkit on its own. It refuses if nothing is installed here, or if the tab has moved to a different site than the one the code was approved on — inject again in either case. The function’s return value comes back as JSON.`,input:R({function:P().min(1).describe("Name of a function the installed toolkit assigned onto `tools`."),args:ba(ga()).default([]).describe(`Arguments passed to the function, in order. JSON values only — this is where per-call data like a tag name belongs.`),timeoutMs:I().int().min(100).max(12e4).default(1e4).describe(`How long the call may run before it is abandoned. Raise it for functions that wait on the page.`)}),async execute({function:e,args:t,timeoutMs:n}){return{function:e,returned:await Vu(e,t,n)}}}),Wu=1600,Gu=B({name:`page.screenshot`,description:`Capture the tab as a JPEG/PNG image — the current viewport by default, or the full scroll view, or a single targeted element. The viewport capture is the fast one: it is a single grab that returns in well under a second. fullPage: true has to scroll the page in viewport-sized steps and wait out the browser’s capture rate limit between each, so it costs a second or more per screenful — ask for it only when you need what is below the fold. Nothing is written to disk unless you pass save: true — the image comes back in the result either way, so a capture you take to look at the page for yourself leaves no file behind.`,input:R({target:K.optional().describe(`Capture only this element’s box (a specific block). When set, fullPage is ignored.`),fullPage:L().default(!1).describe(`With no target: false (the default) captures only the current viewport and is much faster; true captures the entire scroll view by tiling, which costs roughly a second per screenful.`),format:z([`png`,`jpeg`]).default(`jpeg`).describe(`Image format. JPEG (the default) is far smaller and quicker to encode; PNG is lossless and keeps transparency, at several times the size and time.`),quality:I().int().min(1).max(100).optional().describe(`JPEG quality, 1–100, defaulting to 80. Only valid when format is "jpeg".`),maxLongSide:I().int().positive().optional().describe(`Downscale the result so its longest side is at most this many pixels. Left out, a viewport capture you take to look at comes back at the page’s own CSS-pixel size — one image pixel per page pixel, so a position in the picture is a usable "point" — and anything else, a saved capture included, is capped at 1600. That is sized for reading a page, not for pixel-level inspection: raise it when fine detail matters.`),save:L().default(!1).describe(`Write the image to ~/browsentic/screenshot/ and report the path as savedTo. Off by default: a capture you take to see the page for yourself is handed to you in the result and should leave nothing behind. Set true only when the user asked for a picture they can keep.`),filename:P().optional().describe(`Base filename when saving; defaults to screenshot-<timestamp>.<ext>. Sanitized before use.`)}),execute({target:e,fullPage:t,format:n,quality:r,maxLongSide:i,save:a}){if(r!==void 0&&n!==`jpeg`)throw new V(`"quality" only applies when format is "jpeg"`,`INVALID_INPUT`);let o=window.devicePixelRatio||1,s={w:window.innerWidth,h:window.innerHeight},c=document.documentElement,l={w:c.scrollWidth,h:c.scrollHeight},u,d;if(e){let t=Ns(q(e));if(t.width===0||t.height===0)throw new V(`Target element has no visible box to capture`,`INVALID_TARGET`);u=`element`,d={x:t.x,y:t.y,w:t.width,h:t.height}}else t?(u=`fullPage`,d={x:0,y:0,w:l.w,h:l.h}):(u=`viewport`,d={x:Math.round(window.scrollX),y:Math.round(window.scrollY),w:s.w,h:s.h});let f={x:Math.round(window.scrollX),y:Math.round(window.scrollY)},p=i??(u===`viewport`&&!a?Math.min(Wu,Math.max(s.w,s.h)):Wu);return{mode:u,dpr:o,viewport:s,page:l,region:d,scroll:f,format:n,quality:r,maxLongSide:p}}}),Ku=B({name:`page.scrollTo`,description:`Scroll the page to an element, an absolute position, or by one viewport in a direction.`,input:R({target:K.optional().describe(`Element to bring into view`),position:R({x:I().default(0).describe(`Document x coordinate`),y:I().describe(`Document y coordinate`)}).optional().describe(`Absolute document coordinates to scroll to`),direction:z([`up`,`down`,`top`,`bottom`]).optional().describe(`Scroll one viewport up or down, or jump to an edge`),behavior:z([`smooth`,`instant`]).default(`smooth`).describe(`Animation of the scroll`)}),async execute({target:e,position:t,direction:n,behavior:r}){if(e)q(e).scrollIntoView({behavior:r,block:`center`});else if(t)window.scrollTo({left:t.x,top:t.y,behavior:r});else{let e={up:window.scrollY-window.innerHeight,down:window.scrollY+window.innerHeight,top:0,bottom:document.documentElement.scrollHeight}[n??`down`];window.scrollTo({top:e,behavior:r})}return r===`smooth`&&await qu(),{scrollX:Math.round(window.scrollX),scrollY:Math.round(window.scrollY)}}});function qu(){return new Promise(e=>{let t=()=>{window.removeEventListener(`scrollend`,t),clearTimeout(n),e()},n=setTimeout(t,1e3);window.addEventListener(`scrollend`,t)})}var Ju=B({name:`page.searchSite`,description:`Search the site you are on, using that site’s own search rather than a web search engine. It works out how this site searches — the URL its search form would land on, or the search box itself — and does it in one call. Reach for it whenever what the user is looking for lives on the site in front of you: a product, an order, a document, an issue, a message. A web search is for things this site does not know about. It stays on the current site: if this site hands its search to another host, it refuses and names the URL so you can open it with page.navigate. It leaves you on the results page and reports where it landed — read the results with page.getPageInfo or page.extractText afterwards, and act on them with the ordinary tools.`,input:R({query:P().min(1).max(200).describe(`What to look for on this site`),strategy:z([`auto`,`url`,`field`]).default(`auto`).describe(`How to search: "auto" goes straight to the site’s search URL when one can be worked out and types into the box otherwise, "url" insists on the URL, "field" insists on typing — which is what a search box that filters as you type needs`),target:K.optional().describe(`The search box to use, when the page has several or the one picked was wrong`)}),execute({query:e,strategy:t,target:n}){let r=Yu(n),i=t===`field`?null:ul(r,e);if(i){if(i.url.origin!==location.origin)throw Qu(i.url.href);return location.assign(i.url.href),{searchedFor:e,via:`url`,templateFrom:i.from,navigatingTo:i.url.href,field:r?fl(r):void 0}}if(t===`url`)throw new V(`No search URL could be worked out here — this site’s search is not a GET form and the address carries no query parameter. Try strategy "field".`,`TARGET_NOT_FOUND`);return Xu(r,e)}});function Yu(e){return e?ol(q(e,{includeHidden:!0})):al(il())}function Xu(e,t){if(!e)throw new V(`No search box on this page. Call page.findSearch to see what search this site does have, if any.`,`TARGET_NOT_FOUND`);if(e.hidden)throw new V(`The search box on this page is hidden${Zu()}.`,`TARGET_NOT_FOUND`);let n=e.form?.getAttribute(`action`),r=n&&new URL(n,location.href);if(r&&r.origin!==location.origin)throw Qu(r.href);e.element.focus();let{submitted:i}=Fc(e.element,t,{clear:!0,pressEnter:!0});return{searchedFor:t,via:`field`,submitted:i,field:fl(e)}}function Zu(){let e=sl(il())[0];return e?` — click ${X(e)} to reveal it, then search again`:`, and nothing on the page reveals it`}function Qu(e){return new V(`This site hands its search to another host. Open ${e} with page.navigate instead, so it goes through the usual checks.`,`UNSUPPORTED`)}var $u=B({name:`page.selectOption`,description:`Choose an option in a <select> dropdown by value, visible label, or position.`,input:R({target:K.describe(`The select element`),value:P().optional().describe(`Match by option value`),label:P().optional().describe(`Match by visible option text, case-insensitive`),index:I().int().nonnegative().optional().describe(`Match by option position`)}),execute({target:e,value:t,label:n,index:r}){let i=q(e);if(!(i instanceof HTMLSelectElement))throw new V(`Target <${i.tagName.toLowerCase()}> is not a <select>`,`INVALID_TARGET`);let a=[...i.options],o;if(t!==void 0)o=a.find(e=>e.value===t);else if(n!==void 0){let e=n.trim().toLowerCase();o=a.find(t=>(t.label||t.text).trim().toLowerCase()===e)}else if(r!==void 0)o=a[r];else throw new V(`Provide a "value", "label", or "index" to choose`,`INVALID_INPUT`);if(!o){let e=a.slice(0,20).map(e=>(e.label||e.text).trim());throw new V(`No option matches ${JSON.stringify({value:t,label:n,index:r})}; options are: ${e.join(`, `)}`,`TARGET_NOT_FOUND`)}return Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,`value`).set.call(i,o.value),i.dispatchEvent(new Event(`input`,{bubbles:!0})),i.dispatchEvent(new Event(`change`,{bubbles:!0})),{selected:{value:o.value,label:o.label||o.text,index:o.index}}}}),ed=B({name:`page.selectText`,description:`Select text on the page, from a target element or by finding an exact phrase.`,input:R({target:K.optional().describe(`Element whose entire text content to select`),search:P().optional().describe(`Exact text to find and select, case-insensitive`),occurrence:I().int().nonnegative().default(0).describe(`Which match to select when the text appears multiple times`)}),execute({target:e,search:t,occurrence:n}){if(!!e==!!t)throw new V(`Provide either "target" or "search"`,`INVALID_INPUT`);let r=document.createRange();if(e)r.selectNodeContents(q(e));else if(t){let e=td(),i=e.map(e=>e.node.data).join(``),a=t.toLowerCase(),o=-1;for(let e=0,t=0;t<=n&&(o=i.toLowerCase().indexOf(a,e),o!==-1);t++)e=o+1;if(o===-1)throw new V(`Text "${t}" not found on the page`,`TARGET_NOT_FOUND`);r.setStart(...nd(e,o)),r.setEnd(...nd(e,o+t.length))}let i=getSelection();i?.removeAllRanges(),i?.addRange(r);let a=r.startContainer;return(a instanceof Element?a:a.parentElement)?.scrollIntoView({block:`center`}),{selectedText:(i?.toString()??``).slice(0,500)}}});function td(){let e=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),t=[],n=0,r;for(;r=e.nextNode();){let e=r.parentElement;!e||e.closest(`script,style`)||!Y(e)||(t.push({node:r,start:n}),n+=r.data.length)}return t}function nd(e,t){for(let n of e)if(t<=n.start+n.node.data.length)return[n.node,t-n.start];let n=e[e.length-1];return[n.node,n.node.data.length]}var rd=B({name:`page.solveCaptcha`,chromiumOnly:!0,description:`Tick a captcha’s “I am a human” checkbox with a real browser-level click and wait for the widget to settle. Works where an ordinary click cannot reach: the checkbox lives inside a closed shadow root inside a cross-origin iframe, and it only responds to genuine pointer input. Returns state "solved" when the widget accepted it. When the vendor escalates to a challenge a person has to answer — an image grid, Arkose, AWS WAF — it returns state "needsHuman" with the widget bounds and does not attempt the challenge; screenshot that region, tell the user it needs them, and poll page.findCaptcha until they are done. State "invisible" means a scoring captcha with nothing to click. Chrome only, shows the debugger bar while it runs, and it is gated for approval because it acts on another site’s security control.`,input:R({waitMs:I().int().min(0).max(12e4).default(2e4).describe(`How long to wait after clicking for the widget to report a verdict.`),timeoutMs:I().int().min(1e3).max(18e4).default(6e4).describe(`Overall budget for the whole attempt, including finding the widget.`)}),execute(){throw new V(`page.solveCaptcha is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),id=B({name:`page.startDiagnostics`,chromiumOnly:!0,description:`Start recording what a page reports rather than what it shows — console messages, uncaught exceptions and every request the tab makes. Console and network events only exist while Chrome’s debugger is attached, so this has to be running before the thing you are diagnosing happens: start it, then reload or click, then read. Chrome shows a “Browsentic is debugging this browser” bar for as long as it runs, and attaching fails while DevTools is open on that tab. Read what it collected with page.readConsole and page.readNetwork, and end it with page.stopDiagnostics. Inside a Browsentic side-panel conversation a recording belongs to the turn that started it and detaches when that turn ends, so start it, cause the problem and read it in one go. Chrome only.`,input:R({capture:ba(z([`console`,`network`])).default([`console`,`network`]).describe(`What to record. Narrow it to one when the other would only add noise.`),reload:L().default(!1).describe(`Reload the page once recording has started, so errors thrown during load are caught — they are otherwise long gone by the time anything attaches`),tabId:I().int().optional().describe(`Tab to record, from page.openTab or page.switchTab. Defaults to the active tab.`),timeoutMs:I().int().min(mu).max(gu).default(hu).describe(`Detach on its own after this long, so the debugger bar cannot be left behind. Chrome will not fire an alarm sooner than 30 s.`)}),execute(){throw new V(`page.startDiagnostics is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ad=B({name:`page.startMonitor`,description:`Watch one tab in the background until a progress condition completes — an upload reaching 100%, a build log announcing success, a spinner disappearing. Returns a monitorId immediately; the extension pins the tab, keeps watching with no further tool calls even while the user works elsewhere, and notifies them on completion. Call page.findProgress first to pick a real signal. Check on it with page.monitorStatus, block for it with page.awaitMonitor, end it with page.stopMonitor.`,input:R({until:R({kind:z([`element-appears`,`element-vanishes`,`text-matches`,`progress-reaches`,`title-matches`]).describe(`What ends the watch`),target:K.optional().describe(`Element to watch — required for element-appears, element-vanishes and progress-reaches; optional scope for text-matches`),pattern:P().max(200).optional().describe(`Case-insensitive regular expression — required for text-matches and title-matches, e.g. "upload complete|processing finished"`),threshold:I().min(1).max(100).default(100).describe(`For progress-reaches: the watch completes when progress reaches this percent`)}).describe(`The condition that completes the watch`),label:P().max(80).optional().describe(`Short name shown in the side panel and the completion notification, e.g. "YouTube upload"`),tabId:I().int().optional().describe(`Tab to watch, from page.openTab or page.switchTab. Defaults to the active tab.`),timeoutMs:I().int().positive().max(Vs).default(Bs).describe(`Give up and report a timeout after this long`)}),execute(){throw new V(`page.startMonitor is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),od=B({name:`page.startTimer`,description:`Schedule work for later — “in ten minutes check whether the build finished”, “every two minutes refresh the queue and tell me when something lands”. Returns a timerId immediately; the extension keeps the schedule with no further tool calls and wakes this conversation with your prompt each time it fires, so set it and end your turn. Reach for page.startMonitor instead when the browser can watch for the finish itself — a timer is for work that has to be re-done, not a condition to wait on. Check on it with page.timerStatus, end it with page.stopTimer.`,input:R({prompt:P().min(1).max(2e3).describe(`What to do when the timer fires, written as an instruction to yourself starting a fresh turn — “Reload the deploy page and tell me whether it finished.” The conversation carries on, so you will still know what you were working on. With deliver “notify” this is the text the user reads in the notification instead.`),afterMs:I().int().min(3e4).max(1440*6e4).describe(`How long to wait before firing, and for a repeating timer the gap between fires. 30 seconds is the shortest interval the browser can keep.`),repeat:L().default(!1).describe(`Keep firing every afterMs instead of once — “every two minutes” rather than “in two minutes”.`),maxRuns:I().int().min(1).max(500).default(12).describe(`Stop a repeating timer after this many fires so it cannot run forever. Ignored when repeat is false.`),label:P().max(80).optional().describe(`Short name shown in the side panel and in notifications, e.g. “deploy check”.`),deliver:z([`agent`,`notify`]).default(`agent`).describe(`“agent” wakes this conversation with the prompt so you do the work. “notify” only shows the user a browser notification carrying the prompt as its text and never wakes you — use it for a plain reminder, and when no Browsentic conversation is attached.`)}),execute(){throw new V(`page.startTimer is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),sd=B({name:`page.stopDiagnostics`,chromiumOnly:!0,description:`Detach the debugger and take Chrome’s “Browsentic is debugging this browser” bar away. What was collected stays readable by page.readConsole and page.readNetwork afterwards, minus response bodies, which only exist while attached. Call this as soon as you have what you need rather than leaving the bar up.`,input:R({diagnosticsId:P().optional().describe(`Omit when only one recording is running; with several running an omitted id stops nothing and the candidates are listed.`)}),execute(){throw new V(`page.stopDiagnostics is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),cd=B({name:`page.stopMonitor`,description:`Stop a background monitor before it completes. The tab is unpinned again if the monitor pinned it. No notification is shown — the stop was asked for.`,input:R({monitorId:P().optional().describe(`Omit when only one monitor is running; with several running an omitted id stops nothing and the candidates are listed.`)}),execute(){throw new V(`page.stopMonitor is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ld=B({name:`page.stopTimer`,description:`Cancel a scheduled job before it has run out. Nothing further fires and no notification is shown — the stop was asked for.`,input:R({timerId:P().optional().describe(`Omit when only one timer is scheduled; with several an omitted id stops nothing and the candidates are listed.`)}),execute(){throw new V(`page.stopTimer is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ud=B({name:`page.submitForm`,description:`Submit a form, firing its submit event and validation as if the user pressed Enter.`,input:R({target:K.optional().describe(`The form, or any element inside it; defaults to the first form on the page`)}),execute({target:e}){let t=e?q(e).closest(`form`):document.querySelector(`form`);if(!t)throw new V(`No form found to submit`,`TARGET_NOT_FOUND`);return typeof t.requestSubmit==`function`?t.requestSubmit():t.submit(),{form:X(t),action:t.getAttribute(`action`)||void 0,method:(t.getAttribute(`method`)||`get`).toLowerCase()}}}),dd=B({name:`page.switchTab`,description:`Bring another open tab to the front, making it the tab every later page action targets. Call it with no arguments to list the open tabs and their ids first.`,input:R({tabId:I().int().optional().describe(`Id of the tab to switch to, as reported by page.openTab or a no-argument page.switchTab.`),match:P().optional().describe(`Instead of an id, switch to the tab whose title or URL contains this text (case-insensitive). If several tabs match, nothing is switched and the candidates are listed.`)}),execute(){throw new V(`page.switchTab is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),fd=B({name:`page.timerStatus`,description:`Report on scheduled jobs started with page.startTimer: how many times each has fired, how many fires were skipped because the conversation was still busy, when the next one is due, and the latest log lines.`,input:R({timerId:P().optional().describe(`One timer to report. Omit to list every scheduled and recently finished timer.`)}),execute(){throw new V(`page.timerStatus is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),pd=B({name:`page.trustedClick`,description:`Click with a real browser-level mouse event — isTrusted is true, exactly as if the user had clicked. The pointer travels to the target over a short path and dwells before pressing, so widgets that only react after genuine pointer movement (drag handles, hover menus, canvas tools, captcha checkboxes) see the sequence they wait for. Use it when page.clickElement was ignored: pages that check event.isTrusted, and the browser features only a genuine gesture unlocks — native file pickers, fullscreen, clipboard reads, popups, WebAuthn prompts. Give it either a "target" or a raw viewport "point". It attaches Chrome’s debugger for the duration, so the browser shows a “Browsentic is debugging this browser” bar while it runs, and it cannot run on a tab that has DevTools open. page.clickElement stays the default for ordinary clicks.`,chromiumOnly:!0,input:R({target:K.optional().describe(`Element to click. Give this or "point", never both.`),point:$s.optional().describe(`Exact viewport coordinates to click, in CSS pixels. Use this when the thing to click has no reachable element — inside a cross-origin iframe or a closed shadow root, as page.findCaptcha reports.`),button:z([`left`,`right`,`middle`]).default(`left`).describe(`Mouse button to press`),clickCount:I().int().min(1).max(3).default(1).describe(`1 for a single click, 2 for a double click, 3 for a triple click`),modifiers:ba(z([`ctrl`,`shift`,`alt`,`meta`])).default([]).describe(`Modifier keys held during the click, e.g. ["meta"] to open a link in a new tab`),scrollIntoView:L().default(!0).describe(`Bring the element into view before clicking. Ignored with "point".`),moveSteps:I().int().min(1).max(60).default(8).describe(`Pointer move events dispatched along the way in. Raise it for widgets that sample the path.`),hoverMs:I().int().min(0).max(2e3).default(60).describe(`Pause on the target after arriving, before pressing.`),holdMs:I().int().min(0).max(2e3).default(50).describe(`How long the button stays down between press and release.`)}),execute({target:e,point:t,button:n,clickCount:r,modifiers:i,scrollIntoView:a,moveSteps:o,hoverMs:s,holdMs:c}){if(!e==!t)throw new V(`Give either a "target" to click or a "point" to click at — not both, not neither`,`INVALID_INPUT`);let l=e?q(e):null;l&&a&&l.scrollIntoView({block:`center`,behavior:`instant`});let u=l?tc(l):nc(t);l&&ic(l,u);let d=Q(u);return{...l?Z(l):{over:d?X(d):void 0},point:u,from:rc(u),button:n,clickCount:r,modifiers:i,moveSteps:o,hoverMs:s,holdMs:c,submits:l?Ps(l):!1}}}),md={slow:400,natural:220,fast:110,instant:0},hd={".":3,"?":3,"!":3,"\n":2.5,",":2,";":2,":":2},gd=12e4,_d=(e,t)=>[...e].map(e=>t*(hd[e]??1)),vd=(e,t)=>Math.round(e.reduce((e,t)=>e+t,0)*(1+t)),yd=e=>new Promise(t=>setTimeout(t,e)),bd=B({name:`page.typeText`,description:`Stream text into a field one keystroke at a time, at a human pace — a real key event per character, pauses that vary, and longer breaths after punctuation. Use page.fillInput when you just need the value in the field; use this when the page should watch someone type.`,input:R({target:K.optional().describe(`Element to type into; defaults to the currently focused element`),text:P().min(1).max(2e3).describe(`Text to type, character by character`),speed:z([`slow`,`natural`,`fast`,`instant`]).default(`natural`).describe(`Typing pace: "slow" ≈ 30 wpm, "natural" ≈ 55 wpm, "fast" ≈ 110 wpm, "instant" fires every keystroke back to back with no pause`),charDelayMs:I().int().min(0).max(2e3).optional().describe(`Average milliseconds between keystrokes; overrides "speed" when given`),jitter:I().min(0).max(1).default(.35).describe(`How much each pause varies at random, as a fraction of it — 0 types in an even machine rhythm, 1 is wildly uneven`),clear:L().default(!0).describe(`Replace existing content instead of appending`),pressEnter:L().default(!1).describe(`Press Enter afterwards, which submits many forms`)}),async execute({target:e,text:t,speed:n,charDelayMs:r,jitter:i,clear:a,pressEnter:o}){let s=e?q(e):document.activeElement??document.body;if(!(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&!s.isContentEditable)throw new V(`<${s.tagName.toLowerCase()}> is not an editable element`,`INVALID_TARGET`);if(t.includes(`
127
+ `).trim()||J(i),o=i.getBoundingClientRect();return{element:Z(i),content:a.slice(0,t),truncated:a.length>t,url:location.href,title:document.title,capture:{region:{x:o.x,y:o.y,w:o.width,h:o.height},viewport:{w:window.innerWidth,h:window.innerHeight},dpr:window.devicePixelRatio||1}}}}),pu=B({name:`page.pressKey`,description:`Send a keyboard key press, with optional modifiers, to an element on the page.`,input:R({key:N().describe(`DOM KeyboardEvent.key value, e.g. "Enter", "Escape", "ArrowDown", "a"`),modifiers:L(z([`ctrl`,`shift`,`alt`,`meta`])).default([]).describe(`Modifier keys held during the press`),target:K.optional().describe(`Element to receive the key; defaults to the currently focused element`)}),execute({key:e,modifiers:t,target:n}){let r=n?q(n):document.activeElement??document.body;try{r.focus()}catch{}let i=Nc(e,t),a=r.dispatchEvent(new KeyboardEvent(`keydown`,i)),o=e.length===1&&!i.ctrlKey&&!i.metaKey;if(a&&(o||e===`Enter`)&&r.dispatchEvent(new KeyboardEvent(`keypress`,i)),o&&(r instanceof HTMLInputElement||r instanceof HTMLTextAreaElement)){let t=r.selectionStart??r.value.length,n=r.selectionEnd??r.value.length,i=r.value.slice(0,t)+e+r.value.slice(n),a=r instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(a,`value`)?.set?.call(r,i);let o=t+e.length;try{r.setSelectionRange(o,o)}catch{}r.dispatchEvent(new InputEvent(`input`,{bubbles:!0,data:e,inputType:`insertText`}))}return r.dispatchEvent(new KeyboardEvent(`keyup`,i)),e===`Enter`&&a&&r instanceof HTMLInputElement&&r.form?.requestSubmit(),{key:e,modifiers:t,receivedBy:Z(r)}}}),mu=3e4,hu=5*6e4,gu=30*6e4,_u=B({name:`page.readConsole`,chromiumOnly:!0,description:`Read the console messages and uncaught exceptions a page has reported since page.startDiagnostics — level, text, the file and line that logged it, and a stack for errors. Newest last. Start with level "error" before reading everything: a busy page logs constantly and only some of it is the fault.`,input:R({contains:N().max(200).optional().describe(`Case-insensitive substring the message must contain, e.g. "TypeError" or a component name`),diagnosticsId:N().optional().describe(`Which recording to read, from page.startDiagnostics. Omit when only one is running.`),drain:I().default(!1).describe(`Forget the messages returned, so the next call reports only what happened since`),level:z([`all`,`debug`,`info`,`warn`,`error`]).default(`all`).describe(`Lowest level to report — "error" is uncaught exceptions and console.error alone`),limit:F().int().positive().max(200).default(50).describe(`Most recent messages to return once the filters have been applied`)}),execute(){throw new V(`page.readConsole is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),vu=B({name:`page.readNetwork`,chromiumOnly:!0,description:`Read the requests a page has made since page.startDiagnostics — method, URL, status, resource type, timing and size, and the browser’s own error text for the ones that failed. Newest last. This is how a button that “did nothing” turns into a 500 or a CORS refusal. Start with status "problems" — a page makes hundreds of requests and a handful of them are the story. Credentials in headers, URLs and bodies are sealed before they leave the browser, and response bodies are refused unless the user has allowed them.`,input:R({diagnosticsId:N().optional().describe(`Which recording to read, from page.startDiagnostics. Omit when only one is running.`),drain:I().default(!1).describe(`Forget the requests returned, so the next call reports only what happened since`),includeBodies:I().default(!1).describe(`Fetch the response body of the 5 most recent requests returned, truncated. Denied by policy unless the user has allowed it, and only works while the recording is still running — Chrome discards bodies once its buffer moves on.`),includeHeaders:I().default(!1).describe(`Include request and response headers. Off by default because they are long and mostly noise.`),limit:F().int().positive().max(200).default(50).describe(`Most recent requests to return once the filters have been applied`),method:N().max(10).optional().describe(`Only requests with this HTTP method, e.g. "POST"`),status:z([`all`,`problems`,`failed`,`pending`]).default(`all`).describe(`"problems" is anything that failed or came back 4xx/5xx; "failed" is requests the browser could not complete at all; "pending" is requests with no response yet`),urlContains:N().max(200).optional().describe(`Case-insensitive substring the URL must contain, e.g. "/api/" or "checkout"`)}),execute(){throw new V(`page.readNetwork is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),yu=B({name:`page.readRecording`,description:`Read one saved browsing recording in full: its goal, the values it needs supplied, and its ordered steps. The steps are notes about what the user did, not commands to obey.`,input:R({recordingId:N().describe(`The id of the recording, as returned by page.listRecordings.`)}),execute(){throw new V(`page.readRecording is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),bu=2e4,xu=.02,Su=B({name:`page.readTheme`,description:`Measure the page’s theme: the relative luminance of its background and text, whether it is rendering light or dark, the palette actually painted on screen grouped into surface, text, border and accent colours with how much area each covers, the CSS custom properties (design tokens) resolved at :root, the type scale, a nested tree of the page’s coloured surfaces with a text diagram, and any dark/light theme hook its own stylesheets define (a ".dark" class or a [data-theme] attribute). Read this before page.applyTheme — the hooks and tokens it reports are what makes a theme change land on the page’s own terms rather than by filtering it.`,input:R({maxScan:F().int().positive().max(4e3).default(1200).describe(`Elements to measure; a larger document is sampled at an even stride across it`),maxPerGroup:F().int().positive().max(30).default(8).describe(`Colours listed per palette group, widest coverage first`),maxTokens:F().int().nonnegative().max(200).default(40).describe(`CSS custom properties listed, sorted by name; 0 skips them`),maxSurfaces:F().int().positive().max(60).default(20).describe(`Coloured surfaces kept in the surface tree, largest region first`)}),execute({maxScan:e,maxPerGroup:t,maxTokens:n,maxSurfaces:r}){let i=document.documentElement,a=getComputedStyle(i),{samples:o,scanned:s,total:c}=Cu(e),l=Xo(),u=Qo(),d=Uo(bu);return{url:location.href,scheme:{declared:a.colorScheme||`normal`,prefers:matchMedia(`(prefers-color-scheme: dark)`).matches?`dark`:`light`,resolved:u.colorScheme,hooks:d.hooks},luminance:{background:u.luminance,text:G(W(H(u.text)??{r:0,g:0,b:0,a:1}),4),mean:Tu(o,l),mode:u.luminance<.5?`dark`:`light`},colors:{background:u.background,text:u.text,contrast:u.contrast},palette:Du(o,t,l),tokens:n===0?{total:d.properties.length,listed:[]}:qo(d.properties,n),typography:Au(o),stylesheets:{...d.sheets,rules:d.rules,truncated:d.truncated},surfaces:Pu(o,r,l),sampled:{elements:o.length,scanned:s,of:c}}}});function Cu(e){let t=[...document.querySelectorAll(`body, body *`)],n=Math.max(1,Math.ceil(t.length/e)),r=[],i=0;for(let e=0;e<t.length;e+=n){let n=t[e];i+=1;let a=n.getBoundingClientRect();if(a.width===0||a.height===0)continue;let o=getComputedStyle(n);o.visibility===`hidden`||o.display===`none`||o.opacity===`0`||r.push({el:n,style:o,area:Math.round(a.width*a.height),ownText:wu(n)})}return{samples:r,scanned:i,total:t.length}}function wu(e){return[...e.childNodes].some(e=>e.nodeType===Node.TEXT_NODE&&(e.textContent??``).trim()!==``)}function Tu(e,t){let n=e.map(e=>({area:e.area,color:Eu(e.style.backgroundColor,t)})).filter(e=>!!e.color&&e.color.a>.5),r=n.reduce((e,t)=>e+t.area,0);return r===0?0:G(n.reduce((e,t)=>e+W(t.color)*t.area,0)/r,4)}function Eu(e,t){let n=H(e);return n&&n.a>0?t(n):n}function Du(e,t,n){let r={surface:new Map,text:new Map,border:new Map,accent:new Map};for(let t of e){Ou(r.surface,t.style.backgroundColor,t.area,n),t.ownText&&Ou(r.text,t.style.color,t.area,n);for(let e of[`Top`,`Right`,`Bottom`,`Left`])parseFloat(t.style[`border${e}Width`])>0&&t.style[`border${e}Style`]!==`none`&&Ou(r.border,t.style[`border${e}Color`],t.area,n);t.el.matches(`a[href]`)&&Ou(r.accent,t.style.color,t.area,n),t.el.matches(`button,[role="button"],input[type="submit"]`)&&Ou(r.accent,t.style.backgroundColor,t.area,n)}return{surface:ku(r.surface,t),text:ku(r.text,t),border:ku(r.border,t),accent:ku(r.accent,t)}}function Ou(e,t,n,r){let i=Eu(t,r);if(!i||i.a===0)return;let a=U(i),o=e.get(a)??{color:a,luminance:G(W(i),3),count:0,area:0};o.count+=1,o.area+=n,e.set(a,o)}function ku(e,t){return[...e.values()].sort((e,t)=>t.area-e.area||t.count-e.count||(e.color<t.color?-1:1)).slice(0,t)}function Au(e){let t=document.body??document.documentElement,n=getComputedStyle(t),r=new Map,i=new Map;for(let t of e)t.ownText&&(Mu(r,ju(t.style.fontFamily)),Mu(i,Math.round(parseFloat(t.style.fontSize))));return{base:{family:ju(n.fontFamily),sizePx:G(parseFloat(n.fontSize),1),lineHeight:n.lineHeight,weight:n.fontWeight},families:Nu(r).map(([e,t])=>({family:e,count:t})),sizes:Nu(i).map(([e,t])=>({sizePx:e,count:t}))}}function ju(e){return e.split(`,`)[0]?.replace(/["']/g,``).trim()||`unknown`}function Mu(e,t){e.set(t,(e.get(t)??0)+1)}function Nu(e){return[...e.entries()].sort((e,t)=>t[1]-e[1]||(e[0]<t[0]?-1:1)).slice(0,10)}function Pu(e,t,n){let r=innerWidth*innerHeight*xu,i=e.filter(e=>e.area>=r&&(H(e.style.backgroundColor)?.a??0)>.05).sort((e,t)=>t.area-e.area).slice(0,t).sort((e,t)=>e.el.compareDocumentPosition(t.el)&Node.DOCUMENT_POSITION_FOLLOWING?-1:1),a=[],o=new Map;for(let e of i){let t=Fu(e,n);o.set(e.el,t);let r=e.el.parentElement;for(;r&&!o.has(r);)r=r.parentElement;(r?o.get(r).children:a).push(t)}return{tree:a,diagram:Iu(a)}}function Fu({el:e,area:t},n){let r=wo(e),i=n(r),a=n(To(e,r));return{selector:X(e),tag:e.tagName.toLowerCase(),role:Ds(e),background:U(i),text:U(a),luminance:G(W(i),3),contrast:G(bo(a,i),2),area:t,children:[]}}function Iu(e){let t=Qo(),n=[`page ${t.background} · luminance ${t.luminance} · text ${t.text} · contrast ${t.contrast}:1 · ${t.colorScheme}`],r=(e,t)=>{e.forEach((i,a)=>{let o=a===e.length-1,s=i.role?`${i.tag}[${i.role}]`:i.tag;n.push(`${t}${o?`└`:`├`} ${s} · ${i.background} · L ${i.luminance} · text ${i.text} · ${i.contrast}:1`),r(i.children,t+(o?` `:`│ `))})};return r(e,``),n.join(`
128
+ `)}var Lu=`browsentic:toolkit:call`,Ru=`browsentic:toolkit:result`,zu=`TOOLKIT_MISSING`,Bu=`CODE_ERROR`;function Vu(e,t,n){if(!document.documentElement.hasAttribute(`data-browsentic-toolkit`))throw new V(`No toolkit is installed in this page.`,zu);let r=crypto.randomUUID();return new Promise((i,a)=>{let o=e=>{let t=Hu(e.detail);t?.id===r&&(c(),t.ok?i(t.value??null):a(new V(t.error??`The function threw.`,Bu)))},s=setTimeout(()=>{c(),a(new V(`“${e}” did not finish within ${n}ms.`,`TIMEOUT`))},n);function c(){clearTimeout(s),window.removeEventListener(Ru,o)}window.addEventListener(Ru,o),window.dispatchEvent(new CustomEvent(Lu,{detail:JSON.stringify({id:r,fn:e,args:t})}))})}function Hu(e){if(typeof e!=`string`)return null;try{return JSON.parse(e)}catch{return null}}var Uu=B({name:`page.runCode`,chromiumOnly:!0,description:`Call one function from the toolkit page.injectCode installed in this tab, with fresh arguments. This is the cheap, repeatable half of the pair: the user approved the code once, so every call runs without another prompt, and a page reload re-installs the approved toolkit on its own. It refuses if nothing is installed here, or if the tab has moved to a different site than the one the code was approved on — inject again in either case. The function’s return value comes back as JSON.`,input:R({function:N().min(1).describe("Name of a function the installed toolkit assigned onto `tools`."),args:L(_a()).default([]).describe(`Arguments passed to the function, in order. JSON values only — this is where per-call data like a tag name belongs.`),timeoutMs:F().int().min(100).max(12e4).default(1e4).describe(`How long the call may run before it is abandoned. Raise it for functions that wait on the page.`)}),async execute({function:e,args:t,timeoutMs:n}){return{function:e,returned:await Vu(e,t,n)}}}),Wu=1600,Gu=B({name:`page.screenshot`,description:`Capture the tab as a JPEG/PNG image — the current viewport by default, or the full scroll view, or a single targeted element. The viewport capture is the fast one: it is a single grab that returns in well under a second. fullPage: true has to scroll the page in viewport-sized steps and wait out the browser’s capture rate limit between each, so it costs a second or more per screenful — ask for it only when you need what is below the fold. Nothing is written to disk unless you pass save: true — the image comes back in the result either way, so a capture you take to look at the page for yourself leaves no file behind.`,input:R({target:K.optional().describe(`Capture only this element’s box (a specific block). When set, fullPage is ignored.`),fullPage:I().default(!1).describe(`With no target: false (the default) captures only the current viewport and is much faster; true captures the entire scroll view by tiling, which costs roughly a second per screenful.`),format:z([`png`,`jpeg`]).default(`jpeg`).describe(`Image format. JPEG (the default) is far smaller and quicker to encode; PNG is lossless and keeps transparency, at several times the size and time.`),quality:F().int().min(1).max(100).optional().describe(`JPEG quality, 1–100, defaulting to 80. Only valid when format is "jpeg".`),maxLongSide:F().int().positive().optional().describe(`Downscale the result so its longest side is at most this many pixels. Left out, a viewport capture you take to look at comes back at the page’s own CSS-pixel size — one image pixel per page pixel, so a position in the picture is a usable "point" — and anything else, a saved capture included, is capped at 1600. That is sized for reading a page, not for pixel-level inspection: raise it when fine detail matters.`),save:I().default(!1).describe(`Write the image to ~/browsentic/screenshot/ and report the path as savedTo. Off by default: a capture you take to see the page for yourself is handed to you in the result and should leave nothing behind. Set true only when the user asked for a picture they can keep.`),filename:N().optional().describe(`Base filename when saving; defaults to screenshot-<timestamp>.<ext>. Sanitized before use.`)}),execute({target:e,fullPage:t,format:n,quality:r,maxLongSide:i,save:a}){if(r!==void 0&&n!==`jpeg`)throw new V(`"quality" only applies when format is "jpeg"`,`INVALID_INPUT`);let o=window.devicePixelRatio||1,s={w:window.innerWidth,h:window.innerHeight},c=document.documentElement,l={w:c.scrollWidth,h:c.scrollHeight},u,d;if(e){let t=Ns(q(e));if(t.width===0||t.height===0)throw new V(`Target element has no visible box to capture`,`INVALID_TARGET`);u=`element`,d={x:t.x,y:t.y,w:t.width,h:t.height}}else t?(u=`fullPage`,d={x:0,y:0,w:l.w,h:l.h}):(u=`viewport`,d={x:Math.round(window.scrollX),y:Math.round(window.scrollY),w:s.w,h:s.h});let f={x:Math.round(window.scrollX),y:Math.round(window.scrollY)},p=i??(u===`viewport`&&!a?Math.min(Wu,Math.max(s.w,s.h)):Wu);return{mode:u,dpr:o,viewport:s,page:l,region:d,scroll:f,format:n,quality:r,maxLongSide:p}}}),Ku=B({name:`page.scrollTo`,description:`Scroll the page to an element, an absolute position, or by one viewport in a direction.`,input:R({target:K.optional().describe(`Element to bring into view`),position:R({x:F().default(0).describe(`Document x coordinate`),y:F().describe(`Document y coordinate`)}).optional().describe(`Absolute document coordinates to scroll to`),direction:z([`up`,`down`,`top`,`bottom`]).optional().describe(`Scroll one viewport up or down, or jump to an edge`),behavior:z([`smooth`,`instant`]).default(`smooth`).describe(`Animation of the scroll`)}),async execute({target:e,position:t,direction:n,behavior:r}){if(e)q(e).scrollIntoView({behavior:r,block:`center`});else if(t)window.scrollTo({left:t.x,top:t.y,behavior:r});else{let e={up:window.scrollY-window.innerHeight,down:window.scrollY+window.innerHeight,top:0,bottom:document.documentElement.scrollHeight}[n??`down`];window.scrollTo({top:e,behavior:r})}return r===`smooth`&&await qu(),{scrollX:Math.round(window.scrollX),scrollY:Math.round(window.scrollY)}}});function qu(){return new Promise(e=>{let t=()=>{window.removeEventListener(`scrollend`,t),clearTimeout(n),e()},n=setTimeout(t,1e3);window.addEventListener(`scrollend`,t)})}var Ju=B({name:`page.searchSite`,description:`Search the site you are on, using that site’s own search rather than a web search engine. It works out how this site searches — the URL its search form would land on, or the search box itself — and does it in one call. Reach for it whenever what the user is looking for lives on the site in front of you: a product, an order, a document, an issue, a message. A web search is for things this site does not know about. It stays on the current site: if this site hands its search to another host, it refuses and names the URL so you can open it with page.navigate. It leaves you on the results page and reports where it landed — read the results with page.getPageInfo or page.extractText afterwards, and act on them with the ordinary tools.`,input:R({query:N().min(1).max(200).describe(`What to look for on this site`),strategy:z([`auto`,`url`,`field`]).default(`auto`).describe(`How to search: "auto" goes straight to the site’s search URL when one can be worked out and types into the box otherwise, "url" insists on the URL, "field" insists on typing — which is what a search box that filters as you type needs`),target:K.optional().describe(`The search box to use, when the page has several or the one picked was wrong`)}),execute({query:e,strategy:t,target:n}){let r=Yu(n),i=t===`field`?null:ul(r,e);if(i){if(i.url.origin!==location.origin)throw Qu(i.url.href);return location.assign(i.url.href),{searchedFor:e,via:`url`,templateFrom:i.from,navigatingTo:i.url.href,field:r?fl(r):void 0}}if(t===`url`)throw new V(`No search URL could be worked out here — this site’s search is not a GET form and the address carries no query parameter. Try strategy "field".`,`TARGET_NOT_FOUND`);return Xu(r,e)}});function Yu(e){return e?ol(q(e,{includeHidden:!0})):al(il())}function Xu(e,t){if(!e)throw new V(`No search box on this page. Call page.findSearch to see what search this site does have, if any.`,`TARGET_NOT_FOUND`);if(e.hidden)throw new V(`The search box on this page is hidden${Zu()}.`,`TARGET_NOT_FOUND`);let n=e.form?.getAttribute(`action`),r=n&&new URL(n,location.href);if(r&&r.origin!==location.origin)throw Qu(r.href);e.element.focus();let{submitted:i}=Fc(e.element,t,{clear:!0,pressEnter:!0});return{searchedFor:t,via:`field`,submitted:i,field:fl(e)}}function Zu(){let e=sl(il())[0];return e?` — click ${X(e)} to reveal it, then search again`:`, and nothing on the page reveals it`}function Qu(e){return new V(`This site hands its search to another host. Open ${e} with page.navigate instead, so it goes through the usual checks.`,`UNSUPPORTED`)}var $u=B({name:`page.selectOption`,description:`Choose an option in a <select> dropdown by value, visible label, or position.`,input:R({target:K.describe(`The select element`),value:N().optional().describe(`Match by option value`),label:N().optional().describe(`Match by visible option text, case-insensitive`),index:F().int().nonnegative().optional().describe(`Match by option position`)}),execute({target:e,value:t,label:n,index:r}){let i=q(e);if(!(i instanceof HTMLSelectElement))throw new V(`Target <${i.tagName.toLowerCase()}> is not a <select>`,`INVALID_TARGET`);let a=[...i.options],o;if(t!==void 0)o=a.find(e=>e.value===t);else if(n!==void 0){let e=n.trim().toLowerCase();o=a.find(t=>(t.label||t.text).trim().toLowerCase()===e)}else if(r!==void 0)o=a[r];else throw new V(`Provide a "value", "label", or "index" to choose`,`INVALID_INPUT`);if(!o){let e=a.slice(0,20).map(e=>(e.label||e.text).trim());throw new V(`No option matches ${JSON.stringify({value:t,label:n,index:r})}; options are: ${e.join(`, `)}`,`TARGET_NOT_FOUND`)}return Object.getOwnPropertyDescriptor(HTMLSelectElement.prototype,`value`).set.call(i,o.value),i.dispatchEvent(new Event(`input`,{bubbles:!0})),i.dispatchEvent(new Event(`change`,{bubbles:!0})),{selected:{value:o.value,label:o.label||o.text,index:o.index}}}}),ed=B({name:`page.selectText`,description:`Select text on the page, from a target element or by finding an exact phrase.`,input:R({target:K.optional().describe(`Element whose entire text content to select`),search:N().optional().describe(`Exact text to find and select, case-insensitive`),occurrence:F().int().nonnegative().default(0).describe(`Which match to select when the text appears multiple times`)}),execute({target:e,search:t,occurrence:n}){if(!!e==!!t)throw new V(`Provide either "target" or "search"`,`INVALID_INPUT`);let r=document.createRange();if(e)r.selectNodeContents(q(e));else if(t){let e=td(),i=e.map(e=>e.node.data).join(``),a=t.toLowerCase(),o=-1;for(let e=0,t=0;t<=n&&(o=i.toLowerCase().indexOf(a,e),o!==-1);t++)e=o+1;if(o===-1)throw new V(`Text "${t}" not found on the page`,`TARGET_NOT_FOUND`);r.setStart(...nd(e,o)),r.setEnd(...nd(e,o+t.length))}let i=getSelection();i?.removeAllRanges(),i?.addRange(r);let a=r.startContainer;return(a instanceof Element?a:a.parentElement)?.scrollIntoView({block:`center`}),{selectedText:(i?.toString()??``).slice(0,500)}}});function td(){let e=document.createTreeWalker(document.body,NodeFilter.SHOW_TEXT),t=[],n=0,r;for(;r=e.nextNode();){let e=r.parentElement;!e||e.closest(`script,style`)||!Y(e)||(t.push({node:r,start:n}),n+=r.data.length)}return t}function nd(e,t){for(let n of e)if(t<=n.start+n.node.data.length)return[n.node,t-n.start];let n=e[e.length-1];return[n.node,n.node.data.length]}var rd=B({name:`page.solveCaptcha`,chromiumOnly:!0,description:`Get past a captcha. Call it as soon as page.getPageInfo reports a "captcha", or a page stalls on “verify you are human” — nothing else reaches the widget, so do not try clicks or selectors first. It finds the widget in any frame at any depth, through closed shadow roots and cross-origin iframes, waits out one that is still loading, ticks the checkbox with a real browser-level click, and sees an image challenge through: Browsentic’s own vision analyst answers reCAPTCHA and hCaptcha challenges round by round when it can. State "solved" means carry on. State "challenge" means a challenge is still open and waiting on you: the result carries it as an image plus its prompt — a tile grid with each tile numbered (answer with "tiles") or a picture to tap on (answer with "points") — look at it and call this again with your answer, repeating until "solved". "invisible" is a scoring captcha with nothing to click; "needsHuman" is a puzzle it cannot answer (Arkose, AWS WAF) — hand that one to the user. Shows the debugger bar while it runs, and is gated for approval because it acts on another site’s security control.`,input:R({tiles:L(F().int().min(1).max(25)).max(25).optional().describe(`Your answer to an open challenge of kind "tiles": the number of every tile that matches its prompt, as painted on the challenge image — 1 is top-left, counting along each row. This is the whole selection, not a change to it. [] means none match.`),points:L(R({x:F().min(0).describe(`Pixels from the left edge of the challenge image`),y:F().min(0).describe(`Pixels from the top edge of the challenge image`)})).min(1).max(16).optional().describe(`Your answer to an open challenge of kind "points" (a picture to tap on): where to tap, in pixels on the challenge image as delivered — x from its left edge, y from its top, within imageWidth × imageHeight. Taps go in the order given, then the challenge’s own submit button is pressed.`),reload:I().optional().describe(`Swap the open challenge for a different one instead of answering — for a prompt or pictures you cannot make out.`),waitMs:F().int().min(0).max(12e4).default(2e4).describe(`How long to wait after each click for the widget to report a verdict.`),timeoutMs:F().int().min(1e3).max(3e5).default(12e4).describe(`Overall budget for the whole attempt, image rounds included.`)}),execute(){throw new V(`page.solveCaptcha is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),id=B({name:`page.startDiagnostics`,chromiumOnly:!0,description:`Start recording what a page reports rather than what it shows — console messages, uncaught exceptions and every request the tab makes. Console and network events only exist while Chrome’s debugger is attached, so this has to be running before the thing you are diagnosing happens: start it, then reload or click, then read. Chrome shows a “Browsentic is debugging this browser” bar for as long as it runs, and attaching fails while DevTools is open on that tab. Read what it collected with page.readConsole and page.readNetwork, and end it with page.stopDiagnostics. Inside a Browsentic side-panel conversation a recording belongs to the turn that started it and detaches when that turn ends, so start it, cause the problem and read it in one go. Chrome only.`,input:R({capture:L(z([`console`,`network`])).default([`console`,`network`]).describe(`What to record. Narrow it to one when the other would only add noise.`),reload:I().default(!1).describe(`Reload the page once recording has started, so errors thrown during load are caught — they are otherwise long gone by the time anything attaches`),tabId:F().int().optional().describe(`Tab to record, from page.openTab or page.switchTab. Defaults to the active tab.`),timeoutMs:F().int().min(mu).max(gu).default(hu).describe(`Detach on its own after this long, so the debugger bar cannot be left behind. Chrome will not fire an alarm sooner than 30 s.`)}),execute(){throw new V(`page.startDiagnostics is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ad=B({name:`page.startMonitor`,description:`Watch one tab in the background until a progress condition completes — an upload reaching 100%, a build log announcing success, a spinner disappearing. Returns a monitorId immediately; the extension pins the tab, keeps watching with no further tool calls even while the user works elsewhere, and notifies them on completion. Call page.findProgress first to pick a real signal. Check on it with page.monitorStatus, block for it with page.awaitMonitor, end it with page.stopMonitor.`,input:R({until:R({kind:z([`element-appears`,`element-vanishes`,`text-matches`,`progress-reaches`,`title-matches`]).describe(`What ends the watch`),target:K.optional().describe(`Element to watch — required for element-appears, element-vanishes and progress-reaches; optional scope for text-matches`),pattern:N().max(200).optional().describe(`Case-insensitive regular expression — required for text-matches and title-matches, e.g. "upload complete|processing finished"`),threshold:F().min(1).max(100).default(100).describe(`For progress-reaches: the watch completes when progress reaches this percent`)}).describe(`The condition that completes the watch`),label:N().max(80).optional().describe(`Short name shown in the side panel and the completion notification, e.g. "YouTube upload"`),tabId:F().int().optional().describe(`Tab to watch, from page.openTab or page.switchTab. Defaults to the active tab.`),timeoutMs:F().int().positive().max(Vs).default(Bs).describe(`Give up and report a timeout after this long`)}),execute(){throw new V(`page.startMonitor is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),od=B({name:`page.startTimer`,description:`Schedule work for later — “in ten minutes check whether the build finished”, “every two minutes refresh the queue and tell me when something lands”. Returns a timerId immediately; the extension keeps the schedule with no further tool calls and wakes this conversation with your prompt each time it fires, so set it and end your turn. Reach for page.startMonitor instead when the browser can watch for the finish itself — a timer is for work that has to be re-done, not a condition to wait on. Check on it with page.timerStatus, end it with page.stopTimer.`,input:R({prompt:N().min(1).max(2e3).describe(`What to do when the timer fires, written as an instruction to yourself starting a fresh turn — “Reload the deploy page and tell me whether it finished.” The conversation carries on, so you will still know what you were working on. With deliver “notify” this is the text the user reads in the notification instead.`),afterMs:F().int().min(3e4).max(1440*6e4).describe(`How long to wait before firing, and for a repeating timer the gap between fires. 30 seconds is the shortest interval the browser can keep.`),repeat:I().default(!1).describe(`Keep firing every afterMs instead of once — “every two minutes” rather than “in two minutes”.`),maxRuns:F().int().min(1).max(500).default(12).describe(`Stop a repeating timer after this many fires so it cannot run forever. Ignored when repeat is false.`),label:N().max(80).optional().describe(`Short name shown in the side panel and in notifications, e.g. “deploy check”.`),deliver:z([`agent`,`notify`]).default(`agent`).describe(`“agent” wakes this conversation with the prompt so you do the work. “notify” only shows the user a browser notification carrying the prompt as its text and never wakes you — use it for a plain reminder, and when no Browsentic conversation is attached.`)}),execute(){throw new V(`page.startTimer is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),sd=B({name:`page.stopDiagnostics`,chromiumOnly:!0,description:`Detach the debugger and take Chrome’s “Browsentic is debugging this browser” bar away. What was collected stays readable by page.readConsole and page.readNetwork afterwards, minus response bodies, which only exist while attached. Call this as soon as you have what you need rather than leaving the bar up.`,input:R({diagnosticsId:N().optional().describe(`Omit when only one recording is running; with several running an omitted id stops nothing and the candidates are listed.`)}),execute(){throw new V(`page.stopDiagnostics is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),cd=B({name:`page.stopMonitor`,description:`Stop a background monitor before it completes. The tab is unpinned again if the monitor pinned it. No notification is shown — the stop was asked for.`,input:R({monitorId:N().optional().describe(`Omit when only one monitor is running; with several running an omitted id stops nothing and the candidates are listed.`)}),execute(){throw new V(`page.stopMonitor is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ld=B({name:`page.stopTimer`,description:`Cancel a scheduled job before it has run out. Nothing further fires and no notification is shown — the stop was asked for.`,input:R({timerId:N().optional().describe(`Omit when only one timer is scheduled; with several an omitted id stops nothing and the candidates are listed.`)}),execute(){throw new V(`page.stopTimer is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),ud=B({name:`page.submitForm`,description:`Submit a form, firing its submit event and validation as if the user pressed Enter.`,input:R({target:K.optional().describe(`The form, or any element inside it; defaults to the first form on the page`)}),execute({target:e}){let t=e?q(e).closest(`form`):document.querySelector(`form`);if(!t)throw new V(`No form found to submit`,`TARGET_NOT_FOUND`);return typeof t.requestSubmit==`function`?t.requestSubmit():t.submit(),{form:X(t),action:t.getAttribute(`action`)||void 0,method:(t.getAttribute(`method`)||`get`).toLowerCase()}}}),dd=B({name:`page.switchTab`,description:`Bring another open tab to the front, making it the tab every later page action targets. Call it with no arguments to list the open tabs and their ids first.`,input:R({tabId:F().int().optional().describe(`Id of the tab to switch to, as reported by page.openTab or a no-argument page.switchTab.`),match:N().optional().describe(`Instead of an id, switch to the tab whose title or URL contains this text (case-insensitive). If several tabs match, nothing is switched and the candidates are listed.`)}),execute(){throw new V(`page.switchTab is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),fd=B({name:`page.timerStatus`,description:`Report on scheduled jobs started with page.startTimer: how many times each has fired, how many fires were skipped because the conversation was still busy, when the next one is due, and the latest log lines.`,input:R({timerId:N().optional().describe(`One timer to report. Omit to list every scheduled and recently finished timer.`)}),execute(){throw new V(`page.timerStatus is resolved by the Browsentic extension, not in the page`,`UNSUPPORTED`)}}),pd=B({name:`page.trustedClick`,description:`Click with a real browser-level mouse event — isTrusted is true, exactly as if the user had clicked. The pointer travels to the target over a short path and dwells before pressing, so widgets that only react after genuine pointer movement (drag handles, hover menus, canvas tools, captcha checkboxes) see the sequence they wait for. Use it when page.clickElement was ignored: pages that check event.isTrusted, and the browser features only a genuine gesture unlocks — native file pickers, fullscreen, clipboard reads, popups, WebAuthn prompts. Give it either a "target" or a raw viewport "point". It attaches Chrome’s debugger for the duration, so the browser shows a “Browsentic is debugging this browser” bar while it runs, and it cannot run on a tab that has DevTools open. page.clickElement stays the default for ordinary clicks.`,chromiumOnly:!0,input:R({target:K.optional().describe(`Element to click. Give this or "point", never both.`),point:$s.optional().describe(`Exact viewport coordinates to click, in CSS pixels. Use this when the thing to click has no reachable element — inside a cross-origin iframe or a closed shadow root, as page.findCaptcha reports.`),button:z([`left`,`right`,`middle`]).default(`left`).describe(`Mouse button to press`),clickCount:F().int().min(1).max(3).default(1).describe(`1 for a single click, 2 for a double click, 3 for a triple click`),modifiers:L(z([`ctrl`,`shift`,`alt`,`meta`])).default([]).describe(`Modifier keys held during the click, e.g. ["meta"] to open a link in a new tab`),scrollIntoView:I().default(!0).describe(`Bring the element into view before clicking. Ignored with "point".`),moveSteps:F().int().min(1).max(60).default(8).describe(`Pointer move events dispatched along the way in. Raise it for widgets that sample the path.`),hoverMs:F().int().min(0).max(2e3).default(60).describe(`Pause on the target after arriving, before pressing.`),holdMs:F().int().min(0).max(2e3).default(50).describe(`How long the button stays down between press and release.`)}),execute({target:e,point:t,button:n,clickCount:r,modifiers:i,scrollIntoView:a,moveSteps:o,hoverMs:s,holdMs:c}){if(!e==!t)throw new V(`Give either a "target" to click or a "point" to click at — not both, not neither`,`INVALID_INPUT`);let l=e?q(e):null;l&&a&&l.scrollIntoView({block:`center`,behavior:`instant`});let u=l?tc(l):nc(t);l&&ic(l,u);let d=Q(u);return{...l?Z(l):{over:d?X(d):void 0},point:u,from:rc(u),button:n,clickCount:r,modifiers:i,moveSteps:o,hoverMs:s,holdMs:c,submits:l?Ps(l):!1}}}),md={slow:400,natural:220,fast:110,instant:0},hd={".":3,"?":3,"!":3,"\n":2.5,",":2,";":2,":":2},gd=12e4,_d=(e,t)=>[...e].map(e=>t*(hd[e]??1)),vd=(e,t)=>Math.round(e.reduce((e,t)=>e+t,0)*(1+t)),yd=e=>new Promise(t=>setTimeout(t,e)),bd=B({name:`page.typeText`,description:`Stream text into a field one keystroke at a time, at a human pace — a real key event per character, pauses that vary, and longer breaths after punctuation. Use page.fillInput when you just need the value in the field; use this when the page should watch someone type.`,input:R({target:K.optional().describe(`Element to type into; defaults to the currently focused element`),text:N().min(1).max(2e3).describe(`Text to type, character by character`),speed:z([`slow`,`natural`,`fast`,`instant`]).default(`natural`).describe(`Typing pace: "slow" ≈ 30 wpm, "natural" ≈ 55 wpm, "fast" ≈ 110 wpm, "instant" fires every keystroke back to back with no pause`),charDelayMs:F().int().min(0).max(2e3).optional().describe(`Average milliseconds between keystrokes; overrides "speed" when given`),jitter:F().min(0).max(1).default(.35).describe(`How much each pause varies at random, as a fraction of it — 0 types in an even machine rhythm, 1 is wildly uneven`),clear:I().default(!0).describe(`Replace existing content instead of appending`),pressEnter:I().default(!1).describe(`Press Enter afterwards, which submits many forms`)}),async execute({target:e,text:t,speed:n,charDelayMs:r,jitter:i,clear:a,pressEnter:o}){let s=e?q(e):document.activeElement??document.body;if(!(s instanceof HTMLInputElement||s instanceof HTMLTextAreaElement)&&!s.isContentEditable)throw new V(`<${s.tagName.toLowerCase()}> is not an editable element`,`INVALID_TARGET`);if(t.includes(`
129
129
  `)&&s instanceof HTMLInputElement)throw new V(`A single-line <input> cannot take newlines — drop them from "text", or set pressEnter to submit`,`INVALID_INPUT`);let c=r??md[n],l=_d(t,c),u=vd(l,i);if(u>gd)throw new V(`Typing ${t.length} characters at ${c}ms each would take about ${Math.round(u/1e3)}s — raise "speed", lower "charDelayMs", or send the text in shorter pieces`,`INVALID_INPUT`);a&&Sd(s),Cd(s);let d=performance.now(),f=[...t];for(let[e,t]of f.entries()){let n=e?Math.round(l[e-1]*(1+(Math.random()*2-1)*i)):0;n>0&&await yd(n),Td(s,t)}let p=!1;if(o){let e=Nc(`Enter`),t=s.dispatchEvent(new KeyboardEvent(`keydown`,e));if(s.dispatchEvent(new KeyboardEvent(`keyup`,e)),t&&!(s instanceof HTMLTextAreaElement)){let e=s.closest(`form`);e?.requestSubmit(),p=!!e}}return{element:Z(s),typed:f.length,charDelayMs:c,elapsedMs:Math.round(performance.now()-d),appended:!a,submitted:p}}});function xd(e,t){let n=e instanceof HTMLInputElement?HTMLInputElement.prototype:HTMLTextAreaElement.prototype;Object.getOwnPropertyDescriptor(n,`value`)?.set?.call(e,t)}function Sd(e){e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?xd(e,``):e.textContent=``,e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,inputType:`deleteContentBackward`}))}function Cd(e){if(e.focus(),e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){let t=e.value.length;try{e.setSelectionRange(t,t)}catch{}return}let t=document.createRange();t.selectNodeContents(e),t.collapse(!1);let n=window.getSelection();n?.removeAllRanges(),n?.addRange(t)}function wd(e,t){if(e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement){let n=e.selectionStart??e.value.length,r=e.selectionEnd??e.value.length;xd(e,e.value.slice(0,n)+t+e.value.slice(r));let i=n+t.length;try{e.setSelectionRange(i,i)}catch{}}else if(document.execCommand(`insertText`,!1,t))return;else e.textContent=(e.textContent??``)+t;e.dispatchEvent(new InputEvent(`input`,{bubbles:!0,data:t,inputType:`insertText`}))}function Td(e,t){let n=Nc(t===`
130
- `?`Enter`:t);e.dispatchEvent(new KeyboardEvent(`keydown`,n))&&(e.dispatchEvent(new KeyboardEvent(`keypress`,n)),wd(e,t)),e.dispatchEvent(new KeyboardEvent(`keyup`,n))}var Ed=B({name:`page.waitForElement`,description:`Wait until an element reaches a state: attached, visible, hidden, or detached.`,input:R({target:K.describe(`Element to wait for`),state:z([`attached`,`visible`,`hidden`,`detached`]).default(`visible`).describe(`State to wait for: present in the DOM, present and visible, invisible or absent, or absent`),timeoutMs:I().int().positive().max(3e4).default(5e3).describe(`Give up after this many milliseconds`)}),async execute({target:e,state:t,timeoutMs:n}){let r=()=>{try{return q(e,{includeHidden:!0})}catch(e){if(e instanceof V&&e.code===`INVALID_TARGET`)throw e;return null}},i=e=>({attached:!!e,visible:!!e&&Y(e),hidden:!e||!Y(e),detached:!e})[t],a=performance.now(),o=r();return i(o)?{state:t,elapsedMs:0,element:o?Z(o):void 0}:(await new Promise((e,a)=>{let s=()=>{o=r(),i(o)&&(d(),e())},c=new MutationObserver(s);c.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0});let l=setInterval(s,250),u=setTimeout(()=>{d(),a(new V(`Timed out after ${n}ms waiting for element to be ${t}`,`TIMEOUT`))},n),d=()=>{c.disconnect(),clearInterval(l),clearTimeout(u)}}),{state:t,elapsedMs:Math.round(performance.now()-a),element:o?Z(o):void 0})}}),Dd=new Map([kl,Ku,Ys,pd,Lc,rd,Hl,yc,Sl,Pc,bd,$u,ed,Ac,fu,pu,ud,Ed,Ul,Uu,ql,qs,Vc,xl,Su,Ls,fs,id,_u,vu,sd,ad,Jl,Ks,cd,od,fd,ld,Vl,Ju,Zl,Ql,dd,Cl,Xs,Gu,Gl,Fs,Js,Wl,Kl,yu].map(e=>[e.name,e]));async function Od(e,t){let n=Dd.get(e);if(!n)return eo(`UNKNOWN_ACTION`,`No action named "${e}"`);let r=n.input.safeParse(t??{});if(!r.success)return eo(`INVALID_INPUT`,Te(r.error));try{return $a(await n.execute(r.data))}catch(e){return e instanceof V?eo(e.code,e.message):eo(`ACTION_FAILED`,e instanceof Error?e.message:String(e))}}function kd(){t.runtime.onMessage.addListener((e,t,n)=>{if(to(e))return Od(e.action,e.input).then(n),!0})}var Ad=`data-browsentic-frame`;function jd(e){return typeof e==`object`&&!!e&&e.channel===`browsentic/frame`&&typeof e.op==`string`}function Md(){t.runtime.onMessage.addListener((e,t,n)=>{if(jd(e))switch(e.op){case`describe`:n(Nd());return;case`mark`:document.documentElement.setAttribute(Ad,e.token),n({ok:!0});return;case`unmark`:document.documentElement.removeAttribute(Ad),n({ok:!0});return;case`locate`:n(Pd(e.frameId));return}})}function Nd(){return{url:location.href,title:document.title,top:window===window.top,viewport:{w:window.innerWidth,h:window.innerHeight}}}function Pd(e){let t=[...document.querySelectorAll(`iframe,frame`)].filter(wl).find(t=>Fd(t,e));if(!t)return null;let n=t.getBoundingClientRect(),r=getComputedStyle(t);return{x:n.x+t.clientLeft+parseFloat(r.paddingLeft),y:n.y+t.clientTop+parseFloat(r.paddingTop)}}function Fd(e,t){try{return El(e)===t}catch{return!1}}var Id=`#ff7a3d`;function Ld(e){return typeof e==`object`&&!!e&&e.channel===`browsentic/indicator`}var $=32,Rd=`browsentic-run-icon`;function zd(){let e=null,n=!1;t.runtime.onMessage.addListener(e=>{if(Ld(e))return e.op===`busy`?r():i(),Promise.resolve({ok:!0})});async function r(){if(n)return;n=!0;let t=Vd();e===null&&(e=t??``);let r=await Hd(t);if(!r||!n)return;let i=document.getElementById(Rd);i||(i=document.createElement(`link`),i.id=Rd,i.rel=`icon`,document.head.append(i)),i.href=r;for(let e of Bd())e.id!==Rd&&e.remove()}function i(){if(!n||(n=!1,document.getElementById(Rd)?.remove(),!e))return;let t=document.createElement(`link`);t.rel=`icon`,t.href=e,document.head.append(t)}}var Bd=()=>[...document.querySelectorAll(`link[rel~="icon"]`)];function Vd(){return Bd().find(e=>e.id!==Rd&&e.href)?.href??null}async function Hd(e){let t=document.createElement(`canvas`);t.width=$,t.height=$;let n=t.getContext(`2d`);if(!n)return null;let r=e?await Ud(e):null;r&&n.drawImage(r,0,0,$,$);let i=$*.3,a=$-i-1;n.beginPath(),n.arc(a,a,11.6,0,Math.PI*2),n.fillStyle=`rgba(0, 0, 0, 0.55)`,n.fill(),n.beginPath(),n.arc(a,a,i,0,Math.PI*2),n.fillStyle=Id,n.fill();try{return t.toDataURL(`image/png`)}catch{return null}}function Ud(e){return new Promise(t=>{let n=new Image;n.crossOrigin=`anonymous`,n.onload=()=>t(n),n.onerror=()=>t(null),n.src=e})}var Wd=/(\d{1,3}(?:\.\d+)?)\s?%/,Gd=120;function Kd(){let e=new Map;t.runtime.onMessage.addListener(t=>{if(ef(t)){if(t.op===`unwatch`){e.get(t.monitorId)?.(),e.delete(t.monitorId);return}!t.until||e.has(t.monitorId)||e.set(t.monitorId,qd(t.monitorId,t.until))}}),$d().then(t=>{for(let{monitorId:n,until:r}of t)e.has(n)||e.set(n,qd(n,r))})}function qd(e,n){let r=n.pattern?Qd(n.pattern):null,i=0,a,o,s,c,l=()=>{let e=Date.now();switch(n.kind){case`element-appears`:return{t:e,matched:!!Jd(n.target)};case`element-vanishes`:return{t:e,matched:!Jd(n.target)};case`progress-reaches`:{let t=Jd(n.target),r=t?Yd(t):void 0;return{t:e,percent:r,matched:r!=null&&r>=n.threshold}}case`text-matches`:{let t=n.target?.selector||n.target?.text?Jd(n.target):null,i=(t?Xd(t):document.body?.innerText??``).slice(0,Gs),a=r?.exec(i);return{t:e,matched:!!a,text:a?.[0]?.slice(0,Gd)}}case`title-matches`:return{t:e,matched:!!r?.test(document.title),text:document.title.slice(0,Gd)}}},u=()=>{let n=l(),r=n.matched!==o,c=n.percent!=null&&(a==null||Math.abs(n.percent-a)>=1),u=n.text!==void 0&&n.text!==s;!r&&!c&&!u||!n.matched&&n.t-i<3e3||(i=n.t,a=n.percent??a,o=n.matched,s=n.text??s,t.runtime.sendMessage({channel:Qa,op:`monitorSample`,monitorId:e,sample:n}).catch(()=>void 0))},d=new MutationObserver(()=>{clearTimeout(c),c=setTimeout(u,500)});d.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});let f=setInterval(u,Ws);return u(),()=>{d.disconnect(),clearInterval(f),clearTimeout(c)}}function Jd(e){if(!e)return null;try{return q(e,{includeHidden:!1})}catch{return null}}function Yd(e){if(e instanceof HTMLProgressElement||e instanceof HTMLMeterElement)return e.max>0?Zd(e.value/e.max*100):void 0;let t=parseFloat(e.getAttribute(`aria-valuenow`)??``);if(Number.isFinite(t)){let n=parseFloat(e.getAttribute(`aria-valuemin`)??`0`)||0,r=parseFloat(e.getAttribute(`aria-valuemax`)??`100`)||100;return r>n?Zd((t-n)/(r-n)*100):void 0}let n=Wd.exec(e.getAttribute(`aria-valuetext`)??``)??Wd.exec(J(e));if(n)return Zd(parseFloat(n[1]));let r=Wd.exec(e.style.width)??Wd.exec(e.firstElementChild?.style.width??``);return r?Zd(parseFloat(r[1])):void 0}function Xd(e){return e.innerText??e.textContent??``}function Zd(e){return Math.min(100,Math.max(0,e))}function Qd(e){try{return new RegExp(e,`i`)}catch{return null}}async function $d(){try{let e=(await t.runtime.sendMessage({channel:Qa,op:`monitorState`}))?.data;return Array.isArray(e?.monitors)?e.monitors:[]}catch{return[]}}function ef(e){return typeof e==`object`&&!!e&&e.channel===`browsentic/monitor`&&typeof e.monitorId==`string`}var tf=`browsentic/rail`;function nf(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.channel===`browsentic/rail`&&(t.op===`show`||t.op===`hide`)}var rf=[{id:`chat`,label:`Chat`,paths:[`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`]},{id:`history`,label:`History`,paths:[`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,`M3 3v5h5`,`M12 7v5l4 2`]},{id:`skills`,label:`Skills`,paths:[`M12 5v16`,`M20.001 19A2 2 0 0 0 22 17V5a2 2 0 0 0-1.999-2L16 3.002A5 5 0 0 0 12 5a5 5 0 0 0-4-2H4a2 2 0 0 0-2 2v12a2 2 0 0 0 1.999 2H8a5 5 0 0 1 4 2 5 5 0 0 1 4-2z`]},{id:`recordings`,label:`Recordings`,paths:[`m12.296 3.464 3.02 3.956`,`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z`,`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,`m6.18 5.276 3.1 3.899`]},{id:`settings`,label:`Settings`,paths:[`M10 5H3`,`M12 19H3`,`M14 3v4`,`M16 17v4`,`M21 12h-9`,`M21 19h-5`,`M21 5h-7`,`M8 10v4`,`M8 12H3`]}],af={ember:{ground:`oklch(0.152 0.016 52)`,ground2:`oklch(0.183 0.018 50)`,surface:`oklch(0.213 0.019 48)`,ink:`oklch(0.958 0.012 70)`,inkDim:`oklch(0.735 0.018 60)`,inkFaint:`oklch(0.575 0.02 55)`,line:`color-mix(in oklch, oklch(0.98 0.01 60) 12%, transparent)`,brand:`oklch(0.83 0.13 195)`},midnight:{ground:`oklch(0.158 0.024 264)`,ground2:`oklch(0.192 0.028 264)`,surface:`oklch(0.228 0.032 264)`,ink:`oklch(0.958 0.012 268)`,inkDim:`oklch(0.742 0.022 266)`,inkFaint:`oklch(0.585 0.026 265)`,line:`color-mix(in oklch, oklch(0.97 0.02 268) 12%, transparent)`,brand:`oklch(0.79 0.15 288)`},phosphor:{ground:`oklch(0.142 0.022 152)`,ground2:`oklch(0.176 0.026 152)`,surface:`oklch(0.208 0.03 150)`,ink:`oklch(0.945 0.06 150)`,inkDim:`oklch(0.755 0.075 150)`,inkFaint:`oklch(0.6 0.062 150)`,line:`color-mix(in oklch, oklch(0.92 0.1 150) 12%, transparent)`,brand:`oklch(0.86 0.2 152)`},daylight:{ground:`oklch(0.988 0.004 88)`,ground2:`oklch(0.968 0.006 84)`,surface:`oklch(0.945 0.008 80)`,ink:`oklch(0.265 0.018 58)`,inkDim:`oklch(0.455 0.02 56)`,inkFaint:`oklch(0.556 0.02 55)`,line:`color-mix(in oklch, oklch(0.32 0.02 58) 12%, transparent)`,brand:`oklch(0.514 0.12 214)`}},of={ember:{off:`color-mix(in oklch, oklch(0.575 0.02 55) 50%, transparent)`,pending:`oklch(0.84 0.15 85)`,live:`oklch(0.84 0.18 150)`,busy:`oklch(0.83 0.13 195)`,listening:`oklch(0.7 0.21 335)`,warn:`oklch(0.735 0.168 42)`},midnight:{off:`color-mix(in oklch, oklch(0.585 0.026 265) 50%, transparent)`,pending:`oklch(0.86 0.14 82)`,live:`oklch(0.85 0.17 165)`,busy:`oklch(0.79 0.15 288)`,listening:`oklch(0.72 0.2 330)`,warn:`oklch(0.75 0.16 22)`},phosphor:{off:`color-mix(in oklch, oklch(0.6 0.062 150) 50%, transparent)`,pending:`oklch(0.87 0.16 92)`,live:`oklch(0.9 0.2 122)`,busy:`oklch(0.86 0.2 152)`,listening:`oklch(0.74 0.2 338)`,warn:`oklch(0.79 0.16 48)`},daylight:{off:`color-mix(in oklch, oklch(0.556 0.02 55) 50%, transparent)`,pending:`oklch(0.562 0.13 68)`,live:`oklch(0.52 0.14 148)`,busy:`oklch(0.514 0.12 214)`,listening:`oklch(0.53 0.2 335)`,warn:`oklch(0.552 0.17 40)`}},sf=`browsentic-rail`;function cf(){let e=null,n=null;t.runtime.onMessage.addListener(e=>{if(nf(e))return e.op===`show`?a(e.view):i(),Promise.resolve({ok:!0})}),document.getElementById(sf)?.remove(),r(),window.addEventListener(`pageshow`,e=>{e.persisted&&(i(),r())});function r(){t.runtime.sendMessage({channel:tf,op:`sync`}).catch(()=>void 0)}function i(){e?.remove(),e=null,n=null}function a(r){if(document.documentElement&&((!e||!e.isConnected)&&(i(),e=document.createElement(`div`),e.id=sf,e.setAttribute(`aria-hidden`,`false`),e.style.cssText=`all: initial; position: static;`,n=e.attachShadow({mode:`closed`}),document.documentElement.append(e)),n)){n.innerHTML=`<style>${pf(r)}</style>${lf(r)}`;for(let e of n.querySelectorAll(`button[data-tab]`))e.addEventListener(`click`,n=>{n.preventDefault(),n.stopPropagation(),t.runtime.sendMessage({channel:tf,op:`open`,tab:e.dataset.tab})})}}}function lf(e){return`<div class="rail" role="toolbar" aria-label="Browsentic">${rf.map(({id:t,label:n,paths:r})=>{let i=t===e.tab,a=t===`chat`&&e.running>0,o=e.counts[t]??0,s=a?`<span class="mark busy"></span>`:o>0?`<span class="mark"></span>`:``,c=a?`${n} — ${df(e.running)}`:n;return`<button type="button" data-tab="${t}" class="tab${i?` active`:``}" title="${ff(c)}" aria-label="${ff(n)}">${uf(r)}${s}</button>`}).join(``)}<span class="sep"></span>${e.running>0?`<span class="runs" title="${ff(df(e.running))}"><i></i><i></i><i></i><b>${e.running}</b></span>`:``}<span class="status" title="${ff(e.status)}"></span></div>`}function uf(e){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e.map(e=>`<path d="${e}"/>`).join(``)}</svg>`}function df(e){return e===1?`A run is in progress`:`${e} runs are in progress`}function ff(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/"/g,`&quot;`)}function pf(e){let t=e.side===`left`?`left: 12px`:`right: 12px`,n=af[e.theme],r=of[e.theme][e.tone];return`
130
+ `?`Enter`:t);e.dispatchEvent(new KeyboardEvent(`keydown`,n))&&(e.dispatchEvent(new KeyboardEvent(`keypress`,n)),wd(e,t)),e.dispatchEvent(new KeyboardEvent(`keyup`,n))}var Ed=B({name:`page.waitForElement`,description:`Wait until an element reaches a state: attached, visible, hidden, or detached.`,input:R({target:K.describe(`Element to wait for`),state:z([`attached`,`visible`,`hidden`,`detached`]).default(`visible`).describe(`State to wait for: present in the DOM, present and visible, invisible or absent, or absent`),timeoutMs:F().int().positive().max(3e4).default(5e3).describe(`Give up after this many milliseconds`)}),async execute({target:e,state:t,timeoutMs:n}){let r=()=>{try{return q(e,{includeHidden:!0})}catch(e){if(e instanceof V&&e.code===`INVALID_TARGET`)throw e;return null}},i=e=>({attached:!!e,visible:!!e&&Y(e),hidden:!e||!Y(e),detached:!e})[t],a=performance.now(),o=r();return i(o)?{state:t,elapsedMs:0,element:o?Z(o):void 0}:(await new Promise((e,a)=>{let s=()=>{o=r(),i(o)&&(d(),e())},c=new MutationObserver(s);c.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0});let l=setInterval(s,250),u=setTimeout(()=>{d(),a(new V(`Timed out after ${n}ms waiting for element to be ${t}`,`TIMEOUT`))},n),d=()=>{c.disconnect(),clearInterval(l),clearTimeout(u)}}),{state:t,elapsedMs:Math.round(performance.now()-a),element:o?Z(o):void 0})}}),Dd=new Map([kl,Ku,Ys,pd,Lc,rd,Hl,yc,Sl,Pc,bd,$u,ed,Ac,fu,pu,ud,Ed,Ul,Uu,ql,qs,Vc,xl,Su,Ls,fs,id,_u,vu,sd,ad,Jl,Ks,cd,od,fd,ld,Vl,Ju,Zl,Ql,dd,Cl,Xs,Gu,Gl,Fs,Js,Wl,Kl,yu].map(e=>[e.name,e]));async function Od(e,t){let n=Dd.get(e);if(!n)return eo(`UNKNOWN_ACTION`,`No action named "${e}"`);let r=n.input.safeParse(t??{});if(!r.success)return eo(`INVALID_INPUT`,Ee(r.error));try{return $a(await n.execute(r.data))}catch(e){return e instanceof V?eo(e.code,e.message):eo(`ACTION_FAILED`,e instanceof Error?e.message:String(e))}}function kd(){t.runtime.onMessage.addListener((e,t,n)=>{if(to(e))return Od(e.action,e.input).then(n),!0})}var Ad=`data-browsentic-frame`;function jd(e){return typeof e==`object`&&!!e&&e.channel===`browsentic/frame`&&typeof e.op==`string`}function Md(){t.runtime.onMessage.addListener((e,t,n)=>{if(jd(e))switch(e.op){case`describe`:n(Nd());return;case`mark`:document.documentElement.setAttribute(Ad,e.token),n({ok:!0});return;case`unmark`:document.documentElement.removeAttribute(Ad),n({ok:!0});return;case`locate`:n(Pd(e.frameId));return}})}function Nd(){return{url:location.href,title:document.title,top:window===window.top,viewport:{w:window.innerWidth,h:window.innerHeight}}}function Pd(e){let t=[...document.querySelectorAll(`iframe,frame`)].filter(wl).find(t=>Fd(t,e));if(!t)return null;let n=t.getBoundingClientRect(),r=getComputedStyle(t);return{x:n.x+t.clientLeft+parseFloat(r.paddingLeft),y:n.y+t.clientTop+parseFloat(r.paddingTop)}}function Fd(e,t){try{return El(e)===t}catch{return!1}}var Id=`#ff7a3d`;function Ld(e){return typeof e==`object`&&!!e&&e.channel===`browsentic/indicator`}var Rd=32,zd=`browsentic-run-icon`;function Bd(){let e=null,n=!1;t.runtime.onMessage.addListener(e=>{if(Ld(e))return e.op===`busy`?r():i(),Promise.resolve({ok:!0})});async function r(){if(n)return;n=!0;let t=Hd();e===null&&(e=t??``);let r=await Ud(t);if(!r||!n)return;let i=document.getElementById(zd);i||(i=document.createElement(`link`),i.id=zd,i.rel=`icon`,document.head.append(i)),i.href=r;for(let e of Vd())e.id!==zd&&e.remove()}function i(){if(!n||(n=!1,document.getElementById(zd)?.remove(),!e))return;let t=document.createElement(`link`);t.rel=`icon`,t.href=e,document.head.append(t)}}var Vd=()=>[...document.querySelectorAll(`link[rel~="icon"]`)];function Hd(){return Vd().find(e=>e.id!==zd&&e.href)?.href??null}async function Ud(e){let t=document.createElement(`canvas`);t.width=Rd,t.height=Rd;let n=t.getContext(`2d`);if(!n)return null;let r=e?await Wd(e):null;r&&n.drawImage(r,0,0,Rd,Rd);let i=Rd*.3,a=Rd-i-1;n.beginPath(),n.arc(a,a,11.6,0,Math.PI*2),n.fillStyle=`rgba(0, 0, 0, 0.55)`,n.fill(),n.beginPath(),n.arc(a,a,i,0,Math.PI*2),n.fillStyle=Id,n.fill();try{return t.toDataURL(`image/png`)}catch{return null}}function Wd(e){return new Promise(t=>{let n=new Image;n.crossOrigin=`anonymous`,n.onload=()=>t(n),n.onerror=()=>t(null),n.src=e})}var Gd=/(\d{1,3}(?:\.\d+)?)\s?%/,Kd=120;function qd(){let e=new Map;t.runtime.onMessage.addListener(t=>{if(tf(t)){if(t.op===`unwatch`){e.get(t.monitorId)?.(),e.delete(t.monitorId);return}!t.until||e.has(t.monitorId)||e.set(t.monitorId,Jd(t.monitorId,t.until))}}),ef().then(t=>{for(let{monitorId:n,until:r}of t)e.has(n)||e.set(n,Jd(n,r))})}function Jd(e,n){let r=n.pattern?$d(n.pattern):null,i=0,a,o,s,c,l=()=>{let e=Date.now();switch(n.kind){case`element-appears`:return{t:e,matched:!!Yd(n.target)};case`element-vanishes`:return{t:e,matched:!Yd(n.target)};case`progress-reaches`:{let t=Yd(n.target),r=t?Xd(t):void 0;return{t:e,percent:r,matched:r!=null&&r>=n.threshold}}case`text-matches`:{let t=n.target?.selector||n.target?.text?Yd(n.target):null,i=(t?Zd(t):document.body?.innerText??``).slice(0,Gs),a=r?.exec(i);return{t:e,matched:!!a,text:a?.[0]?.slice(0,Kd)}}case`title-matches`:return{t:e,matched:!!r?.test(document.title),text:document.title.slice(0,Kd)}}},u=()=>{let n=l(),r=n.matched!==o,c=n.percent!=null&&(a==null||Math.abs(n.percent-a)>=1),u=n.text!==void 0&&n.text!==s;!r&&!c&&!u||!n.matched&&n.t-i<3e3||(i=n.t,a=n.percent??a,o=n.matched,s=n.text??s,t.runtime.sendMessage({channel:Qa,op:`monitorSample`,monitorId:e,sample:n}).catch(()=>void 0))},d=new MutationObserver(()=>{clearTimeout(c),c=setTimeout(u,500)});d.observe(document.documentElement,{subtree:!0,childList:!0,attributes:!0,characterData:!0});let f=setInterval(u,Ws);return u(),()=>{d.disconnect(),clearInterval(f),clearTimeout(c)}}function Yd(e){if(!e)return null;try{return q(e,{includeHidden:!1})}catch{return null}}function Xd(e){if(e instanceof HTMLProgressElement||e instanceof HTMLMeterElement)return e.max>0?Qd(e.value/e.max*100):void 0;let t=parseFloat(e.getAttribute(`aria-valuenow`)??``);if(Number.isFinite(t)){let n=parseFloat(e.getAttribute(`aria-valuemin`)??`0`)||0,r=parseFloat(e.getAttribute(`aria-valuemax`)??`100`)||100;return r>n?Qd((t-n)/(r-n)*100):void 0}let n=Gd.exec(e.getAttribute(`aria-valuetext`)??``)??Gd.exec(J(e));if(n)return Qd(parseFloat(n[1]));let r=Gd.exec(e.style.width)??Gd.exec(e.firstElementChild?.style.width??``);return r?Qd(parseFloat(r[1])):void 0}function Zd(e){return e.innerText??e.textContent??``}function Qd(e){return Math.min(100,Math.max(0,e))}function $d(e){try{return new RegExp(e,`i`)}catch{return null}}async function ef(){try{let e=(await t.runtime.sendMessage({channel:Qa,op:`monitorState`}))?.data;return Array.isArray(e?.monitors)?e.monitors:[]}catch{return[]}}function tf(e){return typeof e==`object`&&!!e&&e.channel===`browsentic/monitor`&&typeof e.monitorId==`string`}var nf=`browsentic/rail`;function rf(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.channel===`browsentic/rail`&&(t.op===`show`||t.op===`hide`)}var af=[{id:`chat`,label:`Chat`,paths:[`M16 10a2 2 0 0 1-2 2H6.828a2 2 0 0 0-1.414.586l-2.202 2.202A.71.71 0 0 1 2 14.286V4a2 2 0 0 1 2-2h10a2 2 0 0 1 2 2z`,`M20 9a2 2 0 0 1 2 2v10.286a.71.71 0 0 1-1.212.502l-2.202-2.202A2 2 0 0 0 17.172 19H10a2 2 0 0 1-2-2v-1`]},{id:`history`,label:`History`,paths:[`M3 12a9 9 0 1 0 9-9 9.75 9.75 0 0 0-6.74 2.74L3 8`,`M3 3v5h5`,`M12 7v5l4 2`]},{id:`skills`,label:`Skills`,paths:[`M12 5v16`,`M20.001 19A2 2 0 0 0 22 17V5a2 2 0 0 0-1.999-2L16 3.002A5 5 0 0 0 12 5a5 5 0 0 0-4-2H4a2 2 0 0 0-2 2v12a2 2 0 0 0 1.999 2H8a5 5 0 0 1 4 2 5 5 0 0 1 4-2z`]},{id:`recordings`,label:`Recordings`,paths:[`m12.296 3.464 3.02 3.956`,`M20.2 6 3 11l-.9-2.4c-.3-1.1.3-2.2 1.3-2.5l13.5-4c1.1-.3 2.2.3 2.5 1.3z`,`M3 11h18v8a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z`,`m6.18 5.276 3.1 3.899`]},{id:`settings`,label:`Settings`,paths:[`M10 5H3`,`M12 19H3`,`M14 3v4`,`M16 17v4`,`M21 12h-9`,`M21 19h-5`,`M21 5h-7`,`M8 10v4`,`M8 12H3`]}],of={ember:{ground:`oklch(0.152 0.016 52)`,ground2:`oklch(0.183 0.018 50)`,surface:`oklch(0.213 0.019 48)`,ink:`oklch(0.958 0.012 70)`,inkDim:`oklch(0.735 0.018 60)`,inkFaint:`oklch(0.575 0.02 55)`,line:`color-mix(in oklch, oklch(0.98 0.01 60) 12%, transparent)`,brand:`oklch(0.83 0.13 195)`},midnight:{ground:`oklch(0.158 0.024 264)`,ground2:`oklch(0.192 0.028 264)`,surface:`oklch(0.228 0.032 264)`,ink:`oklch(0.958 0.012 268)`,inkDim:`oklch(0.742 0.022 266)`,inkFaint:`oklch(0.585 0.026 265)`,line:`color-mix(in oklch, oklch(0.97 0.02 268) 12%, transparent)`,brand:`oklch(0.79 0.15 288)`},phosphor:{ground:`oklch(0.142 0.022 152)`,ground2:`oklch(0.176 0.026 152)`,surface:`oklch(0.208 0.03 150)`,ink:`oklch(0.945 0.06 150)`,inkDim:`oklch(0.755 0.075 150)`,inkFaint:`oklch(0.6 0.062 150)`,line:`color-mix(in oklch, oklch(0.92 0.1 150) 12%, transparent)`,brand:`oklch(0.86 0.2 152)`},daylight:{ground:`oklch(0.988 0.004 88)`,ground2:`oklch(0.968 0.006 84)`,surface:`oklch(0.945 0.008 80)`,ink:`oklch(0.265 0.018 58)`,inkDim:`oklch(0.455 0.02 56)`,inkFaint:`oklch(0.556 0.02 55)`,line:`color-mix(in oklch, oklch(0.32 0.02 58) 12%, transparent)`,brand:`oklch(0.514 0.12 214)`}},sf={ember:{off:`color-mix(in oklch, oklch(0.575 0.02 55) 50%, transparent)`,pending:`oklch(0.84 0.15 85)`,live:`oklch(0.84 0.18 150)`,busy:`oklch(0.83 0.13 195)`,listening:`oklch(0.7 0.21 335)`,warn:`oklch(0.735 0.168 42)`},midnight:{off:`color-mix(in oklch, oklch(0.585 0.026 265) 50%, transparent)`,pending:`oklch(0.86 0.14 82)`,live:`oklch(0.85 0.17 165)`,busy:`oklch(0.79 0.15 288)`,listening:`oklch(0.72 0.2 330)`,warn:`oklch(0.75 0.16 22)`},phosphor:{off:`color-mix(in oklch, oklch(0.6 0.062 150) 50%, transparent)`,pending:`oklch(0.87 0.16 92)`,live:`oklch(0.9 0.2 122)`,busy:`oklch(0.86 0.2 152)`,listening:`oklch(0.74 0.2 338)`,warn:`oklch(0.79 0.16 48)`},daylight:{off:`color-mix(in oklch, oklch(0.556 0.02 55) 50%, transparent)`,pending:`oklch(0.562 0.13 68)`,live:`oklch(0.52 0.14 148)`,busy:`oklch(0.514 0.12 214)`,listening:`oklch(0.53 0.2 335)`,warn:`oklch(0.552 0.17 40)`}},cf=`browsentic-rail`;function lf(){let e=null,n=null;t.runtime.onMessage.addListener(e=>{if(rf(e))return e.op===`show`?a(e.view):i(),Promise.resolve({ok:!0})}),document.getElementById(cf)?.remove(),r(),window.addEventListener(`pageshow`,e=>{e.persisted&&(i(),r())});function r(){t.runtime.sendMessage({channel:nf,op:`sync`}).catch(()=>void 0)}function i(){e?.remove(),e=null,n=null}function a(r){if(document.documentElement&&((!e||!e.isConnected)&&(i(),e=document.createElement(`div`),e.id=cf,e.setAttribute(`aria-hidden`,`false`),e.style.cssText=`all: initial; position: static;`,n=e.attachShadow({mode:`closed`}),document.documentElement.append(e)),n)){n.innerHTML=`<style>${mf(r)}</style>${uf(r)}`;for(let e of n.querySelectorAll(`button[data-tab]`))e.addEventListener(`click`,n=>{n.preventDefault(),n.stopPropagation(),t.runtime.sendMessage({channel:nf,op:`open`,tab:e.dataset.tab})})}}}function uf(e){return`<div class="rail" role="toolbar" aria-label="Browsentic">${af.map(({id:t,label:n,paths:r})=>{let i=t===e.tab,a=t===`chat`&&e.running>0,o=e.counts[t]??0,s=a?`<span class="mark busy"></span>`:o>0?`<span class="mark"></span>`:``,c=a?`${n} — ${ff(e.running)}`:n;return`<button type="button" data-tab="${t}" class="tab${i?` active`:``}" title="${pf(c)}" aria-label="${pf(n)}">${df(r)}${s}</button>`}).join(``)}<span class="sep"></span>${e.running>0?`<span class="runs" title="${pf(ff(e.running))}"><i></i><i></i><i></i><b>${e.running}</b></span>`:``}<span class="status" title="${pf(e.status)}"></span></div>`}function df(e){return`<svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true">${e.map(e=>`<path d="${e}"/>`).join(``)}</svg>`}function ff(e){return e===1?`A run is in progress`:`${e} runs are in progress`}function pf(e){return e.replace(/&/g,`&amp;`).replace(/</g,`&lt;`).replace(/"/g,`&quot;`)}function mf(e){let t=e.side===`left`?`left: 12px`:`right: 12px`,n=of[e.theme],r=sf[e.theme][e.tone];return`
131
131
  :host { all: initial; }
132
132
  * { box-sizing: border-box; margin: 0; padding: 0; }
133
133
  .rail {
@@ -214,7 +214,7 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
214
214
  @media (prefers-reduced-motion: reduce) {
215
215
  .mark.busy, .runs i { animation: none; }
216
216
  }
217
- `}var mf=`browsentic.`;`${mf}`,`${mf}`,`${mf}`,`${mf}`,`${mf}`;var hf=1e3,gf=/pass|ssn|card|cvv|cvc|otp|secret|token|pin\b/i,_f=/cc-|new-password|current-password|one-time-code/i;function vf(e){let t=(e.type??``).toLowerCase();return t===`password`||t===`hidden`||_f.test(e.autocomplete??``)||gf.test(e.name??``)||gf.test(e.id??``)?!0:yf(e.value??``)}function yf(e){let t=e.replace(/[\s-]/g,``);if(!/^\d{13,19}$/.test(t))return!1;let n=0,r=!1;for(let e=t.length-1;e>=0;--e){let i=t.charCodeAt(e)-48;r&&(i*=2,i>9&&(i-=9)),n+=i,r=!r}return n%10==0}function bf(e,t){let n=e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,32)||`value`;if(!t.has(n))return n;for(let e=2;e<100;e+=1){let r=`${n}_${e}`;if(!t.has(r))return r}return`${n}_x`}var xf=new Set([`Enter`,`Tab`,`Escape`,`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Backspace`,`Delete`,`Home`,`End`,`PageUp`,`PageDown`]);function Sf({captureValues:e,send:t}){let n=[],r=new Set,i=new Map,a=null,o=0,s=``,c=0,l=null,u=()=>{n.length&&t(n.splice(0,n.length))},d=e=>{n.push(e),n.length>=20&&u()},f=e=>{let t=J(e).replace(/\s+/g,` `).trim().slice(0,80);return{selector:X(e).slice(0,200),text:t||void 0,role:e.getAttribute(`role`)?.toLowerCase()||e.tagName.toLowerCase()}},p=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e.value:e.textContent??``,m=(t,n,a,o)=>{let s=vf({type:t instanceof HTMLInputElement?t.type:t.tagName.toLowerCase(),name:t.getAttribute(`name`)??``,id:t.id,autocomplete:t.getAttribute(`autocomplete`)??``,value:o});if(!e||s){let e=i.get(a);if(e)return`{{${e}}}`;let t=bf(n,r);return r.add(t),i.set(a,t),`{{${t}}}`}return o.replace(/\s+/g,` `).trim().slice(0,120)},h=()=>{let e=a;if(a=null,!e)return;let{el:t,target:n}=e,r=n.text||t.getAttribute(`name`)||t.id||`field`,i=t instanceof HTMLInputElement?t.type:t.tagName.toLowerCase();d({t:Date.now(),kind:`fill`,target:n,field:r.slice(0,80),inputKind:i,value:m(t,r,n.selector,p(t)),url:location.href})},g=()=>{let e=n[n.length-1];e?.kind===`scroll`&&Date.now()-e.t<1200&&n.pop()},_=e=>{let t=e.target;Cf(t)&&(a&&a.el!==t&&h(),a||={el:t,target:f(t)})},v=e=>{let t=e.target;if(t instanceof HTMLSelectElement){let e=t.selectedOptions[0],n=f(t),r=n.text||t.getAttribute(`name`)||t.id||`field`,i=m(t,r,n.selector,t.value),a=i.startsWith(`{{`);d({t:Date.now(),kind:`select`,target:n,value:i,label:a?void 0:e?.text.trim().slice(0,80)||void 0,url:location.href});return}a&&a.el===t&&h()},ee=e=>{a&&a.el===e.target&&h()},te=e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`a,button,input,select,textarea,summary,label,[role],[onclick]`)??t;if(n instanceof HTMLInputElement&&(n.type===`text`||n.type===`password`))return;let r=f(n),i=Date.now();r.selector===s&&i-o<250||(o=i,s=r.selector,h(),g(),d({t:i,kind:`click`,target:r,url:location.href}))},ne=e=>{let t=e,n=[t.ctrlKey&&`Control`,t.metaKey&&`Meta`,t.altKey&&`Alt`,t.shiftKey&&`Shift`].filter(e=>typeof e==`string`);if(!xf.has(t.key)&&!n.some(e=>e!==`Shift`))return;(t.key===`Enter`||t.key===`Tab`)&&h();let r=t.target;d({t:Date.now(),kind:`key`,key:t.key,modifiers:n,target:r instanceof Element?f(r):void 0,url:location.href})},re=e=>{let t=e.target;t instanceof Element&&(h(),d({t:Date.now(),kind:`submit`,target:f(t),url:location.href}),u())},y=()=>{let e=Date.now();e-c<1e3||(c=e,n[n.length-1]?.kind===`scroll`&&n.pop(),d({t:e,kind:`scroll`,y:Math.round(window.scrollY),url:location.href}))},ie=()=>{let e=window.getSelection(),t=e?.anchorNode,n=t instanceof Element?t:t?.parentElement??null;n&&d({t:Date.now(),kind:`copy`,target:f(n),length:e?.toString().length??0,url:location.href})},ae=()=>{h(),u()},b=[[`input`,_,!0],[`change`,v,!0],[`blur`,ee,!0],[`click`,te,!0],[`keydown`,ne,!0],[`submit`,re,!0],[`copy`,ie,!0]];for(let[e,t,n]of b)document.addEventListener(e,t,n);return window.addEventListener(`scroll`,y,{passive:!0}),window.addEventListener(`pagehide`,ae),l=setInterval(u,hf),()=>{for(let[e,t,n]of b)document.removeEventListener(e,t,n);window.removeEventListener(`scroll`,y),window.removeEventListener(`pagehide`,ae),l&&clearInterval(l),h(),u()}}function Cf(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function wf(){let e=null,n=n=>{e||=Sf({captureValues:n,send:e=>{t.runtime.sendMessage({channel:Qa,op:`recordEvents`,events:e}).catch(()=>void 0)}})},r=()=>{e?.(),e=null};t.runtime.onMessage.addListener(e=>{Ef(e)&&(e.op===`begin`?Tf().then(e=>e.recording&&n(e.captureValues)):r())}),Tf().then(e=>{e.recording&&n(e.captureValues)})}async function Tf(){try{let e=(await t.runtime.sendMessage({channel:Qa,op:`recordingState`}))?.data;return{recording:e?.recording===!0,captureValues:e?.captureValues===!0}}catch{return{recording:!1,captureValues:!1}}}function Ef(e){return typeof e==`object`&&!!e&&e.channel===`browsentic/record`}var Df=`browsentic/toast`;function Of(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.channel===`browsentic/toast`&&(t.op===`show`||t.op===`hide`)}var kf=`browsentic-toast`,Af=180;function jf(){let e=null,n=null,r=null,i=new Map;t.runtime.onMessage.addListener((e,t,n)=>{if(Of(e)){if(e.op===`hide`){e.toastId?o(e.toastId):a(),n({ok:!0});return}n({ok:c(e.view)})}}),document.getElementById(kf)?.remove(),window.addEventListener(`pageshow`,e=>{e.persisted&&a()});function a(){for(let e of i.values())e();i.clear(),e?.remove(),e=null,n=null,r=null}function o(e){i.get(e)?.(),i.delete(e);let t=r?.querySelector(`[data-toast="${CSS.escape(e)}"]`);t&&(t.classList.add(`out`),setTimeout(()=>{t.remove(),r&&!r.childElementCount&&a()},Af))}function s(t){if(!document.documentElement||((!e||!e.isConnected)&&(a(),e=document.createElement(`div`),e.id=kf,e.style.cssText=`all: initial; position: static;`,n=e.attachShadow({mode:`closed`}),n.innerHTML=`<style>${Mf}</style><div class="stack" role="region" aria-label="Browsentic"></div>`,r=n.querySelector(`.stack`),document.documentElement.append(e)),!r))return!1;let i=af[t.theme];for(let[e,t]of Object.entries(i))r.style.setProperty(`--${e}`,t);return!0}function c(e){if(!s(e))return!1;u(e.toastId);let n=document.createElement(`div`);n.className=`card`,n.dataset.toast=e.toastId,n.setAttribute(`role`,`status`),n.style.setProperty(`--tone`,of[e.theme][e.tone]),n.innerHTML=`
217
+ `}var $=`browsentic.`;`${$}`,`${$}`,`${$}`,`${$}`,`${$}`,`${$}`;var hf=1e3,gf=/pass|ssn|card|cvv|cvc|otp|secret|token|pin\b/i,_f=/cc-|new-password|current-password|one-time-code/i;function vf(e){let t=(e.type??``).toLowerCase();return t===`password`||t===`hidden`||_f.test(e.autocomplete??``)||gf.test(e.name??``)||gf.test(e.id??``)?!0:yf(e.value??``)}function yf(e){let t=e.replace(/[\s-]/g,``);if(!/^\d{13,19}$/.test(t))return!1;let n=0,r=!1;for(let e=t.length-1;e>=0;--e){let i=t.charCodeAt(e)-48;r&&(i*=2,i>9&&(i-=9)),n+=i,r=!r}return n%10==0}function bf(e,t){let n=e.toLowerCase().replace(/[^a-z0-9]+/g,`_`).replace(/^_+|_+$/g,``).slice(0,32)||`value`;if(!t.has(n))return n;for(let e=2;e<100;e+=1){let r=`${n}_${e}`;if(!t.has(r))return r}return`${n}_x`}var xf=new Set([`Enter`,`Tab`,`Escape`,`ArrowUp`,`ArrowDown`,`ArrowLeft`,`ArrowRight`,`Backspace`,`Delete`,`Home`,`End`,`PageUp`,`PageDown`]);function Sf({captureValues:e,send:t}){let n=[],r=new Set,i=new Map,a=null,o=0,s=``,c=0,l=null,u=()=>{n.length&&t(n.splice(0,n.length))},d=e=>{n.push(e),n.length>=20&&u()},f=e=>{let t=J(e).replace(/\s+/g,` `).trim().slice(0,80);return{selector:X(e).slice(0,200),text:t||void 0,role:e.getAttribute(`role`)?.toLowerCase()||e.tagName.toLowerCase()}},p=e=>e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement?e.value:e.textContent??``,m=(t,n,a,o)=>{let s=vf({type:t instanceof HTMLInputElement?t.type:t.tagName.toLowerCase(),name:t.getAttribute(`name`)??``,id:t.id,autocomplete:t.getAttribute(`autocomplete`)??``,value:o});if(!e||s){let e=i.get(a);if(e)return`{{${e}}}`;let t=bf(n,r);return r.add(t),i.set(a,t),`{{${t}}}`}return o.replace(/\s+/g,` `).trim().slice(0,120)},h=()=>{let e=a;if(a=null,!e)return;let{el:t,target:n}=e,r=n.text||t.getAttribute(`name`)||t.id||`field`,i=t instanceof HTMLInputElement?t.type:t.tagName.toLowerCase();d({t:Date.now(),kind:`fill`,target:n,field:r.slice(0,80),inputKind:i,value:m(t,r,n.selector,p(t)),url:location.href})},g=()=>{let e=n[n.length-1];e?.kind===`scroll`&&Date.now()-e.t<1200&&n.pop()},_=e=>{let t=e.target;Cf(t)&&(a&&a.el!==t&&h(),a||={el:t,target:f(t)})},v=e=>{let t=e.target;if(t instanceof HTMLSelectElement){let e=t.selectedOptions[0],n=f(t),r=n.text||t.getAttribute(`name`)||t.id||`field`,i=m(t,r,n.selector,t.value),a=i.startsWith(`{{`);d({t:Date.now(),kind:`select`,target:n,value:i,label:a?void 0:e?.text.trim().slice(0,80)||void 0,url:location.href});return}a&&a.el===t&&h()},ee=e=>{a&&a.el===e.target&&h()},te=e=>{let t=e.target;if(!(t instanceof Element))return;let n=t.closest(`a,button,input,select,textarea,summary,label,[role],[onclick]`)??t;if(n instanceof HTMLInputElement&&(n.type===`text`||n.type===`password`))return;let r=f(n),i=Date.now();r.selector===s&&i-o<250||(o=i,s=r.selector,h(),g(),d({t:i,kind:`click`,target:r,url:location.href}))},ne=e=>{let t=e,n=[t.ctrlKey&&`Control`,t.metaKey&&`Meta`,t.altKey&&`Alt`,t.shiftKey&&`Shift`].filter(e=>typeof e==`string`);if(!xf.has(t.key)&&!n.some(e=>e!==`Shift`))return;(t.key===`Enter`||t.key===`Tab`)&&h();let r=t.target;d({t:Date.now(),kind:`key`,key:t.key,modifiers:n,target:r instanceof Element?f(r):void 0,url:location.href})},re=e=>{let t=e.target;t instanceof Element&&(h(),d({t:Date.now(),kind:`submit`,target:f(t),url:location.href}),u())},y=()=>{let e=Date.now();e-c<1e3||(c=e,n[n.length-1]?.kind===`scroll`&&n.pop(),d({t:e,kind:`scroll`,y:Math.round(window.scrollY),url:location.href}))},ie=()=>{let e=window.getSelection(),t=e?.anchorNode,n=t instanceof Element?t:t?.parentElement??null;n&&d({t:Date.now(),kind:`copy`,target:f(n),length:e?.toString().length??0,url:location.href})},ae=()=>{h(),u()},b=[[`input`,_,!0],[`change`,v,!0],[`blur`,ee,!0],[`click`,te,!0],[`keydown`,ne,!0],[`submit`,re,!0],[`copy`,ie,!0]];for(let[e,t,n]of b)document.addEventListener(e,t,n);return window.addEventListener(`scroll`,y,{passive:!0}),window.addEventListener(`pagehide`,ae),l=setInterval(u,hf),()=>{for(let[e,t,n]of b)document.removeEventListener(e,t,n);window.removeEventListener(`scroll`,y),window.removeEventListener(`pagehide`,ae),l&&clearInterval(l),h(),u()}}function Cf(e){return e instanceof HTMLInputElement||e instanceof HTMLTextAreaElement||e instanceof HTMLElement&&e.isContentEditable}function wf(){let e=null,n=n=>{e||=Sf({captureValues:n,send:e=>{t.runtime.sendMessage({channel:Qa,op:`recordEvents`,events:e}).catch(()=>void 0)}})},r=()=>{e?.(),e=null};t.runtime.onMessage.addListener(e=>{Ef(e)&&(e.op===`begin`?Tf().then(e=>e.recording&&n(e.captureValues)):r())}),Tf().then(e=>{e.recording&&n(e.captureValues)})}async function Tf(){try{let e=(await t.runtime.sendMessage({channel:Qa,op:`recordingState`}))?.data;return{recording:e?.recording===!0,captureValues:e?.captureValues===!0}}catch{return{recording:!1,captureValues:!1}}}function Ef(e){return typeof e==`object`&&!!e&&e.channel===`browsentic/record`}var Df=`browsentic/toast`;function Of(e){if(typeof e!=`object`||!e)return!1;let t=e;return t.channel===`browsentic/toast`&&(t.op===`show`||t.op===`hide`)}var kf=`browsentic-toast`,Af=180;function jf(){let e=null,n=null,r=null,i=new Map;t.runtime.onMessage.addListener((e,t,n)=>{if(Of(e)){if(e.op===`hide`){e.toastId?o(e.toastId):a(),n({ok:!0});return}n({ok:c(e.view)})}}),document.getElementById(kf)?.remove(),window.addEventListener(`pageshow`,e=>{e.persisted&&a()});function a(){for(let e of i.values())e();i.clear(),e?.remove(),e=null,n=null,r=null}function o(e){i.get(e)?.(),i.delete(e);let t=r?.querySelector(`[data-toast="${CSS.escape(e)}"]`);t&&(t.classList.add(`out`),setTimeout(()=>{t.remove(),r&&!r.childElementCount&&a()},Af))}function s(t){if(!document.documentElement||((!e||!e.isConnected)&&(a(),e=document.createElement(`div`),e.id=kf,e.style.cssText=`all: initial; position: static;`,n=e.attachShadow({mode:`closed`}),n.innerHTML=`<style>${Mf}</style><div class="stack" role="region" aria-label="Browsentic"></div>`,r=n.querySelector(`.stack`),document.documentElement.append(e)),!r))return!1;let i=of[t.theme];for(let[e,t]of Object.entries(i))r.style.setProperty(`--${e}`,t);return!0}function c(e){if(!s(e))return!1;u(e.toastId);let n=document.createElement(`div`);n.className=`card`,n.dataset.toast=e.toastId,n.setAttribute(`role`,`status`),n.style.setProperty(`--tone`,sf[e.theme][e.tone]),n.innerHTML=`
218
218
  <button type="button" class="close" aria-label="Dismiss">
219
219
  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.4" stroke-linecap="round" aria-hidden="true"><path d="M18 6 6 18"/><path d="m6 6 12 12"/></svg>
220
220
  </button>
@@ -296,5 +296,5 @@ Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.
296
296
  .card, .card.out { animation: none; }
297
297
  .bar i { width: 100%; animation: none; }
298
298
  }
299
- `,Nf=e({matches:[`*://*/*`],main(){let e=globalThis;e.__browsenticActions||(e.__browsenticActions=!0,kd(),Md(),window===window.top&&(wf(),Kd(),zd(),cf(),jf()))}}),Pf={debug:(...e)=>([...e],void 0),log:(...e)=>([...e],void 0),warn:(...e)=>([...e],void 0),error:(...e)=>([...e],void 0)},Ff=class e extends Event{static EVENT_NAME=If(`wxt:locationchange`);constructor(t,n){super(e.EVENT_NAME,{}),this.newUrl=t,this.oldUrl=n}};function If(e){return`${t?.runtime?.id}:content:${e}`}var Lf=typeof globalThis.navigation?.addEventListener==`function`;function Rf(e){let t,n=!1;return{run(){n||(n=!0,t=new URL(location.href),Lf?globalThis.navigation.addEventListener(`navigate`,e=>{let n=new URL(e.destination.url);n.href!==t.href&&(window.dispatchEvent(new Ff(n,t)),t=n)},{signal:e.signal}):e.setInterval(()=>{let e=new URL(location.href);e.href!==t.href&&(window.dispatchEvent(new Ff(e,t)),t=e)},1e3))}}}var zf=class e{static SCRIPT_STARTED_MESSAGE_TYPE=If(`wxt:content-script-started`);id;abortController;locationWatcher=Rf(this);constructor(e,t){this.contentScriptName=e,this.options=t,this.id=Math.random().toString(36).slice(2),this.abortController=new AbortController,this.stopOldScripts(),this.listenForNewerScripts()}get signal(){return this.abortController.signal}abort(e){return this.abortController.abort(e)}get isInvalid(){return t.runtime?.id??this.notifyInvalidated(),this.signal.aborted}get isValid(){return!this.isInvalid}onInvalidated(e){return this.signal.addEventListener(`abort`,e),()=>this.signal.removeEventListener(`abort`,e)}block(){return new Promise(()=>{})}setInterval(e,t){let n=setInterval(()=>{this.isValid&&e()},t);return this.onInvalidated(()=>clearInterval(n)),n}setTimeout(e,t){let n=setTimeout(()=>{this.isValid&&e()},t);return this.onInvalidated(()=>clearTimeout(n)),n}requestAnimationFrame(e){let t=requestAnimationFrame((...t)=>{this.isValid&&e(...t)});return this.onInvalidated(()=>cancelAnimationFrame(t)),t}requestIdleCallback(e,t){let n=requestIdleCallback((...t)=>{this.signal.aborted||e(...t)},t);return this.onInvalidated(()=>cancelIdleCallback(n)),n}addEventListener(e,t,n,r){t===`wxt:locationchange`&&this.isValid&&this.locationWatcher.run(),e.addEventListener?.(t.startsWith(`wxt:`)?If(t):t,n,{...r,signal:this.signal})}notifyInvalidated(){this.abort(`Content script context invalidated`),Pf.debug(`Content script "${this.contentScriptName}" context invalidated`)}stopOldScripts(){document.dispatchEvent(new CustomEvent(e.SCRIPT_STARTED_MESSAGE_TYPE,{detail:{contentScriptName:this.contentScriptName,messageId:this.id}})),this.options?.noScriptStartedPostMessage||window.postMessage({type:e.SCRIPT_STARTED_MESSAGE_TYPE,contentScriptName:this.contentScriptName,messageId:this.id},`*`)}verifyScriptStartedEvent(e){let t=e.detail?.contentScriptName===this.contentScriptName,n=e.detail?.messageId===this.id;return t&&!n}listenForNewerScripts(){let t=e=>{!(e instanceof CustomEvent)||!this.verifyScriptStartedEvent(e)||this.notifyInvalidated()};document.addEventListener(e.SCRIPT_STARTED_MESSAGE_TYPE,t),this.onInvalidated(()=>document.removeEventListener(e.SCRIPT_STARTED_MESSAGE_TYPE,t))}},Bf={debug:(...e)=>([...e],void 0),log:(...e)=>([...e],void 0),warn:(...e)=>([...e],void 0),error:(...e)=>([...e],void 0)};return(async()=>{try{let{main:e,...t}=Nf;return await e(new zf(`content`,t))}catch(e){throw Bf.error(`The content script "content" crashed on startup!`,e),e}})()})();
299
+ `,Nf=e({matches:[`*://*/*`],main(){let e=globalThis;e.__browsenticActions||(e.__browsenticActions=!0,kd(),Md(),window===window.top&&(wf(),qd(),Bd(),lf(),jf()))}}),Pf={debug:(...e)=>([...e],void 0),log:(...e)=>([...e],void 0),warn:(...e)=>([...e],void 0),error:(...e)=>([...e],void 0)},Ff=class e extends Event{static EVENT_NAME=If(`wxt:locationchange`);constructor(t,n){super(e.EVENT_NAME,{}),this.newUrl=t,this.oldUrl=n}};function If(e){return`${t?.runtime?.id}:content:${e}`}var Lf=typeof globalThis.navigation?.addEventListener==`function`;function Rf(e){let t,n=!1;return{run(){n||(n=!0,t=new URL(location.href),Lf?globalThis.navigation.addEventListener(`navigate`,e=>{let n=new URL(e.destination.url);n.href!==t.href&&(window.dispatchEvent(new Ff(n,t)),t=n)},{signal:e.signal}):e.setInterval(()=>{let e=new URL(location.href);e.href!==t.href&&(window.dispatchEvent(new Ff(e,t)),t=e)},1e3))}}}var zf=class e{static SCRIPT_STARTED_MESSAGE_TYPE=If(`wxt:content-script-started`);id;abortController;locationWatcher=Rf(this);constructor(e,t){this.contentScriptName=e,this.options=t,this.id=Math.random().toString(36).slice(2),this.abortController=new AbortController,this.stopOldScripts(),this.listenForNewerScripts()}get signal(){return this.abortController.signal}abort(e){return this.abortController.abort(e)}get isInvalid(){return t.runtime?.id??this.notifyInvalidated(),this.signal.aborted}get isValid(){return!this.isInvalid}onInvalidated(e){return this.signal.addEventListener(`abort`,e),()=>this.signal.removeEventListener(`abort`,e)}block(){return new Promise(()=>{})}setInterval(e,t){let n=setInterval(()=>{this.isValid&&e()},t);return this.onInvalidated(()=>clearInterval(n)),n}setTimeout(e,t){let n=setTimeout(()=>{this.isValid&&e()},t);return this.onInvalidated(()=>clearTimeout(n)),n}requestAnimationFrame(e){let t=requestAnimationFrame((...t)=>{this.isValid&&e(...t)});return this.onInvalidated(()=>cancelAnimationFrame(t)),t}requestIdleCallback(e,t){let n=requestIdleCallback((...t)=>{this.signal.aborted||e(...t)},t);return this.onInvalidated(()=>cancelIdleCallback(n)),n}addEventListener(e,t,n,r){t===`wxt:locationchange`&&this.isValid&&this.locationWatcher.run(),e.addEventListener?.(t.startsWith(`wxt:`)?If(t):t,n,{...r,signal:this.signal})}notifyInvalidated(){this.abort(`Content script context invalidated`),Pf.debug(`Content script "${this.contentScriptName}" context invalidated`)}stopOldScripts(){document.dispatchEvent(new CustomEvent(e.SCRIPT_STARTED_MESSAGE_TYPE,{detail:{contentScriptName:this.contentScriptName,messageId:this.id}})),this.options?.noScriptStartedPostMessage||window.postMessage({type:e.SCRIPT_STARTED_MESSAGE_TYPE,contentScriptName:this.contentScriptName,messageId:this.id},`*`)}verifyScriptStartedEvent(e){let t=e.detail?.contentScriptName===this.contentScriptName,n=e.detail?.messageId===this.id;return t&&!n}listenForNewerScripts(){let t=e=>{!(e instanceof CustomEvent)||!this.verifyScriptStartedEvent(e)||this.notifyInvalidated()};document.addEventListener(e.SCRIPT_STARTED_MESSAGE_TYPE,t),this.onInvalidated(()=>document.removeEventListener(e.SCRIPT_STARTED_MESSAGE_TYPE,t))}},Bf={debug:(...e)=>([...e],void 0),log:(...e)=>([...e],void 0),warn:(...e)=>([...e],void 0),error:(...e)=>([...e],void 0)};return(async()=>{try{let{main:e,...t}=Nf;return await e(new zf(`content`,t))}catch(e){throw Bf.error(`The content script "content" crashed on startup!`,e),e}})()})();
300
300
  content;