require(`../../_virtual/_rolldown/runtime.cjs`);let e=require(`ethers`);var t=(e,n,r)=>n.reduce((n,{name:i,type:a})=>{let o=e[i];if(a.endsWith(`[]`)){let e=a.slice(0,-2);if(r[e]&&Array.isArray(o)){let s=o.reduce((n,i,a)=>({...n,[a]:{value:t(i,r[e],r),type:e}}),{});return{...n,[i]:{value:s,type:a}}}return{...n,[i]:{value:o,type:a}}}return r[a]?{...n,[i]:{value:t(o,r[a],r),type:a}}:{...n,[i]:{value:o,type:a}}},{}),n=(e,n,r)=>{let i=t(e,n[r],n);return{primaryType:{value:r,type:`string`},...i}},r=function(e){return e.Permit=`Permit`,e.PermitWithExpiry=`PermitWithExpiry`,e.PermitBatch=`PermitBatch`,e.PermitBatchTransferFrom=`PermitBatchTransferFrom`,e.PermitSingle=`PermitSingle`,e.PermitTransferFrom=`PermitTransferFrom`,e.PermitWitnessTransferFrom=`PermitWitnessTransferFrom`,e}(r||{}),i=[`Permit`,`PermitWithExpiry`,`PermitBatch`,`PermitBatchTransferFrom`,`PermitSingle`,`PermitTransferFrom`,`PermitWitnessTransferFrom`],a=(e,t)=>{let n;switch(t){case r.PermitSingle:case r.PermitBatch:n=e.details;break;case r.PermitBatchTransferFrom:case r.PermitTransferFrom:case r.PermitWitnessTransferFrom:n=e.permitted;break;default:break}if(n)return Array.isArray(n)?n:[n]},o=(e,t,n)=>{if(!Object.keys(t).some(e=>i.includes(e)))return{isPermit:!1,tokenDetails:[]};let r=a(e,n);return r?{isPermit:!0,tokenDetails:r}:{isPermit:!0,tokenDetails:[]}},s=(t,n,r,i)=>{let{isPermit:a,tokenDetails:s}=o(t,n,i);if(!a)return{isPermit:!1};let c;if(s.length)c=r.verifyingContract;else{let t=r.verifyingContract;t&&s.push({token:t,amount:e.ethers.MaxUint256.toString()})}return{isPermit:a,tokenDetails:s,spender:c}};exports.decodeMessage=t,exports.getDecodedMessage=n,exports.getPermitInfo=s;