firefox-cli 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +661 -0
- package/README.md +68 -0
- package/bin/darwin-arm64/firefox-cli +0 -0
- package/bin/firefox-cli.js +31 -0
- package/extension/development/background.js +73 -0
- package/extension/development/content.js +68 -0
- package/extension/development/firefox-cli-0.1.1.zip +0 -0
- package/extension/development/manifest.json +44 -0
- package/extension/development/popup.css +128 -0
- package/extension/development/popup.html +23 -0
- package/extension/development/popup.js +64 -0
- package/extension/firefox-cli.xpi +0 -0
- package/extension/firefox-cli.xpi.provenance.json +10 -0
- package/lib/platform-binary.js +31 -0
- package/package.json +17 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
class lr{#e=new Map;#t;#n;#r;#o;#i;constructor(t){this.#t=t.timeoutMs,this.#n=n=>t.onDuplicate(n),this.#r=n=>t.onTimeout(n),this.#o=t.setTimer??((n,o)=>globalThis.setTimeout(n,o)),this.#i=t.clearTimer??(n=>{globalThis.clearTimeout(n)})}get size(){return this.#e.size}track(t){if(this.#e.has(t.id))return{ok:!1,value:this.#n(t)};let n;const o=new Promise(i=>{n=i}),r={request:t,resolve:i=>{n?.(i)},timeout:void 0};return this.#e.set(t.id,r),r.timeout=this.#o(()=>{this.settle(t.id,this.#r(t))},this.#t),{ok:!0,promise:o}}getCommand(t){return this.#e.get(t)?.request.command}settle(t,n){const o=this.#e.get(t);return o===void 0?{ok:!1}:(this.#e.delete(t),o.timeout!==void 0&&this.#i(o.timeout),o.resolve(n),{ok:!0,command:o.request.command})}cancel(t,n){return this.settle(t,n)}drain(t){const n=[...this.#e.values()];for(const o of n)this.settle(o.request.id,t(o.request));return n.length}}const xn="firefox-cli",An="firefox_cli",ee=3,Pn=1,zn=ee,ct=1e5,On=9e5,ye=8e6,Nn=9e5,dr=3,pr=20,ut=512e3,lt=64e4;var Dt;function d(e,t,n){function o(a,c){if(a._zod||Object.defineProperty(a,"_zod",{value:{def:c,constr:s,traits:new Set},enumerable:!1}),a._zod.traits.has(e))return;a._zod.traits.add(e),t(a,c);const l=s.prototype,f=Object.keys(l);for(let g=0;g<f.length;g++){const b=f[g];b in a||(a[b]=l[b].bind(a))}}const r=n?.Parent??Object;class i extends r{}Object.defineProperty(i,"name",{value:e});function s(a){var c;const l=n?.Parent?new i:this;o(l,a),(c=l._zod).deferred??(c.deferred=[]);for(const f of l._zod.deferred)f();return l}return Object.defineProperty(s,"init",{value:o}),Object.defineProperty(s,Symbol.hasInstance,{value:a=>n?.Parent&&a instanceof n.Parent?!0:a?._zod?.traits?.has(e)}),Object.defineProperty(s,"name",{value:e}),s}class me extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}}class Cn extends Error{constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}}(Dt=globalThis).__zod_globalConfig??(Dt.__zod_globalConfig={});const St=globalThis.__zod_globalConfig;function te(e){return St}function $n(e){const t=Object.values(e).filter(o=>typeof o=="number");return Object.entries(e).filter(([o,r])=>t.indexOf(+o)===-1).map(([o,r])=>r)}function wt(e,t){return typeof t=="bigint"?t.toString():t}function Ye(e){return{get value(){{const t=e();return Object.defineProperty(this,"value",{value:t}),t}}}}function Tt(e){return e==null}function It(e){const t=e.startsWith("^")?1:0,n=e.endsWith("$")?e.length-1:e.length;return e.slice(t,n)}function fr(e,t){const n=e/t,o=Math.round(n),r=Number.EPSILON*Math.max(Math.abs(n),1);return Math.abs(n-o)<r?0:n-o}const Zt=Symbol("evaluating");function I(e,t,n){let o;Object.defineProperty(e,t,{get(){if(o!==Zt)return o===void 0&&(o=Zt,o=n()),o},set(r){Object.defineProperty(e,t,{value:r})},configurable:!0})}function de(e,t,n){Object.defineProperty(e,t,{value:n,writable:!0,enumerable:!0,configurable:!0})}function ie(...e){const t={};for(const n of e){const o=Object.getOwnPropertyDescriptors(n);Object.assign(t,o)}return Object.defineProperties({},t)}function Vt(e){return JSON.stringify(e)}function mr(e){return e.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}const Mn="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function ke(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const hr=Ye(()=>{if(St.jitless||typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{const e=Function;return new e(""),!0}catch{return!1}});function he(e){if(ke(e)===!1)return!1;const t=e.constructor;if(t===void 0||typeof t!="function")return!0;const n=t.prototype;return!(ke(n)===!1||Object.prototype.hasOwnProperty.call(n,"isPrototypeOf")===!1)}function Dn(e){return he(e)?{...e}:Array.isArray(e)?[...e]:e instanceof Map?new Map(e):e instanceof Set?new Set(e):e}const gr=new Set(["string","number","symbol"]);function ge(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function se(e,t,n){const o=new e._zod.constr(t??e._zod.def);return(!t||n?.parent)&&(o._zod.parent=e),o}function w(e){const t=e;if(!t)return{};if(typeof t=="string")return{error:()=>t};if(t?.message!==void 0){if(t?.error!==void 0)throw new 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 vr(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}const wr={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function br(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".pick() cannot be used on object schemas containing refinements");const i=ie(e._zod.def,{get shape(){const s={};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&(s[a]=n.shape[a])}return de(this,"shape",s),s},checks:[]});return se(e,i)}function _r(e,t){const n=e._zod.def,o=n.checks;if(o&&o.length>0)throw new Error(".omit() cannot be used on object schemas containing refinements");const i=ie(e._zod.def,{get shape(){const s={...e._zod.def.shape};for(const a in t){if(!(a in n.shape))throw new Error(`Unrecognized key: "${a}"`);t[a]&&delete s[a]}return de(this,"shape",s),s},checks:[]});return se(e,i)}function yr(e,t){if(!he(t))throw new Error("Invalid input to extend: expected a plain object");const n=e._zod.def.checks;if(n&&n.length>0){const i=e._zod.def.shape;for(const s in t)if(Object.getOwnPropertyDescriptor(i,s)!==void 0)throw new Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}const r=ie(e._zod.def,{get shape(){const i={...e._zod.def.shape,...t};return de(this,"shape",i),i}});return se(e,r)}function kr(e,t){if(!he(t))throw new Error("Invalid input to safeExtend: expected a plain object");const n=ie(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t};return de(this,"shape",o),o}});return se(e,n)}function Sr(e,t){if(e._zod.def.checks?.length)throw new Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");const n=ie(e._zod.def,{get shape(){const o={...e._zod.def.shape,...t._zod.def.shape};return de(this,"shape",o),o},get catchall(){return t._zod.def.catchall},checks:t._zod.def.checks??[]});return se(e,n)}function Tr(e,t,n){const r=t._zod.def.checks;if(r&&r.length>0)throw new Error(".partial() cannot be used on object schemas containing refinements");const s=ie(t._zod.def,{get shape(){const a=t._zod.def.shape,c={...a};if(n)for(const l in n){if(!(l in a))throw new Error(`Unrecognized key: "${l}"`);n[l]&&(c[l]=e?new e({type:"optional",innerType:a[l]}):a[l])}else for(const l in a)c[l]=e?new e({type:"optional",innerType:a[l]}):a[l];return de(this,"shape",c),c},checks:[]});return se(t,s)}function Ir(e,t,n){const o=ie(t._zod.def,{get shape(){const r=t._zod.def.shape,i={...r};if(n)for(const s in n){if(!(s in i))throw new Error(`Unrecognized key: "${s}"`);n[s]&&(i[s]=new e({type:"nonoptional",innerType:r[s]}))}else for(const s in r)i[s]=new e({type:"nonoptional",innerType:r[s]});return de(this,"shape",i),i}});return se(t,o)}function pe(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 Er(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 fe(e,t){return t.map(n=>{var o;return(o=n).path??(o.path=[]),n.path.unshift(e),n})}function Ae(e){return typeof e=="string"?e:e?.message}function ne(e,t,n){const o=e.message?e.message:Ae(e.inst?._zod.def?.error?.(e))??Ae(t?.error?.(e))??Ae(n.customError?.(e))??Ae(n.localeError?.(e))??"Invalid input",{inst:r,continue:i,input:s,...a}=e;return a.path??(a.path=[]),a.message=o,t?.reportInput&&(a.input=s),a}function Et(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}function Se(...e){const[t,n,o]=e;return typeof t=="string"?{message:t,code:"custom",input:n,inst:o}:{...t}}const Zn=(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,wt,2),Object.defineProperty(e,"toString",{value:()=>e.message,enumerable:!1})},Vn=d("$ZodError",Zn),Ln=d("$ZodError",Zn,{Parent:Error});function Rr(e,t=n=>n.message){const n={},o=[];for(const r of e.issues)r.path.length>0?(n[r.path[0]]=n[r.path[0]]||[],n[r.path[0]].push(t(r))):o.push(t(r));return{formErrors:o,fieldErrors:n}}function xr(e,t=n=>n.message){const n={_errors:[]},o=(r,i=[])=>{for(const s of r.issues)if(s.code==="invalid_union"&&s.errors.length)s.errors.map(a=>o({issues:a},[...i,...s.path]));else if(s.code==="invalid_key")o({issues:s.issues},[...i,...s.path]);else if(s.code==="invalid_element")o({issues:s.issues},[...i,...s.path]);else{const a=[...i,...s.path];if(a.length===0)n._errors.push(t(s));else{let c=n,l=0;for(;l<a.length;){const f=a[l];l===a.length-1?(c[f]=c[f]||{_errors:[]},c[f]._errors.push(t(s))):c[f]=c[f]||{_errors:[]},c=c[f],l++}}}};return o(e),n}const Rt=e=>(t,n,o,r)=>{const i=o?{...o,async:!1}:{async:!1},s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise)throw new me;if(s.issues.length){const a=new(r?.Err??e)(s.issues.map(c=>ne(c,i,te())));throw Mn(a,r?.callee),a}return s.value},xt=e=>async(t,n,o,r)=>{const i=o?{...o,async:!0}:{async:!0};let s=t._zod.run({value:n,issues:[]},i);if(s instanceof Promise&&(s=await s),s.issues.length){const a=new(r?.Err??e)(s.issues.map(c=>ne(c,i,te())));throw Mn(a,r?.callee),a}return s.value},Xe=e=>(t,n,o)=>{const r=o?{...o,async:!1}:{async:!1},i=t._zod.run({value:n,issues:[]},r);if(i instanceof Promise)throw new me;return i.issues.length?{success:!1,error:new(e??Vn)(i.issues.map(s=>ne(s,r,te())))}:{success:!0,data:i.value}},Ar=Xe(Ln),Qe=e=>async(t,n,o)=>{const r=o?{...o,async:!0}:{async:!0};let i=t._zod.run({value:n,issues:[]},r);return i instanceof Promise&&(i=await i),i.issues.length?{success:!1,error:new e(i.issues.map(s=>ne(s,r,te())))}:{success:!0,data:i.value}},Pr=Qe(Ln),zr=e=>(t,n,o)=>{const r=o?{...o,direction:"backward"}:{direction:"backward"};return Rt(e)(t,n,r)},Or=e=>(t,n,o)=>Rt(e)(t,n,o),Nr=e=>async(t,n,o)=>{const r=o?{...o,direction:"backward"}:{direction:"backward"};return xt(e)(t,n,r)},Cr=e=>async(t,n,o)=>xt(e)(t,n,o),$r=e=>(t,n,o)=>{const r=o?{...o,direction:"backward"}:{direction:"backward"};return Xe(e)(t,n,r)},Mr=e=>(t,n,o)=>Xe(e)(t,n,o),Dr=e=>async(t,n,o)=>{const r=o?{...o,direction:"backward"}:{direction:"backward"};return Qe(e)(t,n,r)},Zr=e=>async(t,n,o)=>Qe(e)(t,n,o),Vr=/^[cC][0-9a-z]{6,}$/,Lr=/^[0-9a-z]+$/,Fr=/^[0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{26}$/,Ur=/^[0-9a-vA-V]{20}$/,jr=/^[A-Za-z0-9]{27}$/,Br=/^[a-zA-Z0-9_-]{21}$/,Wr=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Gr=/^([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})$/,Lt=e=>e?new 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)$/,Jr=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/,Hr="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$";function Kr(){return new RegExp(Hr,"u")}const Yr=/^(?:(?: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])$/,Xr=/^(([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}|:))$/,Qr=/^((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])$/,qr=/^(([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])$/,ei=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,Fn=/^[A-Za-z0-9_-]*$/,ti=/^https?$/,ni=/^\+[1-9]\d{6,14}$/,Un="(?:(?:\\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])))",oi=new RegExp(`^${Un}$`);function jn(e){const 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 ri(e){return new RegExp(`^${jn(e)}$`)}function ii(e){const t=jn({precision:e.precision}),n=["Z"];e.local&&n.push(""),e.offset&&n.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");const o=`${t}(?:${n.join("|")})`;return new RegExp(`^${Un}T(?:${o})$`)}const si=e=>{const t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},ai=/^-?\d+$/,Bn=/^-?\d+(?:\.\d+)?$/,ci=/^(?:true|false)$/i,ui=/^null$/i,li=/^[^A-Z]*$/,di=/^[^a-z]*$/,J=d("$ZodCheck",(e,t)=>{var n;e._zod??(e._zod={}),e._zod.def=t,(n=e._zod).onattach??(n.onattach=[])}),Wn={number:"number",bigint:"bigint",object:"date"},Gn=d("$ZodCheckLessThan",(e,t)=>{J.init(e,t);const n=Wn[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,i=(t.inclusive?r.maximum:r.exclusiveMaximum)??Number.POSITIVE_INFINITY;t.value<i&&(t.inclusive?r.maximum=t.value:r.exclusiveMaximum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value<=t.value:o.value<t.value)||o.issues.push({origin:n,code:"too_big",maximum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),Jn=d("$ZodCheckGreaterThan",(e,t)=>{J.init(e,t);const n=Wn[typeof t.value];e._zod.onattach.push(o=>{const r=o._zod.bag,i=(t.inclusive?r.minimum:r.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>i&&(t.inclusive?r.minimum=t.value:r.exclusiveMinimum=t.value)}),e._zod.check=o=>{(t.inclusive?o.value>=t.value:o.value>t.value)||o.issues.push({origin:n,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:o.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}}),pi=d("$ZodCheckMultipleOf",(e,t)=>{J.init(e,t),e._zod.onattach.push(n=>{var o;(o=n._zod.bag).multipleOf??(o.multipleOf=t.value)}),e._zod.check=n=>{if(typeof n.value!=typeof t.value)throw new Error("Cannot mix number and bigint in multiple_of check.");(typeof n.value=="bigint"?n.value%t.value===BigInt(0):fr(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})}}),fi=d("$ZodCheckNumberFormat",(e,t)=>{J.init(e,t),t.format=t.format||"float64";const n=t.format?.includes("int"),o=n?"int":"number",[r,i]=wr[t.format];e._zod.onattach.push(s=>{const a=s._zod.bag;a.format=t.format,a.minimum=r,a.maximum=i,n&&(a.pattern=ai)}),e._zod.check=s=>{const a=s.value;if(n){if(!Number.isInteger(a)){s.issues.push({expected:o,format:t.format,code:"invalid_type",continue:!1,input:a,inst:e});return}if(!Number.isSafeInteger(a)){a>0?s.issues.push({input:a,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort}):s.issues.push({input:a,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:o,inclusive:!0,continue:!t.abort});return}}a<r&&s.issues.push({origin:"number",input:a,code:"too_small",minimum:r,inclusive:!0,inst:e,continue:!t.abort}),a>i&&s.issues.push({origin:"number",input:a,code:"too_big",maximum:i,inclusive:!0,inst:e,continue:!t.abort})}}),mi=d("$ZodCheckMaxLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!Tt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.maximum??Number.POSITIVE_INFINITY;t.maximum<r&&(o._zod.bag.maximum=t.maximum)}),e._zod.check=o=>{const r=o.value;if(r.length<=t.maximum)return;const s=Et(r);o.issues.push({origin:s,code:"too_big",maximum:t.maximum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),hi=d("$ZodCheckMinLength",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!Tt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>r&&(o._zod.bag.minimum=t.minimum)}),e._zod.check=o=>{const r=o.value;if(r.length>=t.minimum)return;const s=Et(r);o.issues.push({origin:s,code:"too_small",minimum:t.minimum,inclusive:!0,input:r,inst:e,continue:!t.abort})}}),gi=d("$ZodCheckLengthEquals",(e,t)=>{var n;J.init(e,t),(n=e._zod.def).when??(n.when=o=>{const r=o.value;return!Tt(r)&&r.length!==void 0}),e._zod.onattach.push(o=>{const r=o._zod.bag;r.minimum=t.length,r.maximum=t.length,r.length=t.length}),e._zod.check=o=>{const r=o.value,i=r.length;if(i===t.length)return;const s=Et(r),a=i>t.length;o.issues.push({origin:s,...a?{code:"too_big",maximum:t.length}:{code:"too_small",minimum:t.length},inclusive:!0,exact:!0,input:o.value,inst:e,continue:!t.abort})}}),qe=d("$ZodCheckStringFormat",(e,t)=>{var n,o;J.init(e,t),e._zod.onattach.push(r=>{const i=r._zod.bag;i.format=t.format,t.pattern&&(i.patterns??(i.patterns=new Set),i.patterns.add(t.pattern))}),t.pattern?(n=e._zod).check??(n.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:t.format,input:r.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(o=e._zod).check??(o.check=()=>{})}),vi=d("$ZodCheckRegex",(e,t)=>{qe.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})}}),wi=d("$ZodCheckLowerCase",(e,t)=>{t.pattern??(t.pattern=li),qe.init(e,t)}),bi=d("$ZodCheckUpperCase",(e,t)=>{t.pattern??(t.pattern=di),qe.init(e,t)}),_i=d("$ZodCheckIncludes",(e,t)=>{J.init(e,t);const n=ge(t.includes),o=new RegExp(typeof t.position=="number"?`^.{${t.position}}${n}`:n);t.pattern=o,e._zod.onattach.push(r=>{const i=r._zod.bag;i.patterns??(i.patterns=new Set),i.patterns.add(o)}),e._zod.check=r=>{r.value.includes(t.includes,t.position)||r.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:t.includes,input:r.value,inst:e,continue:!t.abort})}}),yi=d("$ZodCheckStartsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`^${ge(t.prefix)}.*`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.startsWith(t.prefix)||o.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:t.prefix,input:o.value,inst:e,continue:!t.abort})}}),ki=d("$ZodCheckEndsWith",(e,t)=>{J.init(e,t);const n=new RegExp(`.*${ge(t.suffix)}$`);t.pattern??(t.pattern=n),e._zod.onattach.push(o=>{const r=o._zod.bag;r.patterns??(r.patterns=new Set),r.patterns.add(n)}),e._zod.check=o=>{o.value.endsWith(t.suffix)||o.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:t.suffix,input:o.value,inst:e,continue:!t.abort})}}),Si=d("$ZodCheckOverwrite",(e,t)=>{J.init(e,t),e._zod.check=n=>{n.value=t.tx(n.value)}});class Ti{constructor(t=[]){this.content=[],this.indent=0,this&&(this.args=t)}indented(t){this.indent+=1,t(this),this.indent-=1}write(t){if(typeof t=="function"){t(this,{execution:"sync"}),t(this,{execution:"async"});return}const o=t.split(`
|
|
2
|
+
`).filter(s=>s),r=Math.min(...o.map(s=>s.length-s.trimStart().length)),i=o.map(s=>s.slice(r)).map(s=>" ".repeat(this.indent*2)+s);for(const s of i)this.content.push(s)}compile(){const t=Function,n=this?.args,r=[...(this?.content??[""]).map(i=>` ${i}`)];return new t(...n,r.join(`
|
|
3
|
+
`))}}const Ii={major:4,minor:4,patch:3},P=d("$ZodType",(e,t)=>{var n;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ii;const o=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&o.unshift(e);for(const r of o)for(const i of r._zod.onattach)i(e);if(o.length===0)(n=e._zod).deferred??(n.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{const r=(s,a,c)=>{let l=pe(s),f;for(const g of a){if(g._zod.def.when){if(Er(s)||!g._zod.def.when(s))continue}else if(l)continue;const b=s.issues.length,v=g._zod.check(s);if(v instanceof Promise&&c?.async===!1)throw new me;if(f||v instanceof Promise)f=(f??Promise.resolve()).then(async()=>{await v,s.issues.length!==b&&(l||(l=pe(s,b)))});else{if(s.issues.length===b)continue;l||(l=pe(s,b))}}return f?f.then(()=>s):s},i=(s,a,c)=>{if(pe(s))return s.aborted=!0,s;const l=r(a,o,c);if(l instanceof Promise){if(c.async===!1)throw new me;return l.then(f=>e._zod.parse(f,c))}return e._zod.parse(l,c)};e._zod.run=(s,a)=>{if(a.skipChecks)return e._zod.parse(s,a);if(a.direction==="backward"){const l=e._zod.parse({value:s.value,issues:[]},{...a,skipChecks:!0});return l instanceof Promise?l.then(f=>i(f,s,a)):i(l,s,a)}const c=e._zod.parse(s,a);if(c instanceof Promise){if(a.async===!1)throw new me;return c.then(l=>r(l,o,a))}return r(c,o,a)}}I(e,"~standard",()=>({validate:r=>{try{const i=Ar(e,r);return i.success?{value:i.data}:{issues:i.error?.issues}}catch{return Pr(e,r).then(s=>s.success?{value:s.data}:{issues:s.error?.issues})}},vendor:"zod",version:1}))}),At=d("$ZodString",(e,t)=>{P.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??si(e._zod.bag),e._zod.parse=(n,o)=>{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}}),N=d("$ZodStringFormat",(e,t)=>{qe.init(e,t),At.init(e,t)}),Ei=d("$ZodGUID",(e,t)=>{t.pattern??(t.pattern=Gr),N.init(e,t)}),Ri=d("$ZodUUID",(e,t)=>{if(t.version){const o={v1:1,v2:2,v3:3,v4:4,v5:5,v6:6,v7:7,v8:8}[t.version];if(o===void 0)throw new Error(`Invalid UUID version: "${t.version}"`);t.pattern??(t.pattern=Lt(o))}else t.pattern??(t.pattern=Lt());N.init(e,t)}),xi=d("$ZodEmail",(e,t)=>{t.pattern??(t.pattern=Jr),N.init(e,t)}),Ai=d("$ZodURL",(e,t)=>{N.init(e,t),e._zod.check=n=>{try{const o=n.value.trim();if(!t.normalize&&t.protocol?.source===ti.source&&!/^https?:\/\//i.test(o)){n.issues.push({code:"invalid_format",format:"url",note:"Invalid URL format",input:n.value,inst:e,continue:!t.abort});return}const r=new URL(o);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(r.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(r.protocol.endsWith(":")?r.protocol.slice(0,-1):r.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=r.href:n.value=o;return}catch{n.issues.push({code:"invalid_format",format:"url",input:n.value,inst:e,continue:!t.abort})}}}),Pi=d("$ZodEmoji",(e,t)=>{t.pattern??(t.pattern=Kr()),N.init(e,t)}),zi=d("$ZodNanoID",(e,t)=>{t.pattern??(t.pattern=Br),N.init(e,t)}),Oi=d("$ZodCUID",(e,t)=>{t.pattern??(t.pattern=Vr),N.init(e,t)}),Ni=d("$ZodCUID2",(e,t)=>{t.pattern??(t.pattern=Lr),N.init(e,t)}),Ci=d("$ZodULID",(e,t)=>{t.pattern??(t.pattern=Fr),N.init(e,t)}),$i=d("$ZodXID",(e,t)=>{t.pattern??(t.pattern=Ur),N.init(e,t)}),Mi=d("$ZodKSUID",(e,t)=>{t.pattern??(t.pattern=jr),N.init(e,t)}),Di=d("$ZodISODateTime",(e,t)=>{t.pattern??(t.pattern=ii(t)),N.init(e,t)}),Zi=d("$ZodISODate",(e,t)=>{t.pattern??(t.pattern=oi),N.init(e,t)}),Vi=d("$ZodISOTime",(e,t)=>{t.pattern??(t.pattern=ri(t)),N.init(e,t)}),Li=d("$ZodISODuration",(e,t)=>{t.pattern??(t.pattern=Wr),N.init(e,t)}),Fi=d("$ZodIPv4",(e,t)=>{t.pattern??(t.pattern=Yr),N.init(e,t),e._zod.bag.format="ipv4"}),Ui=d("$ZodIPv6",(e,t)=>{t.pattern??(t.pattern=Xr),N.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})}}}),ji=d("$ZodCIDRv4",(e,t)=>{t.pattern??(t.pattern=Qr),N.init(e,t)}),Bi=d("$ZodCIDRv6",(e,t)=>{t.pattern??(t.pattern=qr),N.init(e,t),e._zod.check=n=>{const o=n.value.split("/");try{if(o.length!==2)throw new Error;const[r,i]=o;if(!i)throw new Error;const s=Number(i);if(`${s}`!==i)throw new Error;if(s<0||s>128)throw new Error;new URL(`http://[${r}]`)}catch{n.issues.push({code:"invalid_format",format:"cidrv6",input:n.value,inst:e,continue:!t.abort})}}});function Hn(e){if(e==="")return!0;if(/\s/.test(e)||e.length%4!==0)return!1;try{return atob(e),!0}catch{return!1}}const Wi=d("$ZodBase64",(e,t)=>{t.pattern??(t.pattern=ei),N.init(e,t),e._zod.bag.contentEncoding="base64",e._zod.check=n=>{Hn(n.value)||n.issues.push({code:"invalid_format",format:"base64",input:n.value,inst:e,continue:!t.abort})}});function Gi(e){if(!Fn.test(e))return!1;const t=e.replace(/[-_]/g,o=>o==="-"?"+":"/"),n=t.padEnd(Math.ceil(t.length/4)*4,"=");return Hn(n)}const Ji=d("$ZodBase64URL",(e,t)=>{t.pattern??(t.pattern=Fn),N.init(e,t),e._zod.bag.contentEncoding="base64url",e._zod.check=n=>{Gi(n.value)||n.issues.push({code:"invalid_format",format:"base64url",input:n.value,inst:e,continue:!t.abort})}}),Hi=d("$ZodE164",(e,t)=>{t.pattern??(t.pattern=ni),N.init(e,t)});function Ki(e,t=null){try{const n=e.split(".");if(n.length!==3)return!1;const[o]=n;if(!o)return!1;const r=JSON.parse(atob(o));return!("typ"in r&&r?.typ!=="JWT"||!r.alg||t&&(!("alg"in r)||r.alg!==t))}catch{return!1}}const Yi=d("$ZodJWT",(e,t)=>{N.init(e,t),e._zod.check=n=>{Ki(n.value,t.alg)||n.issues.push({code:"invalid_format",format:"jwt",input:n.value,inst:e,continue:!t.abort})}}),Kn=d("$ZodNumber",(e,t)=>{P.init(e,t),e._zod.pattern=e._zod.bag.pattern??Bn,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=Number(n.value)}catch{}const r=n.value;if(typeof r=="number"&&!Number.isNaN(r)&&Number.isFinite(r))return n;const i=typeof r=="number"?Number.isNaN(r)?"NaN":Number.isFinite(r)?void 0:"Infinity":void 0;return n.issues.push({expected:"number",code:"invalid_type",input:r,inst:e,...i?{received:i}:{}}),n}}),Xi=d("$ZodNumberFormat",(e,t)=>{fi.init(e,t),Kn.init(e,t)}),Qi=d("$ZodBoolean",(e,t)=>{P.init(e,t),e._zod.pattern=ci,e._zod.parse=(n,o)=>{if(t.coerce)try{n.value=!!n.value}catch{}const r=n.value;return typeof r=="boolean"||n.issues.push({expected:"boolean",code:"invalid_type",input:r,inst:e}),n}}),qi=d("$ZodNull",(e,t)=>{P.init(e,t),e._zod.pattern=ui,e._zod.values=new Set([null]),e._zod.parse=(n,o)=>{const r=n.value;return r===null||n.issues.push({expected:"null",code:"invalid_type",input:r,inst:e}),n}}),es=d("$ZodUnknown",(e,t)=>{P.init(e,t),e._zod.parse=n=>n}),ts=d("$ZodNever",(e,t)=>{P.init(e,t),e._zod.parse=(n,o)=>(n.issues.push({expected:"never",code:"invalid_type",input:n.value,inst:e}),n)});function Ft(e,t,n){e.issues.length&&t.issues.push(...fe(n,e.issues)),t.value[n]=e.value}const ns=d("$ZodArray",(e,t)=>{P.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!Array.isArray(r))return n.issues.push({expected:"array",code:"invalid_type",input:r,inst:e}),n;n.value=Array(r.length);const i=[];for(let s=0;s<r.length;s++){const a=r[s],c=t.element._zod.run({value:a,issues:[]},o);c instanceof Promise?i.push(c.then(l=>Ft(l,n,s))):Ft(c,n,s)}return i.length?Promise.all(i).then(()=>n):n}});function Ue(e,t,n,o,r,i){const s=n in o;if(e.issues.length){if(r&&i&&!s)return;t.issues.push(...fe(n,e.issues))}if(!s&&!r){e.issues.length||t.issues.push({code:"invalid_type",expected:"nonoptional",input:void 0,path:[n]});return}e.value===void 0?s&&(t.value[n]=void 0):t.value[n]=e.value}function Yn(e){const t=Object.keys(e.shape);for(const o of t)if(!e.shape?.[o]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${o}": expected a Zod schema`);const n=vr(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(n)}}function Xn(e,t,n,o,r,i){const s=[],a=r.keySet,c=r.catchall._zod,l=c.def.type,f=c.optin==="optional",g=c.optout==="optional";for(const b in t){if(b==="__proto__"||a.has(b))continue;if(l==="never"){s.push(b);continue}const v=c.run({value:t[b],issues:[]},o);v instanceof Promise?e.push(v.then(R=>Ue(R,n,b,t,f,g))):Ue(v,n,b,t,f,g)}return s.length&&n.issues.push({code:"unrecognized_keys",keys:s,input:t,inst:i}),e.length?Promise.all(e).then(()=>n):n}const os=d("$ZodObject",(e,t)=>{if(P.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){const a=t.shape;Object.defineProperty(t,"shape",{get:()=>{const c={...a};return Object.defineProperty(t,"shape",{value:c}),c}})}const o=Ye(()=>Yn(t));I(e._zod,"propValues",()=>{const a=t.shape,c={};for(const l in a){const f=a[l]._zod;if(f.values){c[l]??(c[l]=new Set);for(const g of f.values)c[l].add(g)}}return c});const r=ke,i=t.catchall;let s;e._zod.parse=(a,c)=>{s??(s=o.value);const l=a.value;if(!r(l))return a.issues.push({expected:"object",code:"invalid_type",input:l,inst:e}),a;a.value={};const f=[],g=s.shape;for(const b of s.keys){const v=g[b],R=v._zod.optin==="optional",m=v._zod.optout==="optional",T=v._zod.run({value:l[b],issues:[]},c);T instanceof Promise?f.push(T.then(A=>Ue(A,a,b,l,R,m))):Ue(T,a,b,l,R,m)}return i?Xn(f,l,a,c,o.value,e):f.length?Promise.all(f).then(()=>a):a}}),rs=d("$ZodObjectJIT",(e,t)=>{os.init(e,t);const n=e._zod.parse,o=Ye(()=>Yn(t)),r=b=>{const v=new Ti(["shape","payload","ctx"]),R=o.value,m=Z=>{const $=Vt(Z);return`shape[${$}]._zod.run({ value: input[${$}], issues: [] }, ctx)`};v.write("const input = payload.value;");const T=Object.create(null);let A=0;for(const Z of R.keys)T[Z]=`key_${A++}`;v.write("const newResult = {};");for(const Z of R.keys){const $=T[Z],F=Vt(Z),$t=b[Z],Mt=$t?._zod?.optin==="optional",ur=$t?._zod?.optout==="optional";v.write(`const ${$} = ${m(Z)};`),Mt&&ur?v.write(`
|
|
4
|
+
if (${$}.issues.length) {
|
|
5
|
+
if (${F} in input) {
|
|
6
|
+
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
7
|
+
...iss,
|
|
8
|
+
path: iss.path ? [${F}, ...iss.path] : [${F}]
|
|
9
|
+
})));
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
if (${$}.value === undefined) {
|
|
14
|
+
if (${F} in input) {
|
|
15
|
+
newResult[${F}] = undefined;
|
|
16
|
+
}
|
|
17
|
+
} else {
|
|
18
|
+
newResult[${F}] = ${$}.value;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
`):Mt?v.write(`
|
|
22
|
+
if (${$}.issues.length) {
|
|
23
|
+
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
24
|
+
...iss,
|
|
25
|
+
path: iss.path ? [${F}, ...iss.path] : [${F}]
|
|
26
|
+
})));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
if (${$}.value === undefined) {
|
|
30
|
+
if (${F} in input) {
|
|
31
|
+
newResult[${F}] = undefined;
|
|
32
|
+
}
|
|
33
|
+
} else {
|
|
34
|
+
newResult[${F}] = ${$}.value;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
`):v.write(`
|
|
38
|
+
const ${$}_present = ${F} in input;
|
|
39
|
+
if (${$}.issues.length) {
|
|
40
|
+
payload.issues = payload.issues.concat(${$}.issues.map(iss => ({
|
|
41
|
+
...iss,
|
|
42
|
+
path: iss.path ? [${F}, ...iss.path] : [${F}]
|
|
43
|
+
})));
|
|
44
|
+
}
|
|
45
|
+
if (!${$}_present && !${$}.issues.length) {
|
|
46
|
+
payload.issues.push({
|
|
47
|
+
code: "invalid_type",
|
|
48
|
+
expected: "nonoptional",
|
|
49
|
+
input: undefined,
|
|
50
|
+
path: [${F}]
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (${$}_present) {
|
|
55
|
+
if (${$}.value === undefined) {
|
|
56
|
+
newResult[${F}] = undefined;
|
|
57
|
+
} else {
|
|
58
|
+
newResult[${F}] = ${$}.value;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
`)}v.write("payload.value = newResult;"),v.write("return payload;");const K=v.compile();return(Z,$)=>K(b,Z,$)};let i;const s=ke,a=!St.jitless,l=a&&hr.value,f=t.catchall;let g;e._zod.parse=(b,v)=>{g??(g=o.value);const R=b.value;return s(R)?a&&l&&v?.async===!1&&v.jitless!==!0?(i||(i=r(t.shape)),b=i(b,v),f?Xn([],R,b,v,g,e):b):n(b,v):(b.issues.push({expected:"object",code:"invalid_type",input:R,inst:e}),b)}});function Ut(e,t,n,o){for(const i of e)if(i.issues.length===0)return t.value=i.value,t;const r=e.filter(i=>!pe(i));return r.length===1?(t.value=r[0].value,r[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:n,errors:e.map(i=>i.issues.map(s=>ne(s,o,te())))}),t)}const Qn=d("$ZodUnion",(e,t)=>{P.init(e,t),I(e._zod,"optin",()=>t.options.some(o=>o._zod.optin==="optional")?"optional":void 0),I(e._zod,"optout",()=>t.options.some(o=>o._zod.optout==="optional")?"optional":void 0),I(e._zod,"values",()=>{if(t.options.every(o=>o._zod.values))return new Set(t.options.flatMap(o=>Array.from(o._zod.values)))}),I(e._zod,"pattern",()=>{if(t.options.every(o=>o._zod.pattern)){const o=t.options.map(r=>r._zod.pattern);return new RegExp(`^(${o.map(r=>It(r.source)).join("|")})$`)}});const n=t.options.length===1?t.options[0]._zod.run:null;e._zod.parse=(o,r)=>{if(n)return n(o,r);let i=!1;const s=[];for(const a of t.options){const c=a._zod.run({value:o.value,issues:[]},r);if(c instanceof Promise)s.push(c),i=!0;else{if(c.issues.length===0)return c;s.push(c)}}return i?Promise.all(s).then(a=>Ut(a,o,e,r)):Ut(s,o,e,r)}}),is=d("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,Qn.init(e,t);const n=e._zod.parse;I(e._zod,"propValues",()=>{const r={};for(const i of t.options){const s=i._zod.propValues;if(!s||Object.keys(s).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(i)}"`);for(const[a,c]of Object.entries(s)){r[a]||(r[a]=new Set);for(const l of c)r[a].add(l)}}return r});const o=Ye(()=>{const r=t.options,i=new Map;for(const s of r){const a=s._zod.propValues?.[t.discriminator];if(!a||a.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(s)}"`);for(const c of a){if(i.has(c))throw new Error(`Duplicate discriminator value "${String(c)}"`);i.set(c,s)}}return i});e._zod.parse=(r,i)=>{const s=r.value;if(!ke(s))return r.issues.push({code:"invalid_type",expected:"object",input:s,inst:e}),r;const a=o.value.get(s?.[t.discriminator]);return a?a._zod.run(r,i):t.unionFallback||i.direction==="backward"?n(r,i):(r.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,options:Array.from(o.value.keys()),input:s,path:[t.discriminator],inst:e}),r)}}),ss=d("$ZodIntersection",(e,t)=>{P.init(e,t),e._zod.parse=(n,o)=>{const r=n.value,i=t.left._zod.run({value:r,issues:[]},o),s=t.right._zod.run({value:r,issues:[]},o);return i instanceof Promise||s instanceof Promise?Promise.all([i,s]).then(([c,l])=>jt(n,c,l)):jt(n,i,s)}});function bt(e,t){if(e===t)return{valid:!0,data:e};if(e instanceof Date&&t instanceof Date&&+e==+t)return{valid:!0,data:e};if(he(e)&&he(t)){const n=Object.keys(t),o=Object.keys(e).filter(i=>n.indexOf(i)!==-1),r={...e,...t};for(const i of o){const s=bt(e[i],t[i]);if(!s.valid)return{valid:!1,mergeErrorPath:[i,...s.mergeErrorPath]};r[i]=s.data}return{valid:!0,data:r}}if(Array.isArray(e)&&Array.isArray(t)){if(e.length!==t.length)return{valid:!1,mergeErrorPath:[]};const n=[];for(let o=0;o<e.length;o++){const r=e[o],i=t[o],s=bt(r,i);if(!s.valid)return{valid:!1,mergeErrorPath:[o,...s.mergeErrorPath]};n.push(s.data)}return{valid:!0,data:n}}return{valid:!1,mergeErrorPath:[]}}function jt(e,t,n){const o=new Map;let r;for(const a of t.issues)if(a.code==="unrecognized_keys"){r??(r=a);for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).l=!0}else e.issues.push(a);for(const a of n.issues)if(a.code==="unrecognized_keys")for(const c of a.keys)o.has(c)||o.set(c,{}),o.get(c).r=!0;else e.issues.push(a);const i=[...o].filter(([,a])=>a.l&&a.r).map(([a])=>a);if(i.length&&r&&e.issues.push({...r,keys:i}),pe(e))return e;const s=bt(t.value,n.value);if(!s.valid)throw new Error(`Unmergable intersection. Error path: ${JSON.stringify(s.mergeErrorPath)}`);return e.value=s.data,e}const as=d("$ZodRecord",(e,t)=>{P.init(e,t),e._zod.parse=(n,o)=>{const r=n.value;if(!he(r))return n.issues.push({expected:"record",code:"invalid_type",input:r,inst:e}),n;const i=[],s=t.keyType._zod.values;if(s){n.value={};const a=new Set;for(const l of s)if(typeof l=="string"||typeof l=="number"||typeof l=="symbol"){a.add(typeof l=="number"?l.toString():l);const f=t.keyType._zod.run({value:l,issues:[]},o);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(f.issues.length){n.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(v=>ne(v,o,te())),input:l,path:[l],inst:e});continue}const g=f.value,b=t.valueType._zod.run({value:r[l],issues:[]},o);b instanceof Promise?i.push(b.then(v=>{v.issues.length&&n.issues.push(...fe(l,v.issues)),n.value[g]=v.value})):(b.issues.length&&n.issues.push(...fe(l,b.issues)),n.value[g]=b.value)}let c;for(const l in r)a.has(l)||(c=c??[],c.push(l));c&&c.length>0&&n.issues.push({code:"unrecognized_keys",input:r,inst:e,keys:c})}else{n.value={};for(const a of Reflect.ownKeys(r)){if(a==="__proto__"||!Object.prototype.propertyIsEnumerable.call(r,a))continue;let c=t.keyType._zod.run({value:a,issues:[]},o);if(c instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof a=="string"&&Bn.test(a)&&c.issues.length){const g=t.keyType._zod.run({value:Number(a),issues:[]},o);if(g instanceof Promise)throw new Error("Async schemas not supported in object keys currently");g.issues.length===0&&(c=g)}if(c.issues.length){t.mode==="loose"?n.value[a]=r[a]:n.issues.push({code:"invalid_key",origin:"record",issues:c.issues.map(g=>ne(g,o,te())),input:a,path:[a],inst:e});continue}const f=t.valueType._zod.run({value:r[a],issues:[]},o);f instanceof Promise?i.push(f.then(g=>{g.issues.length&&n.issues.push(...fe(a,g.issues)),n.value[c.value]=g.value})):(f.issues.length&&n.issues.push(...fe(a,f.issues)),n.value[c.value]=f.value)}}return i.length?Promise.all(i).then(()=>n):n}}),cs=d("$ZodEnum",(e,t)=>{P.init(e,t);const n=$n(t.entries),o=new Set(n);e._zod.values=o,e._zod.pattern=new RegExp(`^(${n.filter(r=>gr.has(typeof r)).map(r=>typeof r=="string"?ge(r):r.toString()).join("|")})$`),e._zod.parse=(r,i)=>{const s=r.value;return o.has(s)||r.issues.push({code:"invalid_value",values:n,input:s,inst:e}),r}}),us=d("$ZodLiteral",(e,t)=>{if(P.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");const n=new Set(t.values);e._zod.values=n,e._zod.pattern=new RegExp(`^(${t.values.map(o=>typeof o=="string"?ge(o):o?ge(o.toString()):String(o)).join("|")})$`),e._zod.parse=(o,r)=>{const i=o.value;return n.has(i)||o.issues.push({code:"invalid_value",values:t.values,input:i,inst:e}),o}}),ls=d("$ZodTransform",(e,t)=>{P.init(e,t),e._zod.optin="optional",e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Cn(e.constructor.name);const r=t.transform(n.value,n);if(o.async)return(r instanceof Promise?r:Promise.resolve(r)).then(s=>(n.value=s,n.fallback=!0,n));if(r instanceof Promise)throw new me;return n.value=r,n.fallback=!0,n}});function Bt(e,t){return t===void 0&&(e.issues.length||e.fallback)?{issues:[],value:void 0}:e}const qn=d("$ZodOptional",(e,t)=>{P.init(e,t),e._zod.optin="optional",e._zod.optout="optional",I(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),I(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${It(n.source)})?$`):void 0}),e._zod.parse=(n,o)=>{if(t.innerType._zod.optin==="optional"){const r=n.value,i=t.innerType._zod.run(n,o);return i instanceof Promise?i.then(s=>Bt(s,r)):Bt(i,r)}return n.value===void 0?n:t.innerType._zod.run(n,o)}}),ds=d("$ZodExactOptional",(e,t)=>{qn.init(e,t),I(e._zod,"values",()=>t.innerType._zod.values),I(e._zod,"pattern",()=>t.innerType._zod.pattern),e._zod.parse=(n,o)=>t.innerType._zod.run(n,o)}),ps=d("$ZodNullable",(e,t)=>{P.init(e,t),I(e._zod,"optin",()=>t.innerType._zod.optin),I(e._zod,"optout",()=>t.innerType._zod.optout),I(e._zod,"pattern",()=>{const n=t.innerType._zod.pattern;return n?new RegExp(`^(${It(n.source)}|null)$`):void 0}),I(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(n,o)=>n.value===null?n:t.innerType._zod.run(n,o)}),fs=d("$ZodDefault",(e,t)=>{P.init(e,t),e._zod.optin="optional",I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);if(n.value===void 0)return n.value=t.defaultValue,n;const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>Wt(i,t)):Wt(r,t)}});function Wt(e,t){return e.value===void 0&&(e.value=t.defaultValue),e}const ms=d("$ZodPrefault",(e,t)=>{P.init(e,t),e._zod.optin="optional",I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>(o.direction==="backward"||n.value===void 0&&(n.value=t.defaultValue),t.innerType._zod.run(n,o))}),hs=d("$ZodNonOptional",(e,t)=>{P.init(e,t),I(e._zod,"values",()=>{const n=t.innerType._zod.values;return n?new Set([...n].filter(o=>o!==void 0)):void 0}),e._zod.parse=(n,o)=>{const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>Gt(i,e)):Gt(r,e)}});function Gt(e,t){return!e.issues.length&&e.value===void 0&&e.issues.push({code:"invalid_type",expected:"nonoptional",input:e.value,inst:t}),e}const gs=d("$ZodCatch",(e,t)=>{P.init(e,t),e._zod.optin="optional",I(e._zod,"optout",()=>t.innerType._zod.optout),I(e._zod,"values",()=>t.innerType._zod.values),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(i=>(n.value=i.value,i.issues.length&&(n.value=t.catchValue({...n,error:{issues:i.issues.map(s=>ne(s,o,te()))},input:n.value}),n.issues=[],n.fallback=!0),n)):(n.value=r.value,r.issues.length&&(n.value=t.catchValue({...n,error:{issues:r.issues.map(i=>ne(i,o,te()))},input:n.value}),n.issues=[],n.fallback=!0),n)}}),vs=d("$ZodPipe",(e,t)=>{P.init(e,t),I(e._zod,"values",()=>t.in._zod.values),I(e._zod,"optin",()=>t.in._zod.optin),I(e._zod,"optout",()=>t.out._zod.optout),I(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(n,o)=>{if(o.direction==="backward"){const i=t.out._zod.run(n,o);return i instanceof Promise?i.then(s=>Pe(s,t.in,o)):Pe(i,t.in,o)}const r=t.in._zod.run(n,o);return r instanceof Promise?r.then(i=>Pe(i,t.out,o)):Pe(r,t.out,o)}});function Pe(e,t,n){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues,fallback:e.fallback},n)}const ws=d("$ZodReadonly",(e,t)=>{P.init(e,t),I(e._zod,"propValues",()=>t.innerType._zod.propValues),I(e._zod,"values",()=>t.innerType._zod.values),I(e._zod,"optin",()=>t.innerType?._zod?.optin),I(e._zod,"optout",()=>t.innerType?._zod?.optout),e._zod.parse=(n,o)=>{if(o.direction==="backward")return t.innerType._zod.run(n,o);const r=t.innerType._zod.run(n,o);return r instanceof Promise?r.then(Jt):Jt(r)}});function Jt(e){return e.value=Object.freeze(e.value),e}const bs=d("$ZodLazy",(e,t)=>{P.init(e,t),I(e._zod,"innerType",()=>{const n=t;return n._cachedInner||(n._cachedInner=t.getter()),n._cachedInner}),I(e._zod,"pattern",()=>e._zod.innerType?._zod?.pattern),I(e._zod,"propValues",()=>e._zod.innerType?._zod?.propValues),I(e._zod,"optin",()=>e._zod.innerType?._zod?.optin??void 0),I(e._zod,"optout",()=>e._zod.innerType?._zod?.optout??void 0),e._zod.parse=(n,o)=>e._zod.innerType._zod.run(n,o)}),_s=d("$ZodCustom",(e,t)=>{J.init(e,t),P.init(e,t),e._zod.parse=(n,o)=>n,e._zod.check=n=>{const o=n.value,r=t.fn(o);if(r instanceof Promise)return r.then(i=>Ht(i,n,o,e));Ht(r,n,o,e)}});function Ht(e,t,n,o){if(!e){const r={code:"custom",input:n,inst:o,path:[...o._zod.def.path??[]],continue:!o._zod.def.abort};o._zod.def.params&&(r.params=o._zod.def.params),t.issues.push(Se(r))}}var Kt;class ys{constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...n){const o=n[0];return this._map.set(t,o),o&&typeof o=="object"&&"id"in o&&this._idmap.set(o.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){const n=this._map.get(t);return n&&typeof n=="object"&&"id"in n&&this._idmap.delete(n.id),this._map.delete(t),this}get(t){const n=t._zod.parent;if(n){const o={...this.get(n)??{}};delete o.id;const r={...o,...this._map.get(t)};return Object.keys(r).length?r:void 0}return this._map.get(t)}has(t){return this._map.has(t)}}function ks(){return new ys}(Kt=globalThis).__zod_globalRegistry??(Kt.__zod_globalRegistry=ks());const _e=globalThis.__zod_globalRegistry;function Ss(e,t){return new e({type:"string",...w(t)})}function Ts(e,t){return new e({type:"string",format:"email",check:"string_format",abort:!1,...w(t)})}function Yt(e,t){return new e({type:"string",format:"guid",check:"string_format",abort:!1,...w(t)})}function Is(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,...w(t)})}function Es(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v4",...w(t)})}function Rs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v6",...w(t)})}function xs(e,t){return new e({type:"string",format:"uuid",check:"string_format",abort:!1,version:"v7",...w(t)})}function As(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...w(t)})}function Ps(e,t){return new e({type:"string",format:"emoji",check:"string_format",abort:!1,...w(t)})}function zs(e,t){return new e({type:"string",format:"nanoid",check:"string_format",abort:!1,...w(t)})}function Os(e,t){return new e({type:"string",format:"cuid",check:"string_format",abort:!1,...w(t)})}function Ns(e,t){return new e({type:"string",format:"cuid2",check:"string_format",abort:!1,...w(t)})}function Cs(e,t){return new e({type:"string",format:"ulid",check:"string_format",abort:!1,...w(t)})}function $s(e,t){return new e({type:"string",format:"xid",check:"string_format",abort:!1,...w(t)})}function Ms(e,t){return new e({type:"string",format:"ksuid",check:"string_format",abort:!1,...w(t)})}function Ds(e,t){return new e({type:"string",format:"ipv4",check:"string_format",abort:!1,...w(t)})}function Zs(e,t){return new e({type:"string",format:"ipv6",check:"string_format",abort:!1,...w(t)})}function Vs(e,t){return new e({type:"string",format:"cidrv4",check:"string_format",abort:!1,...w(t)})}function Ls(e,t){return new e({type:"string",format:"cidrv6",check:"string_format",abort:!1,...w(t)})}function Fs(e,t){return new e({type:"string",format:"base64",check:"string_format",abort:!1,...w(t)})}function Us(e,t){return new e({type:"string",format:"base64url",check:"string_format",abort:!1,...w(t)})}function js(e,t){return new e({type:"string",format:"e164",check:"string_format",abort:!1,...w(t)})}function Bs(e,t){return new e({type:"string",format:"jwt",check:"string_format",abort:!1,...w(t)})}function Ws(e,t){return new e({type:"string",format:"datetime",check:"string_format",offset:!1,local:!1,precision:null,...w(t)})}function Gs(e,t){return new e({type:"string",format:"date",check:"string_format",...w(t)})}function Js(e,t){return new e({type:"string",format:"time",check:"string_format",precision:null,...w(t)})}function Hs(e,t){return new e({type:"string",format:"duration",check:"string_format",...w(t)})}function Ks(e,t){return new e({type:"number",checks:[],...w(t)})}function Ys(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...w(t)})}function Xs(e,t){return new e({type:"boolean",...w(t)})}function Qs(e,t){return new e({type:"null",...w(t)})}function qs(e){return new e({type:"unknown"})}function ea(e,t){return new e({type:"never",...w(t)})}function Xt(e,t){return new Gn({check:"less_than",...w(t),value:e,inclusive:!1})}function dt(e,t){return new Gn({check:"less_than",...w(t),value:e,inclusive:!0})}function Qt(e,t){return new Jn({check:"greater_than",...w(t),value:e,inclusive:!1})}function pt(e,t){return new Jn({check:"greater_than",...w(t),value:e,inclusive:!0})}function qt(e,t){return new pi({check:"multiple_of",...w(t),value:e})}function eo(e,t){return new mi({check:"max_length",...w(t),maximum:e})}function je(e,t){return new hi({check:"min_length",...w(t),minimum:e})}function to(e,t){return new gi({check:"length_equals",...w(t),length:e})}function ta(e,t){return new vi({check:"string_format",format:"regex",...w(t),pattern:e})}function na(e){return new wi({check:"string_format",format:"lowercase",...w(e)})}function oa(e){return new bi({check:"string_format",format:"uppercase",...w(e)})}function ra(e,t){return new _i({check:"string_format",format:"includes",...w(t),includes:e})}function ia(e,t){return new yi({check:"string_format",format:"starts_with",...w(t),prefix:e})}function sa(e,t){return new ki({check:"string_format",format:"ends_with",...w(t),suffix:e})}function ve(e){return new Si({check:"overwrite",tx:e})}function aa(e){return ve(t=>t.normalize(e))}function ca(){return ve(e=>e.trim())}function ua(){return ve(e=>e.toLowerCase())}function la(){return ve(e=>e.toUpperCase())}function da(){return ve(e=>mr(e))}function pa(e,t,n){return new e({type:"array",element:t,...w(n)})}function fa(e,t,n){return new e({type:"custom",check:"custom",fn:t,...w(n)})}function ma(e,t){const n=ha(o=>(o.addIssue=r=>{if(typeof r=="string")o.issues.push(Se(r,o.value,n._zod.def));else{const i=r;i.fatal&&(i.continue=!1),i.code??(i.code="custom"),i.input??(i.input=o.value),i.inst??(i.inst=n),i.continue??(i.continue=!n._zod.def.abort),o.issues.push(Se(i))}},e(o.value,o)),t);return n}function ha(e,t){const n=new J({check:"custom",...w(t)});return n._zod.check=e,n}function no(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??_e,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 D(e,t,n={path:[],schemaPath:[]}){var o;const r=e._zod.def,i=t.seen.get(e);if(i)return i.count++,n.schemaPath.includes(e)&&(i.cycle=n.path),i.schema;const s={schema:{},count:1,cycle:void 0,path:n.path};t.seen.set(e,s);const a=e._zod.toJSONSchema?.();if(a)s.schema=a;else{const f={...n,schemaPath:[...n.schemaPath,e],path:n.path};if(e._zod.processJSONSchema)e._zod.processJSONSchema(t,s.schema,f);else{const b=s.schema,v=t.processors[r.type];if(!v)throw new Error(`[toJSONSchema]: Non-representable type encountered: ${r.type}`);v(e,t,b,f)}const g=e._zod.parent;g&&(s.ref||(s.ref=g),D(g,t,f),t.seen.get(g).isParent=!0)}const c=t.metadataRegistry.get(e);return c&&Object.assign(s.schema,c),t.io==="input"&&B(e)&&(delete s.schema.examples,delete s.schema.default),t.io==="input"&&"_prefault"in s.schema&&((o=s.schema).default??(o.default=s.schema._prefault)),delete s.schema._prefault,t.seen.get(e).schema}function oo(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=new Map;for(const s of e.seen.entries()){const a=e.metadataRegistry.get(s[0])?.id;if(a){const c=o.get(a);if(c&&c!==s[0])throw new Error(`Duplicate schema id "${a}" detected during JSON Schema conversion. Two different schemas cannot share the same id when converted together.`);o.set(a,s[0])}}const r=s=>{const a=e.target==="draft-2020-12"?"$defs":"definitions";if(e.external){const g=e.external.registry.get(s[0])?.id,b=e.external.uri??(R=>R);if(g)return{ref:b(g)};const v=s[1].defId??s[1].schema.id??`schema${e.counter++}`;return s[1].defId=v,{defId:v,ref:`${b("__shared")}#/${a}/${v}`}}if(s[1]===n)return{ref:"#"};const l=`#/${a}/`,f=s[1].schema.id??`__schema${e.counter++}`;return{defId:f,ref:l+f}},i=s=>{if(s[1].schema.$ref)return;const a=s[1],{ref:c,defId:l}=r(s);a.def={...a.schema},l&&(a.defId=l);const f=a.schema;for(const g in f)delete f[g];f.$ref=c};if(e.cycles==="throw")for(const s of e.seen.entries()){const a=s[1];if(a.cycle)throw new Error(`Cycle detected: #/${a.cycle?.join("/")}/<root>
|
|
63
|
+
|
|
64
|
+
Set the \`cycles\` parameter to \`"ref"\` to resolve cyclical schemas with defs.`)}for(const s of e.seen.entries()){const a=s[1];if(t===s[0]){i(s);continue}if(e.external){const l=e.external.registry.get(s[0])?.id;if(t!==s[0]&&l){i(s);continue}}if(e.metadataRegistry.get(s[0])?.id){i(s);continue}if(a.cycle){i(s);continue}if(a.count>1&&e.reused==="ref"){i(s);continue}}}function ro(e,t){const n=e.seen.get(t);if(!n)throw new Error("Unprocessed schema. This is a bug in Zod.");const o=a=>{const c=e.seen.get(a);if(c.ref===null)return;const l=c.def??c.schema,f={...l},g=c.ref;if(c.ref=null,g){o(g);const v=e.seen.get(g),R=v.schema;if(R.$ref&&(e.target==="draft-07"||e.target==="draft-04"||e.target==="openapi-3.0")?(l.allOf=l.allOf??[],l.allOf.push(R)):Object.assign(l,R),Object.assign(l,f),a._zod.parent===g)for(const T in l)T==="$ref"||T==="allOf"||T in f||delete l[T];if(R.$ref&&v.def)for(const T in l)T==="$ref"||T==="allOf"||T in v.def&&JSON.stringify(l[T])===JSON.stringify(v.def[T])&&delete l[T]}const b=a._zod.parent;if(b&&b!==g){o(b);const v=e.seen.get(b);if(v?.schema.$ref&&(l.$ref=v.schema.$ref,v.def))for(const R in l)R==="$ref"||R==="allOf"||R in v.def&&JSON.stringify(l[R])===JSON.stringify(v.def[R])&&delete l[R]}e.override({zodSchema:a,jsonSchema:l,path:c.path??[]})};for(const a of[...e.seen.entries()].reverse())o(a[0]);const r={};if(e.target==="draft-2020-12"?r.$schema="https://json-schema.org/draft/2020-12/schema":e.target==="draft-07"?r.$schema="http://json-schema.org/draft-07/schema#":e.target==="draft-04"?r.$schema="http://json-schema.org/draft-04/schema#":e.target,e.external?.uri){const a=e.external.registry.get(t)?.id;if(!a)throw new Error("Schema is missing an `id` property");r.$id=e.external.uri(a)}Object.assign(r,n.def??n.schema);const i=e.metadataRegistry.get(t)?.id;i!==void 0&&r.id===i&&delete r.id;const s=e.external?.defs??{};for(const a of e.seen.entries()){const c=a[1];c.def&&c.defId&&(c.def.id===c.defId&&delete c.def.id,s[c.defId]=c.def)}e.external||Object.keys(s).length>0&&(e.target==="draft-2020-12"?r.$defs=s:r.definitions=s);try{const a=JSON.parse(JSON.stringify(r));return Object.defineProperty(a,"~standard",{value:{...t["~standard"],jsonSchema:{input:Be(t,"input",e.processors),output:Be(t,"output",e.processors)}},enumerable:!1,writable:!1}),a}catch{throw new Error("Error converting schema to JSON.")}}function B(e,t){const n=t??{seen:new Set};if(n.seen.has(e))return!1;n.seen.add(e);const o=e._zod.def;if(o.type==="transform")return!0;if(o.type==="array")return B(o.element,n);if(o.type==="set")return B(o.valueType,n);if(o.type==="lazy")return B(o.getter(),n);if(o.type==="promise"||o.type==="optional"||o.type==="nonoptional"||o.type==="nullable"||o.type==="readonly"||o.type==="default"||o.type==="prefault")return B(o.innerType,n);if(o.type==="intersection")return B(o.left,n)||B(o.right,n);if(o.type==="record"||o.type==="map")return B(o.keyType,n)||B(o.valueType,n);if(o.type==="pipe")return e._zod.traits.has("$ZodCodec")?!0:B(o.in,n)||B(o.out,n);if(o.type==="object"){for(const r in o.shape)if(B(o.shape[r],n))return!0;return!1}if(o.type==="union"){for(const r of o.options)if(B(r,n))return!0;return!1}if(o.type==="tuple"){for(const r of o.items)if(B(r,n))return!0;return!!(o.rest&&B(o.rest,n))}return!1}const ga=(e,t={})=>n=>{const o=no({...n,processors:t});return D(e,o),oo(o,e),ro(o,e)},Be=(e,t,n={})=>o=>{const{libraryOptions:r,target:i}=o??{},s=no({...r??{},target:i,io:t,processors:n});return D(e,s),oo(s,e),ro(s,e)},va={guid:"uuid",url:"uri",datetime:"date-time",json_string:"json-string",regex:""},wa=(e,t,n,o)=>{const r=n;r.type="string";const{minimum:i,maximum:s,format:a,patterns:c,contentEncoding:l}=e._zod.bag;if(typeof i=="number"&&(r.minLength=i),typeof s=="number"&&(r.maxLength=s),a&&(r.format=va[a]??a,r.format===""&&delete r.format,a==="time"&&delete r.format),l&&(r.contentEncoding=l),c&&c.size>0){const f=[...c];f.length===1?r.pattern=f[0].source:f.length>1&&(r.allOf=[...f.map(g=>({...t.target==="draft-07"||t.target==="draft-04"||t.target==="openapi-3.0"?{type:"string"}:{},pattern:g.source}))])}},ba=(e,t,n,o)=>{const r=n,{minimum:i,maximum:s,format:a,multipleOf:c,exclusiveMaximum:l,exclusiveMinimum:f}=e._zod.bag;typeof a=="string"&&a.includes("int")?r.type="integer":r.type="number";const g=typeof f=="number"&&f>=(i??Number.NEGATIVE_INFINITY),b=typeof l=="number"&&l<=(s??Number.POSITIVE_INFINITY),v=t.target==="draft-04"||t.target==="openapi-3.0";g?v?(r.minimum=f,r.exclusiveMinimum=!0):r.exclusiveMinimum=f:typeof i=="number"&&(r.minimum=i),b?v?(r.maximum=l,r.exclusiveMaximum=!0):r.exclusiveMaximum=l:typeof s=="number"&&(r.maximum=s),typeof c=="number"&&(r.multipleOf=c)},_a=(e,t,n,o)=>{n.type="boolean"},ya=(e,t,n,o)=>{t.target==="openapi-3.0"?(n.type="string",n.nullable=!0,n.enum=[null]):n.type="null"},ka=(e,t,n,o)=>{n.not={}},Sa=(e,t,n,o)=>{},Ta=(e,t,n,o)=>{const r=e._zod.def,i=$n(r.entries);i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),n.enum=i},Ia=(e,t,n,o)=>{const r=e._zod.def,i=[];for(const s of r.values)if(s===void 0){if(t.unrepresentable==="throw")throw new Error("Literal `undefined` cannot be represented in JSON Schema")}else if(typeof s=="bigint"){if(t.unrepresentable==="throw")throw new Error("BigInt literals cannot be represented in JSON Schema");i.push(Number(s))}else i.push(s);if(i.length!==0)if(i.length===1){const s=i[0];n.type=s===null?"null":typeof s,t.target==="draft-04"||t.target==="openapi-3.0"?n.enum=[s]:n.const=s}else i.every(s=>typeof s=="number")&&(n.type="number"),i.every(s=>typeof s=="string")&&(n.type="string"),i.every(s=>typeof s=="boolean")&&(n.type="boolean"),i.every(s=>s===null)&&(n.type="null"),n.enum=i},Ea=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Custom types cannot be represented in JSON Schema")},Ra=(e,t,n,o)=>{if(t.unrepresentable==="throw")throw new Error("Transforms cannot be represented in JSON Schema")},xa=(e,t,n,o)=>{const r=n,i=e._zod.def,{minimum:s,maximum:a}=e._zod.bag;typeof s=="number"&&(r.minItems=s),typeof a=="number"&&(r.maxItems=a),r.type="array",r.items=D(i.element,t,{...o,path:[...o.path,"items"]})},Aa=(e,t,n,o)=>{const r=n,i=e._zod.def;r.type="object",r.properties={};const s=i.shape;for(const l in s)r.properties[l]=D(s[l],t,{...o,path:[...o.path,"properties",l]});const a=new Set(Object.keys(s)),c=new Set([...a].filter(l=>{const f=i.shape[l]._zod;return t.io==="input"?f.optin===void 0:f.optout===void 0}));c.size>0&&(r.required=Array.from(c)),i.catchall?._zod.def.type==="never"?r.additionalProperties=!1:i.catchall?i.catchall&&(r.additionalProperties=D(i.catchall,t,{...o,path:[...o.path,"additionalProperties"]})):t.io==="output"&&(r.additionalProperties=!1)},Pa=(e,t,n,o)=>{const r=e._zod.def,i=r.inclusive===!1,s=r.options.map((a,c)=>D(a,t,{...o,path:[...o.path,i?"oneOf":"anyOf",c]}));i?n.oneOf=s:n.anyOf=s},za=(e,t,n,o)=>{const r=e._zod.def,i=D(r.left,t,{...o,path:[...o.path,"allOf",0]}),s=D(r.right,t,{...o,path:[...o.path,"allOf",1]}),a=l=>"allOf"in l&&Object.keys(l).length===1,c=[...a(i)?i.allOf:[i],...a(s)?s.allOf:[s]];n.allOf=c},Oa=(e,t,n,o)=>{const r=n,i=e._zod.def;r.type="object";const s=i.keyType,c=s._zod.bag?.patterns;if(i.mode==="loose"&&c&&c.size>0){const f=D(i.valueType,t,{...o,path:[...o.path,"patternProperties","*"]});r.patternProperties={};for(const g of c)r.patternProperties[g.source]=f}else(t.target==="draft-07"||t.target==="draft-2020-12")&&(r.propertyNames=D(i.keyType,t,{...o,path:[...o.path,"propertyNames"]})),r.additionalProperties=D(i.valueType,t,{...o,path:[...o.path,"additionalProperties"]});const l=s._zod.values;if(l){const f=[...l].filter(g=>typeof g=="string"||typeof g=="number");f.length>0&&(r.required=f)}},Na=(e,t,n,o)=>{const r=e._zod.def,i=D(r.innerType,t,o),s=t.seen.get(e);t.target==="openapi-3.0"?(s.ref=r.innerType,n.nullable=!0):n.anyOf=[i,{type:"null"}]},Ca=(e,t,n,o)=>{const r=e._zod.def;D(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType},$a=(e,t,n,o)=>{const r=e._zod.def;D(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType,n.default=JSON.parse(JSON.stringify(r.defaultValue))},Ma=(e,t,n,o)=>{const r=e._zod.def;D(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType,t.io==="input"&&(n._prefault=JSON.parse(JSON.stringify(r.defaultValue)))},Da=(e,t,n,o)=>{const r=e._zod.def;D(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType;let s;try{s=r.catchValue(void 0)}catch{throw new Error("Dynamic catch values are not supported in JSON Schema")}n.default=s},Za=(e,t,n,o)=>{const r=e._zod.def,i=r.in._zod.traits.has("$ZodTransform"),s=t.io==="input"?i?r.out:r.in:r.out;D(s,t,o);const a=t.seen.get(e);a.ref=s},Va=(e,t,n,o)=>{const r=e._zod.def;D(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType,n.readOnly=!0},io=(e,t,n,o)=>{const r=e._zod.def;D(r.innerType,t,o);const i=t.seen.get(e);i.ref=r.innerType},La=(e,t,n,o)=>{const r=e._zod.innerType;D(r,t,o);const i=t.seen.get(e);i.ref=r},Fa=d("ZodISODateTime",(e,t)=>{Di.init(e,t),C.init(e,t)});function Ua(e){return Ws(Fa,e)}const ja=d("ZodISODate",(e,t)=>{Zi.init(e,t),C.init(e,t)});function Ba(e){return Gs(ja,e)}const Wa=d("ZodISOTime",(e,t)=>{Vi.init(e,t),C.init(e,t)});function Ga(e){return Js(Wa,e)}const Ja=d("ZodISODuration",(e,t)=>{Li.init(e,t),C.init(e,t)});function Ha(e){return Hs(Ja,e)}const Ka=(e,t)=>{Vn.init(e,t),e.name="ZodError",Object.defineProperties(e,{format:{value:n=>xr(e,n)},flatten:{value:n=>Rr(e,n)},addIssue:{value:n=>{e.issues.push(n),e.message=JSON.stringify(e.issues,wt,2)}},addIssues:{value:n=>{e.issues.push(...n),e.message=JSON.stringify(e.issues,wt,2)}},isEmpty:{get(){return e.issues.length===0}}})},Y=d("ZodError",Ka,{Parent:Error}),Ya=Rt(Y),Xa=xt(Y),Qa=Xe(Y),qa=Qe(Y),ec=zr(Y),tc=Or(Y),nc=Nr(Y),oc=Cr(Y),rc=$r(Y),ic=Mr(Y),sc=Dr(Y),ac=Zr(Y),en=new WeakMap;function Ie(e,t,n){const o=Object.getPrototypeOf(e);let r=en.get(o);if(r||(r=new Set,en.set(o,r)),!r.has(t)){r.add(t);for(const i in n){const s=n[i];Object.defineProperty(o,i,{configurable:!0,enumerable:!1,get(){const a=s.bind(this);return Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a}),a},set(a){Object.defineProperty(this,i,{configurable:!0,writable:!0,enumerable:!0,value:a})}})}}}const z=d("ZodType",(e,t)=>(P.init(e,t),Object.assign(e["~standard"],{jsonSchema:{input:Be(e,"input"),output:Be(e,"output")}}),e.toJSONSchema=ga(e,{}),e.def=t,e.type=t.type,Object.defineProperty(e,"_def",{value:t}),e.parse=(n,o)=>Ya(e,n,o,{callee:e.parse}),e.safeParse=(n,o)=>Qa(e,n,o),e.parseAsync=async(n,o)=>Xa(e,n,o,{callee:e.parseAsync}),e.safeParseAsync=async(n,o)=>qa(e,n,o),e.spa=e.safeParseAsync,e.encode=(n,o)=>ec(e,n,o),e.decode=(n,o)=>tc(e,n,o),e.encodeAsync=async(n,o)=>nc(e,n,o),e.decodeAsync=async(n,o)=>oc(e,n,o),e.safeEncode=(n,o)=>rc(e,n,o),e.safeDecode=(n,o)=>ic(e,n,o),e.safeEncodeAsync=async(n,o)=>sc(e,n,o),e.safeDecodeAsync=async(n,o)=>ac(e,n,o),Ie(e,"ZodType",{check(...n){const o=this.def;return this.clone(ie(o,{checks:[...o.checks??[],...n.map(r=>typeof r=="function"?{_zod:{check:r,def:{check:"custom"},onattach:[]}}:r)]}),{parent:!0})},with(...n){return this.check(...n)},clone(n,o){return se(this,n,o)},brand(){return this},register(n,o){return n.add(this,o),this},refine(n,o){return this.check(nu(n,o))},superRefine(n,o){return this.check(ou(n,o))},overwrite(n){return this.check(ve(n))},optional(){return rn(this)},exactOptional(){return Fc(this)},nullable(){return sn(this)},nullish(){return rn(sn(this))},nonoptional(n){return Jc(this,n)},array(){return L(this)},or(n){return le([this,n])},and(n){return Mc(this,n)},transform(n){return an(this,Vc(n))},default(n){return Bc(this,n)},prefault(n){return Gc(this,n)},catch(n){return Kc(this,n)},pipe(n){return an(this,n)},readonly(){return Qc(this)},describe(n){const o=this.clone();return _e.add(o,{description:n}),o},meta(...n){if(n.length===0)return _e.get(this);const o=this.clone();return _e.add(o,n[0]),o},isOptional(){return this.safeParse(void 0).success},isNullable(){return this.safeParse(null).success},apply(n){return n(this)}}),Object.defineProperty(e,"description",{get(){return _e.get(e)?.description},configurable:!0}),e)),so=d("_ZodString",(e,t)=>{At.init(e,t),z.init(e,t),e._zod.processJSONSchema=(o,r,i)=>wa(e,o,r);const n=e._zod.bag;e.format=n.format??null,e.minLength=n.minimum??null,e.maxLength=n.maximum??null,Ie(e,"_ZodString",{regex(...o){return this.check(ta(...o))},includes(...o){return this.check(ra(...o))},startsWith(...o){return this.check(ia(...o))},endsWith(...o){return this.check(sa(...o))},min(...o){return this.check(je(...o))},max(...o){return this.check(eo(...o))},length(...o){return this.check(to(...o))},nonempty(...o){return this.check(je(1,...o))},lowercase(o){return this.check(na(o))},uppercase(o){return this.check(oa(o))},trim(){return this.check(ca())},normalize(...o){return this.check(aa(...o))},toLowerCase(){return this.check(ua())},toUpperCase(){return this.check(la())},slugify(){return this.check(da())}})}),cc=d("ZodString",(e,t)=>{At.init(e,t),so.init(e,t),e.email=n=>e.check(Ts(uc,n)),e.url=n=>e.check(As(lc,n)),e.jwt=n=>e.check(Bs(Ic,n)),e.emoji=n=>e.check(Ps(dc,n)),e.guid=n=>e.check(Yt(tn,n)),e.uuid=n=>e.check(Is(ze,n)),e.uuidv4=n=>e.check(Es(ze,n)),e.uuidv6=n=>e.check(Rs(ze,n)),e.uuidv7=n=>e.check(xs(ze,n)),e.nanoid=n=>e.check(zs(pc,n)),e.guid=n=>e.check(Yt(tn,n)),e.cuid=n=>e.check(Os(fc,n)),e.cuid2=n=>e.check(Ns(mc,n)),e.ulid=n=>e.check(Cs(hc,n)),e.base64=n=>e.check(Fs(kc,n)),e.base64url=n=>e.check(Us(Sc,n)),e.xid=n=>e.check($s(gc,n)),e.ksuid=n=>e.check(Ms(vc,n)),e.ipv4=n=>e.check(Ds(wc,n)),e.ipv6=n=>e.check(Zs(bc,n)),e.cidrv4=n=>e.check(Vs(_c,n)),e.cidrv6=n=>e.check(Ls(yc,n)),e.e164=n=>e.check(js(Tc,n)),e.datetime=n=>e.check(Ua(n)),e.date=n=>e.check(Ba(n)),e.time=n=>e.check(Ga(n)),e.duration=n=>e.check(Ha(n))});function u(e){return Ss(cc,e)}const C=d("ZodStringFormat",(e,t)=>{N.init(e,t),so.init(e,t)}),uc=d("ZodEmail",(e,t)=>{xi.init(e,t),C.init(e,t)}),tn=d("ZodGUID",(e,t)=>{Ei.init(e,t),C.init(e,t)}),ze=d("ZodUUID",(e,t)=>{Ri.init(e,t),C.init(e,t)}),lc=d("ZodURL",(e,t)=>{Ai.init(e,t),C.init(e,t)}),dc=d("ZodEmoji",(e,t)=>{Pi.init(e,t),C.init(e,t)}),pc=d("ZodNanoID",(e,t)=>{zi.init(e,t),C.init(e,t)}),fc=d("ZodCUID",(e,t)=>{Oi.init(e,t),C.init(e,t)}),mc=d("ZodCUID2",(e,t)=>{Ni.init(e,t),C.init(e,t)}),hc=d("ZodULID",(e,t)=>{Ci.init(e,t),C.init(e,t)}),gc=d("ZodXID",(e,t)=>{$i.init(e,t),C.init(e,t)}),vc=d("ZodKSUID",(e,t)=>{Mi.init(e,t),C.init(e,t)}),wc=d("ZodIPv4",(e,t)=>{Fi.init(e,t),C.init(e,t)}),bc=d("ZodIPv6",(e,t)=>{Ui.init(e,t),C.init(e,t)}),_c=d("ZodCIDRv4",(e,t)=>{ji.init(e,t),C.init(e,t)}),yc=d("ZodCIDRv6",(e,t)=>{Bi.init(e,t),C.init(e,t)}),kc=d("ZodBase64",(e,t)=>{Wi.init(e,t),C.init(e,t)}),Sc=d("ZodBase64URL",(e,t)=>{Ji.init(e,t),C.init(e,t)}),Tc=d("ZodE164",(e,t)=>{Hi.init(e,t),C.init(e,t)}),Ic=d("ZodJWT",(e,t)=>{Yi.init(e,t),C.init(e,t)}),ao=d("ZodNumber",(e,t)=>{Kn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(o,r,i)=>ba(e,o,r),Ie(e,"ZodNumber",{gt(o,r){return this.check(Qt(o,r))},gte(o,r){return this.check(pt(o,r))},min(o,r){return this.check(pt(o,r))},lt(o,r){return this.check(Xt(o,r))},lte(o,r){return this.check(dt(o,r))},max(o,r){return this.check(dt(o,r))},int(o){return this.check(nn(o))},safe(o){return this.check(nn(o))},positive(o){return this.check(Qt(0,o))},nonnegative(o){return this.check(pt(0,o))},negative(o){return this.check(Xt(0,o))},nonpositive(o){return this.check(dt(0,o))},multipleOf(o,r){return this.check(qt(o,r))},step(o,r){return this.check(qt(o,r))},finite(){return this}});const n=e._zod.bag;e.minValue=Math.max(n.minimum??Number.NEGATIVE_INFINITY,n.exclusiveMinimum??Number.NEGATIVE_INFINITY)??null,e.maxValue=Math.min(n.maximum??Number.POSITIVE_INFINITY,n.exclusiveMaximum??Number.POSITIVE_INFINITY)??null,e.isInt=(n.format??"").includes("int")||Number.isSafeInteger(n.multipleOf??.5),e.isFinite=!0,e.format=n.format??null});function h(e){return Ks(ao,e)}const Ec=d("ZodNumberFormat",(e,t)=>{Xi.init(e,t),ao.init(e,t)});function nn(e){return Ys(Ec,e)}const Rc=d("ZodBoolean",(e,t)=>{Qi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>_a(e,n,o)});function x(e){return Xs(Rc,e)}const xc=d("ZodNull",(e,t)=>{qi.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ya(e,n,o)});function co(e){return Qs(xc,e)}const Ac=d("ZodUnknown",(e,t)=>{es.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Sa()});function re(){return qs(Ac)}const Pc=d("ZodNever",(e,t)=>{ts.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>ka(e,n,o)});function zc(e){return ea(Pc,e)}const Oc=d("ZodArray",(e,t)=>{ns.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>xa(e,n,o,r),e.element=t.element,Ie(e,"ZodArray",{min(n,o){return this.check(je(n,o))},nonempty(n){return this.check(je(1,n))},max(n,o){return this.check(eo(n,o))},length(n,o){return this.check(to(n,o))},unwrap(){return this.element}})});function L(e,t){return pa(Oc,e,t)}const Nc=d("ZodObject",(e,t)=>{rs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Aa(e,n,o,r),I(e,"shape",()=>t.shape),Ie(e,"ZodObject",{keyof(){return E(Object.keys(this._zod.def.shape))},catchall(n){return this.clone({...this._zod.def,catchall:n})},passthrough(){return this.clone({...this._zod.def,catchall:re()})},loose(){return this.clone({...this._zod.def,catchall:re()})},strict(){return this.clone({...this._zod.def,catchall:zc()})},strip(){return this.clone({...this._zod.def,catchall:void 0})},extend(n){return yr(this,n)},safeExtend(n){return kr(this,n)},merge(n){return Sr(this,n)},pick(n){return br(this,n)},omit(n){return _r(this,n)},partial(...n){return Tr(lo,this,n[0])},required(...n){return Ir(po,this,n[0])}})});function p(e,t){const n={type:"object",shape:e??{},...w(t)};return new Nc(n)}const uo=d("ZodUnion",(e,t)=>{Qn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Pa(e,n,o,r),e.options=t.options});function le(e,t){return new uo({type:"union",options:e,...w(t)})}const Cc=d("ZodDiscriminatedUnion",(e,t)=>{uo.init(e,t),is.init(e,t)});function Ee(e,t,n){return new Cc({type:"union",options:t,discriminator:e,...w(n)})}const $c=d("ZodIntersection",(e,t)=>{ss.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>za(e,n,o,r)});function Mc(e,t){return new $c({type:"intersection",left:e,right:t})}const on=d("ZodRecord",(e,t)=>{as.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Oa(e,n,o,r),e.keyType=t.keyType,e.valueType=t.valueType});function et(e,t,n){return!t||!t._zod?new on({type:"record",keyType:u(),valueType:e,...w(t)}):new on({type:"record",keyType:e,valueType:t,...w(n)})}const _t=d("ZodEnum",(e,t)=>{cs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(o,r,i)=>Ta(e,o,r),e.enum=t.entries,e.options=Object.values(t.entries);const n=new Set(Object.keys(t.entries));e.extract=(o,r)=>{const i={};for(const s of o)if(n.has(s))i[s]=t.entries[s];else throw new Error(`Key ${s} not found in enum`);return new _t({...t,checks:[],...w(r),entries:i})},e.exclude=(o,r)=>{const i={...t.entries};for(const s of o)if(n.has(s))delete i[s];else throw new Error(`Key ${s} not found in enum`);return new _t({...t,checks:[],...w(r),entries:i})}});function E(e,t){const n=Array.isArray(e)?Object.fromEntries(e.map(o=>[o,o])):e;return new _t({type:"enum",entries:n,...w(t)})}const Dc=d("ZodLiteral",(e,t)=>{us.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ia(e,n,o),e.values=new Set(t.values),Object.defineProperty(e,"value",{get(){if(t.values.length>1)throw new Error("This schema contains multiple valid literal values. Use `.values` instead.");return t.values[0]}})});function y(e,t){return new Dc({type:"literal",values:Array.isArray(e)?e:[e],...w(t)})}const Zc=d("ZodTransform",(e,t)=>{ls.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ra(e,n),e._zod.parse=(n,o)=>{if(o.direction==="backward")throw new Cn(e.constructor.name);n.addIssue=i=>{if(typeof i=="string")n.issues.push(Se(i,n.value,t));else{const s=i;s.fatal&&(s.continue=!1),s.code??(s.code="custom"),s.input??(s.input=n.value),s.inst??(s.inst=e),n.issues.push(Se(s))}};const r=t.transform(n.value,n);return r instanceof Promise?r.then(i=>(n.value=i,n.fallback=!0,n)):(n.value=r,n.fallback=!0,n)}});function Vc(e){return new Zc({type:"transform",transform:e})}const lo=d("ZodOptional",(e,t)=>{qn.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>io(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function rn(e){return new lo({type:"optional",innerType:e})}const Lc=d("ZodExactOptional",(e,t)=>{ds.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>io(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Fc(e){return new Lc({type:"optional",innerType:e})}const Uc=d("ZodNullable",(e,t)=>{ps.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Na(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function sn(e){return new Uc({type:"nullable",innerType:e})}const jc=d("ZodDefault",(e,t)=>{fs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>$a(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeDefault=e.unwrap});function Bc(e,t){return new jc({type:"default",innerType:e,get defaultValue(){return typeof t=="function"?t():Dn(t)}})}const Wc=d("ZodPrefault",(e,t)=>{ms.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ma(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Gc(e,t){return new Wc({type:"prefault",innerType:e,get defaultValue(){return typeof t=="function"?t():Dn(t)}})}const po=d("ZodNonOptional",(e,t)=>{hs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ca(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Jc(e,t){return new po({type:"nonoptional",innerType:e,...w(t)})}const Hc=d("ZodCatch",(e,t)=>{gs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Da(e,n,o,r),e.unwrap=()=>e._zod.def.innerType,e.removeCatch=e.unwrap});function Kc(e,t){return new Hc({type:"catch",innerType:e,catchValue:typeof t=="function"?t:()=>t})}const Yc=d("ZodPipe",(e,t)=>{vs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Za(e,n,o,r),e.in=t.in,e.out=t.out});function an(e,t){return new Yc({type:"pipe",in:e,out:t})}const Xc=d("ZodReadonly",(e,t)=>{ws.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Va(e,n,o,r),e.unwrap=()=>e._zod.def.innerType});function Qc(e){return new Xc({type:"readonly",innerType:e})}const qc=d("ZodLazy",(e,t)=>{bs.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>La(e,n,o,r),e.unwrap=()=>e._zod.def.getter()});function eu(e){return new qc({type:"lazy",getter:e})}const tu=d("ZodCustom",(e,t)=>{_s.init(e,t),z.init(e,t),e._zod.processJSONSchema=(n,o,r)=>Ea(e,n)});function nu(e,t={}){return fa(tu,e,t)}function ou(e,t){return ma(e,t)}const ru=E(["cli","native-host","extension","content-script"]),iu=E(["cli-to-host","host-to-extension","extension-to-content-script"]),su=["mvp","prototype-gated","deferred","unsupported"],au=E(su),cu=E(["INVALID_JSON","INVALID_ENVELOPE","INVALID_RESPONSE","VERSION_MISMATCH","UNKNOWN_COMMAND","UNSUPPORTED_CAPABILITY","NOT_APPROVED","EXTENSION_NOT_CONNECTED","NATIVE_HOST_UNAVAILABLE","PAIRING_MISMATCH","PERMISSION_DENIED","NO_ACTIVE_TAB","INVALID_TARGET","NAVIGATION_FAILED","SCRIPT_INJECTION_FAILED","SELECTOR_NOT_FOUND","REF_NOT_FOUND","OUTPUT_TOO_LARGE","TIMEOUT","ELEMENT_NOT_VISIBLE","ELEMENT_DISABLED","NOT_EDITABLE","ACTION_REJECTED","NO_FOCUSED_ELEMENT","INVALID_KEY","OPTION_NOT_FOUND","EVAL_ERROR","SERIALIZATION_FAILED","UNSUPPORTED_EXECUTION_WORLD","RESULT_TOO_LARGE","CAPTURE_FAILED","FILE_WRITE_FAILED"]),Pt=p({code:cu,message:u().min(1),details:et(u(),re()).optional()}),G={protocolMin:Pn,protocolMax:zn},uu=/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/u;function fo(e){if(e.length===0||e.length%4!==0||!uu.test(e))return null;const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return e.length/4*3-t}const lu=p({command:u().min(1),status:au,reason:u().min(1).optional()}),mo=p({component:ru,productName:y(xn),productVersion:u().min(1),protocolMin:h().int().positive(),protocolMax:h().int().positive(),features:L(u().min(1)).default([])}).superRefine((e,t)=>{e.protocolMin>e.protocolMax&&t.addIssue({code:"custom",message:"protocolMin cannot be greater than protocolMax.",path:["protocolMin"]})}),du=mo.extend({pairToken:u().min(1).optional()}),pu=p({accepted:y(!0),negotiatedProtocolVersion:h().int().positive(),peer:mo,pairing:p({hostId:u().min(1),extensionId:u().min(1),approved:x(),status:E(["approved","not-approved","invalid-pair-state"]).optional(),message:u().min(1).optional(),generation:h().int().positive().optional()}).strict().superRefine((e,t)=>{e.approved&&e.status!==void 0&&e.status!=="approved"&&t.addIssue({code:"custom",message:"Approved pairing cannot have an invalid or not-approved status.",path:["status"]}),!e.approved&&e.status==="approved"&&t.addIssue({code:"custom",message:"Unapproved pairing cannot have approved status.",path:["status"]}),e.status==="invalid-pair-state"&&e.message===void 0&&t.addIssue({code:"custom",message:"Invalid pair-state status requires a message.",path:["message"]})}).optional()}).superRefine((e,t)=>{zt(e.negotiatedProtocolVersion,e.peer)||t.addIssue({code:"custom",message:"Negotiated protocol version must be within the peer protocol range.",path:["negotiatedProtocolVersion"]})}),fu=p({}).strict(),mu=p({ok:y(!0)}),hu=p({}).strict(),gu=p({capabilities:L(lu)});function vu(e){return new TextEncoder().encode(e).byteLength}function ho(e,t,n=[]){return{component:e,productName:xn,productVersion:t,protocolMin:Pn,protocolMax:zn,features:[...n]}}function zt(e,t){return e>=t.protocolMin&&e<=t.protocolMax}function wu(e,t){const n=Math.max(e.protocolMin,t.protocolMin),o=Math.min(e.protocolMax,t.protocolMax);return n>o?{ok:!1,error:go(e,t)}:{ok:!0,value:o}}function go(e,t){return{code:"VERSION_MISMATCH",message:"Protocol version ranges do not overlap.",details:{local:cn(e),peer:cn(t)}}}function cn(e){return{protocolMin:e.protocolMin,protocolMax:e.protocolMax}}const bu=p({id:h().int(),index:h().int().nonnegative(),active:x(),title:u().optional(),url:u().optional(),windowId:h().int(),private:x().optional(),cookieStoreId:u().optional()}).strict(),S=p({window:le([p({kind:y("active")}).strict(),p({kind:y("id"),id:h().int()}).strict(),p({kind:y("index"),index:h().int().nonnegative()}).strict()]).optional(),tab:le([p({kind:y("active")}).strict(),p({kind:y("id"),id:h().int()}).strict(),p({kind:y("index"),index:h().int().nonnegative()}).strict()]).optional()}).strict(),j=p({windowId:h().int(),windowIndex:h().int().nonnegative(),tabId:h().int(),tabIndex:h().int().nonnegative(),title:u().optional(),url:u().optional(),private:x().optional(),cookieStoreId:u().optional()}).strict(),tt=p({id:h().int(),index:h().int().nonnegative(),focused:x(),activeTabId:h().int().optional(),tabCount:h().int().nonnegative(),private:x().optional(),left:h().int().optional(),top:h().int().optional(),width:h().int().positive().optional(),height:h().int().positive().optional()}).strict(),_u=p({target:S.optional()}).strict(),yu=p({target:j.optional(),tabs:L(bu)}),ku=p({url:u().min(1).optional(),target:S.optional()}).strict(),un=p({target:S}).strict(),ln=p({target:j}),Su=p({closedTabId:h().int(),nextActiveTabId:h().int().optional()}),Tu=p({}).strict(),Iu=p({windows:L(tt)}),Eu=p({url:u().min(1).optional()}).strict(),dn=p({target:S}).strict(),Ru=p({window:tt,target:j.optional()}),xu=p({window:tt,target:j.optional()}),Au=p({closedWindowId:h().int()}),Pu=p({url:u().min(1),newTab:x().default(!1),target:S.optional()}).strict(),ft=p({target:S.optional()}).strict(),Oe=p({target:j,url:u().optional(),loadState:E(["unknown","complete"]).optional()});function vo(e,t,n){e.selector===void 0==(e.ref===void 0)&&t.addIssue({code:"custom",message:n,path:["selector"]}),Ot(e,t)}function Ot(e,t){e.ref===void 0&&e.generationId!==void 0&&t.addIssue({code:"custom",message:"Generation IDs apply only to refs.",path:["generationId"]})}function zu(e,t){e.kind==="title"||e.kind==="url"?wo(e,t,`${e.kind} does not accept an element selector or ref.`):vo(e,t,"Element getters require exactly one selector or ref."),e.kind==="attr"&&e.attribute===void 0&&t.addIssue({code:"custom",message:"Attribute getters require an attribute name.",path:["attribute"]}),e.kind!=="attr"&&e.attribute!==void 0&&t.addIssue({code:"custom",message:"Only attr getters accept an attribute name.",path:["attribute"]}),Ot(e,t)}function Ou(e,t){Nu(e,t),Cu(e,t),Lu(e,t),Ot(e,t)}function wo(e,t,n){(e.selector!==void 0||e.ref!==void 0)&&t.addIssue({code:"custom",message:n,path:e.selector===void 0?["ref"]:["selector"]})}function Nu(e,t){const n=[{invalid:e.kind==="ms"&&e.durationMs===void 0,message:"Duration waits require durationMs.",path:["durationMs"]},{invalid:e.kind==="element"&&e.selector===void 0==(e.ref===void 0),message:"Element waits require exactly one selector or ref.",path:["selector"]},{invalid:e.kind==="text"&&e.text===void 0,message:"Text waits require text.",path:["text"]},{invalid:e.kind==="url"&&e.urlGlob===void 0,message:"URL waits require urlGlob.",path:["urlGlob"]},{invalid:e.kind==="function"&&e.expression===void 0,message:"Function waits require expression.",path:["expression"]}];for(const o of n)o.invalid&&t.addIssue({code:"custom",message:o.message,path:[...o.path]})}function Cu(e,t){$u(e,t),Mu(e,t),Du(e,t),Zu(e,t),Vu(e,t),e.kind!=="element"&&wo(e,t,"Only element waits accept selector or ref.")}function $u(e,t){e.kind!=="ms"&&e.durationMs!==void 0&&t.addIssue({code:"custom",message:"Only duration waits accept durationMs.",path:["durationMs"]})}function Mu(e,t){e.kind!=="text"&&e.text!==void 0&&t.addIssue({code:"custom",message:"Only text waits accept text.",path:["text"]})}function Du(e,t){e.kind!=="url"&&e.urlGlob!==void 0&&t.addIssue({code:"custom",message:"Only URL waits accept urlGlob.",path:["urlGlob"]})}function Zu(e,t){e.kind!=="function"&&e.expression!==void 0&&t.addIssue({code:"custom",message:"Only function waits accept expression.",path:["expression"]})}function Vu(e,t){e.kind!=="download"&&(e.downloadId!==void 0||e.filenameGlob!==void 0)&&t.addIssue({code:"custom",message:"Only download waits accept download criteria.",path:e.downloadId===void 0?["filenameGlob"]:["downloadId"]})}function Lu(e,t){Fu(e,t),Uu(e,t),ju(e,t)}function Fu(e,t){e.kind==="element"&&e.state!==void 0&&e.state!=="visible"&&e.state!=="hidden"&&e.state!=="attached"&&t.addIssue({code:"custom",message:"Element waits require visible, hidden, or attached state.",path:["state"]})}function Uu(e,t){e.kind==="load-state"&&e.state!=="domcontentloaded"&&e.state!=="complete"&&e.state!=="networkidle"&&t.addIssue({code:"custom",message:"Load-state waits require domcontentloaded, complete, or networkidle state.",path:["state"]})}function ju(e,t){e.kind!=="element"&&e.kind!=="load-state"&&e.state!==void 0&&t.addIssue({code:"custom",message:"Only element and load-state waits accept state.",path:["state"]})}const Bu=p({target:S.optional(),interactiveOnly:x().optional(),compact:x().optional(),maxDepth:h().int().nonnegative().max(50).optional(),selector:u().min(1).optional(),maxOutputBytes:h().int().positive().max(1e6).optional()}).strict(),Wu=p({selector:u().min(1).optional(),title:u().optional(),url:u().optional(),unsupported:y(!0),reason:u().min(1)}).strict(),Gu=p({target:j.optional(),text:u(),generationId:u().min(1),refs:h().int().nonnegative(),truncated:x(),frames:L(Wu).default([])}),U=u().regex(/^@e[1-9]\d*$/u),nt=p({ref:U,generationId:u().min(1),tagName:u().min(1),role:u().min(1),visible:x(),name:u().optional(),text:u().optional(),value:u().optional(),href:u().optional(),disabled:x().optional(),checked:x().optional()}).strict(),Re=nt.omit({ref:!0,generationId:!0}).extend({ref:U.optional(),generationId:u().min(1).optional()}).strict().superRefine((e,t)=>{e.ref===void 0!=(e.generationId===void 0)&&t.addIssue({code:"custom",message:"Wait element summaries require both ref and generationId, or neither.",path:e.ref===void 0?["generationId"]:["ref"]})}),Ju=p({target:S.optional(),ref:U,generationId:u().min(1).optional()}).strict(),Hu=p({target:j.optional(),element:nt}),Ku=["text","html","value","attr","title","url","count","box","styles"],Yu=E(Ku),Xu=p({target:S.optional(),kind:Yu,selector:u().min(1).optional(),ref:U.optional(),generationId:u().min(1).optional(),attribute:u().min(1).optional(),maxOutputBytes:h().int().positive().max(1e6).optional()}).strict().superRefine(zu),bo=le([u(),h(),x(),co()]),Qu=et(u(),bo),qu=le([bo,Qu]),el=p({x:h(),y:h(),width:h(),height:h(),top:h(),right:h(),bottom:h(),left:h()}).strict(),tl=p({display:u(),visibility:u(),opacity:u(),pointerEvents:u(),position:u(),overflow:u(),overflowX:u(),overflowY:u(),color:u(),backgroundColor:u(),fontSize:u()}).strict(),X=p({target:j.optional(),element:nt.optional()}).strict(),nl=Ee("kind",[X.extend({kind:y("text"),value:u(),truncated:x().optional()}).strict(),X.extend({kind:y("html"),value:u(),truncated:x().optional()}).strict(),X.extend({kind:y("value"),value:u().nullable()}).strict(),X.extend({kind:y("attr"),value:u().nullable()}).strict(),X.extend({kind:y("title"),value:u()}).strict(),X.extend({kind:y("url"),value:u()}).strict(),X.extend({kind:y("count"),value:h().int().nonnegative()}).strict(),X.extend({kind:y("box"),value:el}).strict(),X.extend({kind:y("styles"),value:tl}).strict()]),ol=["visible","enabled","checked"],_o=E(ol),rl=p({target:S.optional(),kind:_o,selector:u().min(1).optional(),ref:U.optional(),generationId:u().min(1).optional()}).strict().superRefine((e,t)=>{vo(e,t,"State checks require exactly one selector or ref.")}),il=p({target:j.optional(),kind:_o,value:x(),element:nt.optional()}).strict(),sl=["ms","element","text","url","function","load-state","download"],al=E(sl),cl=["visible","hidden","attached","domcontentloaded","complete","networkidle"],ul=E(cl),ll=p({target:S.optional(),kind:al,durationMs:h().int().nonnegative().max(6e5).optional(),selector:u().min(1).optional(),ref:U.optional(),generationId:u().min(1).optional(),state:ul.optional(),text:u().min(1).optional(),urlGlob:u().min(1).optional(),expression:u().min(1).max(2e4).optional(),downloadId:h().int().positive().optional(),filenameGlob:u().min(1).optional(),timeoutMs:h().int().positive().max(6e5).optional(),intervalMs:h().int().positive().max(6e4).optional()}).strict().superRefine(Ou),ce=p({target:j.optional(),matched:y(!0),elapsedMs:h().int().nonnegative()}).strict(),dl=Ee("kind",[ce.extend({kind:y("ms")}).strict(),ce.extend({kind:y("element"),element:Re.optional()}).strict(),ce.extend({kind:y("text"),value:u()}).strict(),ce.extend({kind:y("url"),value:u()}).strict(),ce.extend({kind:y("function"),value:qu}).strict(),ce.extend({kind:y("load-state")}).strict(),ce.extend({kind:y("download"),download:p({id:h().int(),filename:u().optional(),state:u().optional()}).strict()}).strict()]),pl=["click","dblclick","focus","hover","fill","type","press","keyboard.type","keyboard.inserttext","check","uncheck","select","scroll","scrollintoview","swipe","drag","upload","mouse","keydown","keyup"];E(pl);const fl=["up","down","left","right"],ml=E(fl),ot=(e,t)=>{e.selector===void 0==(e.ref===void 0)&&t.addIssue({code:"custom",message:"Element actions require exactly one selector or ref.",path:["selector"]}),e.ref===void 0&&e.generationId!==void 0&&t.addIssue({code:"custom",message:"Generation IDs apply only to refs.",path:["generationId"]})},ue=p({target:S.optional(),selector:u().min(1).optional(),ref:U.optional(),generationId:u().min(1).optional()}).strict().superRefine(ot),pn=p({target:S.optional(),selector:u().min(1).optional(),ref:U.optional(),generationId:u().min(1).optional(),text:u()}).strict().superRefine(ot),fn=p({target:S.optional(),text:u()}).strict(),hl=p({target:S.optional(),key:u().min(1).max(100)}).strict(),gl=p({target:S.optional(),selector:u().min(1).optional(),ref:U.optional(),generationId:u().min(1).optional(),values:L(u()).min(1)}).strict().superRefine(ot),mn=p({target:S.optional(),selector:u().min(1).optional(),ref:U.optional(),generationId:u().min(1).optional(),direction:ml,distancePx:h().int().positive().max(1e5).optional()}).strict().superRefine((e,t)=>{e.selector!==void 0&&e.ref!==void 0&&t.addIssue({code:"custom",message:"Scroll actions accept at most one selector or ref.",path:["selector"]}),e.ref===void 0&&e.generationId!==void 0&&t.addIssue({code:"custom",message:"Generation IDs apply only to refs.",path:["generationId"]})}),yo=p({target:j.optional(),ok:y(!0)}).strict(),M=e=>yo.extend({action:y(e),element:Re}).strict(),q=e=>M(e).extend({valueLength:h().int().nonnegative()}).strict(),ko=M("select").extend({selectedValues:L(u())}).strict(),We=e=>yo.extend({action:y(e),element:Re.optional(),scroll:p({x:h(),y:h()}).strict()}).strict(),we=le([M("click"),M("dblclick"),M("focus"),M("hover"),q("fill"),q("type"),M("press"),q("keyboard.type"),q("keyboard.inserttext"),M("check"),M("uncheck"),ko,We("scroll"),M("scrollintoview"),We("swipe"),M("drag"),q("upload"),M("mouse"),M("keydown"),M("keyup")]),vl=["argv","stdin","base64"],wl=E(vl),yt=eu(()=>le([u(),h(),x(),co(),L(yt),et(u(),yt)])),bl=p({target:S.optional(),script:u().min(1),source:wl,timeoutMs:h().int().positive().max(6e5).optional(),maxResultBytes:h().int().positive().max(On).optional()}).strict().superRefine((e,t)=>{vu(e.script)>ct&&t.addIssue({code:"too_big",maximum:ct,origin:"string",inclusive:!0,message:`Eval scripts must be at most ${String(ct)} bytes.`,path:["script"]})}),_l=Ee("type",[p({type:y("undefined")}).strict(),p({type:y("json"),value:yt}).strict()]),yl=p({target:j.optional(),value:_l,elapsedMs:h().int().nonnegative()}).strict(),kl=["png","jpeg"],So=E(kl),Sl=p({target:S.optional(),path:u().min(1),format:So,fullPage:x().optional(),quality:h().int().min(1).max(100).optional(),timeoutMs:h().int().positive().max(6e5).optional(),maxImageBytes:h().int().positive().max(ye).optional()}).strict().superRefine((e,t)=>{e.quality!==void 0&&e.format!=="jpeg"&&t.addIssue({code:"custom",message:"Screenshot quality applies only to JPEG screenshots.",path:["quality"]})}),Tl=p({tabActivated:x(),windowFocused:x()}).strict(),Il=p({target:j.optional(),path:u().min(1),format:So,bytes:h().int().nonnegative().max(ye),width:h().int().positive().optional(),height:h().int().positive().optional(),activation:Tl,imageBase64:u().min(1).optional()}).strict(),To=p({target:S.optional(),selector:u().min(1).optional(),ref:U.optional(),generationId:u().min(1).optional()}).strict().superRefine(ot),El=p({target:S.optional(),sourceSelector:u().min(1).optional(),sourceRef:U.optional(),sourceGenerationId:u().min(1).optional(),targetSelector:u().min(1).optional(),targetRef:U.optional(),targetGenerationId:u().min(1).optional()}).strict(),Rl=p({name:u().min(1),mimeType:u().min(1).optional(),dataBase64:u().min(1)}).strict().superRefine((e,t)=>{const n=fo(e.dataBase64);if(n===null){t.addIssue({code:"custom",message:"Upload file data must be valid base64.",path:["dataBase64"]});return}n>ut&&t.addIssue({code:"custom",message:`Upload file exceeds the ${String(ut)} byte per-file limit.`,path:["dataBase64"],params:{actualBytes:n,maxBytes:ut}})}),Io=To.extend({files:L(Rl).min(1).max(pr)}).superRefine((e,t)=>{Eo(e.files,t,["files"])});function xl(e){let t=0;for(const n of e){const o=fo(n.dataBase64);if(o===null)return null;t+=o}return t}function Eo(e,t,n){const o=xl(e);o===null||o<=lt||t.addIssue({code:"custom",message:`Upload files exceed the ${String(lt)} byte total limit.`,path:n,params:{actualBytes:o,maxBytes:lt}})}const Al=p({target:S.optional(),action:E(["move","down","up","wheel"]),selector:u().min(1).optional(),ref:U.optional(),generationId:u().min(1).optional(),x:h().optional(),y:h().optional(),button:h().int().nonnegative().max(4).optional(),deltaX:h().optional(),deltaY:h().optional()}).strict().superRefine((e,t)=>{e.ref===void 0&&e.generationId!==void 0&&t.addIssue({code:"custom",message:"Generation IDs apply only to refs.",path:["generationId"]})}),hn=p({target:S.optional(),key:u().min(1).max(100),selector:u().min(1).optional(),ref:U.optional(),generationId:u().min(1).optional()}).strict().superRefine((e,t)=>{e.ref===void 0&&e.generationId!==void 0&&t.addIssue({code:"custom",message:"Generation IDs apply only to refs.",path:["generationId"]})}),Pl=["role","text","label","placeholder","alt","title","testid"],zl=E(Pl),Ol=p({target:S.optional(),kind:zl,value:u().min(1),first:x().optional(),last:x().optional(),nth:h().int().nonnegative().optional()}).strict(),Nl=p({target:j.optional(),elements:L(Re)}).strict(),Cl=p({target:S.optional()}).strict(),$l=p({index:h().int().nonnegative(),selector:u().min(1).optional(),title:u().optional(),url:u().optional()}).strict(),Ml=p({target:j.optional(),frames:L($l)}).strict(),Dl=p({url:u().min(1),filename:u().min(1).optional(),saveAs:x().optional()}).strict(),Zl=p({id:h().int(),filename:u().optional(),state:u().optional()}).strict(),Ro=["status","accept","dismiss"],Vl=p({target:S.optional(),action:E(Ro),promptText:u().optional()}).strict(),Ll=p({action:E(Ro),handled:x(),message:u().optional(),type:u().optional()}).strict(),xo=["read","write","copy","paste"],Fl=p({target:S.optional(),action:E(xo),text:u().optional(),selector:u().min(1).optional(),ref:U.optional(),generationId:u().min(1).optional()}).strict(),Ul=p({action:E(xo),ok:y(!0),text:u().optional()}).strict(),Ao=["list","get","set","remove"],jl=p({action:E(Ao),url:u().min(1),name:u().min(1).optional(),value:u().optional(),domain:u().optional(),path:u().optional()}).strict(),gn=p({name:u(),value:u(),domain:u().optional(),path:u().optional()}).strict(),Bl=p({action:E(Ao),ok:y(!0),cookies:L(gn).optional(),cookie:gn.nullable().optional()}).strict(),Po=["local","session"],zo=["get","set","remove","clear"],Wl=p({target:S.optional(),area:E(Po),action:E(zo),key:u().min(1).optional(),value:u().optional()}).strict(),Gl=p({area:E(Po),action:E(zo),ok:y(!0),value:u().nullable().optional(),entries:et(u(),u()).optional()}).strict(),Oo=["list","clear"],Jl=p({target:S.optional(),action:E(Oo),urlGlob:u().min(1).optional()}).strict(),Hl=p({id:u(),url:u(),method:u().optional(),type:u().optional(),statusCode:h().int().optional()}).strict(),Kl=p({action:E(Oo),ok:y(!0),requests:L(Hl).optional()}).strict(),Nt=["list","clear"],No=p({target:S.optional(),action:E(Nt)}).strict(),Co=p({level:u(),text:u(),timestamp:h()}).strict(),Yl=p({action:E(Nt),ok:y(!0),entries:L(Co).optional(),truncated:x().optional(),droppedEntries:h().int().nonnegative().optional()}).strict(),Xl=No,Ql=p({action:E(Nt),ok:y(!0),errors:L(Co).optional(),truncated:x().optional(),droppedEntries:h().int().nonnegative().optional()}).strict(),ql=To.extend({durationMs:h().int().positive().max(6e4).optional()}),ed=p({ok:y(!0),element:Re,target:j.optional()}).strict(),td=p({target:S.optional(),path:u().min(1)}).strict(),nd=p({path:u().min(1)}).strict(),od=p({target:S.optional(),width:h().int().positive().max(1e4),height:h().int().positive().max(1e4)}).strict(),rd=p({window:tt}).strict(),$o=["url","title","snapshot"],id=p({target:S.optional(),kind:E($o),expected:u(),selector:u().min(1).optional()}).strict(),sd=p({kind:E($o),matches:x(),expected:u(),actual:u()}).strict(),ad=p({}).strict(),cd=p({hostId:u().min(1),extensionId:u().min(1),token:u().min(1),generation:h().int().positive(),approvedAt:u().min(1)}).strict(),ud=p({}).strict(),ld=p({ok:y(!0)});function dd(e){const t=p({command:u().min(1),params:re().default({})}).strict().superRefine((s,a)=>{if(!e.hasCommand(s.command)){a.addIssue({code:"custom",message:`Unknown batch command: ${s.command}`,path:["command"]});return}if(!e.isBatchable(s.command)){a.addIssue({code:"custom",message:`Command cannot run inside batch: ${s.command}`,path:["command"]});return}const c=e.paramsFor(s.command);if(c===void 0){a.addIssue({code:"custom",message:`Unknown batch command: ${s.command}`,path:["command"]});return}const l=c.safeParse(s.params),f=e.paramsWithDefaultTarget(s.command,s.params),g=l.success||!f.found?l:c.safeParse(f.params);g.success||a.addIssue({code:"custom",message:"Batch step params are invalid.",path:["params"],params:{command:s.command,issues:g.error.issues}})}),n=p({target:S.optional(),steps:L(t).min(1).max(100),bail:x().optional(),timeoutMs:h().int().positive().max(6e5).optional(),maxResultBytes:h().int().positive().max(Nn).optional()}).strict().superRefine((s,a)=>{const c=s.steps.flatMap(l=>{if(l.command!=="upload")return[];const f=Io.safeParse(l.params);return f.success?f.data.files:[]});Eo(c,a,["steps"])}),o=p({index:h().int().nonnegative(),command:u().min(1)}).strict(),r=Ee("ok",[o.extend({ok:y(!0),result:re()}).strict(),o.extend({ok:y(!1),error:Pt}).strict()]).superRefine((s,a)=>{if(!e.hasCommand(s.command)){a.addIssue({code:"custom",message:`Unknown batch result command: ${s.command}`,path:["command"]});return}if(!e.isBatchable(s.command)){a.addIssue({code:"custom",message:`Command cannot appear in batch results: ${s.command}`,path:["command"]});return}if(s.ok){const c=e.resultFor(s.command);if(c===void 0){a.addIssue({code:"custom",message:`Unknown batch result command: ${s.command}`,path:["command"]});return}const l=c.safeParse(s.result);l.success||a.addIssue({code:"custom",message:"Batch step result is invalid.",path:["result"],params:{command:s.command,issues:l.error.issues}})}}),i=p({ok:x(),steps:L(r),firstFailedIndex:h().int().nonnegative().optional(),elapsedMs:h().int().nonnegative()}).strict().superRefine((s,a)=>{const c=s.steps.find(l=>!l.ok)?.index;if(s.ok){c!==void 0&&a.addIssue({code:"custom",message:"Successful batch results cannot contain failed steps.",path:["ok"]}),s.firstFailedIndex!==void 0&&a.addIssue({code:"custom",message:"Successful batch results cannot include firstFailedIndex.",path:["firstFailedIndex"]});return}if(c===void 0){a.addIssue({code:"custom",message:"Failed batch results must contain a failed step.",path:["ok"]});return}s.firstFailedIndex!==c&&a.addIssue({code:"custom",message:"Batch firstFailedIndex must match the first failed step.",path:["firstFailedIndex"]})});return{batchStepSchema:t,batchParamsSchema:n,batchStepResultSchema:r,batchResultSchema:i}}function Mo(...e){const t={};for(const n of e)for(const[o,r]of Object.entries(n)){if(Object.hasOwn(t,o))throw new Error(`Duplicate command id: ${o}`);t[o]=r}return t}const Do={click:{params:ue,result:M("click"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"click",path:["click"],batch:!0}]},dblclick:{params:ue,result:M("dblclick"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"dblclick",path:["dblclick"],batch:!0}]},focus:{params:ue,result:M("focus"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"focus",path:["focus"],batch:!0}]},hover:{params:ue,result:M("hover"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"hover",path:["hover"],batch:!0}]},fill:{params:pn,result:q("fill"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"fill",path:["fill"],batch:!0}]},type:{params:pn,result:q("type"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"type",path:["type"],batch:!0}]},press:{params:hl,result:M("press"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"press",path:["press"],batch:!0}]},"keyboard.type":{params:fn,result:q("keyboard.type"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"keyboard.type",path:["keyboard","type"],batch:!0}]},"keyboard.inserttext":{params:fn,result:q("keyboard.inserttext"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"keyboard.inserttext",path:["keyboard","inserttext"],batch:!0}]},check:{params:ue,result:M("check"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"check",path:["check"],batch:!0}]},uncheck:{params:ue,result:M("uncheck"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"uncheck",path:["uncheck"],batch:!0}]},select:{params:gl,result:ko,status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"select",path:["select"],batch:!0}]},scroll:{params:mn,result:We("scroll"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"scroll",path:["scroll"],batch:!0}]},scrollintoview:{params:ue,result:M("scrollintoview"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"scrollintoview",path:["scrollintoview"],batch:!0}]},swipe:{params:mn,result:We("swipe"),status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"swipe",path:["swipe"],batch:!0}]}},Zo={"tabs.list":{params:_u,result:yu,status:"mvp",owner:"extension",target:"optional",content:"never",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"tab.list",path:["tab"],batch:!0}]},"tab.new":{params:ku,result:ln,status:"mvp",owner:"extension",target:"optional",content:"never",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"tab.new",path:["tab","new"],batch:!0}]},"tab.select":{params:un,result:ln,status:"mvp",owner:"extension",target:"required",content:"never",action:!1,timeout:"none",batch:{allowed:!0,protocolDefaultTarget:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"tab.select",path:["tab","select"],batch:!0}]},"tab.close":{params:un,result:Su,status:"mvp",owner:"extension",target:"required",content:"never",action:!1,timeout:"none",batch:{allowed:!0,protocolDefaultTarget:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"tab.close",path:["tab","close"],batch:!0}]},"windows.list":{params:Tu,result:Iu,status:"mvp",owner:"extension",target:"none",content:"never",action:!1,timeout:"none",batch:{allowed:!0},cliRoutes:[{id:"window.list",path:["window"],batch:!0}]},"window.new":{params:Eu,result:Ru,status:"mvp",owner:"extension",target:"none",content:"never",action:!1,timeout:"none",batch:{allowed:!0},cliRoutes:[{id:"window.new",path:["window","new"],batch:!0}]},"window.select":{params:dn,result:xu,status:"mvp",owner:"extension",target:"required",content:"never",action:!1,timeout:"none",batch:{allowed:!0,protocolDefaultTarget:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"window.select",path:["window","select"],batch:!0}]},"window.close":{params:dn,result:Au,status:"mvp",owner:"extension",target:"required",content:"never",action:!1,timeout:"none",batch:{allowed:!0,protocolDefaultTarget:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"window.close",path:["window","close"],batch:!0}]},open:{params:Pu,result:Oe,status:"mvp",owner:"extension",target:"optional",content:"never",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"open",path:["open"],batch:!0}]},back:{params:ft,result:Oe,status:"mvp",owner:"extension",target:"optional",content:"never",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"back",path:["back"],batch:!0}]},forward:{params:ft,result:Oe,status:"mvp",owner:"extension",target:"optional",content:"never",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"forward",path:["forward"],batch:!0}]},reload:{params:ft,result:Oe,status:"mvp",owner:"extension",target:"optional",content:"never",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"reload",path:["reload"],batch:!0}]}},Vo={snapshot:{params:Bu,result:Gu,status:"mvp",owner:"extension",target:"optional",content:"always",action:!1,timeout:"none",frameScope:{scope:"main-frame-with-iframe-diagnostics",reason:"Snapshot refs are generated for the main frame; iframe entries are diagnostic/read-only.",future:"docs/iframe-targeting-future.md"},batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"snapshot",path:["snapshot"],batch:!0}]},"ref.resolve":{params:Ju,result:Hu,status:"mvp",owner:"extension",target:"optional",content:"always",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"ref",path:["ref"],batch:!0}]},get:{params:Xu,result:nl,status:"mvp",owner:"extension",target:"mixed",content:"mixed",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"get",path:["get"],batch:!0}]},is:{params:rl,result:il,status:"mvp",owner:"extension",target:"optional",content:"always",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"is",path:["is"],batch:!0}]},wait:{params:ll,result:dl,status:"mvp",owner:"extension",target:"mixed",content:"mixed",action:!1,timeout:"command",security:{level:"conditional",reasons:["page-function-evaluation","downloads","network-observation"]},compatibility:{requirements:[{minProtocolVersion:2,reason:"Network-idle waits are scoped to the resolved tab.",params:{matches:[{path:["kind"],equals:"load-state"},{path:["state"],equals:"networkidle"}]}}]},batch:{allowed:!0,extensionDefaultTarget:!0,timeoutRebase:!0},cliRoutes:[{id:"wait",path:["wait"],batch:!0}]}},Lo={hello:{params:du,result:pu,status:"mvp",owner:"native-host",target:"none",content:"never",action:!1,timeout:"none",batch:{allowed:!1},cliRoutes:[]},capabilities:{params:hu,result:gu,status:"mvp",owner:"extension",target:"none",content:"never",action:!1,timeout:"none",batch:{allowed:!1},cliRoutes:[{id:"capabilities",path:["capabilities"],batch:!1}]},noop:{params:fu,result:mu,status:"mvp",owner:"extension",target:"none",content:"never",action:!1,timeout:"none",batch:{allowed:!1},cliRoutes:[]}},Fo={"pair.approve":{params:ad,result:cd,status:"mvp",owner:"native-host",target:"none",content:"never",action:!1,timeout:"none",batch:{allowed:!1},cliRoutes:[]},"pair.reset":{params:ud,result:ld,status:"mvp",owner:"native-host",target:"none",content:"never",action:!1,timeout:"none",batch:{allowed:!1},cliRoutes:[]}},Uo={eval:{params:bl,result:yl,status:"mvp",owner:"extension",target:"optional",content:"never",action:!1,timeout:"command",security:{level:"sensitive",reasons:["page-code-execution"]},frameScope:{scope:"main-frame-only",reason:"Eval runs in the resolved tab's main frame; iframe targeting is not implemented.",future:"docs/iframe-targeting-future.md"},batch:{allowed:!0,extensionDefaultTarget:!0,timeoutRebase:!0},cliRoutes:[{id:"eval",path:["eval"],batch:!0}]},screenshot:{params:Sl,result:Il,status:"mvp",owner:"extension",target:"optional",content:"never",action:!1,timeout:"command",batch:{allowed:!0,extensionDefaultTarget:!0,timeoutRebase:!0},cliRoutes:[{id:"screenshot",path:["screenshot"],batch:!0}]},drag:{params:El,result:we,status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"drag",path:["drag"],batch:!0}]},upload:{params:Io,result:we,status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"upload",path:["upload"],batch:!0}]},mouse:{params:Al,result:we,status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"mouse",path:["mouse"],batch:!0}]},keydown:{params:hn,result:we,status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"keydown",path:["keydown"],batch:!0}]},keyup:{params:hn,result:we,status:"mvp",owner:"extension",target:"optional",content:"action",action:!0,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"keyup",path:["keyup"],batch:!0}]},find:{params:Ol,result:Nl,status:"mvp",owner:"extension",target:"optional",content:"always",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"find",path:["find"],batch:!0}]},frame:{params:Cl,result:Ml,status:"mvp",owner:"extension",target:"optional",content:"always",action:!1,timeout:"none",frameScope:{scope:"main-frame-with-iframe-diagnostics",reason:"The frame command lists iframe diagnostics from the main frame only.",future:"docs/iframe-targeting-future.md"},batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"frame",path:["frame"],batch:!0}]},download:{params:Dl,result:Zl,status:"mvp",owner:"extension",target:"none",content:"never",action:!1,timeout:"none",security:{level:"sensitive",reasons:["downloads"]},batch:{allowed:!0},cliRoutes:[{id:"download",path:["download"],batch:!0}]},dialog:{params:Vl,result:Ll,status:"mvp",owner:"extension",target:"optional",content:"always",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"dialog",path:["dialog"],batch:!0}]},clipboard:{params:Fl,result:Ul,status:"mvp",owner:"extension",target:"mixed",content:"mixed",action:!1,timeout:"none",security:{level:"sensitive",reasons:["clipboard"]},batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"clipboard",path:["clipboard"],batch:!0}]},cookies:{params:jl,result:Bl,status:"mvp",owner:"extension",target:"none",content:"never",action:!1,timeout:"none",security:{level:"sensitive",reasons:["cookies"]},batch:{allowed:!0},cliRoutes:[{id:"cookies",path:["cookies"],batch:!0}]},storage:{params:Wl,result:Gl,status:"mvp",owner:"extension",target:"optional",content:"always",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"storage",path:["storage"],batch:!0}]},network:{params:Jl,result:Kl,status:"mvp",owner:"extension",target:"optional",content:"never",action:!1,timeout:"none",security:{level:"sensitive",reasons:["network-observation"]},compatibility:{requirements:[{minProtocolVersion:2,reason:"Network commands are scoped to the resolved tab."}]},batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"network",path:["network"],batch:!0}]},console:{params:No,result:Yl,status:"mvp",owner:"extension",target:"optional",content:"always",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"console",path:["console"],batch:!0}]},errors:{params:Xl,result:Ql,status:"mvp",owner:"extension",target:"optional",content:"always",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"errors",path:["errors"],batch:!0}]},highlight:{params:ql,result:ed,status:"mvp",owner:"extension",target:"optional",content:"always",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"highlight",path:["highlight"],batch:!0}]},pdf:{params:td,result:nd,status:"unsupported",owner:"extension",target:"optional",content:"never",action:!1,timeout:"none",batch:{allowed:!0},cliRoutes:[{id:"pdf",path:["pdf"],batch:!0}]},"set.viewport":{params:od,result:rd,status:"mvp",owner:"extension",target:"optional",content:"never",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"set.viewport",path:["set","viewport"],batch:!0}]},diff:{params:id,result:sd,status:"mvp",owner:"extension",target:"mixed",content:"mixed",action:!1,timeout:"none",batch:{allowed:!0,extensionDefaultTarget:!0},cliRoutes:[{id:"diff",path:["diff"],batch:!0}]}},Ce=Mo(Lo,Zo,Vo,Uo,Do,Fo),Ne=e=>Object.hasOwn(Ce,e),Ct=dd({hasCommand:Ne,isBatchable:e=>Ne(e)&&Ce[e].batch.allowed,paramsFor:e=>Ne(e)?Ce[e].params:void 0,resultFor:e=>Ne(e)?Ce[e].result:void 0,paramsWithDefaultTarget:(e,t)=>Id(e,t)}),pd=Ct.batchParamsSchema,fd=Ct.batchStepResultSchema,md=Ct.batchResultSchema,hd={batch:{params:pd,result:md,status:"mvp",owner:"extension",target:"optional",content:"never",action:!1,timeout:"batch",batch:{allowed:!1},cliRoutes:[{id:"batch",path:["batch"],batch:!1}]}},H=Mo(Lo,Zo,Vo,Uo,hd,Do,Fo);function ae(e){return Object.hasOwn(H,e)}function gd(e){return ae(e)?H[e].batch.protocolDefaultTarget===!0:!1}function vd(e){return ae(e)?H[e].batch.extensionDefaultTarget===!0:!1}function wd(e){return ae(e)?H[e].batch.timeoutRebase===!0:!1}function bd(e){return ae(e)&&H[e].action}function _d(e){const t=H[e],n=t.security;return n!==void 0?n:t.action?{level:"sensitive",reasons:["page-mutation"]}:{level:"normal",reasons:[]}}function yd(e){return H[e].compatibility??{requirements:[]}}function kd(e){return yd(e.command).requirements.filter(n=>Sd(n,e.params)).reduce((n,o)=>n===void 0||o.minProtocolVersion>n.minProtocolVersion?o:n,void 0)}function Sd(e,t){const n=e.params?.matches;return n===void 0?!0:n.every(o=>Td(t,o.path)===o.equals)}function Td(e,t){return t.reduce((n,o)=>{if(jo(n))return n[o]},e)}function Id(e,t){return!gd(e)||!jo(t)?{found:!1}:t.target!==void 0?{found:!1}:{found:!0,params:{...t,target:S.parse({window:{kind:"active"},tab:{kind:"active"}})}}}function jo(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Ed=[{command:"screenshot --full",status:"unsupported",reason:"full-page screenshots are unsupported because Firefox WebExtensions expose visible-tab capture only."},{command:"close",status:"unsupported",reason:"top-level close is unsupported; use explicit tab close or window close.",cliCommands:["close"]},{command:"quit",status:"unsupported",reason:"quit is unsupported because firefox-cli must not terminate the user's Firefox process.",cliCommands:["quit"]},{command:"exit",status:"unsupported",reason:"exit is unsupported because firefox-cli must not terminate the user's Firefox process.",cliCommands:["exit"]},{command:"connect",status:"unsupported",reason:"connect is unsupported because Firefox does not provide Chrome CDP attach semantics.",cliCommands:["connect"]},{command:"inspect",status:"unsupported",reason:"inspect is unsupported because Firefox does not expose agent-browser CDP inspection.",cliCommands:["inspect"]}],Rd=[...Object.entries(H).map(([e,t])=>({command:e,status:t.status})),...Ed.map(({command:e,status:t,reason:n})=>({command:e,status:t,reason:n}))];function Bo(e,t){return H[e].params.safeParse(t)}function Wo(e,t){return H[e].result.safeParse(t)}function V(e,t,n){return{ok:!1,error:{code:e,message:t,...n===void 0?{}:{details:n}}}}function Go(e){if(typeof e!="string")return{ok:!0,value:e};try{return{ok:!0,value:JSON.parse(e)}}catch(t){return V("INVALID_JSON","Payload is not valid JSON.",{error:t instanceof Error?t.message:String(t)})}}function Jo(e){return iu.safeParse(e).success}function Ho(e,t,n,o){return{protocolVersion:o,id:n,command:e,params:t}}function xd(e,t,n){return{protocolVersion:n,id:t,ok:!0,result:e}}function Ad(e,t,n){return{protocolVersion:n,id:e.id,ok:!0,result:t}}function Pd(e,t,n){return t.ok?{protocolVersion:n,id:e.id,ok:!0,result:t.result}:rt(e.id,t.error,n)}function zd(e){return e.command}function rt(e,t,n){return{protocolVersion:n,id:e,ok:!1,error:t}}function Od(e,t){const n=H.hello.params.safeParse(e.params);if(!n.success)return V("INVALID_ENVELOPE","Command params are invalid.",{command:"hello",issues:n.error.issues});const o=n.data,r=Ko({envelopeProtocolVersion:e.protocolVersion,local:t.local,peer:o,expectedPeerComponent:t.expectedPeerComponent,errorCode:"INVALID_ENVELOPE"});return r.ok?{ok:!0,value:{protocolVersion:r.value,id:e.id,command:"hello",params:o}}:r}function Nd(e,t){if(!e.ok){const r=Pt.safeParse(e.error);return r.success?!zt(e.protocolVersion,t.local)&&r.data.code!=="VERSION_MISMATCH"?{ok:!1,error:go(t.local,{protocolMin:e.protocolVersion,protocolMax:e.protocolVersion})}:{ok:!0,value:{protocolVersion:e.protocolVersion,id:e.id,ok:!1,error:r.data}}:V("INVALID_RESPONSE","Error response is invalid.",{issues:r.error.issues})}const n=H.hello.result.safeParse(e.result);if(!n.success)return V("INVALID_RESPONSE","Command result is invalid.",{command:"hello",issues:n.error.issues});const o=Ko({envelopeProtocolVersion:e.protocolVersion,local:t.local,peer:n.data.peer,expectedPeerComponent:t.expectedPeerComponent,errorCode:"INVALID_RESPONSE"});return o.ok?n.data.negotiatedProtocolVersion!==o.value?V("INVALID_RESPONSE","Negotiated protocol version is invalid.",{expected:o.value,received:n.data.negotiatedProtocolVersion}):e.protocolVersion!==n.data.negotiatedProtocolVersion?V("INVALID_RESPONSE","Hello response envelope version must match negotiation.",{expected:n.data.negotiatedProtocolVersion,received:e.protocolVersion}):{ok:!0,value:{protocolVersion:o.value,id:e.id,ok:!0,result:n.data}}:o}function Ko(e){if(e.peer.component!==e.expectedPeerComponent)return V(e.errorCode,"Unexpected hello peer component.",{expected:e.expectedPeerComponent,received:e.peer.component});if(!zt(e.envelopeProtocolVersion,e.peer))return V("VERSION_MISMATCH","Hello envelope version is outside the peer range.",{received:e.envelopeProtocolVersion,peer:{protocolMin:e.peer.protocolMin,protocolMax:e.peer.protocolMax}});const t=wu(e.local,e.peer);return t.ok,t}function Cd(e,t=$d(e)){const n=Yo(e),o=n?.minProtocolVersion??1;return{compatible:t>=o,requiredProtocolVersion:o,...n===void 0?{}:{reason:n.reason}}}function $d(e){return e.protocolVersion??ee}function Yo(e){if(e.command==="batch"&&Md(e.params)){const t=e.params.steps.reduce((n,o)=>{const r=Yo({command:o.command,params:o.params});return r===void 0?n:n===void 0||r.minProtocolVersion>n.minProtocolVersion?r:n},void 0);return t===void 0?void 0:{minProtocolVersion:t.minProtocolVersion,reason:"Batch contains scoped network command semantics."}}if(ae(e.command))return kd({command:e.command,params:e.params})}function Md(e){return typeof e=="object"&&e!==null&&"steps"in e&&Array.isArray(e.steps)}const Dd=p({protocolVersion:h().int().positive(),id:u().min(1),command:u().min(1),params:re()}).strict(),Zd=Ee("ok",[p({protocolVersion:h().int().positive(),id:u().min(1),ok:y(!0),result:re()}).strict(),p({protocolVersion:h().int().positive(),id:u().min(1),ok:y(!1),error:re()}).strict()]);function Xo(e,t,n={}){if(!Jo(e))return V("INVALID_ENVELOPE","Unknown protocol boundary.",{boundary:e});const o=Go(t);if(!o.ok)return o;const r=Dd.safeParse(o.value);if(!r.success)return V("INVALID_ENVELOPE","Request envelope is invalid.",{issues:r.error.issues});if(r.data.command==="hello"&&n.hello!==void 0)return Od(r.data,n.hello);const i=n.protocolVersion??ee;if(r.data.protocolVersion!==i)return V("VERSION_MISMATCH","Protocol version is not supported.",{received:r.data.protocolVersion,supported:i});if(!ae(r.data.command))return V("UNKNOWN_COMMAND",`Unknown command: ${r.data.command}`,{command:r.data.command});const s=Bo(r.data.command,r.data.params);if(!s.success)return V("INVALID_ENVELOPE","Command params are invalid.",{command:r.data.command,issues:s.error.issues});const a=Cd({protocolVersion:i,command:r.data.command,params:s.data}),c=Fd(r.data.command,a,i);return c!==void 0?c:{ok:!0,value:Ho(r.data.command,s.data,r.data.id,i)}}function Te(e,t,n,o={}){if(!Jo(e))return V("INVALID_RESPONSE","Unknown protocol boundary.",{boundary:e});const r=Go(n);if(!r.ok)return r;const i=Zd.safeParse(r.value);if(!i.success)return V("INVALID_RESPONSE","Response envelope is invalid.",{issues:i.error.issues});if(t==="hello"&&o.hello!==void 0)return Nd(i.data,o.hello);const s=o.protocolVersion??ee;if(i.data.protocolVersion!==s)return V("VERSION_MISMATCH","Protocol version is not supported.",{received:i.data.protocolVersion,supported:s});if(i.data.ok){const c=Wo(t,i.data.result);return c.success?{ok:!0,value:xd(c.data,i.data.id,s)}:V("INVALID_RESPONSE","Command result is invalid.",{command:t,issues:c.error.issues})}const a=Pt.safeParse(i.data.error);return a.success?{ok:!0,value:rt(i.data.id,a.data,s)}:V("INVALID_RESPONSE","Error response is invalid.",{issues:a.error.issues})}function Vd(e,t,n,o){return Te(e,zd(t),n,o)}function $e(e,t,n=crypto.randomUUID(),o=ee){return Ho(e,t,n,o)}function _(e,t,n=e.protocolVersion){return Ad(e,t,n)}function Q(e,t,n=ee){return rt(e,t,n)}function O(e,t,n=e.protocolVersion){return rt(e.id,t,n)}function Qo(e,t){return{...e,protocolVersion:t}}function Ld(e,t,n){return Pd(e,t,n)}function Fd(e,t,n){if(!t.compatible)return V("VERSION_MISMATCH","Request requires a newer protocol version than the negotiated session.",{command:e,requiredProtocolVersion:t.requiredProtocolVersion,negotiatedProtocolVersion:n,...t.reason===void 0?{}:{reason:t.reason}})}function kt(e){const t={protocolVersion:e};return{protocolVersion:e,parseRequest:(n,o)=>Xo(n,o,{protocolVersion:e}),parseResponse:(n,o,r)=>Te(n,o,r,t),parseResponseForRequest:(n,o,r)=>Vd(n,o,r,t),createOkResponse:(n,o)=>_(n,o,e),createErrorResponse:(n,o)=>Q(n,o,e),createErrorResponseForRequest:(n,o)=>O(n,o,e),withResponseVersion:(n,o)=>Ld(n,o,e),withRequestVersion:n=>Qo(n,e)}}function Ud(e,t){return e.state==="negotiated"?{ok:!0,value:e.session}:e.state==="incompatible"?{ok:!1,error:e.error}:{ok:!1,error:t}}function jd(e,t,n){return Bd(e).createErrorResponse(t,n)}function Bd(e){return e.state==="negotiated"?e.session:kt(G.protocolMax)}function Wd(e){return typeof e=="object"&&e!==null&&"id"in e&&"ok"in e&&typeof e.id=="string"}function Gd(e){return typeof e=="object"&&e!==null&&"id"in e&&typeof e.id=="string"?e.id:"invalid-request"}function Jd(e){return typeof e=="object"&&e!==null&&"protocolVersion"in e&&typeof e.protocolVersion=="number"?e.protocolVersion:G.protocolMax}function Hd(e,t){return typeof e=="object"&&e!==null&&"command"in e&&e.command===t}function Kd(e,t){return e.command===t}function Yd(...e){const t={};for(const n of e)for(const[o,r]of Object.entries(n)){if(Object.hasOwn(t,o))throw new Error(`Duplicate command handler: ${o}`);t[o]=r}return t}function Xd(e,t,...n){return ep(e,t)(t,...n)}function Qd(e,t){const n=fd.safeParse(t);if(!n.success)return Me("INVALID_RESPONSE","Batch step result is invalid.",{command:e,issues:n.error.issues});if(n.data.command!==e)return Me("INVALID_RESPONSE","Batch result command does not match expected command.",{expected:e,received:n.data.command});if(!n.data.ok)return{ok:!0,value:{index:n.data.index,command:e,ok:!1,error:n.data.error}};const o=Wo(e,n.data.result);return o.success?{ok:!0,value:{index:n.data.index,command:e,ok:!0,result:o.data}}:Me("INVALID_RESPONSE","Batch step result is invalid.",{command:e,issues:o.error.issues})}function qd(e,t){const n=Bo(e,t);return n.success?{ok:!0,value:n.data}:Me("INVALID_ENVELOPE","Command params are invalid.",{command:e,issues:n.error.issues})}function ep(e,t){return e[t.command]}function Me(e,t,n){return{ok:!1,error:{code:e,message:t,...n===void 0?{}:{details:n}}}}const vn="<all_urls>",tp=["nativeMessaging","scripting","tabs","storage"],np=["browsingActivity","websiteActivity","websiteContent"],op={"page-mutation":[],"page-code-execution":[],"page-function-evaluation":[],clipboard:["clipboardRead","clipboardWrite"],downloads:["downloads"],cookies:["cookies"],"network-observation":["webRequest"]},rp=new Set(["page-mutation","page-code-execution","page-function-evaluation","cookies","network-observation"]);function qo(){const e=new Set(tp),t=new Set,n=new Set,o=Object.entries(H).map(([i,s])=>{const a=er(s,sp(i));for(const c of a.manifestPermissions)e.add(c);return a.hostAccess&&t.add(vn),a.networkObservation&&n.add(vn),a}),r=De(t);return{firefoxStrictMinVersion:"150.0",manifestPermissions:De(e),hostPermissions:r,popupApprovalOrigins:r,webRequestListenerOrigins:De(n),dataCollection:{required:[...np],optional:[]},commands:o}}function ip(e){return er(H[e],e).hostAccess}function er(e,t){const n=[..._d(t).reasons],o=new Set;for(const r of n)for(const i of op[r])o.add(i);return{command:t,securityReasons:n,hostAccess:ap(e,n),manifestPermissions:De(o),networkObservation:n.includes("network-observation")}}function sp(e){if(ae(e))return e;throw new Error(`Unknown command id: ${e}`)}function ap(e,t){return e.owner==="extension"&&(e.target!=="none"||e.content!=="never"||e.action||t.some(n=>rp.has(n)))}function De(e){return[...e].sort((t,n)=>t.localeCompare(n))}const it={browserWait:{timeoutMs:3e4,intervalMs:100},browserEval:{timeoutMs:3e4},browserScreenshot:{timeoutMs:3e4}};function cp(){return{hasRequiredHostAccess:async()=>!0,listWindows:async()=>[],createTab:async()=>{throw new Error("Browser adapter is not configured.")},selectTab:async()=>{throw new Error("Browser adapter is not configured.")},closeTab:async()=>{throw new Error("Browser adapter is not configured.")},createWindow:async()=>{throw new Error("Browser adapter is not configured.")},focusWindow:async()=>{throw new Error("Browser adapter is not configured.")},closeWindow:async()=>{throw new Error("Browser adapter is not configured.")},navigateTab:async()=>{throw new Error("Browser adapter is not configured.")},goBack:async()=>{throw new Error("Browser adapter is not configured.")},goForward:async()=>{throw new Error("Browser adapter is not configured.")},reload:async()=>{throw new Error("Browser adapter is not configured.")},sendContentRequest:async()=>{throw new Error("Browser adapter is not configured.")},executeEval:async()=>{throw new Error("Browser adapter is not configured.")},captureVisibleTab:async()=>{throw new Error("Browser adapter is not configured.")},download:async()=>{throw new Error("Browser adapter is not configured.")},waitForDownload:async()=>{throw new Error("Browser adapter is not configured.")},readClipboard:async()=>{throw new Error("Browser adapter is not configured.")},writeClipboard:async()=>{throw new Error("Browser adapter is not configured.")},listCookies:async()=>{throw new Error("Browser adapter is not configured.")},setCookie:async()=>{throw new Error("Browser adapter is not configured.")},removeCookie:async()=>{throw new Error("Browser adapter is not configured.")},listNetworkRequests:async()=>[],clearNetworkRequests:async()=>{},waitForNetworkIdle:async()=>{},resizeWindow:async()=>{throw new Error("Browser adapter is not configured.")}}}class up{#e;#t;#n;#r;#o=null;#i=!1;#s=0;#c=!1;#a=!1;constructor(t){this.#e=t.connectNative,this.#t=t.reconnectDelaysMs,this.#n=t.scheduleTimer,this.#r=t.events}get connected(){return this.#i}get stopped(){return this.#a}start(){this.#a||this.#u()}stop(){this.#a||(this.#a=!0,this.#i=!1,this.#o=null,this.#c=!1)}postMessage(t){if(this.#o===null||!this.#i)return!1;try{return this.#o.postMessage(t),!0}catch{return!1}}#u(){if(!this.#a)try{const t=this.#e(An);this.#o=t,this.#i=!0,this.#s=0,this.#c=!1,t.onMessage.addListener(n=>{this.#a||this.#r.onMessage(n)}),t.onDisconnect.addListener(n=>{this.#a||(this.#i=!1,this.#o=null,this.#r.onDisconnect(n?.message??"Native host disconnected."),this.#l())}),this.#r.onConnect()}catch(t){this.#i=!1,this.#o=null,this.#r.onConnectError(t instanceof Error?t.message:String(t)),this.#l()}}#l(){if(this.#a||this.#c||this.#t.length===0)return;const t=this.#t[Math.min(this.#s,this.#t.length-1)];this.#s+=1,this.#c=!0,this.#n(()=>{this.#a||(this.#c=!1,this.#u())},t??0)}}function lp(e){return Ud(e,{code:"NATIVE_HOST_UNAVAILABLE",message:"Native host protocol negotiation has not completed."})}function dp(e,t,n){return jd(e,t,n)}function pp(e){return Wd(e)}function fp(e){return Gd(e)}function mp(e){return Jd(e)}function hp(e,t){return Hd(e,t)}class gp{#e={state:"disconnected"};get stateName(){return this.#e.state}beginNegotiation(){this.#e={state:"negotiating"}}markDisconnected(){this.#e={state:"disconnected"}}getNegotiatedSession(){return lp(this.#e)}parseResponse(t,n){return t==="hello"?Te("host-to-extension",t,n,{hello:{local:G,expectedPeerComponent:"native-host"}}):Te("host-to-extension",t,n,{protocolVersion:this.#e.state==="negotiated"?this.#e.session.protocolVersion:G.protocolMax})}applyResponseParseFailure(t,n){t==="hello"&&this.setIncompatible(n)}applyHelloResponse(t){t.ok?this.#e={state:"negotiated",session:kt(t.protocolVersion)}:this.setIncompatible(t.error)}parseRequest(t){return Xo("host-to-extension",t,{...this.#e.state==="negotiated"?{protocolVersion:this.#e.session.protocolVersion}:{},hello:{local:G,expectedPeerComponent:"native-host"}})}markRequestIncompatibleIfNeeded(t,n,o){(hp(t,"hello")||n==="VERSION_MISMATCH")&&this.setIncompatible(o)}prepareRequest(t){const n=kt(t.protocolVersion);return t.command==="hello"?(this.#e={state:"negotiated",session:n},{ok:!0,protocolSession:n}):this.#e.state==="incompatible"?{ok:!1,response:n.createErrorResponse(t.id,this.#e.error)}:this.#e.state!=="negotiated"?{ok:!1,response:n.createErrorResponse(t.id,{code:"NATIVE_HOST_UNAVAILABLE",message:"Native host protocol negotiation has not completed."})}:{ok:!0,protocolSession:n}}setIncompatible(t){this.#e={state:"incompatible",error:t}}createStateErrorResponse(t,n){return dp(this.#e,fp(t),n)}getMessageProtocolVersion(t){return mp(t)}}class vp{#e;#t=null;#n=!1;#r=0;constructor(t){this.#e=t}get approved(){return this.#n}get pairToken(){return this.#t}beginMutation(){this.#r+=1}async loadStoredPairToken(){const t=this.#r,n=await this.#e.getPairToken();return this.#r!==t?{applied:!1,pairToken:n}:(this.#t=n,this.#n=n!==null,{applied:!0,pairToken:n})}async approve(t){this.#t=t,this.#n=!0,await this.#e.setPairToken(t)}markRejected(){this.#n=!1}async reset(){this.#t=null,this.#n=!1,await this.#e.setPairToken(null)}async applyHelloPairing(t){if(t!==void 0)return this.#n=t.approved,!t.approved&&t.status!=="invalid-pair-state"&&this.#t!==null&&(this.#t=null,await this.#e.setPairToken(null)),!t.approved&&t.status==="invalid-pair-state"?t.message??"Native host pair state is invalid.":void 0}}class k extends Error{code;details;constructor(t,n,o){super(n),this.name="BrowserCommandError",this.code=t,this.details=o}}class Ze extends Error{deliveryCause;stage;originalMessage;retried;constructor(t){super(bp(t)),this.name="ContentScriptDeliveryError",this.deliveryCause=t.cause,this.stage=t.stage,this.originalMessage=t.originalMessage,this.retried=t.retried}}function tr(){const e=new Set;return{markInjected:t=>{e.add(t)},forgetTab:t=>{e.delete(t)},hasInjected:t=>e.has(t)}}async function wp(e,t,n){try{const o=await e.sendMessage(t,n);return e.markInjected?.(t),o}catch(o){const r=mt(o);if(r!=="not-loaded")throw new Ze({cause:r,stage:"send",originalMessage:Ve(o),retried:!1})}try{await e.injectContentScript(t),e.markInjected?.(t)}catch(o){throw new Ze({cause:mt(o),stage:"inject",originalMessage:Ve(o),retried:!0})}try{const o=await e.sendMessage(t,n);return e.markInjected?.(t),o}catch(o){throw new Ze({cause:mt(o),stage:"retry",originalMessage:Ve(o),retried:!0})}}function mt(e){const t=Ve(e).toLowerCase();return be(t,["receiving end does not exist","could not establish connection","content script missing","no matching message handler","no receiver"])?"not-loaded":be(t,["restricted firefox page","restricted page","privileged page","cannot access"])?"restricted-page":be(t,["missing host permission","permission denied","not allowed"])?"permission-denied":be(t,["discarded","unloaded","crashed"])?"tab-discarded":be(t,["invalid tab id","no tab with id","tab not found"])?"tab-unavailable":"unknown"}function bp(e){return`Content script delivery failed during ${e.stage} (${e.cause}): ${e.originalMessage}`}function Ve(e){return e instanceof Error?e.message:String(e)}function be(e,t){return t.some(n=>e.includes(n))}async function W(e,t,n){let o;const r=Qo(n,ee);try{o=await e.sendContentRequest(t,r)}catch(s){const a=s instanceof Ze?s:void 0,c=a?.originalMessage??(s instanceof Error?s.message:String(s));throw new k("SCRIPT_INJECTION_FAILED",`${yp(a)} Firefox reported: ${c}`,a===void 0?void 0:{cause:a.deliveryCause,stage:a.stage,retried:a.retried})}const i=Te("extension-to-content-script",n.command,o,{protocolVersion:ee});return i.ok?!i.value.ok&&i.value.error.code==="VERSION_MISMATCH"?wn(n,i.value.error):_p(n,i.value)?i.value:O(n,{code:"INVALID_RESPONSE",message:"Content script returned a response for a different command."}):i.error.code==="VERSION_MISMATCH"?wn(n,i.error):O(n,i.error)}function _p(e,t){return t.id===e.id}function yp(e){if(e===void 0)return"Cannot inject firefox-cli into this tab. Open a normal web page, reload the extension, or choose a different tab.";switch(e.deliveryCause){case"not-loaded":return"Cannot inject firefox-cli into this tab after retrying content-script startup. Reload the tab or the Firefox extension.";case"restricted-page":return"Cannot run firefox-cli on this restricted Firefox page. Choose a normal web page.";case"permission-denied":return"Cannot run firefox-cli in this tab because Firefox denied extension host access. Re-approve host permissions and try again.";case"tab-discarded":return"Cannot run firefox-cli in this tab because Firefox reported the tab is unloaded, discarded, or crashed. Reload the tab and try again.";case"tab-unavailable":return"Cannot run firefox-cli in this tab because Firefox reported the tab is unavailable. Choose a current tab and try again.";case"unknown":return"Cannot inject firefox-cli into this tab. Open a normal web page, reload the extension, or choose a different tab."}}function wn(e,t){return O(e,{...t,message:"Content script protocol mismatch. Reload the tab and ensure the Firefox extension is upgraded."})}const kp={snapshot:async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target),r=await W(t,o.tab.id,e);if(!r.ok)return O(e,r.error);const i={...r.result,target:o.target};return _(e,i)},"ref.resolve":async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target),r=await W(t,o.tab.id,e);if(!r.ok)return O(e,r.error);const i={...r.result,target:o.target};return _(e,i)},get:async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target);if(e.params.kind==="title"||e.params.kind==="url")return _(e,{kind:e.params.kind,value:e.params.kind==="title"?o.tab.title??"":o.tab.url??"",target:o.target});const r=await W(t,o.tab.id,e);if(!r.ok)return O(e,r.error);const i={...r.result,target:o.target};return _(e,i)},is:async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target),r=await W(t,o.tab.id,e);if(!r.ok)return O(e,r.error);const i={...r.result,target:o.target};return _(e,i)},find:async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target),r=await W(t,o.tab.id,e);if(!r.ok)return O(e,r.error);const i={...r.result,target:o.target};return _(e,i)},frame:async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target),r=await W(t,o.tab.id,e);if(!r.ok)return O(e,r.error);const i={...r.result,target:o.target};return _(e,i)},dialog:async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target),r=await W(t,o.tab.id,e);return r.ok?_(e,r.result):O(e,r.error)},storage:async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target),r=await W(t,o.tab.id,e);if(!r.ok)return O(e,r.error);const i=r.result;return _(e,i)},console:async(e,t,n)=>bn(e,t,n),errors:async(e,t,n)=>bn(e,t,n),highlight:async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target),r=await W(t,o.tab.id,e);if(!r.ok)return O(e,r.error);const i={...r.result,target:o.target};return _(e,i)},diff:async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target),r=e.params.kind==="url"?o.tab.url??"":e.params.kind==="title"?o.tab.title??"":await xp(t,o.tab.id,e),i={kind:e.params.kind,expected:e.params.expected,actual:r,matches:r===e.params.expected};return _(e,i)}};async function Sp(e,t,n){const o=await n.targetContext.resolveTarget(e.params.target),r=await W(t,o.tab.id,e);if(!r.ok)return O(e,r.error);const i={...r.result,target:o.target};return _(e,i)}async function bn(e,t,n){const o=await n.targetContext.resolveTarget(e.params.target),r=await W(t,o.tab.id,e);return r.ok?_(e,Tp(r.result,e.protocolVersion)):O(e,r.error)}function Tp(e,t){return t>=dr?e:Ip(e)}function Ip(e){return"errors"in e?Rp(e):Ep(e)}function Ep(e){return{action:e.action,ok:e.ok,...e.entries===void 0?{}:{entries:e.entries}}}function Rp(e){return{action:e.action,ok:e.ok,...e.errors===void 0?{}:{errors:e.errors}}}async function xp(e,t,n){const o={protocolVersion:n.protocolVersion,id:`${n.id}:snapshot`,command:"snapshot",params:{compact:!0,...n.params.selector===void 0?{}:{selector:n.params.selector}}},r=await W(e,t,o);if(!r.ok)throw new k(Ap(r.error.code),r.error.message);return r.result.text}function Ap(e){switch(e){case"NO_ACTIVE_TAB":case"INVALID_TARGET":case"UNSUPPORTED_CAPABILITY":case"PERMISSION_DENIED":case"NAVIGATION_FAILED":case"SCRIPT_INJECTION_FAILED":case"TIMEOUT":case"CAPTURE_FAILED":case"OUTPUT_TOO_LARGE":case"RESULT_TOO_LARGE":return e;default:return"INVALID_TARGET"}}async function Pp(e,t,n,o){const r=Date.now(),i=e.params.timeoutMs,s=e.params.maxResultBytes??Nn,a=(await o.resolveTarget(e.params.target)).target,c={window:{kind:"id",id:a.windowId},tab:{kind:"id",id:a.tabId}},l=[];let f=0;for(let v=0;v<e.params.steps.length;v+=1){const R=Dp(r,i);zp(i,R);const m=Op(e,v,c,R);if(m===void 0)continue;const T=await n(m,t),A=Np(v,m.command,T);if(l.push(A),f=Cp(f,A),_n({ok:l.every(K=>K.ok),steps:l,...ht(l)===void 0?{}:{firstFailedIndex:ht(l)},elapsedMs:Math.max(0,Date.now()-r)},s),!A.ok&&e.params.bail===!0)break}const g=ht(l),b={ok:g===void 0,steps:l,...g===void 0?{}:{firstFailedIndex:g},elapsedMs:Math.max(0,Date.now()-r)};return _n(b,s),b}function zp(e,t){if(t!==void 0&&t<=0)throw new k("TIMEOUT",`Timed out after ${String(e)}ms.`)}function Op(e,t,n,o){const r=e.params.steps[t];if(r===void 0)return;if(!ae(r.command))throw new k("INVALID_TARGET",`Unknown batch command: ${r.command}`);const i=qd(r.command,$p(r.command,r.params,n,o));if(!i.ok)throw new k("INVALID_TARGET",i.error.message);return $e(r.command,i.value,`${e.id}:${String(t)}`,e.protocolVersion)}function Np(e,t,n){return n.ok?{index:e,command:t,ok:!0,result:n.result}:{index:e,command:t,ok:!1,error:n.error}}function Cp(e,t){if(!t.ok||t.command!=="screenshot")return e;const n=e+nr(t).bytes;if(n>ye)throw new k("OUTPUT_TOO_LARGE",`Batch screenshots exceed the ${String(ye)} byte native messaging limit.`);return n}function $p(e,t,n,o){return Lp(t)?{...t,...vd(e)&&t.target===void 0?{target:n}:{},...Mp(e,t.timeoutMs,o)}:t}function Mp(e,t,n){if(n===void 0||!wd(e))return{};const o=typeof t=="number"?Math.min(t,n):n;return{timeoutMs:Math.max(1,Math.floor(o))}}function Dp(e,t){return t===void 0?void 0:t-(Date.now()-e)}function _n(e,t){const n=Zp(e),o=new TextEncoder().encode(JSON.stringify(n)).byteLength;if(o>t)throw new k("RESULT_TOO_LARGE",`Batch result is ${String(o)} bytes, exceeding the ${String(t)} byte limit.`)}function Zp(e){return{...e,steps:e.steps.map(t=>t.ok&&t.command==="screenshot"?{...t,result:Vp(nr(t))}:t)}}function nr(e){const t=Qd("screenshot",e);if(!t.ok||!t.value.ok)throw new k("INVALID_TARGET","Batch screenshot result is invalid.");return t.value.result}function Vp(e){return{...e.target===void 0?{}:{target:e.target},path:e.path,format:e.format,bytes:e.bytes,...e.width===void 0?{}:{width:e.width},...e.height===void 0?{}:{height:e.height},activation:e.activation}}function ht(e){return e.find(t=>!t.ok)?.index}function Lp(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}const Fp=()=>async(e,t,n)=>{const o=await Pp(e,t,n.executeStep,n.targetContext);return _(e,o)};function Ge(e){const t=Date.now(),n=()=>Math.max(0,Date.now()-t),o=()=>Math.max(0,e-n()),r=i=>{if(o()<=0)throw new k("TIMEOUT",i())};return{timeoutMs:e,elapsedMs:n,remainingMs:o,throwIfExpired:r,run:async(i,s)=>Je(i,o(),()=>(r(s),s())),sleep:async(i,s)=>Je(new Promise(a=>setTimeout(a,Math.min(i,o()))),o(),()=>(r(s),s()))}}async function Je(e,t,n){if(t<=0)throw new k("TIMEOUT",n());let o;try{return await Promise.race([e,new Promise((r,i)=>{o=setTimeout(()=>{i(new k("TIMEOUT",n()))},t)})])}finally{o!==void 0&&clearTimeout(o)}}async function Up(e){return new Promise(t=>setTimeout(t,e??0))}async function jp(e,t){return Je(e,t,()=>`Timed out after ${String(t)}ms.`)}const xe=it.browserWait.timeoutMs,st=it.browserWait.intervalMs,Bp=it.browserEval.timeoutMs,Wp=it.browserScreenshot.timeoutMs,Gp=new Set(["|","\\","{","}","(",")","[","]","^","$","+",".","?"]);function Jp(e,t={}){const n=t.questionMark??"literal",o=Array.from(e).map(r=>r==="*"?".*":r==="?"&&n==="wildcard"?".":Hp(r)).join("");return new RegExp(`^${o}$`,"u")}function He(e,t={}){const n=Jp(e,t);return o=>n.test(o)}function Hp(e){return Gp.has(e)?`\\${e}`:e}async function Kp(e){return at(await e.listWindows())}function at(e){return[...e].sort((t,n)=>Number(n.focused)-Number(t.focused)||t.id-n.id).map((t,n)=>({...t,index:n,tabs:[...t.tabs].sort((o,r)=>o.index-r.index)}))}function yn(e,t,n={}){const o=Yp(e,t),r=o?.window??or(e,t?.window),i=o?.tab??Qp(r,t?.tab);return Xp(r,i,n),{window:r,tab:i,target:Ke(r,i)}}function Yp(e,t){return t?.tab?.kind==="id"&&t.window===void 0?rr(e,t.tab.id):void 0}function Xp(e,t,n){if(!(n.allowPrivate===!0||e.private!==!0&&t.private!==!0))throw new k("UNSUPPORTED_CAPABILITY","Private window commands require private browsing permission.")}function or(e,t){if(e.length===0)throw new k("NO_ACTIVE_TAB","Firefox has no normal browser windows.");if(t===void 0||t.kind==="active"){const o=e.find(i=>i.focused);if(o!==void 0)return o;const r=e[0];if(r===void 0)throw new k("NO_ACTIVE_TAB","Firefox has no normal browser windows.");return r}const n=t.kind==="id"?ir(e,t.id):e.find(o=>o.index===t.index);if(n===void 0)throw new k("INVALID_TARGET","Requested Firefox window was not found.");return n}function Le(e){if(e.private===!0)throw new k("UNSUPPORTED_CAPABILITY","Private window commands require private browsing permission.")}function Qp(e,t){if(e.tabs.length===0)throw new k("NO_ACTIVE_TAB","Firefox window has no tabs.");if(t===void 0||t.kind==="active"){const o=e.tabs.find(r=>r.active);if(o===void 0)throw new k("NO_ACTIVE_TAB","Firefox window has no active tab.");return o}const n=t.kind==="id"?e.tabs.find(o=>o.id===t.id):e.tabs.find(o=>o.index===t.index);if(n===void 0)throw new k("INVALID_TARGET","Requested Firefox tab was not found.");return n}function rr(e,t){for(const n of e){const o=n.tabs.find(r=>r.id===t);if(o!==void 0)return{window:n,tab:o}}}function ir(e,t){return e.find(n=>n.id===t)}function Ke(e,t){return{windowId:e.id,windowIndex:e.index,tabId:t.id,tabIndex:t.index,...t.title===void 0?{}:{title:t.title},...t.url===void 0?{}:{url:t.url},...t.private===void 0?{}:{private:t.private},...t.cookieStoreId===void 0?{}:{cookieStoreId:t.cookieStoreId}}}function Fe(e){return{id:e.id,index:e.index,focused:e.focused,activeTabId:e.tabs.find(t=>t.active)?.id,tabCount:e.tabs.length,...e.private===void 0?{}:{private:e.private},...e.left===void 0?{}:{left:e.left},...e.top===void 0?{}:{top:e.top},...e.width===void 0?{}:{width:e.width},...e.height===void 0?{}:{height:e.height}}}async function qp(e,t,n){const o=n.timeoutMs??xe,r=n.intervalMs??st,i=Ge(o),s=He(n.urlGlob??"",{questionMark:"wildcard"}),a=()=>`Timed out after ${String(o)}ms waiting for URL ${JSON.stringify(n.urlGlob??"")}.`;for(;;){const c=rr(await i.run(Kp(e),a),t);if(c===void 0)throw new k("INVALID_TARGET","Requested Firefox tab was not found.");const l=c.tab.url??"";if(s(l))return{kind:"url",matched:!0,elapsedMs:i.elapsedMs(),value:l,target:Ke(c.window,c.tab)};i.throwIfExpired(a),await i.sleep(r,a)}}async function ef(e,t,n){const o=n.timeoutMs??xe,r=n.intervalMs??st,i=Ge(o),s=tf(n.expression??""),a=()=>`Timed out after ${String(o)}ms waiting for function predicate.`;for(;;){const c=await i.run(e.executeEval(t,{script:s,timeoutMs:Math.max(1,i.remainingMs()),maxResultBytes:4096}),a);if(!c.ok)throw new k("SCRIPT_INJECTION_FAILED",`Wait predicate failed: ${c.error.message}`);const l=nf(c.value);if(l.matched)return{kind:"function",matched:!0,elapsedMs:i.elapsedMs(),value:l.value};i.throwIfExpired(a),await i.sleep(r,a)}}function tf(e){return`(async () => {
|
|
65
|
+
const value = (${e});
|
|
66
|
+
const resolved = await (typeof value === "function" ? value({ document, window }) : value);
|
|
67
|
+
return {
|
|
68
|
+
matched: Boolean(resolved),
|
|
69
|
+
value: resolved === undefined ? null : resolved,
|
|
70
|
+
};
|
|
71
|
+
})()`}function nf(e){if(e.type!=="json"||typeof e.value!="object"||e.value===null)return{matched:!1,value:null};const t=rf(e.value);return{matched:t.matched===!0,value:of(t.value??null)}}function of(e){return typeof e=="string"||typeof e=="number"||typeof e=="boolean"||e===null?e:typeof e=="object"?Object.fromEntries(Object.entries(e).map(([t,n])=>[t,typeof n=="string"||typeof n=="number"||typeof n=="boolean"||n===null?n:kn(n)])):kn(e)}function rf(e){return{..."matched"in e?{matched:e.matched}:{},..."value"in e?{value:e.value}:{}}}function kn(e){return typeof e=="string"?e:typeof e=="number"||typeof e=="boolean"||typeof e=="bigint"?e.toString():typeof e=="symbol"?e.description??"":typeof e=="function"?e.name===""?"[function]":`[function ${e.name}]`:e===void 0?"undefined":e===null?"null":JSON.stringify(e)}const sf={wait:async(e,t,n)=>af(e,t,n),eval:async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target);let r;try{r=await t.executeEval(o.tab.id,{script:e.params.script,timeoutMs:e.params.timeoutMs??Bp,maxResultBytes:e.params.maxResultBytes??On})}catch(s){const a=s instanceof Error?s.message:String(s);throw new k("SCRIPT_INJECTION_FAILED",`Cannot run eval in this tab. Open a normal web page, reload the extension, or choose a different tab. Firefox reported: ${a}`)}if(!r.ok)return O(e,r.error);const i={value:r.value,elapsedMs:r.elapsedMs,target:o.target};return _(e,i)}};async function af(e,t,n){if(e.params.kind==="ms")return cf(e);if(e.params.kind==="download")return uf(e,t);const o=e.params.timeoutMs??xe,r=await n.targetContext.resolveTarget(e.params.target,{deadlineMs:o,timeoutMessage:()=>`Timed out after ${String(o)}ms resolving wait target.`});if(e.params.kind==="url"){const a=await qp(t,r.tab.id,e.params);return _(e,a)}if(e.params.kind==="load-state"&&e.params.state==="networkidle"){const a=await lf(e,t,r.tab.id);return _(e,{...a,target:r.target})}if(e.params.kind==="function"){const a=await ef(t,r.tab.id,e.params);return _(e,{...a,target:r.target})}const i=await W(t,r.tab.id,e);if(!i.ok)return O(e,i.error);const s={...i.result,target:r.target};return _(e,s)}async function cf(e){const t=Date.now(),n=e.params.durationMs??0,o=e.params.timeoutMs;if(await Up(Math.min(n,o??n)),o!==void 0&&n>o)throw new k("TIMEOUT",`Timed out after ${String(o)}ms waiting ${String(n)}ms.`);return _(e,{kind:"ms",matched:!0,elapsedMs:Math.max(0,Date.now()-t)})}async function uf(e,t){const n=Date.now(),o=e.params.timeoutMs??xe,r=await t.waitForDownload({...e.params.downloadId===void 0?{}:{downloadId:e.params.downloadId},...e.params.filenameGlob===void 0?{}:{filenameGlob:e.params.filenameGlob},timeoutMs:o,intervalMs:e.params.intervalMs??st});return _(e,{kind:"download",matched:!0,elapsedMs:Math.max(0,Date.now()-n),download:r})}async function lf(e,t,n){const o=Date.now(),r=e.params.timeoutMs??xe;return await t.waitForNetworkIdle({tabId:n,timeoutMs:r,idleMs:e.params.intervalMs??st}),{kind:"load-state",matched:!0,elapsedMs:Math.max(0,Date.now()-o)}}const df={open:async(e,t,n)=>{if(e.params.newTab){const i=await n.targetContext.resolveWindow(e.params.target?.window);Le(i);const s=await t.createTab({url:e.params.url,windowId:i.id});return n.targetContext.invalidate(),_(e,{target:await n.targetContext.resolveFreshTarget({tab:{kind:"id",id:s.id}}),url:s.url??e.params.url,loadState:"unknown"})}const o=await n.targetContext.resolveTarget(e.params.target),r=await t.navigateTab(o.tab.id,e.params.url);return n.targetContext.invalidate(),_(e,{target:await n.targetContext.resolveFreshTarget({tab:{kind:"id",id:r.id}}),url:r.url??e.params.url,loadState:"unknown"})},back:async(e,t,n)=>gt(e,t,n),forward:async(e,t,n)=>gt(e,t,n),reload:async(e,t,n)=>gt(e,t,n)};async function gt(e,t,n){const o=await n.targetContext.resolveTarget(e.params.target),r=e.command==="back"?await t.goBack(o.tab.id):e.command==="forward"?await t.goForward(o.tab.id):await t.reload(o.tab.id);return n.targetContext.invalidate(),_(e,{target:await n.targetContext.resolveFreshTarget({tab:{kind:"id",id:r.id}}),...r.url===void 0?{}:{url:r.url},loadState:"unknown"})}const pf={download:async(e,t)=>{const n=await t.download({url:e.params.url,...e.params.filename===void 0?{}:{filename:e.params.filename},...e.params.saveAs===void 0?{}:{saveAs:e.params.saveAs}});return _(e,n)},clipboard:async(e,t,n)=>{if(e.params.action==="read"){const s={action:"read",ok:!0,text:await t.readClipboard()};return _(e,s)}if(e.params.action==="write")return await t.writeClipboard(e.params.text??""),_(e,{action:"write",ok:!0});const o=await n.targetContext.resolveTarget(e.params.target),r=e.params.action==="paste"?{...e,params:{...e.params,text:await t.readClipboard()}}:e,i=await W(t,o.tab.id,r);return i.ok?(e.params.action==="copy"&&i.result.text!==void 0&&await t.writeClipboard(i.result.text),_(e,i.result)):O(e,i.error)},cookies:async(e,t)=>{if(e.params.action==="set"){if(e.params.name===void 0||e.params.value===void 0)throw new k("INVALID_TARGET","Cookie set requires name and value.");const r=await t.setCookie({url:e.params.url,name:e.params.name,value:e.params.value,...e.params.domain===void 0?{}:{domain:e.params.domain},...e.params.path===void 0?{}:{path:e.params.path}});return _(e,{action:"set",ok:!0,cookie:r})}if(e.params.action==="remove"){if(e.params.name===void 0)throw new k("INVALID_TARGET","Cookie remove requires name.");return await t.removeCookie({url:e.params.url,name:e.params.name}),_(e,{action:"remove",ok:!0})}const n=await t.listCookies({url:e.params.url,...e.params.name===void 0?{}:{name:e.params.name}}),o={action:e.params.action,ok:!0,...e.params.action==="get"?{cookie:n?.[0]??null}:{cookies:n}};return _(e,o)},network:async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target);return e.params.action==="clear"?(await t.clearNetworkRequests({tabId:o.tab.id,...e.params.urlGlob===void 0?{}:{urlGlob:e.params.urlGlob}}),_(e,{action:"clear",ok:!0})):_(e,{action:"list",ok:!0,requests:await t.listNetworkRequests({tabId:o.tab.id,...e.params.urlGlob===void 0?{}:{urlGlob:e.params.urlGlob}})})},pdf:async e=>O(e,{code:"UNSUPPORTED_CAPABILITY",message:"PDF export is unsupported because Firefox saves PDFs through a browser dialog instead of writing a requested CLI path."}),"set.viewport":async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target),r=await t.resizeWindow(o.window.id,{width:e.params.width,height:e.params.height});n.targetContext.invalidate();const i=at([r])[0];if(i===void 0)throw new k("INVALID_TARGET","Firefox did not return the resized window.");const s={window:Fe(i)};return _(e,s)}};function ff(e,t,n){const o=`data:image/${t};base64,`;if(!e.startsWith(o))throw new k("CAPTURE_FAILED",`Firefox did not return a ${t.toUpperCase()} screenshot.`);const r=e.slice(o.length),i=mf(r);if(i<=0)throw new k("CAPTURE_FAILED","Firefox returned an empty screenshot.");if(i>n)throw new k("OUTPUT_TOO_LARGE",`Screenshot is ${String(i)} bytes, exceeding the ${String(n)} byte limit.`);return{base64:r,bytes:i,...t==="png"?hf(r):{}}}function mf(e){const t=e.endsWith("==")?2:e.endsWith("=")?1:0;return Math.floor(e.length*3/4)-t}function hf(e){try{const t=atob(e.slice(0,32)),n=Uint8Array.from(t,i=>i.charCodeAt(0));if(![137,80,78,71,13,10,26,10].every((i,s)=>n[s]===i)||n.length<24)throw new Error("Invalid PNG header.");return{width:Sn(n,16),height:Sn(n,20)}}catch(t){throw new k("CAPTURE_FAILED",`Firefox returned invalid PNG data: ${t instanceof Error?t.message:String(t)}`)}}function Sn(e,t){return(e[t]??0)*16777216+((e[t+1]??0)<<16)+((e[t+2]??0)<<8)+(e[t+3]??0)}const gf={screenshot:async(e,t,n)=>{if(e.params.fullPage===!0)return O(e,{code:"UNSUPPORTED_CAPABILITY",message:"Full-page screenshots are unsupported because Firefox WebExtensions expose visible-tab capture only."});const o=await n.targetContext.resolveTarget(e.params.target),r=await vf(t,n,o),i=await wf(n,o,r),s=await bf(t,e,i),a=ff(s,e.params.format,e.params.maxImageBytes??ye),c={path:e.params.path,format:e.params.format,bytes:a.bytes,...a.width===void 0?{}:{width:a.width},...a.height===void 0?{}:{height:a.height},activation:r,imageBase64:a.base64,target:i};return _(e,c)}};async function vf(e,t,n){const o={tabActivated:!n.tab.active,windowFocused:!n.window.focused};try{o.tabActivated&&await e.selectTab(n.tab.id),o.windowFocused&&await e.focusWindow(n.window.id),(o.tabActivated||o.windowFocused)&&t.targetContext.invalidate()}catch(r){const i=r instanceof Error?r.message:String(r);throw new k("CAPTURE_FAILED",`Failed to activate screenshot target: ${i}`)}return o}async function wf(e,t,n){return n.tabActivated||n.windowFocused?e.targetContext.resolveFreshTarget({tab:{kind:"id",id:t.tab.id}}):t.target}async function bf(e,t,n){try{return await jp(e.captureVisibleTab(n.windowId,{format:t.params.format,...t.params.quality===void 0?{}:{quality:t.params.quality}}),t.params.timeoutMs??Wp)}catch(o){const r=o instanceof Error?o.message:String(o);throw new k(o instanceof k?o.code:"CAPTURE_FAILED",`Failed to capture visible tab screenshot: ${r}`)}}const _f={"tabs.list":async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target,{allowPrivate:!0});return _(e,{target:o.target,tabs:[...o.window.tabs]})},"windows.list":async(e,t,n)=>{const o=await n.targetContext.getWindows();return _(e,{windows:o.map(Fe)})},"tab.new":async(e,t,n)=>{const o=await n.targetContext.resolveWindow(e.params.target?.window);Le(o);const r=await t.createTab({...e.params.url===void 0?{}:{url:e.params.url},windowId:o.id});return n.targetContext.invalidate(),_(e,{target:await n.targetContext.resolveFreshTarget({tab:{kind:"id",id:r.id}})})},"tab.select":async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target);return await t.selectTab(o.tab.id),n.targetContext.invalidate(),_(e,{target:await n.targetContext.resolveFreshTarget({tab:{kind:"id",id:o.tab.id}})})},"tab.close":async(e,t,n)=>{const o=await n.targetContext.resolveTarget(e.params.target);await t.closeTab(o.tab.id),n.targetContext.invalidate();const r=await n.targetContext.findWindowById(o.window.id);return _(e,{closedTabId:o.tab.id,...r?.tabs.find(i=>i.active)?.id===void 0?{}:{nextActiveTabId:r.tabs.find(i=>i.active)?.id}})},"window.new":async(e,t,n)=>{const o=await t.createWindow({...e.params.url===void 0?{}:{url:e.params.url}});n.targetContext.invalidate();const r=at([o])[0];if(r===void 0)throw new k("INVALID_TARGET","Firefox did not return the created window.");return _(e,{window:Fe(r),...r.tabs[0]===void 0?{}:{target:Ke(r,r.tabs[0])}})},"window.select":async(e,t,n)=>{const o=await n.targetContext.resolveWindow(e.params.target.window);Le(o),await t.focusWindow(o.id),n.targetContext.invalidate();const r=await n.targetContext.resolveWindow({kind:"id",id:o.id}),i=r.tabs.find(s=>s.active);return _(e,{window:Fe(r),...i===void 0?{}:{target:Ke(r,i)}})},"window.close":async(e,t,n)=>{const o=await n.targetContext.resolveWindow(e.params.target.window);return Le(o),await t.closeWindow(o.id),n.targetContext.invalidate(),_(e,{closedWindowId:o.id})}};function yf(e){let t;const n=async()=>(t??=e.listWindows().then(at),t),o=async(r={})=>{const i=n();return r.deadlineMs===void 0||r.timeoutMessage===void 0?i:Je(i,r.deadlineMs,r.timeoutMessage)};return{getWindows:o,resolveTarget:async(r,i={})=>yn(await o(i),r,Tn(i)),resolveWindow:async(r,i={})=>or(await o(i),r),resolveFreshTarget:async(r,i={})=>(t=void 0,yn(await o(i),r,Tn(i)).target),findWindowById:async(r,i={})=>ir(await o(i),r),invalidate:()=>{t=void 0}}}function Tn(e){return e.allowPrivate===void 0?{}:{allowPrivate:e.allowPrivate}}const sr=Yd(_f,df,kp,sf,gf,pf),kf=Fp();async function ar(e,t){const n=yf(t),o=async(r,i)=>{try{return await ar(r,i)}catch(s){return Q(r.id,{code:s instanceof k?s.code:"PERMISSION_DENIED",message:s instanceof Error?s.message:String(s)},r.protocolVersion)}};return Kd(e,"batch")?kf(e,t,{executeStep:o,targetContext:n}):Sf(e)?Sp(e,t,{targetContext:n}):Tf(e)?Xd(sr,e,t,{executeStep:o,targetContext:n}):O(e,{code:"UNSUPPORTED_CAPABILITY",message:`Unsupported browser command: ${e.command}`})}function Sf(e){return bd(e.command)}function Tf(e){return Object.hasOwn(sr,e.command)}async function If(e,t){try{if(ip(e.command)&&!await t.hasRequiredHostAccess())throw new k("PERMISSION_DENIED","Approve host access for all websites in the firefox-cli extension popup.");return await ar(e,t)}catch(n){return Q(e.id,{code:n instanceof k?n.code:"PERMISSION_DENIED",message:n instanceof Error?n.message:String(n),...n instanceof k&&n.details!==void 0?{details:n.details}:{}},e.protocolVersion)}}function Ef(e){const{request:t,productVersion:n,approved:o,browserAdapter:r,protocolSession:i}=e;return t.command==="hello"?i.createOkResponse(t,{accepted:!0,negotiatedProtocolVersion:i.protocolVersion,peer:{...ho("extension",n),protocolMin:G.protocolMin,protocolMax:G.protocolMax}}):t.command==="pair.approve"||t.command==="pair.reset"?i.createErrorResponse(t.id,{code:"UNSUPPORTED_CAPABILITY",message:"Pairing commands are handled by the native host."}):o?t.command==="capabilities"?i.createOkResponse(t,{capabilities:[...Rd]}):t.command==="noop"?i.createOkResponse(t,{ok:!0}):If(t,r):i.createErrorResponse(t.id,{code:"NOT_APPROVED",message:"Approve firefox-cli in the extension popup before running CLI commands."})}class Rf{#e;#t;constructor(t){this.#e=t.browserAdapter,this.#t=t.productVersion}forward(t,n,o){return Ef({request:t,productVersion:this.#t,approved:n,browserAdapter:this.#e,protocolSession:o})}}const xf=66e4;class Af{#e;#t;#n=new gp;#r;#o;#i;#s;constructor(t){const n=t.browserAdapter??cp(),o=t.storageAdapter??{getPairToken:async()=>null,setPairToken:async()=>{}};this.#o=t.productVersion,this.#t=new vp(o),this.#r=new Rf({browserAdapter:n,productVersion:this.#o}),this.#e=new up({connectNative:t.connectNative,reconnectDelaysMs:t.reconnectDelaysMs??[250,1e3,5e3,1e4],scheduleTimer:t.scheduleTimer??((i,s)=>{setTimeout(i,s)}),events:{onConnect:()=>{this.#n.beginNegotiation(),this.#s=void 0,this.#c()},onMessage:i=>{this.#u(i)},onDisconnect:i=>{this.#n.markDisconnected(),this.#s=i,this.#p()},onConnectError:i=>{this.#n.markDisconnected(),this.#s=i}}});const r=t.requestTimeoutMs??xf;this.#i=new lr({timeoutMs:r,onDuplicate:i=>Q(i.id,{code:"INVALID_ENVELOPE",message:`Request ID is already pending: ${i.id}`},i.protocolVersion??G.protocolMax),onTimeout:i=>Q(i.id,{code:"TIMEOUT",message:`Timed out waiting for native host response to ${i.command}.`},i.protocolVersion??G.protocolMax)})}start(){this.#e.stopped||(this.#t.loadStoredPairToken().then(({applied:t,pairToken:n})=>{t&&n!==null&&this.#e.connected&&this.#c()}).catch(t=>{this.#s=t instanceof Error?t.message:String(t)}),this.#e.start())}getStatus(){return{connected:this.#e.connected,approved:this.#t.approved,...this.#s===void 0?{}:{lastError:this.#s},diagnostics:JSON.stringify({connected:this.#e.connected,approved:this.#t.approved,lastError:this.#s,nativeHostName:An,protocolVersion:ee,nativeProtocolState:this.#n.stateName},null,2)}}async handleRuntimeMessage(t){if(t.type==="firefox-cli:get-status")return this.getStatus();if(t.type==="firefox-cli:approve"){this.#t.beginMutation();const n=$e("pair.approve",{}),o=await this.#a(n);return o.ok?(await this.#t.approve(o.result.token),this.#s=void 0):(this.#t.markRejected(),this.#s=o.error.message),this.getStatus()}if(t.type==="firefox-cli:reset"){if(this.#t.beginMutation(),this.#e.connected){const n=await this.#a($e("pair.reset",{}));if(!n.ok)return this.#s=n.error.message,this.getStatus()}return await this.#t.reset(),this.#s=void 0,this.getStatus()}}stop(){this.#e.stopped||(this.#e.stop(),this.#t.beginMutation(),this.#n.markDisconnected(),this.#s="Extension background stopped.",this.#i.drain(t=>Q(t.id,{code:"NATIVE_HOST_UNAVAILABLE",message:"Extension background stopped before the native host responded."},t.protocolVersion??G.protocolMax)))}#c(){const t=$e("hello",{...ho("extension",this.#o),productVersion:this.#o,protocolMin:G.protocolMin,protocolMax:G.protocolMax,...this.#t.pairToken===null?{}:{pairToken:this.#t.pairToken}},void 0,G.protocolMin);this.#n.beginNegotiation(),this.#a(t).then(n=>{n.ok||(this.#s=n.error.message)}).catch(n=>{this.#s=n instanceof Error?n.message:String(n)})}async#a(t){if(this.#e.stopped)return O(t,{code:"NATIVE_HOST_UNAVAILABLE",message:"Extension background is stopped."});if(!this.#e.connected)return O(t,{code:"EXTENSION_NOT_CONNECTED",message:"Native host is not connected."});const n=t.command==="hello"?void 0:this.#n.getNegotiatedSession();if(n!==void 0&&!n.ok)return O(t,n.error);const o=n===void 0?t:n.value.withRequestVersion(t),r=this.#i.track(o);return r.ok?(this.#e.postMessage(o)||this.#i.settle(o.id,Q(o.id,{code:"NATIVE_HOST_UNAVAILABLE",message:"Failed to send request to the native host."},o.protocolVersion)),r.promise):r.value}async#u(t){if(!this.#e.stopped){if(pp(t)){await this.#l(t);return}await this.#d(t)}}async#l(t){const n=this.#i.getCommand(t.id);if(n===void 0)return;const o=this.#n.parseResponse(n,t);if(!o.ok){this.#s=o.error.message,this.#n.applyResponseParseFailure(n,o.error),this.#i.settle(t.id,Q(t.id,o.error,this.#n.getMessageProtocolVersion(t)));return}let r;n==="hello"&&Pf(n,o.value)&&(this.#n.applyHelloResponse(o.value),o.value.ok&&(r=await this.#t.applyHelloPairing(o.value.result.pairing))),this.#i.settle(t.id,o.value),this.#s=r}async#d(t){const n=this.#n.parseRequest(t);if(!n.ok){const r=this.#n.createStateErrorResponse(t,n.error);this.#n.markRequestIncompatibleIfNeeded(t,n.error.code,n.error),this.#e.postMessage(r);return}const o=this.#n.prepareRequest(n.value);if(!o.ok){this.#e.postMessage(o.response);return}this.#e.postMessage(await this.#r.forward(n.value,this.#t.approved,o.protocolSession))}#p(){this.#i.drain(t=>Q(t.id,{code:"NATIVE_HOST_UNAVAILABLE",message:"Native host disconnected before responding."},t.protocolVersion??G.protocolMax))}}function Pf(e,t){return e==="hello"&&(!t.ok||"accepted"in t.result&&"peer"in t.result)}async function zf(e){const t=Date.now();try{const m=await o(Promise.resolve().then(()=>n(e.script)),e.timeoutMs),A={value:r(m),elapsedMs:Math.max(0,Math.round(Date.now()-t))},K=new TextEncoder().encode(JSON.stringify(A)).byteLength;if(K>e.maxResultBytes)throw g("RESULT_TOO_LARGE",`Eval result is ${String(K)} bytes, exceeding the ${String(e.maxResultBytes)} byte limit.`,{resultBytes:K,maxResultBytes:e.maxResultBytes});return{ok:!0,...A}}catch(m){return b(m)?{ok:!1,error:{code:m.code,message:m.message,...m.details===void 0?{}:{details:m.details}}}:{ok:!1,error:{code:"EVAL_ERROR",message:`Eval failed: ${m instanceof Error?m.message:String(m)}`,details:R(m)}}}function n(m){const{Function:T}=globalThis;let A;try{const Z=T(`"use strict"; return (${m}
|
|
72
|
+
);`);A=()=>Z.call(globalThis)}catch(Z){if(!v(Z))throw Z}return A!==void 0?A():T(`"use strict"; return (async () => {${m}
|
|
73
|
+
})();`).call(globalThis)}async function o(m,T){let A;try{return await Promise.race([m,new Promise((K,Z)=>{A=setTimeout(()=>{Z(g("TIMEOUT",`Timed out after ${String(T)}ms running eval.`))},T)})])}finally{A!==void 0&&clearTimeout(A)}}function r(m){return m===void 0?{type:"undefined"}:{type:"json",value:i(m,[])}}function i(m,T){const A=s(m);if(A.ok)return A.value;if(a(m))throw g("SERIALIZATION_FAILED",`Eval result contains a non-serializable ${typeof m}.`);if(m===null||typeof m!="object")throw g("SERIALIZATION_FAILED","Eval result is not JSON-serializable.");if(T.includes(m))throw g("SERIALIZATION_FAILED","Eval result contains a circular reference.");return c(m,T)}function s(m){if(m===null||typeof m=="string"||typeof m=="boolean")return{ok:!0,value:m};if(typeof m!="number")return{ok:!1};if(!Number.isFinite(m))throw g("SERIALIZATION_FAILED","Eval result contains a non-finite number.");return{ok:!0,value:m}}function a(m){return typeof m>"u"||typeof m=="bigint"||typeof m=="function"||typeof m=="symbol"}function c(m,T){const A=[...T,m];if(Array.isArray(m))return m.map(K=>i(K,A));if(l(m))return i(m.toJSON(),A);if(!f(m))throw g("SERIALIZATION_FAILED",`Eval result contains a non-plain object: ${m.constructor.name}.`);return Object.fromEntries(Object.entries(m).map(([K,Z])=>[K,i(Z,A)]))}function l(m){return"toJSON"in m&&typeof m.toJSON=="function"}function f(m){return Object.getPrototypeOf(m)===Object.prototype||Object.getPrototypeOf(m)===null}function g(m,T,A){return Object.assign(new Error(T),{name:"EvalExecutorError",code:m,...A===void 0?{}:{details:A}})}function b(m){return m instanceof Error&&m.name==="EvalExecutorError"&&"code"in m&&typeof m.code=="string"}function v(m){return m instanceof SyntaxError||typeof m=="object"&&m!==null&&"name"in m&&m.name==="SyntaxError"}function R(m){return m instanceof Error?{name:m.name,...m.stack===void 0?{}:{stack:m.stack}}:{error:String(m)}}}function Of(e){const t=e.clipboard??navigator.clipboard,n={origins:qo().popupApprovalOrigins},o=e.contentScriptState??tr();return{hasRequiredHostAccess:async()=>e.browser.permissions?.contains(n)??!0,listWindows:async()=>(await e.browser.windows.getAll({populate:!0})).filter(Nf).map(i=>({id:i.id,focused:i.focused===!0,...i.incognito===void 0?{}:{private:i.incognito},...i.left===void 0?{}:{left:i.left},...i.top===void 0?{}:{top:i.top},...i.width===void 0?{}:{width:i.width},...i.height===void 0?{}:{height:i.height},tabs:(i.tabs??[]).map(oe)})),createTab:async r=>oe(await e.browser.tabs.create({active:!0,...r.url===void 0?{}:{url:r.url},...r.windowId===void 0?{}:{windowId:r.windowId}})),selectTab:async r=>{const i=oe(await e.browser.tabs.update(r,{active:!0}));return await e.browser.windows.update(i.windowId,{focused:!0}),i},closeTab:async r=>{await e.browser.tabs.remove(r)},createWindow:async r=>vt(await e.browser.windows.create({...r.url===void 0?{}:{url:r.url}})),focusWindow:async r=>vt(await e.browser.windows.update(r,{focused:!0})),closeWindow:async r=>{await e.browser.windows.remove(r)},navigateTab:async(r,i)=>oe(await e.browser.tabs.update(r,{active:!0,url:i})),goBack:async r=>(await e.browser.tabs.goBack(r),oe(await e.browser.tabs.get(r))),goForward:async r=>(await e.browser.tabs.goForward(r),oe(await e.browser.tabs.get(r))),reload:async r=>(await e.browser.tabs.reload(r),oe(await e.browser.tabs.get(r))),captureVisibleTab:async(r,i)=>e.browser.tabs.captureVisibleTab(r,{format:i.format,...i.quality===void 0?{}:{quality:i.quality}}),download:async r=>{const i=await e.browser.downloads.download({url:r.url,...r.filename===void 0?{}:{filename:r.filename},...r.saveAs===void 0?{}:{saveAs:r.saveAs}}),[s]=await e.browser.downloads.search({id:i});return In(s??{id:i})},waitForDownload:async r=>{const i=Ge(r.timeoutMs),s=()=>"Timed out waiting for download.",a=r.filenameGlob===void 0?void 0:He(r.filenameGlob);for(;;){const l=(await i.run(e.browser.downloads.search(r.downloadId===void 0?{}:{id:r.downloadId}),s)).find(f=>(r.downloadId===void 0||f.id===r.downloadId)&&(a===void 0||a(f.filename??"")));if(l?.state==="complete")return In(l);if(l?.state==="interrupted")throw new Error(`Download ${String(l.id)} was interrupted.`);i.throwIfExpired(s),await i.sleep(r.intervalMs,s)}},readClipboard:async()=>t.readText(),writeClipboard:async r=>{await t.writeText(r)},listCookies:async r=>(await e.browser.cookies.getAll({url:r.url,...r.name===void 0?{}:{name:r.name}})).map(En),setCookie:async r=>En(await e.browser.cookies.set({url:r.url,name:r.name,value:r.value,...r.domain===void 0?{}:{domain:r.domain},...r.path===void 0?{}:{path:r.path}})),removeCookie:async r=>{await e.browser.cookies.remove(r)},listNetworkRequests:async r=>e.networkObservation.observeTab(r.tabId,i=>i.list({tabId:r.tabId,...r.urlGlob===void 0?{}:{urlGlob:r.urlGlob}})),clearNetworkRequests:async r=>e.networkObservation.observeTab(r.tabId,i=>{i.clear({tabId:r.tabId,...r.urlGlob===void 0?{}:{urlGlob:r.urlGlob}})},{retainWhenEmpty:!1}),waitForNetworkIdle:async r=>{const i=Ge(r.timeoutMs),s=()=>"Timed out waiting for network idle.";await e.networkObservation.observeTab(r.tabId,async a=>{for(;;){if(a.isIdle({tabId:r.tabId,idleMs:r.idleMs}))return;i.throwIfExpired(s),await i.sleep(100,s)}})},resizeWindow:async(r,i)=>{await e.browser.windows.update(r,i);const a=(await e.browser.windows.getAll({populate:!0})).find(c=>c.id===r);if(a===void 0)throw new Error("Firefox did not return the resized window.");return vt(a)},sendContentRequest:async(r,i)=>wp({sendMessage:async(s,a)=>e.browser.tabs.sendMessage(s,a),injectContentScript:async s=>{await e.browser.scripting.executeScript({target:{tabId:s,allFrames:!1},files:["content.js"]})},markInjected:s=>{o.markInjected(s)}},r,i),executeEval:async(r,i)=>{const[s]=await e.browser.scripting.executeScript({target:{tabId:r,allFrames:!1},world:"MAIN",func:zf,args:[i]});if(s===void 0)throw new Error("Firefox did not return an eval result.");if(s.error!==void 0)throw new Error(s.error.message);if(s.result===void 0)throw new Error("Firefox did not return an eval payload.");return s.result}}}function In(e){if(e.id===void 0)throw new Error("Firefox did not return a download ID.");return{id:e.id,...e.filename===void 0?{}:{filename:e.filename},...e.state===void 0?{}:{state:e.state}}}function vt(e){if(e.id===void 0)throw new Error("Firefox did not return a window ID.");return{id:e.id,focused:e.focused===!0,...e.incognito===void 0?{}:{private:e.incognito},...e.left===void 0?{}:{left:e.left},...e.top===void 0?{}:{top:e.top},...e.width===void 0?{}:{width:e.width},...e.height===void 0?{}:{height:e.height},tabs:(e.tabs??[]).map(oe)}}function Nf(e){return e.id!==void 0}function oe(e){return{id:e.id,index:e.index,active:e.active,windowId:e.windowId,...e.title===void 0?{}:{title:e.title},...e.url===void 0?{}:{url:e.url},...e.incognito===void 0?{}:{private:e.incognito},...e.cookieStoreId===void 0?{}:{cookieStoreId:e.cookieStoreId}}}function En(e){return{name:e.name,value:e.value,...e.domain===void 0?{}:{domain:e.domain},...e.path===void 0?{}:{path:e.path}}}class cr{#e;#t;#n;#r=new Map;#o=new Map;#i=new Map;constructor(t={}){this.#e=t.maxCompletedRequestsPerTab??1e3,this.#t=t.maxActiveRequestAgeMs??6e4,this.#n=t.now??(()=>Date.now())}recordStart(t){if(this.pruneStaleActiveRequests(),!Rn(t.tabId)||!$f(t.url))return;const n=this.#n(),o={id:String(t.requestId),tabId:t.tabId,url:t.url,...t.method===void 0?{}:{method:t.method},...t.type===void 0?{}:{type:t.type},startedAt:n};return this.#r.set(o.id,o),this.#i.set(o.tabId,n),o}recordEnd(t){this.pruneStaleActiveRequests();const n=String(t.requestId),o=this.#r.get(n);if(o===void 0)return;this.#r.delete(n);const r=this.#n(),i={...o,...t.statusCode===void 0?{}:{statusCode:t.statusCode},completedAt:r};return this.#c(i),i}list(t){this.pruneStaleActiveRequests();const n=t.urlGlob===void 0?void 0:He(t.urlGlob);return this.#s(t.tabId).filter(o=>n===void 0||n(o.url)).sort((o,r)=>o.startedAt-r.startedAt).map(Mf)}clear(t){this.pruneStaleActiveRequests();const n=this.#o.get(t.tabId);if(n===void 0)return;const o=t.urlGlob===void 0?void 0:He(t.urlGlob);this.#o.set(t.tabId,n.filter(r=>o!==void 0&&!o(r.url))),this.#a(t.tabId)}isIdle(t){if(this.pruneStaleActiveRequests(),[...this.#r.values()].some(o=>o.tabId===t.tabId))return!1;const n=this.#i.get(t.tabId)??0;return this.#n()-n>=t.idleMs}pruneTab(t){if(Rn(t)){for(const[n,o]of this.#r)o.tabId===t&&this.#r.delete(n);this.#o.delete(t),this.#i.delete(t)}}hasActiveRequests(t){return this.pruneStaleActiveRequests(),this.#u(t)}hasTabState(t){return this.pruneStaleActiveRequests(),this.hasActiveRequests(t)||(this.#o.get(t)?.length??0)>0||this.#i.has(t)}pruneStaleActiveRequests(t=this.#t){const n=this.#n();let o=0;for(const[r,i]of this.#r)n-i.startedAt<t||(this.#r.delete(r),this.#c({...i,completedAt:n}),o+=1);return o}#s(t){return[...this.#o.get(t)??[],...[...this.#r.values()].filter(n=>n.tabId===t)]}#c(t){const n=[...this.#o.get(t.tabId)??[],t];this.#o.set(t.tabId,Cf(n,this.#e)),this.#i.set(t.tabId,t.completedAt??this.#n())}#a(t){(this.#o.get(t)?.length??0)===0&&this.#o.delete(t),!(!this.#i.has(t)||this.#u(t)||(this.#o.get(t)?.length??0)>0)&&this.#i.delete(t)}#u(t){return[...this.#r.values()].some(n=>n.tabId===t)}}function Cf(e,t){const n=e.length-t;return n<=0?[...e]:e.slice(n)}function Rn(e){return typeof e=="number"&&Number.isInteger(e)&&e>=0}function $f(e){if(e===void 0)return!1;const t=/^[a-z][a-z0-9+.-]*:/iu.exec(e)?.[0]?.toLowerCase();return t!==void 0&&t!=="moz-extension:"&&t!=="about:"&&t!=="chrome:"&&t!=="resource:"}function Mf(e){return{id:e.id,url:e.url,...e.method===void 0?{}:{method:e.method},...e.type===void 0?{}:{type:e.type},...e.statusCode===void 0?{}:{statusCode:e.statusCode}}}const Df=3e4;class Zf{tracker;#e;#t;#n;#r;#o=new Map;constructor(t){this.#e=t.browser,this.tracker=t.tracker??new cr,this.#t=t.retentionMs??Df,this.#n=t.scheduleTimer??((n,o)=>setTimeout(n,o)),this.#r=t.clearTimer??(n=>{clearTimeout(n)})}async observeTab(t,n,o={}){const r=this.#i(t);r.activeCount+=1,this.#a(r);try{return await n(this.tracker)}finally{r.activeCount=Math.max(0,r.activeCount-1),o.retainWhenEmpty===!1&&!this.tracker.hasTabState(t)?this.#u(t):this.#c(t)}}pruneTab(t){this.tracker.pruneTab(t),this.#u(t)}dispose(){for(const t of[...this.#o.keys()])this.#u(t)}observedTabIds(){return[...this.#o.keys()].sort((t,n)=>t-n)}#i(t){const n=this.#o.get(t);if(n!==void 0)return n;const o={activeCount:0,registrations:[]};this.#o.set(t,o),this.#s(t,this.#e.webRequest?.onBeforeRequest,i=>{const s=this.tracker.recordStart(i);s!==void 0&&this.#c(s.tabId)});const r=i=>{const s=this.tracker.recordEnd(i);s!==void 0&&this.#c(s.tabId)};return this.#s(t,this.#e.webRequest?.onCompleted,r),this.#s(t,this.#e.webRequest?.onErrorOccurred,r),o}#s(t,n,o){const r=this.#o.get(t);n===void 0||r===void 0||(n.addListener(o,{urls:qo().webRequestListenerOrigins,tabId:t}),r.registrations.push({event:n,listener:o}))}#c(t){const n=this.#o.get(t);n===void 0||n.activeCount>0||(this.#a(n),n.retentionTimer=this.#n(()=>{const o=this.#o.get(t);if(!(o===void 0||o.activeCount>0)){if(this.tracker.hasActiveRequests(t)){this.#c(t);return}this.tracker.pruneTab(t),this.#u(t)}},this.#t))}#a(t){t.retentionTimer!==void 0&&(this.#r(t.retentionTimer),delete t.retentionTimer)}#u(t){const n=this.#o.get(t);if(n!==void 0){this.#a(n);for(const o of n.registrations)o.event.removeListener(o.listener);this.#o.delete(t)}}}function Vf(e){const t=e.networkObservation??new Zf({browser:e.browser,tracker:e.networkTracker??new cr}),n=tr(),o=new Af({browserAdapter:Of({browser:e.browser,networkObservation:t,contentScriptState:n,...e.clipboard===void 0?{}:{clipboard:e.clipboard}}),connectNative:s=>e.browser.runtime.connectNative(s),productVersion:e.manifest.version,...Lf(e.controllerOptions)}),r=async s=>o.handleRuntimeMessage(s),i=s=>{t.pruneTab(s),n.forgetTab(s)};return o.start(),e.browser.runtime.onMessage.addListener(r),e.browser.tabs.onRemoved?.addListener(i),{controller:o,dispose:()=>{e.browser.runtime.onMessage.removeListener(r),t.dispose(),e.browser.tabs.onRemoved?.removeListener(i),o.stop()}}}function Lf(e){return e===void 0?{}:{...e.reconnectDelaysMs===void 0?{}:{reconnectDelaysMs:e.reconnectDelaysMs},...e.scheduleTimer===void 0?{}:{scheduleTimer:e.scheduleTimer},...e.requestTimeoutMs===void 0?{}:{requestTimeoutMs:e.requestTimeoutMs},...e.storageAdapter===void 0?{}:{storageAdapter:e.storageAdapter}}}const Ff=3,Uf="FF-CLI Bridge",jf="0.1.1",Bf="Browser extension bridge for CLI control.",Wf={gecko:{id:"ff-cli-bridge@respawn.pro",update_url:"https://opensource.respawn.pro/firefox-cli/updates.json",strict_min_version:"150.0",data_collection_permissions:{required:["browsingActivity","websiteActivity","websiteContent"],optional:[]}}},Gf=["nativeMessaging","scripting","tabs","storage","downloads","cookies","clipboardRead","clipboardWrite","webRequest"],Jf=["<all_urls>"],Hf={scripts:["background.js"]},Kf={default_title:"FF-CLI Bridge",default_popup:"popup.html"},Yf={manifest_version:Ff,name:Uf,version:jf,description:Bf,browser_specific_settings:Wf,permissions:Gf,host_permissions:Jf,background:Hf,action:Kf};Vf({browser,manifest:Yf});
|