require(`../../_virtual/_rolldown/runtime.cjs`);const e=require(`../../constants/protocol.constants.cjs`),t=require(`../utils/time.utils.cjs`);let n=require(`@solana/web3.js`);var r=30,i=async(e,t)=>{if(!t)return;let r=[...new Set(t)];return Promise.all(r.map(async t=>{let r=(await e.connection.getAddressLookupTable(new n.PublicKey(t))).value;if(!r)throw Error(`failed to fetch lookup table ${t}`);return r}))},a=async(i,a,o)=>{let[s,{blockhash:c}]=await Promise.all([i.connection.getSlot(`finalized`),i.connection.getLatestBlockhash(`finalized`)]),l=s,[u,d]=n.AddressLookupTableProgram.createLookupTable({authority:o.publicKey,payer:o.publicKey,recentSlot:l}),f=n.ComputeBudgetProgram.setComputeUnitPrice({microLamports:e.MAX_MICRO_LAMPORTS_PER_CU}),p=new n.Transaction().add(f).add(u);p.recentBlockhash=c,p.feePayer=o.publicKey,p.sign(o),await(0,n.sendAndConfirmTransaction)(i.connection,p,[o],{commitment:`confirmed`});for(let e=0;e<20&&!(await i.connection.getAddressLookupTable(d,{commitment:`confirmed`})).value;e+=1){if(e===19)throw Error(`Lookup table ${d.toBase58()} not visible after creation`);await t.waitLittle(500)}for(let e=0;e<a.length;e+=r){let t=a.slice(e,e+r),s=n.AddressLookupTableProgram.extendLookupTable({payer:o.publicKey,authority:o.publicKey,lookupTable:d,addresses:t}),{blockhash:c}=await i.connection.getLatestBlockhash(),l=new n.Transaction().add(s);l.recentBlockhash=c,l.feePayer=o.publicKey,l.sign(o),await(0,n.sendAndConfirmTransaction)(i.connection,l,[o],{commitment:`confirmed`})}return d};exports.createAndExtendAddressLookupTable=a,exports.getAddressLookupTableAccounts=i;