const t=(r,n,e={})=>({id:r,canonicalWire:`DAPP_${r}`,mobileWire:e.mobile===!1?void 0:e.mobileWire??r,group:n,connection:e.connection??"required",approval:e.approval??"never",sync:{canonical:e.canonicalSync??!1,mobile:e.mobileSync??e.canonicalSync??!1},mobileRead:e.mobileRead??!1}),l=Object.freeze([t("CONNECT","session",{connection:"none",approval:"always"}),t("GET_CONFIGURATION","session",{mobileRead:!0}),t("GET_CONNECTION_STATUS","session",{connection:"status",mobileRead:!0}),t("HINT_USAGE","session",{mobileRead:!0}),t("GET_SHIELDED_BALANCES","read",{canonicalSync:!0,mobileRead:!0}),t("GET_UNSHIELDED_BALANCES","read",{canonicalSync:!0,mobileRead:!0}),t("GET_DUST_BALANCE","read",{canonicalSync:!0,mobileRead:!0}),t("GET_SHIELDED_ADDRESSES","read",{mobileRead:!0}),t("GET_UNSHIELDED_ADDRESS","read",{mobileRead:!0}),t("GET_DUST_ADDRESS","read",{mobileRead:!0}),t("GET_TX_HISTORY","read",{canonicalSync:!0,mobileRead:!0}),t("SIGN_DATA","sign",{approval:"always"}),t("MAKE_TRANSFER","build",{approval:"always",canonicalSync:!0}),t("MAKE_INTENT","build",{approval:"always",canonicalSync:!0}),t("BALANCE_UNSEALED_TX","balance",{approval:"always",canonicalSync:!0}),t("BALANCE_SEALED_TX","balance",{approval:"always",canonicalSync:!0}),t("SUBMIT_TRANSACTION","submit",{approval:"always",mobileSync:!0}),t("PROVING_CHECK","prove",{approval:"proof-session-grant",mobileRead:!0}),t("PROVING_PROVE","prove",{mobileWire:"PROVE",approval:"proof-session-grant",mobileRead:!0}),t("DECRYPT_TX_OUTPUTS","decrypt",{mobile:!1,approval:"always"})]),u=new Map(l.map(r=>[r.canonicalWire,r])),d=new Map(l.flatMap(r=>r.mobileWire?[[r.mobileWire,r]]:[]));function E(r,n="canonical"){return(n==="canonical"?u:d).get(r)??null}function s(r){if(Array.isArray(r))return r.map(s);if(r instanceof Uint8Array)return Array.from(r);if(r&&typeof r=="object"){const n=r,e={};for(const i of Object.keys(n).sort()){const c=n[i];c!==void 0&&(e[i]=s(c))}return e}return typeof r=="bigint"?r.toString():r}function A(r,n){if(!n||typeof n!="object")return n;const e=n;switch(r){case"DAPP_CONNECT":return{networkId:e.networkId};case"DAPP_MAKE_TRANSFER":{let i=[];return Array.isArray(e.desiredOutputs)?i=e.desiredOutputs:Array.isArray(e.outputs)&&(i=e.outputs),{outputs:i.map(c=>{const a=c;return{recipient:a.recipient,type:a.type,value:a.value,kind:a.kind}})}}case"DAPP_MAKE_INTENT":{const i=Array.isArray(e.desiredInputs)?e.desiredInputs:[],c=Array.isArray(e.desiredOutputs)?e.desiredOutputs:[];return{desiredInputs:i.map(a=>{const o=a;return{type:o.type,value:o.value,kind:o.kind}}),desiredOutputs:c.map(a=>{const o=a;return{recipient:o.recipient,type:o.type,value:o.value,kind:o.kind}})}}case"DAPP_BALANCE_UNSEALED_TX":case"DAPP_BALANCE_SEALED_TX":case"DAPP_SUBMIT_TRANSACTION":return{tx:e.tx};case"DAPP_PROVING_CHECK":case"DAPP_PROVING_PROVE":return{keyLocation:e.keyLocation,serializedPreimage:e.serializedPreimage,overwriteBindingInput:e.overwriteBindingInput};default:return n}}function p(r){let n=2166136261;for(let e=0;e<r.length;e++)n^=r.charCodeAt(e),n=Math.imul(n,16777619);return(n>>>0).toString(36)}function _(r,n,e,i=512){const c=A(n,e),a=JSON.stringify(s(c))??"",o=i>0?a.slice(0,i):a;return`${r}:${n}:${o}:${p(a)}`}export{_ as b,E as r};
