import{cq as f,cr as d,cs as y,ct as A,c9 as p,cn as x,cu as h,cv as L,cw as F}from"../main.js";function a(t,r){switch(t.binary){case"bytes":if("layout"in t){const{custom:o}=t;return o===void 0||typeof o.from!="function"?e(t.layout,o?o.from:r):r}case"int":case"uint":{const{custom:o}=t;return t!=null&&t.omit?void 0:d(o)?o:y(o)?o.to:r}case"array":return Array.isArray(r)?r.map(o=>e(t.layout,o)):void 0;case"switch":{const o=r[t.idTag??"id"],[s,n]=t.layouts.find(([c])=>(Array.isArray(c)?c[1]:c)==o);return{[t.idTag??"id"]:o,...e(n,r)}}}}function e(t,r){if(r=r??{},f(t))return a(t,r);const o={};for(const s of t){const n=a(s,r[s.name]??{});n!==void 0&&(o[s.name]=n)}return o}function u(t,r){return e(t,r)}function i(t){return[...h,L(t)]}function T(t,r){const[o,s]=A(t),n=u(i(t),r);return{protocolName:o,payloadName:s,payloadLiteral:t,...u(F,r),...n,hash:p(x(i(t),n))}}export{T as c};
