@visa/cli 1.1.1-rc.0 → 1.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/dist/cli.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var Zt=Object.create;var fe=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var en=Object.getOwnPropertyNames;var tn=Object.getPrototypeOf,nn=Object.prototype.hasOwnProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var rn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),on=(t,e)=>{for(var n in e)fe(t,n,{get:e[n],enumerable:!0})},sn=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of en(e))!nn.call(t,o)&&o!==n&&fe(t,o,{get:()=>e[o],enumerable:!(r=Qt(e,o))||r.enumerable});return t};var p=(t,e,n)=>(n=t!=null?Zt(tn(t)):{},sn(e||!t||!t.__esModule?fe(n,"default",{value:t,enumerable:!0}):n,t));async function je(){try{let{stdout:t}=await R("security",["find-generic-password","-s",A,"-a",Z,"-w"],{timeout:5e3});return t.trim()||null}catch{return null}}async function qe(t){try{try{await R("security",["delete-generic-password","-s",A,"-a",Z],{timeout:5e3})}catch{}return await R("security",["add-generic-password","-s",A,"-a",Z,"-w",t],{timeout:5e3}),!0}catch{return!1}}async function Fe(){try{await R("security",["delete-generic-password","-s",A,"-a",Z],{timeout:5e3})}catch{}}async function an(){try{let{stdout:t}=await R("security",["find-generic-password","-s",A,"-a",Q,"-w"],{timeout:5e3});return t.trim()||null}catch{return null}}async function cn(t){try{try{await R("security",["delete-generic-password","-s",A,"-a",Q],{timeout:5e3})}catch{}await R("security",["add-generic-password","-s",A,"-a",Q,"-w",t],{timeout:5e3})}catch{}}async function ln(){try{await R("security",["delete-generic-password","-s",A,"-a",Q],{timeout:5e3})}catch{}}function un(t){C.mkdirSync(ye,{recursive:!0,mode:448}),C.writeFileSync(X,t,{mode:384})}function dn(){try{return C.readFileSync(X,"utf-8").trim()||null}catch{return null}}var De,Ve,C,He,he,R,ye,X,A,Z,Q,g,K=f(()=>{"use strict";De=require("child_process"),Ve=require("util"),C=p(require("fs")),He=p(require("os")),he=p(require("path")),R=(0,Ve.promisify)(De.execFile),ye=he.join(He.homedir(),".visa-mcp"),X=he.join(ye,"session-token"),A="visa-cli",Z="session-token",Q="rc-access";g=class{static async getSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN==="true")return Promise.resolve("mock-session-token-for-testing");let e=await je();if(e)return e;let n=dn();return n?(await qe(n),n):null}static async saveSessionToken(e){if(process.env.VISA_MOCK_KEYCHAIN==="true")return;if(await qe(e)){if(await je()===e){try{C.unlinkSync(X)}catch{}return}await Fe()}if(un(e),await this.getSessionToken()!==e)throw new Error("Failed to persist session token. "+(process.platform==="darwin"?'Check Keychain Access permissions for "visa-cli".':`Ensure ${ye} is writable.`))}static async getRcAccessToken(){return process.env.VISA_MOCK_KEYCHAIN==="true"?"mock-rc-token-for-testing":an()}static async saveRcAccessToken(e){process.env.VISA_MOCK_KEYCHAIN!=="true"&&await cn(e)}static async deleteSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN!=="true"){await Fe();try{C.unlinkSync(X)}catch{}}}static async clearAll(){await this.deleteSessionToken(),await ln()}}});var _e=rn((Gn,mn)=>{mn.exports={name:"@visa/cli",version:"1.1.1-rc.0",description:"AI-powered payments for Claude Code",bin:{"visa-cli":"./bin/visa-cli.js"},scripts:{build:"tsc --noEmit && node esbuild.config.js",dev:"tsc --watch",start:"node dist/mcp-server/index.js",test:"jest --config jest.config.js","test:unit":"jest --config jest.config.js","test:unit:watch":"jest --config jest.config.js --watch","test:unit:coverage":"jest --config jest.config.js --coverage","test:smoke":"VISA_AUTH_URL=https://auth.visacli.sh jest --config jest.smoke.config.js","test:integration":"jest --config jest.integration.config.js","test:e2e":"jest --config jest.e2e.config.js","test:catalog-e2e":"jest --config jest.catalog-e2e.config.js","test:all":"npm run test:unit && npm run test:integration && npm run test:e2e",prepublishOnly:"npm run build && npm test",lint:"eslint src/**/*.ts",format:'prettier --write "src/**/*.ts"',"format:check":'prettier --check "src/**/*.ts"'},keywords:["visa","checkout","mcp","ai-agent","payments","click-to-pay","usdc","stablecoin"],author:"Visa Crypto Labs",license:"SEE LICENSE IN LICENSE",dependencies:{"@modelcontextprotocol/sdk":"^1.0.0",commander:"^12.1.0",zod:"^3.23.0"},devDependencies:{"@visa-cli/tools":"workspace:*","@changesets/changelog-git":"^0.2.1","@changesets/cli":"^2.30.0","@types/jest":"^30.0.0","@types/node":"^25.6.0","@typescript-eslint/eslint-plugin":"^8.56.1","@typescript-eslint/parser":"^8.56.1","@types/express":"^5.0.0",esbuild:"^0.27.4",express:"^4.21.0",eslint:"^10.0.2","eslint-config-prettier":"^10.1.8",jest:"^29.7.0",prettier:"^3.8.1","ts-jest":"^29.2.0",typescript:"^5.7.0"},engines:{node:">=18.0.0"},files:["bin/visa-cli.js","dist/","native/visa-keychain.m","README.md","LICENSE"]}});async function ze(t,e){let n=e?.timeoutMs??3e4,r=new AbortController,o=setTimeout(()=>r.abort(),n);try{let{timeoutMs:s,...a}=e??{};return await fetch(t,{...a,signal:r.signal})}finally{clearTimeout(o)}}var Ye=f(()=>{"use strict"});function Xe(t,e){let n=Je(t),r=Je(e);if(!n||!r)return!1;for(let o=0;o<3;o++)if(n.main[o]!==r.main[o])return n.main[o]>r.main[o];return n.pre&&!r.pre?!1:!n.pre&&r.pre?!0:!n.pre&&!r.pre?!1:bn(n.pre,r.pre)>0}function Je(t){if(typeof t!="string")return null;let n=t.trim().replace(/^v/,"").match(wn);return n?{main:[Number(n[1]),Number(n[2]),Number(n[3])],pre:n[4]??null}:null}function bn(t,e){let n=t.split("."),r=e.split("."),o=Math.max(n.length,r.length);for(let s=0;s<o;s++){if(s>=n.length)return-1;if(s>=r.length)return 1;let a=n[s],i=r[s],l=/^\d+$/.test(a),c=/^\d+$/.test(i);if(l&&c){let u=Number(a)-Number(i);if(u!==0)return u}else{if(l)return-1;if(c)return 1;if(a<i)return-1;if(a>i)return 1}}return 0}var wn,Ze=f(()=>{"use strict";wn=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/});function re(){return!!(Qe(process.env.VISA_CLI_NO_UPDATE_CHECK)||Qe(process.env.CI)||process.env.NODE_ENV==="test")}function Qe(t){if(t===void 0)return!1;let e=t.trim().toLowerCase();return!(e===""||e==="0"||e==="false"||e==="no"||e==="off")}var be=f(()=>{"use strict"});var Se,$,oe=f(()=>{"use strict";Ye();Ze();be();Se="1.1.1-rc.0",$=class{constructor(e){this.getSessionToken=e;this.baseUrl=process.env.VISA_AUTH_URL||"https://auth.visacli.sh"}getSessionToken;baseUrl;lastSignals={};parseServerSignals(e){if(this.lastSignals={},!re()){let r=e.headers.get("X-Latest-Version"),o=e.headers.get("X-Update-Message");r&&Xe(r,Se)&&(this.lastSignals.updateAvailable={version:r,message:o||`Update available: v${r}. Run: npm install -g @visa/cli && visa-cli setup`})}let n=e.headers.get("X-Feedback-Prompt");if(n)try{this.lastSignals.feedbackPrompt=JSON.parse(n)}catch{}}getClientVersion(){return Se}async request(e,n,r,o,s){let a=await this.getSessionToken();if(!a)throw new Error("Not logged in. Sign up at https://visacli.sh or run: visa-cli setup");let i={Authorization:`Bearer ${a}`};s&&(e==="GET"?i["X-User-Context"]=s.replace(/[\r\n\0]/g," ").slice(0,1e3):r={...r||{},user_context:s}),r&&(i["Content-Type"]="application/json");let l;try{l=await ze(`${this.baseUrl}${n}`,{method:e,headers:{...i,"X-Visa-CLI-Version":Se},body:r?JSON.stringify(r):void 0,timeoutMs:o})}catch(u){throw u.name==="AbortError"||u.message?.includes("aborted")?new Error("The request timed out. The server may be under heavy load. Please try again."):new Error("Cannot reach the Visa CLI server. Check your internet connection and try again.")}if(this.parseServerSignals(l),l.status===401)throw new Error("Your session has expired. Run: visa-cli setup");if(l.status===429){let u=l.headers.get("Retry-After")||"3";throw new Error(`Rate limited \u2014 wait ${u}s. Tip: use the batch tool to combine multiple requests into one.`)}if(l.status===503)throw new Error("Visa CLI is temporarily unavailable. Check https://visacli.sh for status.");let c;try{c=await l.json()}catch{throw l.status===500?new Error(`Server error on ${n}. Try again or check https://visacli.sh for status.`):new Error(`Unexpected response from ${n}. Try again.`)}if(!l.ok)throw l.status===500?new Error(`Server error on ${n}. Try again or check https://visacli.sh for status.`):new Error(c?.error||`Request failed (${l.status}). Try again.`);return c}async pay(e,n){return this.request("POST","/v1/pay",e,void 0,n)}async shortcut(e,n,r,o){return this.request("POST",`/v1/shortcuts/${encodeURIComponent(e)}`,n,r,o)}async batch(e,n,r){return this.request("POST","/v1/batch",e,n,r)}async catalogSearch(e,n){let r=new URLSearchParams;e&&r.set("q",e),n&&r.set("category",n);let o=r.toString();return this.request("GET",`/v1/catalog${o?`?${o}`:""}`)}async catalogTool(e){try{return await this.request("GET",`/v1/catalog/${encodeURIComponent(e)}`)}catch{return null}}async paymentPreview(e,n){return this.request("POST","/v1/payment-preview",e,void 0,n)}async getStatus(e){return this.request("GET","/v1/status",void 0,void 0,e)}async getTransactions(e){return this.request("GET","/v1/transactions",void 0,void 0,e)}async updateSpendingControls(e,n){return this.request("POST","/v1/spending-controls",e,void 0,n)}async removeCard(e,n,r){return this.request("DELETE",`/v1/cards/${encodeURIComponent(String(e))}`,n,void 0,r)}async setDefaultCard(e,n,r){return this.request("POST",`/v1/cards/${encodeURIComponent(String(e))}/default`,n,void 0,r)}async getAttestationChallenge(){return this.request("GET","/v1/attestation-challenge")}async registerAttestationKey(e){return this.request("POST","/v1/attestation-key",{publicKey:e})}async logout(e,n){return this.request("POST","/v1/logout",e,void 0,n)}async feedback(e,n,r){return this.request("POST","/v1/feedback",{message:e,...n&&{transaction_id:n}},void 0,r)}async feedSubmit(e){return this.request("POST","/v1/feed",e)}async feedList(e){let n=new URLSearchParams;e?.tab&&n.set("tab",e.tab),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset));let r=n.toString();return this.request("GET",`/v1/feed${r?"?"+r:""}`)}async feedVote(e,n){return this.request("POST",`/v1/feed/${encodeURIComponent(e)}/vote`,{direction:n})}async feedApprove(e){return this.request("POST",`/v1/feed/${encodeURIComponent(e)}/approve`)}async feedDelete(e){return this.request("DELETE",`/v1/feed/${encodeURIComponent(e)}`)}async feedPending(){return this.request("GET","/v1/feed/pending")}async submitFeedback(e,n,r){return this.request("POST","/v1/feedback",{message:e,...n&&{transaction_id:n}},void 0,r)}async getFeedback(e,n){let r=new URLSearchParams;e&&r.set("limit",String(e));let o=r.toString();return this.request("GET",`/v1/feedback${o?"?"+o:""}`,void 0,void 0,n)}async submitRatedFeedback(e){return this.request("POST","/v1/feedback",e)}}});function vn(){w.existsSync(xe)||w.mkdirSync(xe,{recursive:!0,mode:448})}function xn(){if(!ve){if(vn(),w.existsSync(B)&&w.statSync(B).size>Sn){let e=B+".1";w.existsSync(e)&&w.unlinkSync(e),w.renameSync(B,e)}ve=w.createWriteStream(B,{flags:"a"})}return ve}function se(t,...e){let n=new Date().toISOString(),r=e.map(s=>typeof s=="string"?s:JSON.stringify(s,null,2)).join(" "),o=`[${n}] [${t}] ${r}
2
- `;process.stderr.write(o),xn().write(o)}var w,Pe,et,xe,B,Sn,ve,M,Te=f(()=>{"use strict";w=p(require("fs")),Pe=p(require("path")),et=p(require("os")),xe=Pe.join(et.homedir(),".visa-mcp"),B=Pe.join(xe,"mcp-server.log"),Sn=5*1024*1024,ve=null;M={debug:(...t)=>se("DEBUG",...t),info:(...t)=>se("INFO",...t),warn:(...t)=>se("WARN",...t),error:(...t)=>se("ERROR",...t)}});function ot(t){let e=h.readFileSync(t);return it.createHash("sha256").update(e).digest("hex")}async function ct(){try{if(h.readFileSync(nt,"utf-8").trim()===tt&&h.existsSync(L)){let r=h.readFileSync(rt,"utf-8").trim();if(ot(L)!==r)M.warn("binary:hash-mismatch",{message:"Binary hash mismatch \u2014 possible tampering detected. Recompiling from source."}),h.unlinkSync(L);else return L}}catch{}let t=E.join(Pn,"visa-keychain.m");if(h.existsSync(t)||(t=E.resolve(__dirname,"..","..","native","visa-keychain.m")),h.existsSync(t)||(t=E.resolve(__dirname,"..","native","visa-keychain.m")),!h.existsSync(t))throw new Error("visa-keychain.m source not found. Reinstall Visa CLI.");h.mkdirSync(ce,{recursive:!0,mode:448});try{await F("clang",["-framework","Security","-framework","LocalAuthentication","-framework","Foundation","-framework","AppKit","-o",L,t],{timeout:3e4})}catch(n){throw n.code==="ENOENT"?new Error("Xcode Command Line Tools required. Install: xcode-select --install"):n}let e=ot(L);return h.writeFileSync(rt,e,{mode:384}),h.writeFileSync(nt,tt,{mode:384}),L}async function lt(t){let e=await ct(),n;try{n=(await F(e,t,{timeout:6e4})).stdout}catch(s){n=s.stdout||"";let a=n.trim();throw a.startsWith("ERROR:")?new Error(a.slice(6)):new Error(s.stderr?.trim()||s.message||"Unknown error")}let r=n.trim();if(r.startsWith("OK:"))return r.slice(3);if(r==="OK")return;let o=r.startsWith("ERROR:")?r.slice(6):"Unknown error";throw new Error(o)}function U(){return process.env.VISA_MOCK_TOUCHID==="true"?!0:process.platform!=="darwin"?!1:Ee!==null?Ee:(Ee=!0,!0)}async function Tn(t){try{await F("security",["delete-generic-password","-s",ie,"-a",ae],{timeout:5e3})}catch{}await F("security",["add-generic-password","-s",ie,"-a",ae,"-w",t],{timeout:5e3})}async function En(){try{let{stdout:t}=await F("security",["find-generic-password","-s",ie,"-a",ae,"-w"],{timeout:5e3});return t.trim()||null}catch{return null}}async function ut(){let t=await lt(["generate-key"]);if(!t)throw new Error("Key generation returned no output");let e=t.indexOf(":");if(e<0)throw new Error("Unexpected generate-key output format");let n=t.slice(0,e),r=t.slice(e+1);return await Tn(n),r}async function le(t,e){if(process.env.VISA_MOCK_TOUCHID==="true")return Promise.resolve("mock-ecdsa-signature-for-testing");let n=await En();if(!n)throw new Error("Attestation key not found. Run setup to generate a new key.");let r=await ct(),o=["sign",t];return e&&o.push(e),new Promise((s,a)=>{let i=(0,Ce.execFile)(r,o,{timeout:6e4},(l,c)=>{let u=(c||"").trim();if(l){u.startsWith("ERROR:")?a(new Error(u.slice(6))):a(new Error(l.stderr?.trim()||l.message||"Unknown error"));return}u.startsWith("OK:")?s(u.slice(3)):a(new Error(u.startsWith("ERROR:")?u.slice(6):"Unknown error"))});i.stdin.write(n),i.stdin.end()})}async function $e(){try{await F("security",["delete-generic-password","-s",ie,"-a",ae],{timeout:5e3})}catch{}try{await lt(["delete-key"])}catch{}}var Ce,st,it,h,at,E,F,ce,L,Pn,tt,nt,rt,Ee,ie,ae,ke=f(()=>{"use strict";Ce=require("child_process"),st=require("util"),it=p(require("crypto")),h=p(require("fs")),at=p(require("os")),E=p(require("path"));Te();F=(0,st.promisify)(Ce.execFile),ce=E.join(at.homedir(),".visa-mcp","bin"),L=E.join(ce,"Visa CLI"),Pn=E.join(__dirname,"..","native"),tt="5",nt=E.join(ce,"visa-keychain.version"),rt=E.join(ce,"visa-keychain.sha256");Ee=null;ie="visa-cli",ae="attestation-key"});async function ue(t){let{model:e,messages:n,tools:r,maxTokens:o=4096,temperature:s=.7,attestation:a,sessionBudgetId:i}=t;return await kn.shortcut(e,{prompt:"",messages:n,...r?.length?{tools:r}:{},max_tokens:o,temperature:s,...a?{attestation:a}:{},...i?{session_budget_id:i}:{}},12e4)}function St(t,e){let n={"or-claude-sonnet":{inPerM:3,outPerM:15},"or-gpt-4o":{inPerM:5,outPerM:15},"or-gpt-4o-mini":{inPerM:.15,outPerM:.6},"or-gemini-pro":{inPerM:.25,outPerM:1},"or-llama-70b":{inPerM:.59,outPerM:.79},"or-deepseek-chat":{inPerM:.27,outPerM:1.1},"or-deepseek-r1":{inPerM:.55,outPerM:2.19},"or-mistral-large":{inPerM:2,outPerM:6}},r=n[e]||n["or-gpt-4o-mini"],o=t.prompt_tokens/1e6*r.inPerM*100,s=t.completion_tokens/1e6*r.outPerM*100;return Math.ceil(o+s)}var kn,Me=f(()=>{"use strict";oe();K();kn=new $(()=>g.getSessionToken())});function xt(t){let e=[];e.push(`You are an AI coding assistant powered by Visa CLI.
1
+ "use strict";var Zt=Object.create;var fe=Object.defineProperty;var Qt=Object.getOwnPropertyDescriptor;var en=Object.getOwnPropertyNames;var tn=Object.getPrototypeOf,nn=Object.prototype.hasOwnProperty;var f=(t,e)=>()=>(t&&(e=t(t=0)),e);var rn=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),on=(t,e)=>{for(var n in e)fe(t,n,{get:e[n],enumerable:!0})},sn=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of en(e))!nn.call(t,o)&&o!==n&&fe(t,o,{get:()=>e[o],enumerable:!(r=Qt(e,o))||r.enumerable});return t};var p=(t,e,n)=>(n=t!=null?Zt(tn(t)):{},sn(e||!t||!t.__esModule?fe(n,"default",{value:t,enumerable:!0}):n,t));async function je(){try{let{stdout:t}=await R("security",["find-generic-password","-s",A,"-a",Z,"-w"],{timeout:5e3});return t.trim()||null}catch{return null}}async function qe(t){try{try{await R("security",["delete-generic-password","-s",A,"-a",Z],{timeout:5e3})}catch{}return await R("security",["add-generic-password","-s",A,"-a",Z,"-w",t],{timeout:5e3}),!0}catch{return!1}}async function Fe(){try{await R("security",["delete-generic-password","-s",A,"-a",Z],{timeout:5e3})}catch{}}async function an(){try{let{stdout:t}=await R("security",["find-generic-password","-s",A,"-a",Q,"-w"],{timeout:5e3});return t.trim()||null}catch{return null}}async function cn(t){try{try{await R("security",["delete-generic-password","-s",A,"-a",Q],{timeout:5e3})}catch{}await R("security",["add-generic-password","-s",A,"-a",Q,"-w",t],{timeout:5e3})}catch{}}async function ln(){try{await R("security",["delete-generic-password","-s",A,"-a",Q],{timeout:5e3})}catch{}}function un(t){C.mkdirSync(ye,{recursive:!0,mode:448}),C.writeFileSync(X,t,{mode:384})}function dn(){try{return C.readFileSync(X,"utf-8").trim()||null}catch{return null}}var De,Ve,C,He,he,R,ye,X,A,Z,Q,g,K=f(()=>{"use strict";De=require("child_process"),Ve=require("util"),C=p(require("fs")),He=p(require("os")),he=p(require("path")),R=(0,Ve.promisify)(De.execFile),ye=he.join(He.homedir(),".visa-mcp"),X=he.join(ye,"session-token"),A="visa-cli",Z="session-token",Q="rc-access";g=class{static async getSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN==="true")return Promise.resolve("mock-session-token-for-testing");let e=await je();if(e)return e;let n=dn();return n?(await qe(n),n):null}static async saveSessionToken(e){if(process.env.VISA_MOCK_KEYCHAIN==="true")return;if(await qe(e)){if(await je()===e){try{C.unlinkSync(X)}catch{}return}await Fe()}if(un(e),await this.getSessionToken()!==e)throw new Error("Failed to persist session token. "+(process.platform==="darwin"?'Check Keychain Access permissions for "visa-cli".':`Ensure ${ye} is writable.`))}static async getRcAccessToken(){return process.env.VISA_MOCK_KEYCHAIN==="true"?"mock-rc-token-for-testing":an()}static async saveRcAccessToken(e){process.env.VISA_MOCK_KEYCHAIN!=="true"&&await cn(e)}static async deleteSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN!=="true"){await Fe();try{C.unlinkSync(X)}catch{}}}static async clearAll(){await this.deleteSessionToken(),await ln()}}});var _e=rn((Gn,mn)=>{mn.exports={name:"@visa/cli",version:"1.1.1",description:"AI-powered payments for Claude Code",bin:{"visa-cli":"./bin/visa-cli.js"},scripts:{build:"tsc --noEmit && node esbuild.config.js",dev:"tsc --watch",start:"node dist/mcp-server/index.js",test:"jest --config jest.config.js","test:unit":"jest --config jest.config.js","test:unit:watch":"jest --config jest.config.js --watch","test:unit:coverage":"jest --config jest.config.js --coverage","test:smoke":"VISA_AUTH_URL=https://auth.visacli.sh jest --config jest.smoke.config.js","test:integration":"jest --config jest.integration.config.js","test:e2e":"jest --config jest.e2e.config.js","test:catalog-e2e":"jest --config jest.catalog-e2e.config.js","test:all":"npm run test:unit && npm run test:integration && npm run test:e2e",prepublishOnly:"npm run build && npm test",lint:"eslint src/**/*.ts",format:'prettier --write "src/**/*.ts"',"format:check":'prettier --check "src/**/*.ts"'},keywords:["visa","checkout","mcp","ai-agent","payments","click-to-pay","usdc","stablecoin"],author:"Visa Crypto Labs",license:"SEE LICENSE IN LICENSE",dependencies:{"@modelcontextprotocol/sdk":"^1.0.0",commander:"^12.1.0",zod:"^3.23.0"},devDependencies:{"@visa-cli/tools":"workspace:*","@changesets/changelog-git":"^0.2.1","@changesets/cli":"^2.30.0","@types/jest":"^30.0.0","@types/node":"^25.6.0","@typescript-eslint/eslint-plugin":"^8.56.1","@typescript-eslint/parser":"^8.56.1","@types/express":"^5.0.0",esbuild:"^0.27.4",express:"^4.21.0",eslint:"^10.0.2","eslint-config-prettier":"^10.1.8",jest:"^29.7.0",prettier:"^3.8.1","ts-jest":"^29.2.0",typescript:"^5.7.0"},engines:{node:">=18.0.0"},files:["bin/visa-cli.js","dist/","native/visa-keychain.m","README.md","LICENSE"]}});async function ze(t,e){let n=e?.timeoutMs??3e4,r=new AbortController,o=setTimeout(()=>r.abort(),n);try{let{timeoutMs:s,...a}=e??{};return await fetch(t,{...a,signal:r.signal})}finally{clearTimeout(o)}}var Ye=f(()=>{"use strict"});function Xe(t,e){let n=Je(t),r=Je(e);if(!n||!r)return!1;for(let o=0;o<3;o++)if(n.main[o]!==r.main[o])return n.main[o]>r.main[o];return n.pre&&!r.pre?!1:!n.pre&&r.pre?!0:!n.pre&&!r.pre?!1:Sn(n.pre,r.pre)>0}function Je(t){if(typeof t!="string")return null;let n=t.trim().replace(/^v/,"").match(wn);return n?{main:[Number(n[1]),Number(n[2]),Number(n[3])],pre:n[4]??null}:null}function Sn(t,e){let n=t.split("."),r=e.split("."),o=Math.max(n.length,r.length);for(let s=0;s<o;s++){if(s>=n.length)return-1;if(s>=r.length)return 1;let a=n[s],i=r[s],l=/^\d+$/.test(a),c=/^\d+$/.test(i);if(l&&c){let u=Number(a)-Number(i);if(u!==0)return u}else{if(l)return-1;if(c)return 1;if(a<i)return-1;if(a>i)return 1}}return 0}var wn,Ze=f(()=>{"use strict";wn=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/});function re(){return!!(Qe(process.env.VISA_CLI_NO_UPDATE_CHECK)||Qe(process.env.CI)||process.env.NODE_ENV==="test")}function Qe(t){if(t===void 0)return!1;let e=t.trim().toLowerCase();return!(e===""||e==="0"||e==="false"||e==="no"||e==="off")}var Se=f(()=>{"use strict"});var be,$,oe=f(()=>{"use strict";Ye();Ze();Se();be="1.1.1",$=class{constructor(e){this.getSessionToken=e;this.baseUrl=process.env.VISA_AUTH_URL||"https://auth.visacli.sh"}getSessionToken;baseUrl;lastSignals={};parseServerSignals(e){if(this.lastSignals={},!re()){let r=e.headers.get("X-Latest-Version"),o=e.headers.get("X-Update-Message");r&&Xe(r,be)&&(this.lastSignals.updateAvailable={version:r,message:o||`Update available: v${r}. Run: npm install -g @visa/cli && visa-cli setup`})}let n=e.headers.get("X-Feedback-Prompt");if(n)try{this.lastSignals.feedbackPrompt=JSON.parse(n)}catch{}}getClientVersion(){return be}async request(e,n,r,o,s){let a=await this.getSessionToken();if(!a)throw new Error("Not logged in. Sign up at https://visacli.sh or run: visa-cli setup");let i={Authorization:`Bearer ${a}`};s&&(e==="GET"?i["X-User-Context"]=s.replace(/[\r\n\0]/g," ").slice(0,1e3):r={...r||{},user_context:s}),r&&(i["Content-Type"]="application/json");let l;try{l=await ze(`${this.baseUrl}${n}`,{method:e,headers:{...i,"X-Visa-CLI-Version":be},body:r?JSON.stringify(r):void 0,timeoutMs:o})}catch(u){throw u.name==="AbortError"||u.message?.includes("aborted")?new Error("The request timed out. The server may be under heavy load. Please try again."):new Error("Cannot reach the Visa CLI server. Check your internet connection and try again.")}if(this.parseServerSignals(l),l.status===401)throw new Error("Your session has expired. Run: visa-cli setup");if(l.status===429){let u=l.headers.get("Retry-After")||"3";throw new Error(`Rate limited \u2014 wait ${u}s. Tip: use the batch tool to combine multiple requests into one.`)}if(l.status===503)throw new Error("Visa CLI is temporarily unavailable. Check https://visacli.sh for status.");let c;try{c=await l.json()}catch{throw l.status===500?new Error(`Server error on ${n}. Try again or check https://visacli.sh for status.`):new Error(`Unexpected response from ${n}. Try again.`)}if(!l.ok)throw l.status===500?new Error(`Server error on ${n}. Try again or check https://visacli.sh for status.`):new Error(c?.error||`Request failed (${l.status}). Try again.`);return c}async pay(e,n){return this.request("POST","/v1/pay",e,void 0,n)}async shortcut(e,n,r,o){return this.request("POST",`/v1/shortcuts/${encodeURIComponent(e)}`,n,r,o)}async batch(e,n,r){return this.request("POST","/v1/batch",e,n,r)}async catalogSearch(e,n){let r=new URLSearchParams;e&&r.set("q",e),n&&r.set("category",n);let o=r.toString();return this.request("GET",`/v1/catalog${o?`?${o}`:""}`)}async catalogTool(e){try{return await this.request("GET",`/v1/catalog/${encodeURIComponent(e)}`)}catch{return null}}async paymentPreview(e,n){return this.request("POST","/v1/payment-preview",e,void 0,n)}async getStatus(e){return this.request("GET","/v1/status",void 0,void 0,e)}async getTransactions(e){return this.request("GET","/v1/transactions",void 0,void 0,e)}async updateSpendingControls(e,n){return this.request("POST","/v1/spending-controls",e,void 0,n)}async removeCard(e,n,r){return this.request("DELETE",`/v1/cards/${encodeURIComponent(String(e))}`,n,void 0,r)}async setDefaultCard(e,n,r){return this.request("POST",`/v1/cards/${encodeURIComponent(String(e))}/default`,n,void 0,r)}async getAttestationChallenge(){return this.request("GET","/v1/attestation-challenge")}async registerAttestationKey(e){return this.request("POST","/v1/attestation-key",{publicKey:e})}async logout(e,n){return this.request("POST","/v1/logout",e,void 0,n)}async feedback(e,n,r){return this.request("POST","/v1/feedback",{message:e,...n&&{transaction_id:n}},void 0,r)}async feedSubmit(e){return this.request("POST","/v1/feed",e)}async feedList(e){let n=new URLSearchParams;e?.tab&&n.set("tab",e.tab),e?.limit&&n.set("limit",String(e.limit)),e?.offset&&n.set("offset",String(e.offset));let r=n.toString();return this.request("GET",`/v1/feed${r?"?"+r:""}`)}async feedVote(e,n){return this.request("POST",`/v1/feed/${encodeURIComponent(e)}/vote`,{direction:n})}async feedApprove(e){return this.request("POST",`/v1/feed/${encodeURIComponent(e)}/approve`)}async feedDelete(e){return this.request("DELETE",`/v1/feed/${encodeURIComponent(e)}`)}async feedPending(){return this.request("GET","/v1/feed/pending")}async submitFeedback(e,n,r){return this.request("POST","/v1/feedback",{message:e,...n&&{transaction_id:n}},void 0,r)}async getFeedback(e,n){let r=new URLSearchParams;e&&r.set("limit",String(e));let o=r.toString();return this.request("GET",`/v1/feedback${o?"?"+o:""}`,void 0,void 0,n)}async submitRatedFeedback(e){return this.request("POST","/v1/feedback",e)}}});function vn(){w.existsSync(xe)||w.mkdirSync(xe,{recursive:!0,mode:448})}function xn(){if(!ve){if(vn(),w.existsSync(B)&&w.statSync(B).size>bn){let e=B+".1";w.existsSync(e)&&w.unlinkSync(e),w.renameSync(B,e)}ve=w.createWriteStream(B,{flags:"a"})}return ve}function se(t,...e){let n=new Date().toISOString(),r=e.map(s=>typeof s=="string"?s:JSON.stringify(s,null,2)).join(" "),o=`[${n}] [${t}] ${r}
2
+ `;process.stderr.write(o),xn().write(o)}var w,Pe,et,xe,B,bn,ve,M,Te=f(()=>{"use strict";w=p(require("fs")),Pe=p(require("path")),et=p(require("os")),xe=Pe.join(et.homedir(),".visa-mcp"),B=Pe.join(xe,"mcp-server.log"),bn=5*1024*1024,ve=null;M={debug:(...t)=>se("DEBUG",...t),info:(...t)=>se("INFO",...t),warn:(...t)=>se("WARN",...t),error:(...t)=>se("ERROR",...t)}});function ot(t){let e=h.readFileSync(t);return it.createHash("sha256").update(e).digest("hex")}async function ct(){try{if(h.readFileSync(nt,"utf-8").trim()===tt&&h.existsSync(L)){let r=h.readFileSync(rt,"utf-8").trim();if(ot(L)!==r)M.warn("binary:hash-mismatch",{message:"Binary hash mismatch \u2014 possible tampering detected. Recompiling from source."}),h.unlinkSync(L);else return L}}catch{}let t=E.join(Pn,"visa-keychain.m");if(h.existsSync(t)||(t=E.resolve(__dirname,"..","..","native","visa-keychain.m")),h.existsSync(t)||(t=E.resolve(__dirname,"..","native","visa-keychain.m")),!h.existsSync(t))throw new Error("visa-keychain.m source not found. Reinstall Visa CLI.");h.mkdirSync(ce,{recursive:!0,mode:448});try{await F("clang",["-framework","Security","-framework","LocalAuthentication","-framework","Foundation","-framework","AppKit","-o",L,t],{timeout:3e4})}catch(n){throw n.code==="ENOENT"?new Error("Xcode Command Line Tools required. Install: xcode-select --install"):n}let e=ot(L);return h.writeFileSync(rt,e,{mode:384}),h.writeFileSync(nt,tt,{mode:384}),L}async function lt(t){let e=await ct(),n;try{n=(await F(e,t,{timeout:6e4})).stdout}catch(s){n=s.stdout||"";let a=n.trim();throw a.startsWith("ERROR:")?new Error(a.slice(6)):new Error(s.stderr?.trim()||s.message||"Unknown error")}let r=n.trim();if(r.startsWith("OK:"))return r.slice(3);if(r==="OK")return;let o=r.startsWith("ERROR:")?r.slice(6):"Unknown error";throw new Error(o)}function U(){return process.env.VISA_MOCK_TOUCHID==="true"?!0:process.platform!=="darwin"?!1:Ee!==null?Ee:(Ee=!0,!0)}async function Tn(t){try{await F("security",["delete-generic-password","-s",ie,"-a",ae],{timeout:5e3})}catch{}await F("security",["add-generic-password","-s",ie,"-a",ae,"-w",t],{timeout:5e3})}async function En(){try{let{stdout:t}=await F("security",["find-generic-password","-s",ie,"-a",ae,"-w"],{timeout:5e3});return t.trim()||null}catch{return null}}async function ut(){let t=await lt(["generate-key"]);if(!t)throw new Error("Key generation returned no output");let e=t.indexOf(":");if(e<0)throw new Error("Unexpected generate-key output format");let n=t.slice(0,e),r=t.slice(e+1);return await Tn(n),r}async function le(t,e){if(process.env.VISA_MOCK_TOUCHID==="true")return Promise.resolve("mock-ecdsa-signature-for-testing");let n=await En();if(!n)throw new Error("Attestation key not found. Run setup to generate a new key.");let r=await ct(),o=["sign",t];return e&&o.push(e),new Promise((s,a)=>{let i=(0,Ce.execFile)(r,o,{timeout:6e4},(l,c)=>{let u=(c||"").trim();if(l){u.startsWith("ERROR:")?a(new Error(u.slice(6))):a(new Error(l.stderr?.trim()||l.message||"Unknown error"));return}u.startsWith("OK:")?s(u.slice(3)):a(new Error(u.startsWith("ERROR:")?u.slice(6):"Unknown error"))});i.stdin.write(n),i.stdin.end()})}async function $e(){try{await F("security",["delete-generic-password","-s",ie,"-a",ae],{timeout:5e3})}catch{}try{await lt(["delete-key"])}catch{}}var Ce,st,it,h,at,E,F,ce,L,Pn,tt,nt,rt,Ee,ie,ae,ke=f(()=>{"use strict";Ce=require("child_process"),st=require("util"),it=p(require("crypto")),h=p(require("fs")),at=p(require("os")),E=p(require("path"));Te();F=(0,st.promisify)(Ce.execFile),ce=E.join(at.homedir(),".visa-mcp","bin"),L=E.join(ce,"Visa CLI"),Pn=E.join(__dirname,"..","native"),tt="5",nt=E.join(ce,"visa-keychain.version"),rt=E.join(ce,"visa-keychain.sha256");Ee=null;ie="visa-cli",ae="attestation-key"});async function ue(t){let{model:e,messages:n,tools:r,maxTokens:o=4096,temperature:s=.7,attestation:a,sessionBudgetId:i}=t;return await kn.shortcut(e,{prompt:"",messages:n,...r?.length?{tools:r}:{},max_tokens:o,temperature:s,...a?{attestation:a}:{},...i?{session_budget_id:i}:{}},12e4)}function bt(t,e){let n={"or-claude-sonnet":{inPerM:3,outPerM:15},"or-gpt-4o":{inPerM:5,outPerM:15},"or-gpt-4o-mini":{inPerM:.15,outPerM:.6},"or-gemini-pro":{inPerM:.25,outPerM:1},"or-llama-70b":{inPerM:.59,outPerM:.79},"or-deepseek-chat":{inPerM:.27,outPerM:1.1},"or-deepseek-r1":{inPerM:.55,outPerM:2.19},"or-mistral-large":{inPerM:2,outPerM:6}},r=n[e]||n["or-gpt-4o-mini"],o=t.prompt_tokens/1e6*r.inPerM*100,s=t.completion_tokens/1e6*r.outPerM*100;return Math.ceil(o+s)}var kn,Me=f(()=>{"use strict";oe();K();kn=new $(()=>g.getSessionToken())});function xt(t){let e=[];e.push(`You are an AI coding assistant powered by Visa CLI.
3
3
  You can read, write, and edit files. You can run shell commands.
4
4
  You can generate images, music, video, and query data \u2014 each costs money.
5
5
  The user pays per-use via their Visa card. Show costs before expensive operations.
@@ -19,7 +19,7 @@ ${l}`},{role:"assistant",content:"Understood. I have context from our previous c
19
19
  `)||"No matches",isError:!1}}catch{return{content:"No matches",isError:!1}}},grep(t,e){let n=t.path?k.resolve(e,t.path):e,r=t.pattern,o=t.include,s=["-rn",...o?["--include",o]:[],r,n];try{return{content:(0,Oe.execFileSync)("grep",s,{encoding:"utf-8",timeout:1e4}).split(`
20
20
  `).filter(Boolean).slice(0,50).join(`
21
21
  `)||"No matches",isError:!1}}catch{return{content:"No matches",isError:!1}}},list_dir(t,e){let n=k.resolve(e,t.path||".");return{content:v.readdirSync(n,{withFileTypes:!0}).map(s=>`${s.isDirectory()?"d":"f"} ${s.name}`).join(`
22
- `),isError:!1}}}});var kt,In,It,Rt,At=f(()=>{"use strict";kt=require("child_process"),In=[/rm\s+-rf\s+\//,/mkfs/,/dd\s+if=/,/:()\{\s*:\|:&\s*\};:/,/>\s*\/dev\/sd/],It=[{type:"function",function:{name:"bash",description:"Run a bash command. Returns stdout + stderr.",parameters:{type:"object",properties:{command:{type:"string",description:"Bash command to execute"}},required:["command"]}}}],Rt={bash(t,e){let n=t.command;for(let r of In)if(r.test(n))return{content:"Blocked: dangerous command pattern",isError:!0};try{return{content:(0,kt.execSync)(n,{cwd:e,encoding:"utf-8",timeout:3e4,maxBuffer:1048576,stdio:["pipe","pipe","pipe"]}).slice(0,1e4),isError:!1}}catch(r){return{content:((r.stdout||"")+(r.stderr||"")).slice(0,1e4)||r.message,isError:!0}}}}});async function Nt(t,e,n){let r=Rn[t];if(!r)return{content:`Unknown tool: ${t}`,isError:!0};try{return r(e,n)}catch(o){return{content:o.message||String(o),isError:!0}}}var Mt,Rn,Ot=f(()=>{"use strict";$t();At();Mt=[...Et,...It],Rn={...Ct,...Rt}});async function Lt(t,e,n,r,o,s){let a=process.cwd(),i=[{role:"system",content:xt(a)}],l=Nn[t.model]||128e3;for(;t.turns<An;){let c=await n();if(c===null)break;if(!c.trim())continue;if(c.startsWith("/")){if(c.startsWith("/model ")){t.model=c.slice(7).trim(),r(`Switched to ${t.model}`);continue}if(c==="/budget"||c==="/cost"){r(`Spent: $${(t.spentCents/100).toFixed(2)} / $${(t.budgetCents/100).toFixed(2)}`);continue}if(c==="/quit"||c==="/exit")break}i.push({role:"user",content:c});let u=0,_=0;for(;;){if(t.turns++,t.spentCents>=t.budgetCents){r("Session budget exhausted. Run /budget to check or start a new session.");return}let T;try{T=await ue({model:t.model,messages:i,tools:Mt,maxTokens:4096,temperature:.7,...e?{attestation:e}:{}})}catch(S){r(`Error: ${S.message||S}`),i.pop();break}let Y=St(T.usage,t.model);t.spentCents+=Y,t.inputTokens+=T.usage.prompt_tokens,t.outputTokens+=T.usage.completion_tokens,u+=Y;let H=T.choices[0];if(!H)break;let I=H.message;if(I.content&&r(I.content),i.push(I),!I.tool_calls?.length||H.finish_reason==="stop")break;for(let S of I.tool_calls){let Ue=S.function.name,J;try{J=JSON.parse(S.function.arguments)}catch{J={}}o(Ue,J);let{content:Xt}=await Nt(Ue,J,a);i.push({role:"tool",content:Xt.slice(0,1e4),tool_call_id:S.id})}}if(s(u,_),On(i)>l*Mn){let T=await Pt(i,t.model);i.length=0,i.push(...T)}}}function On(t){let e=0;for(let n of t)if(typeof n.content=="string"&&(e+=n.content.length),n.tool_calls)for(let r of n.tool_calls)e+=r.function.arguments.length+r.function.name.length;return Math.ceil(e/3.5)}var An,Mn,Nn,Ut=f(()=>{"use strict";Me();Tt();Ot();An=50,Mn=.7,Nn={"or-claude-sonnet":2e5,"or-gpt-4o":128e3,"or-gpt-4o-mini":128e3,"or-gemini-pro":1e6,"or-deepseek-r1":64e3}});var Ln,Er,jt=f(()=>{"use strict";Le();Ln={generate_image:{intro:"Generate an AI image.",tiers:{balanced:{toolId:"fal-flux-pro",priceCents:4,notes:"FLUX Pro v1.1, 1K, ~10s (DEFAULT \u2014 good quality/speed tradeoff)"},fast:{toolId:"fal-flux-schnell",priceCents:1,notes:"FLUX Schnell, 1K, ~3s (drafts, iteration, cheapest)"},pro:{toolId:"fal-flux-pro-ultra",priceCents:6,notes:"FLUX Pro Ultra, 2K, ~30s (hero images, detail)"},text_heavy:{toolId:"fal-ideogram-v2",priceCents:8,notes:"Ideogram V2 \u2014 best when the image contains rendered text/logos"},vector:{toolId:"fal-recraft-v3",priceCents:5,notes:"Recraft V3 \u2014 vector/flat/illustration styles"}},guidance:"If the user didn't specify a tier, pick 'balanced' unless the prompt clearly signals otherwise (text \u2192 text_heavy, logo/icon \u2192 vector, quick test \u2192 fast, hero/print \u2192 pro).",inputProperties:{prompt:{type:"string",description:"Text description of the image to generate."},aspect_ratio:{type:"string",description:'Aspect ratio, e.g. "16:9", "1:1", "9:16".',default:"16:9"}},required:["prompt"]},generate_video:{intro:"Generate an AI video from a text prompt.",tiers:{balanced:{toolId:"fal-minimax-video",priceCents:15,notes:"MiniMax \u2014 good quality/price balance (DEFAULT)"},fast:{toolId:"fal-wan-video",priceCents:10,notes:"Wan \u2014 cheapest, shorter clips"},pro:{toolId:"fal-kling-video",priceCents:20,notes:"Kling \u2014 highest quality, cinematic"}},guidance:"Show the tier menu with prices unless the user specified one. Videos take 60-180s to generate.",inputProperties:{prompt:{type:"string",description:"Text description of the video scene."},aspect_ratio:{type:"string",description:'Aspect ratio, e.g. "16:9" or "9:16".',default:"16:9"}},required:["prompt"]},generate_music:{intro:"Generate an original music track from a prompt.",tiers:{suno:{toolId:"suno-music",priceCents:10,notes:"Suno v4 \u2014 songs with vocals, lyrics, full arrangement"}},guidance:"Takes ~60-90s. Returns an audio URL the user can play.",inputProperties:{prompt:{type:"string",description:"Musical style / mood / lyrics hint."},instrumental:{type:"boolean",description:"True for instrumental (no vocals), false for vocal track.",default:!1}},required:["prompt"]},generate_audio:{intro:"Generate speech or sound effects.",tiers:{tts:{toolId:"fal-metavoice",priceCents:3,notes:"MetaVoice \u2014 high-quality TTS from text"},sfx:{toolId:"fal-stable-audio",priceCents:4,notes:"Stable Audio \u2014 sound effects and ambient from a prompt"}},guidance:'Pick "tts" for spoken words, "sfx" for music-beds/effects/ambient.',inputProperties:{prompt:{type:"string",description:"Text to speak (tts) or description of sound (sfx)."}},required:["prompt"]},generate_3d:{intro:"Generate a 3D model from a text description.",tiers:{trellis:{toolId:"fal-trellis-3d",priceCents:8,notes:"Trellis \u2014 fast text-to-3D, returns a GLB mesh URL"}},guidance:"Takes ~30-60s. Returns a downloadable 3D mesh URL.",inputProperties:{prompt:{type:"string",description:"Description of the 3D object."}},required:["prompt"]},upscale_image:{intro:"Upscale an image to higher resolution.",tiers:{aura:{toolId:"fal-aura-sr",priceCents:3,notes:"Aura SR \u2014 default; preserves detail without hallucination"}},guidance:"Pass the existing image URL. Returns an upscaled version.",inputProperties:{image_url:{type:"string",description:"URL of the image to upscale."}},required:["image_url"]},transcribe_audio:{intro:"Transcribe speech in an audio/video URL to text.",tiers:{whisper:{toolId:"fal-whisper",priceCents:2,notes:"OpenAI Whisper \u2014 fast, multilingual"}},guidance:"Pass the URL. Returns the transcript text.",inputProperties:{audio_url:{type:"string",description:"URL of the audio or video file to transcribe."}},required:["audio_url"]},run_llm:{intro:"Run a text prompt through an LLM (OpenRouter). Token-metered \u2014 prices below are per 1M input/output tokens. Typical 500-in/500-out prompts cost 1\u20139\xA2 depending on model.",tiers:{fast:{toolId:"or-gpt-4o-mini",priceCents:1,notes:"GPT-4o Mini \u2014 $0.15/M in \xB7 $0.60/M out. Fastest, cheapest, good general-purpose (DEFAULT)"},reasoning:{toolId:"or-claude-sonnet",priceCents:9,notes:"Claude 3.5 Sonnet \u2014 $3.00/M in \xB7 $15.00/M out. Strong reasoning, long-context. ~20x pricier than `fast`."},deep_reasoning:{toolId:"or-deepseek-r1",priceCents:2,notes:"DeepSeek R1 \u2014 $0.55/M in \xB7 $2.19/M out. Deep chain-of-thought reasoning, mid-range pricing."},search:{toolId:"or-perplexity-sonar",priceCents:1,notes:"Perplexity Sonar \u2014 $1.00/M in \xB7 $1.00/M out. Search-augmented, web-grounded with citations."},open_source:{toolId:"or-llama-70b",priceCents:1,notes:"Llama 3.3 70B \u2014 $0.30/M in \xB7 $0.40/M out. Open-source large model."},coding:{toolId:"or-deepseek-chat",priceCents:1,notes:"DeepSeek Chat V3 \u2014 $0.30/M in \xB7 $0.88/M out. Strong at code generation."}},guidance:"Pick based on the user's need: fast (most questions, cheapest), reasoning (complex analysis \u2014 WARN user it's ~$0.09/call), search (questions about current events), coding (code generation), deep_reasoning (hard math/logic problems).",inputProperties:{prompt:{type:"string",description:"The user query."},system_prompt:{type:"string",description:"Optional system prompt to set model behavior."},max_tokens:{type:"number",description:"Maximum output tokens.",default:1024,minimum:1,maximum:8192},temperature:{type:"number",description:"Sampling temperature \u2014 0 is deterministic, higher is more creative.",default:.7,minimum:0,maximum:2}},required:["prompt"]}},Er=Object.keys(Ln)});async function qt(t,e,n,r){if(!U()){M.warn("attestation:unavailable",{context:t});return}M.info("attestation:attempt",{context:t,amount:e,merchant:n});try{let{nonce:o}=await Un.getAttestationChallenge(),s=Buffer.from(JSON.stringify({nonce:o,amount:e,merchant:n,context:t})).toString("base64");M.info("touchid:prompt",{context:t,amount:e,merchant:n});let a=await le(s,r);return M.info("attestation:success",{context:t,amount:e,merchant:n}),{signature:a,nonce:o,amount:e,merchant:n}}catch(o){throw M.error("attestation:failure",{context:t,amount:e,merchant:n,error:o.message}),o}}var Or,Un,jn,Lr,Ur,jr,Le=f(()=>{"use strict";oe();ke();K();Te();jt();Or=process.env.VISA_AUTH_URL||"https://auth.visacli.sh",Un=new $(()=>g.getSessionToken()),jn=["generate_image","generate_video","generate_music","generate_audio","generate_3d","upscale_image","transcribe_audio","run_llm"],Lr=["","","You're ready to go! Try:","","Core:",'\u2022 "Show my account status" \u2192 get_status','\u2022 "List my enrolled cards" \u2192 get_cards','\u2022 "Show my recent transactions" \u2192 transaction_history','\u2022 "Set my daily limit to $50" \u2192 update_spending_controls','\u2022 "Pay https://example.com/checkout" \u2192 pay','\u2022 "Generate 3 variations in parallel" \u2192 batch',"","Fast shortcuts:",'\u2022 "Generate an image of a sunset over Tokyo" \u2192 generate_image_card (~$0.06)','\u2022 "Make a fast thumbnail: minimalist cat logo" \u2192 generate_image_fast_card (~$0.04)','\u2022 "Make a 4-second video of a penguin juggling" \u2192 generate_video_tempo_card (~$0.30)','\u2022 "Make a song about coding late at night" \u2192 generate_music_tempo_card (~$0.10)','\u2022 "Check the status of my music job" \u2192 check_music_status_tempo_card','\u2022 "What is ETH on Base trading at?" \u2192 query_onchain_prices_card (~$0.02)','\u2022 "Explore stablecoin inflows on Base" \u2192 allium_explorer_card','\u2022 "Open the latest Allium result set" \u2192 allium_explorer_results_card','\u2022 "Show pxlwall campaign insights" \u2192 pxlwall_card',"","Category tools:",...jn.map(t=>`\u2022 "${t.replace(/_/g," ")}" \u2192 ${t}`),"","Tool catalog:",'\u2022 "Find an image upscaler" \u2192 discover_tools','\u2022 "Run fal-aura-sr on this URL" \u2192 execute_tool'].join(`
22
+ `),isError:!1}}}});var kt,In,It,Rt,At=f(()=>{"use strict";kt=require("child_process"),In=[/rm\s+-rf\s+\//,/mkfs/,/dd\s+if=/,/:()\{\s*:\|:&\s*\};:/,/>\s*\/dev\/sd/],It=[{type:"function",function:{name:"bash",description:"Run a bash command. Returns stdout + stderr.",parameters:{type:"object",properties:{command:{type:"string",description:"Bash command to execute"}},required:["command"]}}}],Rt={bash(t,e){let n=t.command;for(let r of In)if(r.test(n))return{content:"Blocked: dangerous command pattern",isError:!0};try{return{content:(0,kt.execSync)(n,{cwd:e,encoding:"utf-8",timeout:3e4,maxBuffer:1048576,stdio:["pipe","pipe","pipe"]}).slice(0,1e4),isError:!1}}catch(r){return{content:((r.stdout||"")+(r.stderr||"")).slice(0,1e4)||r.message,isError:!0}}}}});async function Nt(t,e,n){let r=Rn[t];if(!r)return{content:`Unknown tool: ${t}`,isError:!0};try{return r(e,n)}catch(o){return{content:o.message||String(o),isError:!0}}}var Mt,Rn,Ot=f(()=>{"use strict";$t();At();Mt=[...Et,...It],Rn={...Ct,...Rt}});async function Lt(t,e,n,r,o,s){let a=process.cwd(),i=[{role:"system",content:xt(a)}],l=Nn[t.model]||128e3;for(;t.turns<An;){let c=await n();if(c===null)break;if(!c.trim())continue;if(c.startsWith("/")){if(c.startsWith("/model ")){t.model=c.slice(7).trim(),r(`Switched to ${t.model}`);continue}if(c==="/budget"||c==="/cost"){r(`Spent: $${(t.spentCents/100).toFixed(2)} / $${(t.budgetCents/100).toFixed(2)}`);continue}if(c==="/quit"||c==="/exit")break}i.push({role:"user",content:c});let u=0,_=0;for(;;){if(t.turns++,t.spentCents>=t.budgetCents){r("Session budget exhausted. Run /budget to check or start a new session.");return}let T;try{T=await ue({model:t.model,messages:i,tools:Mt,maxTokens:4096,temperature:.7,...e?{attestation:e}:{}})}catch(b){r(`Error: ${b.message||b}`),i.pop();break}let Y=bt(T.usage,t.model);t.spentCents+=Y,t.inputTokens+=T.usage.prompt_tokens,t.outputTokens+=T.usage.completion_tokens,u+=Y;let H=T.choices[0];if(!H)break;let I=H.message;if(I.content&&r(I.content),i.push(I),!I.tool_calls?.length||H.finish_reason==="stop")break;for(let b of I.tool_calls){let Ue=b.function.name,J;try{J=JSON.parse(b.function.arguments)}catch{J={}}o(Ue,J);let{content:Xt}=await Nt(Ue,J,a);i.push({role:"tool",content:Xt.slice(0,1e4),tool_call_id:b.id})}}if(s(u,_),On(i)>l*Mn){let T=await Pt(i,t.model);i.length=0,i.push(...T)}}}function On(t){let e=0;for(let n of t)if(typeof n.content=="string"&&(e+=n.content.length),n.tool_calls)for(let r of n.tool_calls)e+=r.function.arguments.length+r.function.name.length;return Math.ceil(e/3.5)}var An,Mn,Nn,Ut=f(()=>{"use strict";Me();Tt();Ot();An=50,Mn=.7,Nn={"or-claude-sonnet":2e5,"or-gpt-4o":128e3,"or-gpt-4o-mini":128e3,"or-gemini-pro":1e6,"or-deepseek-r1":64e3}});var Ln,Er,jt=f(()=>{"use strict";Le();Ln={generate_image:{intro:"Generate an AI image.",tiers:{balanced:{toolId:"fal-flux-pro",priceCents:4,notes:"FLUX Pro v1.1, 1K, ~10s (DEFAULT \u2014 good quality/speed tradeoff)"},fast:{toolId:"fal-flux-schnell",priceCents:1,notes:"FLUX Schnell, 1K, ~3s (drafts, iteration, cheapest)"},pro:{toolId:"fal-flux-pro-ultra",priceCents:6,notes:"FLUX Pro Ultra, 2K, ~30s (hero images, detail)"},text_heavy:{toolId:"fal-ideogram-v2",priceCents:8,notes:"Ideogram V2 \u2014 best when the image contains rendered text/logos"},vector:{toolId:"fal-recraft-v3",priceCents:5,notes:"Recraft V3 \u2014 vector/flat/illustration styles"}},guidance:"If the user didn't specify a tier, pick 'balanced' unless the prompt clearly signals otherwise (text \u2192 text_heavy, logo/icon \u2192 vector, quick test \u2192 fast, hero/print \u2192 pro).",inputProperties:{prompt:{type:"string",description:"Text description of the image to generate."},aspect_ratio:{type:"string",description:'Aspect ratio, e.g. "16:9", "1:1", "9:16".',default:"16:9"}},required:["prompt"]},generate_video:{intro:"Generate an AI video from a text prompt.",tiers:{balanced:{toolId:"fal-minimax-video",priceCents:15,notes:"MiniMax \u2014 good quality/price balance (DEFAULT)"},fast:{toolId:"fal-wan-video",priceCents:10,notes:"Wan \u2014 cheapest, shorter clips"},pro:{toolId:"fal-kling-video",priceCents:20,notes:"Kling \u2014 highest quality, cinematic"}},guidance:"Show the tier menu with prices unless the user specified one. Videos take 60-180s to generate.",inputProperties:{prompt:{type:"string",description:"Text description of the video scene."},aspect_ratio:{type:"string",description:'Aspect ratio, e.g. "16:9" or "9:16".',default:"16:9"}},required:["prompt"]},generate_music:{intro:"Generate an original music track from a prompt.",tiers:{suno:{toolId:"suno-music",priceCents:10,notes:"Suno v4 \u2014 songs with vocals, lyrics, full arrangement"}},guidance:"Takes ~60-90s. Returns an audio URL the user can play.",inputProperties:{prompt:{type:"string",description:"Musical style / mood / lyrics hint."},instrumental:{type:"boolean",description:"True for instrumental (no vocals), false for vocal track.",default:!1}},required:["prompt"]},generate_audio:{intro:"Generate speech or sound effects.",tiers:{tts:{toolId:"fal-metavoice",priceCents:3,notes:"MetaVoice \u2014 high-quality TTS from text"},sfx:{toolId:"fal-stable-audio",priceCents:4,notes:"Stable Audio \u2014 sound effects and ambient from a prompt"}},guidance:'Pick "tts" for spoken words, "sfx" for music-beds/effects/ambient.',inputProperties:{prompt:{type:"string",description:"Text to speak (tts) or description of sound (sfx)."}},required:["prompt"]},generate_3d:{intro:"Generate a 3D model from a text description.",tiers:{trellis:{toolId:"fal-trellis-3d",priceCents:8,notes:"Trellis \u2014 fast text-to-3D, returns a GLB mesh URL"}},guidance:"Takes ~30-60s. Returns a downloadable 3D mesh URL.",inputProperties:{prompt:{type:"string",description:"Description of the 3D object."}},required:["prompt"]},upscale_image:{intro:"Upscale an image to higher resolution.",tiers:{aura:{toolId:"fal-aura-sr",priceCents:3,notes:"Aura SR \u2014 default; preserves detail without hallucination"}},guidance:"Pass the existing image URL. Returns an upscaled version.",inputProperties:{image_url:{type:"string",description:"URL of the image to upscale."}},required:["image_url"]},transcribe_audio:{intro:"Transcribe speech in an audio/video URL to text.",tiers:{whisper:{toolId:"fal-whisper",priceCents:2,notes:"OpenAI Whisper \u2014 fast, multilingual"}},guidance:"Pass the URL. Returns the transcript text.",inputProperties:{audio_url:{type:"string",description:"URL of the audio or video file to transcribe."}},required:["audio_url"]},run_llm:{intro:"Run a text prompt through an LLM (OpenRouter). Token-metered \u2014 prices below are per 1M input/output tokens. Typical 500-in/500-out prompts cost 1\u20139\xA2 depending on model.",tiers:{fast:{toolId:"or-gpt-4o-mini",priceCents:1,notes:"GPT-4o Mini \u2014 $0.15/M in \xB7 $0.60/M out. Fastest, cheapest, good general-purpose (DEFAULT)"},reasoning:{toolId:"or-claude-sonnet",priceCents:9,notes:"Claude 3.5 Sonnet \u2014 $3.00/M in \xB7 $15.00/M out. Strong reasoning, long-context. ~20x pricier than `fast`."},deep_reasoning:{toolId:"or-deepseek-r1",priceCents:2,notes:"DeepSeek R1 \u2014 $0.55/M in \xB7 $2.19/M out. Deep chain-of-thought reasoning, mid-range pricing."},search:{toolId:"or-perplexity-sonar",priceCents:1,notes:"Perplexity Sonar \u2014 $1.00/M in \xB7 $1.00/M out. Search-augmented, web-grounded with citations."},open_source:{toolId:"or-llama-70b",priceCents:1,notes:"Llama 3.3 70B \u2014 $0.30/M in \xB7 $0.40/M out. Open-source large model."},coding:{toolId:"or-deepseek-chat",priceCents:1,notes:"DeepSeek Chat V3 \u2014 $0.30/M in \xB7 $0.88/M out. Strong at code generation."}},guidance:"Pick based on the user's need: fast (most questions, cheapest), reasoning (complex analysis \u2014 WARN user it's ~$0.09/call), search (questions about current events), coding (code generation), deep_reasoning (hard math/logic problems).",inputProperties:{prompt:{type:"string",description:"The user query."},system_prompt:{type:"string",description:"Optional system prompt to set model behavior."},max_tokens:{type:"number",description:"Maximum output tokens.",default:1024,minimum:1,maximum:8192},temperature:{type:"number",description:"Sampling temperature \u2014 0 is deterministic, higher is more creative.",default:.7,minimum:0,maximum:2}},required:["prompt"]}},Er=Object.keys(Ln)});async function qt(t,e,n,r){if(!U()){M.warn("attestation:unavailable",{context:t});return}M.info("attestation:attempt",{context:t,amount:e,merchant:n});try{let{nonce:o}=await Un.getAttestationChallenge(),s=Buffer.from(JSON.stringify({nonce:o,amount:e,merchant:n,context:t})).toString("base64");M.info("touchid:prompt",{context:t,amount:e,merchant:n});let a=await le(s,r);return M.info("attestation:success",{context:t,amount:e,merchant:n}),{signature:a,nonce:o,amount:e,merchant:n}}catch(o){throw M.error("attestation:failure",{context:t,amount:e,merchant:n,error:o.message}),o}}var Or,Un,jn,Lr,Ur,jr,Le=f(()=>{"use strict";oe();ke();K();Te();jt();Or=process.env.VISA_AUTH_URL||"https://auth.visacli.sh",Un=new $(()=>g.getSessionToken()),jn=["generate_image","generate_video","generate_music","generate_audio","generate_3d","upscale_image","transcribe_audio","run_llm"],Lr=["","","You're ready to go! Try:","","Core:",'\u2022 "Show my account status" \u2192 get_status','\u2022 "List my enrolled cards" \u2192 get_cards','\u2022 "Show my recent transactions" \u2192 transaction_history','\u2022 "Set my daily limit to $50" \u2192 update_spending_controls','\u2022 "Pay https://example.com/checkout" \u2192 pay','\u2022 "Generate 3 variations in parallel" \u2192 batch',"","Fast shortcuts:",'\u2022 "Generate an image of a sunset over Tokyo" \u2192 generate_image_card (~$0.06)','\u2022 "Make a fast thumbnail: minimalist cat logo" \u2192 generate_image_fast_card (~$0.04)','\u2022 "Make a 4-second video of a penguin juggling" \u2192 generate_video_tempo_card (~$0.30)','\u2022 "Make a song about coding late at night" \u2192 generate_music_tempo_card (~$0.10)','\u2022 "Check the status of my music job" \u2192 check_music_status_tempo_card','\u2022 "What is ETH on Base trading at?" \u2192 query_onchain_prices_card (~$0.02)','\u2022 "Explore stablecoin inflows on Base" \u2192 allium_explorer_card','\u2022 "Open the latest Allium result set" \u2192 allium_explorer_results_card','\u2022 "Show pxlwall campaign insights" \u2192 pxlwall_card',"","Category tools:",...jn.map(t=>`\u2022 "${t.replace(/_/g," ")}" \u2192 ${t}`),"","Tool catalog:",'\u2022 "Find an image upscaler" \u2192 discover_tools','\u2022 "Run fal-aura-sr on this URL" \u2192 execute_tool'].join(`
23
23
  `);Ur=16*1024,jr=50*1024*1024});function Dt(t="or-claude-sonnet"){return{model:t,budgetCents:Ft,spentCents:0,turns:0,inputTokens:0,outputTokens:0}}async function Vt(t=Ft){try{return{attestation:await qt("visa-client-session",t/100,"Visa CLI",`Visa CLI session budget: $${(t/100).toFixed(2)}`)||void 0,budgetCents:t}}catch{return{attestation:void 0,budgetCents:t}}}function de(t){let e=(t.budgetCents-t.spentCents)/100,n=t.spentCents/100;return`$${e.toFixed(2)} remaining ($${n.toFixed(2)} spent, ${t.turns} turns)`}var Ft,Ht=f(()=>{"use strict";Le();Ft=500});var Bt={};on(Bt,{startClient:()=>Dn});async function Dn(t={}){let e=Dt(t.model);console.log(Fn),console.log(`
24
24
  ${j}Model: ${e.model}${N}`),console.log(` ${j}Authorizing session budget: $${(e.budgetCents/100).toFixed(2)}${N}`);let n=await Vt(t.budget||e.budgetCents);e.budgetCents=n.budgetCents,n.attestation?console.log(` ${j}Touch ID authorized. ${de(e)}${N}
25
25
  `):console.log(` ${j}No attestation (Touch ID unavailable). ${de(e)}${N}
@@ -29,7 +29,7 @@ ${l}`},{role:"assistant",content:"Understood. I have context from our previous c
29
29
  `)}
30
30
  `)},a=(l,c)=>{let u=l==="bash"?c.command?.slice(0,60):c.path||"";console.log(` ${j}\u25B8 ${l}${N} ${u}`)},i=(l,c)=>{let u=l+c,_=[`$${(l/100).toFixed(3)} inference`];c>0&&_.push(`$${(c/100).toFixed(3)} tools`),console.log(` ${j}${_.join(" \xB7 ")} \xB7 $${(u/100).toFixed(3)} this turn${N}`)};await Lt(e,n.attestation,o,s,a,i),console.log(`
31
31
  ${j}Session ended. ${de(e)}${N}`),r.close()}var Kt,N,qn,j,Fn,Wt=f(()=>{"use strict";Kt=p(require("readline"));Ut();Ht();N="\x1B[0m",qn="\x1B[38;5;33m",j="\x1B[2m",Fn=[" \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28E4\u28C0\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2880\u28FF\u2807\u28B0\u28F6\u28E6\u28E4\u28C0\u2840\u2812\u2802\u2824\u2824\u2884\u28C0\u28C0\u2840\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28B8\u285F\u2880\u28FF\u281F\u283F\u28BF\u28FF\u28FF\u28FF\u28FF\u28F6\u28F6\u28E4\u28C4\u28C9\u2841\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u28FE\u2801\u28F8\u28FF\u28F7\u28F6\u28E4\u28E4\u28C8\u2849\u281B\u283B\u283F\u28FF\u28FF\u28FF\u28FF\u28FF\u2876\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2880\u284F\u28A0\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28F6\u28E6\u28E4\u28C4\u28C9\u28B9\u28FF\u2803\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2838\u2800\u28FE\u28FF\u28FF\u28FF\u28CF\u28D9\u281B\u283B\u283F\u28BF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u284F\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2802\u28B8\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28FF\u28F7\u28F6\u28E6\u28E4\u28F8\u28FF\u28FF\u28FF\u28FF\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2880\u28FF\u28FF\u287F\u280B\u28C1\u28E4\u2804\u2880\u2800\u2809\u283B\u28FF\u28FF\u28FF\u28FF\u28FF\u2807\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u28FC\u28FF\u280F\u28C0\u2818\u281B\u2801\u2830\u28FF\u2847\u28B8\u28E6\u2848\u28BF\u28FF\u28FF\u287F\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u28A0\u28FF\u284F\u28A0\u28FF\u28FF\u2803\u28F4\u28F6\u28E4\u2844\u2880\u28C9\u2803\u28B8\u28FF\u28FF\u2803\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u28FE\u28FF\u28C7\u2800\u28C4\u28C9\u2800\u281B\u283F\u283F\u2801\u28FC\u28FF\u2847\u28B8\u28FF\u284F\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u28B8\u28FF\u28FF\u28FF\u28C4\u2819\u28BF\u2818\u28F7\u2876\u2800\u28E4\u28C8\u2849\u2881\u28FE\u28FF\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2819\u281B\u283F\u283F\u28FF\u28E6\u28C4\u2800\u2809\u2820\u281E\u281B\u28C9\u28F4\u28FF\u28FF\u2807\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2808\u2809\u281B\u2812\u2836\u28BF\u28FF\u28FF\u28FF\u287F\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"," \u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2808\u2809\u2801\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800\u2800"].join(`
32
- `)});var Gt=require("commander"),pe=p(require("crypto")),V=p(require("os")),zt=require("child_process"),Yt=require("util");K();var ee=p(require("crypto")),te=p(require("tty")),ne=p(require("fs"));var O="6820f6e91b762e645c9bf020c0d3673bb99d4a25a824880c0d548e10bb9bc7b1";K();function pn(t){return/-rc\.|-beta\./.test(t)}function we(t){return ee.createHash("sha256").update(t.trim()).digest("hex")}function Ke(t){return O==="SKIP"?!0:ee.timingSafeEqual(Buffer.from(we(t)),Buffer.from(O))}function gn(t){return new Promise((e,n)=>{let r=ne.openSync("/dev/tty","r+"),o=new te.ReadStream(r),s=new te.WriteStream(r),a=()=>{try{o.destroy()}catch{}try{s.destroy()}catch{}try{ne.closeSync(r)}catch{}};s.write(t),o.setRawMode(!0),o.resume(),o.setEncoding("utf8");let i="";o.on("data",l=>{l==="\r"||l===`
32
+ `)});var Gt=require("commander"),pe=p(require("crypto")),V=p(require("os")),zt=require("child_process"),Yt=require("util");K();var ee=p(require("crypto")),te=p(require("tty")),ne=p(require("fs"));var O="0000000000000000000000000000000000000000000000000000000000000000";K();function pn(t){return/-rc\.|-beta\./.test(t)}function we(t){return ee.createHash("sha256").update(t.trim()).digest("hex")}function Ke(t){return O==="SKIP"?!0:ee.timingSafeEqual(Buffer.from(we(t)),Buffer.from(O))}function gn(t){return new Promise((e,n)=>{let r=ne.openSync("/dev/tty","r+"),o=new te.ReadStream(r),s=new te.WriteStream(r),a=()=>{try{o.destroy()}catch{}try{s.destroy()}catch{}try{ne.closeSync(r)}catch{}};s.write(t),o.setRawMode(!0),o.resume(),o.setEncoding("utf8");let i="";o.on("data",l=>{l==="\r"||l===`
33
33
  `?(s.write(`
34
34
  `),a(),e(i)):l===""?(s.write(`
35
35
  `),a(),n(new Error("Cancelled"))):l==="\x7F"||l==="\b"?i.length>0&&(i=i.slice(0,-1),s.write("\b \b")):(i+=l,s.write("\u2022"))})})}var fn=`
@@ -50,13 +50,13 @@ ${l}`},{role:"assistant",content:"Understood. I have context from our previous c
50
50
  Invalid code. Contact your team lead.
51
51
  `),process.exit(1)}var We=require("child_process");function hn(t=process.env,e=process.platform){return t.VISA_CLI_NO_BROWSER==="1"||t.VISA_CLI_NO_BROWSER==="true"?{headless:!0,reason:"VISA_CLI_NO_BROWSER is set"}:t.CI==="true"||t.CI==="1"?{headless:!0,reason:"CI environment detected"}:t.SSH_CONNECTION||t.SSH_TTY?{headless:!0,reason:"SSH session detected"}:e==="linux"&&!t.DISPLAY&&!t.WAYLAND_DISPLAY?{headless:!0,reason:"Linux with no $DISPLAY or $WAYLAND_DISPLAY"}:{headless:!1}}function yn(t){let n=t.length+4;return[`\u250C${"\u2500".repeat(n)}\u2510`,`\u2502${" ".repeat(2)}${t}${" ".repeat(2)}\u2502`,`\u2514${"\u2500".repeat(n)}\u2518`].join(`
52
52
  `)}function _n(t,e=process.platform){return e==="darwin"?{cmd:"open",args:[t]}:e==="win32"?{cmd:"cmd",args:["/c","start","",t]}:e==="linux"?{cmd:"xdg-open",args:[t]}:null}async function Ge(t,e={}){let n=e.log??(l=>console.log(l)),r=e.env??process.env,o=e.platform??process.platform,s=e.spawn??((l,c,u)=>{(0,We.execFile)(l,c,_=>u(_))});n(""),n(" Sign in to Visa CLI by opening this URL in your browser:"),n("");for(let l of yn(t).split(`
53
- `))n(` ${l}`);n("");let a=hn(r,o);if(a.headless){n(` (${a.reason} \u2014 skipping browser auto-open.)`),n(" Open the URL above on any device with a browser. The CLI will"),n(" continue waiting for you to complete sign-in."),n("");return}let i=_n(t,o);if(!i){n(` No known browser-open command for platform "${o}".`),n(" Open the URL above manually to continue."),n("");return}await new Promise(l=>{s(i.cmd,i.args,c=>{c?(n(` Could not open browser automatically (${c.message}).`),n(" Open the URL above manually to continue."),n("")):(n(" Opened browser. Waiting for you to sign in..."),n("")),l()})})}oe();ke();be();function mt(t,e=process.stderr){if(re()||!t?.updateAvailable)return!1;let{message:n}=t.updateAvailable;return n?(e.write(`
53
+ `))n(` ${l}`);n("");let a=hn(r,o);if(a.headless){n(` (${a.reason} \u2014 skipping browser auto-open.)`),n(" Open the URL above on any device with a browser. The CLI will"),n(" continue waiting for you to complete sign-in."),n("");return}let i=_n(t,o);if(!i){n(` No known browser-open command for platform "${o}".`),n(" Open the URL above manually to continue."),n("");return}await new Promise(l=>{s(i.cmd,i.args,c=>{c?(n(` Could not open browser automatically (${c.message}).`),n(" Open the URL above manually to continue."),n("")):(n(" Opened browser. Waiting for you to sign in..."),n("")),l()})})}oe();ke();Se();function mt(t,e=process.stderr){if(re()||!t?.updateAvailable)return!1;let{message:n}=t.updateAvailable;return n?(e.write(`
54
54
  \x1B[33m\u2191 ${n}\x1B[0m
55
- `),!0):!1}var b=class extends Error{constructor(e){super(e),this.name="PayValidationError"}},pt=["GET","POST"];function gt(t){let e;try{e=new URL(t)}catch{throw new b(`Invalid URL: ${t}. Expected a fully-qualified http(s) URL.`)}if(e.protocol!=="http:"&&e.protocol!=="https:")throw new b(`Unsupported URL scheme "${e.protocol}". Only http and https are allowed.`);return e}function ft(t){let e=(t??"GET").toUpperCase();if(!pt.includes(e))throw new b(`Unsupported HTTP method "${t}". Supported: ${pt.join(", ")}.`);return e}function ht(t){if(t!==void 0){try{JSON.parse(t)}catch(e){throw new b(`--body is not valid JSON: ${e?.message??"parse error"}`)}return t}}function yt(t){if(!t||typeof t!="object")throw new b("Merchant returned no payment preview.");let e=t;if(typeof e.amount!="number"||!Number.isFinite(e.amount)||e.amount<=0)throw new b("Could not determine payment amount from merchant.");if(typeof e.merchantName!="string"||e.merchantName.trim().length===0)throw new b("Merchant returned an empty merchant name.");if(e.merchantName.length>200)throw new b(`Merchant name too long (${e.merchantName.length} chars).`);if(typeof e.currency!="string"||e.currency.trim().length===0)throw new b("Merchant returned an empty currency.");if(e.currency.length>10)throw new b(`Currency code too long (${e.currency.length} chars).`);return{amount:e.amount,currency:e.currency,merchantName:e.merchantName}}var m=p(require("fs")),d=p(require("path")),_t=p(require("os")),y=_t.homedir(),P=[{id:"claude",displayName:"Claude Code",globalConfigPath:d.join(y,".claude.json"),configKey:"mcpServers",detectPaths:[d.join(y,".claude.json")],postInstallHint:"Restart Claude Code or run /mcp to connect."},{id:"claude-desktop",displayName:"Claude Desktop",globalConfigPath:d.join(y,"Library","Application Support","Claude","claude_desktop_config.json"),configKey:"mcpServers",detectPaths:[d.join(y,"Library","Application Support","Claude")],postInstallHint:"Restart the Claude desktop app to connect."},{id:"cursor",displayName:"Cursor",globalConfigPath:d.join(y,".cursor","mcp.json"),configKey:"mcpServers",detectPaths:[d.join(y,".cursor")],postInstallHint:"Restart Cursor to connect."},{id:"windsurf",displayName:"Windsurf",globalConfigPath:d.join(y,".codeium","windsurf","mcp_config.json"),configKey:"mcpServers",detectPaths:[d.join(y,".codeium","windsurf")],postInstallHint:"Restart Windsurf to connect."},{id:"cline",displayName:"Cline",globalConfigPath:d.join(y,".vscode","mcp.json"),configKey:"mcpServers",detectPaths:[d.join(y,".vscode","extensions","saoudrizwan.claude-dev-*")],postInstallHint:"Restart VS Code to connect."},{id:"roo-code",displayName:"Roo Code",globalConfigPath:d.join(y,".config","Roo","mcp_settings.json"),configKey:"mcpServers",detectPaths:[d.join(y,".vscode","extensions","RooVeterinaryInc.roo-cline-*")],postInstallHint:"Restart VS Code to connect."},{id:"copilot",displayName:"VS Code Copilot",globalConfigPath:d.join(y,".vscode","mcp.json"),configKey:"servers",detectPaths:[d.join(y,".vscode")],postInstallHint:"Restart VS Code to connect."},{id:"zed",displayName:"Zed",globalConfigPath:d.join(y,".config","zed","settings.json"),configKey:"context_servers",detectPaths:[d.join(y,".config","zed")],postInstallHint:"Restart Zed to connect.",buildEntry:t=>({source:"custom",...t})}];function Ie(t){return P.find(e=>e.id===t)}function W(t){return t.detectPaths.some(e=>{if(e.includes("*")){let n=d.dirname(e),r=d.basename(e).replaceAll("*","");if(!m.existsSync(n))return!1;try{return m.readdirSync(n).some(o=>o.startsWith(r))}catch{return!1}}return m.existsSync(e)})}function wt(){return{command:"node",args:[d.resolve(__dirname,"mcp-server/index.js")]}}function G(t,e="global"){let n=e==="project"?d.join(process.cwd(),".mcp.json"):t.globalConfigPath,r=d.dirname(n);m.existsSync(r)||m.mkdirSync(r,{recursive:!0});let o={};if(m.existsSync(n))try{o=JSON.parse(m.readFileSync(n,"utf-8"))}catch{o={}}o[t.configKey]=o[t.configKey]||{};let s=wt();return o[t.configKey]["visa-cli"]=t.buildEntry?t.buildEntry(s):s,m.writeFileSync(n,JSON.stringify(o,null,2)+`
55
+ `),!0):!1}var S=class extends Error{constructor(e){super(e),this.name="PayValidationError"}},pt=["GET","POST"];function gt(t){let e;try{e=new URL(t)}catch{throw new S(`Invalid URL: ${t}. Expected a fully-qualified http(s) URL.`)}if(e.protocol!=="http:"&&e.protocol!=="https:")throw new S(`Unsupported URL scheme "${e.protocol}". Only http and https are allowed.`);return e}function ft(t){let e=(t??"GET").toUpperCase();if(!pt.includes(e))throw new S(`Unsupported HTTP method "${t}". Supported: ${pt.join(", ")}.`);return e}function ht(t){if(t!==void 0){try{JSON.parse(t)}catch(e){throw new S(`--body is not valid JSON: ${e?.message??"parse error"}`)}return t}}function yt(t){if(!t||typeof t!="object")throw new S("Merchant returned no payment preview.");let e=t;if(typeof e.amount!="number"||!Number.isFinite(e.amount)||e.amount<=0)throw new S("Could not determine payment amount from merchant.");if(typeof e.merchantName!="string"||e.merchantName.trim().length===0)throw new S("Merchant returned an empty merchant name.");if(e.merchantName.length>200)throw new S(`Merchant name too long (${e.merchantName.length} chars).`);if(typeof e.currency!="string"||e.currency.trim().length===0)throw new S("Merchant returned an empty currency.");if(e.currency.length>10)throw new S(`Currency code too long (${e.currency.length} chars).`);return{amount:e.amount,currency:e.currency,merchantName:e.merchantName}}var m=p(require("fs")),d=p(require("path")),_t=p(require("os")),y=_t.homedir(),P=[{id:"claude",displayName:"Claude Code",globalConfigPath:d.join(y,".claude.json"),configKey:"mcpServers",detectPaths:[d.join(y,".claude.json")],postInstallHint:"Restart Claude Code or run /mcp to connect."},{id:"claude-desktop",displayName:"Claude Desktop",globalConfigPath:d.join(y,"Library","Application Support","Claude","claude_desktop_config.json"),configKey:"mcpServers",detectPaths:[d.join(y,"Library","Application Support","Claude")],postInstallHint:"Restart the Claude desktop app to connect."},{id:"cursor",displayName:"Cursor",globalConfigPath:d.join(y,".cursor","mcp.json"),configKey:"mcpServers",detectPaths:[d.join(y,".cursor")],postInstallHint:"Restart Cursor to connect."},{id:"windsurf",displayName:"Windsurf",globalConfigPath:d.join(y,".codeium","windsurf","mcp_config.json"),configKey:"mcpServers",detectPaths:[d.join(y,".codeium","windsurf")],postInstallHint:"Restart Windsurf to connect."},{id:"cline",displayName:"Cline",globalConfigPath:d.join(y,".vscode","mcp.json"),configKey:"mcpServers",detectPaths:[d.join(y,".vscode","extensions","saoudrizwan.claude-dev-*")],postInstallHint:"Restart VS Code to connect."},{id:"roo-code",displayName:"Roo Code",globalConfigPath:d.join(y,".config","Roo","mcp_settings.json"),configKey:"mcpServers",detectPaths:[d.join(y,".vscode","extensions","RooVeterinaryInc.roo-cline-*")],postInstallHint:"Restart VS Code to connect."},{id:"copilot",displayName:"VS Code Copilot",globalConfigPath:d.join(y,".vscode","mcp.json"),configKey:"servers",detectPaths:[d.join(y,".vscode")],postInstallHint:"Restart VS Code to connect."},{id:"zed",displayName:"Zed",globalConfigPath:d.join(y,".config","zed","settings.json"),configKey:"context_servers",detectPaths:[d.join(y,".config","zed")],postInstallHint:"Restart Zed to connect.",buildEntry:t=>({source:"custom",...t})}];function Ie(t){return P.find(e=>e.id===t)}function W(t){return t.detectPaths.some(e=>{if(e.includes("*")){let n=d.dirname(e),r=d.basename(e).replaceAll("*","");if(!m.existsSync(n))return!1;try{return m.readdirSync(n).some(o=>o.startsWith(r))}catch{return!1}}return m.existsSync(e)})}function wt(){return{command:"node",args:[d.resolve(__dirname,"mcp-server/index.js")]}}function G(t,e="global"){let n=e==="project"?d.join(process.cwd(),".mcp.json"):t.globalConfigPath,r=d.dirname(n);m.existsSync(r)||m.mkdirSync(r,{recursive:!0});let o={};if(m.existsSync(n))try{o=JSON.parse(m.readFileSync(n,"utf-8"))}catch{o={}}o[t.configKey]=o[t.configKey]||{};let s=wt();return o[t.configKey]["visa-cli"]=t.buildEntry?t.buildEntry(s):s,m.writeFileSync(n,JSON.stringify(o,null,2)+`
56
56
  `),{installed:!0,configPath:n,message:t.postInstallHint}}function Re(t,e="global"){let n=e==="project"?d.join(process.cwd(),".mcp.json"):t.globalConfigPath;if(!m.existsSync(n))return{removed:!1,configPath:n};let r;try{r=JSON.parse(m.readFileSync(n,"utf-8"))}catch{return{removed:!1,configPath:n}}let o=r[t.configKey];return!o||!o["visa-cli"]?{removed:!1,configPath:n}:(delete o["visa-cli"],m.writeFileSync(n,JSON.stringify(r,null,2)+`
57
- `),{removed:!0,configPath:n})}function bt(t,e="global"){let n=e==="project"?d.join(process.cwd(),".mcp.json"):t.globalConfigPath;if(!m.existsSync(n))return!1;try{return!!JSON.parse(m.readFileSync(n,"utf-8"))?.[t.configKey]?.["visa-cli"]}catch{return!1}}function Cn(t){if(!t||typeof t!="object")return;let e=t;if(e.command!=="node"||!Array.isArray(e.args)||e.args.length===0)return;let n=e.args[e.args.length-1];if(!(typeof n!="string"||n.length===0))return n}function $n(t,e){if(t===e)return!0;let n=d.resolve(t),r=d.resolve(e);if(n===r)return!0;try{let o=m.realpathSync(n),s=m.realpathSync(r);return o===s}catch{return!1}}function z(){let t=wt(),e=t.args[t.args.length-1],n=[];for(let r of P){let o=r.globalConfigPath;if(!m.existsSync(o))continue;let s;try{s=JSON.parse(m.readFileSync(o,"utf-8"))}catch{continue}let a=s?.[r.configKey]?.["visa-cli"];if(!a)continue;let i=Cn(a);if(!i||$n(i,e))continue;let l=m.existsSync(i)?"mismatch":"missing";n.push({client:r,configPath:o,currentPath:i,expectedPath:e,staleReason:l})}return n}function Ae(t){return{configPath:G(t.client,"global").configPath}}var Vn=(0,Yt.promisify)(zt.execFile);function Hn(t){let e=V.homedir(),n=o=>o.replace(e,"~"),r=t.staleReason==="missing"?"path missing on disk":"path mismatch";return` \u2022 ${t.client.displayName} (${n(t.configPath)})
57
+ `),{removed:!0,configPath:n})}function St(t,e="global"){let n=e==="project"?d.join(process.cwd(),".mcp.json"):t.globalConfigPath;if(!m.existsSync(n))return!1;try{return!!JSON.parse(m.readFileSync(n,"utf-8"))?.[t.configKey]?.["visa-cli"]}catch{return!1}}function Cn(t){if(!t||typeof t!="object")return;let e=t;if(e.command!=="node"||!Array.isArray(e.args)||e.args.length===0)return;let n=e.args[e.args.length-1];if(!(typeof n!="string"||n.length===0))return n}function $n(t,e){if(t===e)return!0;let n=d.resolve(t),r=d.resolve(e);if(n===r)return!0;try{let o=m.realpathSync(n),s=m.realpathSync(r);return o===s}catch{return!1}}function z(){let t=wt(),e=t.args[t.args.length-1],n=[];for(let r of P){let o=r.globalConfigPath;if(!m.existsSync(o))continue;let s;try{s=JSON.parse(m.readFileSync(o,"utf-8"))}catch{continue}let a=s?.[r.configKey]?.["visa-cli"];if(!a)continue;let i=Cn(a);if(!i||$n(i,e))continue;let l=m.existsSync(i)?"mismatch":"missing";n.push({client:r,configPath:o,currentPath:i,expectedPath:e,staleReason:l})}return n}function Ae(t){return{configPath:G(t.client,"global").configPath}}var Vn=(0,Yt.promisify)(zt.execFile);function Hn(t){let e=V.homedir(),n=o=>o.replace(e,"~"),r=t.staleReason==="missing"?"path missing on disk":"path mismatch";return` \u2022 ${t.client.displayName} (${n(t.configPath)})
58
58
  ${r}: ${n(t.currentPath)}`}function Jt(t,e){if(t.length===0){console.log(`${e} \u2713 All MCP client configs are up to date.`);return}console.log(`${e} Found ${t.length} stale MCP config ${t.length===1?"entry":"entries"}:`);for(let n of t)console.log(Hn(n))}var x=new Gt.Command,me=null;function ge(){return me=new $(()=>g.getSessionToken()),me}x.name("visa-cli").description("Visa CLI - AI payment orchestration").version(_e().version);x.hook("preAction",async()=>{await Be()});x.command("setup").description("Register MCP server, authenticate, and generate attestation key").option("--check","Scan MCP client configs for stale visa-cli entries and exit without making changes").action(async t=>{try{if(t.check){let c=z();Jt(c,"MCP config check:"),c.length>0&&(console.log("\nRun `visa-cli setup` (or `visa-cli install --repair`) to rewrite these entries."),process.exit(1));return}console.log("Step 1: Registering MCP server...");let e=z(),n=new Map(e.map(c=>[c.client.id,c])),r=new Set;for(let c of P)if(W(c)){let u=G(c),_=n.get(c.id),q=_?` \u2014 repaired stale ${_.staleReason} entry`:"";console.log(` \u2713 ${c.displayName} (${u.configPath.replace(V.homedir(),"~")})${q}`),_&&r.add(c.id)}let o=e.filter(c=>!r.has(c.client.id));for(let c of o)Ae(c),console.log(` \u2713 ${c.client.displayName} (${c.configPath.replace(V.homedir(),"~")}) \u2014 repaired stale ${c.staleReason} entry`);let s=r.size+o.length;console.log(s===0?" \u2713 MCP config verified \u2014 nothing to repair.":` \u2713 Repaired ${s} stale MCP config ${s===1?"entry":"entries"}.`),console.log(`
59
- Step 2: Checking authentication...`);let a=await g.getSessionToken();if(a?console.log(" Already authenticated."):(console.log(" No session found. Opening browser for GitHub login..."),a=await new Promise(async(c,u)=>{let _=pe.randomBytes(16).toString("hex"),q=`https://auth.visacli.sh/login?state=${_}`;await Ge(q);let T=3e4,Y=300*1e3,H=Date.now()+Y;for(;Date.now()<H;)try{let I=await globalThis.fetch("https://auth.visacli.sh/v1/auth-status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:_,timeout:T}),signal:AbortSignal.timeout(T+5e3)});if(!I.ok)continue;let S=await I.json();if(S.status==="pending")continue;if(S.status==="expired"){u(new Error("Session expired. Please run setup again."));return}if(S.status==="complete"&&S.sessionToken){console.log(` Signed in as ${S.user}.`),c(S.sessionToken);return}}catch{}u(new Error("Login timed out after 5 minutes. Please run setup again."))}),await g.saveSessionToken(a),console.log(" Session token saved.")),console.log(`
59
+ Step 2: Checking authentication...`);let a=await g.getSessionToken();if(a?console.log(" Already authenticated."):(console.log(" No session found. Opening browser for GitHub login..."),a=await new Promise(async(c,u)=>{let _=pe.randomBytes(16).toString("hex"),q=`https://auth.visacli.sh/login?state=${_}`;await Ge(q);let T=3e4,Y=300*1e3,H=Date.now()+Y;for(;Date.now()<H;)try{let I=await globalThis.fetch("https://auth.visacli.sh/v1/auth-status",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({state:_,timeout:T}),signal:AbortSignal.timeout(T+5e3)});if(!I.ok)continue;let b=await I.json();if(b.status==="pending")continue;if(b.status==="expired"){u(new Error("Session expired. Please run setup again."));return}if(b.status==="complete"&&b.sessionToken){console.log(` Signed in as ${b.user}.`),c(b.sessionToken);return}}catch{}u(new Error("Login timed out after 5 minutes. Please run setup again."))}),await g.saveSessionToken(a),console.log(" Session token saved.")),console.log(`
60
60
  Step 3: Setting up authentication...`),!U())console.log(" Not macOS \u2014 skipping biometric setup.");else{try{await Vn("clang",["--version"])}catch{console.error(" Xcode Command Line Tools are required for payment authentication."),console.error(" Install them by running: xcode-select --install"),console.error(" Then re-run: visa-cli setup"),process.exit(1)}try{let c=await ut();console.log(" Attestation key generated."),await ge().registerAttestationKey(c),console.log(" Attestation key registered with server.")}catch(c){console.log(` Skipped: ${c.message}`)}}let i="\x1B[1m",l="\x1B[0m";console.log(`
61
61
  \u2588\u2588\u2557 \u2588\u2588\u2557\u2588\u2588\u2557\u2588\u2588\u2588\u2588\u2588\u2588\u2588\u2557 \u2588\u2588\u2588\u2588\u2588\u2557
62
62
  \u2588\u2588\u2551 \u2588\u2588\u2551\u2588\u2588\u2551\u2588\u2588\u2554\u2550\u2550\u2550\u2550\u255D\u2588\u2588\u2554\u2550\u2550\u2588\u2588\u2557
@@ -77,11 +77,11 @@ Step 3: Setting up authentication...`),!U())console.log(" Not macOS \u2014 ski
77
77
  `)}catch(e){console.error("Error:",e.message),process.exit(1)}});x.command("install [client]").description("Register MCP server with an AI client (claude, cursor, windsurf, cline, zed, ...)").option("--all","Install for all detected clients").option("--list","Show supported clients and install status").option("--check","Scan MCP client configs for stale visa-cli entries and exit without making changes").option("--repair","Repair stale MCP client configs without re-running the full setup flow").option("--scope <scope>","Install scope: global or project","global").action(async(t,e)=>{try{if(e.check){let s=z();Jt(s,"MCP config check:"),s.length>0&&process.exit(1);return}if(e.repair){let s=z();if(s.length===0){console.log("\u2713 MCP config verified \u2014 nothing to repair.");return}for(let a of s)Ae(a),console.log(` \u2713 ${a.client.displayName} (${a.configPath.replace(V.homedir(),"~")}) \u2014 repaired stale ${a.staleReason} entry`);console.log(`
78
78
  Repaired ${s.length} stale MCP config ${s.length===1?"entry":"entries"}.`);return}if(e.list){console.log(`
79
79
  \x1B[1mSupported MCP Clients\x1B[0m
80
- `),console.log(` ${"Client".padEnd(18)} ${"Detected".padEnd(10)} ${"Installed".padEnd(11)} Config Path`),console.log(` ${"\u2500".repeat(18)} ${"\u2500".repeat(10)} ${"\u2500".repeat(11)} ${"\u2500".repeat(40)}`);for(let i of P){let l=W(i),c=bt(i),u=l?"Yes":"No",_=c?"Yes":"No",q=i.globalConfigPath.replace(V.homedir(),"~");console.log(` ${i.displayName.padEnd(18)} ${u.padEnd(10)} ${_.padEnd(11)} ${q}`)}console.log("");return}let n=e.scope==="project"?"project":"global";if(e.all){let s=[],a=[];for(let i of P){if(!W(i)){a.push(i.displayName);continue}G(i,n),s.push(i.displayName)}s.length>0&&console.log(`Installed for: ${s.join(", ")}.`),a.length>0&&console.log(`Skipped: ${a.map(i=>`${i} (not detected)`).join(", ")}.`),s.length===0&&a.length===0&&console.log("No supported clients found.");return}t||(console.error("Usage: visa-cli install <client>"),console.error(" visa-cli install --all"),console.error(" visa-cli install --list"),console.error(`
80
+ `),console.log(` ${"Client".padEnd(18)} ${"Detected".padEnd(10)} ${"Installed".padEnd(11)} Config Path`),console.log(` ${"\u2500".repeat(18)} ${"\u2500".repeat(10)} ${"\u2500".repeat(11)} ${"\u2500".repeat(40)}`);for(let i of P){let l=W(i),c=St(i),u=l?"Yes":"No",_=c?"Yes":"No",q=i.globalConfigPath.replace(V.homedir(),"~");console.log(` ${i.displayName.padEnd(18)} ${u.padEnd(10)} ${_.padEnd(11)} ${q}`)}console.log("");return}let n=e.scope==="project"?"project":"global";if(e.all){let s=[],a=[];for(let i of P){if(!W(i)){a.push(i.displayName);continue}G(i,n),s.push(i.displayName)}s.length>0&&console.log(`Installed for: ${s.join(", ")}.`),a.length>0&&console.log(`Skipped: ${a.map(i=>`${i} (not detected)`).join(", ")}.`),s.length===0&&a.length===0&&console.log("No supported clients found.");return}t||(console.error("Usage: visa-cli install <client>"),console.error(" visa-cli install --all"),console.error(" visa-cli install --list"),console.error(`
81
81
  Supported clients: ${P.map(s=>s.id).join(", ")}`),process.exit(1));let r=Ie(t);r||(console.error(`Unknown client: ${t}`),console.error(`Supported clients: ${P.map(s=>s.id).join(", ")}`),process.exit(1)),n==="global"&&!W(r)&&(console.error(`${r.displayName} not detected on this machine.`),console.error(`Expected: ${r.detectPaths.join(", ")}`),process.exit(1));let o=G(r,n);console.log(`Registered visa-cli MCP server in ${o.configPath}`),console.log(o.message)}catch(n){console.error("Error:",n.message),process.exit(1)}});x.command("uninstall [client]").description("Remove MCP server from an AI client").option("--all","Remove from all clients").option("--scope <scope>","Uninstall scope: global or project","global").action(async(t,e)=>{try{let n=e.scope==="project"?"project":"global";if(e.all){let s=[];for(let a of P)Re(a,n).removed&&s.push(a.displayName);s.length>0?console.log(`Removed visa-cli from: ${s.join(", ")}.`):console.log("visa-cli was not installed in any client.");return}t||(console.error("Usage: visa-cli uninstall <client>"),console.error(" visa-cli uninstall --all"),console.error(`
82
82
  Supported clients: ${P.map(s=>s.id).join(", ")}`),process.exit(1));let r=Ie(t);r||(console.error(`Unknown client: ${t}`),console.error(`Supported clients: ${P.map(s=>s.id).join(", ")}`),process.exit(1));let o=Re(r,n);o.removed?console.log(`Removed visa-cli from ${o.configPath}`):console.log(`visa-cli was not installed for ${r.displayName}.`)}catch(n){console.error("Error:",n.message),process.exit(1)}});x.command("pay <url>").description("Pay a merchant URL (amount auto-detected from HTTP 402 response)").option("-m, --method <method>","HTTP method (GET or POST)","GET").option("-b, --body <json>","JSON request body for POST endpoints").action(async(t,e)=>{try{gt(t);let n=ft(e.method),r=ht(e.body),o=new $(()=>g.getSessionToken());console.log(`Checking payment for ${t}...`);let s=yt(await o.paymentPreview({url:t}));console.log(` Merchant: ${s.merchantName}`),console.log(` Amount: $${s.amount.toFixed(2)} ${s.currency}`),console.log(` Rail: auto-detected
83
83
  `);let a;if(U())try{let{nonce:l}=await o.getAttestationChallenge(),c=Buffer.from(JSON.stringify({nonce:l,amount:s.amount,merchant:s.merchantName,context:t})).toString("base64");a={signature:await le(c,`pay $${s.amount.toFixed(2)} to ${s.merchantName}`),nonce:l,amount:s.amount,merchant:s.merchantName}}catch(l){console.error(`Touch ID confirmation failed: ${l?.message||"user cancelled or biometric error"}`),process.exit(1)}else console.warn("Warning: Touch ID unavailable on this system \u2014 payment will proceed without biometric attestation.");let i=await o.pay({url:t,method:n,body:r,attestation:a,idempotencyKey:pe.randomUUID()});if(i.success){if(console.log(`Payment complete: $${(i.amount??s.amount).toFixed(2)} \u2192 ${i.merchantName??s.merchantName}`),i.receipt?.urls?.length){console.log(`
84
- Result URLs:`);for(let l of i.receipt.urls)console.log(` ${l}`)}}else console.error(`Payment failed: ${i.message||"Unknown error"}`),process.exit(1)}catch(n){n instanceof b?console.error(`Error: ${n.message}`):console.error("Error:",n.message),process.exit(1)}});x.command("status").description("Check enrollment, cards, wallet, and spending controls").action(async()=>{try{let e=await ge().getStatus();if(console.log(`Visa CLI Status
84
+ Result URLs:`);for(let l of i.receipt.urls)console.log(` ${l}`)}}else console.error(`Payment failed: ${i.message||"Unknown error"}`),process.exit(1)}catch(n){n instanceof S?console.error(`Error: ${n.message}`):console.error("Error:",n.message),process.exit(1)}});x.command("status").description("Check enrollment, cards, wallet, and spending controls").action(async()=>{try{let e=await ge().getStatus();if(console.log(`Visa CLI Status
85
85
  `),console.log("Enrollment:"),console.log(` Enrolled: ${e.enrolled?"Yes":"No"}`),e.githubUser&&console.log(` GitHub: ${e.githubUser}`),console.log(` Cards: ${e.cardCount??0}`),e.cards&&e.cards.length>0){console.log(`
86
86
  Cards:`);for(let n of e.cards){let r=n.isDefault?" (default)":"",o=Number.isInteger(n.id)?`#${n.id} `:"";console.log(` ${o}${n.brand?.toUpperCase()||"CARD"} ****${n.last4}${r}`)}}if(e.spendingControls){let n=e.spendingControls;console.log(`
87
87
  Spending Controls:`),console.log(` Max per transaction: $${n.maxTransactionAmount}`),console.log(` Daily limit: $${n.dailyLimit}`),n.dailySpent!==void 0&&console.log(` Spent today: $${Number(n.dailySpent).toFixed(2)} / $${n.dailyLimit}`)}console.log(`
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- "use strict";var en=Object.create;var It=Object.defineProperty;var tn=Object.getOwnPropertyDescriptor;var rn=Object.getOwnPropertyNames;var nn=Object.getPrototypeOf,sn=Object.prototype.hasOwnProperty;var an=(r,e)=>()=>(r&&(e=r(r=0)),e);var on=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Xt=(r,e)=>{for(var t in e)It(r,t,{get:e[t],enumerable:!0})},cn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of rn(e))!sn.call(r,s)&&s!==t&&It(r,s,{get:()=>e[s],enumerable:!(n=tn(e,s))||n.enumerable});return r};var A=(r,e,t)=>(t=r!=null?en(nn(r)):{},cn(e||!r||!r.__esModule?It(t,"default",{value:r,enumerable:!0}):t,r));var Jt={};Xt(Jt,{fetchWithTimeout:()=>Et});async function Et(r,e){let t=e?.timeoutMs??3e4,n=new AbortController,s=setTimeout(()=>n.abort(),t);try{let{timeoutMs:a,...i}=e??{};return await fetch(r,{...i,signal:n.signal})}finally{clearTimeout(s)}}var Rt=an(()=>{"use strict"});var Zr=on((Hi,Na)=>{Na.exports={name:"@visa/cli",version:"1.1.1-rc.0",description:"AI-powered payments for Claude Code",bin:{"visa-cli":"./bin/visa-cli.js"},scripts:{build:"tsc --noEmit && node esbuild.config.js",dev:"tsc --watch",start:"node dist/mcp-server/index.js",test:"jest --config jest.config.js","test:unit":"jest --config jest.config.js","test:unit:watch":"jest --config jest.config.js --watch","test:unit:coverage":"jest --config jest.config.js --coverage","test:smoke":"VISA_AUTH_URL=https://auth.visacli.sh jest --config jest.smoke.config.js","test:integration":"jest --config jest.integration.config.js","test:e2e":"jest --config jest.e2e.config.js","test:catalog-e2e":"jest --config jest.catalog-e2e.config.js","test:all":"npm run test:unit && npm run test:integration && npm run test:e2e",prepublishOnly:"npm run build && npm test",lint:"eslint src/**/*.ts",format:'prettier --write "src/**/*.ts"',"format:check":'prettier --check "src/**/*.ts"'},keywords:["visa","checkout","mcp","ai-agent","payments","click-to-pay","usdc","stablecoin"],author:"Visa Crypto Labs",license:"SEE LICENSE IN LICENSE",dependencies:{"@modelcontextprotocol/sdk":"^1.0.0",commander:"^12.1.0",zod:"^3.23.0"},devDependencies:{"@visa-cli/tools":"workspace:*","@changesets/changelog-git":"^0.2.1","@changesets/cli":"^2.30.0","@types/jest":"^30.0.0","@types/node":"^25.6.0","@typescript-eslint/eslint-plugin":"^8.56.1","@typescript-eslint/parser":"^8.56.1","@types/express":"^5.0.0",esbuild:"^0.27.4",express:"^4.21.0",eslint:"^10.0.2","eslint-config-prettier":"^10.1.8",jest:"^29.7.0",prettier:"^3.8.1","ts-jest":"^29.2.0",typescript:"^5.7.0"},engines:{node:">=18.0.0"},files:["bin/visa-cli.js","dist/","native/visa-keychain.m","README.md","LICENSE"]}});var Xr=require("@modelcontextprotocol/sdk/server/index.js"),Jr=require("@modelcontextprotocol/sdk/server/stdio.js"),Q=require("@modelcontextprotocol/sdk/types.js");Rt();var un=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;function rt(r,e){let t=Qt(r),n=Qt(e);if(!t||!n)return!1;for(let s=0;s<3;s++)if(t.main[s]!==n.main[s])return t.main[s]>n.main[s];return t.pre&&!n.pre?!1:!t.pre&&n.pre?!0:!t.pre&&!n.pre?!1:ln(t.pre,n.pre)>0}function Qt(r){if(typeof r!="string")return null;let t=r.trim().replace(/^v/,"").match(un);return t?{main:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]??null}:null}function ln(r,e){let t=r.split("."),n=e.split("."),s=Math.max(t.length,n.length);for(let a=0;a<s;a++){if(a>=t.length)return-1;if(a>=n.length)return 1;let i=t[a],o=n[a],c=/^\d+$/.test(i),l=/^\d+$/.test(o);if(c&&l){let u=Number(i)-Number(o);if(u!==0)return u}else{if(c)return-1;if(l)return 1;if(i<o)return-1;if(i>o)return 1}}return 0}function nt(){return!!(er(process.env.VISA_CLI_NO_UPDATE_CHECK)||er(process.env.CI)||process.env.NODE_ENV==="test")}function er(r){if(r===void 0)return!1;let e=r.trim().toLowerCase();return!(e===""||e==="0"||e==="false"||e==="no"||e==="off")}var At="1.1.1-rc.0",st=class{constructor(e){this.getSessionToken=e;this.baseUrl=process.env.VISA_AUTH_URL||"https://auth.visacli.sh"}getSessionToken;baseUrl;lastSignals={};parseServerSignals(e){if(this.lastSignals={},!nt()){let n=e.headers.get("X-Latest-Version"),s=e.headers.get("X-Update-Message");n&&rt(n,At)&&(this.lastSignals.updateAvailable={version:n,message:s||`Update available: v${n}. Run: npm install -g @visa/cli && visa-cli setup`})}let t=e.headers.get("X-Feedback-Prompt");if(t)try{this.lastSignals.feedbackPrompt=JSON.parse(t)}catch{}}getClientVersion(){return At}async request(e,t,n,s,a){let i=await this.getSessionToken();if(!i)throw new Error("Not logged in. Sign up at https://visacli.sh or run: visa-cli setup");let o={Authorization:`Bearer ${i}`};a&&(e==="GET"?o["X-User-Context"]=a.replace(/[\r\n\0]/g," ").slice(0,1e3):n={...n||{},user_context:a}),n&&(o["Content-Type"]="application/json");let c;try{c=await Et(`${this.baseUrl}${t}`,{method:e,headers:{...o,"X-Visa-CLI-Version":At},body:n?JSON.stringify(n):void 0,timeoutMs:s})}catch(u){throw u.name==="AbortError"||u.message?.includes("aborted")?new Error("The request timed out. The server may be under heavy load. Please try again."):new Error("Cannot reach the Visa CLI server. Check your internet connection and try again.")}if(this.parseServerSignals(c),c.status===401)throw new Error("Your session has expired. Run: visa-cli setup");if(c.status===429){let u=c.headers.get("Retry-After")||"3";throw new Error(`Rate limited \u2014 wait ${u}s. Tip: use the batch tool to combine multiple requests into one.`)}if(c.status===503)throw new Error("Visa CLI is temporarily unavailable. Check https://visacli.sh for status.");let l;try{l=await c.json()}catch{throw c.status===500?new Error(`Server error on ${t}. Try again or check https://visacli.sh for status.`):new Error(`Unexpected response from ${t}. Try again.`)}if(!c.ok)throw c.status===500?new Error(`Server error on ${t}. Try again or check https://visacli.sh for status.`):new Error(l?.error||`Request failed (${c.status}). Try again.`);return l}async pay(e,t){return this.request("POST","/v1/pay",e,void 0,t)}async shortcut(e,t,n,s){return this.request("POST",`/v1/shortcuts/${encodeURIComponent(e)}`,t,n,s)}async batch(e,t,n){return this.request("POST","/v1/batch",e,t,n)}async catalogSearch(e,t){let n=new URLSearchParams;e&&n.set("q",e),t&&n.set("category",t);let s=n.toString();return this.request("GET",`/v1/catalog${s?`?${s}`:""}`)}async catalogTool(e){try{return await this.request("GET",`/v1/catalog/${encodeURIComponent(e)}`)}catch{return null}}async paymentPreview(e,t){return this.request("POST","/v1/payment-preview",e,void 0,t)}async getStatus(e){return this.request("GET","/v1/status",void 0,void 0,e)}async getTransactions(e){return this.request("GET","/v1/transactions",void 0,void 0,e)}async updateSpendingControls(e,t){return this.request("POST","/v1/spending-controls",e,void 0,t)}async removeCard(e,t,n){return this.request("DELETE",`/v1/cards/${encodeURIComponent(String(e))}`,t,void 0,n)}async setDefaultCard(e,t,n){return this.request("POST",`/v1/cards/${encodeURIComponent(String(e))}/default`,t,void 0,n)}async getAttestationChallenge(){return this.request("GET","/v1/attestation-challenge")}async registerAttestationKey(e){return this.request("POST","/v1/attestation-key",{publicKey:e})}async logout(e,t){return this.request("POST","/v1/logout",e,void 0,t)}async feedback(e,t,n){return this.request("POST","/v1/feedback",{message:e,...t&&{transaction_id:t}},void 0,n)}async feedSubmit(e){return this.request("POST","/v1/feed",e)}async feedList(e){let t=new URLSearchParams;e?.tab&&t.set("tab",e.tab),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let n=t.toString();return this.request("GET",`/v1/feed${n?"?"+n:""}`)}async feedVote(e,t){return this.request("POST",`/v1/feed/${encodeURIComponent(e)}/vote`,{direction:t})}async feedApprove(e){return this.request("POST",`/v1/feed/${encodeURIComponent(e)}/approve`)}async feedDelete(e){return this.request("DELETE",`/v1/feed/${encodeURIComponent(e)}`)}async feedPending(){return this.request("GET","/v1/feed/pending")}async submitFeedback(e,t,n){return this.request("POST","/v1/feedback",{message:e,...t&&{transaction_id:t}},void 0,n)}async getFeedback(e,t){let n=new URLSearchParams;e&&n.set("limit",String(e));let s=n.toString();return this.request("GET",`/v1/feedback${s?"?"+s:""}`,void 0,void 0,t)}async submitRatedFeedback(e){return this.request("POST","/v1/feedback",e)}};var $t=require("child_process"),ir=require("util"),or=A(require("crypto")),P=A(require("fs")),cr=A(require("os")),B=A(require("path"));var L=A(require("fs")),Nt=A(require("path")),tr=A(require("os")),Ct=Nt.join(tr.homedir(),".visa-mcp"),ze=Nt.join(Ct,"mcp-server.log"),dn=5*1024*1024,Ot=null;function pn(){L.existsSync(Ct)||L.mkdirSync(Ct,{recursive:!0,mode:448})}function mn(){if(!Ot){if(pn(),L.existsSync(ze)&&L.statSync(ze).size>dn){let e=ze+".1";L.existsSync(e)&&L.unlinkSync(e),L.renameSync(ze,e)}Ot=L.createWriteStream(ze,{flags:"a"})}return Ot}function at(r,...e){let t=new Date().toISOString(),n=e.map(a=>typeof a=="string"?a:JSON.stringify(a,null,2)).join(" "),s=`[${t}] [${r}] ${n}
2
+ "use strict";var en=Object.create;var It=Object.defineProperty;var tn=Object.getOwnPropertyDescriptor;var rn=Object.getOwnPropertyNames;var nn=Object.getPrototypeOf,sn=Object.prototype.hasOwnProperty;var an=(r,e)=>()=>(r&&(e=r(r=0)),e);var on=(r,e)=>()=>(e||r((e={exports:{}}).exports,e),e.exports),Xt=(r,e)=>{for(var t in e)It(r,t,{get:e[t],enumerable:!0})},cn=(r,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of rn(e))!sn.call(r,s)&&s!==t&&It(r,s,{get:()=>e[s],enumerable:!(n=tn(e,s))||n.enumerable});return r};var A=(r,e,t)=>(t=r!=null?en(nn(r)):{},cn(e||!r||!r.__esModule?It(t,"default",{value:r,enumerable:!0}):t,r));var Jt={};Xt(Jt,{fetchWithTimeout:()=>Et});async function Et(r,e){let t=e?.timeoutMs??3e4,n=new AbortController,s=setTimeout(()=>n.abort(),t);try{let{timeoutMs:a,...i}=e??{};return await fetch(r,{...i,signal:n.signal})}finally{clearTimeout(s)}}var Rt=an(()=>{"use strict"});var Zr=on((Hi,Na)=>{Na.exports={name:"@visa/cli",version:"1.1.1",description:"AI-powered payments for Claude Code",bin:{"visa-cli":"./bin/visa-cli.js"},scripts:{build:"tsc --noEmit && node esbuild.config.js",dev:"tsc --watch",start:"node dist/mcp-server/index.js",test:"jest --config jest.config.js","test:unit":"jest --config jest.config.js","test:unit:watch":"jest --config jest.config.js --watch","test:unit:coverage":"jest --config jest.config.js --coverage","test:smoke":"VISA_AUTH_URL=https://auth.visacli.sh jest --config jest.smoke.config.js","test:integration":"jest --config jest.integration.config.js","test:e2e":"jest --config jest.e2e.config.js","test:catalog-e2e":"jest --config jest.catalog-e2e.config.js","test:all":"npm run test:unit && npm run test:integration && npm run test:e2e",prepublishOnly:"npm run build && npm test",lint:"eslint src/**/*.ts",format:'prettier --write "src/**/*.ts"',"format:check":'prettier --check "src/**/*.ts"'},keywords:["visa","checkout","mcp","ai-agent","payments","click-to-pay","usdc","stablecoin"],author:"Visa Crypto Labs",license:"SEE LICENSE IN LICENSE",dependencies:{"@modelcontextprotocol/sdk":"^1.0.0",commander:"^12.1.0",zod:"^3.23.0"},devDependencies:{"@visa-cli/tools":"workspace:*","@changesets/changelog-git":"^0.2.1","@changesets/cli":"^2.30.0","@types/jest":"^30.0.0","@types/node":"^25.6.0","@typescript-eslint/eslint-plugin":"^8.56.1","@typescript-eslint/parser":"^8.56.1","@types/express":"^5.0.0",esbuild:"^0.27.4",express:"^4.21.0",eslint:"^10.0.2","eslint-config-prettier":"^10.1.8",jest:"^29.7.0",prettier:"^3.8.1","ts-jest":"^29.2.0",typescript:"^5.7.0"},engines:{node:">=18.0.0"},files:["bin/visa-cli.js","dist/","native/visa-keychain.m","README.md","LICENSE"]}});var Xr=require("@modelcontextprotocol/sdk/server/index.js"),Jr=require("@modelcontextprotocol/sdk/server/stdio.js"),Q=require("@modelcontextprotocol/sdk/types.js");Rt();var un=/^(\d+)\.(\d+)\.(\d+)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;function rt(r,e){let t=Qt(r),n=Qt(e);if(!t||!n)return!1;for(let s=0;s<3;s++)if(t.main[s]!==n.main[s])return t.main[s]>n.main[s];return t.pre&&!n.pre?!1:!t.pre&&n.pre?!0:!t.pre&&!n.pre?!1:ln(t.pre,n.pre)>0}function Qt(r){if(typeof r!="string")return null;let t=r.trim().replace(/^v/,"").match(un);return t?{main:[Number(t[1]),Number(t[2]),Number(t[3])],pre:t[4]??null}:null}function ln(r,e){let t=r.split("."),n=e.split("."),s=Math.max(t.length,n.length);for(let a=0;a<s;a++){if(a>=t.length)return-1;if(a>=n.length)return 1;let i=t[a],o=n[a],c=/^\d+$/.test(i),l=/^\d+$/.test(o);if(c&&l){let u=Number(i)-Number(o);if(u!==0)return u}else{if(c)return-1;if(l)return 1;if(i<o)return-1;if(i>o)return 1}}return 0}function nt(){return!!(er(process.env.VISA_CLI_NO_UPDATE_CHECK)||er(process.env.CI)||process.env.NODE_ENV==="test")}function er(r){if(r===void 0)return!1;let e=r.trim().toLowerCase();return!(e===""||e==="0"||e==="false"||e==="no"||e==="off")}var At="1.1.1",st=class{constructor(e){this.getSessionToken=e;this.baseUrl=process.env.VISA_AUTH_URL||"https://auth.visacli.sh"}getSessionToken;baseUrl;lastSignals={};parseServerSignals(e){if(this.lastSignals={},!nt()){let n=e.headers.get("X-Latest-Version"),s=e.headers.get("X-Update-Message");n&&rt(n,At)&&(this.lastSignals.updateAvailable={version:n,message:s||`Update available: v${n}. Run: npm install -g @visa/cli && visa-cli setup`})}let t=e.headers.get("X-Feedback-Prompt");if(t)try{this.lastSignals.feedbackPrompt=JSON.parse(t)}catch{}}getClientVersion(){return At}async request(e,t,n,s,a){let i=await this.getSessionToken();if(!i)throw new Error("Not logged in. Sign up at https://visacli.sh or run: visa-cli setup");let o={Authorization:`Bearer ${i}`};a&&(e==="GET"?o["X-User-Context"]=a.replace(/[\r\n\0]/g," ").slice(0,1e3):n={...n||{},user_context:a}),n&&(o["Content-Type"]="application/json");let c;try{c=await Et(`${this.baseUrl}${t}`,{method:e,headers:{...o,"X-Visa-CLI-Version":At},body:n?JSON.stringify(n):void 0,timeoutMs:s})}catch(u){throw u.name==="AbortError"||u.message?.includes("aborted")?new Error("The request timed out. The server may be under heavy load. Please try again."):new Error("Cannot reach the Visa CLI server. Check your internet connection and try again.")}if(this.parseServerSignals(c),c.status===401)throw new Error("Your session has expired. Run: visa-cli setup");if(c.status===429){let u=c.headers.get("Retry-After")||"3";throw new Error(`Rate limited \u2014 wait ${u}s. Tip: use the batch tool to combine multiple requests into one.`)}if(c.status===503)throw new Error("Visa CLI is temporarily unavailable. Check https://visacli.sh for status.");let l;try{l=await c.json()}catch{throw c.status===500?new Error(`Server error on ${t}. Try again or check https://visacli.sh for status.`):new Error(`Unexpected response from ${t}. Try again.`)}if(!c.ok)throw c.status===500?new Error(`Server error on ${t}. Try again or check https://visacli.sh for status.`):new Error(l?.error||`Request failed (${c.status}). Try again.`);return l}async pay(e,t){return this.request("POST","/v1/pay",e,void 0,t)}async shortcut(e,t,n,s){return this.request("POST",`/v1/shortcuts/${encodeURIComponent(e)}`,t,n,s)}async batch(e,t,n){return this.request("POST","/v1/batch",e,t,n)}async catalogSearch(e,t){let n=new URLSearchParams;e&&n.set("q",e),t&&n.set("category",t);let s=n.toString();return this.request("GET",`/v1/catalog${s?`?${s}`:""}`)}async catalogTool(e){try{return await this.request("GET",`/v1/catalog/${encodeURIComponent(e)}`)}catch{return null}}async paymentPreview(e,t){return this.request("POST","/v1/payment-preview",e,void 0,t)}async getStatus(e){return this.request("GET","/v1/status",void 0,void 0,e)}async getTransactions(e){return this.request("GET","/v1/transactions",void 0,void 0,e)}async updateSpendingControls(e,t){return this.request("POST","/v1/spending-controls",e,void 0,t)}async removeCard(e,t,n){return this.request("DELETE",`/v1/cards/${encodeURIComponent(String(e))}`,t,void 0,n)}async setDefaultCard(e,t,n){return this.request("POST",`/v1/cards/${encodeURIComponent(String(e))}/default`,t,void 0,n)}async getAttestationChallenge(){return this.request("GET","/v1/attestation-challenge")}async registerAttestationKey(e){return this.request("POST","/v1/attestation-key",{publicKey:e})}async logout(e,t){return this.request("POST","/v1/logout",e,void 0,t)}async feedback(e,t,n){return this.request("POST","/v1/feedback",{message:e,...t&&{transaction_id:t}},void 0,n)}async feedSubmit(e){return this.request("POST","/v1/feed",e)}async feedList(e){let t=new URLSearchParams;e?.tab&&t.set("tab",e.tab),e?.limit&&t.set("limit",String(e.limit)),e?.offset&&t.set("offset",String(e.offset));let n=t.toString();return this.request("GET",`/v1/feed${n?"?"+n:""}`)}async feedVote(e,t){return this.request("POST",`/v1/feed/${encodeURIComponent(e)}/vote`,{direction:t})}async feedApprove(e){return this.request("POST",`/v1/feed/${encodeURIComponent(e)}/approve`)}async feedDelete(e){return this.request("DELETE",`/v1/feed/${encodeURIComponent(e)}`)}async feedPending(){return this.request("GET","/v1/feed/pending")}async submitFeedback(e,t,n){return this.request("POST","/v1/feedback",{message:e,...t&&{transaction_id:t}},void 0,n)}async getFeedback(e,t){let n=new URLSearchParams;e&&n.set("limit",String(e));let s=n.toString();return this.request("GET",`/v1/feedback${s?"?"+s:""}`,void 0,void 0,t)}async submitRatedFeedback(e){return this.request("POST","/v1/feedback",e)}};var $t=require("child_process"),ir=require("util"),or=A(require("crypto")),P=A(require("fs")),cr=A(require("os")),B=A(require("path"));var L=A(require("fs")),Nt=A(require("path")),tr=A(require("os")),Ct=Nt.join(tr.homedir(),".visa-mcp"),ze=Nt.join(Ct,"mcp-server.log"),dn=5*1024*1024,Ot=null;function pn(){L.existsSync(Ct)||L.mkdirSync(Ct,{recursive:!0,mode:448})}function mn(){if(!Ot){if(pn(),L.existsSync(ze)&&L.statSync(ze).size>dn){let e=ze+".1";L.existsSync(e)&&L.unlinkSync(e),L.renameSync(ze,e)}Ot=L.createWriteStream(ze,{flags:"a"})}return Ot}function at(r,...e){let t=new Date().toISOString(),n=e.map(a=>typeof a=="string"?a:JSON.stringify(a,null,2)).join(" "),s=`[${t}] [${r}] ${n}
3
3
  `;process.stderr.write(s),mn().write(s)}var p={debug:(...r)=>at("DEBUG",...r),info:(...r)=>at("INFO",...r),warn:(...r)=>at("WARN",...r),error:(...r)=>at("ERROR",...r)};var it=(0,ir.promisify)($t.execFile),ot=B.join(cr.homedir(),".visa-mcp","bin"),de=B.join(ot,"Visa CLI"),fn=B.join(__dirname,"..","native"),rr="5",nr=B.join(ot,"visa-keychain.version"),sr=B.join(ot,"visa-keychain.sha256");function ar(r){let e=P.readFileSync(r);return or.createHash("sha256").update(e).digest("hex")}async function ur(){try{if(P.readFileSync(nr,"utf-8").trim()===rr&&P.existsSync(de)){let n=P.readFileSync(sr,"utf-8").trim();if(ar(de)!==n)p.warn("binary:hash-mismatch",{message:"Binary hash mismatch \u2014 possible tampering detected. Recompiling from source."}),P.unlinkSync(de);else return de}}catch{}let r=B.join(fn,"visa-keychain.m");if(P.existsSync(r)||(r=B.resolve(__dirname,"..","..","native","visa-keychain.m")),P.existsSync(r)||(r=B.resolve(__dirname,"..","native","visa-keychain.m")),!P.existsSync(r))throw new Error("visa-keychain.m source not found. Reinstall Visa CLI.");P.mkdirSync(ot,{recursive:!0,mode:448});try{await it("clang",["-framework","Security","-framework","LocalAuthentication","-framework","Foundation","-framework","AppKit","-o",de,r],{timeout:3e4})}catch(t){throw t.code==="ENOENT"?new Error("Xcode Command Line Tools required. Install: xcode-select --install"):t}let e=ar(de);return P.writeFileSync(sr,e,{mode:384}),P.writeFileSync(nr,rr,{mode:384}),de}async function hn(r){let e=await ur(),t;try{t=(await it(e,r,{timeout:6e4})).stdout}catch(a){t=a.stdout||"";let i=t.trim();throw i.startsWith("ERROR:")?new Error(i.slice(6)):new Error(a.stderr?.trim()||a.message||"Unknown error")}let n=t.trim();if(n.startsWith("OK:"))return n.slice(3);if(n==="OK")return;let s=n.startsWith("ERROR:")?n.slice(6):"Unknown error";throw new Error(s)}var Pt=null;function Mt(){return process.env.VISA_MOCK_TOUCHID==="true"?!0:process.platform!=="darwin"?!1:Pt!==null?Pt:(Pt=!0,!0)}var lr="visa-cli",dr="attestation-key";async function gn(){try{let{stdout:r}=await it("security",["find-generic-password","-s",lr,"-a",dr,"-w"],{timeout:5e3});return r.trim()||null}catch{return null}}async function pr(r,e){if(process.env.VISA_MOCK_TOUCHID==="true")return Promise.resolve("mock-ecdsa-signature-for-testing");let t=await gn();if(!t)throw new Error("Attestation key not found. Run setup to generate a new key.");let n=await ur(),s=["sign",r];return e&&s.push(e),new Promise((a,i)=>{let o=(0,$t.execFile)(n,s,{timeout:6e4},(c,l)=>{let u=(l||"").trim();if(c){u.startsWith("ERROR:")?i(new Error(u.slice(6))):i(new Error(c.stderr?.trim()||c.message||"Unknown error"));return}u.startsWith("OK:")?a(u.slice(3)):i(new Error(u.startsWith("ERROR:")?u.slice(6):"Unknown error"))});o.stdin.write(t),o.stdin.end()})}async function mr(){try{await it("security",["delete-generic-password","-s",lr,"-a",dr],{timeout:5e3})}catch{}try{await hn(["delete-key"])}catch{}}var yr=require("child_process"),_r=require("util"),ee=A(require("fs")),vr=A(require("os")),jt=A(require("path")),ae=(0,_r.promisify)(yr.execFile),Lt=jt.join(vr.homedir(),".visa-mcp"),ct=jt.join(Lt,"session-token"),ie="visa-cli",ut="session-token",lt="rc-access";async function fr(){try{let{stdout:r}=await ae("security",["find-generic-password","-s",ie,"-a",ut,"-w"],{timeout:5e3});return r.trim()||null}catch{return null}}async function hr(r){try{try{await ae("security",["delete-generic-password","-s",ie,"-a",ut],{timeout:5e3})}catch{}return await ae("security",["add-generic-password","-s",ie,"-a",ut,"-w",r],{timeout:5e3}),!0}catch{return!1}}async function gr(){try{await ae("security",["delete-generic-password","-s",ie,"-a",ut],{timeout:5e3})}catch{}}async function _n(){try{let{stdout:r}=await ae("security",["find-generic-password","-s",ie,"-a",lt,"-w"],{timeout:5e3});return r.trim()||null}catch{return null}}async function vn(r){try{try{await ae("security",["delete-generic-password","-s",ie,"-a",lt],{timeout:5e3})}catch{}await ae("security",["add-generic-password","-s",ie,"-a",lt,"-w",r],{timeout:5e3})}catch{}}async function wn(){try{await ae("security",["delete-generic-password","-s",ie,"-a",lt],{timeout:5e3})}catch{}}function bn(r){ee.mkdirSync(Lt,{recursive:!0,mode:448}),ee.writeFileSync(ct,r,{mode:384})}function xn(){try{return ee.readFileSync(ct,"utf-8").trim()||null}catch{return null}}var M=class{static async getSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN==="true")return Promise.resolve("mock-session-token-for-testing");let e=await fr();if(e)return e;let t=xn();return t?(await hr(t),t):null}static async saveSessionToken(e){if(process.env.VISA_MOCK_KEYCHAIN==="true")return;if(await hr(e)){if(await fr()===e){try{ee.unlinkSync(ct)}catch{}return}await gr()}if(bn(e),await this.getSessionToken()!==e)throw new Error("Failed to persist session token. "+(process.platform==="darwin"?'Check Keychain Access permissions for "visa-cli".':`Ensure ${Lt} is writable.`))}static async getRcAccessToken(){return process.env.VISA_MOCK_KEYCHAIN==="true"?"mock-rc-token-for-testing":_n()}static async saveRcAccessToken(e){process.env.VISA_MOCK_KEYCHAIN!=="true"&&await vn(e)}static async deleteSessionToken(){if(process.env.VISA_MOCK_KEYCHAIN!=="true"){await gr();try{ee.unlinkSync(ct)}catch{}}}static async clearAll(){await this.deleteSessionToken(),await wn()}};var dt={generate_image:{intro:"Generate an AI image.",tiers:{balanced:{toolId:"fal-flux-pro",priceCents:4,notes:"FLUX Pro v1.1, 1K, ~10s (DEFAULT \u2014 good quality/speed tradeoff)"},fast:{toolId:"fal-flux-schnell",priceCents:1,notes:"FLUX Schnell, 1K, ~3s (drafts, iteration, cheapest)"},pro:{toolId:"fal-flux-pro-ultra",priceCents:6,notes:"FLUX Pro Ultra, 2K, ~30s (hero images, detail)"},text_heavy:{toolId:"fal-ideogram-v2",priceCents:8,notes:"Ideogram V2 \u2014 best when the image contains rendered text/logos"},vector:{toolId:"fal-recraft-v3",priceCents:5,notes:"Recraft V3 \u2014 vector/flat/illustration styles"}},guidance:"If the user didn't specify a tier, pick 'balanced' unless the prompt clearly signals otherwise (text \u2192 text_heavy, logo/icon \u2192 vector, quick test \u2192 fast, hero/print \u2192 pro).",inputProperties:{prompt:{type:"string",description:"Text description of the image to generate."},aspect_ratio:{type:"string",description:'Aspect ratio, e.g. "16:9", "1:1", "9:16".',default:"16:9"}},required:["prompt"]},generate_video:{intro:"Generate an AI video from a text prompt.",tiers:{balanced:{toolId:"fal-minimax-video",priceCents:15,notes:"MiniMax \u2014 good quality/price balance (DEFAULT)"},fast:{toolId:"fal-wan-video",priceCents:10,notes:"Wan \u2014 cheapest, shorter clips"},pro:{toolId:"fal-kling-video",priceCents:20,notes:"Kling \u2014 highest quality, cinematic"}},guidance:"Show the tier menu with prices unless the user specified one. Videos take 60-180s to generate.",inputProperties:{prompt:{type:"string",description:"Text description of the video scene."},aspect_ratio:{type:"string",description:'Aspect ratio, e.g. "16:9" or "9:16".',default:"16:9"}},required:["prompt"]},generate_music:{intro:"Generate an original music track from a prompt.",tiers:{suno:{toolId:"suno-music",priceCents:10,notes:"Suno v4 \u2014 songs with vocals, lyrics, full arrangement"}},guidance:"Takes ~60-90s. Returns an audio URL the user can play.",inputProperties:{prompt:{type:"string",description:"Musical style / mood / lyrics hint."},instrumental:{type:"boolean",description:"True for instrumental (no vocals), false for vocal track.",default:!1}},required:["prompt"]},generate_audio:{intro:"Generate speech or sound effects.",tiers:{tts:{toolId:"fal-metavoice",priceCents:3,notes:"MetaVoice \u2014 high-quality TTS from text"},sfx:{toolId:"fal-stable-audio",priceCents:4,notes:"Stable Audio \u2014 sound effects and ambient from a prompt"}},guidance:'Pick "tts" for spoken words, "sfx" for music-beds/effects/ambient.',inputProperties:{prompt:{type:"string",description:"Text to speak (tts) or description of sound (sfx)."}},required:["prompt"]},generate_3d:{intro:"Generate a 3D model from a text description.",tiers:{trellis:{toolId:"fal-trellis-3d",priceCents:8,notes:"Trellis \u2014 fast text-to-3D, returns a GLB mesh URL"}},guidance:"Takes ~30-60s. Returns a downloadable 3D mesh URL.",inputProperties:{prompt:{type:"string",description:"Description of the 3D object."}},required:["prompt"]},upscale_image:{intro:"Upscale an image to higher resolution.",tiers:{aura:{toolId:"fal-aura-sr",priceCents:3,notes:"Aura SR \u2014 default; preserves detail without hallucination"}},guidance:"Pass the existing image URL. Returns an upscaled version.",inputProperties:{image_url:{type:"string",description:"URL of the image to upscale."}},required:["image_url"]},transcribe_audio:{intro:"Transcribe speech in an audio/video URL to text.",tiers:{whisper:{toolId:"fal-whisper",priceCents:2,notes:"OpenAI Whisper \u2014 fast, multilingual"}},guidance:"Pass the URL. Returns the transcript text.",inputProperties:{audio_url:{type:"string",description:"URL of the audio or video file to transcribe."}},required:["audio_url"]},run_llm:{intro:"Run a text prompt through an LLM (OpenRouter). Token-metered \u2014 prices below are per 1M input/output tokens. Typical 500-in/500-out prompts cost 1\u20139\xA2 depending on model.",tiers:{fast:{toolId:"or-gpt-4o-mini",priceCents:1,notes:"GPT-4o Mini \u2014 $0.15/M in \xB7 $0.60/M out. Fastest, cheapest, good general-purpose (DEFAULT)"},reasoning:{toolId:"or-claude-sonnet",priceCents:9,notes:"Claude 3.5 Sonnet \u2014 $3.00/M in \xB7 $15.00/M out. Strong reasoning, long-context. ~20x pricier than `fast`."},deep_reasoning:{toolId:"or-deepseek-r1",priceCents:2,notes:"DeepSeek R1 \u2014 $0.55/M in \xB7 $2.19/M out. Deep chain-of-thought reasoning, mid-range pricing."},search:{toolId:"or-perplexity-sonar",priceCents:1,notes:"Perplexity Sonar \u2014 $1.00/M in \xB7 $1.00/M out. Search-augmented, web-grounded with citations."},open_source:{toolId:"or-llama-70b",priceCents:1,notes:"Llama 3.3 70B \u2014 $0.30/M in \xB7 $0.40/M out. Open-source large model."},coding:{toolId:"or-deepseek-chat",priceCents:1,notes:"DeepSeek Chat V3 \u2014 $0.30/M in \xB7 $0.88/M out. Strong at code generation."}},guidance:"Pick based on the user's need: fast (most questions, cheapest), reasoning (complex analysis \u2014 WARN user it's ~$0.09/call), search (questions about current events), coding (code generation), deep_reasoning (hard math/logic problems).",inputProperties:{prompt:{type:"string",description:"The user query."},system_prompt:{type:"string",description:"Optional system prompt to set model behavior."},max_tokens:{type:"number",description:"Maximum output tokens.",default:1024,minimum:1,maximum:8192},temperature:{type:"number",description:"Sampling temperature \u2014 0 is deterministic, higher is more creative.",default:.7,minimum:0,maximum:2}},required:["prompt"]}};function We(){return process.env.VISA_SPECIFIC_TOOLS!=="false"}function Be(){return process.env.VISA_META_TOOLS!=="false"}function Ze(){return process.env.VISA_DISCOVER_TOOLS!=="false"}function wr(r){let e=dt[r];if(!e)throw new Error(`Unknown meta-tool: ${r}`);let t=[e.intro,"","Tiers:"];for(let[n,s]of Object.entries(e.tiers)){let a=`$${(s.priceCents/100).toFixed(2)}`;t.push(` - ${n.padEnd(15)} ${a.padStart(6)} ${s.notes}`)}return t.push("",e.guidance),t.join(`
4
4
  `)}function br(r){let e=dt[r];if(!e)throw new Error(`Unknown meta-tool: ${r}`);let t=Object.keys(e.tiers);return{type:"object",properties:{tier:{type:"string",enum:t,default:t[0],description:`Quality/style tier. Default: ${t[0]}.`},...e.inputProperties},required:e.required??[]}}function pt(r,e){if(!pe.includes(r))return r;let t=dt[r];if(!t)return r;let n=Object.keys(t.tiers),s=e||n[0],a=t.tiers[s];if(!a)throw new Error(`Unknown tier '${s}' for ${r}. Valid tiers: ${n.join(", ")}`);return a.toolId}async function xr(r,e,t){let n=pt(r,e.tier),{tier:s,...a}=e;return O.executeTool({tool_id:n,...a},t)}var pe=Object.keys(dt);var Ke=A(require("crypto")),mt=require("child_process"),Z=A(require("fs")),ft=A(require("os")),ht=A(require("path")),gt=process.env.VISA_AUTH_URL||"https://auth.visacli.sh",T=new st(()=>M.getSessionToken()),kn=["generate_image","generate_video","generate_music","generate_audio","generate_3d","upscale_image","transcribe_audio","run_llm"],kr=["","","You're ready to go! Try:","","Core:",'\u2022 "Show my account status" \u2192 get_status','\u2022 "List my enrolled cards" \u2192 get_cards','\u2022 "Show my recent transactions" \u2192 transaction_history','\u2022 "Set my daily limit to $50" \u2192 update_spending_controls','\u2022 "Pay https://example.com/checkout" \u2192 pay','\u2022 "Generate 3 variations in parallel" \u2192 batch',"","Fast shortcuts:",'\u2022 "Generate an image of a sunset over Tokyo" \u2192 generate_image_card (~$0.06)','\u2022 "Make a fast thumbnail: minimalist cat logo" \u2192 generate_image_fast_card (~$0.04)','\u2022 "Make a 4-second video of a penguin juggling" \u2192 generate_video_tempo_card (~$0.30)','\u2022 "Make a song about coding late at night" \u2192 generate_music_tempo_card (~$0.10)','\u2022 "Check the status of my music job" \u2192 check_music_status_tempo_card','\u2022 "What is ETH on Base trading at?" \u2192 query_onchain_prices_card (~$0.02)','\u2022 "Explore stablecoin inflows on Base" \u2192 allium_explorer_card','\u2022 "Open the latest Allium result set" \u2192 allium_explorer_results_card','\u2022 "Show pxlwall campaign insights" \u2192 pxlwall_card',"","Category tools:",...kn.map(r=>`\u2022 "${r.replace(/_/g," ")}" \u2192 ${r}`),"","Tool catalog:",'\u2022 "Find an image upscaler" \u2192 discover_tools','\u2022 "Run fal-aura-sr on this URL" \u2192 execute_tool'].join(`
5
5
  `);function D(r){if(!r||typeof r!="string"||process.env.VISA_SUPPRESS_BROWSER==="true")return;let e;try{e=new URL(r)}catch{return}if(e.protocol!=="https:"&&e.protocol!=="http:")return;let t=e.toString(),n=ft.platform();n==="darwin"?(0,mt.execFile)("open",[t]):n==="win32"?(0,mt.execFile)("cmd",["/c","start","",t]):(0,mt.execFile)("xdg-open",[t])}async function C(r,e,t,n){if(!Mt()){p.warn("attestation:unavailable",{context:r});return}p.info("attestation:attempt",{context:r,amount:e,merchant:t});try{let{nonce:s}=await T.getAttestationChallenge(),a=Buffer.from(JSON.stringify({nonce:s,amount:e,merchant:t,context:r})).toString("base64");p.info("touchid:prompt",{context:r,amount:e,merchant:t});let i=await pr(a,n);return p.info("attestation:success",{context:r,amount:e,merchant:t}),{signature:i,nonce:s,amount:e,merchant:t}}catch(s){throw p.error("attestation:failure",{context:r,amount:e,merchant:t,error:s.message}),s}}async function z(r,e,t){let n=await T.paymentPreview({tool:r,url:e},t);if(!n||!n.merchantName||!n.amount||n.amount<=0)throw new Error("Could not determine payment amount and merchant. Try again.");if(!Number.isFinite(n.amount)||n.amount<0||n.amount>999999)throw new Error(`Invalid payment amount: ${n.amount}. Payment rejected for safety.`);return n}function G(r){if(r.pricingMode==="max-cap"){let e=typeof r.estimatedAmount=="number"&&r.estimatedAmount>0?` (estimated $${r.estimatedAmount.toFixed(2)})`:"";return`pay up to $${r.amount.toFixed(2)} to ${r.merchantName}${e}`}return`pay $${r.amount.toFixed(2)} to ${r.merchantName}`}function Sr(){return ht.join(ft.homedir(),".visa-mcp","allium-results")}var Tn=16*1024,Sn=50*1024*1024,In=10;function En(r){return r.replace(/[^A-Za-z0-9_\-]/g,"_").slice(0,128)}function Rn(r,e){let t=Sr();Z.mkdirSync(t,{recursive:!0});let n=En(r),s=ht.join(t,`${n}.csv`);Z.writeFileSync(s,e);let a=Buffer.byteLength(e),i=e.split(`
@@ -13,7 +13,7 @@
13
13
 
14
14
  ${n}
15
15
 
16
- Use execute_tool with the tool id and required params to run any of these.`}],_tools:t}}catch(e){throw p.error("catalog:discover:error",{error:e.message}),new Error(`Failed to search tool catalog: ${e.message}`)}}async function os(r,e){let{tool_id:t,params:n,...s}=r,a=n||s;if(!t)throw new Error("tool_id is required. Use discover_tools first to find available tools.");p.info("catalog:execute",{tool:t});let i=await z(t,void 0,e);p.info("payment:attempt",{tool:t,amount:i.amount,merchant:i.merchantName});try{let o=await C(t,i.amount,i.merchantName,G(i)),c=await T.shortcut(t,{...a,attestation:o},12e4,e);if(p.info("payment:success",{tool:t,amount:i.amount,merchant:i.merchantName}),c.urls?.length){c.urls.forEach(u=>D(u));let l=c.mediaType||(c.urls[0]?.match(/\.(mp4|webm|mov)/)?"video":"image");Ye({prompt:a.prompt||`${t} execution`,tool:t,mediaUrl:c.urls[0],mediaType:l,cost:c.amount??i.amount,transactionId:c.transactionId,userContext:e})}return c}catch(o){throw p.error("payment:failure",{tool:t,amount:i.amount,merchant:i.merchantName,error:o.message}),o}}var O=class{static async getStatus(e){return Gn(e)}static async pay(e,t){return On(e,t)}static async getCards(e){return Kn(e)}static async transactionHistory(e){return Yn(e)}static async feedback(e,t){return Xn(e,t)}static async updateSpendingControls(e,t){return Jn(e,t)}static async reset(e,t){return ss(e,t)}static async login(e){return rs(e)}static async addCard(e){return ns(e)}static async removeCard(e,t){return es(e,t)}static async setDefaultCard(e,t){return ts(e,t)}static async batch(e,t){return Zn(e,t)}static async discoverTools(e){return is(e)}static async executeTool(e,t){return os(e,t)}static async shortcut(e,t,n){switch(e){case"generate_image_card":return Cn(t,n);case"generate_image_fast_card":return Nn(t,n);case"generate_video_tempo_card":return Pn(t,n);case"generate_music_tempo_card":return $n(t,n);case"check_music_status_tempo_card":return Mn(t,n);case"query_onchain_prices_card":return jn(t,n);case"allium_explorer_card":return Ln(t,n);case"allium_explorer_results_card":return qn(t,n);case"pxlwall_card":return Dn(t,n);default:{p.info("payment:attempt",{tool:e});try{let s=await C(e,0,""),a=await T.shortcut(e,{...t,attestation:s},void 0,n);return p.info("payment:success",{tool:e}),a.urls?.length&&a.urls.forEach(i=>D(i)),a}catch(s){throw p.error("payment:failure",{tool:e,error:s.message}),s}}}}static async submitFeedback(e,t,n){p.info("feedback:submit",{length:e.length});try{let s=await T.submitFeedback(e,t,n);return p.info("feedback:submitted",{message:"Feedback received"}),s}catch(s){let a=s instanceof Error?s.message:"Unknown error";throw p.error("feedback:error",{error:a}),s}}static async getFeedback(e,t){p.info("feedback:list",{limit:e||20});try{let n=await T.getFeedback(e,t);return p.info("feedback:listed",{count:n?.feedback?.length||0}),n}catch(n){let s=n instanceof Error?n.message:"Unknown error";throw p.error("feedback:error",{error:s}),n}}};var qt=new Set(["generate_image_card","generate_image_fast_card","generate_video_tempo_card","generate_music_tempo_card","check_music_status_tempo_card","query_onchain_prices_card","allium_explorer_card","allium_explorer_results_card","pxlwall_card"]),Ut=new Set(["discover_tools","execute_tool"]),cs=new Set(pe);function Er(r){return qt.has(r)&&!We()?"VISA_SPECIFIC_TOOLS":Ut.has(r)&&!Ze()?"VISA_DISCOVER_TOOLS":cs.has(r)&&!Be()?"VISA_META_TOOLS":null}var yt=A(require("fs")),Rr=A(require("path")),Ar=A(require("os"));var Dt=Rr.join(Ar.homedir(),".visa-mcp"),Xe=class{static ensureConfigDir(){yt.existsSync(Dt)||yt.mkdirSync(Dt,{recursive:!0,mode:448})}static getConfigDir(){return Dt}static TOOL_STATES={login:!0,get_status:!0,get_cards:!0,add_card:!0,pay:!0,transaction_history:!0,update_spending_controls:!0,enroll_device:!1,verify_otp:!1,reset:!0,batch:!0,generate_x402_image:!1,browser_launch:!1,browser_navigate:!1,browser_snapshot:!1,browser_click:!1,browser_type:!1,browser_scroll:!1,generate_music_card:!1,generate_image_card:!0,query_onchain_prices_card:!0,generate_music_tempo_card:!0,check_music_status_tempo_card:!0,generate_image_fast_card:!0,pxlwall_card:!1,generate_video_tempo_card:!0};static loadToolStates(){return{...this.TOOL_STATES}}static getDisabledTools(){let e=new Set;for(let[t,n]of Object.entries(this.TOOL_STATES))n||e.add(t);return e}static isToolDisabled(e){return this.TOOL_STATES[e]===!1}};var Vt=["pay","generate_image_card","generate_image_fast_card","generate_video_tempo_card","generate_music_tempo_card","query_onchain_prices_card","allium_explorer_card","allium_explorer_results_card"],us={generate_image_card:"image generation",generate_image_fast_card:"fast image generation",generate_music_tempo_card:"music generation",generate_video_tempo_card:"video generation",query_onchain_prices_card:"onchain price queries",allium_explorer_card:"blockchain data exploration",allium_explorer_results_card:"blockchain data results",pay:"payments"};function ls(r){return us[r]||r}var me=null;async function Or(r){if(me!==null)return me;try{let{transactions:e}=await r.getTransactions();me={};for(let t of e)t.status==="completed"&&(me[t.tool_name]=(me[t.tool_name]||0)+1)}catch{p.warn("feedback-prompting:cache-error",{message:"Failed to fetch transaction history for feedback prompting"}),me={}}return me}function Cr(r,e,t){return Vt.includes(r)?e===0?{_feedback_prompt:{message:`This was your first time using ${ls(r)} \u2014 if you have any thoughts on the experience, I'd be happy to pass them along to the Visa CLI team.`,transaction_id:t}}:e%5===0?{_feedback_hint:{message:"Feedback? Just say how that went.",transaction_id:t}}:{}:{}}var k={};Xt(k,{BRAND:()=>js,DIRTY:()=>fe,EMPTY_PATH:()=>fs,INVALID:()=>g,NEVER:()=>wa,OK:()=>$,ParseStatus:()=>N,Schema:()=>w,ZodAny:()=>ue,ZodArray:()=>se,ZodBigInt:()=>ge,ZodBoolean:()=>ye,ZodBranded:()=>Qe,ZodCatch:()=>Re,ZodDate:()=>_e,ZodDefault:()=>Ee,ZodDiscriminatedUnion:()=>wt,ZodEffects:()=>F,ZodEnum:()=>Se,ZodError:()=>q,ZodFirstPartyTypeKind:()=>_,ZodFunction:()=>xt,ZodIntersection:()=>xe,ZodIssueCode:()=>d,ZodLazy:()=>ke,ZodLiteral:()=>Te,ZodMap:()=>qe,ZodNaN:()=>De,ZodNativeEnum:()=>Ie,ZodNever:()=>W,ZodNull:()=>we,ZodNullable:()=>X,ZodNumber:()=>he,ZodObject:()=>U,ZodOptional:()=>V,ZodParsedType:()=>f,ZodPipeline:()=>et,ZodPromise:()=>le,ZodReadonly:()=>Ae,ZodRecord:()=>bt,ZodSchema:()=>w,ZodSet:()=>Ue,ZodString:()=>ce,ZodSymbol:()=>je,ZodTransformer:()=>F,ZodTuple:()=>Y,ZodType:()=>w,ZodUndefined:()=>ve,ZodUnion:()=>be,ZodUnknown:()=>ne,ZodVoid:()=>Le,addIssueToContext:()=>m,any:()=>Ws,array:()=>Ks,bigint:()=>Ds,boolean:()=>Hr,coerce:()=>va,custom:()=>Ur,date:()=>Vs,datetimeRegex:()=>Lr,defaultErrorMap:()=>te,discriminatedUnion:()=>Qs,effect:()=>da,enum:()=>ca,function:()=>aa,getErrorMap:()=>Pe,getParsedType:()=>K,instanceof:()=>qs,intersection:()=>ea,isAborted:()=>_t,isAsync:()=>$e,isDirty:()=>vt,isValid:()=>oe,late:()=>Ls,lazy:()=>ia,literal:()=>oa,makeIssue:()=>Je,map:()=>na,nan:()=>Us,nativeEnum:()=>ua,never:()=>Zs,null:()=>zs,nullable:()=>ma,number:()=>Vr,object:()=>Ys,objectUtil:()=>Ht,oboolean:()=>_a,onumber:()=>ya,optional:()=>pa,ostring:()=>ga,pipeline:()=>ha,preprocess:()=>fa,promise:()=>la,quotelessJson:()=>ds,record:()=>ra,set:()=>sa,setErrorMap:()=>ms,strictObject:()=>Xs,string:()=>Dr,symbol:()=>Hs,transformer:()=>da,tuple:()=>ta,undefined:()=>Fs,union:()=>Js,unknown:()=>Bs,util:()=>x,void:()=>Gs});var x;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},r.getValidEnumValues=s=>{let a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(let o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(let i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Ht;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ht||(Ht={}));var f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),K=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}};var d=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ds=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),q=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){let l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let s of this.issues)if(s.path.length>0){let a=s.path[0];t[a]=t[a]||[],t[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};q.create=r=>new q(r);var ps=(r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}},te=ps;var Nr=te;function ms(r){Nr=r}function Pe(){return Nr}var Je=r=>{let{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},fs=[];function m(r,e){let t=Pe(),n=Je({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===te?void 0:te].filter(s=>!!s)});r.common.issues.push(n)}var N=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let s of t){if(s.status==="aborted")return g;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let s of t){let a=await s.key,i=await s.value;n.push({key:a,value:i})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return g;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},g=Object.freeze({status:"aborted"}),fe=r=>({status:"dirty",value:r}),$=r=>({status:"valid",value:r}),_t=r=>r.status==="aborted",vt=r=>r.status==="dirty",oe=r=>r.status==="valid",$e=r=>typeof Promise<"u"&&r instanceof Promise;var h;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(h||(h={}));var H=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Pr=(r,e)=>{if(oe(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new q(r.common.issues);return this._error=t,this._error}}};function v(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{let{message:c}=r;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:s}}var w=class{get description(){return this._def.description}_getType(e){return K(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:K(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new N,ctx:{common:e.parent.common,data:e.data,parsedType:K(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if($e(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:K(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Pr(n,s)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:K(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return oe(n)?{value:n.value}:{issues:t.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(n=>oe(n)?{value:n.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:K(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await($e(s)?s:Promise.resolve(s));return Pr(n,a)}refine(e,t){let n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{let i=e(s),o=()=>a.addIssue({code:d.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new F({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return V.create(this,this._def)}nullable(){return X.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this)}promise(){return le.create(this,this._def)}or(e){return be.create([this,e],this._def)}and(e){return xe.create(this,e,this._def)}transform(e){return new F({...v(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new Ee({...v(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new Qe({typeName:_.ZodBranded,type:this,...v(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Re({...v(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return et.create(this,e)}readonly(){return Ae.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},hs=/^c[^\s-]{8,}$/i,gs=/^[0-9a-z]+$/,ys=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_s=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,vs=/^[a-z0-9_-]{21}$/i,ws=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,bs=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,xs=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ks="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ft,Ts=/^(?:(?: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])$/,Ss=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Is=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Es=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Rs=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,As=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mr="((\\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])))",Os=new RegExp(`^${Mr}$`);function jr(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Cs(r){return new RegExp(`^${jr(r)}$`)}function Lr(r){let e=`${Mr}T${jr(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ns(r,e){return!!((e==="v4"||!e)&&Ts.test(r)||(e==="v6"||!e)&&Is.test(r))}function Ps(r,e){if(!ws.test(r))return!1;try{let[t]=r.split(".");if(!t)return!1;let n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function $s(r,e){return!!((e==="v4"||!e)&&Ss.test(r)||(e==="v6"||!e)&&Es.test(r))}var ce=class r extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_type,expected:f.string,received:a.parsedType}),g}let n=new N,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?m(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&m(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")xs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Ft||(Ft=new RegExp(ks,"u")),Ft.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")_s.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")vs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"nanoid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")hs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")gs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ys.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:d.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"regex",code:d.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Lr(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Os.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Cs(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?bs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"duration",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Ns(e.data,a.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Ps(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"jwt",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?$s(e.data,a.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cidr",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Rs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?As.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64url",code:d.invalid_string,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:d.invalid_string,...h.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...h.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...h.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};ce.create=r=>new ce({checks:[],typeName:_.ZodString,coerce:r?.coerce??!1,...v(r)});function Ms(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=Number.parseInt(r.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}var he=class r extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_type,expected:f.number,received:a.parsedType}),g}let n,s=new N;for(let a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Ms(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_finite,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:h.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};he.create=r=>new he({checks:[],typeName:_.ZodNumber,coerce:r?.coerce||!1,...v(r)});var ge=class r extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let n,s=new N;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return m(t,{code:d.invalid_type,expected:f.bigint,received:t.parsedType}),g}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:h.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};ge.create=r=>new ge({checks:[],typeName:_.ZodBigInt,coerce:r?.coerce??!1,...v(r)});var ye=class extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:f.boolean,received:n.parsedType}),g}return $(e.data)}};ye.create=r=>new ye({typeName:_.ZodBoolean,coerce:r?.coerce||!1,...v(r)});var _e=class r extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_type,expected:f.date,received:a.parsedType}),g}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_date}),g}let n=new N,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):x.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};_e.create=r=>new _e({checks:[],coerce:r?.coerce||!1,typeName:_.ZodDate,...v(r)});var je=class extends w{_parse(e){if(this._getType(e)!==f.symbol){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:f.symbol,received:n.parsedType}),g}return $(e.data)}};je.create=r=>new je({typeName:_.ZodSymbol,...v(r)});var ve=class extends w{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:f.undefined,received:n.parsedType}),g}return $(e.data)}};ve.create=r=>new ve({typeName:_.ZodUndefined,...v(r)});var we=class extends w{_parse(e){if(this._getType(e)!==f.null){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:f.null,received:n.parsedType}),g}return $(e.data)}};we.create=r=>new we({typeName:_.ZodNull,...v(r)});var ue=class extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}};ue.create=r=>new ue({typeName:_.ZodAny,...v(r)});var ne=class extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}};ne.create=r=>new ne({typeName:_.ZodUnknown,...v(r)});var W=class extends w{_parse(e){let t=this._getOrReturnCtx(e);return m(t,{code:d.invalid_type,expected:f.never,received:t.parsedType}),g}};W.create=r=>new W({typeName:_.ZodNever,...v(r)});var Le=class extends w{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:f.void,received:n.parsedType}),g}return $(e.data)}};Le.create=r=>new Le({typeName:_.ZodVoid,...v(r)});var se=class r extends w{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==f.array)return m(t,{code:d.invalid_type,expected:f.array,received:t.parsedType}),g;if(s.exactLength!==null){let i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(m(t,{code:i?d.too_big:d.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(m(t,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(m(t,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new H(t,i,t.path,o)))).then(i=>N.mergeArray(n,i));let a=[...t.data].map((i,o)=>s.type._parseSync(new H(t,i,t.path,o)));return N.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}};se.create=(r,e)=>new se({type:r,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...v(e)});function Me(r){if(r instanceof U){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=V.create(Me(n))}return new U({...r._def,shape:()=>e})}else return r instanceof se?new se({...r._def,type:Me(r.element)}):r instanceof V?V.create(Me(r.unwrap())):r instanceof X?X.create(Me(r.unwrap())):r instanceof Y?Y.create(r.items.map(e=>Me(e))):r}var U=class r extends w{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.object){let l=this._getOrReturnCtx(e);return m(l,{code:d.invalid_type,expected:f.object,received:l.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof W&&this._def.unknownKeys==="strip"))for(let l in s.data)i.includes(l)||o.push(l);let c=[];for(let l of i){let u=a[l],y=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new H(s,y,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof W){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of o)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")o.length>0&&(m(s,{code:d.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of o){let y=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new H(s,y,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let y=await u.key,E=await u.value;l.push({key:y,value:E,alwaysSet:u.alwaysSet})}return l}).then(l=>N.mergeObjectSync(n,l)):N.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{let s=this._def.errorMap?.(t,n).message??n.defaultError;return t.code==="unrecognized_keys"?{message:h.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let n of x.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let n of x.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new r({...this._def,shape:()=>t})}deepPartial(){return Me(this)}partial(e){let t={};for(let n of x.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let n of x.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof V;)a=a._def.innerType;t[n]=a}return new r({...this._def,shape:()=>t})}keyof(){return qr(x.objectKeys(this.shape))}};U.create=(r,e)=>new U({shape:()=>r,unknownKeys:"strip",catchall:W.create(),typeName:_.ZodObject,...v(e)});U.strictCreate=(r,e)=>new U({shape:()=>r,unknownKeys:"strict",catchall:W.create(),typeName:_.ZodObject,...v(e)});U.lazycreate=(r,e)=>new U({shape:r,unknownKeys:"strip",catchall:W.create(),typeName:_.ZodObject,...v(e)});var be=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new q(o.ctx.common.issues));return m(t,{code:d.invalid_union,unionErrors:i}),g}if(t.common.async)return Promise.all(n.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a,i=[];for(let c of n){let l={...t,common:{...t.common,issues:[]},parent:null},u=c._parseSync({data:t.data,path:t.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new q(c));return m(t,{code:d.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};be.create=(r,e)=>new be({options:r,typeName:_.ZodUnion,...v(e)});var re=r=>r instanceof ke?re(r.schema):r instanceof F?re(r.innerType()):r instanceof Te?[r.value]:r instanceof Se?r.options:r instanceof Ie?x.objectValues(r.enum):r instanceof Ee?re(r._def.innerType):r instanceof ve?[void 0]:r instanceof we?[null]:r instanceof V?[void 0,...re(r.unwrap())]:r instanceof X?[null,...re(r.unwrap())]:r instanceof Qe||r instanceof Ae?re(r.unwrap()):r instanceof Re?re(r._def.innerType):[],wt=class r extends w{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return m(t,{code:d.invalid_type,expected:f.object,received:t.parsedType}),g;let n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(m(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let a of t){let i=re(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new r({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...v(n)})}};function zt(r,e){let t=K(r),n=K(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&n===f.object){let s=x.objectKeys(e),a=x.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(let o of a){let c=zt(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===f.array&&n===f.array){if(r.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<r.length;a++){let i=r[a],o=e[a],c=zt(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===f.date&&n===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var xe=class extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(_t(a)||_t(i))return g;let o=zt(a.value,i.value);return o.valid?((vt(a)||vt(i))&&t.dirty(),{status:t.value,value:o.data}):(m(n,{code:d.invalid_intersection_types}),g)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};xe.create=(r,e,t)=>new xe({left:r,right:e,typeName:_.ZodIntersection,...v(t)});var Y=class r extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return m(n,{code:d.invalid_type,expected:f.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return m(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...n.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new H(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>N.mergeArray(t,i)):N.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};Y.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Y({items:r,typeName:_.ZodTuple,rest:null,...v(e)})};var bt=class r extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return m(n,{code:d.invalid_type,expected:f.object,received:n.parsedType}),g;let s=[],a=this._def.keyType,i=this._def.valueType;for(let o in n.data)s.push({key:a._parse(new H(n,o,n.path,o)),value:i._parse(new H(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?N.mergeObjectAsync(t,s):N.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof w?new r({keyType:e,valueType:t,typeName:_.ZodRecord,...v(n)}):new r({keyType:ce.create(),valueType:e,typeName:_.ZodRecord,...v(t)})}},qe=class extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return m(n,{code:d.invalid_type,expected:f.map,received:n.parsedType}),g;let s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new H(n,o,n.path,[l,"key"])),value:a._parse(new H(n,c,n.path,[l,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return g;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),o.set(l.value,u.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let c of i){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return g;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),o.set(l.value,u.value)}return{status:t.value,value:o}}}};qe.create=(r,e,t)=>new qe({valueType:e,keyType:r,typeName:_.ZodMap,...v(t)});var Ue=class r extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return m(n,{code:d.invalid_type,expected:f.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(m(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(m(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let a=this._def.valueType;function i(c){let l=new Set;for(let u of c){if(u.status==="aborted")return g;u.status==="dirty"&&t.dirty(),l.add(u.value)}return{status:t.value,value:l}}let o=[...n.data.values()].map((c,l)=>a._parse(new H(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ue.create=(r,e)=>new Ue({valueType:r,minSize:null,maxSize:null,typeName:_.ZodSet,...v(e)});var xt=class r extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return m(t,{code:d.invalid_type,expected:f.function,received:t.parsedType}),g;function n(o,c){return Je({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Pe(),te].filter(l=>!!l),issueData:{code:d.invalid_arguments,argumentsError:c}})}function s(o,c){return Je({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Pe(),te].filter(l=>!!l),issueData:{code:d.invalid_return_type,returnTypeError:c}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof le){let o=this;return $(async function(...c){let l=new q([]),u=await o._def.args.parseAsync(c,a).catch(b=>{throw l.addIssue(n(c,b)),l}),y=await Reflect.apply(i,this,u);return await o._def.returns._def.type.parseAsync(y,a).catch(b=>{throw l.addIssue(s(y,b)),l})})}else{let o=this;return $(function(...c){let l=o._def.args.safeParse(c,a);if(!l.success)throw new q([n(c,l.error)]);let u=Reflect.apply(i,this,l.data),y=o._def.returns.safeParse(u,a);if(!y.success)throw new q([s(u,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:Y.create(e).rest(ne.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||Y.create([]).rest(ne.create()),returns:t||ne.create(),typeName:_.ZodFunction,...v(n)})}},ke=class extends w{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ke.create=(r,e)=>new ke({getter:r,typeName:_.ZodLazy,...v(e)});var Te=class extends w{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};Te.create=(r,e)=>new Te({value:r,typeName:_.ZodLiteral,...v(e)});function qr(r,e){return new Se({values:r,typeName:_.ZodEnum,...v(e)})}var Se=class r extends w{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return m(t,{expected:x.joinValues(n),received:t.parsedType,code:d.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return m(t,{received:t.data,code:d.invalid_enum_value,options:n}),g}return $(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Se.create=qr;var Ie=class extends w{_parse(e){let t=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let s=x.objectValues(t);return m(n,{expected:x.joinValues(s),received:n.parsedType,code:d.invalid_type}),g}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=x.objectValues(t);return m(n,{received:n.data,code:d.invalid_enum_value,options:s}),g}return $(e.data)}get enum(){return this._def.values}};Ie.create=(r,e)=>new Ie({values:r,typeName:_.ZodNativeEnum,...v(e)});var le=class extends w{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return m(t,{code:d.invalid_type,expected:f.promise,received:t.parsedType}),g;let n=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return $(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};le.create=(r,e)=>new le({type:r,typeName:_.ZodPromise,...v(e)});var F=class extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{m(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return g;let c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?g:c.status==="dirty"?fe(c.value):t.value==="dirty"?fe(c.value):c});{if(t.value==="aborted")return g;let o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"?fe(o.value):t.value==="dirty"?fe(o.value):o}}if(s.type==="refinement"){let i=o=>{let c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?g:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!oe(i))return g;let o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>oe(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):g);x.assertNever(s)}};F.create=(r,e,t)=>new F({schema:r,typeName:_.ZodEffects,effect:e,...v(t)});F.createWithPreprocess=(r,e,t)=>new F({schema:e,effect:{type:"preprocess",transform:r},typeName:_.ZodEffects,...v(t)});var V=class extends w{_parse(e){return this._getType(e)===f.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};V.create=(r,e)=>new V({innerType:r,typeName:_.ZodOptional,...v(e)});var X=class extends w{_parse(e){return this._getType(e)===f.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};X.create=(r,e)=>new X({innerType:r,typeName:_.ZodNullable,...v(e)});var Ee=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Ee.create=(r,e)=>new Ee({innerType:r,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});var Re=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return $e(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new q(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new q(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Re.create=(r,e)=>new Re({innerType:r,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});var De=class extends w{_parse(e){if(this._getType(e)!==f.nan){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:f.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}};De.create=r=>new De({typeName:_.ZodNaN,...v(r)});var js=Symbol("zod_brand"),Qe=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},et=class r extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?g:a.status==="dirty"?(t.dirty(),fe(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?g:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:_.ZodPipeline})}},Ae=class extends w{_parse(e){let t=this._def.innerType._parse(e),n=s=>(oe(s)&&(s.value=Object.freeze(s.value)),s);return $e(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};Ae.create=(r,e)=>new Ae({innerType:r,typeName:_.ZodReadonly,...v(e)});function $r(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function Ur(r,e={},t){return r?ue.create().superRefine((n,s)=>{let a=r(n);if(a instanceof Promise)return a.then(i=>{if(!i){let o=$r(e,n),c=o.fatal??t??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!a){let i=$r(e,n),o=i.fatal??t??!0;s.addIssue({code:"custom",...i,fatal:o})}}):ue.create()}var Ls={object:U.lazycreate},_;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(_||(_={}));var qs=(r,e={message:`Input not instance of ${r.name}`})=>Ur(t=>t instanceof r,e),Dr=ce.create,Vr=he.create,Us=De.create,Ds=ge.create,Hr=ye.create,Vs=_e.create,Hs=je.create,Fs=ve.create,zs=we.create,Ws=ue.create,Bs=ne.create,Zs=W.create,Gs=Le.create,Ks=se.create,Ys=U.create,Xs=U.strictCreate,Js=be.create,Qs=wt.create,ea=xe.create,ta=Y.create,ra=bt.create,na=qe.create,sa=Ue.create,aa=xt.create,ia=ke.create,oa=Te.create,ca=Se.create,ua=Ie.create,la=le.create,da=F.create,pa=V.create,ma=X.create,fa=F.createWithPreprocess,ha=et.create,ga=()=>Dr().optional(),ya=()=>Vr().optional(),_a=()=>Hr().optional(),va={string:(r=>ce.create({...r,coerce:!0})),number:(r=>he.create({...r,coerce:!0})),boolean:(r=>ye.create({...r,coerce:!0})),bigint:(r=>ge.create({...r,coerce:!0})),date:(r=>_e.create({...r,coerce:!0}))};var wa=g;var Fr="1.1.1-rc.0",zr=k.object({name:k.string().max(100).nullable(),location:k.string().max(100).nullable(),member_since:k.string()}),Wr=k.object({total_transactions:k.number(),total_spent:k.number(),tools_used:k.record(k.string(),k.number()),last_active:k.string().nullable(),themes:k.array(k.string().max(100)).max(20),recent_prompts:k.array(k.string().max(500)).max(50).optional().default([])}),Br=k.object({daily_remaining:k.number(),daily_limit:k.number()}),ba=k.object({message:k.string().max(500),tool:k.string(),reason:k.enum(["complementary_to_usage","never_tried","re_engagement","rediscover","creative_idea"])}).nullable(),xa=k.object({proactive:ba,reactive:k.record(k.string(),k.array(k.string().max(500)).nullable())}),ka=k.object({user:zr,usage:Wr,budget:Br,suggestions:xa}),Ta=k.object({user:zr,usage:Wr,budget:Br});function Sa(r){let e=ka.safeParse(r);if(e.success)return{full:e.data,partial:null};let t=Ta.safeParse(r);return t.success?{full:null,partial:t.data}:{full:null,partial:null}}function Oe(r){let e=r;for(let t=0;t<5;t++){let n=e.replace(/<[^>]*>/g,"");if(n===e)break;e=n}return e.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"").trim()}var Ia=`You are a creative assistant with Visa CLI \u2014 a toolkit for AI images, music, videos, crypto prices, and payments. Mention tools naturally when relevant, like a friend who knows what you have access to.
16
+ Use execute_tool with the tool id and required params to run any of these.`}],_tools:t}}catch(e){throw p.error("catalog:discover:error",{error:e.message}),new Error(`Failed to search tool catalog: ${e.message}`)}}async function os(r,e){let{tool_id:t,params:n,...s}=r,a=n||s;if(!t)throw new Error("tool_id is required. Use discover_tools first to find available tools.");p.info("catalog:execute",{tool:t});let i=await z(t,void 0,e);p.info("payment:attempt",{tool:t,amount:i.amount,merchant:i.merchantName});try{let o=await C(t,i.amount,i.merchantName,G(i)),c=await T.shortcut(t,{...a,attestation:o},12e4,e);if(p.info("payment:success",{tool:t,amount:i.amount,merchant:i.merchantName}),c.urls?.length){c.urls.forEach(u=>D(u));let l=c.mediaType||(c.urls[0]?.match(/\.(mp4|webm|mov)/)?"video":"image");Ye({prompt:a.prompt||`${t} execution`,tool:t,mediaUrl:c.urls[0],mediaType:l,cost:c.amount??i.amount,transactionId:c.transactionId,userContext:e})}return c}catch(o){throw p.error("payment:failure",{tool:t,amount:i.amount,merchant:i.merchantName,error:o.message}),o}}var O=class{static async getStatus(e){return Gn(e)}static async pay(e,t){return On(e,t)}static async getCards(e){return Kn(e)}static async transactionHistory(e){return Yn(e)}static async feedback(e,t){return Xn(e,t)}static async updateSpendingControls(e,t){return Jn(e,t)}static async reset(e,t){return ss(e,t)}static async login(e){return rs(e)}static async addCard(e){return ns(e)}static async removeCard(e,t){return es(e,t)}static async setDefaultCard(e,t){return ts(e,t)}static async batch(e,t){return Zn(e,t)}static async discoverTools(e){return is(e)}static async executeTool(e,t){return os(e,t)}static async shortcut(e,t,n){switch(e){case"generate_image_card":return Cn(t,n);case"generate_image_fast_card":return Nn(t,n);case"generate_video_tempo_card":return Pn(t,n);case"generate_music_tempo_card":return $n(t,n);case"check_music_status_tempo_card":return Mn(t,n);case"query_onchain_prices_card":return jn(t,n);case"allium_explorer_card":return Ln(t,n);case"allium_explorer_results_card":return qn(t,n);case"pxlwall_card":return Dn(t,n);default:{p.info("payment:attempt",{tool:e});try{let s=await C(e,0,""),a=await T.shortcut(e,{...t,attestation:s},void 0,n);return p.info("payment:success",{tool:e}),a.urls?.length&&a.urls.forEach(i=>D(i)),a}catch(s){throw p.error("payment:failure",{tool:e,error:s.message}),s}}}}static async submitFeedback(e,t,n){p.info("feedback:submit",{length:e.length});try{let s=await T.submitFeedback(e,t,n);return p.info("feedback:submitted",{message:"Feedback received"}),s}catch(s){let a=s instanceof Error?s.message:"Unknown error";throw p.error("feedback:error",{error:a}),s}}static async getFeedback(e,t){p.info("feedback:list",{limit:e||20});try{let n=await T.getFeedback(e,t);return p.info("feedback:listed",{count:n?.feedback?.length||0}),n}catch(n){let s=n instanceof Error?n.message:"Unknown error";throw p.error("feedback:error",{error:s}),n}}};var qt=new Set(["generate_image_card","generate_image_fast_card","generate_video_tempo_card","generate_music_tempo_card","check_music_status_tempo_card","query_onchain_prices_card","allium_explorer_card","allium_explorer_results_card","pxlwall_card"]),Ut=new Set(["discover_tools","execute_tool"]),cs=new Set(pe);function Er(r){return qt.has(r)&&!We()?"VISA_SPECIFIC_TOOLS":Ut.has(r)&&!Ze()?"VISA_DISCOVER_TOOLS":cs.has(r)&&!Be()?"VISA_META_TOOLS":null}var yt=A(require("fs")),Rr=A(require("path")),Ar=A(require("os"));var Dt=Rr.join(Ar.homedir(),".visa-mcp"),Xe=class{static ensureConfigDir(){yt.existsSync(Dt)||yt.mkdirSync(Dt,{recursive:!0,mode:448})}static getConfigDir(){return Dt}static TOOL_STATES={login:!0,get_status:!0,get_cards:!0,add_card:!0,pay:!0,transaction_history:!0,update_spending_controls:!0,enroll_device:!1,verify_otp:!1,reset:!0,batch:!0,generate_x402_image:!1,browser_launch:!1,browser_navigate:!1,browser_snapshot:!1,browser_click:!1,browser_type:!1,browser_scroll:!1,generate_music_card:!1,generate_image_card:!0,query_onchain_prices_card:!0,generate_music_tempo_card:!0,check_music_status_tempo_card:!0,generate_image_fast_card:!0,pxlwall_card:!1,generate_video_tempo_card:!0};static loadToolStates(){return{...this.TOOL_STATES}}static getDisabledTools(){let e=new Set;for(let[t,n]of Object.entries(this.TOOL_STATES))n||e.add(t);return e}static isToolDisabled(e){return this.TOOL_STATES[e]===!1}};var Vt=["pay","generate_image_card","generate_image_fast_card","generate_video_tempo_card","generate_music_tempo_card","query_onchain_prices_card","allium_explorer_card","allium_explorer_results_card"],us={generate_image_card:"image generation",generate_image_fast_card:"fast image generation",generate_music_tempo_card:"music generation",generate_video_tempo_card:"video generation",query_onchain_prices_card:"onchain price queries",allium_explorer_card:"blockchain data exploration",allium_explorer_results_card:"blockchain data results",pay:"payments"};function ls(r){return us[r]||r}var me=null;async function Or(r){if(me!==null)return me;try{let{transactions:e}=await r.getTransactions();me={};for(let t of e)t.status==="completed"&&(me[t.tool_name]=(me[t.tool_name]||0)+1)}catch{p.warn("feedback-prompting:cache-error",{message:"Failed to fetch transaction history for feedback prompting"}),me={}}return me}function Cr(r,e,t){return Vt.includes(r)?e===0?{_feedback_prompt:{message:`This was your first time using ${ls(r)} \u2014 if you have any thoughts on the experience, I'd be happy to pass them along to the Visa CLI team.`,transaction_id:t}}:e%5===0?{_feedback_hint:{message:"Feedback? Just say how that went.",transaction_id:t}}:{}:{}}var k={};Xt(k,{BRAND:()=>js,DIRTY:()=>fe,EMPTY_PATH:()=>fs,INVALID:()=>g,NEVER:()=>wa,OK:()=>$,ParseStatus:()=>N,Schema:()=>w,ZodAny:()=>ue,ZodArray:()=>se,ZodBigInt:()=>ge,ZodBoolean:()=>ye,ZodBranded:()=>Qe,ZodCatch:()=>Re,ZodDate:()=>_e,ZodDefault:()=>Ee,ZodDiscriminatedUnion:()=>wt,ZodEffects:()=>F,ZodEnum:()=>Se,ZodError:()=>q,ZodFirstPartyTypeKind:()=>_,ZodFunction:()=>xt,ZodIntersection:()=>xe,ZodIssueCode:()=>d,ZodLazy:()=>ke,ZodLiteral:()=>Te,ZodMap:()=>qe,ZodNaN:()=>De,ZodNativeEnum:()=>Ie,ZodNever:()=>W,ZodNull:()=>we,ZodNullable:()=>X,ZodNumber:()=>he,ZodObject:()=>U,ZodOptional:()=>V,ZodParsedType:()=>f,ZodPipeline:()=>et,ZodPromise:()=>le,ZodReadonly:()=>Ae,ZodRecord:()=>bt,ZodSchema:()=>w,ZodSet:()=>Ue,ZodString:()=>ce,ZodSymbol:()=>je,ZodTransformer:()=>F,ZodTuple:()=>Y,ZodType:()=>w,ZodUndefined:()=>ve,ZodUnion:()=>be,ZodUnknown:()=>ne,ZodVoid:()=>Le,addIssueToContext:()=>m,any:()=>Ws,array:()=>Ks,bigint:()=>Ds,boolean:()=>Hr,coerce:()=>va,custom:()=>Ur,date:()=>Vs,datetimeRegex:()=>Lr,defaultErrorMap:()=>te,discriminatedUnion:()=>Qs,effect:()=>da,enum:()=>ca,function:()=>aa,getErrorMap:()=>Pe,getParsedType:()=>K,instanceof:()=>qs,intersection:()=>ea,isAborted:()=>_t,isAsync:()=>$e,isDirty:()=>vt,isValid:()=>oe,late:()=>Ls,lazy:()=>ia,literal:()=>oa,makeIssue:()=>Je,map:()=>na,nan:()=>Us,nativeEnum:()=>ua,never:()=>Zs,null:()=>zs,nullable:()=>ma,number:()=>Vr,object:()=>Ys,objectUtil:()=>Ht,oboolean:()=>_a,onumber:()=>ya,optional:()=>pa,ostring:()=>ga,pipeline:()=>ha,preprocess:()=>fa,promise:()=>la,quotelessJson:()=>ds,record:()=>ra,set:()=>sa,setErrorMap:()=>ms,strictObject:()=>Xs,string:()=>Dr,symbol:()=>Hs,transformer:()=>da,tuple:()=>ta,undefined:()=>Fs,union:()=>Js,unknown:()=>Bs,util:()=>x,void:()=>Gs});var x;(function(r){r.assertEqual=s=>{};function e(s){}r.assertIs=e;function t(s){throw new Error}r.assertNever=t,r.arrayToEnum=s=>{let a={};for(let i of s)a[i]=i;return a},r.getValidEnumValues=s=>{let a=r.objectKeys(s).filter(o=>typeof s[s[o]]!="number"),i={};for(let o of a)i[o]=s[o];return r.objectValues(i)},r.objectValues=s=>r.objectKeys(s).map(function(a){return s[a]}),r.objectKeys=typeof Object.keys=="function"?s=>Object.keys(s):s=>{let a=[];for(let i in s)Object.prototype.hasOwnProperty.call(s,i)&&a.push(i);return a},r.find=(s,a)=>{for(let i of s)if(a(i))return i},r.isInteger=typeof Number.isInteger=="function"?s=>Number.isInteger(s):s=>typeof s=="number"&&Number.isFinite(s)&&Math.floor(s)===s;function n(s,a=" | "){return s.map(i=>typeof i=="string"?`'${i}'`:i).join(a)}r.joinValues=n,r.jsonStringifyReplacer=(s,a)=>typeof a=="bigint"?a.toString():a})(x||(x={}));var Ht;(function(r){r.mergeShapes=(e,t)=>({...e,...t})})(Ht||(Ht={}));var f=x.arrayToEnum(["string","nan","number","integer","float","boolean","date","bigint","symbol","function","undefined","null","array","object","unknown","promise","void","never","map","set"]),K=r=>{switch(typeof r){case"undefined":return f.undefined;case"string":return f.string;case"number":return Number.isNaN(r)?f.nan:f.number;case"boolean":return f.boolean;case"function":return f.function;case"bigint":return f.bigint;case"symbol":return f.symbol;case"object":return Array.isArray(r)?f.array:r===null?f.null:r.then&&typeof r.then=="function"&&r.catch&&typeof r.catch=="function"?f.promise:typeof Map<"u"&&r instanceof Map?f.map:typeof Set<"u"&&r instanceof Set?f.set:typeof Date<"u"&&r instanceof Date?f.date:f.object;default:return f.unknown}};var d=x.arrayToEnum(["invalid_type","invalid_literal","custom","invalid_union","invalid_union_discriminator","invalid_enum_value","unrecognized_keys","invalid_arguments","invalid_return_type","invalid_date","invalid_string","too_small","too_big","invalid_intersection_types","not_multiple_of","not_finite"]),ds=r=>JSON.stringify(r,null,2).replace(/"([^"]+)":/g,"$1:"),q=class r extends Error{get errors(){return this.issues}constructor(e){super(),this.issues=[],this.addIssue=n=>{this.issues=[...this.issues,n]},this.addIssues=(n=[])=>{this.issues=[...this.issues,...n]};let t=new.target.prototype;Object.setPrototypeOf?Object.setPrototypeOf(this,t):this.__proto__=t,this.name="ZodError",this.issues=e}format(e){let t=e||function(a){return a.message},n={_errors:[]},s=a=>{for(let i of a.issues)if(i.code==="invalid_union")i.unionErrors.map(s);else if(i.code==="invalid_return_type")s(i.returnTypeError);else if(i.code==="invalid_arguments")s(i.argumentsError);else if(i.path.length===0)n._errors.push(t(i));else{let o=n,c=0;for(;c<i.path.length;){let l=i.path[c];c===i.path.length-1?(o[l]=o[l]||{_errors:[]},o[l]._errors.push(t(i))):o[l]=o[l]||{_errors:[]},o=o[l],c++}}};return s(this),n}static assert(e){if(!(e instanceof r))throw new Error(`Not a ZodError: ${e}`)}toString(){return this.message}get message(){return JSON.stringify(this.issues,x.jsonStringifyReplacer,2)}get isEmpty(){return this.issues.length===0}flatten(e=t=>t.message){let t={},n=[];for(let s of this.issues)if(s.path.length>0){let a=s.path[0];t[a]=t[a]||[],t[a].push(e(s))}else n.push(e(s));return{formErrors:n,fieldErrors:t}}get formErrors(){return this.flatten()}};q.create=r=>new q(r);var ps=(r,e)=>{let t;switch(r.code){case d.invalid_type:r.received===f.undefined?t="Required":t=`Expected ${r.expected}, received ${r.received}`;break;case d.invalid_literal:t=`Invalid literal value, expected ${JSON.stringify(r.expected,x.jsonStringifyReplacer)}`;break;case d.unrecognized_keys:t=`Unrecognized key(s) in object: ${x.joinValues(r.keys,", ")}`;break;case d.invalid_union:t="Invalid input";break;case d.invalid_union_discriminator:t=`Invalid discriminator value. Expected ${x.joinValues(r.options)}`;break;case d.invalid_enum_value:t=`Invalid enum value. Expected ${x.joinValues(r.options)}, received '${r.received}'`;break;case d.invalid_arguments:t="Invalid function arguments";break;case d.invalid_return_type:t="Invalid function return type";break;case d.invalid_date:t="Invalid date";break;case d.invalid_string:typeof r.validation=="object"?"includes"in r.validation?(t=`Invalid input: must include "${r.validation.includes}"`,typeof r.validation.position=="number"&&(t=`${t} at one or more positions greater than or equal to ${r.validation.position}`)):"startsWith"in r.validation?t=`Invalid input: must start with "${r.validation.startsWith}"`:"endsWith"in r.validation?t=`Invalid input: must end with "${r.validation.endsWith}"`:x.assertNever(r.validation):r.validation!=="regex"?t=`Invalid ${r.validation}`:t="Invalid";break;case d.too_small:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at least":"more than"} ${r.minimum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at least":"over"} ${r.minimum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="bigint"?t=`Number must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${r.minimum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly equal to ":r.inclusive?"greater than or equal to ":"greater than "}${new Date(Number(r.minimum))}`:t="Invalid input";break;case d.too_big:r.type==="array"?t=`Array must contain ${r.exact?"exactly":r.inclusive?"at most":"less than"} ${r.maximum} element(s)`:r.type==="string"?t=`String must contain ${r.exact?"exactly":r.inclusive?"at most":"under"} ${r.maximum} character(s)`:r.type==="number"?t=`Number must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="bigint"?t=`BigInt must be ${r.exact?"exactly":r.inclusive?"less than or equal to":"less than"} ${r.maximum}`:r.type==="date"?t=`Date must be ${r.exact?"exactly":r.inclusive?"smaller than or equal to":"smaller than"} ${new Date(Number(r.maximum))}`:t="Invalid input";break;case d.custom:t="Invalid input";break;case d.invalid_intersection_types:t="Intersection results could not be merged";break;case d.not_multiple_of:t=`Number must be a multiple of ${r.multipleOf}`;break;case d.not_finite:t="Number must be finite";break;default:t=e.defaultError,x.assertNever(r)}return{message:t}},te=ps;var Nr=te;function ms(r){Nr=r}function Pe(){return Nr}var Je=r=>{let{data:e,path:t,errorMaps:n,issueData:s}=r,a=[...t,...s.path||[]],i={...s,path:a};if(s.message!==void 0)return{...s,path:a,message:s.message};let o="",c=n.filter(l=>!!l).slice().reverse();for(let l of c)o=l(i,{data:e,defaultError:o}).message;return{...s,path:a,message:o}},fs=[];function m(r,e){let t=Pe(),n=Je({issueData:e,data:r.data,path:r.path,errorMaps:[r.common.contextualErrorMap,r.schemaErrorMap,t,t===te?void 0:te].filter(s=>!!s)});r.common.issues.push(n)}var N=class r{constructor(){this.value="valid"}dirty(){this.value==="valid"&&(this.value="dirty")}abort(){this.value!=="aborted"&&(this.value="aborted")}static mergeArray(e,t){let n=[];for(let s of t){if(s.status==="aborted")return g;s.status==="dirty"&&e.dirty(),n.push(s.value)}return{status:e.value,value:n}}static async mergeObjectAsync(e,t){let n=[];for(let s of t){let a=await s.key,i=await s.value;n.push({key:a,value:i})}return r.mergeObjectSync(e,n)}static mergeObjectSync(e,t){let n={};for(let s of t){let{key:a,value:i}=s;if(a.status==="aborted"||i.status==="aborted")return g;a.status==="dirty"&&e.dirty(),i.status==="dirty"&&e.dirty(),a.value!=="__proto__"&&(typeof i.value<"u"||s.alwaysSet)&&(n[a.value]=i.value)}return{status:e.value,value:n}}},g=Object.freeze({status:"aborted"}),fe=r=>({status:"dirty",value:r}),$=r=>({status:"valid",value:r}),_t=r=>r.status==="aborted",vt=r=>r.status==="dirty",oe=r=>r.status==="valid",$e=r=>typeof Promise<"u"&&r instanceof Promise;var h;(function(r){r.errToObj=e=>typeof e=="string"?{message:e}:e||{},r.toString=e=>typeof e=="string"?e:e?.message})(h||(h={}));var H=class{constructor(e,t,n,s){this._cachedPath=[],this.parent=e,this.data=t,this._path=n,this._key=s}get path(){return this._cachedPath.length||(Array.isArray(this._key)?this._cachedPath.push(...this._path,...this._key):this._cachedPath.push(...this._path,this._key)),this._cachedPath}},Pr=(r,e)=>{if(oe(e))return{success:!0,data:e.value};if(!r.common.issues.length)throw new Error("Validation failed but no issues detected.");return{success:!1,get error(){if(this._error)return this._error;let t=new q(r.common.issues);return this._error=t,this._error}}};function v(r){if(!r)return{};let{errorMap:e,invalid_type_error:t,required_error:n,description:s}=r;if(e&&(t||n))throw new Error(`Can't use "invalid_type_error" or "required_error" in conjunction with custom error map.`);return e?{errorMap:e,description:s}:{errorMap:(i,o)=>{let{message:c}=r;return i.code==="invalid_enum_value"?{message:c??o.defaultError}:typeof o.data>"u"?{message:c??n??o.defaultError}:i.code!=="invalid_type"?{message:o.defaultError}:{message:c??t??o.defaultError}},description:s}}var w=class{get description(){return this._def.description}_getType(e){return K(e.data)}_getOrReturnCtx(e,t){return t||{common:e.parent.common,data:e.data,parsedType:K(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}_processInputParams(e){return{status:new N,ctx:{common:e.parent.common,data:e.data,parsedType:K(e.data),schemaErrorMap:this._def.errorMap,path:e.path,parent:e.parent}}}_parseSync(e){let t=this._parse(e);if($e(t))throw new Error("Synchronous parse encountered promise.");return t}_parseAsync(e){let t=this._parse(e);return Promise.resolve(t)}parse(e,t){let n=this.safeParse(e,t);if(n.success)return n.data;throw n.error}safeParse(e,t){let n={common:{issues:[],async:t?.async??!1,contextualErrorMap:t?.errorMap},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:K(e)},s=this._parseSync({data:e,path:n.path,parent:n});return Pr(n,s)}"~validate"(e){let t={common:{issues:[],async:!!this["~standard"].async},path:[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:K(e)};if(!this["~standard"].async)try{let n=this._parseSync({data:e,path:[],parent:t});return oe(n)?{value:n.value}:{issues:t.common.issues}}catch(n){n?.message?.toLowerCase()?.includes("encountered")&&(this["~standard"].async=!0),t.common={issues:[],async:!0}}return this._parseAsync({data:e,path:[],parent:t}).then(n=>oe(n)?{value:n.value}:{issues:t.common.issues})}async parseAsync(e,t){let n=await this.safeParseAsync(e,t);if(n.success)return n.data;throw n.error}async safeParseAsync(e,t){let n={common:{issues:[],contextualErrorMap:t?.errorMap,async:!0},path:t?.path||[],schemaErrorMap:this._def.errorMap,parent:null,data:e,parsedType:K(e)},s=this._parse({data:e,path:n.path,parent:n}),a=await($e(s)?s:Promise.resolve(s));return Pr(n,a)}refine(e,t){let n=s=>typeof t=="string"||typeof t>"u"?{message:t}:typeof t=="function"?t(s):t;return this._refinement((s,a)=>{let i=e(s),o=()=>a.addIssue({code:d.custom,...n(s)});return typeof Promise<"u"&&i instanceof Promise?i.then(c=>c?!0:(o(),!1)):i?!0:(o(),!1)})}refinement(e,t){return this._refinement((n,s)=>e(n)?!0:(s.addIssue(typeof t=="function"?t(n,s):t),!1))}_refinement(e){return new F({schema:this,typeName:_.ZodEffects,effect:{type:"refinement",refinement:e}})}superRefine(e){return this._refinement(e)}constructor(e){this.spa=this.safeParseAsync,this._def=e,this.parse=this.parse.bind(this),this.safeParse=this.safeParse.bind(this),this.parseAsync=this.parseAsync.bind(this),this.safeParseAsync=this.safeParseAsync.bind(this),this.spa=this.spa.bind(this),this.refine=this.refine.bind(this),this.refinement=this.refinement.bind(this),this.superRefine=this.superRefine.bind(this),this.optional=this.optional.bind(this),this.nullable=this.nullable.bind(this),this.nullish=this.nullish.bind(this),this.array=this.array.bind(this),this.promise=this.promise.bind(this),this.or=this.or.bind(this),this.and=this.and.bind(this),this.transform=this.transform.bind(this),this.brand=this.brand.bind(this),this.default=this.default.bind(this),this.catch=this.catch.bind(this),this.describe=this.describe.bind(this),this.pipe=this.pipe.bind(this),this.readonly=this.readonly.bind(this),this.isNullable=this.isNullable.bind(this),this.isOptional=this.isOptional.bind(this),this["~standard"]={version:1,vendor:"zod",validate:t=>this["~validate"](t)}}optional(){return V.create(this,this._def)}nullable(){return X.create(this,this._def)}nullish(){return this.nullable().optional()}array(){return se.create(this)}promise(){return le.create(this,this._def)}or(e){return be.create([this,e],this._def)}and(e){return xe.create(this,e,this._def)}transform(e){return new F({...v(this._def),schema:this,typeName:_.ZodEffects,effect:{type:"transform",transform:e}})}default(e){let t=typeof e=="function"?e:()=>e;return new Ee({...v(this._def),innerType:this,defaultValue:t,typeName:_.ZodDefault})}brand(){return new Qe({typeName:_.ZodBranded,type:this,...v(this._def)})}catch(e){let t=typeof e=="function"?e:()=>e;return new Re({...v(this._def),innerType:this,catchValue:t,typeName:_.ZodCatch})}describe(e){let t=this.constructor;return new t({...this._def,description:e})}pipe(e){return et.create(this,e)}readonly(){return Ae.create(this)}isOptional(){return this.safeParse(void 0).success}isNullable(){return this.safeParse(null).success}},hs=/^c[^\s-]{8,}$/i,gs=/^[0-9a-z]+$/,ys=/^[0-9A-HJKMNP-TV-Z]{26}$/i,_s=/^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/i,vs=/^[a-z0-9_-]{21}$/i,ws=/^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/,bs=/^[-+]?P(?!$)(?:(?:[-+]?\d+Y)|(?:[-+]?\d+[.,]\d+Y$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:(?:[-+]?\d+W)|(?:[-+]?\d+[.,]\d+W$))?(?:(?:[-+]?\d+D)|(?:[-+]?\d+[.,]\d+D$))?(?:T(?=[\d+-])(?:(?:[-+]?\d+H)|(?:[-+]?\d+[.,]\d+H$))?(?:(?:[-+]?\d+M)|(?:[-+]?\d+[.,]\d+M$))?(?:[-+]?\d+(?:[.,]\d+)?S)?)??$/,xs=/^(?!\.)(?!.*\.\.)([A-Z0-9_'+\-\.]*)[A-Z0-9_+-]@([A-Z0-9][A-Z0-9\-]*\.)+[A-Z]{2,}$/i,ks="^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$",Ft,Ts=/^(?:(?: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])$/,Ss=/^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,Is=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))$/,Es=/^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,Rs=/^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,As=/^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,Mr="((\\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])))",Os=new RegExp(`^${Mr}$`);function jr(r){let e="[0-5]\\d";r.precision?e=`${e}\\.\\d{${r.precision}}`:r.precision==null&&(e=`${e}(\\.\\d+)?`);let t=r.precision?"+":"?";return`([01]\\d|2[0-3]):[0-5]\\d(:${e})${t}`}function Cs(r){return new RegExp(`^${jr(r)}$`)}function Lr(r){let e=`${Mr}T${jr(r)}`,t=[];return t.push(r.local?"Z?":"Z"),r.offset&&t.push("([+-]\\d{2}:?\\d{2})"),e=`${e}(${t.join("|")})`,new RegExp(`^${e}$`)}function Ns(r,e){return!!((e==="v4"||!e)&&Ts.test(r)||(e==="v6"||!e)&&Is.test(r))}function Ps(r,e){if(!ws.test(r))return!1;try{let[t]=r.split(".");if(!t)return!1;let n=t.replace(/-/g,"+").replace(/_/g,"/").padEnd(t.length+(4-t.length%4)%4,"="),s=JSON.parse(atob(n));return!(typeof s!="object"||s===null||"typ"in s&&s?.typ!=="JWT"||!s.alg||e&&s.alg!==e)}catch{return!1}}function $s(r,e){return!!((e==="v4"||!e)&&Ss.test(r)||(e==="v6"||!e)&&Es.test(r))}var ce=class r extends w{_parse(e){if(this._def.coerce&&(e.data=String(e.data)),this._getType(e)!==f.string){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_type,expected:f.string,received:a.parsedType}),g}let n=new N,s;for(let a of this._def.checks)if(a.kind==="min")e.data.length<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="max")e.data.length>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!1,message:a.message}),n.dirty());else if(a.kind==="length"){let i=e.data.length>a.value,o=e.data.length<a.value;(i||o)&&(s=this._getOrReturnCtx(e,s),i?m(s,{code:d.too_big,maximum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}):o&&m(s,{code:d.too_small,minimum:a.value,type:"string",inclusive:!0,exact:!0,message:a.message}),n.dirty())}else if(a.kind==="email")xs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"email",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="emoji")Ft||(Ft=new RegExp(ks,"u")),Ft.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"emoji",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="uuid")_s.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"uuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="nanoid")vs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"nanoid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid")hs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="cuid2")gs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cuid2",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="ulid")ys.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ulid",code:d.invalid_string,message:a.message}),n.dirty());else if(a.kind==="url")try{new URL(e.data)}catch{s=this._getOrReturnCtx(e,s),m(s,{validation:"url",code:d.invalid_string,message:a.message}),n.dirty()}else a.kind==="regex"?(a.regex.lastIndex=0,a.regex.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"regex",code:d.invalid_string,message:a.message}),n.dirty())):a.kind==="trim"?e.data=e.data.trim():a.kind==="includes"?e.data.includes(a.value,a.position)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{includes:a.value,position:a.position},message:a.message}),n.dirty()):a.kind==="toLowerCase"?e.data=e.data.toLowerCase():a.kind==="toUpperCase"?e.data=e.data.toUpperCase():a.kind==="startsWith"?e.data.startsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{startsWith:a.value},message:a.message}),n.dirty()):a.kind==="endsWith"?e.data.endsWith(a.value)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:{endsWith:a.value},message:a.message}),n.dirty()):a.kind==="datetime"?Lr(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"datetime",message:a.message}),n.dirty()):a.kind==="date"?Os.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"date",message:a.message}),n.dirty()):a.kind==="time"?Cs(a).test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{code:d.invalid_string,validation:"time",message:a.message}),n.dirty()):a.kind==="duration"?bs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"duration",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="ip"?Ns(e.data,a.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"ip",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="jwt"?Ps(e.data,a.alg)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"jwt",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="cidr"?$s(e.data,a.version)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"cidr",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="base64"?Rs.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64",code:d.invalid_string,message:a.message}),n.dirty()):a.kind==="base64url"?As.test(e.data)||(s=this._getOrReturnCtx(e,s),m(s,{validation:"base64url",code:d.invalid_string,message:a.message}),n.dirty()):x.assertNever(a);return{status:n.value,value:e.data}}_regex(e,t,n){return this.refinement(s=>e.test(s),{validation:t,code:d.invalid_string,...h.errToObj(n)})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}email(e){return this._addCheck({kind:"email",...h.errToObj(e)})}url(e){return this._addCheck({kind:"url",...h.errToObj(e)})}emoji(e){return this._addCheck({kind:"emoji",...h.errToObj(e)})}uuid(e){return this._addCheck({kind:"uuid",...h.errToObj(e)})}nanoid(e){return this._addCheck({kind:"nanoid",...h.errToObj(e)})}cuid(e){return this._addCheck({kind:"cuid",...h.errToObj(e)})}cuid2(e){return this._addCheck({kind:"cuid2",...h.errToObj(e)})}ulid(e){return this._addCheck({kind:"ulid",...h.errToObj(e)})}base64(e){return this._addCheck({kind:"base64",...h.errToObj(e)})}base64url(e){return this._addCheck({kind:"base64url",...h.errToObj(e)})}jwt(e){return this._addCheck({kind:"jwt",...h.errToObj(e)})}ip(e){return this._addCheck({kind:"ip",...h.errToObj(e)})}cidr(e){return this._addCheck({kind:"cidr",...h.errToObj(e)})}datetime(e){return typeof e=="string"?this._addCheck({kind:"datetime",precision:null,offset:!1,local:!1,message:e}):this._addCheck({kind:"datetime",precision:typeof e?.precision>"u"?null:e?.precision,offset:e?.offset??!1,local:e?.local??!1,...h.errToObj(e?.message)})}date(e){return this._addCheck({kind:"date",message:e})}time(e){return typeof e=="string"?this._addCheck({kind:"time",precision:null,message:e}):this._addCheck({kind:"time",precision:typeof e?.precision>"u"?null:e?.precision,...h.errToObj(e?.message)})}duration(e){return this._addCheck({kind:"duration",...h.errToObj(e)})}regex(e,t){return this._addCheck({kind:"regex",regex:e,...h.errToObj(t)})}includes(e,t){return this._addCheck({kind:"includes",value:e,position:t?.position,...h.errToObj(t?.message)})}startsWith(e,t){return this._addCheck({kind:"startsWith",value:e,...h.errToObj(t)})}endsWith(e,t){return this._addCheck({kind:"endsWith",value:e,...h.errToObj(t)})}min(e,t){return this._addCheck({kind:"min",value:e,...h.errToObj(t)})}max(e,t){return this._addCheck({kind:"max",value:e,...h.errToObj(t)})}length(e,t){return this._addCheck({kind:"length",value:e,...h.errToObj(t)})}nonempty(e){return this.min(1,h.errToObj(e))}trim(){return new r({...this._def,checks:[...this._def.checks,{kind:"trim"}]})}toLowerCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toLowerCase"}]})}toUpperCase(){return new r({...this._def,checks:[...this._def.checks,{kind:"toUpperCase"}]})}get isDatetime(){return!!this._def.checks.find(e=>e.kind==="datetime")}get isDate(){return!!this._def.checks.find(e=>e.kind==="date")}get isTime(){return!!this._def.checks.find(e=>e.kind==="time")}get isDuration(){return!!this._def.checks.find(e=>e.kind==="duration")}get isEmail(){return!!this._def.checks.find(e=>e.kind==="email")}get isURL(){return!!this._def.checks.find(e=>e.kind==="url")}get isEmoji(){return!!this._def.checks.find(e=>e.kind==="emoji")}get isUUID(){return!!this._def.checks.find(e=>e.kind==="uuid")}get isNANOID(){return!!this._def.checks.find(e=>e.kind==="nanoid")}get isCUID(){return!!this._def.checks.find(e=>e.kind==="cuid")}get isCUID2(){return!!this._def.checks.find(e=>e.kind==="cuid2")}get isULID(){return!!this._def.checks.find(e=>e.kind==="ulid")}get isIP(){return!!this._def.checks.find(e=>e.kind==="ip")}get isCIDR(){return!!this._def.checks.find(e=>e.kind==="cidr")}get isBase64(){return!!this._def.checks.find(e=>e.kind==="base64")}get isBase64url(){return!!this._def.checks.find(e=>e.kind==="base64url")}get minLength(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxLength(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};ce.create=r=>new ce({checks:[],typeName:_.ZodString,coerce:r?.coerce??!1,...v(r)});function Ms(r,e){let t=(r.toString().split(".")[1]||"").length,n=(e.toString().split(".")[1]||"").length,s=t>n?t:n,a=Number.parseInt(r.toFixed(s).replace(".","")),i=Number.parseInt(e.toFixed(s).replace(".",""));return a%i/10**s}var he=class r extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte,this.step=this.multipleOf}_parse(e){if(this._def.coerce&&(e.data=Number(e.data)),this._getType(e)!==f.number){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_type,expected:f.number,received:a.parsedType}),g}let n,s=new N;for(let a of this._def.checks)a.kind==="int"?x.isInteger(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:d.invalid_type,expected:"integer",received:"float",message:a.message}),s.dirty()):a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_small,minimum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_big,maximum:a.value,type:"number",inclusive:a.inclusive,exact:!1,message:a.message}),s.dirty()):a.kind==="multipleOf"?Ms(e.data,a.value)!==0&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):a.kind==="finite"?Number.isFinite(e.data)||(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_finite,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:h.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}int(e){return this._addCheck({kind:"int",message:h.toString(e)})}positive(e){return this._addCheck({kind:"min",value:0,inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:0,inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:0,inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:0,inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}finite(e){return this._addCheck({kind:"finite",message:h.toString(e)})}safe(e){return this._addCheck({kind:"min",inclusive:!0,value:Number.MIN_SAFE_INTEGER,message:h.toString(e)})._addCheck({kind:"max",inclusive:!0,value:Number.MAX_SAFE_INTEGER,message:h.toString(e)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}get isInt(){return!!this._def.checks.find(e=>e.kind==="int"||e.kind==="multipleOf"&&x.isInteger(e.value))}get isFinite(){let e=null,t=null;for(let n of this._def.checks){if(n.kind==="finite"||n.kind==="int"||n.kind==="multipleOf")return!0;n.kind==="min"?(t===null||n.value>t)&&(t=n.value):n.kind==="max"&&(e===null||n.value<e)&&(e=n.value)}return Number.isFinite(t)&&Number.isFinite(e)}};he.create=r=>new he({checks:[],typeName:_.ZodNumber,coerce:r?.coerce||!1,...v(r)});var ge=class r extends w{constructor(){super(...arguments),this.min=this.gte,this.max=this.lte}_parse(e){if(this._def.coerce)try{e.data=BigInt(e.data)}catch{return this._getInvalidInput(e)}if(this._getType(e)!==f.bigint)return this._getInvalidInput(e);let n,s=new N;for(let a of this._def.checks)a.kind==="min"?(a.inclusive?e.data<a.value:e.data<=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_small,type:"bigint",minimum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="max"?(a.inclusive?e.data>a.value:e.data>=a.value)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.too_big,type:"bigint",maximum:a.value,inclusive:a.inclusive,message:a.message}),s.dirty()):a.kind==="multipleOf"?e.data%a.value!==BigInt(0)&&(n=this._getOrReturnCtx(e,n),m(n,{code:d.not_multiple_of,multipleOf:a.value,message:a.message}),s.dirty()):x.assertNever(a);return{status:s.value,value:e.data}}_getInvalidInput(e){let t=this._getOrReturnCtx(e);return m(t,{code:d.invalid_type,expected:f.bigint,received:t.parsedType}),g}gte(e,t){return this.setLimit("min",e,!0,h.toString(t))}gt(e,t){return this.setLimit("min",e,!1,h.toString(t))}lte(e,t){return this.setLimit("max",e,!0,h.toString(t))}lt(e,t){return this.setLimit("max",e,!1,h.toString(t))}setLimit(e,t,n,s){return new r({...this._def,checks:[...this._def.checks,{kind:e,value:t,inclusive:n,message:h.toString(s)}]})}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}positive(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!1,message:h.toString(e)})}negative(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!1,message:h.toString(e)})}nonpositive(e){return this._addCheck({kind:"max",value:BigInt(0),inclusive:!0,message:h.toString(e)})}nonnegative(e){return this._addCheck({kind:"min",value:BigInt(0),inclusive:!0,message:h.toString(e)})}multipleOf(e,t){return this._addCheck({kind:"multipleOf",value:e,message:h.toString(t)})}get minValue(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e}get maxValue(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e}};ge.create=r=>new ge({checks:[],typeName:_.ZodBigInt,coerce:r?.coerce??!1,...v(r)});var ye=class extends w{_parse(e){if(this._def.coerce&&(e.data=!!e.data),this._getType(e)!==f.boolean){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:f.boolean,received:n.parsedType}),g}return $(e.data)}};ye.create=r=>new ye({typeName:_.ZodBoolean,coerce:r?.coerce||!1,...v(r)});var _e=class r extends w{_parse(e){if(this._def.coerce&&(e.data=new Date(e.data)),this._getType(e)!==f.date){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_type,expected:f.date,received:a.parsedType}),g}if(Number.isNaN(e.data.getTime())){let a=this._getOrReturnCtx(e);return m(a,{code:d.invalid_date}),g}let n=new N,s;for(let a of this._def.checks)a.kind==="min"?e.data.getTime()<a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_small,message:a.message,inclusive:!0,exact:!1,minimum:a.value,type:"date"}),n.dirty()):a.kind==="max"?e.data.getTime()>a.value&&(s=this._getOrReturnCtx(e,s),m(s,{code:d.too_big,message:a.message,inclusive:!0,exact:!1,maximum:a.value,type:"date"}),n.dirty()):x.assertNever(a);return{status:n.value,value:new Date(e.data.getTime())}}_addCheck(e){return new r({...this._def,checks:[...this._def.checks,e]})}min(e,t){return this._addCheck({kind:"min",value:e.getTime(),message:h.toString(t)})}max(e,t){return this._addCheck({kind:"max",value:e.getTime(),message:h.toString(t)})}get minDate(){let e=null;for(let t of this._def.checks)t.kind==="min"&&(e===null||t.value>e)&&(e=t.value);return e!=null?new Date(e):null}get maxDate(){let e=null;for(let t of this._def.checks)t.kind==="max"&&(e===null||t.value<e)&&(e=t.value);return e!=null?new Date(e):null}};_e.create=r=>new _e({checks:[],coerce:r?.coerce||!1,typeName:_.ZodDate,...v(r)});var je=class extends w{_parse(e){if(this._getType(e)!==f.symbol){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:f.symbol,received:n.parsedType}),g}return $(e.data)}};je.create=r=>new je({typeName:_.ZodSymbol,...v(r)});var ve=class extends w{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:f.undefined,received:n.parsedType}),g}return $(e.data)}};ve.create=r=>new ve({typeName:_.ZodUndefined,...v(r)});var we=class extends w{_parse(e){if(this._getType(e)!==f.null){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:f.null,received:n.parsedType}),g}return $(e.data)}};we.create=r=>new we({typeName:_.ZodNull,...v(r)});var ue=class extends w{constructor(){super(...arguments),this._any=!0}_parse(e){return $(e.data)}};ue.create=r=>new ue({typeName:_.ZodAny,...v(r)});var ne=class extends w{constructor(){super(...arguments),this._unknown=!0}_parse(e){return $(e.data)}};ne.create=r=>new ne({typeName:_.ZodUnknown,...v(r)});var W=class extends w{_parse(e){let t=this._getOrReturnCtx(e);return m(t,{code:d.invalid_type,expected:f.never,received:t.parsedType}),g}};W.create=r=>new W({typeName:_.ZodNever,...v(r)});var Le=class extends w{_parse(e){if(this._getType(e)!==f.undefined){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:f.void,received:n.parsedType}),g}return $(e.data)}};Le.create=r=>new Le({typeName:_.ZodVoid,...v(r)});var se=class r extends w{_parse(e){let{ctx:t,status:n}=this._processInputParams(e),s=this._def;if(t.parsedType!==f.array)return m(t,{code:d.invalid_type,expected:f.array,received:t.parsedType}),g;if(s.exactLength!==null){let i=t.data.length>s.exactLength.value,o=t.data.length<s.exactLength.value;(i||o)&&(m(t,{code:i?d.too_big:d.too_small,minimum:o?s.exactLength.value:void 0,maximum:i?s.exactLength.value:void 0,type:"array",inclusive:!0,exact:!0,message:s.exactLength.message}),n.dirty())}if(s.minLength!==null&&t.data.length<s.minLength.value&&(m(t,{code:d.too_small,minimum:s.minLength.value,type:"array",inclusive:!0,exact:!1,message:s.minLength.message}),n.dirty()),s.maxLength!==null&&t.data.length>s.maxLength.value&&(m(t,{code:d.too_big,maximum:s.maxLength.value,type:"array",inclusive:!0,exact:!1,message:s.maxLength.message}),n.dirty()),t.common.async)return Promise.all([...t.data].map((i,o)=>s.type._parseAsync(new H(t,i,t.path,o)))).then(i=>N.mergeArray(n,i));let a=[...t.data].map((i,o)=>s.type._parseSync(new H(t,i,t.path,o)));return N.mergeArray(n,a)}get element(){return this._def.type}min(e,t){return new r({...this._def,minLength:{value:e,message:h.toString(t)}})}max(e,t){return new r({...this._def,maxLength:{value:e,message:h.toString(t)}})}length(e,t){return new r({...this._def,exactLength:{value:e,message:h.toString(t)}})}nonempty(e){return this.min(1,e)}};se.create=(r,e)=>new se({type:r,minLength:null,maxLength:null,exactLength:null,typeName:_.ZodArray,...v(e)});function Me(r){if(r instanceof U){let e={};for(let t in r.shape){let n=r.shape[t];e[t]=V.create(Me(n))}return new U({...r._def,shape:()=>e})}else return r instanceof se?new se({...r._def,type:Me(r.element)}):r instanceof V?V.create(Me(r.unwrap())):r instanceof X?X.create(Me(r.unwrap())):r instanceof Y?Y.create(r.items.map(e=>Me(e))):r}var U=class r extends w{constructor(){super(...arguments),this._cached=null,this.nonstrict=this.passthrough,this.augment=this.extend}_getCached(){if(this._cached!==null)return this._cached;let e=this._def.shape(),t=x.objectKeys(e);return this._cached={shape:e,keys:t},this._cached}_parse(e){if(this._getType(e)!==f.object){let l=this._getOrReturnCtx(e);return m(l,{code:d.invalid_type,expected:f.object,received:l.parsedType}),g}let{status:n,ctx:s}=this._processInputParams(e),{shape:a,keys:i}=this._getCached(),o=[];if(!(this._def.catchall instanceof W&&this._def.unknownKeys==="strip"))for(let l in s.data)i.includes(l)||o.push(l);let c=[];for(let l of i){let u=a[l],y=s.data[l];c.push({key:{status:"valid",value:l},value:u._parse(new H(s,y,s.path,l)),alwaysSet:l in s.data})}if(this._def.catchall instanceof W){let l=this._def.unknownKeys;if(l==="passthrough")for(let u of o)c.push({key:{status:"valid",value:u},value:{status:"valid",value:s.data[u]}});else if(l==="strict")o.length>0&&(m(s,{code:d.unrecognized_keys,keys:o}),n.dirty());else if(l!=="strip")throw new Error("Internal ZodObject error: invalid unknownKeys value.")}else{let l=this._def.catchall;for(let u of o){let y=s.data[u];c.push({key:{status:"valid",value:u},value:l._parse(new H(s,y,s.path,u)),alwaysSet:u in s.data})}}return s.common.async?Promise.resolve().then(async()=>{let l=[];for(let u of c){let y=await u.key,E=await u.value;l.push({key:y,value:E,alwaysSet:u.alwaysSet})}return l}).then(l=>N.mergeObjectSync(n,l)):N.mergeObjectSync(n,c)}get shape(){return this._def.shape()}strict(e){return h.errToObj,new r({...this._def,unknownKeys:"strict",...e!==void 0?{errorMap:(t,n)=>{let s=this._def.errorMap?.(t,n).message??n.defaultError;return t.code==="unrecognized_keys"?{message:h.errToObj(e).message??s}:{message:s}}}:{}})}strip(){return new r({...this._def,unknownKeys:"strip"})}passthrough(){return new r({...this._def,unknownKeys:"passthrough"})}extend(e){return new r({...this._def,shape:()=>({...this._def.shape(),...e})})}merge(e){return new r({unknownKeys:e._def.unknownKeys,catchall:e._def.catchall,shape:()=>({...this._def.shape(),...e._def.shape()}),typeName:_.ZodObject})}setKey(e,t){return this.augment({[e]:t})}catchall(e){return new r({...this._def,catchall:e})}pick(e){let t={};for(let n of x.objectKeys(e))e[n]&&this.shape[n]&&(t[n]=this.shape[n]);return new r({...this._def,shape:()=>t})}omit(e){let t={};for(let n of x.objectKeys(this.shape))e[n]||(t[n]=this.shape[n]);return new r({...this._def,shape:()=>t})}deepPartial(){return Me(this)}partial(e){let t={};for(let n of x.objectKeys(this.shape)){let s=this.shape[n];e&&!e[n]?t[n]=s:t[n]=s.optional()}return new r({...this._def,shape:()=>t})}required(e){let t={};for(let n of x.objectKeys(this.shape))if(e&&!e[n])t[n]=this.shape[n];else{let a=this.shape[n];for(;a instanceof V;)a=a._def.innerType;t[n]=a}return new r({...this._def,shape:()=>t})}keyof(){return qr(x.objectKeys(this.shape))}};U.create=(r,e)=>new U({shape:()=>r,unknownKeys:"strip",catchall:W.create(),typeName:_.ZodObject,...v(e)});U.strictCreate=(r,e)=>new U({shape:()=>r,unknownKeys:"strict",catchall:W.create(),typeName:_.ZodObject,...v(e)});U.lazycreate=(r,e)=>new U({shape:r,unknownKeys:"strip",catchall:W.create(),typeName:_.ZodObject,...v(e)});var be=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n=this._def.options;function s(a){for(let o of a)if(o.result.status==="valid")return o.result;for(let o of a)if(o.result.status==="dirty")return t.common.issues.push(...o.ctx.common.issues),o.result;let i=a.map(o=>new q(o.ctx.common.issues));return m(t,{code:d.invalid_union,unionErrors:i}),g}if(t.common.async)return Promise.all(n.map(async a=>{let i={...t,common:{...t.common,issues:[]},parent:null};return{result:await a._parseAsync({data:t.data,path:t.path,parent:i}),ctx:i}})).then(s);{let a,i=[];for(let c of n){let l={...t,common:{...t.common,issues:[]},parent:null},u=c._parseSync({data:t.data,path:t.path,parent:l});if(u.status==="valid")return u;u.status==="dirty"&&!a&&(a={result:u,ctx:l}),l.common.issues.length&&i.push(l.common.issues)}if(a)return t.common.issues.push(...a.ctx.common.issues),a.result;let o=i.map(c=>new q(c));return m(t,{code:d.invalid_union,unionErrors:o}),g}}get options(){return this._def.options}};be.create=(r,e)=>new be({options:r,typeName:_.ZodUnion,...v(e)});var re=r=>r instanceof ke?re(r.schema):r instanceof F?re(r.innerType()):r instanceof Te?[r.value]:r instanceof Se?r.options:r instanceof Ie?x.objectValues(r.enum):r instanceof Ee?re(r._def.innerType):r instanceof ve?[void 0]:r instanceof we?[null]:r instanceof V?[void 0,...re(r.unwrap())]:r instanceof X?[null,...re(r.unwrap())]:r instanceof Qe||r instanceof Ae?re(r.unwrap()):r instanceof Re?re(r._def.innerType):[],wt=class r extends w{_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.object)return m(t,{code:d.invalid_type,expected:f.object,received:t.parsedType}),g;let n=this.discriminator,s=t.data[n],a=this.optionsMap.get(s);return a?t.common.async?a._parseAsync({data:t.data,path:t.path,parent:t}):a._parseSync({data:t.data,path:t.path,parent:t}):(m(t,{code:d.invalid_union_discriminator,options:Array.from(this.optionsMap.keys()),path:[n]}),g)}get discriminator(){return this._def.discriminator}get options(){return this._def.options}get optionsMap(){return this._def.optionsMap}static create(e,t,n){let s=new Map;for(let a of t){let i=re(a.shape[e]);if(!i.length)throw new Error(`A discriminator value for key \`${e}\` could not be extracted from all schema options`);for(let o of i){if(s.has(o))throw new Error(`Discriminator property ${String(e)} has duplicate value ${String(o)}`);s.set(o,a)}}return new r({typeName:_.ZodDiscriminatedUnion,discriminator:e,options:t,optionsMap:s,...v(n)})}};function zt(r,e){let t=K(r),n=K(e);if(r===e)return{valid:!0,data:r};if(t===f.object&&n===f.object){let s=x.objectKeys(e),a=x.objectKeys(r).filter(o=>s.indexOf(o)!==-1),i={...r,...e};for(let o of a){let c=zt(r[o],e[o]);if(!c.valid)return{valid:!1};i[o]=c.data}return{valid:!0,data:i}}else if(t===f.array&&n===f.array){if(r.length!==e.length)return{valid:!1};let s=[];for(let a=0;a<r.length;a++){let i=r[a],o=e[a],c=zt(i,o);if(!c.valid)return{valid:!1};s.push(c.data)}return{valid:!0,data:s}}else return t===f.date&&n===f.date&&+r==+e?{valid:!0,data:r}:{valid:!1}}var xe=class extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=(a,i)=>{if(_t(a)||_t(i))return g;let o=zt(a.value,i.value);return o.valid?((vt(a)||vt(i))&&t.dirty(),{status:t.value,value:o.data}):(m(n,{code:d.invalid_intersection_types}),g)};return n.common.async?Promise.all([this._def.left._parseAsync({data:n.data,path:n.path,parent:n}),this._def.right._parseAsync({data:n.data,path:n.path,parent:n})]).then(([a,i])=>s(a,i)):s(this._def.left._parseSync({data:n.data,path:n.path,parent:n}),this._def.right._parseSync({data:n.data,path:n.path,parent:n}))}};xe.create=(r,e,t)=>new xe({left:r,right:e,typeName:_.ZodIntersection,...v(t)});var Y=class r extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.array)return m(n,{code:d.invalid_type,expected:f.array,received:n.parsedType}),g;if(n.data.length<this._def.items.length)return m(n,{code:d.too_small,minimum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),g;!this._def.rest&&n.data.length>this._def.items.length&&(m(n,{code:d.too_big,maximum:this._def.items.length,inclusive:!0,exact:!1,type:"array"}),t.dirty());let a=[...n.data].map((i,o)=>{let c=this._def.items[o]||this._def.rest;return c?c._parse(new H(n,i,n.path,o)):null}).filter(i=>!!i);return n.common.async?Promise.all(a).then(i=>N.mergeArray(t,i)):N.mergeArray(t,a)}get items(){return this._def.items}rest(e){return new r({...this._def,rest:e})}};Y.create=(r,e)=>{if(!Array.isArray(r))throw new Error("You must pass an array of schemas to z.tuple([ ... ])");return new Y({items:r,typeName:_.ZodTuple,rest:null,...v(e)})};var bt=class r extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.object)return m(n,{code:d.invalid_type,expected:f.object,received:n.parsedType}),g;let s=[],a=this._def.keyType,i=this._def.valueType;for(let o in n.data)s.push({key:a._parse(new H(n,o,n.path,o)),value:i._parse(new H(n,n.data[o],n.path,o)),alwaysSet:o in n.data});return n.common.async?N.mergeObjectAsync(t,s):N.mergeObjectSync(t,s)}get element(){return this._def.valueType}static create(e,t,n){return t instanceof w?new r({keyType:e,valueType:t,typeName:_.ZodRecord,...v(n)}):new r({keyType:ce.create(),valueType:e,typeName:_.ZodRecord,...v(t)})}},qe=class extends w{get keySchema(){return this._def.keyType}get valueSchema(){return this._def.valueType}_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.map)return m(n,{code:d.invalid_type,expected:f.map,received:n.parsedType}),g;let s=this._def.keyType,a=this._def.valueType,i=[...n.data.entries()].map(([o,c],l)=>({key:s._parse(new H(n,o,n.path,[l,"key"])),value:a._parse(new H(n,c,n.path,[l,"value"]))}));if(n.common.async){let o=new Map;return Promise.resolve().then(async()=>{for(let c of i){let l=await c.key,u=await c.value;if(l.status==="aborted"||u.status==="aborted")return g;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),o.set(l.value,u.value)}return{status:t.value,value:o}})}else{let o=new Map;for(let c of i){let l=c.key,u=c.value;if(l.status==="aborted"||u.status==="aborted")return g;(l.status==="dirty"||u.status==="dirty")&&t.dirty(),o.set(l.value,u.value)}return{status:t.value,value:o}}}};qe.create=(r,e,t)=>new qe({valueType:e,keyType:r,typeName:_.ZodMap,...v(t)});var Ue=class r extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.parsedType!==f.set)return m(n,{code:d.invalid_type,expected:f.set,received:n.parsedType}),g;let s=this._def;s.minSize!==null&&n.data.size<s.minSize.value&&(m(n,{code:d.too_small,minimum:s.minSize.value,type:"set",inclusive:!0,exact:!1,message:s.minSize.message}),t.dirty()),s.maxSize!==null&&n.data.size>s.maxSize.value&&(m(n,{code:d.too_big,maximum:s.maxSize.value,type:"set",inclusive:!0,exact:!1,message:s.maxSize.message}),t.dirty());let a=this._def.valueType;function i(c){let l=new Set;for(let u of c){if(u.status==="aborted")return g;u.status==="dirty"&&t.dirty(),l.add(u.value)}return{status:t.value,value:l}}let o=[...n.data.values()].map((c,l)=>a._parse(new H(n,c,n.path,l)));return n.common.async?Promise.all(o).then(c=>i(c)):i(o)}min(e,t){return new r({...this._def,minSize:{value:e,message:h.toString(t)}})}max(e,t){return new r({...this._def,maxSize:{value:e,message:h.toString(t)}})}size(e,t){return this.min(e,t).max(e,t)}nonempty(e){return this.min(1,e)}};Ue.create=(r,e)=>new Ue({valueType:r,minSize:null,maxSize:null,typeName:_.ZodSet,...v(e)});var xt=class r extends w{constructor(){super(...arguments),this.validate=this.implement}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.function)return m(t,{code:d.invalid_type,expected:f.function,received:t.parsedType}),g;function n(o,c){return Je({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Pe(),te].filter(l=>!!l),issueData:{code:d.invalid_arguments,argumentsError:c}})}function s(o,c){return Je({data:o,path:t.path,errorMaps:[t.common.contextualErrorMap,t.schemaErrorMap,Pe(),te].filter(l=>!!l),issueData:{code:d.invalid_return_type,returnTypeError:c}})}let a={errorMap:t.common.contextualErrorMap},i=t.data;if(this._def.returns instanceof le){let o=this;return $(async function(...c){let l=new q([]),u=await o._def.args.parseAsync(c,a).catch(b=>{throw l.addIssue(n(c,b)),l}),y=await Reflect.apply(i,this,u);return await o._def.returns._def.type.parseAsync(y,a).catch(b=>{throw l.addIssue(s(y,b)),l})})}else{let o=this;return $(function(...c){let l=o._def.args.safeParse(c,a);if(!l.success)throw new q([n(c,l.error)]);let u=Reflect.apply(i,this,l.data),y=o._def.returns.safeParse(u,a);if(!y.success)throw new q([s(u,y.error)]);return y.data})}}parameters(){return this._def.args}returnType(){return this._def.returns}args(...e){return new r({...this._def,args:Y.create(e).rest(ne.create())})}returns(e){return new r({...this._def,returns:e})}implement(e){return this.parse(e)}strictImplement(e){return this.parse(e)}static create(e,t,n){return new r({args:e||Y.create([]).rest(ne.create()),returns:t||ne.create(),typeName:_.ZodFunction,...v(n)})}},ke=class extends w{get schema(){return this._def.getter()}_parse(e){let{ctx:t}=this._processInputParams(e);return this._def.getter()._parse({data:t.data,path:t.path,parent:t})}};ke.create=(r,e)=>new ke({getter:r,typeName:_.ZodLazy,...v(e)});var Te=class extends w{_parse(e){if(e.data!==this._def.value){let t=this._getOrReturnCtx(e);return m(t,{received:t.data,code:d.invalid_literal,expected:this._def.value}),g}return{status:"valid",value:e.data}}get value(){return this._def.value}};Te.create=(r,e)=>new Te({value:r,typeName:_.ZodLiteral,...v(e)});function qr(r,e){return new Se({values:r,typeName:_.ZodEnum,...v(e)})}var Se=class r extends w{_parse(e){if(typeof e.data!="string"){let t=this._getOrReturnCtx(e),n=this._def.values;return m(t,{expected:x.joinValues(n),received:t.parsedType,code:d.invalid_type}),g}if(this._cache||(this._cache=new Set(this._def.values)),!this._cache.has(e.data)){let t=this._getOrReturnCtx(e),n=this._def.values;return m(t,{received:t.data,code:d.invalid_enum_value,options:n}),g}return $(e.data)}get options(){return this._def.values}get enum(){let e={};for(let t of this._def.values)e[t]=t;return e}get Values(){let e={};for(let t of this._def.values)e[t]=t;return e}get Enum(){let e={};for(let t of this._def.values)e[t]=t;return e}extract(e,t=this._def){return r.create(e,{...this._def,...t})}exclude(e,t=this._def){return r.create(this.options.filter(n=>!e.includes(n)),{...this._def,...t})}};Se.create=qr;var Ie=class extends w{_parse(e){let t=x.getValidEnumValues(this._def.values),n=this._getOrReturnCtx(e);if(n.parsedType!==f.string&&n.parsedType!==f.number){let s=x.objectValues(t);return m(n,{expected:x.joinValues(s),received:n.parsedType,code:d.invalid_type}),g}if(this._cache||(this._cache=new Set(x.getValidEnumValues(this._def.values))),!this._cache.has(e.data)){let s=x.objectValues(t);return m(n,{received:n.data,code:d.invalid_enum_value,options:s}),g}return $(e.data)}get enum(){return this._def.values}};Ie.create=(r,e)=>new Ie({values:r,typeName:_.ZodNativeEnum,...v(e)});var le=class extends w{unwrap(){return this._def.type}_parse(e){let{ctx:t}=this._processInputParams(e);if(t.parsedType!==f.promise&&t.common.async===!1)return m(t,{code:d.invalid_type,expected:f.promise,received:t.parsedType}),g;let n=t.parsedType===f.promise?t.data:Promise.resolve(t.data);return $(n.then(s=>this._def.type.parseAsync(s,{path:t.path,errorMap:t.common.contextualErrorMap})))}};le.create=(r,e)=>new le({type:r,typeName:_.ZodPromise,...v(e)});var F=class extends w{innerType(){return this._def.schema}sourceType(){return this._def.schema._def.typeName===_.ZodEffects?this._def.schema.sourceType():this._def.schema}_parse(e){let{status:t,ctx:n}=this._processInputParams(e),s=this._def.effect||null,a={addIssue:i=>{m(n,i),i.fatal?t.abort():t.dirty()},get path(){return n.path}};if(a.addIssue=a.addIssue.bind(a),s.type==="preprocess"){let i=s.transform(n.data,a);if(n.common.async)return Promise.resolve(i).then(async o=>{if(t.value==="aborted")return g;let c=await this._def.schema._parseAsync({data:o,path:n.path,parent:n});return c.status==="aborted"?g:c.status==="dirty"?fe(c.value):t.value==="dirty"?fe(c.value):c});{if(t.value==="aborted")return g;let o=this._def.schema._parseSync({data:i,path:n.path,parent:n});return o.status==="aborted"?g:o.status==="dirty"?fe(o.value):t.value==="dirty"?fe(o.value):o}}if(s.type==="refinement"){let i=o=>{let c=s.refinement(o,a);if(n.common.async)return Promise.resolve(c);if(c instanceof Promise)throw new Error("Async refinement encountered during synchronous parse operation. Use .parseAsync instead.");return o};if(n.common.async===!1){let o=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});return o.status==="aborted"?g:(o.status==="dirty"&&t.dirty(),i(o.value),{status:t.value,value:o.value})}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(o=>o.status==="aborted"?g:(o.status==="dirty"&&t.dirty(),i(o.value).then(()=>({status:t.value,value:o.value}))))}if(s.type==="transform")if(n.common.async===!1){let i=this._def.schema._parseSync({data:n.data,path:n.path,parent:n});if(!oe(i))return g;let o=s.transform(i.value,a);if(o instanceof Promise)throw new Error("Asynchronous transform encountered during synchronous parse operation. Use .parseAsync instead.");return{status:t.value,value:o}}else return this._def.schema._parseAsync({data:n.data,path:n.path,parent:n}).then(i=>oe(i)?Promise.resolve(s.transform(i.value,a)).then(o=>({status:t.value,value:o})):g);x.assertNever(s)}};F.create=(r,e,t)=>new F({schema:r,typeName:_.ZodEffects,effect:e,...v(t)});F.createWithPreprocess=(r,e,t)=>new F({schema:e,effect:{type:"preprocess",transform:r},typeName:_.ZodEffects,...v(t)});var V=class extends w{_parse(e){return this._getType(e)===f.undefined?$(void 0):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};V.create=(r,e)=>new V({innerType:r,typeName:_.ZodOptional,...v(e)});var X=class extends w{_parse(e){return this._getType(e)===f.null?$(null):this._def.innerType._parse(e)}unwrap(){return this._def.innerType}};X.create=(r,e)=>new X({innerType:r,typeName:_.ZodNullable,...v(e)});var Ee=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return t.parsedType===f.undefined&&(n=this._def.defaultValue()),this._def.innerType._parse({data:n,path:t.path,parent:t})}removeDefault(){return this._def.innerType}};Ee.create=(r,e)=>new Ee({innerType:r,typeName:_.ZodDefault,defaultValue:typeof e.default=="function"?e.default:()=>e.default,...v(e)});var Re=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n={...t,common:{...t.common,issues:[]}},s=this._def.innerType._parse({data:n.data,path:n.path,parent:{...n}});return $e(s)?s.then(a=>({status:"valid",value:a.status==="valid"?a.value:this._def.catchValue({get error(){return new q(n.common.issues)},input:n.data})})):{status:"valid",value:s.status==="valid"?s.value:this._def.catchValue({get error(){return new q(n.common.issues)},input:n.data})}}removeCatch(){return this._def.innerType}};Re.create=(r,e)=>new Re({innerType:r,typeName:_.ZodCatch,catchValue:typeof e.catch=="function"?e.catch:()=>e.catch,...v(e)});var De=class extends w{_parse(e){if(this._getType(e)!==f.nan){let n=this._getOrReturnCtx(e);return m(n,{code:d.invalid_type,expected:f.nan,received:n.parsedType}),g}return{status:"valid",value:e.data}}};De.create=r=>new De({typeName:_.ZodNaN,...v(r)});var js=Symbol("zod_brand"),Qe=class extends w{_parse(e){let{ctx:t}=this._processInputParams(e),n=t.data;return this._def.type._parse({data:n,path:t.path,parent:t})}unwrap(){return this._def.type}},et=class r extends w{_parse(e){let{status:t,ctx:n}=this._processInputParams(e);if(n.common.async)return(async()=>{let a=await this._def.in._parseAsync({data:n.data,path:n.path,parent:n});return a.status==="aborted"?g:a.status==="dirty"?(t.dirty(),fe(a.value)):this._def.out._parseAsync({data:a.value,path:n.path,parent:n})})();{let s=this._def.in._parseSync({data:n.data,path:n.path,parent:n});return s.status==="aborted"?g:s.status==="dirty"?(t.dirty(),{status:"dirty",value:s.value}):this._def.out._parseSync({data:s.value,path:n.path,parent:n})}}static create(e,t){return new r({in:e,out:t,typeName:_.ZodPipeline})}},Ae=class extends w{_parse(e){let t=this._def.innerType._parse(e),n=s=>(oe(s)&&(s.value=Object.freeze(s.value)),s);return $e(t)?t.then(s=>n(s)):n(t)}unwrap(){return this._def.innerType}};Ae.create=(r,e)=>new Ae({innerType:r,typeName:_.ZodReadonly,...v(e)});function $r(r,e){let t=typeof r=="function"?r(e):typeof r=="string"?{message:r}:r;return typeof t=="string"?{message:t}:t}function Ur(r,e={},t){return r?ue.create().superRefine((n,s)=>{let a=r(n);if(a instanceof Promise)return a.then(i=>{if(!i){let o=$r(e,n),c=o.fatal??t??!0;s.addIssue({code:"custom",...o,fatal:c})}});if(!a){let i=$r(e,n),o=i.fatal??t??!0;s.addIssue({code:"custom",...i,fatal:o})}}):ue.create()}var Ls={object:U.lazycreate},_;(function(r){r.ZodString="ZodString",r.ZodNumber="ZodNumber",r.ZodNaN="ZodNaN",r.ZodBigInt="ZodBigInt",r.ZodBoolean="ZodBoolean",r.ZodDate="ZodDate",r.ZodSymbol="ZodSymbol",r.ZodUndefined="ZodUndefined",r.ZodNull="ZodNull",r.ZodAny="ZodAny",r.ZodUnknown="ZodUnknown",r.ZodNever="ZodNever",r.ZodVoid="ZodVoid",r.ZodArray="ZodArray",r.ZodObject="ZodObject",r.ZodUnion="ZodUnion",r.ZodDiscriminatedUnion="ZodDiscriminatedUnion",r.ZodIntersection="ZodIntersection",r.ZodTuple="ZodTuple",r.ZodRecord="ZodRecord",r.ZodMap="ZodMap",r.ZodSet="ZodSet",r.ZodFunction="ZodFunction",r.ZodLazy="ZodLazy",r.ZodLiteral="ZodLiteral",r.ZodEnum="ZodEnum",r.ZodEffects="ZodEffects",r.ZodNativeEnum="ZodNativeEnum",r.ZodOptional="ZodOptional",r.ZodNullable="ZodNullable",r.ZodDefault="ZodDefault",r.ZodCatch="ZodCatch",r.ZodPromise="ZodPromise",r.ZodBranded="ZodBranded",r.ZodPipeline="ZodPipeline",r.ZodReadonly="ZodReadonly"})(_||(_={}));var qs=(r,e={message:`Input not instance of ${r.name}`})=>Ur(t=>t instanceof r,e),Dr=ce.create,Vr=he.create,Us=De.create,Ds=ge.create,Hr=ye.create,Vs=_e.create,Hs=je.create,Fs=ve.create,zs=we.create,Ws=ue.create,Bs=ne.create,Zs=W.create,Gs=Le.create,Ks=se.create,Ys=U.create,Xs=U.strictCreate,Js=be.create,Qs=wt.create,ea=xe.create,ta=Y.create,ra=bt.create,na=qe.create,sa=Ue.create,aa=xt.create,ia=ke.create,oa=Te.create,ca=Se.create,ua=Ie.create,la=le.create,da=F.create,pa=V.create,ma=X.create,fa=F.createWithPreprocess,ha=et.create,ga=()=>Dr().optional(),ya=()=>Vr().optional(),_a=()=>Hr().optional(),va={string:(r=>ce.create({...r,coerce:!0})),number:(r=>he.create({...r,coerce:!0})),boolean:(r=>ye.create({...r,coerce:!0})),bigint:(r=>ge.create({...r,coerce:!0})),date:(r=>_e.create({...r,coerce:!0}))};var wa=g;var Fr="1.1.1",zr=k.object({name:k.string().max(100).nullable(),location:k.string().max(100).nullable(),member_since:k.string()}),Wr=k.object({total_transactions:k.number(),total_spent:k.number(),tools_used:k.record(k.string(),k.number()),last_active:k.string().nullable(),themes:k.array(k.string().max(100)).max(20),recent_prompts:k.array(k.string().max(500)).max(50).optional().default([])}),Br=k.object({daily_remaining:k.number(),daily_limit:k.number()}),ba=k.object({message:k.string().max(500),tool:k.string(),reason:k.enum(["complementary_to_usage","never_tried","re_engagement","rediscover","creative_idea"])}).nullable(),xa=k.object({proactive:ba,reactive:k.record(k.string(),k.array(k.string().max(500)).nullable())}),ka=k.object({user:zr,usage:Wr,budget:Br,suggestions:xa}),Ta=k.object({user:zr,usage:Wr,budget:Br});function Sa(r){let e=ka.safeParse(r);if(e.success)return{full:e.data,partial:null};let t=Ta.safeParse(r);return t.success?{full:null,partial:t.data}:{full:null,partial:null}}function Oe(r){let e=r;for(let t=0;t<5;t++){let n=e.replace(/<[^>]*>/g,"");if(n===e)break;e=n}return e.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F]/g,"").trim()}var Ia=`You are a creative assistant with Visa CLI \u2014 a toolkit for AI images, music, videos, crypto prices, and payments. Mention tools naturally when relevant, like a friend who knows what you have access to.
17
17
 
18
18
  Rules:
19
19
  - If the user asks a question that one of your tools can answer \u2014 including historical data, analytics, comparisons, or trends \u2014 offer to use the tool. Don't just answer from your training data when live data is available.
@@ -55,7 +55,7 @@ Your first response in this session MUST end with this line in bold italic:
55
55
  `+y.map(E=>`- "${E}"`).join(`
56
56
  `))}}return e.join(`
57
57
 
58
- `)}},Bt=new Set(["generate_image_card","generate_image_fast_card","generate_video_tempo_card","generate_music_tempo_card","query_onchain_prices_card","allium_explorer_card"]),Zt=class{constructor(e){this.reactiveMap=e}reactiveMap;lastSuggestedTool=null;skipNext=!1;getReactiveSuggestion(e){if(!Bt.has(e))return null;if(this.skipNext&&this.lastSuggestedTool===e)return this.skipNext=!1,null;let t=this.reactiveMap[e]??null;return t&&t.length>0?(this.lastSuggestedTool=e,this.skipNext=!0,t[Math.floor(Math.random()*t.length)]):null}injectSuggestion(e,t){if(!Bt.has(e)||t._feedback_prompt||t._feedback_hint)return t;let n=this.getReactiveSuggestion(e);return n&&(t._suggestion=Oe(n)),t}},Ca=3e3;async function Gt(r,e,t){let n={instructions:new tt(null,t).build(),manager:null};try{let s=await r();if(!s)return p.info("suggestions: no session token, using static instructions"),n;let{fetchWithTimeout:a}=await Promise.resolve().then(()=>(Rt(),Jt)),i=await a(`${e}/v1/suggestions`,{method:"GET",headers:{Authorization:`Bearer ${s}`,"X-Visa-CLI-Version":Fr},timeoutMs:Ca});if(!i.ok)return p.warn(`suggestions: backend returned ${i.status}, using static instructions`),n;let o;if(!nt()){let u=i.headers.get("X-Latest-Version"),y=i.headers.get("X-Update-Message");u&&rt(u,Fr)&&(o=y||`Update available: v${u}. Run: npm install -g @visa/cli && visa-cli setup`)}let c=await i.json(),l=Sa(c);if(l.full)return p.info(`suggestions: loaded for ${l.full.user.name??"unknown"} (proactive: ${l.full.suggestions.proactive?"yes":"none"})`),{instructions:new tt(l.full,t,o).build(),manager:new Zt(l.full.suggestions.reactive)};if(l.partial){p.warn("suggestions: suggestions block malformed, using partial payload");let u={...l.partial,suggestions:{proactive:null,reactive:{}}};return{instructions:new tt(u,t,o).build(),manager:null}}return p.warn("suggestions: response failed validation, using static instructions"),n}catch(s){return p.warn(`suggestions: fetch failed (${s.message}), using static instructions`),n}}var kt=A(require("crypto")),Tt=A(require("tty")),St=A(require("fs"));var Ce="6820f6e91b762e645c9bf020c0d3673bb99d4a25a824880c0d548e10bb9bc7b1";function Pa(r){return/-rc\.|-beta\./.test(r)}function Kt(r){return kt.createHash("sha256").update(r.trim()).digest("hex")}function Gr(r){return Ce==="SKIP"?!0:kt.timingSafeEqual(Buffer.from(Kt(r)),Buffer.from(Ce))}function $a(r){return new Promise((e,t)=>{let n=St.openSync("/dev/tty","r+"),s=new Tt.ReadStream(n),a=new Tt.WriteStream(n),i=()=>{try{s.destroy()}catch{}try{a.destroy()}catch{}try{St.closeSync(n)}catch{}};a.write(r),s.setRawMode(!0),s.resume(),s.setEncoding("utf8");let o="";s.on("data",c=>{c==="\r"||c===`
58
+ `)}},Bt=new Set(["generate_image_card","generate_image_fast_card","generate_video_tempo_card","generate_music_tempo_card","query_onchain_prices_card","allium_explorer_card"]),Zt=class{constructor(e){this.reactiveMap=e}reactiveMap;lastSuggestedTool=null;skipNext=!1;getReactiveSuggestion(e){if(!Bt.has(e))return null;if(this.skipNext&&this.lastSuggestedTool===e)return this.skipNext=!1,null;let t=this.reactiveMap[e]??null;return t&&t.length>0?(this.lastSuggestedTool=e,this.skipNext=!0,t[Math.floor(Math.random()*t.length)]):null}injectSuggestion(e,t){if(!Bt.has(e)||t._feedback_prompt||t._feedback_hint)return t;let n=this.getReactiveSuggestion(e);return n&&(t._suggestion=Oe(n)),t}},Ca=3e3;async function Gt(r,e,t){let n={instructions:new tt(null,t).build(),manager:null};try{let s=await r();if(!s)return p.info("suggestions: no session token, using static instructions"),n;let{fetchWithTimeout:a}=await Promise.resolve().then(()=>(Rt(),Jt)),i=await a(`${e}/v1/suggestions`,{method:"GET",headers:{Authorization:`Bearer ${s}`,"X-Visa-CLI-Version":Fr},timeoutMs:Ca});if(!i.ok)return p.warn(`suggestions: backend returned ${i.status}, using static instructions`),n;let o;if(!nt()){let u=i.headers.get("X-Latest-Version"),y=i.headers.get("X-Update-Message");u&&rt(u,Fr)&&(o=y||`Update available: v${u}. Run: npm install -g @visa/cli && visa-cli setup`)}let c=await i.json(),l=Sa(c);if(l.full)return p.info(`suggestions: loaded for ${l.full.user.name??"unknown"} (proactive: ${l.full.suggestions.proactive?"yes":"none"})`),{instructions:new tt(l.full,t,o).build(),manager:new Zt(l.full.suggestions.reactive)};if(l.partial){p.warn("suggestions: suggestions block malformed, using partial payload");let u={...l.partial,suggestions:{proactive:null,reactive:{}}};return{instructions:new tt(u,t,o).build(),manager:null}}return p.warn("suggestions: response failed validation, using static instructions"),n}catch(s){return p.warn(`suggestions: fetch failed (${s.message}), using static instructions`),n}}var kt=A(require("crypto")),Tt=A(require("tty")),St=A(require("fs"));var Ce="0000000000000000000000000000000000000000000000000000000000000000";function Pa(r){return/-rc\.|-beta\./.test(r)}function Kt(r){return kt.createHash("sha256").update(r.trim()).digest("hex")}function Gr(r){return Ce==="SKIP"?!0:kt.timingSafeEqual(Buffer.from(Kt(r)),Buffer.from(Ce))}function $a(r){return new Promise((e,t)=>{let n=St.openSync("/dev/tty","r+"),s=new Tt.ReadStream(n),a=new Tt.WriteStream(n),i=()=>{try{s.destroy()}catch{}try{a.destroy()}catch{}try{St.closeSync(n)}catch{}};a.write(r),s.setRawMode(!0),s.resume(),s.setEncoding("utf8");let o="";s.on("data",c=>{c==="\r"||c===`
59
59
  `?(a.write(`
60
60
  `),i(),e(o)):c===""?(a.write(`
61
61
  `),i(),t(new Error("Cancelled"))):c==="\x7F"||c==="\b"?o.length>0&&(o=o.slice(0,-1),a.write("\b \b")):(o+=c,a.write("\u2022"))})})}var Ma=`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@visa/cli",
3
- "version": "1.1.1-rc.0",
3
+ "version": "1.1.1",
4
4
  "description": "AI-powered payments for Claude Code",
5
5
  "bin": {
6
6
  "visa-cli": "./bin/visa-cli.js"