solloop 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +87 -3
- package/THIRD_PARTY_NOTICES.txt +353 -0
- package/esm/chunk-BvjMblAr.js +47 -0
- package/esm/chunk-Dwvo-ZwZ.js +74 -0
- package/esm/index.js +1 -0
- package/esm/react-chunk-0PAV0iQq.js +75 -0
- package/esm/react-chunk-C9Ij-QyN.js +47 -0
- package/esm/react.js +1 -0
- package/package.json +35 -4
- package/types/index.d.ts +25 -0
- package/types/public-types.d.ts +61 -0
- package/types/react.d.ts +18 -0
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import{jsxs as e,jsx as t}from"react/jsx-runtime";import{useState as n,useEffect as r,useRef as s,useMemo as a,useLayoutEffect as l}from"react";import{createPortal as i}from"react-dom";class o extends Error{code;details;constructor(e,t,n={}){super(t,void 0===n.cause?void 0:{cause:n.cause}),this.name="SolLoopError",this.code=e,this.details=n.details??{}}}class c extends o{constructor(e,t){super("invalid_amount",`"${e}" is not a valid amount: ${t}.`,{details:{input:e,reason:t}}),this.name="InvalidAmountError"}}function d(e){return e instanceof o}const u=/^[1-9A-HJ-NP-Za-km-z]+$/;function p(e){const t=function(e){if(!u.test(e))return null;let t=0n;for(const s of e)t=58n*t+BigInt("123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz".indexOf(s));const n=[];for(;t>0n;)n.unshift(Number(t%256n)),t/=256n;let r=0;for(const s of e){if("1"!==s)break;r+=1}return new Uint8Array([...new Array(r).fill(0),...n])}(e);return null!==t&&32===t.length}function h(e,t={}){const n=t.head??4,r=t.tail??4;return e.length<=n+r+3?e:`${e.slice(0,n)}...${e.slice(e.length-r)}`}const g=["mainnet-beta","devnet","localnet"];function f(e){return"string"==typeof e&&g.includes(e)}function m(e,t,n){const r=`https://explorer.solana.com/${e}/${encodeURIComponent(t)}`;switch(n){case"mainnet-beta":return r;case"devnet":return`${r}?cluster=devnet`;case"localnet":return`${r}?cluster=custom&customUrl=${encodeURIComponent("http://localhost:8899")}`}}function w(e){if(e<0n||e>1000n)throw new o("fee_rate_out_of_range",`Fee rate ${e} bps is outside 0..1000.`,{details:{value:e.toString(),max:1000n.toString()}});return e}w(100n);const b={"mainnet-beta":{USDC:{symbol:"USDC",address:"EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",decimals:6}},devnet:{USDC:{symbol:"USDC",address:"4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU",decimals:6}},localnet:{}};function v(e,t){return function(e){const t=b[e];return Object.values(t)}(e).find(e=>e.address===t)}function y(e){if(e<1n||e>8760n)throw new o("invalid_period",`Billing period must be between 1 and 8760 hours; got ${e}.`,{details:{hours:e.toString()}})}function x(e){return y(e),3600n*e}function k(e,t,n,r){const s=x(t),a=[];let l=function(e,t,n){return function(e,t,n){const r=x(t);return n<e?e:e+(n-e)/r*r}(e,t,n)+x(t)}(e,t,n);for(let i=0;i<r;i+=1)a.push(l),l+=s;return a}function S(e){return BigInt(Math.floor(e.getTime()/1e3))}function N(e){return new o("invalid_plan_record",`Plan record field "${e}" is invalid.`,{details:{field:e}})}function _(e,t){const n=e[t];if("string"!=typeof n)throw N(t);return n}function $(e,t){const n=e[t];if("string"!=typeof n||!/^\d{1,20}$/.test(n))throw N(t);return BigInt(n)}const C=/^plan_[A-Za-z0-9]{4,32}$/,z=/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/,U=/^\d{1,3}(?:\.\d+)?(?:px|rem|em|%)$/,I=/^[A-Za-z]{2,3}(?:-[A-Za-z0-9]{2,8})*$/;function P(e){const t=e?.trim()??"";return C.test(t)?{kind:"id",id:t}:p(t)?{kind:"pda",pda:t}:null}function T(e){try{const t=new URL(e??""),n="localhost"===t.hostname||"127.0.0.1"===t.hostname;return"https:"===t.protocol||"http:"===t.protocol&&n?t.href:null}catch{return null}}const A={rpc_unreachable:"Can't reach Solana right now. Try again in a moment.",blockhash_expired:"The network was slow to confirm. Try again.",insufficient_sol:"Your wallet needs a little SOL for the network fee. Add some, then try again.",wallet_unavailable:"Couldn't open your wallet. Check it is unlocked and try again.",plan_terms_mismatch:"This plan's price changed. Here are the new terms.",subscription_invalidated:"Your wallet reset its subscription authority. Approve again to continue.",program_error:"Something went wrong. Try again."},L=A.program_error;function j(e){return A[e.code]??L}function H(e){return d(e)?{code:e.code,message:e.message}:e instanceof TypeError?{code:"rpc_unreachable",message:A.rpc_unreachable}:(console.error("[solloop]",e),{code:"program_error",message:L})}function M(e,t){const n=function(e,t,n={}){if(function(e){if(!Number.isInteger(e)||e<0||e>18)throw new c(String(e),"decimals must be an integer from 0 to 18")}(t),e<0n)throw new c(e.toString(),"token amounts cannot be negative");if(0===t)return e.toString();const r=10n**BigInt(t),s=(e/r).toString();let a=(e%r).toString().padStart(t,"0");if(n.trimZeros){const e=n.minFractionDigits??0;if(a=a.replace(/0+$/,""),a.length<e&&(a=a.padEnd(e,"0")),0===a.length)return s}return`${s}.${a}`}(e,t,{trimZeros:!0,minFractionDigits:Math.min(2,t)}),[r="",s]=n.split("."),a=r.replace(/\B(?=(\d{3})+(?!\d))/g,",");return void 0===s?a:`${a}.${s}`}function B(e){if(8760n===e)return"year";if(1n===e)return"hour";if(e%24n==0n){const t=e/24n;return 1n===t?"day":7n===t?"week":`${t} days`}return`${e} hours`}function D(e){return`every ${B(e)}`}function E(e,t,n){return function(e,t,n=!1){const r=function(e){return new Date(1e3*Number(e))}(e),s=n?{day:"numeric",month:"short",hour:"numeric",minute:"2-digit"}:{day:"numeric",month:"short"};return new Intl.DateTimeFormat(t,s).format(r)}(e,n,t<24n)}function F(e,t){return`${e} (${h(t)})`}function R(e){const t=e/100n,n=e%100n;return 0n===n?`${t}%`:`${t}.${n.toString().padStart(2,"0").replace(/0$/,"")}%`}function Z(e){return null===e?"Includes a SolLoop fee":`Includes a ${R(e)} SolLoop fee`}const W={screen:"plan",status:"loading"};function Y(e){return{amount:e.amount,periodHours:e.periodHours,mint:e.mint}}function G(e,t,n){return{screen:"preflight",status:"checking",plan:e,wallet:t,seen:n}}function q(e){return"plan_not_found"===e?"unknown":"plan_retired"===e?"retired":null}const J=/* @__PURE__ */new Set(["retry","connect","wallet.pick","recheck","approve","back","skip_redirect"]);function O(e,t){const n=setTimeout(e,t);return()=>{clearTimeout(n)}}function X(e){window.location.assign(e)}async function V(e,t){const n=await fetch(`${e.replace(/\/$/,"")}/v1/public/plans/${t}`,{headers:{accept:"application/json"}});if(404===n.status)return null;if(!n.ok)throw new o("rpc_unreachable","Can't reach SolLoop right now. Try again in a moment.",{details:{status:n.status}});return function(e){if("object"!=typeof e||null===e)throw N("$");const t=e,n=_(t,"id");if(!/^plan_[A-Za-z0-9]{4,32}$/.test(n))throw N("id");const r=_(t,"planPda");if(!p(r))throw N("planPda");const s=_(t,"merchantAddress");if(!p(s))throw N("merchantAddress");const a=_(t,"mint");if(!p(a))throw N("mint");const l=t.cluster;if(!f(l))throw N("cluster");const i=t.logoUrl;if(null!==i&&("string"!=typeof i||!i.startsWith("https://")))throw N("logoUrl");const o=t.decimals;if("number"!=typeof o||!Number.isInteger(o)||o<0)throw N("decimals");const c=$(t,"periodHours");try{y(c)}catch{throw N("periodHours")}let d;try{d=w($(t,"feeBps"))}catch{throw N("feeBps")}const u=t.status;if("active"!==u&&"retired"!==u)throw N("status");return{id:n,planPda:r,cluster:l,merchantName:_(t,"merchantName"),merchantAddress:s,name:_(t,"name"),description:_(t,"description"),logoUrl:i,mint:a,symbol:_(t,"symbol"),decimals:o,amount:$(t,"amount"),periodHours:c,feeBps:d,status:u}}(await n.json())}function K(e,t){return{pda:e.planPda,cluster:t,name:e.name,description:e.description,merchantName:e.merchantName,merchantAddress:e.merchantAddress,logoUrl:e.logoUrl,mint:e.mint,symbol:e.symbol,decimals:e.decimals,amount:e.amount,periodHours:e.periodHours,feeBps:e.feeBps,status:e.status}}function Q(e,t){const n=e.destinations[0]??e.owner;return{pda:e.pda,cluster:t,name:e.metadata?.name??"Subscription",description:e.metadata?.description??"",merchantName:h(n),merchantAddress:n,logoUrl:e.metadata?.logoUrl??null,mint:e.mint,symbol:v(t,e.mint)?.symbol??"tokens",decimals:e.decimals,amount:e.amount,periodHours:e.periodHours,feeBps:null,status:e.status}}function ee(e,t){return{...e,mint:t.mint,decimals:t.decimals,amount:t.amount,periodHours:t.periodHours,merchantAddress:t.destinations[0]??t.owner,status:t.status}}const te=async e=>{const{createLazyModule:t}=await(import("./react-chunk-C9Ij-QyN.js"));return t(e)},ne=/* @__PURE__ */new Map;function re(e,t){const n=function(e){const t=ne.get(e);if(void 0!==t)return t;let n=null;try{n=new CSSStyleSheet,n.replaceSync(e)}catch{n=null}return ne.set(e,n),n}(t);if(null!==n&&"adoptedStyleSheets"in e)return void(e.adoptedStyleSheets.includes(n)||(e.adoptedStyleSheets=[...e.adoptedStyleSheets,n]));const r=String([...ne.keys()].indexOf(t));if(null!==e.querySelector(`style[data-solloop="${r}"]`))return;const s=document.createElement("style");s.dataset.solloop=r,s.textContent=t,e.prepend(s)}const se="De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44";function ae({plan:n}){/* @__PURE__ */
|
|
2
|
+
return e("div",{className:"sl-head",children:[null!==n.logoUrl?/* @__PURE__ */t("img",{className:"sl-logo",src:n.logoUrl,alt:""}):null,
|
|
3
|
+
/* @__PURE__ */e("div",{children:[
|
|
4
|
+
/* @__PURE__ */t("h2",{className:"sl-title",children:n.name}),
|
|
5
|
+
/* @__PURE__ */t("p",{className:"sl-sub",children:n.merchantName})]})]})}function le({plan:t}){/* @__PURE__ */
|
|
6
|
+
return e("p",{className:"sl-price",children:[
|
|
7
|
+
/* @__PURE__ */e("span",{className:"sl-price-amount sl-num",children:[M(t.amount,t.decimals)," ",t.symbol]}),
|
|
8
|
+
/* @__PURE__ */e("span",{className:"sl-price-unit",children:["/ ",B(t.periodHours)]})]})}function ie({text:n}){/* @__PURE__ */
|
|
9
|
+
return e("div",{className:"sl-status",role:"status","aria-live":"polite",children:[
|
|
10
|
+
/* @__PURE__ */t("span",{className:"sl-spinner","aria-hidden":"true"}),
|
|
11
|
+
/* @__PURE__ */t("span",{className:"sl-status-text",children:n})]})}const oe={info:/* @__PURE__ */t("circle",{cx:"12",cy:"12",r:"9"}),warn:/* @__PURE__ */t("path",{d:"M12 3l10 18H2L12 3zm0 6v5m0 3v.5"}),fail:/* @__PURE__ */t("path",{d:"M12 3a9 9 0 110 18 9 9 0 010-18zm0 5v5m0 3v.5"}),ok:/* @__PURE__ */t("path",{d:"M5 12l5 5L20 7"})};function ce({tone:n,children:r,testId:s}){/* @__PURE__ */
|
|
12
|
+
return e("div",{className:`sl-notice sl-notice--${n}`,role:"fail"===n?"alert":void 0,"data-testid":s,children:[
|
|
13
|
+
/* @__PURE__ */t("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2",strokeLinecap:"round",strokeLinejoin:"round","aria-hidden":"true",children:oe[n]}),
|
|
14
|
+
/* @__PURE__ */t("div",{children:r})]})}function de({cluster:n}){/* @__PURE__ */
|
|
15
|
+
return e("div",{className:"sl-foot",children:[
|
|
16
|
+
/* @__PURE__ */e("span",{children:["Powered by"," ",
|
|
17
|
+
/* @__PURE__ */t("a",{href:"https://solloop.app",target:"_blank",rel:"noopener noreferrer",children:"SolLoop"})]}),void 0!==n&&"mainnet-beta"!==n?/* @__PURE__ */t("span",{className:"sl-badge","data-testid":"cluster-badge",children:n}):null]})}function ue({state:n,send:r}){switch(n.status){case"loading":/* @__PURE__ */
|
|
18
|
+
return e("div",{"aria-busy":"true",children:[
|
|
19
|
+
/* @__PURE__ */t("p",{className:"sl-sr",children:"Loading plan"}),
|
|
20
|
+
/* @__PURE__ */t("div",{className:"sl-skel sl-skel--title"}),
|
|
21
|
+
/* @__PURE__ */t("div",{className:"sl-skel sl-skel--price"}),
|
|
22
|
+
/* @__PURE__ */t("div",{className:"sl-skel sl-skel--desc"}),
|
|
23
|
+
/* @__PURE__ */t("div",{className:"sl-skel sl-skel--button"})]});case"unavailable":/* @__PURE__ */
|
|
24
|
+
return e("div",{children:[
|
|
25
|
+
/* @__PURE__ */t("h2",{className:"sl-h2",children:"This plan isn't available."}),"unconfigured"===n.reason?/* @__PURE__ */e("p",{className:"sl-lede",children:["The ",
|
|
26
|
+
/* @__PURE__ */t("code",{className:"sl-mono",children:"plan"})," attribute is missing or malformed."]}):null,
|
|
27
|
+
/* @__PURE__ */t(de,{})]});case"error":/* @__PURE__ */
|
|
28
|
+
return e("div",{children:[
|
|
29
|
+
/* @__PURE__ */t(ce,{tone:"fail",children:j(n.error)}),
|
|
30
|
+
/* @__PURE__ */t("button",{type:"button",className:"sl-btn sl-btn--ghost",onClick:()=>{r({type:"retry"})},children:"Try again"}),
|
|
31
|
+
/* @__PURE__ */t(de,{})]});case"ready":{const{plan:s}=n;/* @__PURE__ */
|
|
32
|
+
return e("div",{children:[
|
|
33
|
+
/* @__PURE__ */t(ae,{plan:s}),
|
|
34
|
+
/* @__PURE__ */t(le,{plan:s}),s.description.length>0?/* @__PURE__ */t("p",{className:"sl-desc",children:s.description}):null,
|
|
35
|
+
/* @__PURE__ */t("button",{type:"button",className:"sl-btn",onClick:()=>{r({type:"connect"})},children:"Connect wallet"}),
|
|
36
|
+
/* @__PURE__ */t(de,{cluster:s.cluster})]})}}}function pe({state:n,config:r,send:s}){const{plan:a}=n,l=/* @__PURE__ */t("button",{type:"button",className:"sl-btn sl-btn--text",onClick:()=>{s({type:"back"})},children:"← Back"});switch(n.status){case"loading_wallets":/* @__PURE__ */
|
|
37
|
+
return e("div",{children:[
|
|
38
|
+
/* @__PURE__ */t(ae,{plan:a}),
|
|
39
|
+
/* @__PURE__ */t(ie,{text:"Looking for your wallet…"})]});case"choose_wallet":/* @__PURE__ */
|
|
40
|
+
return e("div",{children:[
|
|
41
|
+
/* @__PURE__ */t(ae,{plan:a}),
|
|
42
|
+
/* @__PURE__ */t("h3",{className:"sl-h2",children:"Choose a wallet"}),
|
|
43
|
+
/* @__PURE__ */t(he,{wallets:n.wallets,send:s}),l]});case"no_wallet":/* @__PURE__ */
|
|
44
|
+
return e("div",{children:[
|
|
45
|
+
/* @__PURE__ */t(ae,{plan:a}),
|
|
46
|
+
/* @__PURE__ */t("h3",{className:"sl-h2",children:"No Solana wallet found"}),
|
|
47
|
+
/* @__PURE__ */e("p",{className:"sl-lede",children:["Install"," ",
|
|
48
|
+
/* @__PURE__ */t("a",{href:"https://phantom.app",target:"_blank",rel:"noopener noreferrer",children:"Phantom"})," ","or"," ",
|
|
49
|
+
/* @__PURE__ */t("a",{href:"https://solflare.com",target:"_blank",rel:"noopener noreferrer",children:"Solflare"}),", then come back to this page. The widget notices when a wallet appears."]}),l]});case"connecting":/* @__PURE__ */
|
|
50
|
+
return e("div",{children:[
|
|
51
|
+
/* @__PURE__ */t(ae,{plan:a}),
|
|
52
|
+
/* @__PURE__ */t(ie,{text:"Waiting for your wallet…"}),l]});case"checking":/* @__PURE__ */
|
|
53
|
+
return e("div",{children:[
|
|
54
|
+
/* @__PURE__ */t(ae,{plan:a}),
|
|
55
|
+
/* @__PURE__ */t(ie,{text:"Checking your balance and existing subscriptions…"})]});case"insufficient":/* @__PURE__ */
|
|
56
|
+
return e("div",{children:[
|
|
57
|
+
/* @__PURE__ */t(ae,{plan:a}),
|
|
58
|
+
/* @__PURE__ */e(ce,{tone:"warn",children:["You have ",(i=n.balance,o=a.decimals,c=a.symbol,`${M(i,o)} ${c}`),". This plan needs ",M(a.amount,a.decimals),"."]}),
|
|
59
|
+
/* @__PURE__ */e("p",{className:"sl-lede",children:["Top up"," ",
|
|
60
|
+
/* @__PURE__ */t("span",{className:"sl-mono",children:h(n.wallet.address)})," and check again."]}),
|
|
61
|
+
/* @__PURE__ */t("button",{type:"button",className:"sl-btn",onClick:()=>{s({type:"recheck"})},children:"Check again"}),l]});case"already_subscribed":/* @__PURE__ */
|
|
62
|
+
return e("div",{children:[
|
|
63
|
+
/* @__PURE__ */t(ae,{plan:a}),
|
|
64
|
+
/* @__PURE__ */e(ce,{tone:"ok",children:["You're subscribed. Next charge"," ",E(n.nextChargeTs,a.periodHours,r.locale),"."]}),
|
|
65
|
+
/* @__PURE__ */e("p",{className:"sl-lede",children:[
|
|
66
|
+
/* @__PURE__ */t("a",{href:m("address",n.subscriptionPda,a.cluster),target:"_blank",rel:"noopener noreferrer",children:"View your subscription"})," ","on the explorer. Cancel any time from your wallet."]}),l]});case"error":/* @__PURE__ */
|
|
67
|
+
return e("div",{children:[
|
|
68
|
+
/* @__PURE__ */t(ae,{plan:a}),
|
|
69
|
+
/* @__PURE__ */t(ce,{tone:"fail",children:j(n.error)}),
|
|
70
|
+
/* @__PURE__ */e("div",{className:"sl-actions",children:[
|
|
71
|
+
/* @__PURE__ */t("button",{type:"button",className:"sl-btn sl-btn--ghost",onClick:()=>{s({type:"retry"})},children:"Try again"}),l]})]})}var i,o,c}function he({wallets:n,send:r}){/* @__PURE__ */
|
|
72
|
+
return t("div",{className:"sl-wallets",children:n.map(n=>/* @__PURE__ */e("button",{type:"button",className:"sl-wallet",onClick:()=>{r({type:"wallet.pick",walletId:n.id})},children:[
|
|
73
|
+
/* @__PURE__ */t("img",{src:n.icon,alt:""}),n.name]},n.id))})}function ge({controller:e,config:s}){const a=function(e){const[t,s]=n(e.getState);return r(()=>{const t=()=>{s(e.getState())};return t(),e.subscribe(t)},[e]),t}(e),l=t=>{e.send(t)},i=e.getLateScreens();let o;switch(a.screen){case"plan":o=/* @__PURE__ */t(ue,{state:a,send:l});break;case"preflight":o=/* @__PURE__ */t(pe,{state:a,config:s,send:l});break;case"authorise":o=null===i?/* @__PURE__ */t(ie,{text:"Loading…"}):/* @__PURE__ */t(i.AuthoriseScreen,{state:a,config:s,send:l});break;case"signing":o=null===i?/* @__PURE__ */t(ie,{text:"Loading…"}):/* @__PURE__ */t(i.SigningScreen,{state:a,send:l});break;case"done":o=null===i?/* @__PURE__ */t(ie,{text:"Loading…"}):/* @__PURE__ */t(i.DoneScreen,{state:a,config:s,send:l})}/* @__PURE__ */
|
|
74
|
+
return t("div",{className:"sl-root","data-testid":"solloop-root","data-screen":a.screen,"data-status":a.status,children:o})}function fe(e){const o=s(null),[c,d]=n(null),u=s(null),p=a(()=>function(e){const t="auto"===e.theme?"auto":"light",n="string"==typeof e.accent&&z.test(e.accent)?e.accent:null,r="string"==typeof e.radius&&U.test(e.radius)?e.radius:"16px",s="string"==typeof e.locale&&I.test(e.locale)?e.locale:"en";return{plan:P(e.plan),theme:t,accent:n,radius:r,locale:s,cluster:f(e.cluster)?e.cluster:null,rpcUrl:T(e.rpc),successUrl:T(e["success-url"]),apiUrl:T(e["api-url"])??"https://api.solloop.app"}}({plan:e.plan,theme:e.theme,accent:e.accent,radius:e.radius,locale:e.locale,cluster:e.cluster,rpc:e.rpcUrl,"success-url":e.successUrl,"api-url":e.apiUrl}),[e.plan,e.theme,e.accent,e.radius,e.locale,e.cluster,e.rpcUrl,e.successUrl,e.apiUrl]),h=s(e);h.current=e;const g=a(()=>function(e){const t=e.schedule??O,n=e.navigate??X,r=e.fetchPublicPlan??V;let s=W,a=!1;const l=/* @__PURE__ */new Set;let i=null,o=null,c=null,d=0,u=null;const p=async t=>{if(null===i||o!==t){const n={cluster:t,config:e.config};o=t,i=e.loadLazy(n)}const n=await i;return null===c&&(c=n.screens,e.onLazyLoaded?.(n)),n.chain},h=(e,t)=>{if(a||t!==d)return;const n=s;s=function(e,t){switch(t.type){case"plan.loaded":return"plan"===e.screen&&"loading"===e.status?{screen:"plan",status:"ready",plan:t.plan}:e;case"plan.unavailable":return"plan"===e.screen&&"loading"===e.status?{screen:"plan",status:"unavailable",reason:t.reason}:e;case"plan.failed":return"plan"===e.screen&&"loading"===e.status?{screen:"plan",status:"error",error:t.error}:e;case"retry":return"plan"===e.screen&&"error"===e.status?W:"preflight"===e.screen&&"error"===e.status?null===e.wallet?{screen:"preflight",status:"loading_wallets",plan:e.plan}:G(e.plan,e.wallet,Y(e.plan)):"signing"===e.screen&&"error"===e.status?{screen:"authorise",status:"ready",plan:e.plan,wallet:e.wallet,prepared:e.prepared,termsChanged:!1}:e;case"connect":return"plan"===e.screen&&"ready"===e.status?{screen:"preflight",status:"loading_wallets",plan:e.plan}:e;case"wallets.loaded":{if("preflight"!==e.screen)return e;if("loading_wallets"!==e.status&&"choose_wallet"!==e.status&&"no_wallet"!==e.status)return e;if(0===t.wallets.length)return{screen:"preflight",status:"no_wallet",plan:e.plan};const n=1===t.wallets.length?t.wallets[0]:void 0;return void 0!==n&&"loading_wallets"===e.status?{screen:"preflight",status:"connecting",plan:e.plan,walletId:n.id}:{screen:"preflight",status:"choose_wallet",plan:e.plan,wallets:t.wallets}}case"wallet.pick":return"preflight"!==e.screen||"choose_wallet"!==e.status&&"no_wallet"!==e.status?e:{screen:"preflight",status:"connecting",plan:e.plan,walletId:t.walletId};case"wallet.connected":return"preflight"===e.screen&&"connecting"===e.status?G(e.plan,t.wallet,Y(e.plan)):e;case"wallet.failed":return"preflight"!==e.screen||"connecting"!==e.status&&"loading_wallets"!==e.status?e:"wallet_rejected"===t.error.code?{screen:"plan",status:"ready",plan:e.plan}:{screen:"preflight",status:"error",plan:e.plan,wallet:null,error:t.error};case"preflight.ready":return"preflight"===e.screen&&"checking"===e.status?{screen:"authorise",status:"ready",plan:t.plan,wallet:e.wallet,prepared:t.prepared,termsChanged:(n=e.seen,r=t.plan,n.amount!==r.amount||n.periodHours!==r.periodHours||n.mint!==r.mint)}:e;case"preflight.insufficient":return"preflight"===e.screen&&"checking"===e.status?{screen:"preflight",status:"insufficient",plan:t.plan,wallet:e.wallet,balance:t.balance}:e;case"preflight.already":return"preflight"===e.screen&&"checking"===e.status?{screen:"preflight",status:"already_subscribed",plan:t.plan,wallet:e.wallet,subscriptionPda:t.subscriptionPda,nextChargeTs:t.nextChargeTs}:e;case"preflight.failed":{if("preflight"!==e.screen||"checking"!==e.status)return e;const n=q(t.error.code);return null!==n?{screen:"plan",status:"unavailable",reason:n}:{screen:"preflight",status:"error",plan:e.plan,wallet:e.wallet,error:t.error}}case"recheck":return"preflight"===e.screen&&"insufficient"===e.status?G(e.plan,e.wallet,Y(e.plan)):e;case"approve":return"authorise"===e.screen?{screen:"signing",status:"wallet",plan:e.plan,wallet:e.wallet,prepared:e.prepared,signature:null,slow:!1}:e;case"wallet.rejected":return"signing"===e.screen&&"wallet"===e.status?{screen:"authorise",status:"ready",plan:e.plan,wallet:e.wallet,prepared:e.prepared,termsChanged:!1}:e;case"signing.slow":return"signing"===e.screen&&"wallet"===e.status?{...e,slow:!0}:e;case"signing.sent":return"signing"!==e.screen||"wallet"!==e.status&&"sending"!==e.status?e:{...e,status:"confirming",signature:t.signature,slow:!1};case"signing.confirmed":return"signing"===e.screen&&"error"!==e.status?{screen:"done",status:"confirmed",plan:e.plan,wallet:e.wallet,result:t.result,redirectIn:t.redirectIn}:e;case"signing.failed":{if("signing"!==e.screen||"error"===e.status)return e;const{code:n}=t.error;if("plan_terms_mismatch"===n||"insufficient_balance"===n||"already_subscribed"===n)return G(e.plan,e.wallet,Y(e.plan));const r=q(n);return null!==r?{screen:"plan",status:"unavailable",reason:r}:{screen:"signing",status:"error",plan:e.plan,wallet:e.wallet,prepared:e.prepared,error:t.error}}case"back":return"plan"===e.screen||"done"===e.screen||"signing"===e.screen&&"error"!==e.status?e:{screen:"plan",status:"ready",plan:e.plan};case"tick":return"done"===e.screen&&null!==e.redirectIn&&e.redirectIn>0?{...e,redirectIn:e.redirectIn-1}:e;case"skip_redirect":return"done"===e.screen&&null!==e.redirectIn?{...e,redirectIn:null}:e}var n,r}(s,e),s!==n&&(g(n,e),(()=>{for(const e of l)e()})(),f(n))},g=(t,n)=>{switch(n.type){case"wallet.connected":return void e.emit("solloop:connected",{address:n.wallet.address});case"approve":return void e.emit("solloop:subscribing",{});case"signing.confirmed":return void e.emit("solloop:subscribed",{signature:n.result.signature,subscriptionPda:n.result.subscriptionPda});case"wallet.rejected":return void e.emit("solloop:cancelled",{});case"plan.failed":case"wallet.failed":case"preflight.failed":case"signing.failed":return void("error"===s.status?e.emit("solloop:error",{code:n.error.code,message:n.error.message}):"wallet.failed"===n.type&&"connecting"===t.status&&e.emit("solloop:cancelled",{}));default:return}},f=l=>{const i=d,o=s;switch(null===u||o.screen===l.screen&&o.status===l.status&&"done"!==o.screen||(u(),u=null),o.screen){case"plan":return void("loading"===o.status&&(async(t,n)=>{try{if(null===t)return void h({type:"plan.unavailable",reason:"unconfigured"},n);if("id"===t.kind){const s=await r(e.config.apiUrl,t.id);return null===s?void h({type:"plan.unavailable",reason:"unknown"},n):"active"!==s.status?void h({type:"plan.unavailable",reason:"retired"},n):void h({type:"plan.loaded",plan:K(s,e.config.cluster??s.cluster)},n)}const s=e.config.cluster??"mainnet-beta",a=await(await p(s)).fetchPlanTerms(t.pda);if(null===a)return void h({type:"plan.unavailable",reason:"unknown"},n);if("active"!==a.status)return void h({type:"plan.unavailable",reason:"retired"},n);h({type:"plan.loaded",plan:Q(a,s)},n)}catch(s){h({type:"plan.failed",error:H(s)},n)}})(e.config.plan,i));case"preflight":return void("loading_wallets"===o.status?(async(e,t)=>{try{const n=await p(e.cluster);if(a||t!==d)return;h({type:"wallets.loaded",wallets:n.listWallets()},t),u=n.onWalletsChanged(()=>{h({type:"wallets.loaded",wallets:n.listWallets()},d)})}catch(n){h({type:"wallet.failed",error:H(n)},t)}})(o.plan,i):"connecting"===o.status?(async(e,t,n)=>{try{const r=await p(e.cluster),s=await r.connect(t);h({type:"wallet.connected",wallet:s},n)}catch(r){h({type:"wallet.failed",error:H(r)},n)}})(o.plan,o.walletId,i):"checking"===o.status&&(async(e,t,n)=>{try{const r=await p(e.cluster),s=await r.preflight(e.pda,t);switch(s.status){case"ready":return void h({type:"preflight.ready",plan:ee(e,s.prepared.terms),prepared:s.prepared},n);case"insufficient":return void h({type:"preflight.insufficient",plan:ee(e,s.terms),balance:s.balance},n);case"already_subscribed":return void h({type:"preflight.already",plan:ee(e,s.terms),subscriptionPda:s.subscriptionPda,nextChargeTs:s.nextChargeTs},n)}}catch(r){h({type:"preflight.failed",error:H(r)},n)}})(o.plan,o.wallet,i));case"authorise":return;case"signing":return void("wallet"===o.status&&"signing"!==l.screen&&(async(n,r)=>{const s=t(()=>{h({type:"signing.slow"},r)},8e3);try{const t=await p(n.plan.cluster),a=await t.subscribe(n.prepared,n.wallet,{onSent:e=>{s(),h({type:"signing.sent",signature:e},r)}});h({type:"signing.confirmed",result:a,redirectIn:null===e.config.successUrl?null:3},r)}catch(a){const e=H(a);"wallet_rejected"===e.code?h({type:"wallet.rejected"},r):h({type:"signing.failed",error:e},r)}finally{s()}})(o,i));case"done":if(null===o.redirectIn)return;return 0===o.redirectIn?void(null!==e.config.successUrl&&n(e.config.successUrl)):void(e=>{u=t(()=>{u=null,h({type:"tick"},e)},1e3)})(i)}};return{getState:()=>s,subscribe:e=>(l.add(e),()=>{l.delete(e)}),send:e=>{if(!function(e){return J.has(e.type)}(e))return;const t="back"===e.type?function(e){return"wallet"in e?e.wallet:null}(s):null;d+=1,h(e,d),null!==t&&"plan"===s.screen&&t.disconnect().catch(()=>{})},getLateScreens:()=>c,start:()=>{d+=1,f(s)},destroy:()=>{a=!0,u?.(),u=null,l.clear()}}}({config:p,loadLazy:te,emit:(e,t)=>{const n=h.current;switch(e){case"solloop:connected":return void n.onConnected?.({address:t.address??""});case"solloop:subscribing":return void n.onSubscribing?.();case"solloop:subscribed":return void n.onSubscribed?.({signature:t.signature??"",subscriptionPda:t.subscriptionPda??""});case"solloop:error":return void n.onError?.({code:t.code??"",message:t.message??""});case"solloop:cancelled":return void n.onCancelled?.()}},onLazyLoaded:e=>{null!==u.current&&re(u.current,e.css)}}),[p]);return l(()=>{const e=o.current;if(null===e)return;!function(e,t){e.dataset.theme=t.theme,null!==t.accent?e.style.setProperty("--sl-accent",t.accent):e.style.removeProperty("--sl-accent"),e.style.setProperty("--sl-radius",t.radius)}(e,p);const t=function(e){const t=e.shadowRoot??e.attachShadow({mode:"open"});return re(t,":host{display:block;contain:content;--sl-ink:#101822;--sl-graphite:#4a5768;--sl-haze:#8695a8;--sl-shell:#edf0f5;--sl-surface:#ffffff;--sl-line:rgb(16 24 34 / 0.08);--sl-line-strong:rgb(16 24 34 / 0.14);--sl-wash:rgb(16 24 34 / 0.035);--sl-settled:#0e8f63;--sl-settled-tint:#e4f5ee;--sl-pending:#b06e00;--sl-pending-tint:#fbf1de;--sl-failed:#c0392f;--sl-failed-tint:#fbe8e6;--sl-accent:#3a2fe0;--sl-accent-deep:color-mix(in srgb,var(--sl-accent) 82%,#000);--sl-accent-tint:color-mix(in srgb,var(--sl-accent) 11%,#fff);--sl-radius:16px;--sl-shadow:inset 0 1px 0 0 rgb(255 255 255 / 0.85),0 1px 2px rgb(16 24 34 / 0.04),0 8px 24px -12px rgb(16 24 34 / 0.1);--sl-ease:cubic-bezier(0.2,0,0,1)}:host([hidden]){display:none}@supports not (color:color-mix(in srgb,red,blue)){:host{--sl-accent-deep:#2f26b8;--sl-accent-tint:#eceafc}}.sl-root,.sl-root *{box-sizing:border-box}.sl-root{all:initial;display:block;box-sizing:border-box;width:100%;min-width:280px;max-width:420px;margin:0;padding:24px;border:1px solid var(--sl-line);border-radius:var(--sl-radius);background:var(--sl-surface);box-shadow:var(--sl-shadow);color:var(--sl-ink);font-family:'Mona Sans',ui-sans-serif,system-ui,-apple-system,'Segoe UI',Roboto,sans-serif;font-size:15px;font-weight:400;font-style:normal;font-variant:normal;line-height:1.5;letter-spacing:normal;word-spacing:normal;text-align:left;text-transform:none;text-indent:0;text-shadow:none;white-space:normal;direction:ltr;visibility:visible;cursor:auto;-webkit-font-smoothing:antialiased;-webkit-text-size-adjust:100%}.sl-mono{font-family:'IBM Plex Mono',ui-monospace,'SFMono-Regular',Menlo,monospace;font-variant-numeric:tabular-nums}.sl-num{font-variant-numeric:tabular-nums}.sl-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}p,h2,h3,ul{margin:0;padding:0}ul{list-style:none}a{color:var(--sl-accent);text-decoration:underline;text-underline-offset:2px}a:hover{color:var(--sl-accent-deep)}img{display:block;max-width:100%}.sl-head{display:flex;align-items:center;gap:12px;margin-bottom:16px}.sl-logo{width:40px;height:40px;border-radius:10px;object-fit:cover;flex:none;background:var(--sl-wash)}.sl-title{font-size:17px;font-weight:600;line-height:1.3}.sl-sub{color:var(--sl-graphite);font-size:13px}.sl-h2{font-size:17px;font-weight:600;line-height:1.3;margin-bottom:4px}.sl-lede{color:var(--sl-graphite);font-size:14px;margin-bottom:16px}.sl-price{display:flex;align-items:baseline;gap:6px;margin:4px 0 4px}.sl-price-amount{font-size:32px;font-weight:600;line-height:1.1;letter-spacing:-0.01em}.sl-price-unit{color:var(--sl-graphite);font-size:15px}.sl-desc{color:var(--sl-graphite);font-size:14px;margin:8px 0 20px}.sl-btn{display:inline-flex;align-items:center;justify-content:center;gap:8px;width:100%;min-height:44px;padding:10px 16px;border:1px solid transparent;border-radius:10px;background:var(--sl-accent);color:#fff;font:inherit;font-size:15px;font-weight:600;line-height:1.2;cursor:pointer;text-decoration:none;transition:background-color 120ms var(--sl-ease),transform 120ms var(--sl-ease)}.sl-btn:hover{background:var(--sl-accent-deep)}.sl-btn:active{transform:translateY(1px)}.sl-btn:disabled{opacity:0.6;cursor:not-allowed;transform:none}.sl-btn--ghost{background:transparent;color:var(--sl-ink);border-color:var(--sl-line-strong)}.sl-btn--ghost:hover{background:var(--sl-wash)}.sl-btn--text{width:auto;min-height:32px;padding:4px 8px;background:transparent;color:var(--sl-graphite);font-weight:500;font-size:13px}.sl-btn--text:hover{background:var(--sl-wash);color:var(--sl-ink)}.sl-btn + .sl-btn,.sl-actions>* + *{margin-top:8px}.sl-btn:focus-visible,a:focus-visible,.sl-wallet:focus-visible,.sl-disclose:focus-visible{outline:none;box-shadow:0 0 0 2px var(--sl-surface),0 0 0 4px var(--sl-accent)}.sl-wallets{display:grid;gap:8px;margin:12px 0 16px}.sl-wallet{display:flex;align-items:center;gap:12px;width:100%;min-height:48px;padding:8px 12px;border:1px solid var(--sl-line-strong);border-radius:10px;background:var(--sl-surface);color:var(--sl-ink);font:inherit;font-size:15px;font-weight:500;cursor:pointer;text-align:left}.sl-wallet:hover{background:var(--sl-wash)}.sl-wallet img{width:28px;height:28px;border-radius:6px}.sl-notice{display:flex;gap:10px;padding:12px;border-radius:10px;font-size:13px;line-height:1.45;margin:16px 0}.sl-notice svg{flex:none;width:18px;height:18px;margin-top:1px}.sl-notice--info{background:var(--sl-accent-tint);color:var(--sl-ink)}.sl-notice--info svg{color:var(--sl-accent)}.sl-notice--warn{background:var(--sl-pending-tint);color:var(--sl-ink)}.sl-notice--warn svg{color:var(--sl-pending)}.sl-notice--fail{background:var(--sl-failed-tint);color:var(--sl-ink)}.sl-notice--fail svg{color:var(--sl-failed)}.sl-notice--ok{background:var(--sl-settled-tint);color:var(--sl-ink)}.sl-notice--ok svg{color:var(--sl-settled)}.sl-status{display:flex;align-items:center;gap:12px;padding:16px 0}.sl-status-text{font-weight:500}.sl-spinner{width:20px;height:20px;flex:none;border-radius:50%;border:2px solid var(--sl-line-strong);border-top-color:var(--sl-accent);animation:sl-spin 800ms linear infinite}.sl-skel{height:14px;border-radius:6px;background:var(--sl-wash);animation:sl-pulse 1.2s ease-in-out infinite}.sl-skel + .sl-skel{margin-top:10px}.sl-skel--title{width:55%}.sl-skel--price{width:40%;height:32px}.sl-skel--desc{width:80%}.sl-skel--button{height:44px;border-radius:10px}.sl-foot{display:flex;justify-content:space-between;gap:8px;align-items:center;margin-top:16px;color:var(--sl-haze);font-size:12px}.sl-foot a{color:inherit}.sl-badge{display:inline-block;padding:1px 6px;border-radius:999px;background:var(--sl-pending-tint);color:var(--sl-pending);font-size:11px;font-weight:600;text-transform:uppercase;letter-spacing:0.04em}@keyframes sl-spin{to{transform:rotate(360deg)}}@keyframes sl-pulse{50%{opacity:0.5}}@media (prefers-reduced-motion:reduce){.sl-spinner{animation-duration:1.6s}.sl-skel{animation:none}.sl-btn{transition:none}}"),t}(e);u.current=t,d(t)},[p]),r(()=>(g.start(),()=>{g.destroy()}),[g]),/* @__PURE__ */t("div",{ref:o,className:e.className,"data-solloop":"",children:null!==c?i(
|
|
75
|
+
/* @__PURE__ */t(ge,{controller:g,config:p}),c):null})}export{de as F,ce as N,ae as P,o as S,j as a,ie as b,M as c,S as d,m as e,E as f,D as g,le as h,d as i,Z as j,R as k,se as l,F as m,fe as n,x as p,h as t,k as u};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import{S as e,i as t,p as n,f as r,e as a,F as o,P as i,N as s,a as c,b as d,t as u,d as l,u as f,c as m,g as p,h,m as g,j as b,k as w,l as y}from"./react-chunk-0PAV0iQq.js";import{jsxs as v,jsx as x}from"react/jsx-runtime";import{useState as A}from"react";var T=1,S=2,k=3,I=4,$=5,P=6,z=7,E=8,N=9,C=10,B=11,L=12,O=-32700,_=-32603,M=-32602,R=-32601,j=-32600,D=-32021,F=-32020,V=-32019,W=-32018,U=-32017,q=-32016,H=-32015,J=-32014,G=-32013,K=-32012,Y=-32011,X=-32010,Z=-32009,Q=-32008,ee=-32007,te=-32006,ne=-32005,re=-32004,ae=-32003,oe=-32002,ie=-32001,se=28e5,ce=2800001,de=2800002,ue=2800003,le=2800004,fe=2800005,me=2800006,pe=2800007,he=2800008,ge=2800009,be=2800010,we=2800011,ye=323e4,ve=32300001,xe=3230002,Ae=3230003,Te=3230004,Se=361e4,ke=3610001,Ie=3610002,$e=3610003,Pe=3610004,ze=3610005,Ee=3610006,Ne=3610007,Ce=3611e3,Be=3704e3,Le=3704001,Oe=3704002,_e=3704003,Me=3704004,Re=3704005,je=3704006,De=3712e3,Fe=4128e3,Ve=4128001,We=4128002,Ue=4615e3,qe=4615001,He=4615002,Je=4615003,Ge=4615004,Ke=4615005,Ye=4615006,Xe=4615007,Ze=4615008,Qe=4615009,et=4615010,tt=4615011,nt=4615012,rt=4615013,at=4615014,ot=4615015,it=4615016,st=4615017,ct=4615018,dt=4615019,ut=4615020,lt=4615021,ft=4615022,mt=4615023,pt=4615024,ht=4615025,gt=4615026,bt=4615027,wt=4615028,yt=4615029,vt=4615030,xt=4615031,At=4615032,Tt=4615033,St=4615034,kt=4615035,It=4615036,$t=4615037,Pt=4615038,zt=4615039,Et=4615040,Nt=4615041,Ct=4615042,Bt=4615043,Lt=4615044,Ot=4615045,_t=4615046,Mt=4615047,Rt=4615048,jt=4615049,Dt=4615050,Ft=4615051,Vt=4615052,Wt=4615053,Ut=4615054,qt=5508e3,Ht=5508001,Jt=5508002,Gt=5508003,Kt=5508004,Yt=5508005,Xt=5508006,Zt=5508007,Qt=5508008,en=5508009,tn=5508010,nn=5508011,rn=5508012,an=5607e3,on=5607001,sn=5607002,cn=5607003,dn=5607004,un=5607005,ln=5607006,fn=5607007,mn=5607008,pn=5607009,hn=5607010,gn=5607011,bn=5607012,wn=5607013,yn=5607014,vn=5607015,xn=5607016,An=5607017,Tn=5607018,Sn=5607019,kn=5663e3,In=5663001,$n=5663002,Pn=5663003,zn=5663004,En=5663005,Nn=5663006,Cn=5663007,Bn=5663008,Ln=5663009,On=5663010,_n=5663011,Mn=5663012,Rn=5663013,jn=5663014,Dn=5663015,Fn=5663016,Vn=5663017,Wn=5663018,Un=5663019,qn=5663020,Hn=5663021,Jn=5663022,Gn=5663023,Kn=5663024,Yn=5663025,Xn=5663026,Zn=5663027,Qn=5663028,er=5663029,tr=5663030,nr=5663031,rr=5663032,ar=5663033,or=5663034,ir=5663035,sr=5663036,cr=5663037,dr=5663038,ur=5664e3,lr=5664001,fr=705e4,mr=7050001,pr=7050002,hr=7050003,gr=7050004,br=7050005,wr=7050006,yr=7050007,vr=7050008,xr=7050009,Ar=7050010,Tr=7050011,Sr=7050012,kr=7050013,Ir=7050014,$r=7050015,Pr=7050016,zr=7050017,Er=7050018,Nr=7050019,Cr=7050020,Br=7050021,Lr=7050022,Or=7050023,_r=7050024,Mr=7050025,Rr=7050026,jr=7050027,Dr=7050028,Fr=7050029,Vr=7050030,Wr=7050031,Ur=7050032,qr=7050033,Hr=7050034,Jr=7050035,Gr=7050036,Kr=7618e3,Yr=7618001,Xr=7618002,Zr=7618003,Qr=7618004,ea=7618005,ta=7618006,na=7618007,ra=7618008,aa=7618009,oa=7618010,ia=7618011,sa=8078e3,ca=8078001,da=8078002,ua=8078003,la=8078004,fa=8078005,ma=8078006,pa=8078007,ha=8078008,ga=8078009,ba=8078010,wa=8078011,ya=8078012,va=8078013,xa=8078014,Aa=8078015,Ta=8078016,Sa=8078017,ka=8078018,Ia=8078019,$a=8078020,Pa=8078021,za=8078022,Ea=8078023,Na=8078024,Ca=8078025,Ba=809e4,La=8090001,Oa=8090002,_a=8090003,Ma=8090004,Ra=8090005,ja=8090006,Da=8090007,Fa=8090008,Va=8090009,Wa=8090010,Ua=8090011,qa=8090012,Ha=81e5,Ja=8100001,Ga=8100002,Ka=8100003,Ya=819e4,Xa=8190001,Za=8190002,Qa=8190003,eo=8190004,to=8195e3,no=8195001,ro=85e5,ao=8500001,oo=8500002,io=8500003,so=8500004,co=8500005,uo=8500006,lo=89e5,fo=8900001,mo=8900002,po=8900003,ho=9e6,go=9000001,bo=9000002,wo=99e5,yo=9900001,vo=9900002,xo=9900003,Ao=9900004,To=9900005,So=9900006;function ko(e){return Array.isArray(e)?"%5B"+e.map(ko).join("%2C%20")+"%5D":"bigint"==typeof e?`${e}n`:encodeURIComponent(String(null!=e&&null===Object.getPrototypeOf(e)?{...e}:e))}function Io([e,t]){return`${e}=${ko(t)}`}var $o={[ye]:"Account not found at address: $address",[Te]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[Ae]:"Expected decoded account at address: $address",[xe]:"Failed to decode account data at address: $address",[ve]:"Accounts not found at addresses: $addresses",[ge]:"Unable to find a viable program address bump seed.",[de]:"$putativeAddress is not a base58-encoded address.",[se]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[ue]:"The `CryptoKey` must be an `Ed25519` public key.",[we]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[he]:"Invalid seeds; point must fall off the Ed25519 curve.",[le]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[me]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[pe]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[fe]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[be]:"Program address cannot end with PDA marker.",[ce]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[I]:"Expected base58-encoded blockhash string of length in the range [32, 44]. Actual length: $actualLength.",[T]:"The network has progressed past the last block for which this transaction could have been committed.",[sa]:"Codec [$codecDescription] cannot decode empty byte arrays.",[za]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[$a]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[fa]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[ma]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[la]:"Encoder and decoder must either both be fixed-size or variable-size.",[ha]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[da]:"Expected a fixed-size codec, got a variable-size one.",[va]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[ua]:"Expected a variable-size codec, got a fixed-size one.",[Ia]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[ca]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[ka]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[ga]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[ba]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Aa]:"Invalid literal union variant. Expected one of [$variants], got $value.",[pa]:"Expected [$codecDescription] to have $expected items, got $actual.",[ya]:"Invalid value $value for base $base with alphabet $alphabet.",[Ta]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[wa]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[xa]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[Pa]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[Sa]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Ea]:"This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",[Na]:"Invalid pattern match value. The provided value does not match any of the specified patterns.",[Ca]:"Invalid pattern match bytes. The provided byte array does not match any of the specified patterns.",[Ce]:"No random values implementation could be found.",[B]:"Failed to send transaction$causeMessage",[L]:"Failed to send transactions$causeMessages",[Da]:"Fixed-point operation `$operation` of kind `$kind` overflowed. Expected a raw bigint in [$min, $max], got $result.",[Va]:"Fixed-point division by zero for value of kind `$kind` ($signedness, $totalBits bits).",[_a]:"`fractionalBits` ($fractionalBits) must not exceed `totalBits` ($totalBits).",[Oa]:"Invalid `decimals`. Expected a non-negative integer, got $decimals.",[La]:"Invalid `fractionalBits`. Expected a non-negative integer, got $fractionalBits.",[Ra]:"Invalid string `$input` for fixed-point value of kind `$kind`.",[Ba]:"Invalid `totalBits`. Expected a positive integer, got $totalBits.",[ja]:"Invalid ratio $numerator/$denominator for fixed-point value of kind `$kind`. Denominator must be non-zero.",[Ua]:"Fixed-point value of kind `$kind` has a malformed `raw` field. Expected a bigint, got `$raw`.",[Fa]:"Fixed-point `$operation` operation expected $expectedKind ($expectedSignedness, $expectedTotalBits bits, $expectedScale $expectedScaleLabel); got $actualKind ($actualSignedness, $actualTotalBits bits, $actualScale $actualScaleLabel).",[Wa]:"Fixed-point operation `$operation` of kind `$kind` cannot be performed exactly; pass a rounding mode other than `strict` to allow a rounded result.",[qa]:"Fixed-point codec of kind `$kind` requires `totalBits` to be a multiple of 8; got $totalBits.",[Ma]:"Fixed-point value of kind `$kind` is out of range for $signedness $totalBits-bit storage. Expected a raw bigint in [$min, $max], got $raw.",[De]:"Filesystem operation `$operation` is not supported in this environment.",[Qe]:"Instruction requires an uninitialized account",[mt]:"Instruction tries to borrow reference for an account which is already borrowed",[pt]:"Instruction left account with an outstanding borrowed reference",[lt]:"Program other than the account's owner changed the size of the account data",[Ke]:"Account data too small for instruction",[ft]:"Instruction expected an executable account",[_t]:"An account does not have enough lamports to be rent-exempt",[Rt]:"Program arithmetic overflowed",[Ot]:"Failed to serialize or deserialize account data",[Ut]:"Builtin programs must consume compute units",[At]:"Cross-program invocation call depth too deep",[Pt]:"Computational budget exceeded",[gt]:"Custom program error: #$code",[st]:"Instruction contains duplicate accounts",[ht]:"Instruction modifications of multiply-passed account differ",[vt]:"Executable accounts must be rent exempt",[wt]:"Instruction changed executable accounts data",[yt]:"Instruction changed the balance of an executable account",[ct]:"Instruction changed executable bit of an account",[at]:"Instruction modified data of an account it does not own",[rt]:"Instruction spent from the balance of an account it does not own",[qe]:"Generic instruction error",[Dt]:"Provided owner is not allowed",[Bt]:"Account is immutable",[Lt]:"Incorrect authority provided",[Xe]:"Incorrect program id for instruction",[Ye]:"Insufficient funds for instruction",[Ge]:"Invalid account data for instruction",[Mt]:"Invalid account owner",[He]:"Invalid program argument",[bt]:"Program returned invalid error code",[Je]:"Invalid instruction data",[$t]:"Failed to reallocate account data",[It]:"Provided seeds do not result in a valid address",[Ft]:"Accounts data allocations exceeded the maximum allowed per transaction",[Vt]:"Max accounts exceeded",[Wt]:"Max instruction trace length exceeded",[kt]:"Length of the seed is too long for address generation",[Tt]:"An account required by the instruction is missing",[Ze]:"Missing required signature for instruction",[nt]:"Instruction illegally modified the program id of an account",[ut]:"Insufficient account keys for instruction",[zt]:"Cross-program invocation with unauthorized signer or writable account",[Et]:"Failed to create program execution environment",[Ct]:"Program failed to compile",[Nt]:"Program failed to complete",[it]:"Instruction modified data of a read-only account",[ot]:"Instruction changed the balance of a read-only account",[St]:"Cross-program invocation reentrancy not allowed for this instruction",[dt]:"Instruction modified rent epoch of an account",[tt]:"Sum of account balances before and after instruction do not match",[et]:"Instruction requires an initialized account",[Ue]:"The instruction failed with the error: $errorName",[xt]:"Unsupported program id",[jt]:"Unsupported sysvar",[To]:"Invalid instruction plan kind: $kind.",[Xr]:"The provided instruction plan is empty.",[ea]:"No failed transaction plan result was found in the provided transaction plan result.",[Qr]:"This transaction plan executor does not support non-divisible sequential plans. To support them, you may create your own executor such that multi-transaction atomicity is preserved — e.g. by targetting RPCs that support transaction bundles.",[Zr]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute for more details. Note that the `cause` property is deprecated, and a future version will not set it.",[ia]:"The configured maximum of $maxInstructions instructions per transaction is invalid. It must be a positive integer no greater than the transaction format limit of $transactionInstructionLimit instructions per transaction. Provide a `maxInstructionsPerTransaction` (on the transaction planner) or `maxInstructions` (on the message packer) value between 1 and $transactionInstructionLimit.",[oa]:"Planning this transaction message would require $numInstructions instructions, which exceeds the configured maximum of $maxInstructions instructions per transaction. This limit is configurable, and intended to leave headroom for inner instructions which are included in the maximum instruction limit for transactions. Increase `maxInstructionsPerTransaction` on the transaction planner (or `maxInstructions` on the message packer) to allow more instructions per transaction.",[Kr]:"The provided message has insufficient capacity to accommodate the next instruction(s) in this plan. Expected at least $numBytesRequired free byte(s), got $numFreeBytes byte(s).",[So]:"Invalid transaction plan kind: $kind.",[Yr]:"No more instructions to pack; the message packer has completed the instruction plan.",[ta]:"Unexpected instruction plan. Expected $expectedKind plan, got $actualKind plan.",[na]:"Unexpected transaction plan. Expected $expectedKind plan, got $actualKind plan.",[ra]:"Unexpected transaction plan result. Expected $expectedKind plan, got $actualKind plan.",[aa]:"Expected a successful transaction plan result. I.e. there is at least one failed or cancelled transaction in the plan.",[Fe]:"The instruction does not have any accounts.",[Ve]:"The instruction does not have any data.",[We]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[$]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[S]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[vo]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Ao]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[yo]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[wo]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[xo]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[_]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[M]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[j]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[R]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[O]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[K]:"$__serverMessage",[ie]:"$__serverMessage",[re]:"$__serverMessage",[J]:"$__serverMessage",[U]:"Epoch rewards period still active at slot $slot",[F]:"$__serverMessage",[X]:"$__serverMessage",[Z]:"$__serverMessage",[V]:"Failed to query long-term storage; please try again",[q]:"Minimum context slot has not been reached",[ne]:"Node is unhealthy; behind by $numSlotsBehind slots",[D]:"No slot history",[Q]:"No snapshot",[oe]:"Transaction simulation failed",[W]:"Rewards cannot be found because slot $slot is not the epoch boundary. This may be due to gap in the queried node's local ledger or long-term storage",[ee]:"$__serverMessage",[Y]:"Transaction history is not available from this node",[te]:"$__serverMessage",[G]:"Transaction signature length mismatch",[ae]:"Transaction signature verification failure",[H]:"$__serverMessage",[Re]:"The grind regex `/$source/` contains the character `$character`, which is not in the base58 alphabet and can never match a Solana address.",[Be]:"Key pair bytes must be of length 64, got $byteLength.",[Le]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Oe]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Me]:"The provided private key does not match the provided public key.",[_e]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[je]:"Writing a key pair to disk is not supported in this environment.",[P]:"Lamports value must be in the range [0, 2e64-1]",[z]:"`$value` cannot be parsed as a `BigInt`",[C]:"$message",[E]:"`$value` cannot be parsed as a `Number`",[k]:"No nonce account could be found at address `$nonceAccountAddress`",[cn]:"Expected base58 encoded application domain to decode to a byte array of length 32. Actual length: $actualLength.",[wn]:"Attempted to sign an offchain message with an address that is not a signer for it",[sn]:"Expected base58-encoded application domain string of length in the range [32, 44]. Actual length: $actualLength.",[Tn]:"The content of the offchain message does not match the content that was expected. Expected content with a byte-length of $expectedBytes; got content with a byte-length of $actualBytes. The signer may have signed different data than was requested; do not trust its signature.",[bn]:"The signer addresses in this offchain message envelope do not match the list of required signers in the message preamble. These unexpected signers were present in the envelope: `[$unexpectedSigners]`. These required signers were missing from the envelope `[$missingSigners]`.",[an]:"The message body provided has a byte-length of $actualBytes. The maximum allowable byte-length is $maxBytes",[fn]:"Expected message format $expectedMessageFormat, got $actualMessageFormat",[mn]:"The message length specified in the message preamble is $specifiedLength bytes. The actual length of the message is $actualLength bytes.",[pn]:"Offchain message content must be non-empty",[un]:"Offchain message must specify the address of at least one required signer",[hn]:"Offchain message envelope must reserve space for at least one signature",[dn]:"The offchain message preamble specifies $numRequiredSignatures required signature(s), got $signaturesLength.",[Sn]:"The offchain message lists different required signatories than was expected. Expected [$expectedAddresses]. Got [$actualAddresses]. The signer may have signed different data than was requested; do not trust its signature.",[vn]:"The signatories of this offchain message must be listed in lexicographical order",[xn]:"An address must be listed no more than once among the signatories of an offchain message",[gn]:"Offchain message is missing signatures for addresses: $addresses.",[An]:"Offchain message signature verification failed. Signature mismatch for required signatories [$signatoriesWithInvalidSignatures]. Missing signatures for signatories [$signatoriesWithMissingSignatures]",[on]:"The message body provided contains characters whose codes fall outside the allowed range. In order to ensure clear-signing compatiblity with hardware wallets, the message may only contain line feeds and characters in the range [\\x20-\\x7e].",[yn]:"Expected offchain message version $expectedVersion. Got $actualVersion.",[ln]:"This version of Kit does not support decoding offchain messages with version $unsupportedVersion. The current max supported version is 0.",[uo]:"The provided account could not be identified as an account from the $programName program.",[oo]:"The provided instruction could not be identified as an instruction from the $programName program.",[ro]:"The provided instruction is missing some accounts. Expected at least $expectedAccountMetas account(s), got $actualAccountMetas.",[so]:"Expected resolved instruction input '$inputName' to be non-null.",[io]:"Expected resolved instruction input '$inputName' to be of type `$expectedType`.",[co]:"Unrecognized account type '$accountType' for the $programName program.",[ao]:"Unrecognized instruction type '$instructionType' for the $programName program.",[Ya]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[Za]:"WebSocket was closed before payload could be added to the send buffer",[Qa]:"WebSocket connection closed",[eo]:"WebSocket failed to connect",[Xa]:"Failed to obtain a subscription id from the server",[Ka]:"Could not find an API plan for RPC method: `$method`",[Ha]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[Ga]:"HTTP error ($statusCode): $message",[Ja]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[qt]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Ht]:"The provided value does not implement the `KeyPairSigner` interface",[Gt]:"The provided value does not implement the `MessageModifyingSigner` interface",[Kt]:"The provided value does not implement the `MessagePartialSigner` interface",[Jt]:"The provided value does not implement any of the `MessageSigner` interfaces",[Xt]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Zt]:"The provided value does not implement the `TransactionPartialSigner` interface",[Qt]:"The provided value does not implement the `TransactionSendingSigner` interface",[Yt]:"The provided value does not implement any of the `TransactionSigner` interfaces",[en]:"More than one `TransactionSendingSigner` was identified.",[tn]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[rn]:"The wallet account $address cannot be used to create a transaction signer because it does not implement either the `solana:signTransaction` or `solana:signAndSendTransaction` feature. At least one of these features is required. The account supports the following features: $supportedFeatures.",[nn]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[to]:"This `ReactiveStreamStore` does not support retry. Use `createReactiveStoreFromDataPublisherFactory` to construct a retryable store.",[no]:"The stream store closed in an error state but did not report an error.",[Ne]:"Cannot export a non-extractable key.",[ke]:"No digest implementation could be found.",[Se]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[Ie]:"This runtime does not support the generation of Ed25519 key pairs.\n\nInstall @solana/webcrypto-ed25519-polyfill and call its `install` function before generating keys in environments that do not support Ed25519.\n\nFor a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.",[$e]:"No key export implementation could be found.",[Pe]:"No key generation implementation could be found.",[ze]:"No signing implementation could be found.",[Ee]:"No signature verification implementation could be found.",[N]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Pr]:"Transaction processing left an account with an outstanding borrowed reference",[mr]:"Account in use",[pr]:"Account loaded twice",[hr]:"Attempt to debit an account but found no record of a prior credit.",[Or]:"Transaction loads an address table account that doesn't exist",[yr]:"This transaction has already been processed",[vr]:"Blockhash not found",[xr]:"Loader call chain is too deep",[$r]:"Transactions are currently disabled due to cluster maintenance",[Vr]:"Transaction contains a duplicate instruction ($index) that is not allowed",[br]:"Insufficient funds for fee",[Wr]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[wr]:"This account may not be used to pay transaction fees",[Tr]:"Transaction contains an invalid account reference",[Mr]:"Transaction loads an address table account with invalid data",[Rr]:"Transaction address table lookup uses an invalid index",[_r]:"Transaction loads an address table account with an invalid owner",[qr]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[kr]:"This program may not be used for executing instructions",[jr]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Nr]:"Transaction loads a writable account that cannot be written",[Ur]:"Transaction exceeded max loaded accounts data size cap",[Ar]:"Transaction requires a fee but has no signature present",[gr]:"Attempt to load a program that does not exist",[Jr]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Hr]:"ResanitizationNeeded",[Ir]:"Transaction failed to sanitize accounts offsets correctly",[Sr]:"Transaction did not pass signature verification",[Lr]:"Transaction locked too many accounts",[Gr]:"Sum of account balances before and after transaction do not match",[fr]:"The transaction failed with the error `$errorName`",[Er]:"Transaction version is unsupported",[Br]:"Transaction would exceed account data limit within the block",[Fr]:"Transaction would exceed total account data limit",[Cr]:"Transaction would exceed max account limit within the block",[zr]:"Transaction would exceed max Block Cost Limit",[Dr]:"Transaction would exceed max Vote Cost Limit",[Dn]:"Attempted to sign a transaction with an address that is not a signer for it",[On]:"Transaction is missing an address at index: $index.",[Fn]:"Transaction has no expected signers therefore it cannot be encoded",[qn]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[$n]:"Transaction does not have a blockhash lifetime",[Pn]:"Transaction is not a durable nonce transaction",[En]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[Nn]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[Bn]:"No fee payer set in CompiledTransaction",[Cn]:"Could not find program address at index $index",[Wn]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[sr]:"Failed to estimate the loaded accounts data size for this transaction message. The RPC did not return a `loadedAccountsDataSize` value from simulation. This value is required for version 1 transactions",[Un]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[cr]:"Transaction failed when it was simulated in order to estimate its resource limits. The resource limit estimates provided are for a transaction that failed when simulated and may not be representative of the resources this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[_n]:"Transaction is missing a fee payer.",[Mn]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[jn]:"Transaction first instruction is not advance nonce account instruction.",[Rn]:"Transaction with no instructions cannot be durable nonce transaction.",[kn]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[In]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[Vn]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[Ln]:"Transaction is missing signatures for addresses: $addresses.",[zn]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[Hn]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 1.",[Jn]:"The transaction has a durable nonce lifetime (with nonce `$nonce`), but the nonce account address is in a lookup table. The lifetime constraint cannot be constructed without fetching the lookup tables for the transaction.",[Qn]:"Invalid transaction config mask: $mask. Bits 0 and 1 must match (both set or both unset)",[Gn]:"Transaction message bytes are malformed: $messageBytes",[Kn]:"Transaction message bytes are empty, so the transaction cannot be encoded",[Yn]:"Transaction bytes are empty, so no transaction can be decoded",[Xn]:"Transaction version 0 must be encoded with signatures first. This transaction was encoded with first byte $firstByte, which is expected to be a signature count for v0 transactions.",[Zn]:"The provided transaction bytes expect that there should be $numExpectedSignatures signatures, but the bytes are not long enough to contain a transaction message with this many signatures. The provided bytes are $transactionBytesLength bytes long.",[er]:"The transaction has a durable nonce lifetime, but the nonce account index is invalid. Expected a nonce account index less than $numberOfStaticAccounts, got $nonceAccountIndex.",[tr]:"The transaction config value for $configName has the incorrect kind. Expected $expectedKind, got $actualKind.",[nr]:"The transaction does not have the same number of instruction headers and instruction payloads. Got $numInstructionHeaders instruction headers, and $numInstructionPayloads instruction payloads.",[rr]:"Transaction has $actualCount unique signer addresses but the maximum allowed is $maxAllowed",[ar]:"Transaction has $actualCount unique account addresses but the maximum allowed is $maxAllowed",[or]:"Transaction has $actualCount instructions but the maximum allowed is $maxAllowed",[ir]:"The instruction at index $instructionIndex has $actualCount account references but the maximum allowed is $maxAllowed",[dr]:"Could not find an account address at index $index while decompiling an instruction",[ur]:"`getTransaction` responses fetched with `encoding: 'jsonParsed'` cannot be decoded. Re-fetch the transaction with `encoding: 'base64'`, `'base58'`, or `'json'`",[lr]:"Could not recognize the shape of this `getTransaction` response. Expected a response fetched with `encoding: 'base64'`, `'base58'`, or `'json'`",[go]:"`$hookName` requires the following capabilities to be installed on the client: [$capabilities]. $providerHint",[ho]:"`$hookName` was called outside of a `ClientProvider`. Mount a `<ClientProvider client={client}>` in the ancestor tree.",[bo]:"The subscription closed in an error state but did not report an error.",[lo]:"Cannot $operation: no wallet connected",[fo]:"No signing wallet connected (status: $status)",[mo]:"Connected wallet does not support signing",[po]:'Account $address is not available in wallet "$walletName"'},Po="i",zo="t";function Eo(e,t){return!!(e instanceof Error&&"SolanaError"===e.name)&&(void 0===t||e.context.__code===t)}var No=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([t,a])=>{"cause"===t?r={cause:a.value}:(void 0===n&&(n={__code:e}),Object.defineProperty(n,t,a))}),super(function(e,t={}){if("production"!=="production")return function(e,t={}){const n=$o[e];if(0===n.length)return"";let r;function a(e){if(2===r[zo]){const a=n.slice(r[Po]+1,e);o.push(a in t?`${t[a]}`:`$${a}`)}else 1===r[zo]&&o.push(n.slice(r[Po],e))}const o=[];n.split("").forEach((e,t)=>{if(0===t)return void(r={[Po]:0,[zo]:"\\"===n[0]?0:"$"===n[0]?2:1});let o;switch(r[zo]){case 0:o={[Po]:t,[zo]:1};break;case 1:"\\"===e?o={[Po]:t,[zo]:0}:"$"===e&&(o={[Po]:t,[zo]:2});break;case 2:"\\"===e?o={[Po]:t,[zo]:0}:"$"===e?o={[Po]:t,[zo]:2}:e.match(/\w/)||(o={[Po]:t,[zo]:1})}o&&(r!==o&&a(t),r=o)}),a();let i=o.join("");return e>=Ue&&e<4616e3&&"index"in t&&(i+=` (instruction #${t.index+1})`),i}(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${function(e){const t=Object.entries(e).map(Io).join("&");return btoa(t)}(t)}'`),`${n}\``}}(e,n),r),this.context=Object.freeze(void 0===n?{__code:e}:n),this.name="SolanaError"}};function Co(...e){"captureStackTrace"in Error&&"function"==typeof Error.captureStackTrace&&Error.captureStackTrace(...e)}function Bo({errorCodeBaseOffset:e,getErrorContext:t,orderedErrorNames:n,rpcEnumError:r},a){let o,i;"string"==typeof r?o=r:(o=Object.keys(r)[0],i=r[o]);const s=e+n.indexOf(o),c=t(s,o,i),d=new No(s,c);return Co(d,a),d}var Lo=["GenericError","InvalidArgument","InvalidInstructionData","InvalidAccountData","AccountDataTooSmall","InsufficientFunds","IncorrectProgramId","MissingRequiredSignature","AccountAlreadyInitialized","UninitializedAccount","UnbalancedInstruction","ModifiedProgramId","ExternalAccountLamportSpend","ExternalAccountDataModified","ReadonlyLamportChange","ReadonlyDataModified","DuplicateAccountIndex","ExecutableModified","RentEpochModified","NotEnoughAccountKeys","AccountDataSizeChanged","AccountNotExecutable","AccountBorrowFailed","AccountBorrowOutstanding","DuplicateAccountOutOfSync","Custom","InvalidError","ExecutableDataModified","ExecutableLamportChange","ExecutableAccountNotRentExempt","UnsupportedProgramId","CallDepth","MissingAccount","ReentrancyNotAllowed","MaxSeedLengthExceeded","InvalidSeeds","InvalidRealloc","ComputationalBudgetExceeded","PrivilegeEscalation","ProgramEnvironmentSetupFailure","ProgramFailedToComplete","ProgramFailedToCompile","Immutable","IncorrectAuthority","BorshIoError","AccountNotRentExempt","InvalidAccountOwner","ArithmeticOverflow","UnsupportedSysvar","IllegalOwner","MaxAccountsDataAllocationsExceeded","MaxAccountsExceeded","MaxInstructionTraceLengthExceeded","BuiltinProgramsMustConsumeComputeUnits"];function Oo(e,t){const n=Number(e);return Bo({errorCodeBaseOffset:4615001,getErrorContext:(e,t,r)=>e===Ue?{errorName:t,index:n,...void 0!==r?{instructionErrorContext:r}:null}:e===gt?{code:Number(r),index:n}:{index:n},orderedErrorNames:Lo,rpcEnumError:t},Oo)}var _o=["AccountInUse","AccountLoadedTwice","AccountNotFound","ProgramAccountNotFound","InsufficientFundsForFee","InvalidAccountForFee","AlreadyProcessed","BlockhashNotFound","CallChainTooDeep","MissingSignatureForFee","InvalidAccountIndex","SignatureFailure","InvalidProgramForExecution","SanitizeFailure","ClusterMaintenance","AccountBorrowOutstanding","WouldExceedMaxBlockCostLimit","UnsupportedVersion","InvalidWritableAccount","WouldExceedMaxAccountCostLimit","WouldExceedAccountDataBlockLimit","TooManyAccountLocks","AddressLookupTableNotFound","InvalidAddressLookupTableOwner","InvalidAddressLookupTableData","InvalidAddressLookupTableIndex","InvalidRentPayingAccount","WouldExceedMaxVoteCostLimit","WouldExceedAccountDataTotalLimit","DuplicateInstruction","InsufficientFundsForRent","MaxLoadedAccountsDataSizeExceeded","InvalidLoadedAccountsDataSizeLimit","ResanitizationNeeded","ProgramExecutionTemporarilyRestricted","UnbalancedTransaction"];function Mo(e){return"object"==typeof e&&"InstructionError"in e?Oo(...e.InstructionError):Bo({errorCodeBaseOffset:7050001,getErrorContext:(e,t,n)=>e===fr?{errorName:t,...void 0!==n?{transactionErrorContext:n}:null}:e===Vr?{index:Number(n)}:e===Wr||e===Jr?{accountIndex:Number(n.account_index)}:void 0,orderedErrorNames:_o,rpcEnumError:e},Mo)}function Ro(e){let t;if("object"==typeof(n=e)&&null!==n&&"code"in n&&"message"in n&&("number"==typeof n.code||"bigint"==typeof n.code)&&"string"==typeof n.message){const{code:n,data:r,message:a}=e,o=Number(n);if(o===oe){const{err:e,...n}=r,a=e?{cause:Mo(e)}:null;t=new No(oe,{...n,...a})}else{let e;switch(o){case _:case M:case j:case R:case O:case K:case ie:case re:case J:case F:case X:case Z:case ee:case te:case H:e={__serverMessage:a};break;default:"object"!=typeof r||Array.isArray(r)||(e=r)}t=new No(o,e)}}else{const n="object"==typeof e&&null!==e&&"message"in e&&"string"==typeof e.message?e.message:"Malformed JSON-RPC error with no message attribute";t=new No(10,{error:e,message:n})}var n;return Co(t,Ro),t}function jo(e,t,n){const r=(0===n||n<=-e.byteLength)&&e.length===t.length?e:e.slice(n,n+t.length);return o=t,(a=r).length===o.length&&a.every((e,t)=>e===o[t]);var a,o}function Do(e,t){return"fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function Fo(e){return Object.freeze({...e,encode:t=>{const n=new Uint8Array(Do(t,e));return e.write(t,n,0),n}})}function Vo(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function Wo(e){return"fixedSize"in e&&"number"==typeof e.fixedSize}function Uo(e){if(!Wo(e))throw new No(da)}function qo(e,t,n,r=0){const a=n.length-r;if(a<t)throw new No(ca,{bytesLength:a,codecDescription:e,expected:t})}function Ho(e,t,n){if(t<0||t>n)throw new No(xa,{bytesLength:n,codecDescription:e,offset:t})}function Jo(e,t){const n=(n,r,a)=>{const o=e.encode(n);return a=t.write(o.length,r,a),r.set(o,a),a+o.length};if(Wo(t)&&Wo(e))return Fo({...e,fixedSize:t.fixedSize+e.fixedSize,write:n});const r=Wo(t)?t.fixedSize:t.maxSize??null,a=Wo(e)?e.fixedSize:e.maxSize??null,o=null!==r&&null!==a?r+a:null;return Fo({...e,...null!==o?{maxSize:o}:{},getSizeFromValue:n=>{const r=Do(n,e);return Do(r,t)+r},write:n})}function Go(e,t){return Fo({fixedSize:t,write:(n,r,a)=>{const o=e.encode(n),i=o.length>t?o.slice(0,t):o;return r.set(i,a),a+t}})}function Ko(e,t){return Vo({fixedSize:t,read:(n,r)=>{qo("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),Wo(e)&&(n=((e,t)=>function(e,t){if(e.length>=t)return e;const n=new Uint8Array(t).fill(0);return n.set(e),n}(e.length<=t?e:e.slice(0,t),t))(n,e.fixedSize));const[a]=e.read(n,0);return[a,r+t]}})}function Yo(e,t){return function(e,t){return Vo({...e,read:(n,r)=>{const a=e=>{return t=e,0===(r=n.length)?0:(t%r+r)%r;var t,r},o=t.preOffset?t.preOffset({bytes:n,preOffset:r,wrapBytes:a}):r;Ho("offsetDecoder",o,n.length);const[i,s]=e.read(n,o),c=t.postOffset?t.postOffset({bytes:n,newPreOffset:o,postOffset:s,preOffset:r,wrapBytes:a}):s;return Ho("offsetDecoder",c,n.length),[i,c]}})}(function(e){if(Wo(e)){const n=e.fixedSize+t;if(n<0)throw new No(va,{bytesLength:n,codecDescription:"resizeDecoder"});return Vo({...e,fixedSize:n})}return e}(e),{postOffset:({postOffset:e})=>e+t})}function Xo(e,t){return Fo({...(n=e,Wo(n)?e:{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}),write:(n,r,a)=>e.write(t(n),r,a)});var n}function Zo(e,t){return Vo({...e,read:(n,r)=>{const[a,o]=e.read(n,r);return[t(a,n,r),o]}})}function Qo(e,t){const[n,r]=e.split(new RegExp(`((?!${t}).*)`));return[n,r]}function ei(e,t){const n=BigInt(t.length);let r=0n;for(const a of e)r*=n,r+=BigInt(t.indexOf(a));return r}var ti,ni,ri="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ai=()=>{return e=ri,Fo({getSizeFromValue:t=>{const[n,r]=Qo(t,e[0]);if(!r)return t.length;const a=ei(r,e);return n.length+Math.ceil(a.toString(16).length/2)},write(t,n,r){if(function(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new No(ya,{alphabet:e,base:e.length,value:n})}(e,t),""===t)return r;const[a,o]=Qo(t,e[0]);if(!o)return n.set(new Uint8Array(a.length).fill(0),r),r+a.length;let i=ei(o,e);const s=[];for(;i>0n;)s.unshift(Number(i%256n)),i/=256n;const c=[...Array(a.length).fill(0),...s];return n.set(c,r),r+c.length}});var e},oi=()=>{return e=ri,Vo({read(t,n){const r=0===n||n<=-t.byteLength?t:t.slice(n);if(0===r.length)return["",t.length];let a=r.findIndex(e=>0!==e);a=-1===a?r.length:a;const o=e[0].repeat(a);if(a===r.length)return[o,t.length];const i=function(e,t){const n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}(r.slice(a).reduce((e,t)=>256n*e+BigInt(t),0n),e);return[o+i,t.length]}});var e},ii="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",si=e=>e.replace(/\u0000/g,""),ci=globalThis.TextDecoder,di=globalThis.TextEncoder,ui=()=>{let e;return Fo({getSizeFromValue:t=>(e||=new di).encode(t).length,write:(t,n,r)=>{const a=(e||=new di).encode(t);return n.set(a,r),r+a.length}})},li=()=>{let e;return Vo({read(t,n){const r=(e||=new ci).decode(t.slice(n));return[si(r),t.length]}})};function fi(e,t){try{return"exists"in e&&!e.exists?e:Object.freeze({...e,data:t.decode(e.data)})}catch{throw new No(xe,{address:e.address})}}function mi(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function pi(e,t,n={}){const{abortSignal:r,...a}=n;return function(e,t){if(!t)return Object.freeze({address:e,exists:!1});const n=Fo({getSizeFromValue:e=>{try{return atob(e).length}catch{throw new No(ya,{alphabet:ii,base:64,value:e})}},write(e,t,n){try{const r=atob(e).split("").map(e=>e.charCodeAt(0));return t.set(r,n),r.length+n}catch{throw new No(ya,{alphabet:ii,base:64,value:e})}}}).encode(t.data[0]);return Object.freeze({...mi(t),address:e,data:n,exists:!0})}(t,(await e.getAccountInfo(t,{...a,encoding:"base64"}).send({abortSignal:r})).value)}function hi(){return ti||(ti=ai()),ti}function gi(e){return function(e){if(e.length<32||e.length>44)throw new No(ce,{actualLength:e.length});const t=hi().encode(e).byteLength;if(32!==t)throw new No(se,{actualLength:t})}(e),e}function bi(){return Xo(Go(hi(),32),e=>gi(e))}function wi(){return Ko((ni||(ni=oi()),ni),32)}function yi(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:!1,localeMatcher:"best fit",numeric:!1,sensitivity:"variant",usage:"sort"}).compare}var vi=57896044618658097711785492504343953926634992332820282019728792003956564819949n,xi=19681161376707505956807079304988542015446066515923890162744021073123829784752n;function Ai(e){const t=e%vi;return t>=0n?t:vi+t}function Ti(e,t){let n=e;for(;t-- >0n;)n*=n,n%=vi;return n}function Si(e){if(32!==e.byteLength)return!1;const t=function(e){const t=e.reduce((e,t,n)=>`${function(e){const t=e.toString(16);return 1===t.length?`0${t}`:t}(31===n?-129&t:t)}${e}`,"");return BigInt(`0x${t}`)}(e);return function(e,t){const n=Ai(e*e),r=function(e,t){const n=Ai(t*t*t),r=function(e){const t=e*e%vi*e%vi,n=Ti(t,2n)*t%vi,r=Ti(n,1n)*e%vi,a=Ti(r,5n)*r%vi,o=Ti(a,10n)*a%vi,i=Ti(o,20n)*o%vi,s=Ti(i,40n)*i%vi,c=Ti(s,80n)*s%vi,d=Ti(c,80n)*s%vi,u=Ti(d,10n)*a%vi;return Ti(u,2n)*e%vi}(e*Ai(n*n*t));let a=Ai(e*n*r);const o=Ai(t*a*a),i=a,s=Ai(a*xi),c=o===e,d=o===Ai(-e),u=o===Ai(-e*xi);return c&&(a=i),(d||u)&&(a=s),1n==(1n&Ai(a))&&(a=Ai(-a)),c||d?a:null}(Ai(n-1n),Ai(37095705934669439343138083508754565189542113879843219016388785533085940283555n*n+1n));return!(null===r||0n===r&&128&t)}(t,e[31])}var ki=[80,114,111,103,114,97,109,68,101,114,105,118,101,100,65,100,100,114,101,115,115];async function Ii({programAddress:e,seeds:t}){if(function(){if(function(){if(!globalThis.isSecureContext)throw new No(Se)}(),void 0===globalThis.crypto||"function"!=typeof globalThis.crypto.subtle?.digest)throw new No(ke)}(),t.length>16)throw new No(me,{actual:t.length,maxSeeds:16});let n;const r=t.reduce((e,t,r)=>{const a="string"==typeof t?(n||=new TextEncoder).encode(t):t;if(a.byteLength>32)throw new No(pe,{actual:a.byteLength,index:r,maxSeedLength:32});return e.push(...a),e},[]),a=function(e,t){if(Wo(e)!==Wo(t))throw new No(la);if(Wo(e)&&Wo(t)&&e.fixedSize!==t.fixedSize)throw new No(fa,{decoderFixedSize:t.fixedSize,encoderFixedSize:e.fixedSize});if(!Wo(e)&&!Wo(t)&&e.maxSize!==t.maxSize)throw new No(ma,{decoderMaxSize:t.maxSize,encoderMaxSize:e.maxSize});return{...t,...e,decode:t.decode,encode:e.encode,read:t.read,write:e.write}}(bi(),wi()),o=a.encode(e),i=await crypto.subtle.digest("SHA-256",new Uint8Array([...r,...o,...ki])),s=new Uint8Array(i);if(Si(s))throw new No(he);return a.decode(s)}async function $i({programAddress:e,seeds:t}){let n=255;for(;n>0;)try{return[await Ii({programAddress:e,seeds:[...t,new Uint8Array([n])]}),n]}catch(r){if(!Eo(r,he))throw r;n--}throw new No(ge)}function Pi(e,t,n,r){if(r<t||r>n)throw new No(wa,{codecDescription:e,max:n,min:t,value:r})}function zi(e){return 1!==e?.endian}function Ei(e){return Fo({fixedSize:e.size,write(t,n,r){e.range&&Pi(e.name,e.range[0],e.range[1],t);const a=new ArrayBuffer(e.size);return e.set(new DataView(a),t,zi(e.config)),n.set(new Uint8Array(a),r),r+e.size}})}function Ni(e){return Vo({fixedSize:e.size,read(t,n=0){!function(e,t,n=0){if(t.length-n<=0)throw new No(sa,{codecDescription:e})}(e.name,t,n),qo(e.name,e.size,t,n);const r=new DataView(function(e,t,n){const r=e.byteOffset+(t??0),a=n??e.byteLength;let o;return"undefined"==typeof SharedArrayBuffer?o=e.buffer:e.buffer instanceof SharedArrayBuffer?(o=new ArrayBuffer(e.length),new Uint8Array(o).set(new Uint8Array(e))):o=e.buffer,0!==r&&r!==-e.byteLength||a!==e.byteLength?o.slice(r,r+a):o}(t,n,e.size));return[e.get(r,zi(e.config)),n+e.size]}})}var Ci=(e={})=>Ei({config:e,name:"i64",range:[-BigInt("0x7fffffffffffffff")-1n,BigInt("0x7fffffffffffffff")],set:(e,t,n)=>e.setBigInt64(0,BigInt(t),n),size:8}),Bi=(e={})=>Ni({config:e,get:(e,t)=>e.getBigInt64(0,t),name:"i64",size:8}),Li=()=>Fo({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,t,n)=>{Pi("shortU16",0,65535,e);const r=[0];for(let a=0;;a+=1){const t=Number(e)>>7*a;if(0===t)break;const n=127&t;r[a]=n,a>0&&(r[a-1]|=128)}return t.set(r,n),n+r.length}}),Oi=()=>Vo({maxSize:3,read:(e,t)=>{let n=0,r=0;for(;++r;){const a=r-1,o=e[t+a];if(n|=(127&o)<<7*a,!(128&o))break}return[n,t+r]}}),_i=(e={})=>Ei({config:e,name:"u16",range:[0,Number("0xffff")],set:(e,t,n)=>e.setUint16(0,Number(t),n),size:2}),Mi=(e={})=>Ei({config:e,name:"u32",range:[0,Number("0xffffffff")],set:(e,t,n)=>e.setUint32(0,Number(t),n),size:4}),Ri=(e={})=>Ni({config:e,get:(e,t)=>e.getUint32(0,t),name:"u32",size:4}),ji=(e={})=>Ei({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(e,t,n)=>e.setBigUint64(0,BigInt(t),n),size:8}),Di=(e={})=>Ni({config:e,get:(e,t)=>e.getBigUint64(0,t),name:"u64",size:8}),Fi=()=>Ei({name:"u8",range:[0,Number("0xff")],set:(e,t)=>e.setUint8(0,Number(t)),size:1}),Vi=()=>Ni({get:e=>e.getUint8(0),name:"u8",size:1});function Wi(e,t,n){if(t!==n)throw new No(pa,{actual:n,codecDescription:e,expected:t})}function Ui(e){return e.reduce((e,t)=>null===e||null===t?null:e+t,0)}function qi(e){return Wo(e)?e.fixedSize:null}function Hi(e){return Wo(e)?e.fixedSize:e.maxSize??null}function Ji(e,t={}){const n=t.size??Mi(),r=Ki(n,qi(e)),a=Ki(n,Hi(e))??void 0;return Fo({...null!==r?{fixedSize:r}:{getSizeFromValue:t=>("object"==typeof n?Do(t.length,n):0)+[...t].reduce((t,n)=>t+Do(n,e),0),maxSize:a},write:(r,a,o)=>("number"==typeof n&&Wi(t.description??"array",n,r.length),"object"==typeof n&&(o=n.write(r.length,a,o)),r.forEach(t=>{o=e.write(t,a,o)}),o)})}function Gi(e,t={}){const n=t.size??Ri(),r=qi(e),a=Ki(n,r),o=Ki(n,Hi(e))??void 0;return Vo({...null!==a?{fixedSize:a}:{maxSize:o},read:(t,r)=>{const a=[];if("object"==typeof n&&r>=t.length)return[a,r];if("remainder"===n){for(;r<t.length;){const[n,o]=e.read(t,r);r=o,a.push(n)}return[a,r]}const[o,i]="number"==typeof n?[n,r]:n.read(t,r);r=i;for(let n=0;n<o;n+=1){const[n,o]=e.read(t,r);r=o,a.push(n)}return[a,r]}})}function Ki(e,t){return"number"!=typeof e?null:0===e?0:null===t?null:t*e}function Yi(e={}){return Zo(e.size??Vi(),e=>1===Number(e))}function Xi(){return Fo({getSizeFromValue:e=>e.length,write:(e,t,n)=>(t.set(e,n),n+e.length)})}function Zi(){return Vo({read:(e,t)=>{const n=e.slice(t);return[n,t+n.length]}})}function Qi(e,t){const n=Ui(e.map(qi)),r=Ui(e.map(Hi))??void 0;return Fo({...null===n?{getSizeFromValue:t=>e.map((e,n)=>Do(t[n],e)).reduce((e,t)=>e+t,0),maxSize:r}:{fixedSize:n},write:(t,n,r)=>(Wi("tuple",e.length,t.length),e.forEach((e,a)=>{r=e.write(t[a],n,r)}),r)})}function es(e){const t=Ui(e.map(qi)),n=Ui(e.map(Hi))??void 0;return Vo({...null===t?{maxSize:n}:{fixedSize:t},read:(t,n)=>{const r=[];return e.forEach(e=>{const[a,o]=e.read(t,n);r.push(a),n=o}),[r,n]}})}function ts(e,t){const n=as(e),r=(n,r,a)=>{const o=t(n);return rs(e,o),e[o].write(n,r,a)};if(null!==n)return Fo({fixedSize:n,write:r});const a=os(e);return Fo({...null!==a?{maxSize:a}:{},getSizeFromValue:n=>{const r=t(n);return rs(e,r),Do(n,e[r])},write:r})}function ns(e,t){const n=as(e),r=(n,r)=>{const a=t(n,r);return rs(e,a),e[a].read(n,r)};if(null!==n)return Vo({fixedSize:n,read:r});const a=os(e);return Vo({...null!==a?{maxSize:a}:{},read:r})}function rs(e,t){if(void 0===e[t])throw new No(Sa,{maxRange:e.length-1,minRange:0,variant:t})}function as(e){if(0===e.length)return 0;if(!Wo(e[0]))return null;const t=e[0].fixedSize;return e.every(e=>Wo(e)&&e.fixedSize===t)?t:null}function os(e){return e.map(e=>Hi(e)).reduce((e,t)=>null===e||null===t?null:Math.max(e,t),0)}function is(e){if(0===e.length)return"";let t=[e[0],e[0]];const n=[];for(let r=1;r<e.length;r++){const a=e[r];t[1]+1===a?t[1]=a:(n.push(t[0]===t[1]?`${t[0]}`:`${t[0]}-${t[1]}`),t=[a,a])}return n.push(t[0]===t[1]?`${t[0]}`:`${t[0]}-${t[1]}`),n.join(", ")}function ss(e,t={}){const n=t.size??Vi(),r=t.useValuesAsDiscriminators??!1,{enumKeys:a,enumValues:o,numericalValues:i}=function(e){const t=[...new Set(Object.values(e).filter(e=>"number"==typeof e))].sort(),n=Object.fromEntries(Object.entries(e).slice(t.length)),r=Object.keys(n),a=Object.values(n),o=[.../* @__PURE__ */new Set([...r,...a.filter(e=>"string"==typeof e)])];return{enumKeys:r,enumRecord:n,enumValues:a,numericalValues:t,stringValues:o}}(e);if(r&&o.some(e=>"string"==typeof e))throw new No(za,{stringValues:o.filter(e=>"string"==typeof e)});return Zo(n,e=>{const t=Number(e),n=function({discriminator:e,enumKeys:t,enumValues:n,useValuesAsDiscriminators:r}){return r?function(e,t){let n=e.length;for(;n--;)if(t(e[n]))return n;return-1}(n,t=>t===e):e>=0&&e<t.length?e:-1}({discriminator:t,enumKeys:a,enumValues:o,useValuesAsDiscriminators:r});if(n<0){const e=r?i:[...Array(a.length).keys()];throw new No(ha,{discriminator:t,formattedValidDiscriminators:is(e),validDiscriminators:e})}return o[n]})}function cs(){return Fo({fixedSize:0,write:(e,t,n)=>n})}function ds(){return Vo({fixedSize:0,read:(e,t)=>[void 0,t]})}function us(e){return ts(e.map(([,e])=>e),t=>{const n=e.findIndex(([e])=>e(t));if(-1===n)throw new No(Na);return n})}function ls(e){const t=e.map(([,e])=>e),n=Ui(t.map(qi)),r=Ui(t.map(Hi))??void 0;return Fo({...null===n?{getSizeFromValue:t=>e.map(([e,n])=>Do(t[e],n)).reduce((e,t)=>e+t,0),maxSize:r}:{fixedSize:n},write:(t,n,r)=>(e.forEach(([e,a])=>{r=a.write(t[e],n,r)}),r)})}function fs(e){const t=e.map(([,e])=>e),n=Ui(t.map(qi)),r=Ui(t.map(Hi))??void 0;return Vo({...null===n?{maxSize:r}:{fixedSize:n},read:(t,n)=>{const r={};return e.forEach(([e,a])=>{const[o,i]=a.read(t,n);n=i,r[e]=o}),[r,n]}})}function ms(e,t={}){const n=null===t.prefix?Zo(ds(),()=>!1):Yi({size:t.prefix??Vi()}),r="zeroes"===t.noneValue?(Uo(e),Ko(ds(),e.fixedSize)):t.noneValue?Vo({fixedSize:(a=t.noneValue).length,read:(e,t)=>{const n=Vo({read:(e,t)=>[e.slice(t).reduce((e,t)=>e+t.toString(16).padStart(2,"0"),""),e.length]});if(!jo(e,a,t))throw new No(ka,{constant:a,data:e,hexConstant:n.decode(a),hexData:n.decode(e),offset:t});return[void 0,t+a.length]}}):ds();var a;return ns([Zo(es([n,r]),()=>({__option:"None"})),Zo(es([n,e]),([,e])=>(e=>({__option:"Some",value:e}))(e))],(e,a)=>null!==t.prefix||t.noneValue?null===t.prefix&&null!=t.noneValue?jo(e,"zeroes"===t.noneValue?new Uint8Array(r.fixedSize).fill(0):t.noneValue,a)?0:1:Number(n.read(e,a)[0]):Number(a<e.length))}function ps(e,...t){return t.reduce((e,t)=>t(e),e)}var hs,gs,bs=/* @__PURE__ */(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(bs||{});function ws(e){return e>=2}function ys(e){return!!(1&e)}function vs(e,t){return e|t}function xs(){return hs||(hs=Fi()),hs}function As(){return ls([["numSignerAccounts",xs()],["numReadonlySignerAccounts",xs()],["numReadonlyNonSignerAccounts",xs()]])}function Ts(){return gs||(gs=Xo(ls([["programAddressIndex",Fi()],["accountIndices",Ji(Fi(),{size:Li()})],["data",Jo(Xi(),Li())]]),e=>void 0!==e.accountIndices&&void 0!==e.data?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)})),gs}var Ss;function ks(e,t){const[n,r]=e.split(new RegExp(`((?!${t}).*)`));return[n,r]}function Is(e,t){const n=BigInt(t.length);let r=0n;for(const a of e)r*=n,r+=BigInt(t.indexOf(a));return r}function $s(){return Xo(function(e,t={}){const n=null===t.prefix?Xo(cs(),e=>{}):function(e={}){return Xo(e.size??Fi(),e=>e?1:0)}({size:t.prefix??Fi()});var r;return ts([Xo(Qi([n,"zeroes"===t.noneValue?(Uo(e),Go(cs(),e.fixedSize)):t.noneValue?Fo({fixedSize:(r=t.noneValue).length,write:(e,t,n)=>(t.set(r,n),n+r.length)}):cs()]),e=>[!1,void 0]),Xo(Qi([n,e]),e=>[!0,e])],e=>Number(null!==e))}(Go((e="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",Fo({getSizeFromValue:t=>{const[n,r]=ks(t,e[0]);if(!r)return t.length;const a=Is(r,e);return n.length+Math.ceil(a.toString(16).length/2)},write(t,n,r){if(function(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new No(ya,{alphabet:e,base:e.length,value:n})}(e,t),""===t)return r;const[a,o]=ks(t,e[0]);if(!o)return n.set(new Uint8Array(a.length).fill(0),r),r+a.length;let i=Is(o,e);const s=[];for(;i>0n;)s.unshift(Number(i%256n)),i/=256n;const c=[...Array(a.length).fill(0),...s];return n.set(c,r),r+c.length}})),32),{noneValue:"zeroes",prefix:null}),e=>e??null);var e}function Ps(){return Fo({getSizeFromValue:e=>"legacy"===e?0:1,maxSize:1,write:(e,t,n)=>{if("legacy"===e)return n;if(e<0||e>127)throw new No(zn,{actualVersion:e});if(e>1)throw new No(Hn,{unsupportedVersion:e});return t.set([128|e],n),n+1}})}function zs(){return Vo({maxSize:1,read:(e,t)=>{const n=e[t];if(128&n){const e=128^n;if(e>1)throw new No(Hn,{unsupportedVersion:e});return[e,t+1]}return["legacy",t]}})}function Es(){if(!Ss){const e=Ji(Fi(),{size:Li()});Ss=ls([["lookupTableAddress",bi()],["writableIndexes",e],["readonlyIndexes",e]])}return Ss}function Ns(e,t,n){e[t]=n(e[t]??{role:bs.READONLY})}var Cs=/* @__PURE__ */Symbol("AddressMapTypeProperty");function Bs(e,t){const n={[e]:{[Cs]:0,role:bs.WRITABLE_SIGNER}},r=/* @__PURE__ */new Set;for(const a of t)if(Ns(n,a.programAddress,e=>{if(r.add(a.programAddress),Cs in e){if(ys(e.role)){if(0===e[Cs])throw new No(kn,{programAddress:a.programAddress});throw new No(In,{programAddress:a.programAddress})}if(1===e[Cs])return e}return{[Cs]:1,role:bs.READONLY}}),a.accounts)for(const e of a.accounts)Ns(n,e.address,t=>{const{address:n,...a}=e;if(Cs in t)switch(t[Cs]){case 0:return t;case 1:{const n=vs(t.role,a.role);if(r.has(e.address)){if(ys(a.role))throw new No(In,{programAddress:e.address});return t.role!==n?{...t,role:n}:t}return t.role!==n?{...t,role:n}:t}}return{...a,[Cs]:1}});return n}function Ls(e){let t;return Object.entries(e).sort(([e,n],[r,a])=>{if(n[Cs]!==a[Cs]){if(0===n[Cs])return-1;if(0===a[Cs])return 1;if(1===n[Cs])return-1;if(1===a[Cs])return 1}const o=ws(n.role);if(o!==ws(a.role))return o?-1:1;const i=ys(n.role);return i!==ys(a.role)?i?-1:1:(t||=yi(),t(e,r))}).map(([e,t])=>({address:e,...t}))}function Os(e){let t=0,n=0,r=0;for(const a of e){if("lookupTableAddress"in a)break;const e=ys(a.role);ws(a.role)?(r++,e||n++):e||t++}return{numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:n,numSignerAccounts:r}}function _s(e){const t={};for(const[n,r]of e.entries())t[r.address]=n;return t}function Ms(e,t){const n=_s(t);return e.map(({accounts:e,data:t,programAddress:r})=>({programAddressIndex:n[r],...e?{accountIndices:e.map(({address:e})=>n[e])}:null,...t?{data:t}:null}))}function Rs(e){return"nonce"in e?e.nonce:e.blockhash}function js(e,t,n){e[t]=n(e[t]??{role:bs.READONLY})}var Ds=/* @__PURE__ */Symbol("AddressMapTypeProperty");function Fs(e){const t={};for(const n of e){if(!("lookupTableAddress"in n))continue;const e=t[n.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};n.role===bs.WRITABLE?e.writableIndexes.push(n.addressIndex):e.readonlyIndexes.push(n.addressIndex)}return Object.keys(t).sort(yi()).map(e=>({lookupTableAddress:e,...t[e]}))}function Vs(e,t){const n=function(e){const t={};for(const[n,r]of e.entries())t[r.address]=n;return t}(t);return e.map(({accounts:e,data:t,programAddress:r})=>({programAddressIndex:n[r],...e?{accountIndices:e.map(({address:e})=>n[e])}:null,...t?{data:t}:null}))}function Ws(e){const t=e.findIndex(e=>"lookupTableAddress"in e);return(-1===t?e:e.slice(0,t)).map(({address:e})=>e)}function Us(e){let t=0;return void 0!==e.priorityFeeLamports&&(t|=3),void 0!==e.computeUnitLimit&&(t|=4),void 0!==e.loadedAccountsDataSizeLimit&&(t|=8),void 0!==e.heapSize&&(t|=16),t}function qs(e){const t=[];return void 0!==e.priorityFeeLamports&&t.push({kind:"u64",value:e.priorityFeeLamports}),void 0!==e.computeUnitLimit&&t.push({kind:"u32",value:e.computeUnitLimit}),void 0!==e.loadedAccountsDataSizeLimit&&t.push({kind:"u32",value:e.loadedAccountsDataSizeLimit}),void 0!==e.heapSize&&t.push({kind:"u32",value:e.heapSize}),t}function Hs(e){const t=e.version;if("legacy"===t)return function(e){const t=Ls(Bs(e.feePayer.address,e.instructions)),n=t.length;if(n>64)throw new No(ar,{actualCount:n,maxAllowed:64});const r=t.filter(e=>ws(e.role)).length;if(r>12)throw new No(rr,{actualCount:r,maxAllowed:12});const a=e.instructions.length;if(a>64)throw new No(or,{actualCount:a,maxAllowed:64});for(let i=0;i<e.instructions.length;i++){const t=e.instructions[i].accounts?.length??0;if(t>255)throw new No(ir,{actualCount:t,instructionIndex:i,maxAllowed:255})}const o=e.lifetimeConstraint;return{...o?{lifetimeToken:Rs(o)}:null,header:Os(t),instructions:Ms(e.instructions,t),staticAccounts:t.map(e=>e.address),version:e.version}}(e);if(0===t)return function(e){const t=function(e){let t;return Object.entries(e).sort(([e,n],[r,a])=>{if(n[Ds]!==a[Ds]){if(0===n[Ds])return-1;if(0===a[Ds])return 1;if(2===n[Ds])return-1;if(2===a[Ds])return 1}const o=ws(n.role);if(o!==ws(a.role))return o?-1:1;const i=ys(n.role);return i!==ys(a.role)?i?-1:1:(t||=yi(),1===n[Ds]&&1===a[Ds]&&n.lookupTableAddress!==a.lookupTableAddress?t(n.lookupTableAddress,a.lookupTableAddress):t(e,r))}).map(([e,t])=>({address:e,...t}))}(function(e,t){const n={[e]:{[Ds]:0,role:bs.WRITABLE_SIGNER}},r=/* @__PURE__ */new Set;for(const a of t){let e;if(js(n,a.programAddress,e=>{if(r.add(a.programAddress),Ds in e){if(ys(e.role)){if(0===e[Ds])throw new No(kn,{programAddress:a.programAddress});throw new No(In,{programAddress:a.programAddress})}if(2===e[Ds])return e}return{[Ds]:2,role:bs.READONLY}}),a.accounts)for(const t of a.accounts)js(n,t.address,n=>{const{address:a,...o}=t;if(Ds in n)switch(n[Ds]){case 0:return n;case 1:{const t=vs(n.role,o.role);if("lookupTableAddress"in o){if(n.lookupTableAddress!==o.lookupTableAddress&&(e||=yi())(o.lookupTableAddress,n.lookupTableAddress)<0)return{[Ds]:1,...o,role:t}}else if(ws(o.role))return{[Ds]:2,role:t};return n.role!==t?{...n,role:t}:n}case 2:{const e=vs(n.role,o.role);if(r.has(t.address)){if(ys(o.role))throw new No(In,{programAddress:t.address});return n.role!==e?{...n,role:e}:n}return"lookupTableAddress"in o&&!ws(n.role)?{...o,[Ds]:1,role:e}:n.role!==e?{...n,role:e}:n}}return"lookupTableAddress"in o?{...o,[Ds]:1}:{...o,[Ds]:2}})}return n}(e.feePayer.address,e.instructions)),n=t.length;if(n>64)throw new No(ar,{actualCount:n,maxAllowed:64});const r=t.filter(e=>ws(e.role)).length;if(r>12)throw new No(rr,{actualCount:r,maxAllowed:12});const a=e.instructions.length;if(a>64)throw new No(or,{actualCount:a,maxAllowed:64});for(let i=0;i<e.instructions.length;i++){const t=e.instructions[i].accounts?.length??0;if(t>255)throw new No(ir,{actualCount:t,instructionIndex:i,maxAllowed:255})}const o=e.lifetimeConstraint;return{addressTableLookups:Fs(t),...o?{lifetimeToken:Rs(o)}:null,header:Os(t),instructions:Vs(e.instructions,t),staticAccounts:Ws(t),version:e.version}}(e);if(1===t)return function(e){const t=Ls(Bs(e.feePayer.address,e.instructions)),n=t.length;if(n>64)throw new No(ar,{actualCount:n,maxAllowed:64});const r=t.filter(e=>ws(e.role)).length;if(r>12)throw new No(rr,{actualCount:r,maxAllowed:12});const a=e.instructions.length;if(a>64)throw new No(or,{actualCount:a,maxAllowed:64});for(let s=0;s<e.instructions.length;s++){const t=e.instructions[s].accounts?.length??0;if(t>255)throw new No(ir,{actualCount:t,instructionIndex:s,maxAllowed:255})}const o=_s(t),i=e.lifetimeConstraint;return{version:1,...i?{lifetimeToken:Rs(i)}:null,configMask:Us(e.config??{}),configValues:qs(e.config??{}),header:Os(t),instructionHeaders:e.instructions.map(e=>function(e,t){return{numInstructionAccounts:e.accounts?.length??0,numInstructionDataBytes:e.data?.byteLength??0,programAccountIndex:t[e.programAddress]}}(e,o)),instructionPayloads:e.instructions.map(e=>function(e,t){return{instructionAccountIndices:e.accounts?.map(({address:e})=>t[e])??[],instructionData:e.data??new Uint8Array}}(e,o)),numInstructions:e.instructions.length,numStaticAccounts:t.length,staticAccounts:t.map(e=>e.address)}}(e);throw new No(Hn,{version:t})}function Js(e){return null!==e&&("object"==typeof e||"function"==typeof e)}function Gs(e){const t=/* @__PURE__ */new Set,n={deferreds:t,settled:!1};return Promise.resolve(e).then(e=>{for(const{resolve:n}of t)n(e);t.clear(),n.settled=!0},e=>{for(const{reject:n}of t)n(e);t.clear(),n.settled=!0}),n}var Ks,Ys=/* @__PURE__ */new WeakMap;function Xs(e){const t=Object.values(e);if(0===t.length)throw new No(Fn);return t.map(e=>e||new Uint8Array(64).fill(0))}function Zs(){return e=e=>"signaturesFirst"===function(e){if(0===e.length)throw new No(Kn);return 1===zs().decode(e)?"messageFirst":"signaturesFirst"}(e.messageBytes),ts([ls([["signatures",Xo(Ji(Go(Xi(),64),{size:Li()}),Xs)],["messageBytes",Xi()]]),function(){const e=Xi();return Fo({getSizeFromValue:e=>{const t=Qs(e.messageBytes,0);return e.messageBytes.length+64*t},write:(t,n,r)=>{r=e.write(t.messageBytes,n,r);var a;return(a=Qs(t.messageBytes,0),Xo(Ji(Go(Xi(),64),{description:"signatures",size:a}),Xs)).write(t.signatures,n,r)}})}()],t=>e(t)?0:1);var e}function Qs(e,t){if(e.length<t+2)throw new No(Gn,{messageBytes:e});return e[t+1]}function ec(e){const{messageBytes:t,signatures:n}=e,r=es([zs(),Yo(Vi(),2),Gi(wi(),{size:Oi()})]),[a,o,i]=r.decode(t),s=i.slice(0,o);if(s.length!==n.length)throw new No(Vn,{numRequiredSignatures:o,signaturesLength:n.length,signerAddresses:s});const c=nc(s,n);return{messageBytes:t,signatures:Object.freeze(c)}}function tc(e){const{messageBytes:t,signatures:n}=e,r=t[1],a=Gi(wi(),{size:r}).decode(t,42);if(a.length!==n.length)throw new No(Vn,{numRequiredSignatures:r,signaturesLength:n.length,signerAddresses:a});return{messageBytes:t,signatures:nc(a,n)}}function nc(e,t){const n={};return e.forEach((e,r)=>{const a=t[r];a.every(e=>0===e)?n[e]=null:n[e]=a}),Object.freeze(n)}function rc(e){const t=Hs(e),n=Xo(us([[e=>"legacy"===e.version,Xo(ls([["header",As()],["staticAccounts",Ji(bi(),{size:Li()})],["lifetimeToken",$s()],["instructions",Ji(Ts(),{size:Li()})]]),e=>({...e,lifetimeToken:"lifetimeToken"in e?e.lifetimeToken:void 0}))],[e=>0===e.version,Xo(ls([["version",Ps()],["header",As()],["staticAccounts",Ji(bi(),{size:Li()})],["lifetimeToken",$s()],["instructions",Ji(Ts(),{size:Li()})],["addressTableLookups",Ji(Es(),{size:Li()})]]),e=>({...e,addressTableLookups:e.addressTableLookups??[],lifetimeToken:"lifetimeToken"in e?e.lifetimeToken:void 0}))],[e=>1===e.version,Xo(ls([["version",Ps()],["header",As()],["configMask",Mi()],["lifetimeToken",$s()],["numInstructions",Fi()],["numStaticAccounts",Fi()],["staticAccounts",Ji(bi(),{size:"remainder"})],["configValues",Ji(us([[e=>"u32"===e.kind,Xo(ls([["value",Mi()]]),e=>e)],[e=>"u64"===e.kind,Xo(ls([["value",ji()]]),e=>e)]]),{size:"remainder"})],["instructionHeaders",Ji(ls([["programAccountIndex",Fi()],["numInstructionAccounts",Fi()],["numInstructionDataBytes",_i()]]),{size:"remainder"})],["instructionPayloads",Ji(ls([["instructionAccountIndices",Ji(Fi(),{size:"remainder"})],["instructionData",Xi()]]),{size:"remainder"})]]),e=>({...e,lifetimeToken:"lifetimeToken"in e?e.lifetimeToken:void 0}))]]),e=>{if("legacy"!==e.version&&e.version>1)throw new No(Hn,{unsupportedVersion:e.version});return e}).encode(t),r=t.staticAccounts.slice(0,t.header.numSignerAccounts),a={};for(const i of r)a[i]=null;let o;return function(e){return"lifetimeConstraint"in e&&"string"==typeof e.lifetimeConstraint.blockhash&&"bigint"==typeof e.lifetimeConstraint.lastValidBlockHeight&&function(e){if(e.length<32||e.length>44)return!1;const t=hi();try{return 32===t.encode(e).byteLength}catch{return!1}}(e.lifetimeConstraint.blockhash)}(e)?o={blockhash:e.lifetimeConstraint.blockhash,lastValidBlockHeight:e.lifetimeConstraint.lastValidBlockHeight}:function(e){return"lifetimeConstraint"in e&&"string"==typeof e.lifetimeConstraint.nonce&&null!=e.instructions[0]&&"11111111111111111111111111111111"===(t=e.instructions[0]).programAddress&&null!=t.data&&4===(n=t.data).byteLength&&4===n[0]&&0===n[1]&&0===n[2]&&0===n[3]&&3===t.accounts?.length&&null!=t.accounts[0].address&&t.accounts[0].role===bs.WRITABLE&&"SysvarRecentB1ockHashes11111111111111111111"===t.accounts[1].address&&t.accounts[1].role===bs.READONLY&&null!=t.accounts[2].address&&ws(t.accounts[2].role);var t,n}(e)&&(o={nonce:e.lifetimeConstraint.nonce,nonceAccountAddress:e.instructions[0].accounts[0].address}),Object.freeze({...o?{lifetimeConstraint:o}:void 0,messageBytes:n,signatures:Object.freeze(a)})}function ac(e){const t=Zs().encode(e);return Vo({read(e,t=0){const n=e.slice(t);return[btoa(String.fromCharCode(...n)),e.length]}}).decode(t)}var oc=/* @__PURE__ */new Set(["then","toJSON",/* @__PURE__ */Symbol.for("nodejs.util.inspect.custom"),Symbol.asyncIterator,Symbol.iterator,Symbol.toPrimitive,Symbol.toStringTag,Symbol.asyncDispose,Symbol.dispose].filter(e=>null!=e)),ic=/* @__PURE__ */new Set(["__defineGetter__","__defineSetter__","__lookupGetter__","__lookupSetter__","__proto__","constructor","hasOwnProperty","isPrototypeOf","propertyIsEnumerable","toLocaleString","toString","valueOf"]);function sc(e,t){if(!oc.has(e))return Reflect.get(Object.prototype,e,t)}function cc(e){return oc.has(e)||ic.has(e)}var dc=/^(-?)(\d+)(?:[eE]\+?(\d+))?$/;function uc(e,t){if(!e[t]?.match(/[-\d]/))return null;const n=e.slice(t).match(/^-?(?:0|[1-9]\d*)(?:\.\d+)?(?:[eE][+-]?\d+)?/);return n?n[0]:null}function lc(e){return`{"$n":"${e}"}`}var fc=0n;function mc(){const e=fc;return fc++,e.toString()}var pc=globalThis.AbortController,hc=Object.freeze({data:void 0,error:void 0,status:"idle"});function gc(e){return function(e){return new Proxy(e.api,{defineProperty:()=>!1,deleteProperty:()=>!1,get:(t,n,r)=>cc(n)?sc(n,r):function(...a){const o=n.toString(),i=Reflect.get(t,o,r);if(!i)throw new No(Ka,{method:o,params:a});const s=i(...a);return function({transport:e},t){return{reactiveStore:()=>function(){let n,r=hc;const a=/* @__PURE__ */new Set;function o(e){r.status===e.status&&r.data===e.data&&r.error===e.error||(r=e,a.forEach(e=>e()))}const i=async(a,...i)=>{if(n?.abort(),a?.aborted)throw o({data:r.data,error:a.reason,status:"error"}),a.reason;const s=new pc;n=s;const c=a?AbortSignal.any([s.signal,a]):s.signal,d=r.data;o({data:d,error:r.error,status:"running"});try{const n=await(u=(n=>t.execute({signal:n,transport:e}))(c,...i),l=c,l?async function(e){let t;const n=new Promise((n,r)=>{t={reject:r,resolve:n};for(const a of e){if(!Js(a)){Promise.resolve(a).then(n,r);continue}let e=Ys.get(a);void 0===e?(e=Gs(a),e.deferreds.add(t),Ys.set(a,e)):e.settled?Promise.resolve(a).then(n,r):e.deferreds.add(t)}});return await n.finally(()=>{for(const n of e)Js(n)&&Ys.get(n).deferreds.delete(t)})}([new Promise((e,t)=>{l.aborted?t(l.reason):l.addEventListener("abort",function(){t(this.reason)})}),u]):u);if(c.aborted)throw c.reason;return o({data:n,error:void 0,status:"success"}),n}catch(f){if(s.signal.aborted)throw s.signal.reason;throw o({data:d,error:f,status:"error"}),f}var u,l},s=(...e)=>i(void 0,...e);return{dispatch:(...e)=>{s(...e).catch(()=>{})},dispatchAsync:s,getState:()=>r,reset:()=>{n?.abort(),n=void 0,o(hc)},subscribe:e=>(a.add(e),()=>{a.delete(e)}),withSignal:e=>({dispatch:(...t)=>{i(e,...t).catch(()=>{})},dispatchAsync:(...t)=>i(e,...t)})}}(),send:async n=>await t.execute({signal:n?.abortSignal,transport:e})}}(e,s)}})}(e)}function bc(e){return null!=e&&"object"==typeof e&&!Array.isArray(e)&&"jsonrpc"in e&&"2.0"===e.jsonrpc&&"method"in e&&"string"==typeof e.method&&"params"in e}function wc({commitmentPropertyName:e,params:t,optionsObjectPositionInParams:n,overrideCommitment:r}){const a=t[n];if(void 0===a||a&&"object"==typeof a&&!Array.isArray(a)){if(!a||!(e in a)){const o=[...t];return o[n]={...a,[e]:r},o}if(!a[e]||"finalized"===a[e]){const r=[...t],{[e]:o,...i}=a;return Object.keys(i).length>0?r[n]=i:n===r.length-1?r.length--:r[n]=void 0,r}}return t}function yc(e){return(t,{keyPath:n})=>("bigint"==typeof t&&e&&(t>Number.MAX_SAFE_INTEGER||t<-Number.MAX_SAFE_INTEGER)&&e(n,t),t)}var vc={};function xc(e){return function t(n,r){if(Array.isArray(n))return n.map((e,n)=>{const a={...r,keyPath:[...r.keyPath,n]};return t(e,a)});if("object"==typeof n&&null!==n){const e={};for(const a in n){if(!Object.prototype.hasOwnProperty.call(n,a))continue;const o={...r,keyPath:[...r.keyPath,a]};e[a]=t(n[a],o)}return e}return e.reduce((e,t)=>t(e,r),n)}}function Ac(e,t){return n=>xc(e)(n,t)}var Tc={accountNotifications:1,blockNotifications:1,getAccountInfo:1,getBalance:1,getBlock:1,getBlockHeight:0,getBlockProduction:0,getBlocks:2,getBlocksWithLimit:2,getEpochInfo:0,getFeeForMessage:1,getInflationGovernor:0,getInflationReward:1,getLargestAccounts:0,getLatestBlockhash:0,getLeaderSchedule:1,getMinimumBalanceForRentExemption:1,getMultipleAccounts:1,getProgramAccounts:1,getSignaturesForAddress:1,getSlot:0,getSlotLeader:0,getStakeMinimumDelegation:0,getSupply:0,getTokenAccountBalance:1,getTokenAccountsByDelegate:2,getTokenAccountsByOwner:2,getTokenLargestAccounts:1,getTokenSupply:1,getTransaction:1,getTransactionCount:0,getVoteAccounts:0,isBlockhashValid:1,logsNotifications:1,programNotifications:1,requestAirdrop:2,sendTransaction:1,signatureNotifications:1,simulateTransaction:1};function Sc(e){const t=e?.onIntegerOverflow;return n=>{return ps(n,t?(r=t,e=>{const t=(n=[yc((...t)=>r(e,...t))],a={keyPath:[]},e=>{const t=xc(n);return Object.freeze({...e,params:t(e.params,a)})});var n,a;return t(e)}):e=>e,function({defaultCommitment:e,optionsObjectPositionByMethod:t}){return n=>{const{params:r,methodName:a}=n;if(!Array.isArray(r))return n;const o=t[a];return null==o?n:Object.freeze({methodName:a,params:wc({commitmentPropertyName:"sendTransaction"===a?"preflightCommitment":"commitment",optionsObjectPositionInParams:o,overrideCommitment:e,params:r})})}}({defaultCommitment:e?.defaultCommitment,optionsObjectPositionByMethod:Tc}));var r}}function kc(e){return function(t,{keyPath:n}){return"number"==typeof t&&Number.isInteger(t)||"bigint"==typeof t?function(e,t){return t.some(t=>{if(t.length!==e.length)return!1;for(let n=e.length-1;n>=0;n--){const r=e[n],a=t[n];if(a!==r&&(a!==vc||"number"!=typeof r))return!1}return!0})}(n,e)?Number(t):BigInt(t):t}}var Ic,$c=[["data","parsed","info","tokenAmount","decimals"],["data","parsed","info","tokenAmount","uiAmount"],["data","parsed","info","rentExemptReserve","decimals"],["data","parsed","info","rentExemptReserve","uiAmount"],["data","parsed","info","delegatedAmount","decimals"],["data","parsed","info","delegatedAmount","uiAmount"],["data","parsed","info","extensions",vc,"state","olderTransferFee","transferFeeBasisPoints"],["data","parsed","info","extensions",vc,"state","newerTransferFee","transferFeeBasisPoints"],["data","parsed","info","extensions",vc,"state","preUpdateAverageRate"],["data","parsed","info","extensions",vc,"state","currentRate"]],Pc=[...$c,["data","parsed","info","lastExtendedSlotStartIndex"],["data","parsed","info","slashPenalty"],["data","parsed","info","warmupCooldownRate"],["data","parsed","info","decimals"],["data","parsed","info","numRequiredSigners"],["data","parsed","info","numValidSigners"],["data","parsed","info","stake","delegation","warmupCooldownRate"],["data","parsed","info","exemptionThreshold"],["data","parsed","info","burnPercent"],["data","parsed","info","blockRevenueCommissionBps"],["data","parsed","info","commission"],["data","parsed","info","inflationRewardsCommissionBps"],["data","parsed","info","votes",vc,"confirmationCount"],["data","parsed","info","votes",vc,"latency"]],zc=[["index"],["instructions",vc,"accounts",vc],["instructions",vc,"programIdIndex"],["instructions",vc,"stackHeight"]],Ec=[["accountIndex"],["uiTokenAmount","decimals"],["uiTokenAmount","uiAmount"]],Nc=[["addressTableLookups",vc,"writableIndexes",vc],["addressTableLookups",vc,"readonlyIndexes",vc],["header","numReadonlySignedAccounts"],["header","numReadonlyUnsignedAccounts"],["header","numRequiredSignatures"],["instructions",vc,"accounts",vc],["instructions",vc,"programIdIndex"],["instructions",vc,"stackHeight"]];function Cc(e){return(t,n)=>{const r=n.methodName,a=e?.allowedNumericKeyPaths&&r?e.allowedNumericKeyPaths[r]:void 0;return ps(t,e=>((e,t)=>{const n=e;if("error"in n){const{error:e}=n;if(e&&"object"==typeof e&&"code"in e&&(-32002===e.code||-32002n===e.code)&&"data"in e&&e.data){const n=Ac([kc([["loadedAccountsDataSize"],...Pc.map(e=>["accounts",vc,...e]),...zc.map(e=>["innerInstructions",vc,...e])])],{keyPath:[]})(e.data,t);throw Ro({...e,data:n})}throw Ro(n.error)}return n})(e,n),e=>e.result,e=>Ac([kc(a??[])],{keyPath:[]})(e,n))}}function Bc(e){return function(e){return new Proxy({},{defineProperty:()=>!1,deleteProperty:()=>!1,get(...t){const[n,r]=t;if(cc(r))return sc(r,t[2]);const a=r.toString();return function(...t){const n=Object.freeze({methodName:a,params:t}),r=e?.requestTransformer?e?.requestTransformer(n):n;return Object.freeze({execute:async({signal:t,transport:n})=>{const a=function(e){return{id:mc(),jsonrpc:"2.0",method:e.methodName,params:e.params}}(r),o=await n({payload:a,signal:t});return e?.responseTransformer?e.responseTransformer(o,r):o}})}}})}({requestTransformer:Sc(e),responseTransformer:Cc({allowedNumericKeyPaths:(Ic||(Ic={getAccountInfo:Pc.map(e=>["value",...e]),getBlock:[...Ec.flatMap(e=>[["transactions",vc,"meta","preTokenBalances",vc,...e],["transactions",vc,"meta","postTokenBalances",vc,...e]]),["transactions",vc,"meta","rewards",vc,"commission"],...zc.map(e=>["transactions",vc,"meta","innerInstructions",vc,...e]),...Nc.map(e=>["transactions",vc,"transaction","message",...e]),["transactions",vc,"version"],["rewards",vc,"commission"]],getClusterNodes:[[vc,"featureSet"],[vc,"shredVersion"]],getInflationGovernor:[["initial"],["foundation"],["foundationTerm"],["taper"],["terminal"]],getInflationRate:[["foundation"],["total"],["validator"]],getInflationReward:[[vc,"commission"]],getMultipleAccounts:Pc.map(e=>["value",vc,...e]),getProgramAccounts:Pc.flatMap(e=>[["value",vc,"account",...e],[vc,"account",...e]]),getRecentPerformanceSamples:[[vc,"samplePeriodSecs"]],getSignaturesForAddress:[[vc,"transactionIndex"]],getTokenAccountBalance:[["value","decimals"],["value","uiAmount"]],getTokenAccountsByDelegate:$c.map(e=>["value",vc,"account",...e]),getTokenAccountsByOwner:$c.map(e=>["value",vc,"account",...e]),getTokenLargestAccounts:[["value",vc,"decimals"],["value",vc,"uiAmount"]],getTokenSupply:[["value","decimals"],["value","uiAmount"]],getTransaction:[...Ec.flatMap(e=>[["meta","preTokenBalances",vc,...e],["meta","postTokenBalances",vc,...e]]),["meta","rewards",vc,"commission"],...zc.map(e=>["meta","innerInstructions",vc,...e]),...Nc.map(e=>["transaction","message",...e]),["version"]],getTransactionsForAddress:[["data",vc,"transactionIndex"],...Ec.flatMap(e=>[["data",vc,"meta","preTokenBalances",vc,...e],["data",vc,"meta","postTokenBalances",vc,...e]]),["data",vc,"meta","rewards",vc,"commission"],...zc.map(e=>["data",vc,"meta","innerInstructions",vc,...e]),...Nc.map(e=>["data",vc,"transaction","message",...e]),["data",vc,"version"]],getVersion:[["feature-set"]],getVoteAccounts:[["current",vc,"commission"],["current",vc,"inflationRewardsCommissionBps"],["delinquent",vc,"commission"],["delinquent",vc,"inflationRewardsCommissionBps"]],simulateTransaction:[["value","loadedAccountsDataSize"],...Pc.map(e=>["value","accounts",vc,...e]),...zc.map(e=>["value","innerInstructions",vc,...e]),...Ec.flatMap(e=>[["value","preTokenBalances",vc,...e],["value","postTokenBalances",vc,...e]])]}),Ic)})})}var Lc={accept:!0,"content-length":!0,"content-type":!0},Oc=/* @__PURE__ */Object.assign({"accept-charset":!0,"access-control-request-headers":!0,"access-control-request-method":!0,connection:!0,"content-length":!0,cookie:!0,date:!0,dnt:!0,expect:!0,host:!0,"keep-alive":!0,"permissions-policy":!0,referer:!0,te:!0,trailer:!0,"transfer-encoding":!0,upgrade:!0,via:!0},{"accept-encoding":!0},{origin:!0}),_c=!1;var Mc=["getAccountInfo","getBalance","getBlock","getBlockCommitment","getBlockHeight","getBlockProduction","getBlocks","getBlocksWithLimit","getBlockTime","getClusterNodes","getEpochInfo","getEpochSchedule","getFeeForMessage","getFirstAvailableBlock","getGenesisHash","getHealth","getHighestSnapshotSlot","getIdentity","getInflationGovernor","getInflationRate","getInflationReward","getLargestAccounts","getLatestBlockhash","getLeaderSchedule","getMaxRetransmitSlot","getMaxShredInsertSlot","getMinimumBalanceForRentExemption","getMultipleAccounts","getProgramAccounts","getRecentPerformanceSamples","getRecentPrioritizationFees","getSignaturesForAddress","getSignatureStatuses","getSlot","getSlotLeader","getSlotLeaders","getStakeMinimumDelegation","getSupply","getTokenAccountBalance","getTokenAccountsByDelegate","getTokenAccountsByOwner","getTokenLargestAccounts","getTokenSupply","getTransaction","getTransactionCount","getVersion","getVoteAccounts","index","isBlockhashValid","minimumLedgerSlot","requestAirdrop","sendTransaction","simulateTransaction"];function Rc(e){return bc(e)&&Mc.includes(e.method)}function jc(e){return function(e){"production"!=="production"&&"dispatcher_NODE_ONLY"in e&&(_c||(_c=!0,console.warn("You have supplied a `Dispatcher` to `createHttpTransport()`. It has been ignored because Undici dispatchers only work in Node environments. To eliminate this warning, omit the `dispatcher_NODE_ONLY` property from your config when running in a non-Node environment.")));const{fromJson:t,headers:n,toJson:r,url:a}=e;"production"!=="production"&&n&&function(e){const t=Object.keys(e).filter(e=>{const t=e.toLowerCase();return!0===Lc[e.toLowerCase()]||!0===Oc[e.toLowerCase()]||t.startsWith("proxy-")||t.startsWith("sec-")});if(t.length>0)throw new No(Ja,{headers:t})}(n);const o=n&&function(e){const t={};for(const n in e)t[n.toLowerCase()]=e[n];return t}(n);return async function({payload:e,signal:n}){const i={body:r?r(e):JSON.stringify(e),headers:{...o,accept:"application/json","content-type":"application/json; charset=utf-8"},method:"POST",signal:n},s=await fetch(a,i);if(!s.ok)throw new No(Ga,{headers:s.headers,message:s.statusText,statusCode:s.status});return t?t(await s.text(),e):await s.json()}}({...e,fromJson:(e,t)=>{return Rc(t)?(n=e,JSON.parse(function(e){const t=[];let n=!1;for(let r=0;r<e.length;r++){let a=!1;if("\\"===e[r]&&(t.push(e[r++]),a=!a),'"'!==e[r]){if(!n){const n=uc(e,r);if(n?.length){r+=n.length-1,n.match(/\.|[eE]-/)?t.push(n):t.push(lc(n));continue}}t.push(e[r])}else t.push(e[r]),a||(n=!n)}return t.join("")}(n),(e,t)=>function(e){return!!e&&"object"==typeof e&&"$n"in e&&"string"==typeof e.$n}(t)?function({$n:e}){const t=e.match(dc);if(t){const[,n,r,a]=t;if(r.length+(a?Number(a):0)<=1e3)return a?BigInt(`${n}${r}`)*10n**BigInt(a):BigInt(e)}throw new No(7,{value:e})}(t):t)):JSON.parse(e);var n},toJson:e=>{return Rc(e)?(t=e,function(e){return e.replace(/\{\s*"\$n"\s*:\s*"(-?\d+)"\s*\}/g,"$1")}(JSON.stringify(t,(e,t)=>"bigint"==typeof t?function(e){return{$n:`${e}`}}(t):t,void 0))):JSON.stringify(e);var t}})}var Dc=Object.prototype.toString,Fc=Object.keys||function(e){const t=[];for(const n in e)t.push(n);return t};function Vc(e,t){let n,r,a,o,i,s,c;if(!0===e)return"true";if(!1===e)return"false";switch(typeof e){case"object":if(null===e)return null;if("toJSON"in e&&"function"==typeof e.toJSON)return Vc(e.toJSON(),t);if(c=Dc.call(e),"[object Array]"===c){for(a="[",r=e.length-1,n=0;n<r;n++)a+=Vc(e[n],!0)+",";return r>-1&&(a+=Vc(e[n],!0)),a+"]"}if("[object Object]"===c){for(o=Fc(e).sort(),r=o.length,a="",n=0;n<r;)i=o[n],s=Vc(e[i],!1),void 0!==s&&(a&&(a+=","),a+=JSON.stringify(i)+":"+s),n++;return"{"+a+"}"}return JSON.stringify(e);case"function":case"undefined":return t?null:void 0;case"bigint":return`${e.toString()}n`;case"string":return JSON.stringify(e);default:return isFinite(e)?e:null}}function Wc(e){const t=Vc(e,!1);if(void 0!==t)return""+t}function Uc(e,t,n){let r="";if("number"==typeof t[0]){const e=t[0]+1,n=e%10,a=e%100;r=1==n&&11!=a?e+"st":2==n&&12!=a?e+"nd":3==n&&13!=a?e+"rd":e+"th"}else r=`\`${t[0].toString()}\``;const a=t.length>1?t.slice(1).map(e=>"number"==typeof e?`[${e}]`:e).join("."):void 0,o=new No(Ha,{argumentLabel:r,keyPath:t,methodName:e,optionalPathLabel:a?` at path \`${a}\``:"",value:n,...void 0!==a?{path:a}:void 0});return Co(o,Uc),o}var qc,Hc={defaultCommitment:"confirmed",onIntegerOverflow(e,t,n){throw Uc(e.methodName,t,n)}},Jc=globalThis.AbortController;function Gc(){return"production"!=="production"?{EXPLICIT_ABORT_TOKEN:"This object is thrown from the request that underlies a series of coalesced requests when the last request in that series aborts"}:{}}function Kc(e){return bc(e)?Wc([e.method,e.params]):void 0}function Yc(e){const t={};for(const n in e)t[n.toLowerCase()]=e[n];return t}function Xc(e,t){return n=function(e){return ps(jc({...e,headers:{...e.headers?Yc(e.headers):void 0,"solana-client":"js/7.1.1"}}),e=>function(e,t){let n;return async function(r){const{payload:a,signal:o}=r,i=t(a);if(void 0===i)return await e(r);if(n||(queueMicrotask(()=>{n=void 0}),n={}),null==n[i]){const t=new Jc,a=(async()=>{try{return await e({...r,signal:t.signal})}catch(n){if(n===(qc||=Gc()))return;throw n}})();n[i]={abortController:t,numConsumers:0,responsePromise:a}}const s=n[i];if(s.numConsumers++,o){const e=s.responsePromise;return await new Promise((t,n)=>{const r=e=>{o.removeEventListener("abort",r),s.numConsumers-=1,queueMicrotask(()=>{0===s.numConsumers&&s.abortController.abort(qc||=Gc())}),n(e.target.reason)};o.addEventListener("abort",r),e.then(t).catch(n).finally(()=>{o.removeEventListener("abort",r)})})}return await s.responsePromise}}(e,Kc))}({url:e,...t}),gc({api:Bc(Hc),transport:n});var n}function Zc(e,t){const n=function(e,t){if(null==t)throw new No(so,{inputName:e});return t}(e,t);return"object"==typeof t&&"address"in n?n.address:Array.isArray(n)?n[0]:n}function Qc(e,t){return(n,r)=>{if(!r.value){if("omitted"===t)return;return Object.freeze({address:e,role:bs.READONLY})}const a=r.isWritable?bs.WRITABLE:bs.READONLY,o=!!(i=r.value)&&"object"==typeof i&&"address"in i&&"string"==typeof i.address&&function(e){return function(e){return"signTransactions"in e&&"function"==typeof e.signTransactions}(e)||function(e){return"modifyAndSignTransactions"in e&&"function"==typeof e.modifyAndSignTransactions}(e)||function(e){return"signAndSendTransactions"in e&&"function"==typeof e.signAndSendTransactions}(e)}(i);var i,s;return Object.freeze({address:Zc(n,r.value),role:o?(s=a,2|s):a,...o?{signer:r.value}:{}})}}async function ed(e,t,n){const r=await async function(e,t,n){const r=await pi(e,t,n);return fi(r,fs([["mintAuthority",ms(wi(),{prefix:Ri(),noneValue:"zeroes"})],["supply",Di()],["decimals",Vi()],["isInitialized",Yi()],["freezeAuthority",ms(wi(),{prefix:Ri(),noneValue:"zeroes"})]]))}(e,t,n);return function(e){if(!e.exists)throw new No(ye,{address:e.address})}(r),r}var td=/* @__PURE__ */(e=>(e[e.Uninitialized=0]="Uninitialized",e[e.Initialized=1]="Initialized",e[e.Frozen=2]="Frozen",e))(td||{});async function nd(e,t={}){const{programAddress:n="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL"}=t;return await $i({programAddress:n,seeds:[bi().encode(e.owner),bi().encode(e.tokenProgram),bi().encode(e.mint)]})}var rd="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";async function ad(e,t={}){const{programAddress:n="De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44"}=t;return await $i({programAddress:n,seeds:[ui().encode("SubscriptionAuthority"),bi().encode(e.user),bi().encode(e.tokenMint)]})}async function od(e,t={}){const{programAddress:n="De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44"}=t;return await $i({programAddress:n,seeds:[ui().encode("subscription"),bi().encode(e.planPda),bi().encode(e.subscriber)]})}"production","production";var id=/* @__PURE__ */(e=>(e[e.Sunset=0]="Sunset",e[e.Active=1]="Active",e))(id||{});function sd(){return fs([["amount",Di()],["periodHours",Di()],["createdAt",Bi()]])}var cd,dd="De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44",ud=100,ld=101,fd=102,md=103,pd=104,hd=105,gd=106,bd=107,wd=108,yd=109,vd=110,xd=111,Ad=112,Td=113,Sd=114,kd=115,Id=116,$d=117,Pd=118,zd=119,Ed=120,Nd=121,Cd=122,Bd=123,Ld=124,Od=125,_d=126,Md=127,Rd=128,jd=129,Dd=130,Fd=131,Vd=132,Wd=133,Ud=134,qd=135,Hd=136,Jd=137,Gd=300,Kd=301,Yd=302,Xd=400,Zd=401,Qd=402,eu=403,tu=404,nu=405,ru=406,au=407,ou=408,iu=500,su=501,cu=502,du=503,uu=504,lu=505,fu=506,mu=507,pu=508,hu=509,gu=510,bu=511,wu=512,yu=513,vu=514,xu=515,Au=516,Tu=517,Su=518,ku=519,Iu=520,$u=521,Pu=522,zu=600,Eu=601,Nu=602,Cu=603,Bu=604;function Lu(e){return"production"!=="production"?cd[e]:"Error message not available in production bundles."}"production"!=="production"&&(cd={[Fd]:"Account must be writable",[Tu]:"Already subscribed to this plan",[Gd]:"Transfer amount exceeds delegation limit",[Xd]:"Transfer amount exceeds period limit",[kd]:"Arithmetic Overflow",[Id]:"Arithmetic Underflow",[Vd]:"Token account owner does not match expected",[qd]:"Delegation account already exists",[Rd]:"Delegation has expired",[au]:"Delegation period has not started yet",[Wd]:"Delegation header version is not compatible",[Yd]:"zero amount specified",[Kd]:"Expiry time specified is less than current time",[xd]:"Invalid account data",[$d]:"Invalid account discriminator",[ld]:"Invalid account address",[jd]:"Invalid amount specified",[wd]:"Invalid associated token account address",[_d]:"Invalid delegation PDA derivation",[bu]:"End timestamp must be zero or in the future",[fd]:"Invalid escrow PDA derivation",[zu]:"Invalid event authority PDA",[Eu]:"Invalid event data",[Cu]:"Unknown event discriminator",[Nu]:"Invalid event tag prefix",[Md]:"Invalid header data",[Sd]:"Invalid instruction",[Ad]:"Invalid instruction data",[mu]:"No valid destinations provided",[eu]:"Payer provided does not match delegation",[Qd]:"Invalid Period length",[cu]:"Invalid Plan PDA derivation",[wu]:"Invalid plan status value",[Bu]:"Self program account does not match this program",[md]:"Invalid subscription-authority PDA derivation",[du]:"Invalid subscription PDA derivation",[gd]:"Invalid Token-2022 mint account data",[bd]:"Invalid Token-2022 token account data",[hd]:"Token Program does not match other accounts",[yd]:"Invalid SPL Token mint account data",[vd]:"Invalid SPL Token account data",[Ud]:"Account requires explicit migration",[Pd]:"Mint has ConfidentialTransfer extension",[Bd]:"Mint has MintCloseAuthority extension",[zd]:"Mint has NonTransferable extension",[Ld]:"Mint has Pausable extension",[Ed]:"Mint has PermanentDelegate extension",[Cd]:"Mint has TransferFee extension",[Nd]:"Mint has TransferHook extension",[Od]:"Token mint mismatch",[Td]:"Not enough account keys provided",[uu]:"Caller is not the plan owner",[ud]:"Account must be a signer",[pd]:"Expected system program",[Zd]:"Period has not elapsed yet",[Su]:"Plan account already exists",[Au]:"Plan account has been closed",[Iu]:"A finite plan end timestamp can only be shortened, not removed or extended",[su]:"Plan has expired",[yu]:"Plan cannot be updated after sunset",[xu]:"Plan must be expired to delete",[iu]:"Plan is in sunset status",[ku]:"Subscription plan terms do not match the current plan",[ru]:"zero amount specified",[ou]:"start_ts of 0 (start on landing) requires a non-zero expiry",[nu]:"start time specified is greater than expiry",[tu]:"Past start time specified",[Pu]:"Plan update approval does not match the current plan state",[$u]:"Subscription approval does not match the current subscription",[Hd]:"Delegation init_id does not match current SubscriptionAuthority",[hu]:"Subscription already cancelled",[pu]:"Subscription cancelled and past valid period",[gu]:"Subscription is not cancelled",[lu]:"Subscription does not belong to this plan",[vu]:"Sunset requires a non-zero end timestamp",[Jd]:"Too many transfer hook accounts provided",[Dd]:"Caller not authorized for this action",[fu]:"Destination not in plan whitelist"}),Uint8Array.from([105,37,101,197,75,251,102,26]),wi(),bi(),new TextEncoder;var Ou=class extends Error{constructor(e){super(e),this.name="ValidationError"}};function _u(e){return e?{programAddress:e}:{}}async function Mu(e){const[t]=await async function(e={}){const{programAddress:t="De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44"}=e;return await $i({programAddress:t,seeds:[ui().encode("event_authority")]})}(_u(e));return{eventAuthority:t,selfProgram:e??dd}}function Ru(e,t){return t?function(e,t){if(0===t.length)return e;const n=[...e.accounts??[],...t];return{...e,accounts:n}}(e,[{address:t.address,role:bs.WRITABLE_SIGNER,signer:t}]):e}const ju=dd;async function Du(e,t){const[n]=await od({planPda:e,subscriber:t});return n}async function Fu(e,t){const n=await pi(e,t);return n.exists&&n.programAddress===ju?n:null}const Vu=id.Active;function Wu(e){return e.filter(e=>"11111111111111111111111111111111"!==e)}async function Uu(e,t){const n=await Fu(e,t);if(null===n)return null;const{owner:r,status:a,data:o}=(i=n,fi(i,fs([["discriminator",Vi()],["owner",wi()],["bump",Vi()],["status",Vi()],["data",fs([["planId",Di()],["mint",wi()],["terms",sd()],["endTs",Bi()],["destinations",Gi(wi(),{size:4})],["pullers",Gi(wi(),{size:4})],["metadataUri",Ko(li(),128)]])]]))).data;var i;return{address:t,owner:r,planId:o.planId,mint:o.mint,amount:o.terms.amount,periodHours:o.terms.periodHours,createdAt:o.terms.createdAt,endTs:o.endTs,destinations:Wu(o.destinations),pullers:Wu(o.pullers),metadataUri:o.metadataUri,status:a===Vu?"active":"sunset"}}async function qu(e,t){const n=await Fu(e,t);if(null===n)return null;const{header:r,terms:a,amountPulledInPeriod:o,currentPeriodStartTs:i,expiresAtTs:s}=(c=n,fi(c,fs([["header",fs([["discriminator",Vi()],["version",Vi()],["bump",Vi()],["delegator",wi()],["delegatee",wi()],["payer",wi()],["initId",Bi()]])],["terms",sd()],["amountPulledInPeriod",Di()],["currentPeriodStartTs",Bi()],["expiresAtTs",Bi()]]))).data;var c;return{address:t,subscriber:r.delegator,authorityInitId:r.initId,amount:a.amount,periodHours:a.periodHours,createdAt:a.createdAt,amountPulledInPeriod:o,currentPeriodStartTs:i,expiresAtTs:s}}async function Hu(e,t,n){return qu(e,await Du(t,n))}async function Ju(e,t,n){const r=await async function(e,t){const[n]=await ad({user:e,tokenMint:t});return n}(t,n),a=await Fu(e,r);return null===a?null:{address:r,user:t,tokenMint:n,initId:(o=a,fi(o,fs([["discriminator",Vi()],["user",wi()],["tokenMint",wi()],["payer",wi()],["bump",Vi()],["initId",Bi()]]))).data.initId};var o}async function Gu(e,t,n){const r=await async function(e,t){const[n]=await nd({owner:e,mint:t,tokenProgram:rd});return n}(t,n),a=await async function(e,t){return fi(await pi(e,t,void 0),fs([["mint",wi()],["owner",wi()],["amount",Di()],["delegate",ms(wi(),{prefix:Ri(),noneValue:"zeroes"})],["state",ss(td)],["isNative",ms(Di(),{prefix:Ri(),noneValue:"zeroes"})],["delegatedAmount",Di()],["closeAuthority",ms(wi(),{prefix:Ri(),noneValue:"zeroes"})]]))}(e,r);return{ata:r,amount:a.exists?a.data.amount:null}}const Ku={[Xd]:"already_collected_this_period",[ku]:"plan_terms_mismatch",[Rd]:"subscription_expired",[pu]:"subscription_expired",[Hd]:"subscription_invalidated",[fu]:"invalid_destination",[Dd]:"unauthorized_puller",[Tu]:"already_subscribed",[iu]:"plan_retired",[Qd]:"invalid_period"},Yu={already_collected_this_period:"This period has already been collected.",plan_terms_mismatch:"This plan changed before you signed. Review the new terms and try again.",subscription_expired:"This subscription has ended.",subscription_invalidated:"The wallet reset its subscription authority, which ended this subscription.",invalid_destination:"The plan does not allow payment to that wallet.",unauthorized_puller:"This wallet is not allowed to collect for the plan.",already_subscribed:"This wallet is already subscribed to the plan.",plan_retired:"This plan is no longer accepting subscriptions.",invalid_period:"Billing period must be between 1 hour and 1 year.",insufficient_balance:"Not enough USDC in this wallet for the payment.",insufficient_sol:"This wallet needs a little SOL to pay the network fee."},Xu=/* @__PURE__ */new Set(["AccountNotFound","InsufficientFundsForFee"]);function Zu(t,n){if(t instanceof e)return t;if(function(e){return"string"==typeof e?Xu.has(e):"object"==typeof e&&null!==e&&"InsufficientFundsForRent"in e||void 0!==Qu(e,e=>Eo(e,hr)||Eo(e,br)||Eo(e,Wr))}(t))return new e("insufficient_sol",Yu.insufficient_sol,{cause:t});const r={instructions:[...n]},a=Qu(t,e=>function(e,t,n){if(!Eo(e,gt))return!1;const r=t.instructions[e.context.index]?.programAddress;return!(!r||r!==n)}(e,r,ju));if(void 0===a)return t;const{code:o,index:i}=a.context;if(o<100)return 1===o?new e("insufficient_balance",Yu.insufficient_balance,{details:{tokenErrorCode:o,instructionIndex:i},cause:a}):new e("program_error",`Token program error ${o}.`,{details:{tokenErrorCode:o,instructionIndex:i},cause:a});const s=o,c=function(e){return Ku[e]??"program_error"}(s);return new e(c,Yu[c]??Lu(s),{details:{programCode:s,programMessage:Lu(s),instructionIndex:i},cause:a})}function Qu(e,t){let n=e;for(let r=0;r<8&&null!=n;r+=1){if(t(n))return n;n=n instanceof Error?n.cause:void 0}}async function el(t,n){const r=await Uu(t,n.planPda);if(null===r)throw new e("plan_not_found","This plan is not available.",{details:{planPda:n.planPda}});if("active"!==r.status)throw new e("plan_retired","This plan is no longer accepting subscriptions.",{details:{planPda:n.planPda}});const a=n.subscriber.address,[o,i,s]=await Promise.all([Hu(t,r.address,a),Ju(t,a,r.mint),Gu(t,a,r.mint)]);if(null!==o)throw new e("already_subscribed","This wallet is already subscribed to the plan.",{details:{subscriptionPda:o.address,nextChargeTs:o.currentPeriodStartTs.toString()}});const c=[],d=n.payer??n.subscriber;return null===s.amount&&c.push(await async function(e){const t="ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL",n={payer:{value:e.payer??null,isWritable:!0},ata:{value:e.ata??null,isWritable:!0},owner:{value:e.owner??null,isWritable:!1},mint:{value:e.mint??null,isWritable:!1},systemProgram:{value:e.systemProgram??null,isWritable:!1},tokenProgram:{value:e.tokenProgram??null,isWritable:!1}};n.tokenProgram.value||(n.tokenProgram.value="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"),n.ata.value||(n.ata.value=await nd({owner:Zc("owner",n.owner.value),tokenProgram:Zc("tokenProgram",n.tokenProgram.value),mint:Zc("mint",n.mint.value)})),n.systemProgram.value||(n.systemProgram.value="11111111111111111111111111111111");const r=Qc(t,"programId");return Object.freeze({accounts:[r("payer",n.payer),r("ata",n.ata),r("owner",n.owner),r("mint",n.mint),r("systemProgram",n.systemProgram),r("tokenProgram",n.tokenProgram)],data:Xo(ls([["discriminator",Fi()]]),e=>({...e,discriminator:1})).encode({}),programAddress:t})}({payer:d,owner:a,mint:r.mint,tokenProgram:rd})),null===i&&c.push(await async function(e){return Ru(await async function(e,t){const n=t?.programAddress??dd,r={owner:{value:e.owner??null,isWritable:!0},subscriptionAuthority:{value:e.subscriptionAuthority??null,isWritable:!0},tokenMint:{value:e.tokenMint??null,isWritable:!1},userAta:{value:e.userAta??null,isWritable:!0},systemProgram:{value:e.systemProgram??null,isWritable:!1},tokenProgram:{value:e.tokenProgram??null,isWritable:!1},payer:{value:e.payer??null,isWritable:!0}};r.subscriptionAuthority.value||(r.subscriptionAuthority.value=await ad({user:Zc("owner",r.owner.value),tokenMint:Zc("tokenMint",r.tokenMint.value)})),r.systemProgram.value||(r.systemProgram.value="11111111111111111111111111111111");const a=Qc(n,"omitted");return Object.freeze({accounts:[a("owner",r.owner),a("subscriptionAuthority",r.subscriptionAuthority),a("tokenMint",r.tokenMint),a("userAta",r.userAta),a("systemProgram",r.systemProgram),a("tokenProgram",r.tokenProgram),a("payer",r.payer)].filter(e=>void 0!==e),data:Xo(ls([["discriminator",Fi()]]),e=>({...e,discriminator:0})).encode({}),programAddress:n})}({owner:e.owner,tokenMint:e.tokenMint,tokenProgram:e.tokenProgram,userAta:e.userAta},_u(e.programAddress)),e.payer)}({owner:n.subscriber,payer:d,tokenMint:r.mint,tokenProgram:rd,userAta:s.ata})),c.push(await async function(e){if(void 0===e.expectedAmount||void 0===e.expectedPeriodHours||void 0===e.expectedCreatedAt||void 0===e.expectedSubscriptionAuthorityInitId)throw new Error("getSubscribeOverlayInstructionAsync requires expectedAmount, expectedPeriodHours, expectedCreatedAt, and expectedSubscriptionAuthorityInitId. Use the plugin client `subscriptions.instructions.subscribe(...)` to auto-fetch from the live plan and authority.");!function(e){if("number"==typeof e&&!Number.isSafeInteger(e))throw new Ou("planId must be a bigint or a safe integer (numbers above 2^53-1 lose precision)")}(e.planId);const[t,n]=await async function(e,t={}){const{programAddress:n="De1egAFMkMWZSN5rYXRj9CAdheBamobVNubTsi9avR44"}=t;return await $i({programAddress:n,seeds:[ui().encode("plan"),bi().encode(e.owner),ji().encode(e.planId)]})}({owner:e.merchant,planId:e.planId},_u(e.programAddress)),[r]=await ad({tokenMint:e.tokenMint,user:e.subscriber.address},_u(e.programAddress));return Ru(await async function(e,t){const n=t?.programAddress??dd,r={subscriber:{value:e.subscriber??null,isWritable:!0},merchant:{value:e.merchant??null,isWritable:!1},planPda:{value:e.planPda??null,isWritable:!1},subscriptionPda:{value:e.subscriptionPda??null,isWritable:!0},subscriptionAuthorityPda:{value:e.subscriptionAuthorityPda??null,isWritable:!1},systemProgram:{value:e.systemProgram??null,isWritable:!1},eventAuthority:{value:e.eventAuthority??null,isWritable:!1},selfProgram:{value:e.selfProgram??null,isWritable:!1},payer:{value:e.payer??null,isWritable:!0}},a={...e};r.subscriptionPda.value||(r.subscriptionPda.value=await od({planPda:Zc("planPda",r.planPda.value),subscriber:Zc("subscriber",r.subscriber.value)})),r.systemProgram.value||(r.systemProgram.value="11111111111111111111111111111111"),r.eventAuthority.value||(r.eventAuthority.value=await $i({programAddress:n,seeds:[ui().encode("event_authority")]})),r.selfProgram.value||(r.selfProgram.value=n,r.selfProgram.isWritable=!1);const o=Qc(n,"omitted");return Object.freeze({accounts:[o("subscriber",r.subscriber),o("merchant",r.merchant),o("planPda",r.planPda),o("subscriptionPda",r.subscriptionPda),o("subscriptionAuthorityPda",r.subscriptionAuthorityPda),o("systemProgram",r.systemProgram),o("eventAuthority",r.eventAuthority),o("selfProgram",r.selfProgram),o("payer",r.payer)].filter(e=>void 0!==e),data:Xo(ls([["discriminator",Fi()],["subscribeData",ls([["planId",ji()],["planBump",Fi()],["expectedMint",bi()],["expectedAmount",ji()],["expectedPeriodHours",ji()],["expectedCreatedAt",Ci()],["expectedSubscriptionAuthorityInitId",Ci()]])]]),e=>({...e,discriminator:11})).encode(a),programAddress:n})}({...await Mu(e.programAddress),merchant:e.merchant,planPda:t,subscribeData:{expectedAmount:e.expectedAmount,expectedCreatedAt:e.expectedCreatedAt,expectedMint:e.tokenMint,expectedPeriodHours:e.expectedPeriodHours,expectedSubscriptionAuthorityInitId:e.expectedSubscriptionAuthorityInitId,planBump:n,planId:e.planId},subscriber:e.subscriber,subscriptionAuthorityPda:r},_u(e.programAddress)),e.payer)}({subscriber:n.subscriber,payer:d,merchant:r.owner,planId:r.planId,tokenMint:r.mint,expectedAmount:r.amount,expectedPeriodHours:r.periodHours,expectedCreatedAt:r.createdAt,expectedSubscriptionAuthorityInitId:i?.initId??-9223372036854775808n})),{instructions:c,plan:r,createsTokenAccount:null===s.amount,createsAuthority:null===i,balance:s.amount}}new Map(Object.entries({createPlan:{discriminant:7,planPda:1,subscriptionPda:null,user:0,mint:2},updatePlan:{discriminant:8,planPda:1,subscriptionPda:null,user:0,mint:null},deletePlan:{discriminant:9,planPda:1,subscriptionPda:null,user:0,mint:null},transferSubscription:{discriminant:10,planPda:1,subscriptionPda:0,user:null,mint:6},subscribe:{discriminant:11,planPda:2,subscriptionPda:3,user:0,mint:null},cancelSubscription:{discriminant:12,planPda:1,subscriptionPda:2,user:0,mint:null},resumeSubscription:{discriminant:13,planPda:1,subscriptionPda:2,user:0,mint:null},revokeSubscriptionAuthority:{discriminant:14,planPda:null,subscriptionPda:null,user:0,mint:2},revokeAbandonedSubscription:{discriminant:16,planPda:3,subscriptionPda:1,user:null,mint:null},cancelSubscriptionNow:{discriminant:17,planPda:2,subscriptionPda:3,user:0,mint:null}}).map(([e,t])=>[t.discriminant,e]));const tl="solana:signAndSendTransaction",nl="solana:signTransaction";var rl;let al;const ol=/* @__PURE__ */new Set,il={};function sl(){if(al)return al;if(al=Object.freeze({register:cl,get:ul,on:ll}),"undefined"==typeof window)return al;const e=Object.freeze({register:cl});try{window.addEventListener("wallet-standard:register-wallet",({detail:t})=>t(e))}catch(t){console.error("wallet-standard:register-wallet event listener could not be added\n",t)}try{window.dispatchEvent(new ml(e))}catch(t){console.error("wallet-standard:app-ready event could not be dispatched\n",t)}return al}function cl(...e){return(e=e.filter(e=>!ol.has(e))).length?(e.forEach(e=>function(e){dl=void 0,ol.add(e)}(e)),il.register?.forEach(t=>fl(()=>t(...e))),function(){e.forEach(e=>function(e){dl=void 0,ol.delete(e)}(e)),il.unregister?.forEach(t=>fl(()=>t(...e)))}):()=>{}}let dl;function ul(){return dl||(dl=[...ol]),dl}function ll(e,t){return il[e]?.push(t)||(il[e]=[t]),function(){il[e]=il[e]?.filter(e=>t!==e)}}function fl(e){try{e()}catch(t){console.error(t)}}class ml extends Event{get detail(){return function(e,t){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot read private member from an object whose class did not declare it");return t.get(e)}(this,rl)}get type(){return"wallet-standard:app-ready"}constructor(e){super("wallet-standard:app-ready",{bubbles:!1,cancelable:!1,composed:!1}),rl.set(this,void 0),function(e,t,n){if("function"==typeof t||!t.has(e))throw new TypeError("Cannot write private member to an object whose class did not declare it");t.set(e,n)}(this,rl,e)}preventDefault(){throw new Error("preventDefault cannot be called")}stopImmediatePropagation(){throw new Error("stopImmediatePropagation cannot be called")}stopPropagation(){throw new Error("stopPropagation cannot be called")}}rl=/* @__PURE__ */new WeakMap;const pl="standard:connect",hl={"mainnet-beta":"solana:mainnet",devnet:"solana:devnet",localnet:"solana:localnet"};function gl(e){return hl[e]}function bl(e,t){return t in e.features}function wl(e){const t=gl(e);return sl().get().filter(e=>e.chains.includes(t)&&bl(e,pl)&&(bl(e,tl)||bl(e,nl)))}function yl(e){return{id:e.name,name:e.name,icon:e.icon}}function vl(e){const t=sl(),n=t.on("register",e),r=t.on("unregister",e);return()=>{n(),r()}}function xl(t){const n=t instanceof Error?t.message:String(t);return/reject|denied|declin|cancel|closed|dismiss/i.test(n)?new e("wallet_rejected","The request was declined in the wallet.",{cause:t}):new e("wallet_unavailable","Couldn't open your wallet.",{cause:t})}const Al={"mainnet-beta":"https://api.mainnet-beta.solana.com",devnet:"https://api.devnet.solana.com",localnet:"http://127.0.0.1:8899"};function Tl(e){return new Promise(t=>{setTimeout(t,e)})}function Sl(t){return new e("rpc_unreachable","Can't reach Solana right now.",{cause:t})}async function kl(e){try{return await e()}catch(n){if(t(n))throw n;throw Sl(n)}}function Il(r,a={}){const{cluster:o}=r,i=a.transport??function(e){const t=Xc(e);return{rpc:t,latestBlockhash:async()=>{const{value:e}=await t.getLatestBlockhash({commitment:"confirmed"}).send();return e},simulate:async e=>{const{value:n}=await t.simulateTransaction(ac(e),{encoding:"base64",sigVerify:!1,replaceRecentBlockhash:!0,commitment:"confirmed"}).send();return null===n.err?null:Mo(n.err)},send:e=>t.sendTransaction(ac(e),{encoding:"base64",preflightCommitment:"confirmed"}).send(),status:async e=>{const{value:n}=await t.getSignatureStatuses([e]).send(),r=n[0]??null;return null===r?null:{error:null===r.err?null:Mo(r.err),confirmed:"confirmed"===r.confirmationStatus||"finalized"===r.confirmationStatus}},blockHeight:()=>t.getBlockHeight({commitment:"confirmed"}).send()}}(function(e){const{config:t,cluster:n}=e;return null!==t.rpcUrl?t.rpcUrl:"id"===t.plan?.kind&&null===t.cluster?`${t.apiUrl.replace(/\/$/,"")}/v1/public/rpc/${t.plan.id}`:Al[n]}(r)),s=a.pollMs??1500,c=a.confirmTimeoutMs??9e4,{rpc:d}=i,u=/* @__PURE__ */new Map,l=async e=>(await ed(d,e)).data.decimals,f=async(e,t=null)=>({pda:e.address,owner:e.owner,mint:e.mint,decimals:await l(e.mint),amount:e.amount,periodHours:e.periodHours,createdAt:e.createdAt,destinations:e.destinations,status:"active"===e.status?"active":"retired",metadata:t}),m=async(t,n,r)=>{const a=gi(n.connected.address),d=await i.latestBlockhash();var u;const l=rc(ps((u={version:0},Object.freeze({instructions:Object.freeze([]),version:u.version})),e=>function(e,t){if("feePayer"in t&&e===t.feePayer?.address&&function(e){return!!e&&"address"in e&&"string"==typeof e.address&&1===Object.keys(e).length}(t.feePayer))return t;const n={...t,feePayer:Object.freeze({address:e})};return Object.freeze(n),n}(a,e),e=>{return t=d,"lifetimeConstraint"in(n=e)&&n.lifetimeConstraint&&"blockhash"in n.lifetimeConstraint&&n.lifetimeConstraint.blockhash===t.blockhash&&n.lifetimeConstraint.lastValidBlockHeight===t.lastValidBlockHeight?n:Object.freeze({...n,lifetimeConstraint:Object.freeze(t)});var t,n},e=>{return n=t.instructions,r=e,Object.freeze({...r,instructions:Object.freeze([...r.instructions,...n])});var n,r})),f=await i.simulate(l);if(null!==f)throw Zu(f,t.instructions);const m=await async function(e,t,n){const r=e.wallet.features,a=gl(n);try{const n=r[tl];if(void 0!==n){const[r]=await n.signAndSendTransaction({account:e.account,transaction:t,chain:a,options:{preflightCommitment:"confirmed"}});if(void 0===r)throw new Error("wallet returned no signature");return{kind:"sent",signature:r.signature}}const o=r[nl];if(void 0!==o){const[n]=await o.signTransaction({account:e.account,transaction:t,chain:a});if(void 0===n)throw new Error("wallet returned no transaction");return{kind:"signed",signedTransaction:n.signedTransaction}}throw new Error("wallet cannot sign transactions")}catch(o){throw xl(o)}}(n,new Uint8Array(Zs().encode(l)),o);let p;var h,g;"sent"===m.kind?(function(e){if(Ks||(Ks=ai()),e.length<64||e.length>88)throw new No(_e,{actualLength:e.length});!function(e){const t=e.byteLength;if(64!==t)throw new No(Oe,{actualLength:t})}(Ks.encode(e))}(h=oi().decode(m.signature)),p=h):p=await i.send((g=e=>"signaturesFirst"===function(e){if(0===e.length)throw new No(Yn);const t=e[0];if(!(128&t))return"signaturesFirst";const n=127&t;if(0===n)throw new No(Xn,{firstByte:t,transactionBytes:e});if(1===n)return"messageFirst";throw new No(Hn,{unsupportedVersion:n})}(e),ns([Zo(fs([["signatures",Gi(Ko(Zi(),64),{size:Oi()})],["messageBytes",Zi()]]),ec),Zo(Vo({read(e,t){const n=Qs(e,t),r=64*n,a=e.length-t-r;if(a<0)throw new No(Zn,{numExpectedSignatures:n,transactionBytes:e.subarray(t),transactionBytesLength:e.length-t});const o=e.subarray(t,t+a),[i,s]=Gi(Ko(Zi(),64),{size:n}).read(e,t+a);return[{messageBytes:o,signatures:i},s]}}),tc)],e=>g(e)?0:1)).decode(m.signedTransaction)),r.onSent(p);const b=Date.now()+c;for(;Date.now()<b;){const n=await i.status(p);if(null!==n){if(null!==n.error)throw Zu(n.error,t.instructions);if(n.confirmed)return p}else if(await i.blockHeight()>d.lastValidBlockHeight)throw new e("blockhash_expired","The transaction expired unconfirmed.",{details:{signature:p}});await Tl(s)}throw new e("blockhash_expired","The transaction was not confirmed in time.",{details:{signature:p}})};return{fetchPlanTerms:async e=>kl(async()=>{const t=await Uu(d,gi(e));if(null===t)return null;const n=t.metadataUri.startsWith("https://")?await async function(e){try{const t=await fetch(e);return t.ok?function(e){if("object"!=typeof e||null===e)return null;const t=e,n=t.name;if("string"!=typeof n||0===n.length)return null;const r=t.description,a=t.logoUrl;return{name:n,..."string"==typeof r?{description:r}:{},..."string"==typeof a&&a.startsWith("https://")?{logoUrl:a}:{}}}(await t.json()):null}catch{return null}}(t.metadataUri):null;return f(t,n)}),listWallets:()=>wl(o).map(yl),onWalletsChanged:vl,connect:async t=>{const n=await async function(t,n){const r=wl(n).find(e=>e.name===t);if(void 0===r)throw new e("wallet_unavailable","That wallet is no longer available.",{details:{walletId:t}});const a=gl(n),o=r.features[pl];if(void 0===o)throw new e("wallet_unavailable","That wallet cannot connect.",{details:{walletId:t}});let i;try{({accounts:i}=await o.connect())}catch(c){throw xl(c)}const s=i.find(e=>e.chains.includes(a))??i[0];if(void 0===s)throw new e("wallet_unavailable","The wallet returned no account.",{details:{walletId:t}});return{wallet:r,account:s,connected:{walletId:t,walletName:r.name,address:s.address,disconnect:async()=>{const e=r.features["standard:disconnect"];await(e?.disconnect())}}}}(t,o);return u.set(n.connected.address,n),n.connected},preflight:async(e,r)=>kl(async()=>{const a=function(e){const t={address:e,signMessages:e=>Promise.resolve(e.map(()=>Object.freeze({}))),signTransactions:e=>Promise.resolve(e.map(()=>Object.freeze({})))};return Object.freeze(t)}(gi(r.address)),o=gi(e);let i;try{i=await el(d,{subscriber:a,planPda:o})}catch(l){if(!t(l)||"already_subscribed"!==l.code)throw l;const[e,r]=await Promise.all([Hu(d,o,a.address),Uu(d,o)]);if(null===e||null===r)throw l;return{status:"already_subscribed",terms:await f(r),subscriptionPda:e.address,nextChargeTs:e.currentPeriodStartTs+n(e.periodHours)}}const s=await f(i.plan),c=i.balance??0n;if(c<i.plan.amount)return{status:"insufficient",terms:s,balance:c};const u={instructions:i.instructions,planPda:o};return{status:"ready",prepared:{terms:s,balance:c,createsAuthority:i.createsAuthority,createsTokenAccount:i.createsTokenAccount,handle:u}}}),subscribe:async(r,a,o)=>{const i=(t=>{const n=u.get(t.address);if(void 0===n)throw new e("wallet_unavailable","The wallet is no longer connected.",{details:{address:t.address}});return n})(a),s=r.handle;let c;try{c=await m(s,i,o)}catch(h){if(!t(h)||"blockhash_expired"!==h.code)throw $l(h);try{c=await m(s,i,o)}catch(g){throw $l(g)}}const l=await Du(s.planPda,gi(a.address)),f=await kl(()=>qu(d,l)),p=f?.currentPeriodStartTs??r.terms.createdAt;return{signature:c,subscriptionPda:l,firstChargeTs:p,nextChargeTs:p+n(r.terms.periodHours)}}}}function $l(e){return t(e)?e:Sl(e)}const Pl={wallet:"Waiting for your wallet…",sending:"Sending…",confirming:"Confirming on Solana…"},zl={AuthoriseScreen:function({state:e,config:t,send:n}){const{plan:i}=e,[c,d]=A(!1),u=l(/* @__PURE__ */new Date),T=f(u,i.periodHours,u,3),S=m(i.amount,i.decimals),k=p(i.periodHours);/* @__PURE__ */
|
|
2
|
+
return v("div",{children:[
|
|
3
|
+
/* @__PURE__ */x("h2",{className:"sl-h2",children:"Approve recurring payments"}),e.termsChanged?/* @__PURE__ */x(s,{tone:"warn",testId:"terms-changed",children:"This plan's price changed. Here are the new terms."}):null,
|
|
4
|
+
/* @__PURE__ */x(h,{plan:i}),
|
|
5
|
+
/* @__PURE__ */x("p",{className:"sl-sub",children:k}),
|
|
6
|
+
/* @__PURE__ */v("dl",{className:"sl-rows",children:[
|
|
7
|
+
/* @__PURE__ */v("div",{className:"sl-row",children:[
|
|
8
|
+
/* @__PURE__ */x("dt",{children:"First charge"}),
|
|
9
|
+
/* @__PURE__ */x("dd",{children:"today"})]}),
|
|
10
|
+
/* @__PURE__ */v("div",{className:"sl-row",children:[
|
|
11
|
+
/* @__PURE__ */x("dt",{children:"Then"}),
|
|
12
|
+
/* @__PURE__ */v("dd",{className:"sl-num",children:[T.map(e=>r(e,i.periodHours,t.locale)).join(", "),"…"]})]}),
|
|
13
|
+
/* @__PURE__ */v("div",{className:"sl-row",children:[
|
|
14
|
+
/* @__PURE__ */x("dt",{children:"Paid to"}),
|
|
15
|
+
/* @__PURE__ */v("dd",{children:[
|
|
16
|
+
/* @__PURE__ */x("span",{className:"sl-mono","data-testid":"destination",children:g(i.merchantName,i.merchantAddress)}),
|
|
17
|
+
/* @__PURE__ */x("small",{children:b(i.feeBps)})]})]}),
|
|
18
|
+
/* @__PURE__ */v("div",{className:"sl-row",children:[
|
|
19
|
+
/* @__PURE__ */x("dt",{children:"Cancel"}),
|
|
20
|
+
/* @__PURE__ */x("dd",{children:"any time, from your wallet"})]})]}),
|
|
21
|
+
/* @__PURE__ */v(s,{tone:"info",testId:"approval-explainer",children:[
|
|
22
|
+
/* @__PURE__ */v("p",{children:["Your wallet will show a large approval amount. That's how the Solana subscriptions program works — the approval goes to an on-chain program, not to"," ",i.merchantName,". ",i.merchantName," can only ever take ",S," ",i.symbol," ",k,", to the address above."," ",
|
|
23
|
+
/* @__PURE__ */x("button",{type:"button",className:"sl-disclose","aria-expanded":c,"aria-controls":"sl-explainer",onClick:()=>{d(e=>!e)},children:c?"Show less":"What this means →"})]}),c?/* @__PURE__ */v("div",{id:"sl-explainer",className:"sl-panel","data-testid":"explainer-panel",children:[
|
|
24
|
+
/* @__PURE__ */v("p",{children:["Signing creates a ",
|
|
25
|
+
/* @__PURE__ */x("strong",{children:"subscription authority"}),": a small on-chain account that lets the program move ",i.symbol," from your wallet, and only within the limits you see here."]}),
|
|
26
|
+
/* @__PURE__ */v("p",{children:['The token approval underneath it is unlimited because the Solana token program cannot express "',S," ",k,"\". The subscriptions program enforces that rule instead, on every charge, and rejects anything over the per-period cap or sent anywhere but the plan's fixed destinations."]}),
|
|
27
|
+
/* @__PURE__ */v("p",{children:["Each charge of ",S," ",i.symbol," is split on chain between"," ",i.merchantName," and SolLoop",null!==i.feeBps?` (${w(i.feeBps)})`:"",". Cancelling from your wallet stops future charges; the current period stays paid."]}),
|
|
28
|
+
/* @__PURE__ */x("p",{children:/* @__PURE__ */x("a",{href:a("address",y,i.cluster),target:"_blank",rel:"noopener noreferrer",children:"View the program on the explorer"})})]}):null]}),
|
|
29
|
+
/* @__PURE__ */x("button",{type:"button",className:"sl-btn",onClick:()=>{n({type:"approve"})},children:"Approve and subscribe"}),
|
|
30
|
+
/* @__PURE__ */x("button",{type:"button",className:"sl-btn sl-btn--text",onClick:()=>{n({type:"back"})},children:"← Back"}),
|
|
31
|
+
/* @__PURE__ */x("p",{className:"sl-hint sl-center",children:/* @__PURE__ */x("a",{href:a("address",y,i.cluster),target:"_blank",rel:"noopener noreferrer",children:"View program"})}),
|
|
32
|
+
/* @__PURE__ */x(o,{cluster:i.cluster})]})},SigningScreen:function({state:e,send:t}){const{plan:n}=e;return"error"===e.status?/* @__PURE__ */v("div",{children:[
|
|
33
|
+
/* @__PURE__ */x(i,{plan:n}),
|
|
34
|
+
/* @__PURE__ */x(s,{tone:"fail",children:c(e.error)}),
|
|
35
|
+
/* @__PURE__ */v("div",{className:"sl-actions",children:[
|
|
36
|
+
/* @__PURE__ */x("button",{type:"button",className:"sl-btn sl-btn--ghost",onClick:()=>{t({type:"retry"})},children:"Try again"}),
|
|
37
|
+
/* @__PURE__ */x("button",{type:"button",className:"sl-btn sl-btn--text",onClick:()=>{t({type:"back"})},children:"← Back"})]})]}):/* @__PURE__ */v("div",{"data-stage":e.status,children:[
|
|
38
|
+
/* @__PURE__ */x(i,{plan:n}),
|
|
39
|
+
/* @__PURE__ */x(d,{text:Pl[e.status]}),e.slow?/* @__PURE__ */x("p",{className:"sl-hint","data-testid":"slow-hint",children:"The prompt didn't appear? Open your wallet — it may be waiting behind this window."}):null,null!==e.signature?/* @__PURE__ */v("p",{className:"sl-hint","data-testid":"signature",children:["Transaction"," ",
|
|
40
|
+
/* @__PURE__ */x("a",{className:"sl-mono",href:a("tx",e.signature,n.cluster),target:"_blank",rel:"noopener noreferrer",children:u(e.signature,{head:6,tail:6})}),". Keep this link; it is your receipt even if you close the page."]}):null]})},DoneScreen:function({state:e,config:t,send:n}){const{plan:i,result:s}=e;/* @__PURE__ */
|
|
41
|
+
return v("div",{className:"sl-center",children:[
|
|
42
|
+
/* @__PURE__ */x("div",{className:"sl-check","aria-hidden":"true",children:/* @__PURE__ */x("svg",{viewBox:"0 0 24 24",fill:"none",stroke:"currentColor",strokeWidth:"2.5",strokeLinecap:"round",strokeLinejoin:"round",children:/* @__PURE__ */x("path",{d:"M5 12l5 5L20 7"})})}),
|
|
43
|
+
/* @__PURE__ */v("h2",{className:"sl-h2",role:"status",children:["You're subscribed to ",i.name]}),
|
|
44
|
+
/* @__PURE__ */v("p",{className:"sl-lede",children:["Next charge"," ",r(s.nextChargeTs,i.periodHours,t.locale),". Cancel any time from your wallet or from ",i.merchantName,"'s account page."]}),
|
|
45
|
+
/* @__PURE__ */x("p",{className:"sl-lede",children:/* @__PURE__ */x("a",{className:"sl-mono",href:a("tx",s.signature,i.cluster),target:"_blank",rel:"noopener noreferrer",children:"View transaction"})}),null!==e.redirectIn&&null!==t.successUrl?/* @__PURE__ */v("p",{className:"sl-hint","data-testid":"redirect","aria-live":"polite",children:["Continuing in ",e.redirectIn,"…"," ",
|
|
46
|
+
/* @__PURE__ */x("button",{type:"button",className:"sl-disclose",onClick:()=>{n({type:"skip_redirect"})},children:"Stay here"})]}):null,
|
|
47
|
+
/* @__PURE__ */x(o,{cluster:i.cluster})]})}};function El(e){return{chain:Il(e),screens:zl,css:".sl-rows{border-top:1px solid var(--sl-line);border-bottom:1px solid var(--sl-line);margin:16px 0;padding:4px 0}.sl-row{display:grid;grid-template-columns:96px 1fr;gap:12px;padding:8px 0;font-size:14px}.sl-row dt{color:var(--sl-graphite);margin:0}.sl-row dd{margin:0;min-width:0;overflow-wrap:anywhere}.sl-row dd small{display:block;color:var(--sl-haze);font-size:12px}@media (max-width:340px){.sl-row{grid-template-columns:1fr;gap:2px}}.sl-notice p + p{margin-top:6px}.sl-disclose{display:inline;border:0;padding:0;background:none;color:var(--sl-accent);font:inherit;font-weight:500;cursor:pointer;text-decoration:underline;text-decoration-thickness:1px;text-underline-offset:2px}.sl-panel{margin-top:10px;padding-top:10px;border-top:1px solid var(--sl-line-strong)}.sl-panel p + p{margin-top:6px}.sl-hint{color:var(--sl-graphite);font-size:13px;margin-top:4px}.sl-check{width:48px;height:48px;margin:4px auto 12px;border-radius:50%;display:grid;place-items:center;background:var(--sl-settled-tint);color:var(--sl-settled)}.sl-check svg{width:24px;height:24px}.sl-center{text-align:center}"}}export{El as createLazyModule,zl as screens};
|
package/esm/react.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import"react/jsx-runtime";import"react";import"react-dom";import{n as r}from"./react-chunk-0PAV0iQq.js";export{r as SolLoopSubscribe};
|
package/package.json
CHANGED
|
@@ -1,8 +1,39 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "solloop",
|
|
3
|
-
"version": "0.0
|
|
4
|
-
"description": "
|
|
5
|
-
"license": "
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Recurring USDC subscriptions on Solana: the SolLoop checkout widget.",
|
|
5
|
+
"license": "MIT",
|
|
6
6
|
"homepage": "https://solloop.app",
|
|
7
|
-
"
|
|
7
|
+
"keywords": [
|
|
8
|
+
"solana",
|
|
9
|
+
"usdc",
|
|
10
|
+
"subscriptions",
|
|
11
|
+
"payments",
|
|
12
|
+
"web-component",
|
|
13
|
+
"react"
|
|
14
|
+
],
|
|
15
|
+
"type": "module",
|
|
16
|
+
"exports": {
|
|
17
|
+
".": {
|
|
18
|
+
"types": "./types/index.d.ts",
|
|
19
|
+
"default": "./esm/index.js"
|
|
20
|
+
},
|
|
21
|
+
"./react": {
|
|
22
|
+
"types": "./types/react.d.ts",
|
|
23
|
+
"default": "./esm/react.js"
|
|
24
|
+
},
|
|
25
|
+
"./package.json": "./package.json"
|
|
26
|
+
},
|
|
27
|
+
"peerDependencies": {
|
|
28
|
+
"react": "^19.0.0",
|
|
29
|
+
"react-dom": "^19.0.0"
|
|
30
|
+
},
|
|
31
|
+
"peerDependenciesMeta": {
|
|
32
|
+
"react": {
|
|
33
|
+
"optional": true
|
|
34
|
+
},
|
|
35
|
+
"react-dom": {
|
|
36
|
+
"optional": true
|
|
37
|
+
}
|
|
38
|
+
}
|
|
8
39
|
}
|
package/types/index.d.ts
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// Published as `solloop`'s types; mirrors src/index.ts. Importing the package
|
|
2
|
+
// registers <solloop-subscribe>, so the value export is only the tag name.
|
|
3
|
+
import type { SolLoopEventDetails } from './public-types.js';
|
|
4
|
+
|
|
5
|
+
export type {
|
|
6
|
+
SolLoopCluster,
|
|
7
|
+
SolLoopEventDetails,
|
|
8
|
+
SolLoopEventName,
|
|
9
|
+
SolLoopSubscribeAttributes,
|
|
10
|
+
} from './public-types.js';
|
|
11
|
+
|
|
12
|
+
export declare const TAG_NAME: 'solloop-subscribe';
|
|
13
|
+
|
|
14
|
+
declare global {
|
|
15
|
+
interface HTMLElementTagNameMap {
|
|
16
|
+
'solloop-subscribe': HTMLElement;
|
|
17
|
+
}
|
|
18
|
+
interface HTMLElementEventMap {
|
|
19
|
+
'solloop:connected': CustomEvent<SolLoopEventDetails['solloop:connected']>;
|
|
20
|
+
'solloop:subscribing': CustomEvent<SolLoopEventDetails['solloop:subscribing']>;
|
|
21
|
+
'solloop:subscribed': CustomEvent<SolLoopEventDetails['solloop:subscribed']>;
|
|
22
|
+
'solloop:error': CustomEvent<SolLoopEventDetails['solloop:error']>;
|
|
23
|
+
'solloop:cancelled': CustomEvent<SolLoopEventDetails['solloop:cancelled']>;
|
|
24
|
+
}
|
|
25
|
+
}
|