diff --git a/snaps-simulator/staging/main.js b/snaps-simulator/staging/main.js index 1f5940aeba..9c94fc95d5 100644 --- a/snaps-simulator/staging/main.js +++ b/snaps-simulator/staging/main.js @@ -202,4 +202,4 @@ ${e} `}table(e,t){return t&&(t=`${t}`),"\n\n"+e+"\n"+t+"
\n"}tablerow(e){return` ${e} `}tablecell(e,t){let r=t.header?"th":"td",n=t.align?`<${r} align="${t.align}">`:`<${r}>`;return n+e+` -`}strong(e){return`${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return"
"}del(e){return`${e}`}link(e,t,r){let n=o_(e);if(null===n)return r;let i='"}image(e,t,r){let n=o_(e);if(null===n)return r;let i=`${r}"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""));continue;case"code":r+=this.renderer.code(i.text,i.lang,!!i.escaped);continue;case"table":{let e="",t="";for(let e=0;e0&&"paragraph"===t.tokens[0].type?(t.tokens[0].text=e+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&"text"===t.tokens[0].tokens[0].type&&(t.tokens[0].tokens[0].text=e+" "+t.tokens[0].tokens[0].text)):t.tokens.unshift({type:"text",text:e+" "}):s+=e+" "}s+=this.parse(t.tokens,n),o+=this.renderer.listitem(s,a,!!r)}r+=this.renderer.list(o,e,t);continue}case"html":r+=this.renderer.html(i.text,i.block);continue;case"paragraph":r+=this.renderer.paragraph(this.parseInline(i.tokens));continue;case"text":{let o=i,a=o.tokens?this.parseInline(o.tokens):o.text;for(;n+1{let i=e[n].flat(1/0);r=r.concat(this.walkTokens(i,t))}):e.tokens&&(r=r.concat(this.walkTokens(e.tokens,t)))}}return r}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let r={...e};if(r.async=this.defaults.async||r.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error("extension name required");if("renderer"in e){let r=t.renderers[e.name];r?t.renderers[e.name]=function(...t){let n=e.renderer.apply(this,t);return!1===n&&(n=r.apply(this,t)),n}:t.renderers[e.name]=e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw Error("extension level must be 'block' or 'inline'");let r=t[e.level];r?r.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),r.extensions=t),e.renderer){let t=this.defaults.renderer||new o3(this.defaults);for(let r in e.renderer){if(!(r in t))throw Error(`renderer '${r}' does not exist`);if("options"===r)continue;let n=e.renderer[r],i=t[r];t[r]=(...e)=>{let r=n.apply(t,e);return!1===r&&(r=i.apply(t,e)),r||""}}r.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new oy(this.defaults);for(let r in e.tokenizer){if(!(r in t))throw Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let n=e.tokenizer[r],i=t[r];t[r]=(...e)=>{let r=n.apply(t,e);return!1===r&&(r=i.apply(t,e)),r}}r.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new o5;for(let r in e.hooks){if(!(r in t))throw Error(`hook '${r}' does not exist`);if("options"===r)continue;let n=e.hooks[r],i=t[r];o5.passThroughHooks.has(r)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(n.call(t,e)).then(e=>i.call(t,e));let r=n.call(t,e);return i.call(t,r)}:t[r]=(...e)=>{let r=n.apply(t,e);return!1===r&&(r=i.apply(t,e)),r}}r.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,n=e.walkTokens;r.walkTokens=function(e){let r=[];return r.push(n.call(this,e)),t&&(r=r.concat(t.call(this,e))),r}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return o2.lex(e,t??this.defaults)}parser(e,t){return o6.parse(e,t??this.defaults)}#e(e,t){return(r,n)=>{let i={...n},o={...this.defaults,...i};!0===this.defaults.async&&!1===i.async&&(o.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),o.async=!0);let a=this.#t(!!o.silent,!!o.async);if(null==r)return a(Error("marked(): input parameter is undefined or null"));if("string"!=typeof r)return a(Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));if(o.hooks&&(o.hooks.options=o),o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(r):r).then(t=>e(t,o)).then(e=>o.hooks?o.hooks.processAllTokens(e):e).then(e=>o.walkTokens?Promise.all(this.walkTokens(e,o.walkTokens)).then(()=>e):e).then(e=>t(e,o)).then(e=>o.hooks?o.hooks.postprocess(e):e).catch(a);try{o.hooks&&(r=o.hooks.preprocess(r));let n=e(r,o);o.hooks&&(n=o.hooks.processAllTokens(n)),o.walkTokens&&this.walkTokens(n,o.walkTokens);let i=t(n,o);return o.hooks&&(i=o.hooks.postprocess(i)),i}catch(e){return a(e)}}}#t(e,t){return r=>{if(r.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="

An error occurred:

"+ol(r.message+"",!0)+"
";return t?Promise.resolve(e):e}if(t)return Promise.reject(r);throw r}}}let o7=new o8;function o9(e,t){return o7.parse(e,t)}o9.options=o9.setOptions=function(e){return o7.setOptions(e),o9.defaults=o7.defaults,ot=o9.defaults,o9},o9.getDefaults=oe,o9.defaults=ot,o9.use=function(...e){return o7.use(...e),o9.defaults=o7.defaults,ot=o9.defaults,o9},o9.walkTokens=function(e,t){return o7.walkTokens(e,t)},o9.parseInline=o7.parseInline,o9.Parser=o6,o9.parser=o6.parse,o9.Renderer=o3,o9.TextRenderer=o4,o9.Lexer=o2,o9.lexer=o2.lex,o9.Tokenizer=oy,o9.Hooks=o5,o9.parse=o9,o9.options,o9.setOptions,o9.use;let ae=o9.walkTokens;o9.parseInline,o6.parse;let at=o2.lex;function ar(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);r0?au(e.tokens.flatMap(ap)):e.href});case"text":return e.text;case"strong":return i1(i6,{children:ac(e.tokens)});case"em":return i1(i5,{children:ac(e.tokens)});default:return null}}function a_(e,t,r){try{var n=new URL(e);if((0,d.assert)(al.includes(n.protocol),"Protocol must be one of: ".concat(al.join(", "),".")),"metamask:"===n.protocol){var i=function(e){var t=new URL(e),r=t.hostname,n=t.pathname,i=t.protocol;if("metamask:"!==i)throw Error('Unable to parse URL. Expected the protocol to be "metamask:", but received "'.concat(i,'".'));switch(r){case"client":return(0,d.assert)(an.includes(n),'Unable to navigate to "'.concat(n,'". The provided path is not allowed.')),{authority:r,path:n};case"snap":return function(e){var t,r="Invalid MetaMask url:",n=e5(e.slice(1)),i=e.slice(1).startsWith("npm:")?"npm:":"local:",o=n.startsWith("@"),a=n.split("/"),s="/".concat(a[a.length-1]);if("local:"===i){var l,u=function(e){if(Array.isArray(e))return e}(l=a.slice(0,-1))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(l)||function(e,t){if(e){if("string"==typeof e)return ar(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ar(e,t)}}(l)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),c=u[0],p=u.slice(2);t="".concat(c,"//").concat(p.join("/")),(0,d.assert)(ai.includes(s),"".concat(r," invalid snap path."))}else t=o?"".concat(a[0],"/").concat(a[1]):a[0],(0,d.assert)(o?3===a.length&&ai.includes(s):2===a.length&&ai.includes(s),"".concat(r," invalid snap path."));var _="".concat(i).concat(t);return(0,d.assertStruct)(_,e4,"Invalid snap ID"),{authority:"snap",snapId:_,path:s}}(n);default:throw Error('Expected "metamask:" URL to start with "client" or "snap", but received "'.concat(r,'".'))}}(e);i.snapId&&(0,d.assert)(r(i.snapId),"The Snap being navigated to is not installed.")}else if("mailto:"===n.protocol){var o=n.pathname.split(","),a=!0,s=!1,l=void 0;try{for(var u,c=o[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var p=u.value.split("@")[1];(0,d.assert)(!t(p),"The specified URL is not allowed.")}}catch(e){s=!0,l=e}finally{try{a||null==c.return||c.return()}finally{if(s)throw l}}return}(0,d.assert)(!t(n.hostname),"The specified URL is not allowed.")}catch(e){throw Error("Invalid URL: ".concat((null==e?void 0:e.code)==="ERR_ASSERTION"?e.message:"Unable to parse URL."))}}function ad(e,t,r){var n=(s=at(e,{gfm:!1}),l=[],ae(s,function(e){"link"===e.type&&l.push(e)}),l),i=!0,o=!1,a=void 0;try{for(var s,l,u,c=n[Symbol.iterator]();!(i=(u=c.next()).done);i=!0){var p=u.value;a_(p.href,t,r)}}catch(e){o=!0,a=e}finally{try{i||null==c.return||c.return()}finally{if(o)throw a}}}function af(e){return(0,d.hasProperty)(e.props,"children")}function am(e){return!!e&&!0!==e}function ah(e){if(af(e)){if(Array.isArray(e.props.children))return e.props.children.filter(am).flat(1/0);if(e.props.children)return[e.props.children]}return[]}function ay(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(Array.isArray(e)){var n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var l=a.value,u=ay(l,t,r);if(void 0!==u)return u}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return}var c=t(e,r);if(void 0!==c)return c;if((0,d.hasProperty)(e,"props")&&(0,d.isPlainObject)(e.props)&&(0,d.hasProperty)(e.props,"children")){var p=ah(e),_=!0,f=!1,m=void 0;try{for(var h,y=p[Symbol.iterator]();!(_=(h=y.next()).done);_=!0){var g=h.value;if((0,d.isPlainObject)(g)){var b=ay(g,t,r+1);if(void 0!==b)return b}}}catch(e){f=!0,m=e}finally{try{_||null==y.return||y.return()}finally{if(f)throw m}}}}function ag(e){return Object.entries(e).filter(function(e){return"children"!==aa(e,1)[0]}).sort(function(e,t){var r=aa(e,1)[0],n=aa(t,1)[0];return r.localeCompare(n)}).map(function(e){var t=aa(e,2),r=t[0],n=t[1];return" ".concat(r,"=").concat("string"==typeof n?'"'.concat(n,'"'):"{".concat(JSON.stringify(n),"}"))}).join("")}var ab=r(8261),av=r.n(ab),ax=r(9691),aD=r.n(ax);function aS(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r1?"move":"default",children:[(0,_.jsx)(P,{icon:r.data.type.toLowerCase(),width:"16px"}),(0,_.jsx)(k.Text,{fontWeight:"500",fontSize:"sm",textTransform:"capitalize",color:"text.muted",display:"inline-block",minWidth:"65px",children:r.data.type}),i,Number(r.id)>=2&&(0,_.jsx)(P,{icon:"cross",width:"11px",marginX:"0.5",marginLeft:"auto",cursor:"pointer",onClick:function(){null==o||o(r)}})]})};function aN(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function aj(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:[];return function(){for(var n=arguments.length,i=Array(n),o=0;oe.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);r ul":{display:"flex",flexDirection:"column",flex:1,marginY:"4","& > li":{display:"flex",flexDirection:"column",flex:1,marginTop:"0"}},ul:{listStyleType:"none"},li:{marginTop:"2"}},children:(0,_.jsx)(n6.Tree,{ref:n,tree:t,rootId:0,render:function(e,r){var n=r.depth,a=r.isDragging;return t.length<=1?(0,_.jsx)(aY,{}):(0,_.jsx)(aK,{node:e,depth:n,onChange:i,onClose:o,isDragging:a})},insertDroppableFirst:!1,canDrag:function(e){return!!e&&Number(e.id)>=2},canDrop:function(e,t){var r=t.dropTarget,n=t.dropTargetId,i=t.dragSource;return!!n&&null!=i&&!!i.data&&function(e,t){if(!e||!t)return!1;switch(e.type){case"Box":return aE(t);case"Form":return aT(t);case"Field":return aw(t);default:return!1}}(null==r?void 0:r.data,null==i?void 0:i.data)&&(null==r?void 0:r.droppable)&&Number(n)>0},onDrop:function(e){r(e)},initialOpen:!0,sort:!1,extraAcceptTypes:["template"],placeholderRender:function(){return(0,_.jsx)(k.Box,{width:"100%",height:"20px"})}})})},aG=function(e){var t=e.snapName,r=F(nn),n=r&&new Blob([r.value],{type:"image/svg+xml"}),i=n&&URL.createObjectURL(n);return(0,_.jsxs)(k.Box,{position:"relative",children:[(0,_.jsx)(k.Avatar,{src:i,name:t.slice(0,1).toUpperCase(),fontSize:"md",background:"background.alternative",color:"text.alternative",size:"sm",margin:"1"}),(0,_.jsx)(P,{icon:"snap",width:"16px",height:"16px",position:"absolute",bottom:"0px",right:"0px"})]})},aZ=function(e){var t=e.snapName,r=e.snapId;return(0,_.jsxs)(k.Flex,{gap:"2",marginX:"4",marginY:"4",border:"1px solid",borderColor:"border.default",borderRadius:"32px",padding:"1",alignItems:"center",children:[(0,_.jsx)(aG,{snapName:t}),(0,_.jsxs)(k.Flex,{direction:"column",justify:"center",children:[(0,_.jsx)(k.Text,{fontSize:"sm",lineHeight:"157%",fontFamily:"custom",children:t}),(0,_.jsx)(k.Text,{fontSize:"xs",lineHeight:"167%",fontFamily:"custom",color:"text.alternative",children:r})]})]})},aX=function(e){var t=e.snapName,r=e.snapId,n=e.children,i=e.showAuthorship;return(0,_.jsxs)(k.Flex,{direction:"column",boxShadow:"lg",maxWidth:"360px",height:"600px",paddingY:"4",overflowY:"scroll",children:[(void 0===i||i)&&(0,_.jsx)(aZ,{snapName:t,snapId:r}),n]})};!function(e){e.Content="content",e.Error="error",e.Insights="insights"}(cw||(cw={}));var a0=function(e,t){switch(e){case cw.Insights:return"Insights from ".concat(t);case cw.Error:return"Error from ".concat(t);default:return"Content from ".concat(t)}},a1=function(e){var t=e.type,r=e.snapName,n=e.children,i=t===cw.Error;return(0,_.jsxs)(k.Box,{border:"1px solid",borderColor:"border.default",borderRadius:"md",backgroundColor:i?"error.muted":void 0,children:[(0,_.jsxs)(k.Flex,{direction:"row",alignItems:"center",padding:"1.5",borderBottom:"1px solid",borderColor:"border.default",children:[(0,_.jsx)(P,{icon:i?"snapError":"snap",width:"16px",marginRight:"1"}),(0,_.jsx)(k.Text,{fontFamily:"custom",fontSize:"xs",color:i?"text.error":void 0,children:a0(t,r)})]}),(0,_.jsx)(k.Box,{padding:"3",children:n})]})};function a2(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{let t=sb();sg(!0);try{let r=!1,n=sh(()=>{let t=e();return null!==t&&"object"==typeof t&&"function"==typeof t.then&&(r=!0),t});if(r)return{then:(e,r)=>{n.then(r=>{sg(t),e(r)},e=>{sg(t),r(e)})}};return sg(t),n}catch(e){throw sg(t),e}},sx=function(){return(0,sf.BX)(...arguments)};Object.keys(sf.BX).forEach(e=>{sx[e]=function(){return sf.BX[e](...arguments)}});let sD=sx.mouseEnter,sS=sx.mouseLeave;sx.mouseEnter=function(){return sD(...arguments),sx.mouseOver(...arguments)},sx.mouseLeave=function(){return sS(...arguments),sx.mouseOut(...arguments)};let sE=sx.pointerEnter,sT=sx.pointerLeave;sx.pointerEnter=function(){return sE(...arguments),sx.pointerOver(...arguments)},sx.pointerLeave=function(){return sT(...arguments),sx.pointerOut(...arguments)};let sw=sx.select;sx.select=(e,t)=>{sw(e,t),e.focus(),sx.keyUp(e,t)};let sA=sx.blur,sC=sx.focus;sx.blur=function(){return sx.focusOut(...arguments),sA(...arguments)},sx.focus=function(){return sx.focusIn(...arguments),sC(...arguments)},(0,sf.jQ)({unstable_advanceTimersWrapper:e=>sv(e),asyncWrapper:async e=>{let t=sb();sg(!1);try{let t=await e();return await new Promise(e=>{setTimeout(()=>{e()},0),"undefined"!=typeof jest&&null!==jest&&(!0===setTimeout._isMockFunction||Object.prototype.hasOwnProperty.call(setTimeout,"clock"))&&jest.advanceTimersByTime(0)}),t}finally{sg(t)}},eventWrapper:e=>{let t;return sv(()=>{t=e()}),t}});let sM=new Set,sN=[];function sj(){sN.forEach(e=>{let{root:t,container:r}=e;sv(()=>{t.unmount()}),r.parentNode===document.body&&document.body.removeChild(r)}),sN.length=0,sM.clear()}if((void 0===sm||!sm.env?.RTL_SKIP_AUTO_CLEANUP)&&("function"==typeof afterEach?afterEach(()=>{sj()}):"function"==typeof teardown&&teardown(()=>{sj()}),"function"==typeof beforeAll&&"function"==typeof afterAll)){let e=sb();beforeAll(()=>{e=sb(),sg(!0)}),afterAll(()=>{sg(e)})}var sk=r(3151),sI=r(966),sO=r.n(sI),sP={primary:"primary",destructive:"outline"},sF=function(e){var t,r=e.node,n=e.id;i0(r),(0,d.assert)("Button"===r.type,"Expected value to be a button component.");var i=s_().handleEvent,o=r.props;return(0,_.jsx)(k.Button,{width:"100%",variant:sP[null!==(t=o.variant)&&void 0!==t?t:"primary"],marginBottom:"4",type:o.type,onClick:function(e){o.type===cE.Button&&e.preventDefault(),i({event:cA.ButtonClickEvent,name:o.name})},children:o.children},"".concat(n,"-button"))},sL=function(e){var t=e.node,r=e.id,n=e.form,i=s_(),o=i.handleInputChange,a=i.getValue;i0(t),(0,d.assert)("Input"===t.type,"Expected value to be an input component.");var s=t.props,l=a(s.name,n);return(0,_.jsx)(k.Input,{value:l,type:s.type,placeholder:s.placeholder,onChange:function(e){o(s.name,e.target.value,n)}},"".concat(r,"-input"))},sR={Bold:function(e){var t=e.node,r=e.id;return i0(t),(0,d.assert)("Bold"===t.type,"Expected value to be a bold component."),(0,_.jsx)(k.Text,{fontFamily:"custom",fontSize:"sm",paddingBottom:"1",as:"b",children:sB(ah(t),r)},"".concat(r,"-text"))},Box:function(e){var t=e.node,r=e.id;return i0(t),(0,d.assert)("Box"===t.type,"Expected value to be a Box component."),(0,_.jsx)(k.Box,{children:ah(t).map(function(e,t){return(0,_.jsx)(sz,{node:e},"".concat(r,"-panel-child-").concat(t))})},r)},Button:sF,Copyable:function(e){var t=e.node,r=e.id;i0(t),(0,d.assert)("Copyable"===t.type,"Expected value to be a copyable component.");var n=t.props;return(0,_.jsx)(a3,{value:n.value},"".concat(r,"-copyable"))},Divider:function(e){var t=e.id;return(0,_.jsx)(k.Divider,{orientation:"horizontal",marginTop:"3",marginBottom:"4",borderColor:"border.default"},"".concat(t,"-divider"))},Field:function(e){var t=e.node,r=e.id,n=e.form;i0(t),(0,d.assert)("Field"===t.type,"Expected value to be a field component.");var i=ah(t),o=i[0],a=i[1],s=t.props;return(0,_.jsxs)(k.FormControl,{isInvalid:!!s.error,children:[s.label&&(0,_.jsx)(k.FormLabel,{children:s.label}),(0,_.jsx)(sL,{id:r,node:o,form:n}),a&&(0,_.jsx)(sF,{id:r,node:a}),(0,_.jsx)(k.FormErrorMessage,{children:s.error})]},"".concat(r,"-field"))},Form:function(e){var t=e.node,r=e.id;i0(t),(0,d.assert)("Form"===t.type,"Expected value to be a form component.");var n=s_().handleEvent,i=t.props;return(0,_.jsx)(k.Box,{as:"form",onSubmit:function(e){e.preventDefault(),n({event:cA.FormSubmitEvent,name:i.name})},children:ah(t).map(function(e,n){return(0,_.jsx)(sz,{node:e,form:t.props.name},"".concat(r,"-form-child-").concat(n))})},r)},Heading:function(e){var t=e.node,r=e.id;i0(t),(0,d.assert)("Heading"===t.type,"Expected value to be a heading component.");var n=t.props;return(0,_.jsx)(k.Heading,{fontFamily:"custom",fontSize:"x-large",fontWeight:"bold",paddingBottom:"4",children:n.children},"".concat(r,"-heading"))},Input:sL,Italic:function(e){var t=e.node,r=e.id;return i0(t),(0,d.assert)("Italic"===t.type,"Expected value to be an italic component."),(0,_.jsx)(k.Text,{fontFamily:"custom",fontSize:"sm",paddingBottom:"1",as:"i",children:sB(ah(t),r)},r)},Link:function(e){var t=e.node,r=e.id;i0(t),(0,d.assert)("Link"===t.type,"Expected value to be a link component.");var n=t.props;return(0,_.jsxs)(k.Link,{href:n.href,target:"_blank",fontFamily:"custom",fontSize:"sm",isExternal:!0,color:"link.default",display:"inline",children:[sB(ah(t),r),(0,_.jsx)(P,{icon:"linkOut",width:"14px",marginLeft:"2px",display:"inline",verticalAlign:"middle"})]})},Spinner:function(e){var t=e.id;return(0,_.jsx)(k.Spinner,{},"".concat(t,"-spinner"))},Text:function(e){var t=e.node,r=e.id;return i0(t),(0,d.assert)("Text"===t.type,"Expected value to be a text component."),(0,_.jsx)(k.Text,{fontFamily:"custom",fontSize:"sm",paddingBottom:"1",children:sB(ah(t),r)},r)},Image:function(e){var t=e.id,r=e.node;i0(r),(0,d.assert)("Image"===r.type,"Expected value to be a image component.");var n=r.props,i="data:image/svg+xml;utf8,".concat(encodeURIComponent(n.src));return(0,_.jsx)(k.Image,{src:i,alt:n.alt},"".concat(t,"-image"))}},sz=function(e){var t=e.node,r=e.form,n=e.map,i=void 0===n?{}:n,o=e.id;if(!t)return null;var a=null!=o?o:sq(i,t),s=sR[t.type];if(!s)throw Error("Unknown component type: ".concat(t.type,"."));return(0,_.jsx)(s,{id:a,node:t,form:r},a)};function sB(e,t){return e.map(function(e,r){return"string"==typeof e?(0,sk.unescape)(e):(0,_.jsx)(sz,{id:"".concat(t,"-text-child-").concat(r),node:e},"".concat(t,"-text-child-").concat(r))})}var sU=sO()(function(e){var t=e.type,r=e.props.name,n=function(e){if(!af(e))return null;var t,r=e.props.children;return"string"==typeof r?r.slice(0,5e3):Array.isArray(r)?r.map(function(e){return{type:null!==(t=null==e?void 0:e.type)&&void 0!==t?t:null}}):r}(e);return(0,d.remove0x)((0,d.bytesToHex)(eM(JSON.stringify({type:t,name:null!=r?r:null,children:n}))))});function sq(e,t){var r,n=sU(t),i=(null!==(r=e[n])&&void 0!==r?r:0)+1;return e[n]=i,"".concat(n,"_").concat(i)}var sJ=function(e){var t=e.content,r=sq({},t);return(0,_.jsx)(sp,{children:(0,_.jsx)(sz,{node:t,id:r})})};function s$(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);r=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}(e,["name","onClick"]);return(0,_.jsx)(n0,{cursor:"pointer",onClick:function(){r(n)},children:t})},lj=function(e){var t=e.onClick;return(0,_.jsxs)(k.Box,{marginBottom:"4",children:[(0,_.jsx)(k.Text,{fontWeight:"500",fontSize:"xs",marginBottom:"1",children:"Transaction presets"}),(0,_.jsx)(k.Flex,{gap:"2",children:lM.map(function(e,r){var n,i,o=e.name,a=e.transaction;return(0,m.createElement)(lN,(n=function(e){for(var t=1;t=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var lO={chainId:"eip155:1",origin:"metamask.io",from:"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",to:"0x9f2817015caF6607C1198fB943A8241652EE8906",value:"0.01",gas:"21000",nonce:"5",maxFeePerGas:"10",maxPriorityFeePerGas:"1",data:"0x"},lP=function(){var e,t,r,n,i,o,a,s,l,u,c,p=F(lT).request,d=null!==(c=null==p?void 0:p.params)&&void 0!==c?c:{},f=d.chainId,m=d.transactionOrigin,h=d.transaction;lO.chainId,lO.origin;var y=lI(lO,["chainId","origin"]),g=(0,li.useForm)({defaultValues:lk({chainId:null!=f?f:lO.chainId,transactionOrigin:null!=m?m:lO.origin},null!=h?h:y)}),b=g.handleSubmit,v=g.register,x=g.setValue,D=g.formState.errors,S=j();return(0,_.jsxs)(k.Flex,{as:"form",flexDirection:"column",flex:"1",onSubmit:b(function(e){var t=e.chainId,r=e.transactionOrigin,n=lI(e,["chainId","transactionOrigin"]);S(r3({origin:"",handler:cl.OnTransaction,request:{jsonrpc:"2.0",method:"onTransaction",params:{chainId:t,transaction:lC(n),transactionOrigin:r}}}))}),id:"request-form",children:[(0,_.jsx)(lj,{onClick:function(e){x("chainId",e.chainId),x("transactionOrigin",e.transactionOrigin),x("from",e.from),x("to",e.to),x("value",e.value),x("data",e.data),x("gas",e.gas),x("maxFeePerGas",e.maxFeePerGas),x("maxPriorityFeePerGas",e.maxPriorityFeePerGas),x("nonce",e.nonce)}}),(0,_.jsxs)(k.Flex,{gap:"2",children:[(0,_.jsxs)(k.FormControl,{isInvalid:!!D.chainId,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"chainId",children:"Chain ID"}),(0,_.jsx)(k.Input,lk({id:"chainId",placeholder:lO.chainId,fontFamily:"code"},v("chainId"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(e=D.chainId)||void 0===e?void 0:e.message})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.transactionOrigin,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"origin",children:"Transaction Origin"}),(0,_.jsx)(k.Input,lk({id:"origin",placeholder:lO.origin,fontFamily:"code"},v("transactionOrigin"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(t=D.transactionOrigin)||void 0===t?void 0:t.message})]})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.from,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"from",children:"From Address"}),(0,_.jsx)(k.Input,lk({id:"from",placeholder:lO.from,fontFamily:"code"},v("from"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(r=D.from)||void 0===r?void 0:r.message})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.to,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"to",children:"To Address"}),(0,_.jsx)(k.Input,lk({id:"to",placeholder:lO.to,fontFamily:"code"},v("to"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(n=D.to)||void 0===n?void 0:n.message})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.value,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"value",children:"Value"}),(0,_.jsxs)(k.InputGroup,{children:[(0,_.jsx)(k.Input,lk({id:"value",placeholder:lO.value,fontFamily:"code"},v("value"))),(0,_.jsx)(k.InputRightAddon,{children:"ETH",fontSize:"sm"})]}),(0,_.jsx)(k.FormErrorMessage,{children:null===(i=D.value)||void 0===i?void 0:i.message})]}),(0,_.jsxs)(k.Flex,{gap:"2",children:[(0,_.jsxs)(k.FormControl,{isInvalid:!!D.gas,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"gas",children:"Gas Limit"}),(0,_.jsx)(k.Input,lk({id:"gas",placeholder:lO.gas,fontFamily:"code"},v("gas"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(o=D.gas)||void 0===o?void 0:o.message})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.nonce,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"nonce",children:"Nonce"}),(0,_.jsx)(k.Input,lk({id:"nonce",placeholder:lO.nonce,fontFamily:"code"},v("nonce"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(a=D.nonce)||void 0===a?void 0:a.message})]})]}),(0,_.jsxs)(k.Flex,{gap:"2",children:[(0,_.jsxs)(k.FormControl,{isInvalid:!!D.maxFeePerGas,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"maxFeePerGas",children:"Max Fee Per Gas"}),(0,_.jsxs)(k.InputGroup,{children:[(0,_.jsx)(k.Input,lk({id:"maxFeePerGas",placeholder:lO.maxFeePerGas,fontFamily:"code"},v("maxFeePerGas"))),(0,_.jsx)(k.InputRightAddon,{children:"GWEI",fontSize:"sm"})]}),(0,_.jsx)(k.FormErrorMessage,{children:null===(s=D.maxFeePerGas)||void 0===s?void 0:s.message})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.maxPriorityFeePerGas,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"maxPriorityFeePerGas",children:"Max Priority Fee Per Gas"}),(0,_.jsxs)(k.InputGroup,{children:[(0,_.jsx)(k.Input,lk({id:"maxPriorityFeePerGas",placeholder:lO.maxPriorityFeePerGas,fontFamily:"code"},v("maxPriorityFeePerGas"))),(0,_.jsx)(k.InputRightAddon,{children:"GWEI",fontSize:"sm"})]}),(0,_.jsx)(k.FormErrorMessage,{children:null===(l=D.maxPriorityFeePerGas)||void 0===l?void 0:l.message})]})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.data,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"data",children:"Data"}),(0,_.jsx)(k.Textarea,lk({id:"data",placeholder:lO.data,fontFamily:"code"},v("data"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(u=D.data)||void 0===u?void 0:u.message})]})]})},lF=(0,h.createHashRouter)((0,h.createRoutesFromElements)((0,_.jsxs)(h.Route,{element:(0,_.jsx)(function(){return(0,_.jsxs)(k.Flex,{direction:"column",height:"100vh",children:[(0,_.jsx)(nf,{}),(0,_.jsxs)(k.Flex,{direction:"row",flex:"1",overflow:"hidden",children:[(0,_.jsx)(nP,{}),(0,_.jsxs)(k.Flex,{direction:"column",width:"full",children:[(0,_.jsx)(k.Flex,{flex:"1",overflow:"hidden",children:(0,_.jsx)(h.Outlet,{})}),(0,_.jsx)(Y,{})]})]})]})},{}),children:[(0,_.jsx)(h.Route,{path:"/",element:(0,_.jsx)(h.Navigate,{to:"/handler/".concat(cl.OnRpcRequest),replace:!0})}),(0,_.jsx)(h.Route,{path:"/builder",element:(0,_.jsx)(function(){var e,t,r=sH((0,m.useState)(2),2),n=r[0],i=r[1],o=sH((0,m.useState)([{id:1,parent:0,text:"Box",droppable:!0,data:nR({children:null})}]),2),a=o[0],s=o[1];return(0,_.jsx)(k.Flex,{width:"100%",direction:"column",overflow:"hidden",children:(0,_.jsxs)(k.Flex,{direction:"row",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.Flex,{direction:"column",flex:"1",width:"50%",overflow:"hidden",children:(0,_.jsxs)(k.Tabs,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.TabList,{children:(0,_.jsx)(k.Tab,{children:"Builder"})}),(0,_.jsx)(k.TabPanels,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:(0,_.jsxs)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",overflowY:"auto",children:[(0,_.jsx)(n4,{nextId:n,incrementId:function(){i(function(e){return e+1})}}),(0,_.jsx)(aH,{items:a,setItems:s})]})})]})}),(0,_.jsx)(k.Box,{display:"flex",flexDirection:"column",flex:"1",width:"50%",borderLeft:"1px solid",borderColor:"border.default",children:(0,_.jsxs)(k.Tabs,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsxs)(k.TabList,{children:[(0,_.jsx)(k.Tab,{children:"Result"}),(0,_.jsx)(k.Tab,{children:"Code"})]}),(0,_.jsxs)(k.TabPanels,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",padding:"4",children:(0,_.jsx)(sW,{items:a})}),(0,_.jsx)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",padding:"0",children:(0,_.jsx)(nJ,{border:"none",value:(t=(function e(t){var r=new Set;r.add(t.type);var n=ah(t),i=!0,o=!1,a=void 0;try{for(var s,l=n[Symbol.iterator]();!(i=(s=l.next()).done);i=!0){var u=s.value;if("string"!=typeof u&&(r.add(u.type),af(t))){var c=e(u),p=!0,_=!1,d=void 0;try{for(var f,m=c[Symbol.iterator]();!(p=(f=m.next()).done);p=!0){var h=f.value;r.add(h)}}catch(e){_=!0,d=e}finally{try{p||null==m.return||m.return()}finally{if(_)throw d}}}}}catch(e){o=!0,a=e}finally{try{i||null==l.return||l.return()}finally{if(o)throw a}}return Array.from(r).sort(function(e,t){return e.localeCompare(t)})})(e=aC(a)).join(", "),aD().format("\n import { ".concat(t," } from '@metamask/snaps-sdk/jsx';\n\n const Component = () => (").concat(function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(Array.isArray(t))return t.map(function(t){return e(t,r)}).join("");var n=" ".repeat(r);if("string"==typeof t)return"".concat(n).concat(t,"\n");if(!t)return"";var i=t.type,o=t.props,a=r>0?"\n":"";if((0,d.hasProperty)(o,"children")){var s=e(o.children,r+1);return"".concat(n,"<").concat(i).concat(ag(o),">\n").concat(s).concat(n,"").concat(a)}return"".concat(n,"<").concat(i).concat(ag(o)," />").concat(a)}(e),");\n"),{parser:"typescript",plugins:[av()],printWidth:80,tabWidth:2,singleQuote:!0,trailingComma:"all"})),language:"typescript",options:{readOnly:!0}})})]})]})})]})})},{})}),(0,_.jsx)(h.Route,{path:"/manifest",element:(0,_.jsx)(function(){var e=F(nl);return(0,_.jsx)(k.Flex,{width:"100%",direction:"column",overflow:"hidden",children:(0,_.jsxs)(k.Flex,{direction:"row",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.Flex,{direction:"column",flex:"1",width:"50%",overflow:"hidden",children:(0,_.jsxs)(k.Tabs,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.TabList,{children:(0,_.jsx)(k.Tab,{children:"Validation"})}),(0,_.jsx)(k.TabPanels,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:(0,_.jsx)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",padding:"0",children:(0,_.jsx)(sX,{})})})]})}),(0,_.jsx)(k.Box,{display:"flex",flexDirection:"column",flex:"1",width:"50%",borderLeft:"1px solid",borderColor:"border.default",children:(0,_.jsxs)(k.Tabs,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.TabList,{children:(0,_.jsx)(k.Tab,{children:"Manifest"})}),(0,_.jsx)(k.TabPanels,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:(0,_.jsx)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",padding:"0",children:(0,_.jsx)(nJ,{border:"none",value:JSON.stringify(e,null,2),options:{readOnly:!0,wordWrap:"on"}})})})]})})]})})},{})}),(0,_.jsxs)(h.Route,{path:"/handler",element:(0,_.jsx)(function(){var e,t=function(e){if(Array.isArray(e))return e}(e=(0,m.useState)(0))||function(e,t){var r,n,i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var o=[],a=!0,s=!1;try{for(i=i.call(e);!(a=(r=i.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){s=!0,n=e}finally{try{a||null==i.return||i.return()}finally{if(s)throw n}}return o}}(e,2)||function(e,t){if(e){if("string"==typeof e)return ls(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ls(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),r=t[0],n=t[1],i=F(ni);return(0,_.jsx)(k.Flex,{width:"100%",direction:"column",overflow:"hidden",children:(0,_.jsxs)(k.Flex,{direction:"row",flex:"1",overflow:"hidden",children:[(0,_.jsx)(s0,{isTest:!1,children:(0,_.jsx)(k.Flex,{direction:"column",flex:"1",width:"50%",overflow:"hidden",children:(0,_.jsxs)(k.Tabs,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",isLazy:!0,onChange:n,children:[(0,_.jsx)(s9,{}),(0,_.jsxs)(k.TabList,{alignItems:"center",children:[(0,_.jsx)(k.Tab,{children:"Request"}),(0,_.jsx)(k.Tab,{children:"History"}),0===r&&(0,_.jsx)(k.Box,{marginLeft:"auto",children:(0,_.jsx)(s7,{})})]}),(0,_.jsxs)(k.TabPanels,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",overflowY:"auto","data-testid":"tab-request",children:(0,_.jsx)(h.Outlet,{})}),(0,_.jsx)(k.TabPanel,{padding:"0",display:"flex",flexDirection:"column",flex:"1",overflowY:"auto",children:(0,_.jsx)(s6,{})})]})]})})}),(0,_.jsx)(k.Box,{display:"flex",flexDirection:"column",flex:"1",width:"50%",borderLeft:"1px solid",borderColor:"border.default",children:(0,_.jsxs)(k.Tabs,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(s9,{}),(0,_.jsx)(le,{}),(0,_.jsxs)(k.TabList,{children:[(0,_.jsx)(k.Tab,{children:"Response"}),i&&(0,_.jsx)(k.Tab,{children:"UI"})]}),(0,_.jsxs)(k.TabPanels,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",padding:"0","data-testid":"tab-response",children:(0,_.jsx)(lt,{})}),i&&(0,_.jsx)(k.TabPanel,{overflowY:"auto","data-testid":"tab-ui",children:(0,_.jsx)(la,{})})]})]})})]})})},{}),children:[(0,_.jsx)(h.Route,{path:"/handler/".concat(cl.OnRpcRequest),element:(0,_.jsx)(function(){return(0,_.jsx)(ld,{})},{})}),(0,_.jsx)(h.Route,{path:"/handler/".concat(cl.OnCronjob),element:(0,_.jsx)(function(){return(0,_.jsx)(lx,{})},{})}),(0,_.jsx)(h.Route,{path:"/handler/".concat(cl.OnTransaction),element:(0,_.jsx)(function(){return(0,_.jsx)(lP,{})},{})})]})]})));function lL(e){for(var t=1;t1?t-1:0),n=1;n1?t-1:0),n=1;n1?t-1:0),n=1;n2?r-2:0),i=2;i2?i-2:0),a=2;a2?r-2:0),i=2;i1?t-1:0),n=1;n3?t.i-4:t.i:Array.isArray(e)?1:uQ(e)?2:uH(e)?3:0}function uV(e,t){return 2===uY(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function uW(e,t,r){var n=uY(e);2===n?e.set(t,r):3===n?e.add(r):e[t]=r}function uQ(e){return cF&&e instanceof Map}function uH(e){return cL&&e instanceof Set}function uG(e){return e.o||e.t}function uZ(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=c$(e);delete t[cU];for(var r=cJ(t),n=0;n1&&(e.set=e.add=e.clear=e.delete=u0),Object.freeze(e),t&&uK(e,function(e,t){return uX(t,!0)},!0)),e}function u0(){uq(2)}function u1(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function u2(e){var t=cK[e];return t||uq(18,e),t}function u3(e,t){t&&(u2("Patches"),e.u=[],e.s=[],e.v=t)}function u4(e){u6(e),e.p.forEach(u8),e.p=null}function u6(e){e===cO&&(cO=e.l)}function u5(e){return cO={p:[],l:cO,h:e,m:!0,_:0}}function u8(e){var t=e[cU];0===t.i||1===t.i?t.j():t.g=!0}function u7(e,t){t._=t.p.length;var r=t.p[0],n=void 0!==e&&e!==r;return t.h.O||u2("ES5").S(t,e,n),n?(r[cU].P&&(u4(t),uq(4)),u$(e)&&(e=u9(t,e),t.l||ct(t,e)),t.u&&u2("Patches").M(r[cU].t,e,t.u,t.s)):e=u9(t,r,[]),u4(t),t.u&&t.v(t.u,t.s),e!==cz?e:void 0}function u9(e,t,r){if(u1(t))return t;var n=t[cU];if(!n)return uK(t,function(i,o){return ce(e,n,t,i,o,r)},!0),t;if(n.A!==e)return t;if(!n.P)return ct(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=4===n.i||5===n.i?n.o=uZ(n.k):n.o,o=i,a=!1;3===n.i&&(o=new Set(i),i.clear(),a=!0),uK(o,function(t,o){return ce(e,n,i,t,o,r,a)}),ct(e,i,!1),r&&e.u&&u2("Patches").N(n,r,e.u,e.s)}return n.o}function ce(e,t,r,n,i,o,a){if(uJ(i)){var s=u9(e,i,o&&t&&3!==t.i&&!uV(t.R,n)?o.concat(n):void 0);if(uW(r,n,s),!uJ(s))return;e.m=!1}else a&&r.add(i);if(u$(i)&&!u1(i)){if(!e.h.D&&e._<1)return;u9(e,i),t&&t.A.l||ct(e,i)}}function ct(e,t,r){void 0===r&&(r=!1),!e.l&&e.h.D&&e.m&&uX(t,r)}function cr(e,t){var r=e[cU];return(r?uG(r):e)[t]}function cn(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function ci(e){e.P||(e.P=!0,e.l&&ci(e.l))}function co(e){e.o||(e.o=uZ(e.t))}function ca(e,t,r){var n,i,o,a,s,l,u,c=uQ(t)?u2("MapSet").F(t,r):uH(t)?u2("MapSet").T(t,r):e.O?(o=i={i:(n=Array.isArray(t))?1:0,A:r?r.A:cO,P:!1,I:!1,R:{},l:r,t:t,k:null,o:null,j:null,C:!1},a=cY,n&&(o=[i],a=cV),l=(s=Proxy.revocable(o,a)).revoke,u=s.proxy,i.k=u,i.j=l,u):u2("ES5").J(t,r);return(r?r.A:cO).p.push(c),c}function cs(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return uZ(e)}var cl,cu,cc,cp,c_,cd,cf,cm,ch,cy,cg,cb,cv,cx,cD,cS,cE,cT,cw,cA,cC,cM,cN,cj,ck,cI,cO,cP="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),cF="undefined"!=typeof Map,cL="undefined"!=typeof Set,cR="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,cz=cP?Symbol.for("immer-nothing"):((cI={})["immer-nothing"]=!0,cI),cB=cP?Symbol.for("immer-draftable"):"__$immer_draftable",cU=cP?Symbol.for("immer-state"):"__$immer_state",cq=("undefined"!=typeof Symbol&&Symbol.iterator,""+Object.prototype.constructor),cJ="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,c$=Object.getOwnPropertyDescriptors||function(e){var t={};return cJ(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},cK={},cY={get:function(e,t){if(t===cU)return e;var r,n,i=uG(e);if(!uV(i,t))return(n=cn(i,t))?"value"in n?n.value:null===(r=n.get)||void 0===r?void 0:r.call(e.k):void 0;var o=i[t];return e.I||!u$(o)?o:o===cr(e.t,t)?(co(e),e.o[t]=ca(e.A.h,o,e)):o},has:function(e,t){return t in uG(e)},ownKeys:function(e){return Reflect.ownKeys(uG(e))},set:function(e,t,r){var n=cn(uG(e),t);if(null==n?void 0:n.set)return n.set.call(e.k,r),!0;if(!e.P){var i=cr(uG(e),t),o=null==i?void 0:i[cU];if(o&&o.t===r)return e.o[t]=r,e.R[t]=!1,!0;if((r===i?0!==r||1/r==1/i:r!=r&&i!=i)&&(void 0!==r||uV(e.t,t)))return!0;co(e),ci(e)}return e.o[t]===r&&(void 0!==r||t in e.o)||Number.isNaN(r)&&Number.isNaN(e.o[t])||(e.o[t]=r,e.R[t]=!0),!0},deleteProperty:function(e,t){return void 0!==cr(e.t,t)||t in e.t?(e.R[t]=!1,co(e),ci(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=uG(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){uq(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){uq(12)}},cV={};uK(cY,function(e,t){cV[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),cV.deleteProperty=function(e,t){return cV.set.call(this,e,t,void 0)},cV.set=function(e,t,r){return cY.set.call(this,e[0],t,r,e[0])};var cW=new(function(){function e(e){var t=this;this.O=cR,this.D=!0,this.produce=function(e,r,n){if("function"==typeof e&&"function"!=typeof r){var i,o=r;return r=e,function(e){var n=this;void 0===e&&(e=o);for(var i=arguments.length,a=Array(i>1?i-1:0),s=1;s1?n-1:0),o=1;o=0;r--){var r,n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));var i=u2("Patches").$;return uJ(e)?i(e,t):this.produce(e,function(e){return i(e,t)})},e}());cW.produce,cW.produceWithPatches.bind(cW),cW.setAutoFreeze.bind(cW),cW.setUseProxies.bind(cW),cW.applyPatches.bind(cW),cW.createDraft.bind(cW),cW.finishDraft.bind(cW);let cQ=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((e,t)=>((t&=63)<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");function cH(e){var t;return(0,d.isPlainObject)(e)&&(0,d.hasProperty)(e,"type")&&(0,d.hasProperty)(e,"props")&&(0,d.hasProperty)(e,"key")?e:(t=function e(t){switch(t.type){case cx.Panel:return t.children.reduce(function(t,r){return t+e(r)},0);case cx.Row:return e(t.value);case cx.Text:return t.value.length;default:return 0}}(e),(0,d.assert)(t<=5e4,"The text in a Snap UI may not be larger than ".concat(50," kB.")),function e(t){switch(t.type){case cx.Address:return i1(i8,{address:t.value});case cx.Button:return i1(nQ,{name:t.name,variant:function(e){switch(e){case"primary":return"primary";case"secondary":return"destructive";default:return}}(t.variant),type:t.buttonType,children:t.value});case cx.Copyable:return i1(nV,{value:t.value,sensitive:t.sensitive});case cx.Divider:return i1(nY,{});case cx.Form:return i1(nH,{name:t.name,children:au(t.children.map(e))});case cx.Heading:return i1(n$,{children:t.value});case cx.Image:return i1(nW,{src:t.value});case cx.Input:return i1(nG,{label:t.label,error:t.error,children:i1(nZ,{name:t.name,type:t.inputType,value:t.value,placeholder:t.placeholder})});case cx.Panel:return i1(nR,{children:au(t.children.map(e))});case cx.Row:return i1(i7,{label:t.label,variant:t.variant,children:e(t.value)});case cx.Spinner:return i1(i9,{});case cx.Text:var r,n;return i1(nK,{children:au((r=at(t.value,{gfm:!1}),n=[],ae(r,function(e){if("paragraph"===e.type){n.length>0&&n.push("\n\n");var t,r=e.tokens;n.push.apply(n,function(e){if(Array.isArray(e))return ao(e)}(t=r.flatMap(ap))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||as(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}}),n.filter(function(e){return null!==e})))});default:return(0,d.assertExhaustive)(t)}}(e))}function cG(e,t){(0,d.assert)(void 0===e[t],'Duplicate component names are not allowed, found multiple instances of: "'.concat(t,'".'))}function cZ(e,t,r){var n,i,o,a=r?e[r]:e,s=null==a?void 0:a[t.props.name];return"FileInput"===t.type?null!=s?s:null:null!==(o=null!==(i=null!==(n="Checkbox"===t.type?t.props.checked:t.props.value)&&void 0!==n?n:s)&&void 0!==i?i:function(e){var t,r,n;switch(e.type){case"Dropdown":return null===(t=ah(e)[0])||void 0===t?void 0:t.props.value;case"RadioGroup":return null===(r=ah(e)[0])||void 0===r?void 0:r.props.value;case"Selector":return null===(n=ah(e)[0])||void 0===n?void 0:n.props.value;case"Checkbox":return!1;default:return null}}(t))&&void 0!==o?o:null}function cX(e,t){var r={},n=[];return ay(t,function(t,i){var o=n[n.length-1];if(o&&i<=o.depth&&(n.pop(),o=n[n.length-1]),"Form"===t.type){cG(r,t.props.name),n.push({name:t.props.name,depth:i}),r[t.props.name]={};return}if(o&&("Input"===t.type||"Dropdown"===t.type||"RadioGroup"===t.type||"FileInput"===t.type||"Checkbox"===t.type||"Selector"===t.type)){var a=r[o.name];cG(a,t.props.name),a[t.props.name]=cZ(e,t,o.name);return}("Input"===t.type||"Dropdown"===t.type||"RadioGroup"===t.type||"FileInput"===t.type||"Checkbox"===t.type||"Selector"===t.type)&&(cG(r,t.props.name),r[t.props.name]=cZ(e,t))}),r}function c0(e){if(e){var t=e7(e);(0,d.assert)(t<=1e6,"A Snap interface context may not be larger than ".concat(1," MB."))}}function c1(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c2(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function c3(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){c2(o,n,i,a,s,"next",e)}function s(e){c2(o,n,i,a,s,"throw",e)}a(void 0)})}}function c4(e,t,r){if(!t.has(e))throw TypeError("attempted to get private field on non-instance");return r}function c6(e,t){(function(e,t){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function c5(e,t){for(var r=0;r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=-32099&&e<=-32e3)return"Unspecified server error."}return t}function pM(e){return Object.getOwnPropertyNames(e).reduce((t,r)=>{let n=e[r];return(0,d.isValidJson)(n)&&(t[r]=n),t},{})}pC(pw.rpc.internal);var pN=r(7847),pj=r.n(pN),pk=class extends Error{constructor(e,t,r){var n=(...e)=>{super(...e)};if(!Number.isInteger(e))throw Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw Error('"message" must be a non-empty string.');(function(e){return(0,d.isObject)(e)&&(0,d.hasProperty)(e,"cause")&&(0,d.isObject)(e.cause)})(r)?(n(t,{cause:r.cause}),(0,d.hasProperty)(this,"cause")||Object.assign(this,{cause:r.cause})):n(t),void 0!==r&&(this.data=r),this.code=e}serialize(){var e;let t={code:this.code,message:this.message};return void 0!==this.data&&(t.data=this.data,(0,d.isPlainObject)(this.data)&&(t.data.cause=Array.isArray(e=this.data.cause)?e.map(e=>(0,d.isValidJson)(e)?e:(0,d.isObject)(e)?pM(e):null):(0,d.isObject)(e)?pM(e):(0,d.isValidJson)(e)?e:null)),this.stack&&(t.stack=this.stack),t}toString(){return pj()(this.serialize(),pO,2)}},pI=class extends pk{constructor(e,t,r){if(!function(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}(e))throw Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,r)}};function pO(e,t){if("[Circular]"!==t)return t}var pP={parse:e=>pL(pw.rpc.parse,e),invalidRequest:e=>pL(pw.rpc.invalidRequest,e),invalidParams:e=>pL(pw.rpc.invalidParams,e),methodNotFound:e=>pL(pw.rpc.methodNotFound,e),internal:e=>pL(pw.rpc.internal,e),server:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Ethereum RPC Server errors must provide single object argument.");let{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw Error('"code" must be an integer such that: -32099 <= code <= -32005');return pL(t,e)},invalidInput:e=>pL(pw.rpc.invalidInput,e),resourceNotFound:e=>pL(pw.rpc.resourceNotFound,e),resourceUnavailable:e=>pL(pw.rpc.resourceUnavailable,e),transactionRejected:e=>pL(pw.rpc.transactionRejected,e),methodNotSupported:e=>pL(pw.rpc.methodNotSupported,e),limitExceeded:e=>pL(pw.rpc.limitExceeded,e)},pF={userRejectedRequest:e=>pR(pw.provider.userRejectedRequest,e),unauthorized:e=>pR(pw.provider.unauthorized,e),unsupportedMethod:e=>pR(pw.provider.unsupportedMethod,e),disconnected:e=>pR(pw.provider.disconnected,e),chainDisconnected:e=>pR(pw.provider.chainDisconnected,e),custom:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Ethereum Provider custom errors must provide single object argument.");let{code:t,message:r,data:n}=e;if(!r||"string"!=typeof r)throw Error('"message" must be a nonempty string');return new pI(t,r,n)}};function pL(e,t){let[r,n]=pz(t);return new pk(e,r??pC(e),n)}function pR(e,t){let[r,n]=pz(t);return new pI(e,r??pC(e),n)}function pz(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){let{message:t,data:r}=e;if(t&&"string"!=typeof t)throw Error("Must specify string message.");return[t??void 0,r]}}return[]}function pB(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r1?r-1:0),i=1;i=0,TypeError("Can't start a timer with negative time")),this.state={value:"stopped",remaining:e}}return e=[{key:"status",get:function(){return this.state.value}},{key:"remaining",get:function(){return this.state.remaining}},{key:"cancel",value:function(){(0,d.assert)("paused"===this.status||"running"===this.status,Error("Tried to cancel a not running Timer")),this.onFinish(!1)}},{key:"finish",value:function(){(0,d.assert)("finished"!==this.status,Error("Tried to finish a finished Timer.")),this.onFinish(!0)}},{key:"pause",value:function(){(0,d.assert)("running"===this.state.value,Error("Tried to pause a not running Timer"));var e=this.state,t=e.callback,r=e.start,n=e.timeout,i=e.remaining;void 0!==n&&clearTimeout(n),this.state={value:"paused",callback:t,remaining:i-(Date.now()-r)}}},{key:"start",value:function(e){(0,d.assert)("stopped"===this.state.value,Error("Tried to start an already running Timer"));var t=this.state.remaining;this.state={value:"paused",remaining:t,callback:e},this.resume()}},{key:"resume",value:function(){var e,t=this;(0,d.assert)("paused"===this.state.value,Error("Tried to resume not paused Timer"));var r=this.state,n=r.remaining,i=r.callback,o=Date.now();n!==Number.POSITIVE_INFINITY&&(e=setTimeout(function(){return t.onFinish(!0)},n)),this.state={value:"running",callback:i,remaining:n,start:o,timeout:e}}},{key:"onFinish",value:function(e){(0,d.assert)("running"===this.state.value||"paused"===this.state.value),"running"===this.state.value&&void 0!==this.state.timeout&&clearTimeout(this.state.timeout);var t=this.state,r=t.callback,n=t.remaining;this.state={value:"finished",remaining:"running"===this.state.value?n-(Date.now()-this.state.start):n},e&&r()}}],p$(r.prototype,e),t&&p$(r,t),r}();function pY(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function pV(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){pY(o,n,i,a,s,"next",e)}function s(e){pY(o,n,i,a,s,"throw",e)}a(void 0)})}}function pW(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e.length)&&(t=e.length);for(var r=0,n=Array(t);r=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}(t,["maxRequestTime"]));return a?(n=function(e){for(var t=1;t0),{caveats:t}})),_7(i,_B.targetName,_M(function(e){return{caveats:[{type:cc.KeyringOrigin,value:e}]}})),_7(i,_1.targetName,_M(function(e){return!e||!(0,d.isObject)(e)||(0,d.isObject)(e)&&0===Object.keys(e).length?{caveats:null}:{caveats:[{type:cc.SignatureOrigin,value:(0,d.hasProperty)(e,"allowSignatureOrigin")&&e.allowSignatureOrigin}]}})),_7(i,_J.targetName,_C),_7(i,_L.targetName,_C),i);_7(o={},cl.OnRpcRequest,_Z.targetName),_7(o,cl.OnTransaction,_4.targetName),_7(o,cl.OnCronjob,_k.targetName),_7(o,cl.OnNameLookup,_Y.targetName),_7(o,cl.OnInstall,_J.targetName),_7(o,cl.OnUpdate,_J.targetName),_7(o,cl.OnKeyringRequest,_B.targetName),_7(o,cl.OnHomePage,_L.targetName),_7(o,cl.OnSignature,_1.targetName),_7(o,cl.OnUserInput,null);let dr=BigInt(4294967296-1),dn=BigInt(32),di=(e,t,r)=>e<>>32-r,da=(e,t,r)=>t<>>32-r,ds=(e,t,r)=>t<>>64-r,dl=(e,t,r)=>e<>>64-r,du=[],dc=[],dp=[],d_=BigInt(0),dd=BigInt(1),df=BigInt(2),dm=BigInt(7),dh=BigInt(256),dy=BigInt(113);for(let e=0,t=dd,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],du.push(2*(5*n+r)),dc.push((e+1)*(e+2)/2%64);let i=d_;for(let e=0;e<7;e++)(t=(t<>dm)*dy)%dh)&df&&(i^=dd<<(dd<>dn&dr)}:{h:0|Number(e>>dn&dr),l:0|Number(e&dr)}}(e[i],t);[r[i],n[i]]=[o,a]}return[r,n]}(dp,!0),dv=(e,t,r)=>r>32?ds(e,t,r):di(e,t,r),dx=(e,t,r)=>r>32?dl(e,t,r):da(e,t,r);class dD extends ev{constructor(e,t,r,n=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,eu(r),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ed(this.state)}keccak(){eh||eg(this.state32),function(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let n=(t+8)%10,i=(t+2)%10,o=r[i],a=r[i+1],s=dv(o,a,1)^r[n],l=dx(o,a,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=s,e[t+r+1]^=l}let t=e[2],i=e[3];for(let r=0;r<24;r++){let n=dc[r],o=dv(t,i,n),a=dx(t,i,n),s=du[r];t=e[s],i=e[s+1],e[s]=o,e[s+1]=a}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=dg[n],e[1]^=db[n]}r.fill(0)}(this.state32,this.rounds),eh||eg(this.state32),this.posOut=0,this.pos=0}update(e){ep(this);let{blockLen:t,state:r}=this;e=eb(e);let n=e.length;for(let i=0;i=r&&this.keccak();let o=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return eu(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(e_(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return e||(e=new dD(t,r,n,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}let dS=ex(()=>new dD(136,1,32));function dE(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]>>0;t.push("bip32:".concat(i-2147483648,"'"))}return t}(dS((0,d.concatBytes)([a,dS(s)]))),[4,e9.SLIP10Node.fromDerivationPath({derivationPath:[i,"bip32:".concat(o)].concat(dA(l)),curve:"secp256k1"})];case 1:return u=c.sent().privateKey,(0,d.assert)(u,"Failed to derive the entropy."),[2,(0,d.add0x)(u)]}})})).apply(this,arguments)}function dj(e){return dk.apply(this,arguments)}function dk(){return(dk=dw(function(e){var t,r,n,i;return dC(this,function(o){switch(o.label){case 0:return t=e.curve,r=e.secretRecoveryPhrase,n=e.path,i=function(e){switch(e){case"secp256k1":return"bip32";case"ed25519":return"slip10";case"ed25519Bip32":return"cip3";default:return(0,d.assertExhaustive)(e)}}(t),[4,e9.SLIP10Node.fromDerivationPath({curve:t,derivationPath:[r].concat(dA(n.slice(1).map(function(e){return"".concat(i,":").concat(e)})))})];case 1:return[2,o.sent()]}})})).apply(this,arguments)}function dI(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}var dO="snap_getBip32Entropy",dP=Object.freeze({targetName:dO,specificationBuilder:function(e){var t,r,n,i,o=e.methodHooks;return{permissionType:ts.PermissionType.RestrictedMethod,targetName:dO,allowedCaveats:[cc.PermittedDerivationPaths],methodImplementation:(n=o.getMnemonic,i=o.getUnlockPromise,t=function(e){var t,r;return function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]2147483647)throw pP.invalidParams({message:'Invalid "coinType" parameter. Coin type must be a non-negative integer.'});if(tL.includes(e.coinType))throw pP.invalidParams({message:"Coin type ".concat(e.coinType," is forbidden.")})}var dG=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}({},cc.PermittedCoinTypes,Object.freeze({type:cc.PermittedCoinTypes,decorator:function(e,t){var r,n;return r=function(r){var n;return function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]2&&void 0!==arguments[2]?arguments[2]:104857600;if(!(0,d.isObject)(e))throw pP.invalidParams({message:"Expected params to be a single object."});var i=e.operation,o=e.newState,a=e.encrypted;if(!i||"string"!=typeof i||!Object.values(u).includes(i))throw pP.invalidParams({message:'Must specify a valid manage state "operation".'});if(void 0!==a&&"boolean"!=typeof a)throw pP.invalidParams({message:'"encrypted" parameter must be a boolean if specified.'});if(i===u.UpdateState){if(!(0,d.isObject)(o))throw pP.invalidParams({message:"Invalid ".concat(t,' "updateState" parameter: The new state must be a plain object.'),data:{receivedNewState:void 0===o?"undefined":o}});try{r=(0,d.getJsonSize)(o)}catch(e){throw pP.invalidParams({message:"Invalid ".concat(t,' "updateState" parameter: The new state must be JSON serializable.'),data:{receivedNewState:void 0===o?"undefined":o}})}if(r>n)throw pP.invalidParams({message:"Invalid ".concat(t,' "updateState" parameter: The new state must not exceed ').concat(n," bytes in size."),data:{receivedNewState:void 0===o?"undefined":o}})}return e}(r,s)).encrypted)||void 0===p||p)&&c.operation!==u.ClearState))return[3,2];return[4,n(!0)];case 1:f.sent(),f.label=2;case 2:switch(c.operation){case u.ClearState:return[3,3];case u.GetState:return[3,4];case u.UpdateState:return[3,6]}return[3,8];case 3:return i(l,_),[2,null];case 4:return[4,o(l,_)];case 5:return[2,f.sent()];case 6:return[4,a(l,c.newState,_)];case 7:return f.sent(),[2,null];case 8:throw pP.invalidParams("Invalid ".concat(s,' operation: "').concat(c.operation,'"'));case 9:return[2]}})},r=function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(e){fK(o,n,i,a,s,"next",e)}function s(e){fK(o,n,i,a,s,"throw",e)}a(void 0)})},function(e){return r.apply(this,arguments)}),subjectTypes:[ts.SubjectType.Snap]}},methodHooks:{getUnlockPromise:!0,clearSnapState:!0,getSnapState:!0,updateSnapState:!0}});function fW(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}var fQ="snap_notify",fH=(0,H.object)({type:tT(cN.Native),message:(0,H.string)()}),fG=tw([(0,H.object)({type:tT(cN.InApp),message:(0,H.string)()}),(0,H.object)({type:tT(cN.InApp),message:(0,H.string)(),content:iH,title:(0,H.string)()}),(0,H.object)({type:tT(cN.InApp),message:(0,H.string)(),content:iH,title:(0,H.string)(),footerLink:(0,H.object)({href:(0,H.string)(),text:(0,H.string)()})}),fH]),fZ=Object.freeze({targetName:fQ,specificationBuilder:function(e){var t,r,n,i,o,a,s,l,u=e.allowedCaveats,c=e.methodHooks;return{permissionType:ts.PermissionType.RestrictedMethod,targetName:fQ,allowedCaveats:void 0===u?null:u,methodImplementation:(n=c.showNativeNotification,i=c.showInAppNotification,o=c.isOnPhishingList,a=c.maybeUpdatePhishingList,s=c.createInterface,l=c.getSnap,t=function(e){var t,r,u,c;return function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=50))throw pP.invalidParams({message:'Must specify a non-empty string "message" less than 50 characters long.'});if(n===cN.InApp&&(o||i.length>=500))throw pP.invalidParams({message:'Must specify a non-empty string "message" less than 500 characters long.'});try{var a=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];(0,d.assert)(t.schema,"Expected a struct with a schema. Make sure to use `union` from `@metamask/snaps-sdk`."),(0,d.assert)(t.schema.length>0,"Expected a non-empty array of structs.");var i=t.schema.map(function(e){return e.schema[r]}),o=(0,H.type)(tj({},r,tw(i))),a=tk((0,H.validate)(e,o,{coerce:n}),1)[0];if(a)throw Error(tO(o,a.failures()[0],!1));var s=t.schema.filter(function(t){return(0,H.is)(e[r],t.schema[r])});(0,d.assert)(s.length>0,"Expected a struct to match the value.");var l=s.map(function(t){return(0,H.validate)(e,t,{coerce:n})}),u=l.find(function(e){return!tk(e,1)[0]});if(u)return u[1];throw(0,d.assert)(l[0][0],"Expected at least one error."),Error(tO(t,l.reduce(function(e,t){var r=tk(t,1)[0];return((0,d.assert)(r,"Expected an error."),r.failures().lengthe.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]1&&void 0!==a[1]?a[1]:p.Base64,[4,uT(nc)];case 1:if(n=s.sent(),i=t4(e),!(o=null===(r=n.find(function(e){return e.path===i}))||void 0===r?void 0:r.toString("base64")))return[2,null];return[4,uD(mz,o,t)];case 2:return[2,s.sent()]}})}function mQ(e,t){return mq(this,function(r){switch(r.label){case 0:return[4,uT(r9)];case 1:return[4,uD([r.sent(),"createInterface"],e,t)];case 2:return[2,r.sent()]}})}function mH(e,t){return mq(this,function(r){switch(r.label){case 0:return[4,uT(r9)];case 1:return[4,uD([r.sent(),"getInterface"],e,t)];case 2:return[2,r.sent()]}})}function mG(e,t,r){return mq(this,function(n){switch(n.label){case 0:return[4,uT(r9)];case 1:return[4,uD([n.sent(),"updateInterface"],e,t,r)];case 2:return n.sent(),[4,uD(mH,e,t)];case 3:return[4,ub(rG(mU({id:t},n.sent())))];case 4:return n.sent(),[2]}})}function mZ(e,t){return mq(this,function(r){switch(r.label){case 0:return[4,uT(r9)];case 1:return[4,uD([r.sent(),"getInterface"],e,t)];case 2:return[2,r.sent().state]}})}function mX(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function m0(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){mX(o,n,i,a,s,"next",e)}function s(e){mX(o,n,i,a,s,"throw",e)}a(void 0)})}}function m1(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]2?r-2:0),i=2;i0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]1&&void 0!==arguments[1]?arguments[1]:{};(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,r),hv(this,"cache",new Map),hv(this,"validatedManifest",void 0),hv(this,"url",void 0),hv(this,"fetchFn",void 0),hv(this,"fetchOptions",void 0),(0,d.assertStruct)(e.toString(),e3,"Invalid Snap Id: "),this.fetchFn=null!==(t=n.fetch)&&void 0!==t?t:globalThis.fetch.bind(void 0),this.fetchOptions=n.fetchOptions,this.url=e}return e=[{key:"manifest",value:function(){var e=this;return hg(function(){var t,r,n,i,o;return hx(this,function(a){switch(a.label){case 0:if(e.validatedManifest)return[2,e.validatedManifest.clone()];return t=new URL(cp.Manifest,e.url).toString(),[4,e.fetchFn(t,e.fetchOptions)];case 1:if(!(r=a.sent()).ok)throw Error('Failed to fetch "'.concat(t,'". Status code: ').concat(r.status,"."));return[4,r.text()];case 2:return i=e8(n=a.sent()),o=new eP({value:n,result:t3(i),path:cp.Manifest,data:{canonicalPath:t}}),e.validatedManifest=o,[2,e.manifest()]}})})()}},{key:"fetch",value:function(e){var t=this;return hg(function(){var r,n,i,o,a,s,l,u,c,p,_;return hx(this,function(f){switch(f.label){case 0:if(r=t4(e),!(void 0!==(n=t.cache.get(r))))return[3,2];return i=n.file,o=n.contents,s=Uint8Array.bind,[4,o.arrayBuffer()];case 1:return a=new(s.apply(Uint8Array,[void 0,f.sent()])),(l=i.clone()).value=a,[2,l];case 2:return u=t.toCanonical(r).toString(),[4,t.fetchFn(u,t.fetchOptions)];case 3:if(!(c=f.sent()).ok)throw Error('Failed to fetch "'.concat(u,'". Status code: ').concat(c.status,"."));return p=new eP({value:"",path:r,data:{canonicalPath:u}}),[4,c.blob()];case 4:return _=f.sent(),(0,d.assert)(!t.cache.has(r),"Corrupted cache, multiple files with same path."),t.cache.set(r,{file:p,contents:_}),[2,t.fetch(r)]}})})()}},{key:"root",get:function(){return new URL(this.url)}},{key:"toCanonical",value:function(e){return(0,d.assert)(!e.startsWith("/"),"Tried to parse absolute path."),new URL(e,this.url)}}],hb(r.prototype,e),t&&hb(r,t),r}();function hS(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function hE(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){hS(o,n,i,a,s,"next",e)}function s(e){hS(o,n,i,a,s,"throw",e)}a(void 0)})}}function hT(e,t,r){if(!t.has(e))throw TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function hw(e,t){var r=hT(e,t,"get");return r.get?r.get.call(e):r.value}function hA(e,t){for(var r=0;r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]1&&void 0!==arguments[1]?arguments[1]:{};(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,r),function(e,t){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object")}(this,hM),hM.set(this,{writable:!0,value:void 0}),(0,d.assertStruct)(e.toString(),e1,"Invalid Snap Id"),(0,d.assert)(void 0===o.fetchOptions,"Currently adding fetch options to local: is unsupported."),i=new hD(new URL(e.toString().slice(c_.local.length)),(t=function(e){for(var t=1;t0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0?[2,r.join("\n")]:[2,!0]})});return function(t,r){return e.apply(this,arguments)}}()},{name:"Checksum",manifestName:"source.shasum",validator:function(){var e=hY(function(e,t){var r,n,i,o,a,s,l;return hW(this,function(u){switch(u.label){case 0:if(r=t.sourceCode,n=t.icon,i=t.auxiliaryFiles,o=t.localizationFiles,!e)return[3,2];return s=null===(a=e.result)||void 0===a?void 0:a.source.shasum,[4,function(e){return eZ.apply(this,arguments)}({manifest:e,sourceCode:r,svgIcon:n,auxiliaryFiles:i,localizationFiles:o})];case 1:if(l=u.sent(),s!==l)return[2,'Checksum mismatch - expected "'.concat(l,'" got "').concat(s,'"')];u.label=2;case 2:return[2,!0]}})});return function(t,r){return e.apply(this,arguments)}}()},{name:"Bundle",manifestName:"filePath",validator:function(){var e=hY(function(e,t){var r,n,i,o,a,s,l;return hW(this,function(u){return(r=t.sourceCode,l=hV(t2.schema.source.schema.location.schema.npm.schema.filePath.validate(null===(s=e)||void 0===s?void 0:null===(a=s.result)||void 0===a?void 0:null===(o=a.source)||void 0===o?void 0:null===(i=o.location)||void 0===i?void 0:null===(n=i.npm)||void 0===n?void 0:n.filePath),1)[0])?[2,l.message]:r?[2,!0]:[2,"Unable to load bundle."]})});return function(t,r){return e.apply(this,arguments)}}()}];function hH(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]${e}`}em(e){return`${e}`}codespan(e){return`${e}`}br(){return"
"}del(e){return`${e}`}link(e,t,r){let n=o_(e);if(null===n)return r;let i='
"}image(e,t,r){let n=o_(e);if(null===n)return r;let i=`${r}"colon"===(t=t.toLowerCase())?":":"#"===t.charAt(0)?"x"===t.charAt(1)?String.fromCharCode(parseInt(t.substring(2),16)):String.fromCharCode(+t.substring(1)):""));continue;case"code":r+=this.renderer.code(i.text,i.lang,!!i.escaped);continue;case"table":{let e="",t="";for(let e=0;e0&&"paragraph"===t.tokens[0].type?(t.tokens[0].text=e+" "+t.tokens[0].text,t.tokens[0].tokens&&t.tokens[0].tokens.length>0&&"text"===t.tokens[0].tokens[0].type&&(t.tokens[0].tokens[0].text=e+" "+t.tokens[0].tokens[0].text)):t.tokens.unshift({type:"text",text:e+" "}):s+=e+" "}s+=this.parse(t.tokens,n),o+=this.renderer.listitem(s,a,!!r)}r+=this.renderer.list(o,e,t);continue}case"html":r+=this.renderer.html(i.text,i.block);continue;case"paragraph":r+=this.renderer.paragraph(this.parseInline(i.tokens));continue;case"text":{let o=i,a=o.tokens?this.parseInline(o.tokens):o.text;for(;n+1{let i=e[n].flat(1/0);r=r.concat(this.walkTokens(i,t))}):e.tokens&&(r=r.concat(this.walkTokens(e.tokens,t)))}}return r}use(...e){let t=this.defaults.extensions||{renderers:{},childTokens:{}};return e.forEach(e=>{let r={...e};if(r.async=this.defaults.async||r.async||!1,e.extensions&&(e.extensions.forEach(e=>{if(!e.name)throw Error("extension name required");if("renderer"in e){let r=t.renderers[e.name];r?t.renderers[e.name]=function(...t){let n=e.renderer.apply(this,t);return!1===n&&(n=r.apply(this,t)),n}:t.renderers[e.name]=e.renderer}if("tokenizer"in e){if(!e.level||"block"!==e.level&&"inline"!==e.level)throw Error("extension level must be 'block' or 'inline'");let r=t[e.level];r?r.unshift(e.tokenizer):t[e.level]=[e.tokenizer],e.start&&("block"===e.level?t.startBlock?t.startBlock.push(e.start):t.startBlock=[e.start]:"inline"===e.level&&(t.startInline?t.startInline.push(e.start):t.startInline=[e.start]))}"childTokens"in e&&e.childTokens&&(t.childTokens[e.name]=e.childTokens)}),r.extensions=t),e.renderer){let t=this.defaults.renderer||new o3(this.defaults);for(let r in e.renderer){if(!(r in t))throw Error(`renderer '${r}' does not exist`);if("options"===r)continue;let n=e.renderer[r],i=t[r];t[r]=(...e)=>{let r=n.apply(t,e);return!1===r&&(r=i.apply(t,e)),r||""}}r.renderer=t}if(e.tokenizer){let t=this.defaults.tokenizer||new oy(this.defaults);for(let r in e.tokenizer){if(!(r in t))throw Error(`tokenizer '${r}' does not exist`);if(["options","rules","lexer"].includes(r))continue;let n=e.tokenizer[r],i=t[r];t[r]=(...e)=>{let r=n.apply(t,e);return!1===r&&(r=i.apply(t,e)),r}}r.tokenizer=t}if(e.hooks){let t=this.defaults.hooks||new o5;for(let r in e.hooks){if(!(r in t))throw Error(`hook '${r}' does not exist`);if("options"===r)continue;let n=e.hooks[r],i=t[r];o5.passThroughHooks.has(r)?t[r]=e=>{if(this.defaults.async)return Promise.resolve(n.call(t,e)).then(e=>i.call(t,e));let r=n.call(t,e);return i.call(t,r)}:t[r]=(...e)=>{let r=n.apply(t,e);return!1===r&&(r=i.apply(t,e)),r}}r.hooks=t}if(e.walkTokens){let t=this.defaults.walkTokens,n=e.walkTokens;r.walkTokens=function(e){let r=[];return r.push(n.call(this,e)),t&&(r=r.concat(t.call(this,e))),r}}this.defaults={...this.defaults,...r}}),this}setOptions(e){return this.defaults={...this.defaults,...e},this}lexer(e,t){return o2.lex(e,t??this.defaults)}parser(e,t){return o6.parse(e,t??this.defaults)}#e(e,t){return(r,n)=>{let i={...n},o={...this.defaults,...i};!0===this.defaults.async&&!1===i.async&&(o.silent||console.warn("marked(): The async option was set to true by an extension. The async: false option sent to parse will be ignored."),o.async=!0);let a=this.#t(!!o.silent,!!o.async);if(null==r)return a(Error("marked(): input parameter is undefined or null"));if("string"!=typeof r)return a(Error("marked(): input parameter is of type "+Object.prototype.toString.call(r)+", string expected"));if(o.hooks&&(o.hooks.options=o),o.async)return Promise.resolve(o.hooks?o.hooks.preprocess(r):r).then(t=>e(t,o)).then(e=>o.hooks?o.hooks.processAllTokens(e):e).then(e=>o.walkTokens?Promise.all(this.walkTokens(e,o.walkTokens)).then(()=>e):e).then(e=>t(e,o)).then(e=>o.hooks?o.hooks.postprocess(e):e).catch(a);try{o.hooks&&(r=o.hooks.preprocess(r));let n=e(r,o);o.hooks&&(n=o.hooks.processAllTokens(n)),o.walkTokens&&this.walkTokens(n,o.walkTokens);let i=t(n,o);return o.hooks&&(i=o.hooks.postprocess(i)),i}catch(e){return a(e)}}}#t(e,t){return r=>{if(r.message+="\nPlease report this to https://github.com/markedjs/marked.",e){let e="

An error occurred:

"+ol(r.message+"",!0)+"
";return t?Promise.resolve(e):e}if(t)return Promise.reject(r);throw r}}}let o7=new o8;function o9(e,t){return o7.parse(e,t)}o9.options=o9.setOptions=function(e){return o7.setOptions(e),o9.defaults=o7.defaults,ot=o9.defaults,o9},o9.getDefaults=oe,o9.defaults=ot,o9.use=function(...e){return o7.use(...e),o9.defaults=o7.defaults,ot=o9.defaults,o9},o9.walkTokens=function(e,t){return o7.walkTokens(e,t)},o9.parseInline=o7.parseInline,o9.Parser=o6,o9.parser=o6.parse,o9.Renderer=o3,o9.TextRenderer=o4,o9.Lexer=o2,o9.lexer=o2.lex,o9.Tokenizer=oy,o9.Hooks=o5,o9.parse=o9,o9.options,o9.setOptions,o9.use;let ae=o9.walkTokens;o9.parseInline,o6.parse;let at=o2.lex;function ar(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);r0?au(e.tokens.flatMap(ap)):e.href});case"text":return e.text;case"strong":return i1(i6,{children:ac(e.tokens)});case"em":return i1(i5,{children:ac(e.tokens)});default:return null}}function a_(e,t,r){try{var n=new URL(e);if((0,d.assert)(al.includes(n.protocol),"Protocol must be one of: ".concat(al.join(", "),".")),"metamask:"===n.protocol){var i=function(e){var t=new URL(e),r=t.hostname,n=t.pathname,i=t.protocol;if("metamask:"!==i)throw Error('Unable to parse URL. Expected the protocol to be "metamask:", but received "'.concat(i,'".'));switch(r){case"client":return(0,d.assert)(an.includes(n),'Unable to navigate to "'.concat(n,'". The provided path is not allowed.')),{authority:r,path:n};case"snap":return function(e){var t,r="Invalid MetaMask url:",n=e5(e.slice(1)),i=e.slice(1).startsWith("npm:")?"npm:":"local:",o=n.startsWith("@"),a=n.split("/"),s="/".concat(a[a.length-1]);if("local:"===i){var l,u=function(e){if(Array.isArray(e))return e}(l=a.slice(0,-1))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(l)||function(e,t){if(e){if("string"==typeof e)return ar(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ar(e,t)}}(l)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),c=u[0],p=u.slice(2);t="".concat(c,"//").concat(p.join("/")),(0,d.assert)(ai.includes(s),"".concat(r," invalid snap path."))}else t=o?"".concat(a[0],"/").concat(a[1]):a[0],(0,d.assert)(o?3===a.length&&ai.includes(s):2===a.length&&ai.includes(s),"".concat(r," invalid snap path."));var _="".concat(i).concat(t);return(0,d.assertStruct)(_,e4,"Invalid snap ID"),{authority:"snap",snapId:_,path:s}}(n);default:throw Error('Expected "metamask:" URL to start with "client" or "snap", but received "'.concat(r,'".'))}}(e);i.snapId&&(0,d.assert)(r(i.snapId),"The Snap being navigated to is not installed.")}else if("mailto:"===n.protocol){var o=n.pathname.split(","),a=!0,s=!1,l=void 0;try{for(var u,c=o[Symbol.iterator]();!(a=(u=c.next()).done);a=!0){var p=u.value.split("@")[1];(0,d.assert)(!t(p),"The specified URL is not allowed.")}}catch(e){s=!0,l=e}finally{try{a||null==c.return||c.return()}finally{if(s)throw l}}return}(0,d.assert)(!t(n.hostname),"The specified URL is not allowed.")}catch(e){throw Error("Invalid URL: ".concat((null==e?void 0:e.code)==="ERR_ASSERTION"?e.message:"Unable to parse URL."))}}function ad(e,t,r){var n=(s=at(e,{gfm:!1}),l=[],ae(s,function(e){"link"===e.type&&l.push(e)}),l),i=!0,o=!1,a=void 0;try{for(var s,l,u,c=n[Symbol.iterator]();!(i=(u=c.next()).done);i=!0){var p=u.value;a_(p.href,t,r)}}catch(e){o=!0,a=e}finally{try{i||null==c.return||c.return()}finally{if(o)throw a}}}function af(e){return(0,d.hasProperty)(e.props,"children")}function am(e){return!!e&&!0!==e}function ah(e){if(af(e)){if(Array.isArray(e.props.children))return e.props.children.filter(am).flat(1/0);if(e.props.children)return[e.props.children]}return[]}function ay(e,t){var r=arguments.length>2&&void 0!==arguments[2]?arguments[2]:0;if(Array.isArray(e)){var n=!0,i=!1,o=void 0;try{for(var a,s=e[Symbol.iterator]();!(n=(a=s.next()).done);n=!0){var l=a.value,u=ay(l,t,r);if(void 0!==u)return u}}catch(e){i=!0,o=e}finally{try{n||null==s.return||s.return()}finally{if(i)throw o}}return}var c=t(e,r);if(void 0!==c)return c;if((0,d.hasProperty)(e,"props")&&(0,d.isPlainObject)(e.props)&&(0,d.hasProperty)(e.props,"children")){var p=ah(e),_=!0,f=!1,m=void 0;try{for(var h,y=p[Symbol.iterator]();!(_=(h=y.next()).done);_=!0){var g=h.value;if((0,d.isPlainObject)(g)){var b=ay(g,t,r+1);if(void 0!==b)return b}}}catch(e){f=!0,m=e}finally{try{_||null==y.return||y.return()}finally{if(f)throw m}}}}function ag(e){return Object.entries(e).filter(function(e){return"children"!==aa(e,1)[0]}).sort(function(e,t){var r=aa(e,1)[0],n=aa(t,1)[0];return r.localeCompare(n)}).map(function(e){var t=aa(e,2),r=t[0],n=t[1];return" ".concat(r,"=").concat("string"==typeof n?'"'.concat(n,'"'):"{".concat(JSON.stringify(n),"}"))}).join("")}var ab=r(8261),av=r.n(ab),ax=r(9691),aD=r.n(ax);function aS(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r1?"move":"default",children:[(0,_.jsx)(P,{icon:r.data.type.toLowerCase(),width:"16px"}),(0,_.jsx)(k.Text,{fontWeight:"500",fontSize:"sm",textTransform:"capitalize",color:"text.muted",display:"inline-block",minWidth:"65px",children:r.data.type}),i,Number(r.id)>=2&&(0,_.jsx)(P,{icon:"cross",width:"11px",marginX:"0.5",marginLeft:"auto",cursor:"pointer",onClick:function(){null==o||o(r)}})]})};function aN(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function aj(e){for(var t=1;t2&&void 0!==arguments[2]?arguments[2]:[];return function(){for(var n=arguments.length,i=Array(n),o=0;oe.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);r ul":{display:"flex",flexDirection:"column",flex:1,marginY:"4","& > li":{display:"flex",flexDirection:"column",flex:1,marginTop:"0"}},ul:{listStyleType:"none"},li:{marginTop:"2"}},children:(0,_.jsx)(n6.Tree,{ref:n,tree:t,rootId:0,render:function(e,r){var n=r.depth,a=r.isDragging;return t.length<=1?(0,_.jsx)(aY,{}):(0,_.jsx)(aK,{node:e,depth:n,onChange:i,onClose:o,isDragging:a})},insertDroppableFirst:!1,canDrag:function(e){return!!e&&Number(e.id)>=2},canDrop:function(e,t){var r=t.dropTarget,n=t.dropTargetId,i=t.dragSource;return!!n&&null!=i&&!!i.data&&function(e,t){if(!e||!t)return!1;switch(e.type){case"Box":return aE(t);case"Form":return aT(t);case"Field":return aw(t);default:return!1}}(null==r?void 0:r.data,null==i?void 0:i.data)&&(null==r?void 0:r.droppable)&&Number(n)>0},onDrop:function(e){r(e)},initialOpen:!0,sort:!1,extraAcceptTypes:["template"],placeholderRender:function(){return(0,_.jsx)(k.Box,{width:"100%",height:"20px"})}})})},aG=function(e){var t=e.snapName,r=F(nn),n=r&&new Blob([r.value],{type:"image/svg+xml"}),i=n&&URL.createObjectURL(n);return(0,_.jsxs)(k.Box,{position:"relative",children:[(0,_.jsx)(k.Avatar,{src:i,name:t.slice(0,1).toUpperCase(),fontSize:"md",background:"background.alternative",color:"text.alternative",size:"sm",margin:"1"}),(0,_.jsx)(P,{icon:"snap",width:"16px",height:"16px",position:"absolute",bottom:"0px",right:"0px"})]})},aZ=function(e){var t=e.snapName,r=e.snapId;return(0,_.jsxs)(k.Flex,{gap:"2",marginX:"4",marginY:"4",border:"1px solid",borderColor:"border.default",borderRadius:"32px",padding:"1",alignItems:"center",children:[(0,_.jsx)(aG,{snapName:t}),(0,_.jsxs)(k.Flex,{direction:"column",justify:"center",children:[(0,_.jsx)(k.Text,{fontSize:"sm",lineHeight:"157%",fontFamily:"custom",children:t}),(0,_.jsx)(k.Text,{fontSize:"xs",lineHeight:"167%",fontFamily:"custom",color:"text.alternative",children:r})]})]})},aX=function(e){var t=e.snapName,r=e.snapId,n=e.children,i=e.showAuthorship;return(0,_.jsxs)(k.Flex,{direction:"column",boxShadow:"lg",maxWidth:"360px",height:"600px",paddingY:"4",overflowY:"scroll",children:[(void 0===i||i)&&(0,_.jsx)(aZ,{snapName:t,snapId:r}),n]})};!function(e){e.Content="content",e.Error="error",e.Insights="insights"}(cw||(cw={}));var a0=function(e,t){switch(e){case cw.Insights:return"Insights from ".concat(t);case cw.Error:return"Error from ".concat(t);default:return"Content from ".concat(t)}},a1=function(e){var t=e.type,r=e.snapName,n=e.children,i=t===cw.Error;return(0,_.jsxs)(k.Box,{border:"1px solid",borderColor:"border.default",borderRadius:"md",backgroundColor:i?"error.muted":void 0,children:[(0,_.jsxs)(k.Flex,{direction:"row",alignItems:"center",padding:"1.5",borderBottom:"1px solid",borderColor:"border.default",children:[(0,_.jsx)(P,{icon:i?"snapError":"snap",width:"16px",marginRight:"1"}),(0,_.jsx)(k.Text,{fontFamily:"custom",fontSize:"xs",color:i?"text.error":void 0,children:a0(t,r)})]}),(0,_.jsx)(k.Box,{padding:"3",children:n})]})};function a2(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r{let t=sb();sg(!0);try{let r=!1,n=sh(()=>{let t=e();return null!==t&&"object"==typeof t&&"function"==typeof t.then&&(r=!0),t});if(r)return{then:(e,r)=>{n.then(r=>{sg(t),e(r)},e=>{sg(t),r(e)})}};return sg(t),n}catch(e){throw sg(t),e}},sx=function(){return(0,sf.BX)(...arguments)};Object.keys(sf.BX).forEach(e=>{sx[e]=function(){return sf.BX[e](...arguments)}});let sD=sx.mouseEnter,sS=sx.mouseLeave;sx.mouseEnter=function(){return sD(...arguments),sx.mouseOver(...arguments)},sx.mouseLeave=function(){return sS(...arguments),sx.mouseOut(...arguments)};let sE=sx.pointerEnter,sT=sx.pointerLeave;sx.pointerEnter=function(){return sE(...arguments),sx.pointerOver(...arguments)},sx.pointerLeave=function(){return sT(...arguments),sx.pointerOut(...arguments)};let sw=sx.select;sx.select=(e,t)=>{sw(e,t),e.focus(),sx.keyUp(e,t)};let sA=sx.blur,sC=sx.focus;sx.blur=function(){return sx.focusOut(...arguments),sA(...arguments)},sx.focus=function(){return sx.focusIn(...arguments),sC(...arguments)},(0,sf.jQ)({unstable_advanceTimersWrapper:e=>sv(e),asyncWrapper:async e=>{let t=sb();sg(!1);try{let t=await e();return await new Promise(e=>{setTimeout(()=>{e()},0),"undefined"!=typeof jest&&null!==jest&&(!0===setTimeout._isMockFunction||Object.prototype.hasOwnProperty.call(setTimeout,"clock"))&&jest.advanceTimersByTime(0)}),t}finally{sg(t)}},eventWrapper:e=>{let t;return sv(()=>{t=e()}),t}});let sM=new Set,sN=[];function sj(){sN.forEach(e=>{let{root:t,container:r}=e;sv(()=>{t.unmount()}),r.parentNode===document.body&&document.body.removeChild(r)}),sN.length=0,sM.clear()}if((void 0===sm||!sm.env?.RTL_SKIP_AUTO_CLEANUP)&&("function"==typeof afterEach?afterEach(()=>{sj()}):"function"==typeof teardown&&teardown(()=>{sj()}),"function"==typeof beforeAll&&"function"==typeof afterAll)){let e=sb();beforeAll(()=>{e=sb(),sg(!0)}),afterAll(()=>{sg(e)})}var sk=r(3151),sI=r(966),sO=r.n(sI),sP={primary:"primary",destructive:"outline"},sF=function(e){var t,r=e.node,n=e.id;i0(r),(0,d.assert)("Button"===r.type,"Expected value to be a button component.");var i=s_().handleEvent,o=r.props;return(0,_.jsx)(k.Button,{width:"100%",variant:sP[null!==(t=o.variant)&&void 0!==t?t:"primary"],marginBottom:"4",type:o.type,onClick:function(e){o.type===cE.Button&&e.preventDefault(),i({event:cA.ButtonClickEvent,name:o.name})},children:o.children},"".concat(n,"-button"))},sL=function(e){var t=e.node,r=e.id,n=e.form,i=s_(),o=i.handleInputChange,a=i.getValue;i0(t),(0,d.assert)("Input"===t.type,"Expected value to be an input component.");var s=t.props,l=a(s.name,n);return(0,_.jsx)(k.Input,{value:l,type:s.type,placeholder:s.placeholder,onChange:function(e){o(s.name,e.target.value,n)}},"".concat(r,"-input"))},sR={Bold:function(e){var t=e.node,r=e.id;return i0(t),(0,d.assert)("Bold"===t.type,"Expected value to be a bold component."),(0,_.jsx)(k.Text,{fontFamily:"custom",fontSize:"sm",paddingBottom:"1",as:"b",children:sB(ah(t),r)},"".concat(r,"-text"))},Box:function(e){var t=e.node,r=e.id;return i0(t),(0,d.assert)("Box"===t.type,"Expected value to be a Box component."),(0,_.jsx)(k.Box,{children:ah(t).map(function(e,t){return(0,_.jsx)(sz,{node:e},"".concat(r,"-panel-child-").concat(t))})},r)},Button:sF,Copyable:function(e){var t=e.node,r=e.id;i0(t),(0,d.assert)("Copyable"===t.type,"Expected value to be a copyable component.");var n=t.props;return(0,_.jsx)(a3,{value:n.value},"".concat(r,"-copyable"))},Divider:function(e){var t=e.id;return(0,_.jsx)(k.Divider,{orientation:"horizontal",marginTop:"3",marginBottom:"4",borderColor:"border.default"},"".concat(t,"-divider"))},Field:function(e){var t=e.node,r=e.id,n=e.form;i0(t),(0,d.assert)("Field"===t.type,"Expected value to be a field component.");var i=ah(t),o=i[0],a=i[1],s=t.props;return(0,_.jsxs)(k.FormControl,{isInvalid:!!s.error,children:[s.label&&(0,_.jsx)(k.FormLabel,{children:s.label}),(0,_.jsx)(sL,{id:r,node:o,form:n}),a&&(0,_.jsx)(sF,{id:r,node:a}),(0,_.jsx)(k.FormErrorMessage,{children:s.error})]},"".concat(r,"-field"))},Form:function(e){var t=e.node,r=e.id;i0(t),(0,d.assert)("Form"===t.type,"Expected value to be a form component.");var n=s_().handleEvent,i=t.props;return(0,_.jsx)(k.Box,{as:"form",onSubmit:function(e){e.preventDefault(),n({event:cA.FormSubmitEvent,name:i.name})},children:ah(t).map(function(e,n){return(0,_.jsx)(sz,{node:e,form:t.props.name},"".concat(r,"-form-child-").concat(n))})},r)},Heading:function(e){var t=e.node,r=e.id;i0(t),(0,d.assert)("Heading"===t.type,"Expected value to be a heading component.");var n=t.props;return(0,_.jsx)(k.Heading,{fontFamily:"custom",fontSize:"x-large",fontWeight:"bold",paddingBottom:"4",children:n.children},"".concat(r,"-heading"))},Input:sL,Italic:function(e){var t=e.node,r=e.id;return i0(t),(0,d.assert)("Italic"===t.type,"Expected value to be an italic component."),(0,_.jsx)(k.Text,{fontFamily:"custom",fontSize:"sm",paddingBottom:"1",as:"i",children:sB(ah(t),r)},r)},Link:function(e){var t=e.node,r=e.id;i0(t),(0,d.assert)("Link"===t.type,"Expected value to be a link component.");var n=t.props;return(0,_.jsxs)(k.Link,{href:n.href,target:"_blank",fontFamily:"custom",fontSize:"sm",isExternal:!0,color:"link.default",display:"inline",children:[sB(ah(t),r),(0,_.jsx)(P,{icon:"linkOut",width:"14px",marginLeft:"2px",display:"inline",verticalAlign:"middle"})]})},Spinner:function(e){var t=e.id;return(0,_.jsx)(k.Spinner,{},"".concat(t,"-spinner"))},Text:function(e){var t=e.node,r=e.id;return i0(t),(0,d.assert)("Text"===t.type,"Expected value to be a text component."),(0,_.jsx)(k.Text,{fontFamily:"custom",fontSize:"sm",paddingBottom:"1",children:sB(ah(t),r)},r)},Image:function(e){var t=e.id,r=e.node;i0(r),(0,d.assert)("Image"===r.type,"Expected value to be a image component.");var n=r.props,i="data:image/svg+xml;utf8,".concat(encodeURIComponent(n.src));return(0,_.jsx)(k.Image,{src:i,alt:n.alt},"".concat(t,"-image"))}},sz=function(e){var t=e.node,r=e.form,n=e.map,i=void 0===n?{}:n,o=e.id;if(!t)return null;var a=null!=o?o:sq(i,t),s=sR[t.type];if(!s)throw Error("Unknown component type: ".concat(t.type,"."));return(0,_.jsx)(s,{id:a,node:t,form:r},a)};function sB(e,t){return e.map(function(e,r){return"string"==typeof e?(0,sk.unescape)(e):(0,_.jsx)(sz,{id:"".concat(t,"-text-child-").concat(r),node:e},"".concat(t,"-text-child-").concat(r))})}var sU=sO()(function(e){var t=e.type,r=e.props.name,n=function(e){if(!af(e))return null;var t,r=e.props.children;return"string"==typeof r?r.slice(0,5e3):Array.isArray(r)?r.map(function(e){return{type:null!==(t=null==e?void 0:e.type)&&void 0!==t?t:null}}):r}(e);return(0,d.remove0x)((0,d.bytesToHex)(eM(JSON.stringify({type:t,name:null!=r?r:null,children:n}))))});function sq(e,t){var r,n=sU(t),i=(null!==(r=e[n])&&void 0!==r?r:0)+1;return e[n]=i,"".concat(n,"_").concat(i)}var sJ=function(e){var t=e.content,r=sq({},t);return(0,_.jsx)(sp,{children:(0,_.jsx)(sz,{node:t,id:r})})};function s$(e,t){for(var r=0;re.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);re.length)&&(t=e.length);for(var r=0,n=Array(t);r=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}(e,["name","onClick"]);return(0,_.jsx)(n0,{cursor:"pointer",onClick:function(){r(n)},children:t})},lj=function(e){var t=e.onClick;return(0,_.jsxs)(k.Box,{marginBottom:"4",children:[(0,_.jsx)(k.Text,{fontWeight:"500",fontSize:"xs",marginBottom:"1",children:"Transaction presets"}),(0,_.jsx)(k.Flex,{gap:"2",children:lM.map(function(e,r){var n,i,o=e.name,a=e.transaction;return(0,m.createElement)(lN,(n=function(e){for(var t=1;t=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}var lO={chainId:"eip155:1",origin:"metamask.io",from:"0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",to:"0x9f2817015caF6607C1198fB943A8241652EE8906",value:"0.01",gas:"21000",nonce:"5",maxFeePerGas:"10",maxPriorityFeePerGas:"1",data:"0x"},lP=function(){var e,t,r,n,i,o,a,s,l,u,c,p=F(lT).request,d=null!==(c=null==p?void 0:p.params)&&void 0!==c?c:{},f=d.chainId,m=d.transactionOrigin,h=d.transaction;lO.chainId,lO.origin;var y=lI(lO,["chainId","origin"]),g=(0,li.useForm)({defaultValues:lk({chainId:null!=f?f:lO.chainId,transactionOrigin:null!=m?m:lO.origin},null!=h?h:y)}),b=g.handleSubmit,v=g.register,x=g.setValue,D=g.formState.errors,S=j();return(0,_.jsxs)(k.Flex,{as:"form",flexDirection:"column",flex:"1",onSubmit:b(function(e){var t=e.chainId,r=e.transactionOrigin,n=lI(e,["chainId","transactionOrigin"]);S(r3({origin:"",handler:cl.OnTransaction,request:{jsonrpc:"2.0",method:"onTransaction",params:{chainId:t,transaction:lC(n),transactionOrigin:r}}}))}),id:"request-form",children:[(0,_.jsx)(lj,{onClick:function(e){x("chainId",e.chainId),x("transactionOrigin",e.transactionOrigin),x("from",e.from),x("to",e.to),x("value",e.value),x("data",e.data),x("gas",e.gas),x("maxFeePerGas",e.maxFeePerGas),x("maxPriorityFeePerGas",e.maxPriorityFeePerGas),x("nonce",e.nonce)}}),(0,_.jsxs)(k.Flex,{gap:"2",children:[(0,_.jsxs)(k.FormControl,{isInvalid:!!D.chainId,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"chainId",children:"Chain ID"}),(0,_.jsx)(k.Input,lk({id:"chainId",placeholder:lO.chainId,fontFamily:"code"},v("chainId"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(e=D.chainId)||void 0===e?void 0:e.message})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.transactionOrigin,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"origin",children:"Transaction Origin"}),(0,_.jsx)(k.Input,lk({id:"origin",placeholder:lO.origin,fontFamily:"code"},v("transactionOrigin"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(t=D.transactionOrigin)||void 0===t?void 0:t.message})]})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.from,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"from",children:"From Address"}),(0,_.jsx)(k.Input,lk({id:"from",placeholder:lO.from,fontFamily:"code"},v("from"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(r=D.from)||void 0===r?void 0:r.message})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.to,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"to",children:"To Address"}),(0,_.jsx)(k.Input,lk({id:"to",placeholder:lO.to,fontFamily:"code"},v("to"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(n=D.to)||void 0===n?void 0:n.message})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.value,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"value",children:"Value"}),(0,_.jsxs)(k.InputGroup,{children:[(0,_.jsx)(k.Input,lk({id:"value",placeholder:lO.value,fontFamily:"code"},v("value"))),(0,_.jsx)(k.InputRightAddon,{children:"ETH",fontSize:"sm"})]}),(0,_.jsx)(k.FormErrorMessage,{children:null===(i=D.value)||void 0===i?void 0:i.message})]}),(0,_.jsxs)(k.Flex,{gap:"2",children:[(0,_.jsxs)(k.FormControl,{isInvalid:!!D.gas,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"gas",children:"Gas Limit"}),(0,_.jsx)(k.Input,lk({id:"gas",placeholder:lO.gas,fontFamily:"code"},v("gas"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(o=D.gas)||void 0===o?void 0:o.message})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.nonce,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"nonce",children:"Nonce"}),(0,_.jsx)(k.Input,lk({id:"nonce",placeholder:lO.nonce,fontFamily:"code"},v("nonce"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(a=D.nonce)||void 0===a?void 0:a.message})]})]}),(0,_.jsxs)(k.Flex,{gap:"2",children:[(0,_.jsxs)(k.FormControl,{isInvalid:!!D.maxFeePerGas,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"maxFeePerGas",children:"Max Fee Per Gas"}),(0,_.jsxs)(k.InputGroup,{children:[(0,_.jsx)(k.Input,lk({id:"maxFeePerGas",placeholder:lO.maxFeePerGas,fontFamily:"code"},v("maxFeePerGas"))),(0,_.jsx)(k.InputRightAddon,{children:"GWEI",fontSize:"sm"})]}),(0,_.jsx)(k.FormErrorMessage,{children:null===(s=D.maxFeePerGas)||void 0===s?void 0:s.message})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.maxPriorityFeePerGas,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"maxPriorityFeePerGas",children:"Max Priority Fee Per Gas"}),(0,_.jsxs)(k.InputGroup,{children:[(0,_.jsx)(k.Input,lk({id:"maxPriorityFeePerGas",placeholder:lO.maxPriorityFeePerGas,fontFamily:"code"},v("maxPriorityFeePerGas"))),(0,_.jsx)(k.InputRightAddon,{children:"GWEI",fontSize:"sm"})]}),(0,_.jsx)(k.FormErrorMessage,{children:null===(l=D.maxPriorityFeePerGas)||void 0===l?void 0:l.message})]})]}),(0,_.jsxs)(k.FormControl,{isInvalid:!!D.data,children:[(0,_.jsx)(k.FormLabel,{htmlFor:"data",children:"Data"}),(0,_.jsx)(k.Textarea,lk({id:"data",placeholder:lO.data,fontFamily:"code"},v("data"))),(0,_.jsx)(k.FormErrorMessage,{children:null===(u=D.data)||void 0===u?void 0:u.message})]})]})},lF=(0,h.createHashRouter)((0,h.createRoutesFromElements)((0,_.jsxs)(h.Route,{element:(0,_.jsx)(function(){return(0,_.jsxs)(k.Flex,{direction:"column",height:"100vh",children:[(0,_.jsx)(nf,{}),(0,_.jsxs)(k.Flex,{direction:"row",flex:"1",overflow:"hidden",children:[(0,_.jsx)(nP,{}),(0,_.jsxs)(k.Flex,{direction:"column",width:"full",children:[(0,_.jsx)(k.Flex,{flex:"1",overflow:"hidden",children:(0,_.jsx)(h.Outlet,{})}),(0,_.jsx)(Y,{})]})]})]})},{}),children:[(0,_.jsx)(h.Route,{path:"/",element:(0,_.jsx)(h.Navigate,{to:"/handler/".concat(cl.OnRpcRequest),replace:!0})}),(0,_.jsx)(h.Route,{path:"/builder",element:(0,_.jsx)(function(){var e,t,r=sH((0,m.useState)(2),2),n=r[0],i=r[1],o=sH((0,m.useState)([{id:1,parent:0,text:"Box",droppable:!0,data:nR({children:null})}]),2),a=o[0],s=o[1];return(0,_.jsx)(k.Flex,{width:"100%",direction:"column",overflow:"hidden",children:(0,_.jsxs)(k.Flex,{direction:"row",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.Flex,{direction:"column",flex:"1",width:"50%",overflow:"hidden",children:(0,_.jsxs)(k.Tabs,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.TabList,{children:(0,_.jsx)(k.Tab,{children:"Builder"})}),(0,_.jsx)(k.TabPanels,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:(0,_.jsxs)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",overflowY:"auto",children:[(0,_.jsx)(n4,{nextId:n,incrementId:function(){i(function(e){return e+1})}}),(0,_.jsx)(aH,{items:a,setItems:s})]})})]})}),(0,_.jsx)(k.Box,{display:"flex",flexDirection:"column",flex:"1",width:"50%",borderLeft:"1px solid",borderColor:"border.default",children:(0,_.jsxs)(k.Tabs,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsxs)(k.TabList,{children:[(0,_.jsx)(k.Tab,{children:"Result"}),(0,_.jsx)(k.Tab,{children:"Code"})]}),(0,_.jsxs)(k.TabPanels,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",padding:"4",children:(0,_.jsx)(sW,{items:a})}),(0,_.jsx)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",padding:"0",children:(0,_.jsx)(nJ,{border:"none",value:(t=(function e(t){var r=new Set;r.add(t.type);var n=ah(t),i=!0,o=!1,a=void 0;try{for(var s,l=n[Symbol.iterator]();!(i=(s=l.next()).done);i=!0){var u=s.value;if("string"!=typeof u&&(r.add(u.type),af(t))){var c=e(u),p=!0,_=!1,d=void 0;try{for(var f,m=c[Symbol.iterator]();!(p=(f=m.next()).done);p=!0){var h=f.value;r.add(h)}}catch(e){_=!0,d=e}finally{try{p||null==m.return||m.return()}finally{if(_)throw d}}}}}catch(e){o=!0,a=e}finally{try{i||null==l.return||l.return()}finally{if(o)throw a}}return Array.from(r).sort(function(e,t){return e.localeCompare(t)})})(e=aC(a)).join(", "),aD().format("\n import { ".concat(t," } from '@metamask/snaps-sdk/jsx';\n\n const Component = () => (").concat(function e(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:0;if(Array.isArray(t))return t.map(function(t){return e(t,r)}).join("");var n=" ".repeat(r);if("string"==typeof t)return"".concat(n).concat(t,"\n");if(!t)return"";var i=t.type,o=t.props,a=r>0?"\n":"";if((0,d.hasProperty)(o,"children")){var s=e(o.children,r+1);return"".concat(n,"<").concat(i).concat(ag(o),">\n").concat(s).concat(n,"").concat(a)}return"".concat(n,"<").concat(i).concat(ag(o)," />").concat(a)}(e),");\n"),{parser:"typescript",plugins:[av()],printWidth:80,tabWidth:2,singleQuote:!0,trailingComma:"all"})),language:"typescript",options:{readOnly:!0}})})]})]})})]})})},{})}),(0,_.jsx)(h.Route,{path:"/manifest",element:(0,_.jsx)(function(){var e=F(nl);return(0,_.jsx)(k.Flex,{width:"100%",direction:"column",overflow:"hidden",children:(0,_.jsxs)(k.Flex,{direction:"row",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.Flex,{direction:"column",flex:"1",width:"50%",overflow:"hidden",children:(0,_.jsxs)(k.Tabs,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.TabList,{children:(0,_.jsx)(k.Tab,{children:"Validation"})}),(0,_.jsx)(k.TabPanels,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:(0,_.jsx)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",padding:"0",children:(0,_.jsx)(sX,{})})})]})}),(0,_.jsx)(k.Box,{display:"flex",flexDirection:"column",flex:"1",width:"50%",borderLeft:"1px solid",borderColor:"border.default",children:(0,_.jsxs)(k.Tabs,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.TabList,{children:(0,_.jsx)(k.Tab,{children:"Manifest"})}),(0,_.jsx)(k.TabPanels,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:(0,_.jsx)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",padding:"0",children:(0,_.jsx)(nJ,{border:"none",value:JSON.stringify(e,null,2),options:{readOnly:!0,wordWrap:"on"}})})})]})})]})})},{})}),(0,_.jsxs)(h.Route,{path:"/handler",element:(0,_.jsx)(function(){var e,t=function(e){if(Array.isArray(e))return e}(e=(0,m.useState)(0))||function(e,t){var r,n,i=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=i){var o=[],a=!0,s=!1;try{for(i=i.call(e);!(a=(r=i.next()).done)&&(o.push(r.value),!t||o.length!==t);a=!0);}catch(e){s=!0,n=e}finally{try{a||null==i.return||i.return()}finally{if(s)throw n}}return o}}(e,2)||function(e,t){if(e){if("string"==typeof e)return ls(e,t);var r=Object.prototype.toString.call(e).slice(8,-1);if("Object"===r&&e.constructor&&(r=e.constructor.name),"Map"===r||"Set"===r)return Array.from(r);if("Arguments"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r))return ls(e,t)}}(e,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}(),r=t[0],n=t[1],i=F(ni);return(0,_.jsx)(k.Flex,{width:"100%",direction:"column",overflow:"hidden",children:(0,_.jsxs)(k.Flex,{direction:"row",flex:"1",overflow:"hidden",children:[(0,_.jsx)(s0,{isTest:!1,children:(0,_.jsx)(k.Flex,{direction:"column",flex:"1",width:"50%",overflow:"hidden",children:(0,_.jsxs)(k.Tabs,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",isLazy:!0,onChange:n,children:[(0,_.jsx)(s9,{}),(0,_.jsxs)(k.TabList,{alignItems:"center",children:[(0,_.jsx)(k.Tab,{children:"Request"}),(0,_.jsx)(k.Tab,{children:"History"}),0===r&&(0,_.jsx)(k.Box,{marginLeft:"auto",children:(0,_.jsx)(s7,{})})]}),(0,_.jsxs)(k.TabPanels,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",overflowY:"auto","data-testid":"tab-request",children:(0,_.jsx)(h.Outlet,{})}),(0,_.jsx)(k.TabPanel,{padding:"0",display:"flex",flexDirection:"column",flex:"1",overflowY:"auto",children:(0,_.jsx)(s6,{})})]})]})})}),(0,_.jsx)(k.Box,{display:"flex",flexDirection:"column",flex:"1",width:"50%",borderLeft:"1px solid",borderColor:"border.default",children:(0,_.jsxs)(k.Tabs,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(s9,{}),(0,_.jsx)(le,{}),(0,_.jsxs)(k.TabList,{children:[(0,_.jsx)(k.Tab,{children:"Response"}),i&&(0,_.jsx)(k.Tab,{children:"UI"})]}),(0,_.jsxs)(k.TabPanels,{display:"flex",flexDirection:"column",flex:"1",overflow:"hidden",children:[(0,_.jsx)(k.TabPanel,{display:"flex",flexDirection:"column",flex:"1",padding:"0","data-testid":"tab-response",children:(0,_.jsx)(lt,{})}),i&&(0,_.jsx)(k.TabPanel,{overflowY:"auto","data-testid":"tab-ui",children:(0,_.jsx)(la,{})})]})]})})]})})},{}),children:[(0,_.jsx)(h.Route,{path:"/handler/".concat(cl.OnRpcRequest),element:(0,_.jsx)(function(){return(0,_.jsx)(ld,{})},{})}),(0,_.jsx)(h.Route,{path:"/handler/".concat(cl.OnCronjob),element:(0,_.jsx)(function(){return(0,_.jsx)(lx,{})},{})}),(0,_.jsx)(h.Route,{path:"/handler/".concat(cl.OnTransaction),element:(0,_.jsx)(function(){return(0,_.jsx)(lP,{})},{})})]})]})));function lL(e){for(var t=1;t1?t-1:0),n=1;n1?t-1:0),n=1;n1?t-1:0),n=1;n2?r-2:0),i=2;i2?i-2:0),a=2;a2?r-2:0),i=2;i1?t-1:0),n=1;n3?t.i-4:t.i:Array.isArray(e)?1:uQ(e)?2:uH(e)?3:0}function uV(e,t){return 2===uY(e)?e.has(t):Object.prototype.hasOwnProperty.call(e,t)}function uW(e,t,r){var n=uY(e);2===n?e.set(t,r):3===n?e.add(r):e[t]=r}function uQ(e){return cF&&e instanceof Map}function uH(e){return cL&&e instanceof Set}function uG(e){return e.o||e.t}function uZ(e){if(Array.isArray(e))return Array.prototype.slice.call(e);var t=c$(e);delete t[cU];for(var r=cJ(t),n=0;n1&&(e.set=e.add=e.clear=e.delete=u0),Object.freeze(e),t&&uK(e,function(e,t){return uX(t,!0)},!0)),e}function u0(){uq(2)}function u1(e){return null==e||"object"!=typeof e||Object.isFrozen(e)}function u2(e){var t=cK[e];return t||uq(18,e),t}function u3(e,t){t&&(u2("Patches"),e.u=[],e.s=[],e.v=t)}function u4(e){u6(e),e.p.forEach(u8),e.p=null}function u6(e){e===cO&&(cO=e.l)}function u5(e){return cO={p:[],l:cO,h:e,m:!0,_:0}}function u8(e){var t=e[cU];0===t.i||1===t.i?t.j():t.g=!0}function u7(e,t){t._=t.p.length;var r=t.p[0],n=void 0!==e&&e!==r;return t.h.O||u2("ES5").S(t,e,n),n?(r[cU].P&&(u4(t),uq(4)),u$(e)&&(e=u9(t,e),t.l||ct(t,e)),t.u&&u2("Patches").M(r[cU].t,e,t.u,t.s)):e=u9(t,r,[]),u4(t),t.u&&t.v(t.u,t.s),e!==cz?e:void 0}function u9(e,t,r){if(u1(t))return t;var n=t[cU];if(!n)return uK(t,function(i,o){return ce(e,n,t,i,o,r)},!0),t;if(n.A!==e)return t;if(!n.P)return ct(e,n.t,!0),n.t;if(!n.I){n.I=!0,n.A._--;var i=4===n.i||5===n.i?n.o=uZ(n.k):n.o,o=i,a=!1;3===n.i&&(o=new Set(i),i.clear(),a=!0),uK(o,function(t,o){return ce(e,n,i,t,o,r,a)}),ct(e,i,!1),r&&e.u&&u2("Patches").N(n,r,e.u,e.s)}return n.o}function ce(e,t,r,n,i,o,a){if(uJ(i)){var s=u9(e,i,o&&t&&3!==t.i&&!uV(t.R,n)?o.concat(n):void 0);if(uW(r,n,s),!uJ(s))return;e.m=!1}else a&&r.add(i);if(u$(i)&&!u1(i)){if(!e.h.D&&e._<1)return;u9(e,i),t&&t.A.l||ct(e,i)}}function ct(e,t,r){void 0===r&&(r=!1),!e.l&&e.h.D&&e.m&&uX(t,r)}function cr(e,t){var r=e[cU];return(r?uG(r):e)[t]}function cn(e,t){if(t in e)for(var r=Object.getPrototypeOf(e);r;){var n=Object.getOwnPropertyDescriptor(r,t);if(n)return n;r=Object.getPrototypeOf(r)}}function ci(e){e.P||(e.P=!0,e.l&&ci(e.l))}function co(e){e.o||(e.o=uZ(e.t))}function ca(e,t,r){var n,i,o,a,s,l,u,c=uQ(t)?u2("MapSet").F(t,r):uH(t)?u2("MapSet").T(t,r):e.O?(o=i={i:(n=Array.isArray(t))?1:0,A:r?r.A:cO,P:!1,I:!1,R:{},l:r,t:t,k:null,o:null,j:null,C:!1},a=cY,n&&(o=[i],a=cV),l=(s=Proxy.revocable(o,a)).revoke,u=s.proxy,i.k=u,i.j=l,u):u2("ES5").J(t,r);return(r?r.A:cO).p.push(c),c}function cs(e,t){switch(t){case 2:return new Map(e);case 3:return Array.from(e)}return uZ(e)}var cl,cu,cc,cp,c_,cd,cf,cm,ch,cy,cg,cb,cv,cx,cD,cS,cE,cT,cw,cA,cC,cM,cN,cj,ck,cI,cO,cP="undefined"!=typeof Symbol&&"symbol"==typeof Symbol("x"),cF="undefined"!=typeof Map,cL="undefined"!=typeof Set,cR="undefined"!=typeof Proxy&&void 0!==Proxy.revocable&&"undefined"!=typeof Reflect,cz=cP?Symbol.for("immer-nothing"):((cI={})["immer-nothing"]=!0,cI),cB=cP?Symbol.for("immer-draftable"):"__$immer_draftable",cU=cP?Symbol.for("immer-state"):"__$immer_state",cq=("undefined"!=typeof Symbol&&Symbol.iterator,""+Object.prototype.constructor),cJ="undefined"!=typeof Reflect&&Reflect.ownKeys?Reflect.ownKeys:void 0!==Object.getOwnPropertySymbols?function(e){return Object.getOwnPropertyNames(e).concat(Object.getOwnPropertySymbols(e))}:Object.getOwnPropertyNames,c$=Object.getOwnPropertyDescriptors||function(e){var t={};return cJ(e).forEach(function(r){t[r]=Object.getOwnPropertyDescriptor(e,r)}),t},cK={},cY={get:function(e,t){if(t===cU)return e;var r,n,i=uG(e);if(!uV(i,t))return(n=cn(i,t))?"value"in n?n.value:null===(r=n.get)||void 0===r?void 0:r.call(e.k):void 0;var o=i[t];return e.I||!u$(o)?o:o===cr(e.t,t)?(co(e),e.o[t]=ca(e.A.h,o,e)):o},has:function(e,t){return t in uG(e)},ownKeys:function(e){return Reflect.ownKeys(uG(e))},set:function(e,t,r){var n=cn(uG(e),t);if(null==n?void 0:n.set)return n.set.call(e.k,r),!0;if(!e.P){var i=cr(uG(e),t),o=null==i?void 0:i[cU];if(o&&o.t===r)return e.o[t]=r,e.R[t]=!1,!0;if((r===i?0!==r||1/r==1/i:r!=r&&i!=i)&&(void 0!==r||uV(e.t,t)))return!0;co(e),ci(e)}return e.o[t]===r&&(void 0!==r||t in e.o)||Number.isNaN(r)&&Number.isNaN(e.o[t])||(e.o[t]=r,e.R[t]=!0),!0},deleteProperty:function(e,t){return void 0!==cr(e.t,t)||t in e.t?(e.R[t]=!1,co(e),ci(e)):delete e.R[t],e.o&&delete e.o[t],!0},getOwnPropertyDescriptor:function(e,t){var r=uG(e),n=Reflect.getOwnPropertyDescriptor(r,t);return n?{writable:!0,configurable:1!==e.i||"length"!==t,enumerable:n.enumerable,value:r[t]}:n},defineProperty:function(){uq(11)},getPrototypeOf:function(e){return Object.getPrototypeOf(e.t)},setPrototypeOf:function(){uq(12)}},cV={};uK(cY,function(e,t){cV[e]=function(){return arguments[0]=arguments[0][0],t.apply(this,arguments)}}),cV.deleteProperty=function(e,t){return cV.set.call(this,e,t,void 0)},cV.set=function(e,t,r){return cY.set.call(this,e[0],t,r,e[0])};var cW=new(function(){function e(e){var t=this;this.O=cR,this.D=!0,this.produce=function(e,r,n){if("function"==typeof e&&"function"!=typeof r){var i,o=r;return r=e,function(e){var n=this;void 0===e&&(e=o);for(var i=arguments.length,a=Array(i>1?i-1:0),s=1;s1?n-1:0),o=1;o=0;r--){var r,n=t[r];if(0===n.path.length&&"replace"===n.op){e=n.value;break}}r>-1&&(t=t.slice(r+1));var i=u2("Patches").$;return uJ(e)?i(e,t):this.produce(e,function(e){return i(e,t)})},e}());cW.produce,cW.produceWithPatches.bind(cW),cW.setAutoFreeze.bind(cW),cW.setUseProxies.bind(cW),cW.applyPatches.bind(cW),cW.createDraft.bind(cW),cW.finishDraft.bind(cW);let cQ=(e=21)=>crypto.getRandomValues(new Uint8Array(e)).reduce((e,t)=>((t&=63)<36?e+=t.toString(36):t<62?e+=(t-26).toString(36).toUpperCase():t>62?e+="-":e+="_",e),"");function cH(e){var t;return(0,d.isPlainObject)(e)&&(0,d.hasProperty)(e,"type")&&(0,d.hasProperty)(e,"props")&&(0,d.hasProperty)(e,"key")?e:(t=function e(t){switch(t.type){case cx.Panel:return t.children.reduce(function(t,r){return t+e(r)},0);case cx.Row:return e(t.value);case cx.Text:return t.value.length;default:return 0}}(e),(0,d.assert)(t<=5e4,"The text in a Snap UI may not be larger than ".concat(50," kB.")),function e(t){switch(t.type){case cx.Address:return i1(i8,{address:t.value});case cx.Button:return i1(nQ,{name:t.name,variant:function(e){switch(e){case"primary":return"primary";case"secondary":return"destructive";default:return}}(t.variant),type:t.buttonType,children:t.value});case cx.Copyable:return i1(nV,{value:t.value,sensitive:t.sensitive});case cx.Divider:return i1(nY,{});case cx.Form:return i1(nH,{name:t.name,children:au(t.children.map(e))});case cx.Heading:return i1(n$,{children:t.value});case cx.Image:return i1(nW,{src:t.value});case cx.Input:return i1(nG,{label:t.label,error:t.error,children:i1(nZ,{name:t.name,type:t.inputType,value:t.value,placeholder:t.placeholder})});case cx.Panel:return i1(nR,{children:au(t.children.map(e))});case cx.Row:return i1(i7,{label:t.label,variant:t.variant,children:e(t.value)});case cx.Spinner:return i1(i9,{});case cx.Text:var r,n;return i1(nK,{children:au((r=at(t.value,{gfm:!1}),n=[],ae(r,function(e){if("paragraph"===e.type){n.length>0&&n.push("\n\n");var t,r=e.tokens;n.push.apply(n,function(e){if(Array.isArray(e))return ao(e)}(t=r.flatMap(ap))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||as(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())}}),n.filter(function(e){return null!==e})))});default:return(0,d.assertExhaustive)(t)}}(e))}function cG(e,t){(0,d.assert)(void 0===e[t],'Duplicate component names are not allowed, found multiple instances of: "'.concat(t,'".'))}function cZ(e,t,r){var n,i,o,a=r?e[r]:e,s=null==a?void 0:a[t.props.name];return"FileInput"===t.type?null!=s?s:null:null!==(o=null!==(i=null!==(n="Checkbox"===t.type?t.props.checked:t.props.value)&&void 0!==n?n:s)&&void 0!==i?i:function(e){var t,r,n;switch(e.type){case"Dropdown":return null===(t=ah(e)[0])||void 0===t?void 0:t.props.value;case"RadioGroup":return null===(r=ah(e)[0])||void 0===r?void 0:r.props.value;case"Selector":return null===(n=ah(e)[0])||void 0===n?void 0:n.props.value;case"Checkbox":return!1;default:return null}}(t))&&void 0!==o?o:null}function cX(e,t){var r={},n=[];return ay(t,function(t,i){var o=n[n.length-1];if(o&&i<=o.depth&&(n.pop(),o=n[n.length-1]),"Form"===t.type){cG(r,t.props.name),n.push({name:t.props.name,depth:i}),r[t.props.name]={};return}if(o&&("Input"===t.type||"Dropdown"===t.type||"RadioGroup"===t.type||"FileInput"===t.type||"Checkbox"===t.type||"Selector"===t.type)){var a=r[o.name];cG(a,t.props.name),a[t.props.name]=cZ(e,t,o.name);return}("Input"===t.type||"Dropdown"===t.type||"RadioGroup"===t.type||"FileInput"===t.type||"Checkbox"===t.type||"Selector"===t.type)&&(cG(r,t.props.name),r[t.props.name]=cZ(e,t))}),r}function c0(e){if(e){var t=e7(e);(0,d.assert)(t<=1e6,"A Snap interface context may not be larger than ".concat(1," MB."))}}function c1(e){if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}function c2(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function c3(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){c2(o,n,i,a,s,"next",e)}function s(e){c2(o,n,i,a,s,"throw",e)}a(void 0)})}}function c4(e,t,r){if(!t.has(e))throw TypeError("attempted to get private field on non-instance");return r}function c6(e,t){(function(e,t){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object")})(e,t),t.add(e)}function c5(e,t){for(var r=0;r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=-32099&&e<=-32e3)return"Unspecified server error."}return t}function pM(e){return Object.getOwnPropertyNames(e).reduce((t,r)=>{let n=e[r];return(0,d.isValidJson)(n)&&(t[r]=n),t},{})}pC(pw.rpc.internal);var pN=r(7847),pj=r.n(pN),pk=class extends Error{constructor(e,t,r){var n=(...e)=>{super(...e)};if(!Number.isInteger(e))throw Error('"code" must be an integer.');if(!t||"string"!=typeof t)throw Error('"message" must be a non-empty string.');(function(e){return(0,d.isObject)(e)&&(0,d.hasProperty)(e,"cause")&&(0,d.isObject)(e.cause)})(r)?(n(t,{cause:r.cause}),(0,d.hasProperty)(this,"cause")||Object.assign(this,{cause:r.cause})):n(t),void 0!==r&&(this.data=r),this.code=e}serialize(){var e;let t={code:this.code,message:this.message};return void 0!==this.data&&(t.data=this.data,(0,d.isPlainObject)(this.data)&&(t.data.cause=Array.isArray(e=this.data.cause)?e.map(e=>(0,d.isValidJson)(e)?e:(0,d.isObject)(e)?pM(e):null):(0,d.isObject)(e)?pM(e):(0,d.isValidJson)(e)?e:null)),this.stack&&(t.stack=this.stack),t}toString(){return pj()(this.serialize(),pO,2)}},pI=class extends pk{constructor(e,t,r){if(!function(e){return Number.isInteger(e)&&e>=1e3&&e<=4999}(e))throw Error('"code" must be an integer such that: 1000 <= code <= 4999');super(e,t,r)}};function pO(e,t){if("[Circular]"!==t)return t}var pP={parse:e=>pL(pw.rpc.parse,e),invalidRequest:e=>pL(pw.rpc.invalidRequest,e),invalidParams:e=>pL(pw.rpc.invalidParams,e),methodNotFound:e=>pL(pw.rpc.methodNotFound,e),internal:e=>pL(pw.rpc.internal,e),server:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Ethereum RPC Server errors must provide single object argument.");let{code:t}=e;if(!Number.isInteger(t)||t>-32005||t<-32099)throw Error('"code" must be an integer such that: -32099 <= code <= -32005');return pL(t,e)},invalidInput:e=>pL(pw.rpc.invalidInput,e),resourceNotFound:e=>pL(pw.rpc.resourceNotFound,e),resourceUnavailable:e=>pL(pw.rpc.resourceUnavailable,e),transactionRejected:e=>pL(pw.rpc.transactionRejected,e),methodNotSupported:e=>pL(pw.rpc.methodNotSupported,e),limitExceeded:e=>pL(pw.rpc.limitExceeded,e)},pF={userRejectedRequest:e=>pR(pw.provider.userRejectedRequest,e),unauthorized:e=>pR(pw.provider.unauthorized,e),unsupportedMethod:e=>pR(pw.provider.unsupportedMethod,e),disconnected:e=>pR(pw.provider.disconnected,e),chainDisconnected:e=>pR(pw.provider.chainDisconnected,e),custom:e=>{if(!e||"object"!=typeof e||Array.isArray(e))throw Error("Ethereum Provider custom errors must provide single object argument.");let{code:t,message:r,data:n}=e;if(!r||"string"!=typeof r)throw Error('"message" must be a nonempty string');return new pI(t,r,n)}};function pL(e,t){let[r,n]=pz(t);return new pk(e,r??pC(e),n)}function pR(e,t){let[r,n]=pz(t);return new pI(e,r??pC(e),n)}function pz(e){if(e){if("string"==typeof e)return[e];if("object"==typeof e&&!Array.isArray(e)){let{message:t,data:r}=e;if(t&&"string"!=typeof t)throw Error("Must specify string message.");return[t??void 0,r]}}return[]}function pB(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r1?r-1:0),i=1;i=0,TypeError("Can't start a timer with negative time")),this.state={value:"stopped",remaining:e}}return e=[{key:"status",get:function(){return this.state.value}},{key:"remaining",get:function(){return this.state.remaining}},{key:"cancel",value:function(){(0,d.assert)("paused"===this.status||"running"===this.status,Error("Tried to cancel a not running Timer")),this.onFinish(!1)}},{key:"finish",value:function(){(0,d.assert)("finished"!==this.status,Error("Tried to finish a finished Timer.")),this.onFinish(!0)}},{key:"pause",value:function(){(0,d.assert)("running"===this.state.value,Error("Tried to pause a not running Timer"));var e=this.state,t=e.callback,r=e.start,n=e.timeout,i=e.remaining;void 0!==n&&clearTimeout(n),this.state={value:"paused",callback:t,remaining:i-(Date.now()-r)}}},{key:"start",value:function(e){(0,d.assert)("stopped"===this.state.value,Error("Tried to start an already running Timer"));var t=this.state.remaining;this.state={value:"paused",remaining:t,callback:e},this.resume()}},{key:"resume",value:function(){var e,t=this;(0,d.assert)("paused"===this.state.value,Error("Tried to resume not paused Timer"));var r=this.state,n=r.remaining,i=r.callback,o=Date.now();n!==Number.POSITIVE_INFINITY&&(e=setTimeout(function(){return t.onFinish(!0)},n)),this.state={value:"running",callback:i,remaining:n,start:o,timeout:e}}},{key:"onFinish",value:function(e){(0,d.assert)("running"===this.state.value||"paused"===this.state.value),"running"===this.state.value&&void 0!==this.state.timeout&&clearTimeout(this.state.timeout);var t=this.state,r=t.callback,n=t.remaining;this.state={value:"finished",remaining:"running"===this.state.value?n-(Date.now()-this.state.start):n},e&&r()}}],p$(r.prototype,e),t&&p$(r,t),r}();function pY(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function pV(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){pY(o,n,i,a,s,"next",e)}function s(e){pY(o,n,i,a,s,"throw",e)}a(void 0)})}}function pW(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e.length)&&(t=e.length);for(var r=0,n=Array(t);r=0||(i[r]=e[r]);return i}(e,t);if(Object.getOwnPropertySymbols){var o=Object.getOwnPropertySymbols(e);for(n=0;n=0)&&Object.prototype.propertyIsEnumerable.call(e,r)&&(i[r]=e[r])}return i}(t,["maxRequestTime"]));return a?(n=function(e){for(var t=1;t0),{caveats:t}})),_7(i,_B.targetName,_M(function(e){return{caveats:[{type:cc.KeyringOrigin,value:e}]}})),_7(i,_1.targetName,_M(function(e){return!e||!(0,d.isObject)(e)||(0,d.isObject)(e)&&0===Object.keys(e).length?{caveats:null}:{caveats:[{type:cc.SignatureOrigin,value:(0,d.hasProperty)(e,"allowSignatureOrigin")&&e.allowSignatureOrigin}]}})),_7(i,_J.targetName,_C),_7(i,_L.targetName,_C),i);_7(o={},cl.OnRpcRequest,_Z.targetName),_7(o,cl.OnTransaction,_4.targetName),_7(o,cl.OnCronjob,_k.targetName),_7(o,cl.OnNameLookup,_Y.targetName),_7(o,cl.OnInstall,_J.targetName),_7(o,cl.OnUpdate,_J.targetName),_7(o,cl.OnKeyringRequest,_B.targetName),_7(o,cl.OnHomePage,_L.targetName),_7(o,cl.OnSignature,_1.targetName),_7(o,cl.OnUserInput,null);let dr=BigInt(4294967296-1),dn=BigInt(32),di=(e,t,r)=>e<>>32-r,da=(e,t,r)=>t<>>32-r,ds=(e,t,r)=>t<>>64-r,dl=(e,t,r)=>e<>>64-r,du=[],dc=[],dp=[],d_=BigInt(0),dd=BigInt(1),df=BigInt(2),dm=BigInt(7),dh=BigInt(256),dy=BigInt(113);for(let e=0,t=dd,r=1,n=0;e<24;e++){[r,n]=[n,(2*r+3*n)%5],du.push(2*(5*n+r)),dc.push((e+1)*(e+2)/2%64);let i=d_;for(let e=0;e<7;e++)(t=(t<>dm)*dy)%dh)&df&&(i^=dd<<(dd<>dn&dr)}:{h:0|Number(e>>dn&dr),l:0|Number(e&dr)}}(e[i],t);[r[i],n[i]]=[o,a]}return[r,n]}(dp,!0),dv=(e,t,r)=>r>32?ds(e,t,r):di(e,t,r),dx=(e,t,r)=>r>32?dl(e,t,r):da(e,t,r);class dD extends ev{constructor(e,t,r,n=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=n,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,eu(r),0>=this.blockLen||this.blockLen>=200)throw Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=ed(this.state)}keccak(){eh||eg(this.state32),function(e,t=24){let r=new Uint32Array(10);for(let n=24-t;n<24;n++){for(let t=0;t<10;t++)r[t]=e[t]^e[t+10]^e[t+20]^e[t+30]^e[t+40];for(let t=0;t<10;t+=2){let n=(t+8)%10,i=(t+2)%10,o=r[i],a=r[i+1],s=dv(o,a,1)^r[n],l=dx(o,a,1)^r[n+1];for(let r=0;r<50;r+=10)e[t+r]^=s,e[t+r+1]^=l}let t=e[2],i=e[3];for(let r=0;r<24;r++){let n=dc[r],o=dv(t,i,n),a=dx(t,i,n),s=du[r];t=e[s],i=e[s+1],e[s]=o,e[s+1]=a}for(let t=0;t<50;t+=10){for(let n=0;n<10;n++)r[n]=e[t+n];for(let n=0;n<10;n++)e[t+n]^=~r[(n+2)%10]&r[(n+4)%10]}e[0]^=dg[n],e[1]^=db[n]}r.fill(0)}(this.state32,this.rounds),eh||eg(this.state32),this.posOut=0,this.pos=0}update(e){ep(this);let{blockLen:t,state:r}=this;e=eb(e);let n=e.length;for(let i=0;i=r&&this.keccak();let o=Math.min(r-this.posOut,i-n);e.set(t.subarray(this.posOut,this.posOut+o),n),this.posOut+=o,n+=o}return e}xofInto(e){if(!this.enableXOF)throw Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return eu(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(e_(e,this),this.finished)throw Error("digest() was already called");return this.writeInto(e),this.destroy(),e}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,this.state.fill(0)}_cloneInto(e){let{blockLen:t,suffix:r,outputLen:n,rounds:i,enableXOF:o}=this;return e||(e=new dD(t,r,n,o,i)),e.state32.set(this.state32),e.pos=this.pos,e.posOut=this.posOut,e.finished=this.finished,e.rounds=i,e.suffix=r,e.outputLen=n,e.enableXOF=o,e.destroyed=this.destroyed,e}}let dS=ex(()=>new dD(136,1,32));function dE(e,t){(null==t||t>e.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]>>0;t.push("bip32:".concat(i-2147483648,"'"))}return t}(dS((0,d.concatBytes)([a,dS(s)]))),[4,e9.SLIP10Node.fromDerivationPath({derivationPath:[i,"bip32:".concat(o)].concat(dA(l)),curve:"secp256k1"})];case 1:return u=c.sent().privateKey,(0,d.assert)(u,"Failed to derive the entropy."),[2,(0,d.add0x)(u)]}})})).apply(this,arguments)}function dj(e){return dk.apply(this,arguments)}function dk(){return(dk=dw(function(e){var t,r,n,i;return dC(this,function(o){switch(o.label){case 0:return t=e.curve,r=e.secretRecoveryPhrase,n=e.path,i=function(e){switch(e){case"secp256k1":return"bip32";case"ed25519":return"slip10";case"ed25519Bip32":return"cip3";default:return(0,d.assertExhaustive)(e)}}(t),[4,e9.SLIP10Node.fromDerivationPath({curve:t,derivationPath:[r].concat(dA(n.slice(1).map(function(e){return"".concat(i,":").concat(e)})))})];case 1:return[2,o.sent()]}})})).apply(this,arguments)}function dI(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}var dO="snap_getBip32Entropy",dP=Object.freeze({targetName:dO,specificationBuilder:function(e){var t,r,n,i,o=e.methodHooks;return{permissionType:ts.PermissionType.RestrictedMethod,targetName:dO,allowedCaveats:[cc.PermittedDerivationPaths],methodImplementation:(n=o.getMnemonic,i=o.getUnlockPromise,t=function(e){var t,r;return function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]2147483647)throw pP.invalidParams({message:'Invalid "coinType" parameter. Coin type must be a non-negative integer.'});if(tL.includes(e.coinType))throw pP.invalidParams({message:"Coin type ".concat(e.coinType," is forbidden.")})}var dG=function(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}({},cc.PermittedCoinTypes,Object.freeze({type:cc.PermittedCoinTypes,decorator:function(e,t){var r,n;return r=function(r){var n;return function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]2&&void 0!==arguments[2]?arguments[2]:104857600;if(!(0,d.isObject)(e))throw pP.invalidParams({message:"Expected params to be a single object."});var i=e.operation,o=e.newState,a=e.encrypted;if(!i||"string"!=typeof i||!Object.values(u).includes(i))throw pP.invalidParams({message:'Must specify a valid manage state "operation".'});if(void 0!==a&&"boolean"!=typeof a)throw pP.invalidParams({message:'"encrypted" parameter must be a boolean if specified.'});if(i===u.UpdateState){if(!(0,d.isObject)(o))throw pP.invalidParams({message:"Invalid ".concat(t,' "updateState" parameter: The new state must be a plain object.'),data:{receivedNewState:void 0===o?"undefined":o}});try{r=(0,d.getJsonSize)(o)}catch(e){throw pP.invalidParams({message:"Invalid ".concat(t,' "updateState" parameter: The new state must be JSON serializable.'),data:{receivedNewState:void 0===o?"undefined":o}})}if(r>n)throw pP.invalidParams({message:"Invalid ".concat(t,' "updateState" parameter: The new state must not exceed ').concat(n," bytes in size."),data:{receivedNewState:void 0===o?"undefined":o}})}return e}(r,s)).encrypted)||void 0===p||p)&&c.operation!==u.ClearState))return[3,2];return[4,n(!0)];case 1:f.sent(),f.label=2;case 2:switch(c.operation){case u.ClearState:return[3,3];case u.GetState:return[3,4];case u.UpdateState:return[3,6]}return[3,8];case 3:return i(l,_),[2,null];case 4:return[4,o(l,_)];case 5:return[2,f.sent()];case 6:return[4,a(l,c.newState,_)];case 7:return f.sent(),[2,null];case 8:throw pP.invalidParams("Invalid ".concat(s,' operation: "').concat(c.operation,'"'));case 9:return[2]}})},r=function(){var e=this,r=arguments;return new Promise(function(n,i){var o=t.apply(e,r);function a(e){fK(o,n,i,a,s,"next",e)}function s(e){fK(o,n,i,a,s,"throw",e)}a(void 0)})},function(e){return r.apply(this,arguments)}),subjectTypes:[ts.SubjectType.Snap]}},methodHooks:{getUnlockPromise:!0,clearSnapState:!0,getSnapState:!0,updateSnapState:!0}});function fW(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}var fQ="snap_notify",fH=(0,H.object)({type:tT(cN.Native),message:(0,H.string)()}),fG=tw([(0,H.object)({type:tT(cN.InApp),message:(0,H.string)()}),(0,H.object)({type:tT(cN.InApp),message:(0,H.string)(),content:iH,title:(0,H.string)()}),(0,H.object)({type:tT(cN.InApp),message:(0,H.string)(),content:iH,title:(0,H.string)(),footerLink:(0,H.object)({href:(0,H.string)(),text:(0,H.string)()})}),fH]),fZ=Object.freeze({targetName:fQ,specificationBuilder:function(e){var t,r,n,i,o,a,s,l,u=e.allowedCaveats,c=e.methodHooks;return{permissionType:ts.PermissionType.RestrictedMethod,targetName:fQ,allowedCaveats:void 0===u?null:u,methodImplementation:(n=c.showNativeNotification,i=c.showInAppNotification,o=c.isOnPhishingList,a=c.maybeUpdatePhishingList,s=c.createInterface,l=c.getSnap,t=function(e){var t,r,u,c;return function(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]=50))throw pP.invalidParams({message:'Must specify a non-empty string "message" less than 50 characters long.'});if(n===cN.InApp&&(o||i.length>=500))throw pP.invalidParams({message:'Must specify a non-empty string "message" less than 500 characters long.'});try{var a=function(e,t,r){var n=arguments.length>3&&void 0!==arguments[3]&&arguments[3];(0,d.assert)(t.schema,"Expected a struct with a schema. Make sure to use `union` from `@metamask/snaps-sdk`."),(0,d.assert)(t.schema.length>0,"Expected a non-empty array of structs.");var i=t.schema.map(function(e){return e.schema[r]}),o=(0,H.type)(tj({},r,tw(i))),a=tk((0,H.validate)(e,o,{coerce:n}),1)[0];if(a)throw Error(tO(o,a.failures()[0],!1));var s=t.schema.filter(function(t){return(0,H.is)(e[r],t.schema[r])});(0,d.assert)(s.length>0,"Expected a struct to match the value.");var l=s.map(function(t){return(0,H.validate)(e,t,{coerce:n})}),u=l.find(function(e){return!tk(e,1)[0]});if(u)return u[1];throw(0,d.assert)(l[0][0],"Expected at least one error."),Error(tO(t,l.reduce(function(e,t){var r=tk(t,1)[0];return((0,d.assert)(r,"Expected an error."),r.failures().lengthe.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]1&&void 0!==a[1]?a[1]:p.Base64,[4,uT(nc)];case 1:if(n=s.sent(),i=t4(e),!(o=null===(r=n.find(function(e){return e.path===i}))||void 0===r?void 0:r.toString("base64")))return[2,null];return[4,uD(mz,o,t)];case 2:return[2,s.sent()]}})}function mQ(e,t){return mq(this,function(r){switch(r.label){case 0:return[4,uT(r9)];case 1:return[4,uD([r.sent(),"createInterface"],e,t)];case 2:return[2,r.sent()]}})}function mH(e,t){return mq(this,function(r){switch(r.label){case 0:return[4,uT(r9)];case 1:return[4,uD([r.sent(),"getInterface"],e,t)];case 2:return[2,r.sent()]}})}function mG(e,t,r){return mq(this,function(n){switch(n.label){case 0:return[4,uT(r9)];case 1:return[4,uD([n.sent(),"updateInterface"],e,t,r)];case 2:return n.sent(),[4,uD(mH,e,t)];case 3:return[4,ub(rG(mU({id:t},n.sent())))];case 4:return n.sent(),[2]}})}function mZ(e,t){return mq(this,function(r){switch(r.label){case 0:return[4,uT(r9)];case 1:return[4,uD([r.sent(),"getInterface"],e,t)];case 2:return[2,r.sent().state]}})}function mX(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function m0(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){mX(o,n,i,a,s,"next",e)}function s(e){mX(o,n,i,a,s,"throw",e)}a(void 0)})}}function m1(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]2?r-2:0),i=2;i0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]1&&void 0!==arguments[1]?arguments[1]:{};(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,r),hv(this,"cache",new Map),hv(this,"validatedManifest",void 0),hv(this,"url",void 0),hv(this,"fetchFn",void 0),hv(this,"fetchOptions",void 0),(0,d.assertStruct)(e.toString(),e3,"Invalid Snap Id: "),this.fetchFn=null!==(t=n.fetch)&&void 0!==t?t:globalThis.fetch.bind(void 0),this.fetchOptions=n.fetchOptions,this.url=e}return e=[{key:"manifest",value:function(){var e=this;return hg(function(){var t,r,n,i,o;return hx(this,function(a){switch(a.label){case 0:if(e.validatedManifest)return[2,e.validatedManifest.clone()];return t=new URL(cp.Manifest,e.url).toString(),[4,e.fetchFn(t,e.fetchOptions)];case 1:if(!(r=a.sent()).ok)throw Error('Failed to fetch "'.concat(t,'". Status code: ').concat(r.status,"."));return[4,r.text()];case 2:return i=e8(n=a.sent()),o=new eP({value:n,result:t3(i),path:cp.Manifest,data:{canonicalPath:t}}),e.validatedManifest=o,[2,e.manifest()]}})})()}},{key:"fetch",value:function(e){var t=this;return hg(function(){var r,n,i,o,a,s,l,u,c,p,_;return hx(this,function(f){switch(f.label){case 0:if(r=t4(e),!(void 0!==(n=t.cache.get(r))))return[3,2];return i=n.file,o=n.contents,s=Uint8Array.bind,[4,o.arrayBuffer()];case 1:return a=new(s.apply(Uint8Array,[void 0,f.sent()])),(l=i.clone()).value=a,[2,l];case 2:return u=t.toCanonical(r).toString(),[4,t.fetchFn(u,t.fetchOptions)];case 3:if(!(c=f.sent()).ok)throw Error('Failed to fetch "'.concat(u,'". Status code: ').concat(c.status,"."));return p=new eP({value:"",path:r,data:{canonicalPath:u}}),[4,c.blob()];case 4:return _=f.sent(),(0,d.assert)(!t.cache.has(r),"Corrupted cache, multiple files with same path."),t.cache.set(r,{file:p,contents:_}),[2,t.fetch(r)]}})})()}},{key:"root",get:function(){return new URL(this.url)}},{key:"toCanonical",value:function(e){return(0,d.assert)(!e.startsWith("/"),"Tried to parse absolute path."),new URL(e,this.url)}}],hb(r.prototype,e),t&&hb(r,t),r}();function hS(e,t,r,n,i,o,a){try{var s=e[o](a),l=s.value}catch(e){r(e);return}s.done?t(l):Promise.resolve(l).then(n,i)}function hE(e){return function(){var t=this,r=arguments;return new Promise(function(n,i){var o=e.apply(t,r);function a(e){hS(o,n,i,a,s,"next",e)}function s(e){hS(o,n,i,a,s,"throw",e)}a(void 0)})}}function hT(e,t,r){if(!t.has(e))throw TypeError("attempted to "+r+" private field on non-instance");return t.get(e)}function hw(e,t){var r=hT(e,t,"get");return r.get?r.get.call(e):r.value}function hA(e,t){for(var r=0;r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]1&&void 0!==arguments[1]?arguments[1]:{};(function(e,t){if(!(e instanceof t))throw TypeError("Cannot call a class as a function")})(this,r),function(e,t){if(t.has(e))throw TypeError("Cannot initialize the same private elements twice on an object")}(this,hM),hM.set(this,{writable:!0,value:void 0}),(0,d.assertStruct)(e.toString(),e1,"Invalid Snap Id"),(0,d.assert)(void 0===o.fetchOptions,"Currently adding fetch options to local: is unsupported."),i=new hD(new URL(e.toString().slice(c_.local.length)),(t=function(e){for(var t=1;t0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]e.length)&&(t=e.length);for(var r=0,n=Array(t);r0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0?[2,r.join("\n")]:[2,!0]})});return function(t,r){return e.apply(this,arguments)}}()},{name:"Checksum",manifestName:"source.shasum",validator:function(){var e=hY(function(e,t){var r,n,i,o,a,s,l;return hW(this,function(u){switch(u.label){case 0:if(r=t.sourceCode,n=t.icon,i=t.auxiliaryFiles,o=t.localizationFiles,!e)return[3,2];return s=null===(a=e.result)||void 0===a?void 0:a.source.shasum,[4,function(e){return eZ.apply(this,arguments)}({manifest:e,sourceCode:r,svgIcon:n,auxiliaryFiles:i,localizationFiles:o})];case 1:if(l=u.sent(),s!==l)return[2,'Checksum mismatch - expected "'.concat(l,'" got "').concat(s,'"')];u.label=2;case 2:return[2,!0]}})});return function(t,r){return e.apply(this,arguments)}}()},{name:"Bundle",manifestName:"filePath",validator:function(){var e=hY(function(e,t){var r,n,i,o,a,s,l;return hW(this,function(u){return(r=t.sourceCode,l=hV(t2.schema.source.schema.location.schema.npm.schema.filePath.validate(null===(s=e)||void 0===s?void 0:null===(a=s.result)||void 0===a?void 0:null===(o=a.source)||void 0===o?void 0:null===(i=o.location)||void 0===i?void 0:null===(n=i.npm)||void 0===n?void 0:n.filePath),1)[0])?[2,l.message]:r?[2,!0]:[2,"Unable to load bundle."]})});return function(t,r){return e.apply(this,arguments)}}()}];function hH(e,t){var r,n,i,o,a={label:0,sent:function(){if(1&i[0])throw i[1];return i[1]},trys:[],ops:[]};return o={next:s(0),throw:s(1),return:s(2)},"function"==typeof Symbol&&(o[Symbol.iterator]=function(){return this}),o;function s(o){return function(s){return function(o){if(r)throw TypeError("Generator is already executing.");for(;a;)try{if(r=1,n&&(i=2&o[0]?n.return:o[0]?n.throw||((i=n.return)&&i.call(n),0):n.next)&&!(i=i.call(n,o[1])).done)return i;switch(n=0,i&&(o=[2&o[0],i.value]),o[0]){case 0:case 1:i=o;break;case 4:return a.label++,{value:o[1],done:!1};case 5:a.label++,n=o[1],o=[0];continue;case 7:o=a.ops.pop(),a.trys.pop();continue;default:if(!(i=(i=a.trys).length>0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]0&&i[i.length-1])&&(6===o[0]||2===o[0])){a=0;continue}if(3===o[0]&&(!i||o[1]>i[0]&&o[1]