@fileverse-dev/ddoc 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/index.es.js +6 -4
- package/dist/index.umd.js +2 -2
- package/package.json +1 -1
package/dist/index.umd.js
CHANGED
@@ -369,7 +369,7 @@ img.ProseMirror-separator {
|
|
369
369
|
*
|
370
370
|
* This source code is licensed under the ISC license.
|
371
371
|
* See the LICENSE file in the root directory of this source tree.
|
372
|
-
*/const QE=Re("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]),lF=({editor:n,isOpen:e,setIsOpen:t})=>{const r=[{name:"Text",icon:KE,command:()=>n.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{name:"Heading 1",icon:c0,command:()=>n.chain().focus().toggleHeading({level:1}).run(),isActive:()=>n.isActive("heading",{level:1})},{name:"Heading 2",icon:u0,command:()=>n.chain().focus().toggleHeading({level:2}).run(),isActive:()=>n.isActive("heading",{level:2})},{name:"Heading 3",icon:f0,command:()=>n.chain().focus().toggleHeading({level:3}).run(),isActive:()=>n.isActive("heading",{level:3})},{name:"To-do List",icon:WE,command:()=>n.chain().focus().toggleTaskList().run(),isActive:()=>n.isActive("taskItem")},{name:"Bullet List",icon:ff,command:()=>n.chain().focus().toggleBulletList().run(),isActive:()=>n.isActive("bulletList")},{name:"Numbered List",icon:ff,command:()=>n.chain().focus().toggleOrderedList().run(),isActive:()=>n.isActive("orderedList")},{name:"Quote",icon:h0,command:()=>n.chain().focus().toggleNode("paragraph","paragraph").toggleBlockquote().run(),isActive:()=>n.isActive("blockquote")},{name:"Code",icon:Rh,command:()=>n.chain().focus().toggleCode().run(),isActive:()=>n.isActive("code")}],s=r.filter(i=>i.isActive()).pop()??{name:"Multiple"};return _.jsxs("div",{className:"relative h-full",children:[_.jsxs("button",{className:"flex h-full items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200",onClick:()=>t(!e),children:[_.jsx("span",{children:s==null?void 0:s.name}),_.jsx(Mh,{className:"h-4 w-4"})]}),e&&_.jsx("section",{className:"fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1",children:r.map((i,o)=>_.jsxs("button",{onClick:()=>{i.command(),t(!1)},className:je("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":i.isActive()}),children:[_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx("div",{className:"rounded-sm border border-stone-200 p-1",children:_.jsx(i.icon,{className:"h-3 w-3"})}),_.jsx("span",{children:i.name})]}),s.name===i.name&&_.jsx(Nh,{className:"h-4 w-4"})]},o))})]})},cF=({editor:n,isOpen:e,setIsOpen:t})=>{const r=[{name:"Default",color:"#000000"},{name:"Purple",color:"#9333EA"},{name:"Red",color:"#E00000"},{name:"Blue",color:"#2563EB"},{name:"Green",color:"#008A00"},{name:"Orange",color:"#FFA500"},{name:"Pink",color:"#BA4081"},{name:"Gray",color:"#A8A29E"}],s=r.find(({color:i})=>n.isActive("textStyle",{color:i}));return _.jsxs("div",{className:"",children:[_.jsxs("button",{className:"flex h-[100%] items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200",onClick:()=>t(!e),children:[_.jsx("span",{style:{color:(s==null?void 0:s.color)||"#000000"},children:"A"}),_.jsx(Mh,{className:"h-4 w-4 "})]}),e&&_.jsx("section",{className:"fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1",children:r.map(({name:i,color:o},a)=>_.jsxs("button",{onClick:()=>{n.chain().focus().setColor(o).run(),t(!1)},className:je("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":n.isActive("textStyle",{color:o})}),children:[_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx("div",{className:"rounded-sm border border-stone-200 px-1 py-px font-medium",style:{color:o},children:"A"}),_.jsx("span",{children:i})]}),n.isActive("textStyle",{color:o})&&_.jsx(Nh,{className:"h-4 w-4"})]},a))})]})};var Te=(n=>(n[n.NONE=0]="NONE",n[n.HEADING=1]="HEADING",n[n.TEXT_COLOR=2]="TEXT_COLOR",n[n.HIGHLIGHT=3]="HIGHLIGHT",n[n.LINK=4]="LINK",n[n.FONT_FAMILY=5]="FONT_FAMILY",n[n.ALIGNMENT=6]="ALIGNMENT",n[n.LIST=7]="LIST",n))(Te||{});function uF(n){const[e,t]=R.useState(n),r=R.useRef(null),s=i=>{r&&r.current&&!r.current.contains(i.target)&&t(0)};return R.useEffect(()=>(document.addEventListener("click",s,!0),()=>{document.removeEventListener("click",s,!0)}),[]),{ref:r,toolVisibilty:e,setToolVisibility:t}}const Ph=new vt("upload-image"),fF=()=>new ut({key:Ph,state:{init(){return ft.empty},apply(n,e){e=e.map(n.mapping,n.doc);const t=n.getMeta(this);if(t&&t.add){const{id:r,pos:s,src:i}=t.add,o=document.createElement("div");o.setAttribute("class","img-placeholder");const a=document.createElement("img");a.setAttribute("class","rounded-lg border border-stone-200"),a.src=i,o.appendChild(a);const l=Ht.widget(s+1,o,{id:r});e=e.add(n.doc,[l])}else t&&t.remove&&(e=e.remove(e.find(void 0,void 0,r=>r.id==t.remove.id)));return e}},props:{decorations(n){return this.getState(n)}}});function dF(n,e){const r=Ph.getState(n).find(null,null,s=>s.id==e);return r.length?r[0].from:null}function YE(n,e,t){if(n.type.includes("image/")){if(n.size>1024*1024){console.log("failed");return}}else{console.log("file is not an image");return}const r={},s=e.state.tr;s.selection.empty||s.deleteSelection();const i=new FileReader;i.readAsDataURL(n),i.onload=()=>{s.setMeta(Ph,{add:{id:r,pos:t,src:i.result}}),e.dispatch(s)},hF(n).then(o=>{const{schema:a}=e.state,l=dF(e.state,r);if(l==null)return;const c=typeof o=="object"?i.result:o,u=a.nodes.resizableMedia.create({src:c,"media-type":"img"}),f=e.state.tr.replaceWith(l-2,l+u.nodeSize,u).setMeta(Ph,{remove:{id:r}});e.dispatch(f)})}const hF=n=>new Promise(e=>{const t=new FileReader;t.readAsDataURL(n),t.onload=()=>e(t.result)}),pF=async n=>{const e=new FileReader;if(e.readAsDataURL(n),n.size>1024*1024)throw e.abort(),console.log("should be less than 1 mb"),new Error("Image too large");return await new Promise(r=>{e.onload=()=>{r(e.result)}})},XE=[{title:"Trebuchet MS",value:"Trebuchet MS, sans-serif",command:n=>{n.chain().focus().setFontFamily("Trebuchet MS, sans-serif").run()}},{title:"Verdana",value:"Verdana, Geneva, sans-serif",command:n=>{n.chain().focus().setFontFamily("Verdana, Geneva, sans-serif").run()}},{title:"Georgia",value:"Georgia, serif",command:n=>{n.chain().focus().setFontFamily("Georgia, serif").run()}},{title:"Arial",value:"Arial, Helvetica, sans-serif",command:n=>{n.chain().focus().setFontFamily("Arial, Helvetica, sans-serif").run()}},{title:"Comic Sans MS",value:"Comic Sans MS, Comic Sans",command:n=>{n.chain().focus().setFontFamily("Comic Sans MS, Comic Sans").run()}},{title:"Impact",value:"Impact, Charcoal, sans-serif",command:n=>{n.chain().focus().setFontFamily("Impact, Charcoal, sans-serif").run()}},{title:"Palatino",value:"Palatino Linotype, Book Antiqua, Palatino, serif",command:n=>{n.chain().focus().setFontFamily("Palatino Linotype, Book Antiqua, Palatino, serif").run()}},{title:"Lucida Grande",value:"Lucida Sans Unicode, Lucida Grande, sans-serif",command:n=>{n.chain().focus().setFontFamily("Lucida Sans Unicode, Lucida Grande, sans-serif").run()}},{title:"Serif",value:"serif",command:n=>{n.chain().focus().setFontFamily("serif").run()}},{title:"Monospace",value:"monospace",command:n=>{n.chain().focus().setFontFamily("monospace").run()}},{title:"Cursive",value:"cursive",command:n=>{n.chain().focus().setFontFamily("cursive").run()}}],ZE=({editor:n})=>{const{ref:e,toolVisibilty:t,setToolVisibility:r}=uF(Te.NONE);return{toolbar:[{icon:_.jsx(WB,{size:20}),title:"Text Color",onClick:()=>r(Te.TEXT_COLOR),isActive:t===Te.TEXT_COLOR},{icon:_.jsx(jE,{size:20}),title:"Highlight",onClick:()=>r(Te.HIGHLIGHT),isActive:t===Te.HIGHLIGHT},null,{icon:_.jsx(UE,{size:20}),title:"Bold",onClick:()=>n==null?void 0:n.chain().focus().toggleBold().run(),isActive:n==null?void 0:n.isActive("bold")},{icon:_.jsx($E,{size:20}),title:"Italic",onClick:()=>n==null?void 0:n.chain().focus().toggleItalic().run(),isActive:n==null?void 0:n.isActive("italic")},{icon:_.jsx(qE,{size:20}),title:"Underlined",onClick:()=>n==null?void 0:n.chain().focus().toggleUnderline().run(),isActive:n==null?void 0:n.isActive("underline")},{icon:_.jsx(GE,{size:20}),title:"Strikethrough",onClick:()=>n==null?void 0:n.chain().focus().toggleStrike().run(),isActive:n==null?void 0:n.isActive("strike")},null,{icon:_.jsx(d0,{size:20}),title:"List",onClick:()=>{n==null||n.chain().focus().toggleBulletList().run(),r(Te.NONE)},isActive:t===Te.LIST},{icon:_.jsx(ff,{size:20}),title:"Ordered List",onClick:()=>{n==null||n.chain().focus().toggleOrderedList().run(),r(Te.NONE)},isActive:t===Te.LIST},{icon:_.jsx(VE,{size:20}),title:"To-do List",onClick:()=>{n==null||n.chain().focus().toggleTaskList().run(),r(Te.NONE)},isActive:t===Te.LIST},{icon:_.jsx(l0,{size:20}),title:"Alignment",onClick:()=>r(Te.ALIGNMENT),isActive:t===Te.ALIGNMENT},{icon:_.jsx(h0,{size:20}),title:"Quote",onClick:()=>n==null?void 0:n.chain().focus().toggleBlockquote().run(),isActive:n==null?void 0:n.isActive("blockquote")},null,{icon:_.jsx(YB,{size:20}),title:"Upload Image",onClick:()=>{n==null||n.chain().focus().deleteRange(n.state.selection).run();const i=document.createElement("input");i.type="file",i.accept="image/*",i.onchange=async()=>{var o;if((o=i.files)!=null&&o.length){const a=i.files[0],l=n.view.state.selection.from;YE(a,n.view,l)}},i.click()},isActive:!1},{icon:_.jsx(zE,{size:20}),title:"Link",onClick:()=>r(Te.LINK),isActive:n==null?void 0:n.isActive("link")},{icon:_.jsx(Rh,{size:20}),title:"Code",onClick:()=>n==null?void 0:n.chain().focus().toggleCodeBlock().run(),isActive:n==null?void 0:n.isActive("codeBlock")}],toolRef:e,toolVisibilty:t,setToolVisibility:r}},ek=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return _.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[20%] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all",children:[_.jsx(FE,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetHighlight().run(),e(Te.NONE)}}),r.map(s=>_.jsx("div",{onClick:()=>{n.chain().focus().toggleHighlight({color:s.color}).run(),e(Te.NONE)},className:je("w-6 drop-shadow rounded-full flex items-center justify-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",s.code),children:_.jsx(Nh,{size:14,className:je(n.isActive("highlight",{color:s.color})?"visible":"invisible")})},s.color))]})},mF=({elementRef:n,editor:e,setToolVisibility:t})=>_.jsx("div",{ref:n,className:je("z-50 h-auto absolute top-[50px] left-0 max-h-[330px] w-48 overflow-y-auto scroll-smooth bg-white px-1 py-2 shadow-elevation-3 transition-all animate-in fade-in slide-in-from-top-1"),children:XE.map(r=>_.jsx("button",{onClick:()=>{r.command(e),t(Te.NONE)},style:{fontFamily:r.title},className:je("flex w-full items-center space-x-2 rounded px-2 py-1 text-left text-sm color-text-default",e.isActive("textStyle",{fontFamily:r.value})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:_.jsx("p",{className:"font-medium",children:r.title})},r.title))}),tk=({elementRef:n,editor:e,setToolVisibility:t})=>_.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-[50px] right-[25%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all",children:[_.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("left").run(),t(Te.NONE)},className:je("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer",e.isActive({textAlign:"left"})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:_.jsx(l0,{})}),_.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("center").run(),t(Te.NONE)},className:je("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer",e.isActive({textAlign:"center"})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:_.jsx(zB,{})}),_.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("right").run(),t(Te.NONE)},className:je("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer",e.isActive({textAlign:"right"})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:_.jsx(VB,{})})]}),gF=({elementRef:n,editor:e,setToolVisibility:t})=>_.jsxs("div",{ref:n,className:je("z-50 h-auto absolute gap-2 top-[50px] right-[30%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all"),children:[_.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"unordered list",children:_.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleBulletList().run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("bulletList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:_.jsx(d0,{size:20})})}),_.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"ordered list",children:_.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleOrderedList().run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("orderedList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:_.jsx(ff,{size:20})})}),_.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"to-do list",children:_.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleTaskList().run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("taskList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:_.jsx(VE,{size:20})})})]}),nk=({elementRef:n,editor:e,setToolVisibility:t,bubbleMenu:r,setIsLinkPopupOpen:s})=>{const[i,o]=R.useState(e.getAttributes("link").href),a=()=>{if(i===null)return;if(i===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}let l=i;!i.startsWith("http://")&&!i.startsWith("https://")&&(l="https://"+i);try{l.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&e.chain().focus().extendMarkRange("link").setLink({href:l}).run()}catch{console.error("Invalid URL");return}e.chain().focus().extendMarkRange("link").setLink({href:l}).run(),t(Te.NONE),r&&s&&s(!1)};return _.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-[50px] items-center flex right-[10%] max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white p-2 shadow-elevation-3 transition-all",children:[_.jsx("input",{onChange:l=>o(l.target.value),className:"shadow-none border-[1px]",placeholder:"Add link here",value:i}),_.jsx("div",{className:"h-full flex items-center",children:_.jsx("button",{onClick:()=>a(),className:"min-w-fit",children:"Apply"})})]})},yF=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return _.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[100px] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all",children:[_.jsx(FE,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetColor().run(),e(Te.NONE)}}),r.map(s=>_.jsx("div",{onClick:()=>{n.chain().focus().setColor(s.color).run(),e(Te.NONE)},className:je("w-6 drop-shadow rounded-full flex justify-center items-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",s.code),children:_.jsx(Nh,{size:14,className:je(n.isActive("textStyle",{color:s.color})?"visible":"invisible")})},s.color))]})},bF=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{title:"Text",description:"Normal",icon:_.jsx(aF,{size:20}),command:s=>s.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{title:"Heading 1",description:"Big",icon:_.jsx(c0,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:1}).run()},isActive:()=>n.isActive("heading",{level:1})},{title:"Heading 2",description:"Medium",icon:_.jsx(u0,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:2}).run()},isActive:()=>n.isActive("heading",{level:2})},{title:"Heading 3",description:"Small",icon:_.jsx(f0,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:3}).run()},isActive:()=>n.isActive("heading",{level:3})}];return _.jsx("div",{ref:t,className:je("absolute top-[50px] z-50 mt-1 flex w-48 flex-col overflow-hidden rounded bg-white p-1 shadow-elevation-3 animate-in fade-in slide-in-from-top-1","left-0"),children:r.map(s=>_.jsxs("button",{onClick:()=>{s.command(n),e(Te.NONE)},className:je("flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm color-text-default",{"color-bg-brand hover:color-bg-brand-hover":s.isActive(),"hover:bg-[#f2f2f2]":!s.isActive()}),children:[_.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded bg-white",children:s.icon}),_.jsxs("div",{children:[_.jsx("p",{className:"font-medium",children:s.title}),_.jsxs("p",{className:"text-xs text-stone-500",children:[" ",s.description," "]})]})]},s.title))})},wF=n=>{const e=[{name:"Bold",isActive:()=>n.editor.isActive("bold"),command:()=>n.editor.chain().focus().toggleBold().run(),icon:_.jsx(UE,{size:20})},{name:"Italic",isActive:()=>n.editor.isActive("italic"),command:()=>n.editor.chain().focus().toggleItalic().run(),icon:_.jsx($E,{size:20})},{name:"Underline",isActive:()=>n.editor.isActive("underline"),command:()=>n.editor.chain().focus().toggleUnderline().run(),icon:_.jsx(qE,{size:20})},{name:"Strikethrough",isActive:()=>n.editor.isActive("strike"),command:()=>n.editor.chain().focus().toggleStrike().run(),icon:_.jsx(GE,{size:20})},{name:"Alignment",isActive:()=>f===Te.ALIGNMENT,command:()=>u(Te.ALIGNMENT),icon:_.jsx(l0,{size:20})},{name:"Code",isActive:()=>n.editor.isActive("codeBlock"),command:()=>n.editor.chain().focus().toggleCodeBlock().run(),icon:_.jsx(Rh,{size:20})},{name:"Link",isActive:()=>n.editor.isActive("link"),command:()=>l(!a),icon:_.jsx(zE,{size:20})}],t={...n,shouldShow:({state:d,editor:h})=>{const{selection:p}=d,{empty:g}=p;return!(h.isActive("image")||g||Ux(p))},tippyOptions:{moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",onHidden:()=>{s(!1),o(!1),l(!1)}}},[r,s]=R.useState(!1),[i,o]=R.useState(!1),[a,l]=R.useState(!1),{toolRef:c,setToolVisibility:u,toolVisibilty:f}=ZE({editor:n.editor});return _.jsxs(RE,{...t,className:"flex gap-1 overflow-hidden rounded-[12px] h-[52px] min-w-[472px] w-full py-2 px-4 bg-white items-center shadow-elevation-3",children:[_.jsx(lF,{editor:n.editor,isOpen:r,setIsOpen:()=>{s(!r),o(!1)}}),_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"}),e.map((d,h)=>_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("button",{onClick:d.command,className:je("min-w-fit w-8 h-8 px-2",{"color-bg-brand":d.isActive()}),children:d.icon}),(h===4||h===6)&&_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"})]},h)),_.jsx(cF,{editor:n.editor,isOpen:i,setIsOpen:()=>{o(!i),s(!1)}}),_.jsx("button",{onClick:()=>u(Te.HIGHLIGHT),className:je("min-w-fit w-8 h-8 px-2",{"color-bg-brand":f===Te.HIGHLIGHT}),children:_.jsx(jE,{size:20})}),f===Te.ALIGNMENT&&_.jsx(tk,{setToolVisibility:u,editor:n.editor,elementRef:c}),a&&_.jsx(nk,{setToolVisibility:u,editor:n.editor,elementRef:c,bubbleMenu:!0,setIsLinkPopupOpen:l}),f===Te.HIGHLIGHT&&_.jsx(ek,{setVisibility:u,editor:n.editor,elementRef:c})]})};function vF(){const n=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let t=0;t<36;t++)t===8||t===13||t===18||t===23?e[t]="-":e[t]=n[Math.ceil(Math.random()*n.length-1)];return e.join("")}var AF=vF;const xF=_g(AF),rk=dt.create({name:"column",content:"dBlock+",isolating:!0,addAttributes(){return{position:{default:"",parseHTML:n=>n.getAttribute("data-position"),renderHTML:n=>({"data-position":n.position})}}},renderHTML({HTMLAttributes:n}){return["div",Ue(n,{"data-type":"column"}),0]},parseHTML(){return[{tag:'div[data-type="column"]'}]}}),EF=(n,e)=>Array.from({length:n},(t,r)=>e(r)),Dh=({type:n,content:e})=>e?{type:n,content:e}:{type:n},kF=({content:n})=>Dh({type:"paragraph",content:n}),sk=({content:n})=>Dh({type:"dBlock",content:n}),ik=({content:n})=>Dh({type:"column",content:n}),ok=({content:n})=>Dh({type:"columns",content:n}),ak=n=>{const e=[sk({content:[kF({})]})];return EF(n,()=>ik({content:e}))},lk=(n,e)=>{for(let t=n.depth;t>0;t--){const r=n.node(t),s=t>0?n.before(t):0,i=n.start(t);if(e({node:r,pos:s,start:i}))return{start:i,depth:t,node:r,pos:s}}throw Error("no ancestor found")};class Ih extends xe{constructor(t){const{$from:r,$to:s}=t;super(r,s);j(this,"_$from");j(this,"_$to");this._$from=r,this._$to=s}get $from(){return this._$from}get $to(){return this._$to}map(){return this}content(){return this.$from.doc.slice(this.from,this.to,!0)}eq(t){return t instanceof Ih&&t.anchor==this.anchor}toJSON(){return{type:"column",from:this.from,to:this.to}}expandSelection(t){var l;const r=({pos:c,node:u})=>u.type.name===rk.name?!0:t.resolve(c).depth<=0,{pos:s}=lk(this.$from,r);this._$from=t.resolve(s);const{pos:i,node:o}=lk(this.$to,r);this._$to=t.resolve(i+o.nodeSize),((l=this.getFirstNode())==null?void 0:l.type.name)===_h.name&&(this._$from=t.resolve(this.$from.pos+2),this._$to=t.resolve(this.$to.pos+2));const a=this;a.$anchor=this._$from,a.$head=this._$to,a.ranges=[new Xg(this._$from,this._$to)]}static create(t,r,s){const i=t.resolve(r),o=t.resolve(s),a=new Ae(i,o);return new Ih(a)}getFirstNode(){return this.content().content.firstChild}}var Zo=(n=>(n.AlignLeft="align-left",n.AlignRight="align-right",n.AlignCenter="align-center",n))(Zo||{});const _h=dt.create({name:"columns",group:"columns",content:"column{2,}",defining:!0,draggable:!0,isolating:!0,addAttributes(){return{layout:{default:"align-center"}}},addCommands(){return{unsetColumns:()=>({tr:n,dispatch:e})=>{try{if(!e)return;const t=n.selection.$from,s=By(t,({node:l})=>!this.options.nestedColumns&&l.type==this.type?!0:l.type==this.type);if(s===void 0)return;let i=[];s.node.descendants((l,c,u)=>{(u==null?void 0:u.type.name)===_h.name&&i.push(l)}),i=i.reverse().filter(l=>l.content.size>0);const o=n.doc.resolve(s.pos),a=new ye(o);return n=n.setSelection(a),i.forEach(l=>n=n.insert(s.pos,l)),n=n.deleteSelection(),e(n)}catch(t){console.error(t)}},setColumns:(n,e=!1)=>({tr:t,dispatch:r})=>{try{const{doc:s,selection:i}=t;if(!r){console.log("no dispatch");return}const o=new Ih(i);o.expandSelection(s);const{openStart:a,openEnd:l}=o.content();if(a!==l){console.warn("failed depth check");return}let c;if(e){const h=o.content().toJSON(),p=ik(h),g=ak(n-1);c=ok({content:[p,...g]})}else{const h=ak(n);c=ok({content:h})}const u=s.type.schema.nodeFromJSON(sk({content:[c]}));if(u===null)return;const f=o.$anchor.parent.type;if(!(h=>!(!h.contentMatch.matchType(this.type)||!this.options.nestedColumns&&h.name===_h.name))(f)){console.warn("content not allowed");return}return t=t.setSelection(o),t=t.replaceSelectionWith(u,!1),r(t)}catch(s){console.error(s)}},setLayout:n=>({commands:e})=>e.updateAttributes("columns",{layout:n})}},renderHTML({HTMLAttributes:n}){return["div",{"data-type":"columns",class:`layout-${n.layout}`},0]},parseHTML(){return[{tag:'div[data-type="columns"]'}]}}),CF=(n,e)=>{const{view:t,state:{selection:{from:r}}}=n,s=document.querySelectorAll(".has-focus"),i=s.length,a=s[i-1];if(a&&a.getAttribute("data-type")&&a.getAttribute("data-type")===e||a&&a.classList&&a.classList.contains(e))return a;const l=t.domAtPos(r).node;let c=l;for(c.tagName||(c=l.parentElement);c&&!(c.getAttribute("data-type")&&c.getAttribute("data-type")===e)&&!c.classList.contains(e);)c=c.parentElement;return c},p0=R.forwardRef(({children:n,className:e,withShadow:t=!0,withBorder:r=!0,...s},i)=>{const o=je(e,"bg-white rounded-md",t?"shadow-md":"",r?"border border-neutral-200":"");return _.jsx("div",{className:o,...s,ref:i,children:n})});p0.displayName="Surface";const ck=R.forwardRef(({active:n,buttonSize:e="medium",children:t,disabled:r,variant:s="primary",className:i,activeClassname:o,...a},l)=>{const c=je("flex group items-center justify-center border border-transparent gap-2 text-sm font-semibold rounded disabled:opacity-50 whitespace-nowrap",s==="primary"&&je("text-white bg-black border-black dark:text-black dark:bg-white dark:border-white",!r&&!n&&"hover:bg-neutral-800 active:bg-neutral-900 dark:hover:bg-neutral-200 dark:active:bg-neutral-300",n&&je("bg-neutral-900 dark:bg-neutral-300",o)),s==="secondary"&&je("text-neutral-900 dark:text-white",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-900 dark:active:bg-neutral-800",n&&"bg-neutral-200 dark:bg-neutral-800"),s==="tertiary"&&je("bg-neutral-50 text-neutral-900 dark:bg-neutral-900 dark:text-white dark:border-neutral-900",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-800 dark:active:bg-neutral-700",n&&je("bg-neutral-200 dark:bg-neutral-800",o)),s==="ghost"&&je("bg-transparent border-transparent text-neutral-500",!r&&!n&&"hover:bg-black/5 hover:text-neutral-700 active:bg-black/10 active:text-neutral-800 ",n&&je("bg-black/10 text-neutral-800 ",o)),e==="medium"&&"py-2 px-3",e==="small"&&"py-1 px-2",e==="icon"&&"w-8 h-8",e==="iconSmall"&&"w-6 h-6",i);return _.jsx("button",{ref:l,disabled:r,className:c,...a,children:t})});ck.displayName="Button";const uk=({content:n,children:e})=>{const[t,r]=R.useState(!1);return _.jsxs("div",{className:"relative inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e,t&&_.jsx("div",{className:"absolute z-10 p-2 mt-2 text-sm text-white bg-gray-800 rounded shadow-lg",children:n})]})},fk=R.forwardRef(({shouldShowContent:n=!0,children:e,isVertical:t=!1,className:r,...s},i)=>{const o=je("text-black inline-flex h-full leading-none gap-0.5",t?"flex-col p-2":"flex-row p-1 items-center",r);return n?n&&_.jsx(p0,{className:o,...s,ref:i,children:e}):null});fk.displayName="Toolbar";const dk=R.forwardRef(({horizontal:n,className:e,...t},r)=>{const s=je("bg-neutral-200",n?"w-full min-w-[1.5rem] h-[1px] my-1 first:mt-0 last:mt-0":"h-full min-h-[1.5rem] w-[1px] mx-1 first:ml-0 last:mr-0",e);return _.jsx("div",{className:s,ref:r,...t})});dk.displayName="Toolbar.Divider";const hk=R.forwardRef(({children:n,buttonSize:e="icon",variant:t="ghost",className:r,tooltip:s,activeClassname:i,...o},a)=>{const l=je("gap-1 min-w-[2rem] px-2 w-auto",r),c=_.jsx(ck,{activeClassname:i,className:l,variant:t,buttonSize:e,ref:a,...o,children:n});return s?_.jsx(uk,{content:s,children:c}):c});hk.displayName="ToolbarButton";const df={Wrapper:fk,Divider:dk,Button:hk},SF=({editor:n,appendTo:e})=>{const t=R.useCallback(()=>{const a=CF(n,"columns");return(a==null?void 0:a.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},[n]),r=R.useCallback(()=>n.isActive("columns"),[n]),s=R.useCallback(()=>{n.chain().focus().setLayout(Zo.AlignLeft).run()},[n]),i=R.useCallback(()=>{n.chain().focus().setLayout(Zo.AlignRight).run()},[n]),o=R.useCallback(()=>{n.chain().focus().setLayout(Zo.AlignCenter).run()},[n]);return _.jsx(RE,{editor:n,pluginKey:`columnsMenu-${xF()}`,shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:t,moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",appendTo:()=>e==null?void 0:e.current,plugins:[TB],sticky:"popper"},children:_.jsxs(df.Wrapper,{children:[_.jsx(df.Button,{tooltip:"Align left",active:n.isActive("columns",{layout:Zo.AlignLeft}),onClick:s,children:_.jsx(eF,{size:20})}),_.jsx(df.Button,{tooltip:"Align center",active:n.isActive("columns",{layout:Zo.AlignCenter}),onClick:o,children:_.jsx(HE,{size:20})}),_.jsx(df.Button,{tooltip:"Align right",active:n.isActive("columns",{layout:Zo.AlignRight}),onClick:i,children:_.jsx(tF,{size:20})})]})})},pk=R.createContext(null),Lh=()=>R.useContext(pk),TF=({children:n,isPreviewMode:e})=>_.jsx(pk.Provider,{value:e,children:n}),mk=({height:n,width:e})=>_.jsx("span",{className:"flex items-center justify-center ",children:_.jsx("span",{className:`${e?`w-${e}`:"w-8"} ${n?`h-${n}`:"h-8"} border-4 border-t-4 border-t-[#ccc] border-gray-500 rounded-full animate-spin`})}),OF=({editor:n})=>{var i;const{toolRef:e,toolVisibilty:t,setToolVisibility:r,toolbar:s}=ZE({editor:n});return _.jsxs("div",{className:"w-fit bg-transparent px-4 items-center h-16 flex gap-1 justify-center",children:[_.jsxs("button",{className:"bg-transparent flex items-center gap-2 min-w-[55px]",onClick:()=>r(Te.FONT_FAMILY),children:[_.jsx("span",{className:"text-sm",children:((i=XE.find(o=>n==null?void 0:n.isActive("textStyle",{fontFamily:o.value})))==null?void 0:i.title)||"Font"}),_.jsx(Mh,{size:16})]}),_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"}),_.jsxs("button",{className:"bg-transparent gap-2 flex items-center min-w-[55px]",onClick:()=>r(Te.HEADING),children:[_.jsx("span",{className:"text-sm",children:n!=null&&n.isActive("heading",{level:1})?"Heading 1":n!=null&&n.isActive("heading",{level:2})?"Heading 2":n!=null&&n.isActive("heading",{level:3})?"Heading 3":"Text"}),_.jsx(Mh,{size:16})]}),_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"}),s.map(o=>o?_.jsx("div",{className:"tooltip tooltip-bottom","data-tip":o.title,children:_.jsx("span",{onClick:()=>o.onClick(),className:je("rounded-lg w-8 h-8 p-1 flex cursor-pointer justify-center items-center",o.isActive?"bg-yellow-300":"hover:bg-[#f2f2f2]"),children:typeof o.icon=="string"?_.jsx("img",{src:o.icon,className:"w-4"}):o.icon})},o.title):_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"})),t===Te.FONT_FAMILY&&_.jsx(mF,{setToolVisibility:r,editor:n,elementRef:e}),t===Te.HEADING&&_.jsx(bF,{setVisibility:r,editor:n,elementRef:e}),t===Te.TEXT_COLOR&&_.jsx(yF,{setVisibility:r,editor:n,elementRef:e}),t===Te.HIGHLIGHT&&_.jsx(ek,{setVisibility:r,editor:n,elementRef:e}),t===Te.ALIGNMENT&&_.jsx(tk,{setToolVisibility:r,editor:n,elementRef:e}),t===Te.LIST&&_.jsx(gF,{setToolVisibility:r,editor:n,elementRef:e}),t===Te.LINK&&_.jsx(nk,{setToolVisibility:r,editor:n,elementRef:e})]})},En=()=>new Map,m0=n=>{const e=En();return n.forEach((t,r)=>{e.set(r,t)}),e},Hn=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},NF=(n,e)=>{const t=[];for(const[r,s]of n)t.push(e(s,r));return t},MF=(n,e)=>{for(const[t,r]of n)if(e(r,t))return!0;return!1},Ws=()=>new Set,g0=n=>n[n.length-1],RF=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},Gs=Array.from,PF=(n,e)=>{for(let t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1},y0=Array.isArray;class b0{constructor(){this._observers=En()}on(e,t){return Hn(this._observers,e,Ws).add(t),t}once(e,t){const r=(...s)=>{this.off(e,r),t(...s)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return Gs((this._observers.get(e)||En()).values()).forEach(r=>r(...t))}destroy(){this._observers=En()}}class w0{constructor(){this._observers=En()}on(e,t){Hn(this._observers,e,Ws).add(t)}once(e,t){const r=(...s)=>{this.off(e,r),t(...s)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return Gs((this._observers.get(e)||En()).values()).forEach(r=>r(...t))}destroy(){this._observers=En()}}const _r=Math.floor,Bh=Math.abs,DF=Math.log10,zi=(n,e)=>n<e?n:e,Ks=(n,e)=>n>e?n:e,gk=n=>n!==0?n<0:1/n<0,ds=Date.now,IF=1200,_F=2500,Fh=3e4,v0=n=>{if(n.shouldConnect&&n.ws===null){const e=new WebSocket(n.url),t=n.binaryType;let r=null;t&&(e.binaryType=t),n.ws=e,n.connecting=!0,n.connected=!1,e.onmessage=o=>{n.lastMessageReceived=ds();const a=o.data,l=typeof a=="string"?JSON.parse(a):a;l&&l.type==="pong"&&(clearTimeout(r),r=setTimeout(i,Fh/2)),n.emit("message",[l,n])};const s=o=>{n.ws!==null&&(n.ws=null,n.connecting=!1,n.connected?(n.connected=!1,n.emit("disconnect",[{type:"disconnect",error:o},n])):n.unsuccessfulReconnects++,setTimeout(v0,zi(DF(n.unsuccessfulReconnects+1)*IF,_F),n)),clearTimeout(r)},i=()=>{n.ws===e&&n.send({type:"ping"})};e.onclose=()=>s(null),e.onerror=o=>s(o),e.onopen=()=>{n.lastMessageReceived=ds(),n.connecting=!1,n.connected=!0,n.unsuccessfulReconnects=0,n.emit("connect",[{type:"connect"},n]),r=setTimeout(i,Fh/2)}}};class LF extends w0{constructor(e,{binaryType:t}={}){super(),this.url=e,this.ws=null,this.binaryType=t||null,this.connected=!1,this.connecting=!1,this.unsuccessfulReconnects=0,this.lastMessageReceived=0,this.shouldConnect=!0,this._checkInterval=setInterval(()=>{this.connected&&Fh<ds()-this.lastMessageReceived&&this.ws.close()},Fh/2),v0(this)}send(e){this.ws&&this.ws.send(JSON.stringify(e))}destroy(){clearInterval(this._checkInterval),this.disconnect(),super.destroy()}disconnect(){this.shouldConnect=!1,this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.connected&&this.ws===null&&v0(this)}}const Lr=n=>new Error(n),Br=()=>{throw Lr("Method unimplemented")},gr=()=>{throw Lr("Unexpected case")},yk=1,bk=2,A0=4,x0=8,hf=32,Js=64,Zn=128,Uh=31,E0=63,ea=127,BF=2147483647,FF=crypto.getRandomValues.bind(crypto),wk=Math.random,vk=()=>FF(new Uint32Array(1))[0],UF=n=>n[_r(wk()*n.length)],HF="10000000-1000-4000-8000"+-1e11,Ak=()=>HF.replace(/[018]/g,n=>(n^vk()&15>>n/4).toString(16)),xk=Number.MAX_SAFE_INTEGER,jF=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&_r(n)===n),$F=String.fromCharCode,zF=n=>n.toLowerCase(),VF=/^\s*/g,WF=n=>n.replace(VF,""),GF=/([A-Z])/g,Ek=(n,e)=>WF(n.replace(GF,t=>`${e}${zF(t)}`)),KF=n=>{const e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let s=0;s<t;s++)r[s]=e.codePointAt(s);return r},pf=typeof TextEncoder<"u"?new TextEncoder:null,k0=pf?n=>pf.encode(n):KF;let mf=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});mf&&mf.decode(new Uint8Array).length===1&&(mf=null);class gf{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Jt=()=>new gf,JF=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},At=n=>{const e=new Uint8Array(JF(n));let t=0;for(let r=0;r<n.bufs.length;r++){const s=n.bufs[r];e.set(s,t),t+=s.length}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},qF=(n,e)=>{const t=n.cbuf.length;t-n.cpos<e&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(Ks(t,e)*2),n.cpos=0)},qt=(n,e)=>{const t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e},yf=qt,ve=(n,e)=>{for(;e>ea;)qt(n,Zn|ea&e),e=_r(e/128);qt(n,ea&e)},C0=(n,e)=>{const t=gk(e);for(t&&(e=-e),qt(n,(e>E0?Zn:0)|(t?Js:0)|E0&e),e=_r(e/64);e>0;)qt(n,(e>ea?Zn:0)|ea&e),e=_r(e/128)},S0=new Uint8Array(3e4),QF=S0.length/3,YF=(n,e)=>{if(e.length<QF){const t=pf.encodeInto(e,S0).written||0;ve(n,t);for(let r=0;r<t;r++)qt(n,S0[r])}else St(n,k0(e))},XF=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;ve(n,r);for(let s=0;s<r;s++)qt(n,t.codePointAt(s))},hs=pf&&pf.encodeInto?YF:XF,Hh=(n,e)=>{const t=n.cbuf.length,r=n.cpos,s=zi(t-r,e.length),i=e.length-s;n.cbuf.set(e.subarray(0,s),r),n.cpos+=s,i>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(Ks(t*2,i)),n.cbuf.set(e.subarray(s)),n.cpos=i)},St=(n,e)=>{ve(n,e.byteLength),Hh(n,e)},T0=(n,e)=>{qF(n,e);const t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},ZF=(n,e)=>T0(n,4).setFloat32(0,e,!1),e3=(n,e)=>T0(n,8).setFloat64(0,e,!1),t3=(n,e)=>T0(n,8).setBigInt64(0,e,!1),kk=new DataView(new ArrayBuffer(4)),n3=n=>(kk.setFloat32(0,n),kk.getFloat32(0)===n),Nl=(n,e)=>{switch(typeof e){case"string":qt(n,119),hs(n,e);break;case"number":jF(e)&&Bh(e)<=BF?(qt(n,125),C0(n,e)):n3(e)?(qt(n,124),ZF(n,e)):(qt(n,123),e3(n,e));break;case"bigint":qt(n,122),t3(n,e);break;case"object":if(e===null)qt(n,126);else if(y0(e)){qt(n,117),ve(n,e.length);for(let t=0;t<e.length;t++)Nl(n,e[t])}else if(e instanceof Uint8Array)qt(n,116),St(n,e);else{qt(n,118);const t=Object.keys(e);ve(n,t.length);for(let r=0;r<t.length;r++){const s=t[r];hs(n,s),Nl(n,e[s])}}break;case"boolean":qt(n,e?120:121);break;default:qt(n,127)}};class Ck extends gf{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ve(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Sk=n=>{n.count>0&&(C0(n.encoder,n.count===1?n.s:-n.s),n.count>1&&ve(n.encoder,n.count-2))};class jh{constructor(){this.encoder=new gf,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Sk(this),this.count=1,this.s=e)}toUint8Array(){return Sk(this),At(this.encoder)}}const Tk=n=>{if(n.count>0){const e=n.diff*2+(n.count===1?0:1);C0(n.encoder,e),n.count>1&&ve(n.encoder,n.count-2)}};class O0{constructor(){this.encoder=new gf,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Tk(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Tk(this),At(this.encoder)}}class r3{constructor(){this.sarr=[],this.s="",this.lensE=new jh}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new gf;return this.sarr.push(this.s),this.s="",hs(e,this.sarr.join("")),Hh(e,this.lensE.toUint8Array()),At(e)}}const Ok=Lr("Unexpected end of array"),Nk=Lr("Integer out of Range");class $h{constructor(e){this.arr=e,this.pos=0}}const ps=n=>new $h(n),s3=n=>n.pos!==n.arr.length,i3=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},Qt=n=>i3(n,Oe(n)),ta=n=>n.arr[n.pos++],Oe=n=>{let e=0,t=1;const r=n.arr.length;for(;n.pos<r;){const s=n.arr[n.pos++];if(e=e+(s&ea)*t,t*=128,s<Zn)return e;if(e>xk)throw Nk}throw Ok},N0=n=>{let e=n.arr[n.pos++],t=e&E0,r=64;const s=(e&Js)>0?-1:1;if(!(e&Zn))return s*t;const i=n.arr.length;for(;n.pos<i;){if(e=n.arr[n.pos++],t=t+(e&ea)*r,r*=128,e<Zn)return s*t;if(t>xk)throw Nk}throw Ok},qs=mf?n=>mf.decode(Qt(n)):n=>{let e=Oe(n);if(e===0)return"";{let t=String.fromCodePoint(ta(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(ta(n));else for(;e>0;){const r=e<1e4?e:1e4,s=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(t))}},M0=(n,e)=>{const t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},o3=[n=>{},n=>null,N0,n=>M0(n,4).getFloat32(0,!1),n=>M0(n,8).getFloat64(0,!1),n=>M0(n,8).getBigInt64(0,!1),n=>!1,n=>!0,qs,n=>{const e=Oe(n),t={};for(let r=0;r<e;r++){const s=qs(n);t[s]=Ml(n)}return t},n=>{const e=Oe(n),t=[];for(let r=0;r<e;r++)t.push(Ml(n));return t},Qt],Ml=n=>o3[127-ta(n)](n);class Mk extends $h{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),s3(this)?this.count=Oe(this)+1:this.count=-1),this.count--,this.s}}class zh extends $h{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=N0(this);const e=gk(this.s);this.count=1,e&&(this.s=-this.s,this.count=Oe(this)+2)}return this.count--,this.s}}class R0 extends $h{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=N0(this),t=e&1;this.diff=_r(e/2),this.count=1,t&&(this.count=Oe(this)+2)}return this.s+=this.diff,this.count--,this.s}}class a3{constructor(e){this.decoder=new zh(e),this.str=qs(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const Rk=n=>n===void 0?null:n;class l3{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let Pk=new l3,P0=!0;try{typeof localStorage<"u"&&localStorage&&(Pk=localStorage,P0=!1)}catch{}const Dk=Pk,c3=n=>P0||addEventListener("storage",n),u3=n=>P0||removeEventListener("storage",n),f3=Object.assign,D0=Object.keys,d3=(n,e)=>{for(const t in n)e(n[t],t)},Ik=n=>D0(n).length,_k=n=>D0(n).length,h3=n=>{for(const e in n)return!1;return!0},p3=(n,e)=>{for(const t in n)if(!e(n[t],t))return!1;return!0},Lk=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),m3=(n,e)=>n===e||_k(n)===_k(e)&&p3(n,(t,r)=>(t!==void 0||Lk(e,r))&&e[r]===t),I0=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&I0(n,e,t+1)}},g3=()=>{},y3=n=>n,b3=(n,e)=>n===e,bf=(n,e)=>{if(n==null||e==null)return b3(n,e);if(n.constructor!==e.constructor)return!1;if(n===e)return!0;switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),e=new Uint8Array(e);case Uint8Array:{if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;break}case Set:{if(n.size!==e.size)return!1;for(const t of n)if(!e.has(t))return!1;break}case Map:{if(n.size!==e.size)return!1;for(const t of n.keys())if(!e.has(t)||!bf(n.get(t),e.get(t)))return!1;break}case Object:if(Ik(n)!==Ik(e))return!1;for(const t in n)if(!Lk(n,t)||!bf(n[t],e[t]))return!1;break;case Array:if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!bf(n[t],e[t]))return!1;break;default:return!1}return!0},w3=(n,e)=>e.includes(n),Rl=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",_0=typeof window<"u"&&typeof document<"u"&&!Rl;let ms;const v3=()=>{if(ms===void 0)if(Rl){ms=En();const n=process.argv;let e=null;for(let t=0;t<n.length;t++){const r=n[t];r[0]==="-"?(e!==null&&ms.set(e,""),e=r):e!==null&&(ms.set(e,r),e=null)}e!==null&&ms.set(e,"")}else typeof location=="object"?(ms=En(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){const[e,t]=n.split("=");ms.set(`--${Ek(e,"-")}`,t),ms.set(`-${Ek(e,"-")}`,t)}})):ms=En();return ms},L0=n=>v3().has(n),Vh=n=>Rk(Rl?process.env[n.toUpperCase().replaceAll("-","_")]:Dk.getItem(n));(n=>L0("--"+n)||Vh(n)!==null)("production");const Bk=Rl&&w3(process.env.FORCE_COLOR,["true","1","2"]),A3=!L0("--no-colors")&&(!Rl||process.stdout.isTTY||Bk)&&(!Rl||L0("--color")||Bk||Vh("COLORTERM")!==null||(Vh("TERM")||"").includes("color"));class x3{constructor(e,t){this.left=e,this.right=t}}const Qs=(n,e)=>new x3(n,e),E3=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const k3=n=>NF(n,(e,t)=>`${t}:${e};`).join(""),C3=JSON.stringify,S3=(n=>class{constructor(t){this._=t}destroy(){n(this._)}})(clearTimeout),B0=(n,e)=>new S3(setTimeout(e,n)),Ys=Symbol,yr=Ys(),na=Ys(),Fk=Ys(),F0=Ys(),Uk=Ys(),Hk=Ys(),jk=Ys(),Wh=Ys(),Gh=Ys(),T3=n=>{var r;n.length===1&&((r=n[0])==null?void 0:r.constructor)===Function&&(n=n[0]());const e=[];let t=0;for(;t<n.length;t++){const s=n[t];s===void 0||s.constructor===String||s.constructor===Number||s.constructor===Object&&e.push(JSON.stringify(s))}return e},$k=[Uk,jk,Wh,Fk];let U0=0,zk=ds();const O3=(n,e)=>{const t=$k[U0],r=Vh("log"),s=r!==null&&(r==="*"||r==="true"||new RegExp(r,"gi").test(e));return U0=(U0+1)%$k.length,e+=": ",s?(...i)=>{var l;i.length===1&&((l=i[0])==null?void 0:l.constructor)===Function&&(i=i[0]());const o=ds(),a=o-zk;zk=o,n(t,e,Gh,...i.map(c=>{switch(c!=null&&c.constructor===Uint8Array&&(c=Array.from(c)),typeof c){case"string":case"symbol":return c;default:return C3(c)}}),t," +"+a+"ms")}:g3},N3={[yr]:Qs("font-weight","bold"),[na]:Qs("font-weight","normal"),[Fk]:Qs("color","blue"),[Uk]:Qs("color","green"),[F0]:Qs("color","grey"),[Hk]:Qs("color","red"),[jk]:Qs("color","purple"),[Wh]:Qs("color","orange"),[Gh]:Qs("color","black")},Vk=A3?n=>{var o;n.length===1&&((o=n[0])==null?void 0:o.constructor)===Function&&(n=n[0]());const e=[],t=[],r=En();let s=[],i=0;for(;i<n.length;i++){const a=n[i],l=N3[a];if(l!==void 0)r.set(l.left,l.right);else{if(a===void 0)break;if(a.constructor===String||a.constructor===Number){const c=k3(r);i>0||c.length>0?(e.push("%c"+a),t.push(c)):e.push(a)}else break}}for(i>0&&(s=t,s.unshift(e.join("")));i<n.length;i++){const a=n[i];a instanceof Symbol||s.push(a)}return s}:T3,Wk=(...n)=>{console.log(...Vk(n)),Gk.forEach(e=>e.print(n))},M3=(...n)=>{console.warn(...Vk(n)),n.unshift(Wh),Gk.forEach(e=>e.print(n))},Gk=Ws(),R3=n=>O3(Wk,n),Pl=n=>new Promise(n);Promise.all.bind(Promise);const P3=n=>Promise.reject(n),H0=n=>Promise.resolve(n),Kk=n=>new Uint8Array(n),D3=(n,e,t)=>new Uint8Array(n,e,t),I3=n=>new Uint8Array(n),_3=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=$F(n[t]);return btoa(e)},L3=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),B3=n=>{const e=atob(n),t=Kk(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t},F3=n=>{const e=Buffer.from(n,"base64");return D3(e.buffer,e.byteOffset,e.byteLength)},Jk=_0?_3:L3,qk=_0?B3:F3,U3=n=>{const e=Kk(n.byteLength);return e.set(n),e},Qk=new Map;class H3{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:qk(t.newValue||"")}),c3(this._onChange)}postMessage(e){Dk.setItem(this.room,Jk(I3(e)))}close(){u3(this._onChange)}}const j3=typeof BroadcastChannel>"u"?H3:BroadcastChannel,j0=n=>Hn(Qk,n,()=>{const e=Ws(),t=new j3(n);return t.onmessage=r=>e.forEach(s=>s(r.data,"broadcastchannel")),{bc:t,subs:e}}),$3=(n,e)=>(j0(n).subs.add(e),e),z3=(n,e)=>{const t=j0(n),r=t.subs.delete(e);return r&&t.subs.size===0&&(t.bc.close(),Qk.delete(n)),r},V3=(n,e,t=null)=>{const r=j0(n);r.bc.postMessage(e),r.subs.forEach(s=>s(e,t))},Yk=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}},Xk=n=>({[Symbol.iterator](){return this},next:n}),W3=(n,e)=>Xk(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),$0=(n,e)=>Xk(()=>{const{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});class z0{constructor(e,t){this.clock=e,this.len=t}}class Dl{constructor(){this.clients=new Map}}const Vi=(n,e,t)=>e.clients.forEach((r,s)=>{const i=n.doc.store.clients.get(s);for(let o=0;o<r.length;o++){const a=r[o];vC(n,i,a.clock,a.len,t)}}),G3=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){const s=_r((t+r)/2),i=n[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;t=s+1}else r=s-1}return null},Il=(n,e)=>{const t=n.clients.get(e.client);return t!==void 0&&G3(t,e.clock)!==null},V0=n=>{n.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let t,r;for(t=1,r=1;t<e.length;t++){const s=e[r-1],i=e[t];s.clock+s.len>=i.clock?s.len=Ks(s.len,i.clock+i.len-s.clock):(r<t&&(e[r]=i),r++)}e.length=r})},W0=n=>{const e=new Dl;for(let t=0;t<n.length;t++)n[t].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=t+1;o<n.length;o++)RF(i,n[o].clients.get(s)||[]);e.clients.set(s,i)}});return V0(e),e},wf=(n,e,t,r)=>{Hn(n.clients,e,()=>[]).push(new z0(t,r))},Zk=()=>new Dl,eC=n=>{const e=Zk();return n.clients.forEach((t,r)=>{const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(o.deleted){const a=o.id.clock;let l=o.length;if(i+1<t.length)for(let c=t[i+1];i+1<t.length&&c.deleted;c=t[++i+1])l+=c.length;s.push(new z0(a,l))}}s.length>0&&e.clients.set(r,s)}),e},_l=(n,e)=>{ve(n.restEncoder,e.clients.size),Gs(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),ve(n.restEncoder,t);const s=r.length;ve(n.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];n.writeDsClock(o.clock),n.writeDsLen(o.len)}})},G0=n=>{const e=new Dl,t=Oe(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();const s=Oe(n.restDecoder),i=Oe(n.restDecoder);if(i>0){const o=Hn(e.clients,s,()=>[]);for(let a=0;a<i;a++)o.push(new z0(n.readDsClock(),n.readDsLen()))}}return e},tC=(n,e,t)=>{const r=new Dl,s=Oe(n.restDecoder);for(let i=0;i<s;i++){n.resetDsCurVal();const o=Oe(n.restDecoder),a=Oe(n.restDecoder),l=t.clients.get(o)||[],c=Mt(t,o);for(let u=0;u<a;u++){const f=n.readDsClock(),d=f+n.readDsLen();if(f<c){c<d&&wf(r,o,c,d-c);let h=gs(l,f),p=l[h];for(!p.deleted&&p.id.clock<f&&(l.splice(h+1,0,ip(e,p,f-p.id.clock)),h++);h<l.length&&(p=l[h++],p.id.clock<d);)p.deleted||(d<p.id.clock+p.length&&l.splice(h,0,ip(e,p,d-p.id.clock)),p.delete(e))}else wf(r,o,f,d-f)}}if(r.clients.size>0){const i=new ra;return ve(i.restEncoder,0),_l(i,r),i.toUint8Array()}return null},nC=vk;class Ll extends b0{constructor({guid:e=Ak(),collectionid:t=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=nC(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new yC,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=Pl(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>Pl(c=>{const u=f=>{(f===void 0||f===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&ot(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Gs(this.subdocs).map(e=>e.guid))}transact(e,t=null){return ot(this,e,t)}get(e,t=an){const r=Hn(this.share,e,()=>{const i=new t;return i._integrate(this,null),i}),s=r.constructor;if(t!==an&&s!==t)if(s===an){const i=new t;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,jl)}getText(e=""){return this.get(e,ia)}getMap(e=""){return this.get(e,$l)}getXmlElement(e=""){return this.get(e,kn)}getXmlFragment(e=""){return this.get(e,oa)}toJSON(){const e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){Gs(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new Ll({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,ot(e.parent.doc,r=>{const s=t.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class rC{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Oe(this.restDecoder)}readDsLen(){return Oe(this.restDecoder)}}class sC extends rC{readLeftID(){return Ne(Oe(this.restDecoder),Oe(this.restDecoder))}readRightID(){return Ne(Oe(this.restDecoder),Oe(this.restDecoder))}readClient(){return Oe(this.restDecoder)}readInfo(){return ta(this.restDecoder)}readString(){return qs(this.restDecoder)}readParentInfo(){return Oe(this.restDecoder)===1}readTypeRef(){return Oe(this.restDecoder)}readLen(){return Oe(this.restDecoder)}readAny(){return Ml(this.restDecoder)}readBuf(){return U3(Qt(this.restDecoder))}readJSON(){return JSON.parse(qs(this.restDecoder))}readKey(){return qs(this.restDecoder)}}class K3{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Oe(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Oe(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Bl extends K3{constructor(e){super(e),this.keys=[],Oe(e),this.keyClockDecoder=new R0(Qt(e)),this.clientDecoder=new zh(Qt(e)),this.leftClockDecoder=new R0(Qt(e)),this.rightClockDecoder=new R0(Qt(e)),this.infoDecoder=new Mk(Qt(e),ta),this.stringDecoder=new a3(Qt(e)),this.parentInfoDecoder=new Mk(Qt(e),ta),this.typeRefDecoder=new zh(Qt(e)),this.lenDecoder=new zh(Qt(e))}readLeftID(){return new Fl(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Fl(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Ml(this.restDecoder)}readBuf(){return Qt(this.restDecoder)}readJSON(){return Ml(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class iC{constructor(){this.restEncoder=Jt()}toUint8Array(){return At(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ve(this.restEncoder,e)}writeDsLen(e){ve(this.restEncoder,e)}}class vf extends iC{writeLeftID(e){ve(this.restEncoder,e.client),ve(this.restEncoder,e.clock)}writeRightID(e){ve(this.restEncoder,e.client),ve(this.restEncoder,e.clock)}writeClient(e){ve(this.restEncoder,e)}writeInfo(e){yf(this.restEncoder,e)}writeString(e){hs(this.restEncoder,e)}writeParentInfo(e){ve(this.restEncoder,e?1:0)}writeTypeRef(e){ve(this.restEncoder,e)}writeLen(e){ve(this.restEncoder,e)}writeAny(e){Nl(this.restEncoder,e)}writeBuf(e){St(this.restEncoder,e)}writeJSON(e){hs(this.restEncoder,JSON.stringify(e))}writeKey(e){hs(this.restEncoder,e)}}class oC{constructor(){this.restEncoder=Jt(),this.dsCurrVal=0}toUint8Array(){return At(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,ve(this.restEncoder,t)}writeDsLen(e){e===0&&gr(),ve(this.restEncoder,e-1),this.dsCurrVal+=e}}class ra extends oC{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new O0,this.clientEncoder=new jh,this.leftClockEncoder=new O0,this.rightClockEncoder=new O0,this.infoEncoder=new Ck(yf),this.stringEncoder=new r3,this.parentInfoEncoder=new Ck(yf),this.typeRefEncoder=new jh,this.lenEncoder=new jh}toUint8Array(){const e=Jt();return ve(e,0),St(e,this.keyClockEncoder.toUint8Array()),St(e,this.clientEncoder.toUint8Array()),St(e,this.leftClockEncoder.toUint8Array()),St(e,this.rightClockEncoder.toUint8Array()),St(e,At(this.infoEncoder)),St(e,this.stringEncoder.toUint8Array()),St(e,At(this.parentInfoEncoder)),St(e,this.typeRefEncoder.toUint8Array()),St(e,this.lenEncoder.toUint8Array()),Hh(e,At(this.restEncoder)),At(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Nl(this.restEncoder,e)}writeBuf(e){St(this.restEncoder,e)}writeJSON(e){Nl(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const J3=(n,e,t,r)=>{r=Ks(r,e[0].id.clock);const s=gs(e,r);ve(n.restEncoder,e.length-s),n.writeClient(t),ve(n.restEncoder,r);const i=e[s];i.write(n,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(n,0)},K0=(n,e,t)=>{const r=new Map;t.forEach((s,i)=>{Mt(e,i)>s&&r.set(i,s)}),Cf(e).forEach((s,i)=>{t.has(i)||r.set(i,0)}),ve(n.restEncoder,r.size),Gs(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{J3(n,e.clients.get(s),s,i)})},q3=(n,e)=>{const t=En(),r=Oe(n.restDecoder);for(let s=0;s<r;s++){const i=Oe(n.restDecoder),o=new Array(i),a=n.readClient();let l=Oe(n.restDecoder);t.set(a,{i:0,refs:o});for(let c=0;c<i;c++){const u=n.readInfo();switch(Uh&u){case 0:{const f=n.readLen();o[c]=new br(Ne(a,l),f),l+=f;break}case 10:{const f=Oe(n.restDecoder);o[c]=new wr(Ne(a,l),f),l+=f;break}default:{const f=(u&(Js|Zn))===0,d=new ht(Ne(a,l),null,(u&Zn)===Zn?n.readLeftID():null,null,(u&Js)===Js?n.readRightID():null,f?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,f&&(u&hf)===hf?n.readString():null,YC(n,u));o[c]=d,l+=d.length}}}}return t},Q3=(n,e,t)=>{const r=[];let s=Gs(t.keys()).sort((h,p)=>h-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let h=t.get(s[s.length-1]);for(;h.refs.length===h.i;)if(s.pop(),s.length>0)h=t.get(s[s.length-1]);else return null;return h};let o=i();if(o===null)return null;const a=new yC,l=new Map,c=(h,p)=>{const g=l.get(h);(g==null||g>p)&&l.set(h,p)};let u=o.refs[o.i++];const f=new Map,d=()=>{for(const h of r){const p=h.id.client,g=t.get(p);g?(g.i--,a.clients.set(p,g.refs.slice(g.i)),t.delete(p),g.i=0,g.refs=[]):a.clients.set(p,[h]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(u.constructor!==wr){const p=Hn(f,u.id.client,()=>Mt(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),d();else{const g=u.getMissing(n,e);if(g!==null){r.push(u);const y=t.get(g)||{refs:[],i:0};if(y.refs.length===y.i)c(g,Mt(e,g)),d();else{u=y.refs[y.i++];continue}}else(p===0||p<u.length)&&(u.integrate(n,p),f.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=i(),o===null)break;u=o.refs[o.i++]}}if(a.clients.size>0){const h=new ra;return K0(h,a,new Map),ve(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},Y3=(n,e)=>K0(n,e.doc.store,e.beforeState),X3=(n,e,t,r=new Bl(n))=>ot(e,s=>{s.local=!1;let i=!1;const o=s.doc,a=o.store,l=q3(r,o),c=Q3(s,a,l),u=a.pendingStructs;if(u){for(const[d,h]of u.missing)if(h<Mt(a,d)){i=!0;break}if(c){for(const[d,h]of c.missing){const p=u.missing.get(d);(p==null||p>h)&&u.missing.set(d,h)}u.update=qh([u.update,c.update])}}else a.pendingStructs=c;const f=tC(r,s,a);if(a.pendingDs){const d=new Bl(ps(a.pendingDs));Oe(d.restDecoder);const h=tC(d,s,a);f&&h?a.pendingDs=qh([f,h]):a.pendingDs=f||h}else a.pendingDs=f;if(i){const d=a.pendingStructs.update;a.pendingStructs=null,aC(s.doc,d)}},t,!1),aC=(n,e,t,r=Bl)=>{const s=ps(e);X3(s,n,t,new r(s))},lC=(n,e,t)=>aC(n,e,t,sC),Z3=(n,e,t=new Map)=>{K0(n,e.store,t),_l(n,eC(e.store))},e4=(n,e=new Uint8Array([0]),t=new ra)=>{const r=cC(e);Z3(t,n,r);const s=[t.toUint8Array()];if(n.store.pendingDs&&s.push(n.store.pendingDs),n.store.pendingStructs&&s.push(b4(n.store.pendingStructs.update,e)),s.length>1){if(t.constructor===vf)return g4(s.map((i,o)=>o===0?i:v4(i)));if(t.constructor===ra)return qh(s)}return s[0]},J0=(n,e)=>e4(n,e,new vf),t4=n=>{const e=new Map,t=Oe(n.restDecoder);for(let r=0;r<t;r++){const s=Oe(n.restDecoder),i=Oe(n.restDecoder);e.set(s,i)}return e},cC=n=>t4(new rC(ps(n))),uC=(n,e)=>(ve(n.restEncoder,e.size),Gs(e.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{ve(n.restEncoder,t),ve(n.restEncoder,r)}),n),n4=(n,e)=>uC(n,Cf(e.store)),r4=(n,e=new oC)=>(n instanceof Map?uC(e,n):n4(e,n),e.toUint8Array()),s4=n=>r4(n,new iC);class i4{constructor(){this.l=[]}}const fC=()=>new i4,dC=(n,e)=>n.l.push(e),hC=(n,e)=>{const t=n.l,r=t.length;n.l=t.filter(s=>e!==s),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},pC=(n,e,t)=>I0(n.l,[e,t]);class Fl{constructor(e,t){this.client=e,this.clock=t}}const Ul=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,Ne=(n,e)=>new Fl(n,e),Af=n=>{for(const[e,t]of n.doc.share.entries())if(t===n)return e;throw gr()},xf=(n,e)=>{for(;e!==null;){if(e.parent===n)return!0;e=e.parent._item}return!1};class Ef{constructor(e,t,r,s=0){this.type=e,this.tname=t,this.item=r,this.assoc=s}}const kf=n=>new Ef(n.type==null?null:Ne(n.type.client,n.type.clock),n.tname||null,n.item==null?null:Ne(n.item.client,n.item.clock),n.assoc==null?0:n.assoc);class o4{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}}const a4=(n,e,t=0)=>new o4(n,e,t),Kh=(n,e,t)=>{let r=null,s=null;return n._item===null?s=Af(n):r=Ne(n._item.id.client,n._item.id.clock),new Ef(r,s,e,t)},q0=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return Kh(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Kh(n,Ne(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return Kh(n,r.lastId,t);r=r.right}return Kh(n,null,t)},l4=(n,e,t=!0)=>{const r=e.store,s=n.item,i=n.type,o=n.tname,a=n.assoc;let l=null,c=0;if(s!==null){if(Mt(r,s.client)<=s.clock)return null;const u=t?cb(r,s):{item:Hl(r,s),diff:0},f=u.item;if(!(f instanceof ht))return null;if(l=f.parent,l._item===null||!l._item.deleted){c=f.deleted||!f.countable?0:u.diff+(a>=0?0:1);let d=f.left;for(;d!==null;)!d.deleted&&d.countable&&(c+=d.length),d=d.left}}else{if(o!==null)l=e.get(o);else if(i!==null){if(Mt(r,i.client)<=i.clock)return null;const{item:u}=t?cb(r,i):{item:Hl(r,i)};if(u instanceof ht&&u.content instanceof Ur)l=u.content.type;else return null}else throw gr();a>=0?c=l._length:c=0}return a4(l,c,n.assoc)},mC=(n,e)=>n===e||n!==null&&e!==null&&n.tname===e.tname&&Ul(n.item,e.item)&&Ul(n.type,e.type)&&n.assoc===e.assoc;class Q0{constructor(e,t){this.ds=e,this.sv=t}}const gC=(n,e)=>new Q0(n,e),c4=n=>gC(eC(n.store),Cf(n.store)),sa=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!Il(e.ds,n.id),Y0=(n,e)=>{const t=Hn(n.meta,Y0,Ws),r=n.doc.store;t.has(e)||(e.sv.forEach((s,i)=>{s<Mt(r,i)&&jn(n,Ne(i,s))}),Vi(n,e.ds,s=>{}),t.add(e))};class yC{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Cf=n=>{const e=new Map;return n.clients.forEach((t,r)=>{const s=t[t.length-1];e.set(r,s.id.clock+s.length)}),e},Mt=(n,e)=>{const t=n.clients.get(e);if(t===void 0)return 0;const r=t[t.length-1];return r.id.clock+r.length},bC=(n,e)=>{let t=n.clients.get(e.id.client);if(t===void 0)t=[],n.clients.set(e.id.client,t);else{const r=t[t.length-1];if(r.id.clock+r.length!==e.id.clock)throw gr()}t.push(e)},gs=(n,e)=>{let t=0,r=n.length-1,s=n[r],i=s.id.clock;if(i===e)return r;let o=_r(e/(i+s.length-1)*r);for(;t<=r;){if(s=n[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;t=o+1}else r=o-1;o=_r((t+r)/2)}throw gr()},Hl=(n,e)=>{const t=n.clients.get(e.client);return t[gs(t,e.clock)]},X0=(n,e,t)=>{const r=gs(e,t),s=e[r];return s.id.clock<t&&s instanceof ht?(e.splice(r+1,0,ip(n,s,t-s.id.clock)),r+1):r},jn=(n,e)=>{const t=n.doc.store.clients.get(e.client);return t[X0(n,t,e.clock)]},wC=(n,e,t)=>{const r=e.clients.get(t.client),s=gs(r,t.clock),i=r[s];return t.clock!==i.id.clock+i.length-1&&i.constructor!==br&&r.splice(s+1,0,ip(n,i,t.clock-i.id.clock+1)),i},u4=(n,e,t)=>{const r=n.clients.get(e.id.client);r[gs(r,e.id.clock)]=t},vC=(n,e,t,r,s)=>{if(r===0)return;const i=t+r;let o=X0(n,e,t),a;do a=e[o++],i<a.id.clock+a.length&&X0(n,e,i),s(a);while(o<e.length&&e[o].id.clock<i)};let f4=class{constructor(e,t,r){this.doc=e,this.deleteSet=new Dl,this.beforeState=Cf(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}};const AC=(n,e)=>e.deleteSet.clients.size===0&&!MF(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(V0(e.deleteSet),Y3(n,e),_l(n,e.deleteSet),!0),xC=(n,e,t)=>{const r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&Hn(n.changed,e,Ws).add(t)},Jh=(n,e)=>{let t=n[e],r=n[e-1],s=e;for(;s>0;t=r,r=n[--s-1]){if(r.deleted===t.deleted&&r.constructor===t.constructor&&r.mergeWith(t)){t instanceof ht&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,r);continue}break}const i=e-s;return i&&n.splice(e+1-i,i),i},d4=(n,e,t)=>{for(const[r,s]of n.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const a=s[o],l=a.clock+a.len;for(let c=gs(i,a.clock),u=i[c];c<i.length&&u.id.clock<l;u=i[++c]){const f=i[c];if(a.clock+a.len<=f.id.clock)break;f instanceof ht&&f.deleted&&!f.keep&&t(f)&&f.gc(e,!1)}}}},h4=(n,e)=>{n.clients.forEach((t,r)=>{const s=e.clients.get(r);for(let i=t.length-1;i>=0;i--){const o=t[i],a=zi(s.length-1,1+gs(s,o.clock+o.len-1));for(let l=a,c=s[l];l>0&&c.id.clock>=o.clock;c=s[l])l-=1+Jh(s,l)}})},EC=(n,e)=>{if(e<n.length){const t=n[e],r=t.doc,s=r.store,i=t.deleteSet,o=t._mergeStructs;try{V0(i),t.afterState=Cf(t.doc.store),r.emit("beforeObserverCalls",[t,r]);const a=[];t.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(t,l)})),a.push(()=>{t.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(u=>u.target._item===null||!u.target._item.deleted),l.forEach(u=>{u.currentTarget=c,u._path=null}),l.sort((u,f)=>u.path.length-f.path.length),pC(c._dEH,l,t))})}),a.push(()=>r.emit("afterTransaction",[t,r])),I0(a,[]),t._needFormattingCleanup&&I4(t)}finally{r.gc&&d4(i,s,r.gcFilter),h4(i,s),t.afterState.forEach((u,f)=>{const d=t.beforeState.get(f)||0;if(d!==u){const h=s.clients.get(f),p=Ks(gs(h,d),1);for(let g=h.length-1;g>=p;)g-=1+Jh(h,g)}});for(let u=o.length-1;u>=0;u--){const{client:f,clock:d}=o[u].id,h=s.clients.get(f),p=gs(h,d);p+1<h.length&&Jh(h,p+1)>1||p>0&&Jh(h,p)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(Wk(Wh,yr,"[yjs] ",na,Hk,"Changed the client-id because another client seems to be using it."),r.clientID=nC()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){const u=new vf;AC(u,t)&&r.emit("update",[u.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){const u=new ra;AC(u,t)&&r.emit("updateV2",[u.toUint8Array(),t.origin,r,t])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=t;(a.size>0||c.size>0||l.size>0)&&(a.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,t]),c.forEach(u=>u.destroy())),n.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):EC(n,e+1)}}},ot=(n,e,t=null,r=!0)=>{const s=n._transactionCleanups;let i=!1,o=null;n._transaction===null&&(i=!0,n._transaction=new f4(n,t,r),s.push(n._transaction),s.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{o=e(n._transaction)}finally{if(i){const a=n._transaction===s[0];n._transaction=null,a&&EC(s,0)}}return o};class p4{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const kC=(n,e,t)=>{Vi(n,t.deletions,r=>{r instanceof ht&&e.scope.some(s=>xf(s,r))&&ub(r,!1)})},CC=(n,e,t)=>{let r=null;const s=n.doc,i=n.scope;if(ot(s,o=>{for(;e.length>0&&n.currStackItem===null;){const a=s.store,l=e.pop(),c=new Set,u=[];let f=!1;Vi(o,l.insertions,d=>{if(d instanceof ht){if(d.redone!==null){let{item:h,diff:p}=cb(a,d.id);p>0&&(h=jn(o,Ne(h.id.client,h.id.clock+p))),d=h}!d.deleted&&i.some(h=>xf(h,d))&&u.push(d)}}),Vi(o,l.deletions,d=>{d instanceof ht&&i.some(h=>xf(h,d))&&!Il(l.insertions,d.id)&&c.add(d)}),c.forEach(d=>{f=QC(o,d,c,l.insertions,n.ignoreRemoteMapChanges,n)!==null||f});for(let d=u.length-1;d>=0;d--){const h=u[d];n.deleteFilter(h)&&(h.delete(o),f=!0)}n.currStackItem=f?l:null}o.changed.forEach((a,l)=>{a.has(null)&&l._searchMarker&&(l._searchMarker.length=0)}),r=o},n),n.currStackItem!=null){const o=r.changedParentTypes;n.emit("stack-item-popped",[{stackItem:n.currStackItem,type:t,changedParentTypes:o,origin:n},n]),n.currStackItem=null}return n.currStackItem};class SC extends b0{constructor(e,{captureTimeout:t=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:a=y0(e)?e[0].doc:e.doc}={}){super(),this.scope=[],this.doc=a,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=t,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(y=>l.changedParentTypes.has(y))||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const c=this.undoing,u=this.redoing,f=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);const d=new Dl;l.afterState.forEach((y,b)=>{const x=l.beforeState.get(b)||0,v=y-x;v>0&&wf(d,b,x,v)});const h=ds();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&f.length>0&&!c&&!u){const y=f[f.length-1];y.deletions=W0([y.deletions,l.deleteSet]),y.insertions=W0([y.insertions,d])}else f.push(new p4(l.deleteSet,d)),p=!0;!c&&!u&&(this.lastChange=h),Vi(l,l.deleteSet,y=>{y instanceof ht&&this.scope.some(b=>xf(b,y))&&ub(y,!0)});const g=[{stackItem:f[f.length-1],origin:l.origin,type:c?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",g):this.emit("stack-item-updated",g)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){e=y0(e)?e:[e],e.forEach(t=>{this.scope.every(r=>r!==t)&&(t.doc!==this.doc&&M3("[yjs#509] Not same Y.Doc"),this.scope.push(t))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>kC(r,this,s)),this.undoStack=[]),t&&(this.redoStack.forEach(s=>kC(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=CC(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=CC(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*m4(n){const e=Oe(n.restDecoder);for(let t=0;t<e;t++){const r=Oe(n.restDecoder),s=n.readClient();let i=Oe(n.restDecoder);for(let o=0;o<r;o++){const a=n.readInfo();if(a===10){const l=Oe(n.restDecoder);yield new wr(Ne(s,i),l),i+=l}else if(Uh&a){const l=(a&(Js|Zn))===0,c=new ht(Ne(s,i),null,(a&Zn)===Zn?n.readLeftID():null,null,(a&Js)===Js?n.readRightID():null,l?n.readParentInfo()?n.readString():n.readLeftID():null,l&&(a&hf)===hf?n.readString():null,YC(n,a));yield c,i+=c.length}else{const l=n.readLen();yield new br(Ne(s,i),l),i+=l}}}}class Z0{constructor(e,t){this.gen=m4(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===wr);return this.curr}}class eb{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const g4=n=>qh(n,sC,vf),y4=(n,e)=>{if(n.constructor===br){const{client:t,clock:r}=n.id;return new br(Ne(t,r+e),n.length-e)}else if(n.constructor===wr){const{client:t,clock:r}=n.id;return new wr(Ne(t,r+e),n.length-e)}else{const t=n,{client:r,clock:s}=t.id;return new ht(Ne(r,s+e),null,Ne(r,s+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},qh=(n,e=Bl,t=ra)=>{if(n.length===1)return n[0];const r=n.map(u=>new e(ps(u)));let s=r.map(u=>new Z0(u,!0)),i=null;const o=new t,a=new eb(o);for(;s=s.filter(d=>d.curr!==null),s.sort((d,h)=>{if(d.curr.id.client===h.curr.id.client){const p=d.curr.id.clock-h.curr.id.clock;return p===0?d.curr.constructor===h.curr.constructor?0:d.curr.constructor===wr?1:-1:p}else return h.curr.id.client-d.curr.id.client}),s.length!==0;){const u=s[0],f=u.curr.id.client;if(i!==null){let d=u.curr,h=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=u.next(),h=!0;if(d===null||d.id.client!==f||h&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(f!==i.struct.id.client)Wi(a,i.struct,i.offset),i={struct:d,offset:0},u.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===wr)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{Wi(a,i.struct,i.offset);const p=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new wr(Ne(f,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-d.id.clock;p>0&&(i.struct.constructor===wr?i.struct.length-=p:d=y4(d,p)),i.struct.mergeWith(d)||(Wi(a,i.struct,i.offset),i={struct:d,offset:0},u.next())}}else i={struct:u.curr,offset:0},u.next();for(let d=u.curr;d!==null&&d.id.client===f&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==wr;d=u.next())Wi(a,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(Wi(a,i.struct,i.offset),i=null),tb(a);const l=r.map(u=>G0(u)),c=W0(l);return _l(o,c),o.toUint8Array()},b4=(n,e,t=Bl,r=ra)=>{const s=cC(e),i=new r,o=new eb(i),a=new t(ps(n)),l=new Z0(a,!1);for(;l.curr;){const u=l.curr,f=u.id.client,d=s.get(f)||0;if(l.curr.constructor===wr){l.next();continue}if(u.id.clock+u.length>d)for(Wi(o,u,Ks(d-u.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)Wi(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===f&&l.curr.id.clock+l.curr.length<=d;)l.next()}tb(o);const c=G0(a);return _l(i,c),i.toUint8Array()},TC=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:At(n.encoder.restEncoder)}),n.encoder.restEncoder=Jt(),n.written=0)},Wi=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&TC(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),ve(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},tb=n=>{TC(n);const e=n.encoder.restEncoder;ve(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){const r=n.clientStructs[t];ve(e,r.written),Hh(e,r.restEncoder)}},w4=(n,e,t,r)=>{const s=new t(ps(n)),i=new Z0(s,!1),o=new r,a=new eb(o);for(let c=i.curr;c!==null;c=i.next())Wi(a,e(c),0);tb(a);const l=G0(s);return _l(o,l),o.toUint8Array()},v4=n=>w4(n,y3,Bl,vf),OC="You must not compute changes after the event-handler fired.";class Qh{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=A4(this.currentTarget,this.target))}deletes(e){return Il(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Lr(OC);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(s=>{if(s!==null){const i=t._map.get(s);let o,a;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",a=g0(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",a=g0(l.content.getContent())):(o="add",a=void 0)}else if(this.deletes(i))o="delete",a=g0(i.content.getContent());else return;e.set(s,{action:o,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Lr(OC);const t=this.target,r=Ws(),s=Ws(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let a=null;const l=()=>{a&&i.push(a)};for(let c=t._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=c.length,s.add(c)):this.adds(c)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(c.content.getContent()),r.add(c)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=c.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}}const A4=(n,e)=>{const t=[];for(;e._item!==null&&e!==n;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)s.deleted||r++,s=s.right;t.unshift(r)}e=e._item.parent}return t},NC=80;let nb=0;class x4{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=nb++}}const E4=n=>{n.timestamp=nb++},MC=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=nb++},k4=(n,e,t)=>{if(n.length>=NC){const r=n.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return MC(r,e,t),r}else{const r=new x4(e,t);return n.push(r),r}},Yh=(n,e)=>{if(n._start===null||e===0||n._searchMarker===null)return null;const t=n._searchMarker.length===0?null:n._searchMarker.reduce((i,o)=>Bh(e-i.index)<Bh(e-o.index)?i:o);let r=n._start,s=0;for(t!==null&&(r=t.p,s=t.index,E4(t));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return t!==null&&Bh(t.index-s)<r.parent.length/NC?(MC(t,r,s),t):k4(n._searchMarker,r,s)},Sf=(n,e,t)=>{for(let r=n.length-1;r>=0;r--){const s=n[r];if(t>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){n.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||t>0&&e===s.index)&&(s.index=Ks(e,s.index+t))}},Xh=(n,e,t)=>{const r=n,s=e.changedParentTypes;for(;Hn(s,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;pC(r._eH,t,e)};class an{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=fC(),this._dEH=fC(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Br()}clone(){throw Br()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){dC(this._eH,e)}observeDeep(e){dC(this._dEH,e)}unobserve(e){hC(this._eH,e)}unobserveDeep(e){hC(this._dEH,e)}toJSON(){}}const RC=(n,e,t)=>{e<0&&(e=n._length+e),t<0&&(t=n._length+t);let r=t-e;const s=[];let i=n._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let a=e;a<o.length&&r>0;a++)s.push(o[a]),r--;e=0}}i=i.right}return s},PC=n=>{const e=[];let t=n._start;for(;t!==null;){if(t.countable&&!t.deleted){const r=t.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}t=t.right}return e},DC=(n,e)=>{const t=[];let r=n._start;for(;r!==null;){if(r.countable&&sa(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)t.push(s[i])}r=r.right}return t},Tf=(n,e)=>{let t=0,r=n._start;for(;r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],t++,n)}r=r.right}},IC=(n,e)=>{const t=[];return Tf(n,(r,s)=>{t.push(e(r,s,n))}),t},C4=n=>{let e=n._start,t=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),r=0,e=e.right}const s=t[r++];return t.length<=r&&(t=null),{done:!1,value:s}}}},_C=(n,e)=>{const t=Yh(n,e);let r=n._start;for(t!==null&&(r=t.p,e-=t.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Zh=(n,e,t,r)=>{let s=t;const i=n.doc,o=i.clientID,a=i.store,l=t===null?e._start:t.right;let c=[];const u=()=>{c.length>0&&(s=new ht(Ne(o,Mt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new la(c)),s.integrate(n,0),c=[])};r.forEach(f=>{if(f===null)c.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(f);break;default:switch(u(),f.constructor){case Uint8Array:case ArrayBuffer:s=new ht(Ne(o,Mt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Of(new Uint8Array(f))),s.integrate(n,0);break;case Ll:s=new ht(Ne(o,Mt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Mf(f)),s.integrate(n,0);break;default:if(f instanceof an)s=new ht(Ne(o,Mt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Ur(f)),s.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},LC=()=>Lr("Length exceeded!"),BC=(n,e,t,r)=>{if(t>e._length)throw LC();if(t===0)return e._searchMarker&&Sf(e._searchMarker,t,r.length),Zh(n,e,null,r);const s=t,i=Yh(e,t);let o=e._start;for(i!==null&&(o=i.p,t-=i.index,t===0&&(o=o.prev,t+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(t<=o.length){t<o.length&&jn(n,Ne(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&Sf(e._searchMarker,s,r.length),Zh(n,e,o,r)},S4=(n,e,t)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return Zh(n,e,s,t)},FC=(n,e,t,r)=>{if(r===0)return;const s=t,i=r,o=Yh(e,t);let a=e._start;for(o!==null&&(a=o.p,t-=o.index);a!==null&&t>0;a=a.right)!a.deleted&&a.countable&&(t<a.length&&jn(n,Ne(a.id.client,a.id.clock+t)),t-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&jn(n,Ne(a.id.client,a.id.clock+r)),a.delete(n),r-=a.length),a=a.right;if(r>0)throw LC();e._searchMarker&&Sf(e._searchMarker,s,-i+r)},ep=(n,e,t)=>{const r=e._map.get(t);r!==void 0&&r.delete(n)},rb=(n,e,t,r)=>{const s=e._map.get(t)||null,i=n.doc,o=i.clientID;let a;if(r==null)a=new la([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:a=new la([r]);break;case Uint8Array:a=new Of(r);break;case Ll:a=new Mf(r);break;default:if(r instanceof an)a=new Ur(r);else throw new Error("Unexpected content type")}new ht(Ne(o,Mt(i.store,o)),s,s&&s.lastId,null,null,e,t,a).integrate(n,0)},sb=(n,e)=>{const t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},UC=n=>{const e={};return n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},HC=(n,e)=>{const t=n._map.get(e);return t!==void 0&&!t.deleted},T4=(n,e)=>{const t={};return n._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&sa(i,e)&&(t[s]=i.content.getContent()[i.length-1])}),t},tp=n=>W3(n.entries(),e=>!e[1].deleted);class O4 extends Qh{constructor(e,t){super(e,t),this._transaction=t}}class jl extends an{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new jl;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new jl}clone(){const e=new jl;return e.insert(0,this.toArray().map(t=>t instanceof an?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,t){super._callObserver(e,t),Xh(this,e,new O4(this,e))}insert(e,t){this.doc!==null?ot(this.doc,r=>{BC(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?ot(this.doc,t=>{S4(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?ot(this.doc,r=>{FC(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return _C(this,e)}toArray(){return PC(this)}slice(e=0,t=this.length){return RC(this,e,t)}toJSON(){return this.map(e=>e instanceof an?e.toJSON():e)}map(e){return IC(this,e)}forEach(e){Tf(this,e)}[Symbol.iterator](){return C4(this)}_write(e){e.writeTypeRef(X4)}}const N4=n=>new jl;class M4 extends Qh{constructor(e,t,r){super(e,t),this.keysChanged=r}}class $l extends an{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new $l}clone(){const e=new $l;return this.forEach((t,r)=>{e.set(r,t instanceof an?t.clone():t)}),e}_callObserver(e,t){Xh(this,e,new M4(this,e,t))}toJSON(){const e={};return this._map.forEach((t,r)=>{if(!t.deleted){const s=t.content.getContent()[t.length-1];e[r]=s instanceof an?s.toJSON():s}}),e}get size(){return[...tp(this._map)].length}keys(){return $0(tp(this._map),e=>e[0])}values(){return $0(tp(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return $0(tp(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this._map.forEach((t,r)=>{t.deleted||e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?ot(this.doc,t=>{ep(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?ot(this.doc,r=>{rb(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return sb(this,e)}has(e){return HC(this,e)}clear(){this.doc!==null?ot(this.doc,e=>{this.forEach(function(t,r,s){ep(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Z4)}}const R4=n=>new $l,Gi=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&m3(n,e);class ib{constructor(e,t,r,s){this.left=e,this.right=t,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&gr(),this.right.content.constructor){case Bt:this.right.deleted||zl(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const jC=(n,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case Bt:e.right.deleted||zl(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&jn(n,Ne(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},np=(n,e,t,r)=>{const s=new Map,i=r?Yh(e,t):null;if(i){const o=new ib(i.p.left,i.p,i.index,s);return jC(n,o,t-i.index)}else{const o=new ib(null,e._start,0,s);return jC(n,o,t)}},$C=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===Bt&&Gi(r.get(t.right.content.key),t.right.content.value));)t.right.deleted||r.delete(t.right.content.key),t.forward();const s=n.doc,i=s.clientID;r.forEach((o,a)=>{const l=t.left,c=t.right,u=new ht(Ne(i,Mt(s.store,i)),l,l&&l.lastId,c,c&&c.id,e,null,new Bt(a,o));u.integrate(n,0),t.right=u,t.forward()})},zl=(n,e)=>{const{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},zC=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===Bt&&Gi(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},VC=(n,e,t,r)=>{const s=n.doc,i=s.clientID,o=new Map;for(const a in r){const l=r[a],c=t.currentAttributes.get(a)??null;if(!Gi(c,l)){o.set(a,c);const{left:u,right:f}=t;t.right=new ht(Ne(i,Mt(s.store,i)),u,u&&u.lastId,f,f&&f.id,e,null,new Bt(a,l)),t.right.integrate(n,0),t.forward()}}return o},ob=(n,e,t,r,s)=>{t.currentAttributes.forEach((d,h)=>{s[h]===void 0&&(s[h]=null)});const i=n.doc,o=i.clientID;zC(t,s);const a=VC(n,e,t,s),l=r.constructor===String?new Fr(r):r instanceof an?new Ur(r):new aa(r);let{left:c,right:u,index:f}=t;e._searchMarker&&Sf(e._searchMarker,t.index,l.getLength()),u=new ht(Ne(o,Mt(i.store,o)),c,c&&c.lastId,u,u&&u.id,e,null,l),u.integrate(n,0),t.right=u,t.index=f,t.forward(),$C(n,e,t,a)},WC=(n,e,t,r,s)=>{const i=n.doc,o=i.clientID;zC(t,s);const a=VC(n,e,t,s);e:for(;t.right!==null&&(r>0||a.size>0&&(t.right.deleted||t.right.content.constructor===Bt));){if(!t.right.deleted)switch(t.right.content.constructor){case Bt:{const{key:l,value:c}=t.right.content,u=s[l];if(u!==void 0){if(Gi(u,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}t.right.delete(n)}else t.currentAttributes.set(l,c);break}default:r<t.right.length&&jn(n,Ne(t.right.id.client,t.right.id.clock+r)),r-=t.right.length;break}t.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
372
|
+
*/const QE=Re("Youtube",[["path",{d:"M2.5 17a24.12 24.12 0 0 1 0-10 2 2 0 0 1 1.4-1.4 49.56 49.56 0 0 1 16.2 0A2 2 0 0 1 21.5 7a24.12 24.12 0 0 1 0 10 2 2 0 0 1-1.4 1.4 49.55 49.55 0 0 1-16.2 0A2 2 0 0 1 2.5 17",key:"1q2vi4"}],["path",{d:"m10 15 5-3-5-3z",key:"1jp15x"}]]),lF=({editor:n,isOpen:e,setIsOpen:t})=>{const r=[{name:"Text",icon:KE,command:()=>n.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{name:"Heading 1",icon:c0,command:()=>n.chain().focus().toggleHeading({level:1}).run(),isActive:()=>n.isActive("heading",{level:1})},{name:"Heading 2",icon:u0,command:()=>n.chain().focus().toggleHeading({level:2}).run(),isActive:()=>n.isActive("heading",{level:2})},{name:"Heading 3",icon:f0,command:()=>n.chain().focus().toggleHeading({level:3}).run(),isActive:()=>n.isActive("heading",{level:3})},{name:"To-do List",icon:WE,command:()=>n.chain().focus().toggleTaskList().run(),isActive:()=>n.isActive("taskItem")},{name:"Bullet List",icon:ff,command:()=>n.chain().focus().toggleBulletList().run(),isActive:()=>n.isActive("bulletList")},{name:"Numbered List",icon:ff,command:()=>n.chain().focus().toggleOrderedList().run(),isActive:()=>n.isActive("orderedList")},{name:"Quote",icon:h0,command:()=>n.chain().focus().toggleNode("paragraph","paragraph").toggleBlockquote().run(),isActive:()=>n.isActive("blockquote")},{name:"Code",icon:Rh,command:()=>n.chain().focus().toggleCode().run(),isActive:()=>n.isActive("code")}],s=r.filter(i=>i.isActive()).pop()??{name:"Multiple"};return _.jsxs("div",{className:"relative h-full",children:[_.jsxs("button",{className:"flex h-full items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200",onClick:()=>t(!e),children:[_.jsx("span",{children:s==null?void 0:s.name}),_.jsx(Mh,{className:"h-4 w-4"})]}),e&&_.jsx("section",{className:"fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1",children:r.map((i,o)=>_.jsxs("button",{onClick:()=>{i.command(),t(!1)},className:je("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":i.isActive()}),children:[_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx("div",{className:"rounded-sm border border-stone-200 p-1",children:_.jsx(i.icon,{className:"h-3 w-3"})}),_.jsx("span",{children:i.name})]}),s.name===i.name&&_.jsx(Nh,{className:"h-4 w-4"})]},o))})]})},cF=({editor:n,isOpen:e,setIsOpen:t})=>{const r=[{name:"Default",color:"#000000"},{name:"Purple",color:"#9333EA"},{name:"Red",color:"#E00000"},{name:"Blue",color:"#2563EB"},{name:"Green",color:"#008A00"},{name:"Orange",color:"#FFA500"},{name:"Pink",color:"#BA4081"},{name:"Gray",color:"#A8A29E"}],s=r.find(({color:i})=>n.isActive("textStyle",{color:i}));return _.jsxs("div",{className:"",children:[_.jsxs("button",{className:"flex h-[100%] items-center gap-1 p-2 text-sm font-medium text-stone-600 hover:bg-stone-100 active:bg-stone-200",onClick:()=>t(!e),children:[_.jsx("span",{style:{color:(s==null?void 0:s.color)||"#000000"},children:"A"}),_.jsx(Mh,{className:"h-4 w-4 "})]}),e&&_.jsx("section",{className:"fixed top-full z-[99999] mt-1 flex w-48 flex-col overflow-hidden rounded border border-stone-200 bg-white p-1 shadow-xl animate-in fade-in slide-in-from-top-1",children:r.map(({name:i,color:o},a)=>_.jsxs("button",{onClick:()=>{n.chain().focus().setColor(o).run(),t(!1)},className:je("flex items-center justify-between rounded-sm px-2 py-1 text-sm text-stone-600 hover:bg-stone-100",{"text-blue-600":n.isActive("textStyle",{color:o})}),children:[_.jsxs("div",{className:"flex items-center space-x-2",children:[_.jsx("div",{className:"rounded-sm border border-stone-200 px-1 py-px font-medium",style:{color:o},children:"A"}),_.jsx("span",{children:i})]}),n.isActive("textStyle",{color:o})&&_.jsx(Nh,{className:"h-4 w-4"})]},a))})]})};var Te=(n=>(n[n.NONE=0]="NONE",n[n.HEADING=1]="HEADING",n[n.TEXT_COLOR=2]="TEXT_COLOR",n[n.HIGHLIGHT=3]="HIGHLIGHT",n[n.LINK=4]="LINK",n[n.FONT_FAMILY=5]="FONT_FAMILY",n[n.ALIGNMENT=6]="ALIGNMENT",n[n.LIST=7]="LIST",n))(Te||{});function uF(n){const[e,t]=R.useState(n),r=R.useRef(null),s=i=>{r&&r.current&&!r.current.contains(i.target)&&t(0)};return R.useEffect(()=>(document.addEventListener("click",s,!0),()=>{document.removeEventListener("click",s,!0)}),[]),{ref:r,toolVisibilty:e,setToolVisibility:t}}const Ph=new vt("upload-image"),fF=()=>new ut({key:Ph,state:{init(){return ft.empty},apply(n,e){e=e.map(n.mapping,n.doc);const t=n.getMeta(this);if(t&&t.add){const{id:r,pos:s,src:i}=t.add,o=document.createElement("div");o.setAttribute("class","img-placeholder");const a=document.createElement("img");a.setAttribute("class","rounded-lg border border-stone-200"),a.src=i,o.appendChild(a);const l=Ht.widget(s+1,o,{id:r});e=e.add(n.doc,[l])}else t&&t.remove&&(e=e.remove(e.find(void 0,void 0,r=>r.id==t.remove.id)));return e}},props:{decorations(n){return this.getState(n)}}});function dF(n,e){const r=Ph.getState(n).find(null,null,s=>s.id==e);return r.length?r[0].from:null}function YE(n,e,t){if(n.type.includes("image/")){if(n.size>1024*1024){console.log("failed");return}}else{console.log("file is not an image");return}const r={},s=e.state.tr;s.selection.empty||s.deleteSelection();const i=new FileReader;i.readAsDataURL(n),i.onload=()=>{s.setMeta(Ph,{add:{id:r,pos:t,src:i.result}}),e.dispatch(s)},hF(n).then(o=>{const{schema:a}=e.state,l=dF(e.state,r);if(l==null)return;const c=typeof o=="object"?i.result:o,u=a.nodes.resizableMedia.create({src:c,"media-type":"img"}),f=e.state.tr.replaceWith(l-2,l+u.nodeSize,u).setMeta(Ph,{remove:{id:r}});e.dispatch(f)})}const hF=n=>new Promise(e=>{const t=new FileReader;t.readAsDataURL(n),t.onload=()=>e(t.result)}),pF=async n=>{const e=new FileReader;if(e.readAsDataURL(n),n.size>1024*1024)throw e.abort(),console.log("should be less than 1 mb"),new Error("Image too large");return await new Promise(r=>{e.onload=()=>{r(e.result)}})},XE=[{title:"Trebuchet MS",value:"Trebuchet MS, sans-serif",command:n=>{n.chain().focus().setFontFamily("Trebuchet MS, sans-serif").run()}},{title:"Verdana",value:"Verdana, Geneva, sans-serif",command:n=>{n.chain().focus().setFontFamily("Verdana, Geneva, sans-serif").run()}},{title:"Georgia",value:"Georgia, serif",command:n=>{n.chain().focus().setFontFamily("Georgia, serif").run()}},{title:"Arial",value:"Arial, Helvetica, sans-serif",command:n=>{n.chain().focus().setFontFamily("Arial, Helvetica, sans-serif").run()}},{title:"Comic Sans MS",value:"Comic Sans MS, Comic Sans",command:n=>{n.chain().focus().setFontFamily("Comic Sans MS, Comic Sans").run()}},{title:"Impact",value:"Impact, Charcoal, sans-serif",command:n=>{n.chain().focus().setFontFamily("Impact, Charcoal, sans-serif").run()}},{title:"Palatino",value:"Palatino Linotype, Book Antiqua, Palatino, serif",command:n=>{n.chain().focus().setFontFamily("Palatino Linotype, Book Antiqua, Palatino, serif").run()}},{title:"Lucida Grande",value:"Lucida Sans Unicode, Lucida Grande, sans-serif",command:n=>{n.chain().focus().setFontFamily("Lucida Sans Unicode, Lucida Grande, sans-serif").run()}},{title:"Serif",value:"serif",command:n=>{n.chain().focus().setFontFamily("serif").run()}},{title:"Monospace",value:"monospace",command:n=>{n.chain().focus().setFontFamily("monospace").run()}},{title:"Cursive",value:"cursive",command:n=>{n.chain().focus().setFontFamily("cursive").run()}}],ZE=({editor:n})=>{const{ref:e,toolVisibilty:t,setToolVisibility:r}=uF(Te.NONE);return{toolbar:[{icon:_.jsx(WB,{size:20}),title:"Text Color",onClick:()=>r(Te.TEXT_COLOR),isActive:t===Te.TEXT_COLOR},{icon:_.jsx(jE,{size:20}),title:"Highlight",onClick:()=>r(Te.HIGHLIGHT),isActive:t===Te.HIGHLIGHT},null,{icon:_.jsx(UE,{size:20}),title:"Bold",onClick:()=>n==null?void 0:n.chain().focus().toggleBold().run(),isActive:n==null?void 0:n.isActive("bold")},{icon:_.jsx($E,{size:20}),title:"Italic",onClick:()=>n==null?void 0:n.chain().focus().toggleItalic().run(),isActive:n==null?void 0:n.isActive("italic")},{icon:_.jsx(qE,{size:20}),title:"Underlined",onClick:()=>n==null?void 0:n.chain().focus().toggleUnderline().run(),isActive:n==null?void 0:n.isActive("underline")},{icon:_.jsx(GE,{size:20}),title:"Strikethrough",onClick:()=>n==null?void 0:n.chain().focus().toggleStrike().run(),isActive:n==null?void 0:n.isActive("strike")},null,{icon:_.jsx(d0,{size:20}),title:"List",onClick:()=>{n==null||n.chain().focus().toggleBulletList().run(),r(Te.NONE)},isActive:t===Te.LIST},{icon:_.jsx(ff,{size:20}),title:"Ordered List",onClick:()=>{n==null||n.chain().focus().toggleOrderedList().run(),r(Te.NONE)},isActive:t===Te.LIST},{icon:_.jsx(VE,{size:20}),title:"To-do List",onClick:()=>{n==null||n.chain().focus().toggleTaskList().run(),r(Te.NONE)},isActive:t===Te.LIST},{icon:_.jsx(l0,{size:20}),title:"Alignment",onClick:()=>r(Te.ALIGNMENT),isActive:t===Te.ALIGNMENT},{icon:_.jsx(h0,{size:20}),title:"Quote",onClick:()=>n==null?void 0:n.chain().focus().toggleBlockquote().run(),isActive:n==null?void 0:n.isActive("blockquote")},null,{icon:_.jsx(YB,{size:20}),title:"Upload Image",onClick:()=>{n==null||n.chain().focus().deleteRange(n.state.selection).run();const i=document.createElement("input");i.type="file",i.accept="image/*",i.onchange=async()=>{var o;if((o=i.files)!=null&&o.length){const a=i.files[0],l=n.view.state.selection.from;YE(a,n.view,l)}},i.click()},isActive:!1},{icon:_.jsx(zE,{size:20}),title:"Link",onClick:()=>r(Te.LINK),isActive:n==null?void 0:n.isActive("link")},{icon:_.jsx(Rh,{size:20}),title:"Code",onClick:()=>n==null?void 0:n.chain().focus().toggleCodeBlock().run(),isActive:n==null?void 0:n.isActive("codeBlock")}],toolRef:e,toolVisibilty:t,setToolVisibility:r}},ek=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return _.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[20%] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all",children:[_.jsx(FE,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetHighlight().run(),e(Te.NONE)}}),r.map(s=>_.jsx("div",{onClick:()=>{n.chain().focus().toggleHighlight({color:s.color}).run(),e(Te.NONE)},className:je("w-6 drop-shadow rounded-full flex items-center justify-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",s.code),children:_.jsx(Nh,{size:14,className:je(n.isActive("highlight",{color:s.color})?"visible":"invisible")})},s.color))]})},mF=({elementRef:n,editor:e,setToolVisibility:t})=>_.jsx("div",{ref:n,className:je("z-50 h-auto absolute top-[50px] left-0 max-h-[330px] w-48 overflow-y-auto scroll-smooth bg-white px-1 py-2 shadow-elevation-3 transition-all animate-in fade-in slide-in-from-top-1"),children:XE.map(r=>_.jsx("button",{onClick:()=>{r.command(e),t(Te.NONE)},style:{fontFamily:r.title},className:je("flex w-full items-center space-x-2 rounded px-2 py-1 text-left text-sm color-text-default",e.isActive("textStyle",{fontFamily:r.value})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:_.jsx("p",{className:"font-medium",children:r.title})},r.title))}),tk=({elementRef:n,editor:e,setToolVisibility:t})=>_.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-[50px] right-[25%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all",children:[_.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("left").run(),t(Te.NONE)},className:je("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer",e.isActive({textAlign:"left"})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:_.jsx(l0,{})}),_.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("center").run(),t(Te.NONE)},className:je("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer",e.isActive({textAlign:"center"})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:_.jsx(zB,{})}),_.jsx("span",{onClick:()=>{e==null||e.chain().focus().setTextAlign("right").run(),t(Te.NONE)},className:je("rounded w-8 h-8 p-1 flex justify-center items-center cursor-pointer",e.isActive({textAlign:"right"})?"color-bg-brand hover:color-bg-brand-hover":"hover:bg-[#f2f2f2]"),children:_.jsx(VB,{})})]}),gF=({elementRef:n,editor:e,setToolVisibility:t})=>_.jsxs("div",{ref:n,className:je("z-50 h-auto absolute gap-2 top-[50px] right-[30%] flex flex-wrap max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all"),children:[_.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"unordered list",children:_.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleBulletList().run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("bulletList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:_.jsx(d0,{size:20})})}),_.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"ordered list",children:_.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleOrderedList().run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("orderedList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:_.jsx(ff,{size:20})})}),_.jsx("div",{className:"tooltip tooltip-open tooltip-bottom","data-tip":"to-do list",children:_.jsx("span",{onClick:()=>{e==null||e.chain().focus().toggleTaskList().run(),t(Te.NONE)},className:` hover:bg-[#f2f2f2] ${e.isActive("taskList")?"bg-[#f2f2f2]":""} rounded-lg w-8 h-8 p-1 flex justify-center items-center`,children:_.jsx(VE,{size:20})})})]}),nk=({elementRef:n,editor:e,setToolVisibility:t,bubbleMenu:r,setIsLinkPopupOpen:s})=>{const[i,o]=R.useState(e.getAttributes("link").href),a=()=>{if(i===null)return;if(i===""){e.chain().focus().extendMarkRange("link").unsetLink().run();return}let l=i;!i.startsWith("http://")&&!i.startsWith("https://")&&(l="https://"+i);try{l.match(/^((http|https):\/\/)?([w|W]{3}\.)+[a-zA-Z0-9\-\.]{3,}\.[a-zA-Z]{2,}(\.[a-zA-Z]{2,})?$/)&&e.chain().focus().extendMarkRange("link").setLink({href:l}).run()}catch{console.error("Invalid URL");return}e.chain().focus().extendMarkRange("link").setLink({href:l}).run(),t(Te.NONE),r&&s&&s(!1)};return _.jsxs("div",{ref:n,className:"z-50 h-auto absolute gap-2 top-[50px] items-center flex right-[10%] max-h-[330px] overflow-y-auto scroll-smooth rounded bg-white p-2 shadow-elevation-3 transition-all",children:[_.jsx("input",{onChange:l=>o(l.target.value),className:"shadow-none border-[1px]",placeholder:"Add link here",value:i}),_.jsx("div",{className:"h-full flex items-center",children:_.jsx("button",{onClick:()=>a(),className:"min-w-fit",children:"Apply"})})]})},yF=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{color:"#00FF00",code:"bg-[#00FF00]"},{color:"#008080",code:"bg-[#008080]"},{color:"#FFC0CB",code:"bg-[#FFC0CB]"},{color:"#808000",code:"bg-[#808000]"},{color:"#800000",code:"bg-[#800000]"},{color:"#000080",code:"bg-[#000080]"},{color:"#7FFFD4",code:"bg-[#7FFFD4]"},{color:"#40E0D0",code:"bg-[#40E0D0]"},{color:"#C0C0C0",code:"bg-[#C0C0C0]"},{color:"#808080",code:"bg-[#808080]"},{color:"#000000",code:"bg-[#000000]"},{color:"#FFFFFF",code:"bg-[#FFFFFF]"},{color:"#CD5C5C",code:"bg-[#CD5C5C]"},{color:"#F08080",code:"bg-[#F08080]"},{color:"#FA8072",code:"bg-[#FA8072]"},{color:"#E9967A",code:"bg-[#E9967A]"},{color:"#FFA07A",code:"bg-[#FFA07A]"},{color:"#DC143C",code:"bg-[#DC143C]"},{color:"#FF6347",code:"bg-[#FF6347]"},{color:"#FF7F50",code:"bg-[#FF7F50]"},{color:"#FF4500",code:"bg-[#FF4500]"},{color:"#BDB76B",code:"bg-[#BDB76B]"},{color:"#FFD700",code:"bg-[#FFD700]"},{color:"#F0E68C",code:"bg-[#F0E68C]"},{color:"#FFE5B4",code:"bg-[#FFE5B4]"},{color:"#9ACD32",code:"bg-[#9ACD32]"},{color:"#556B2F",code:"bg-[#556B2F]"},{color:"#6B8E23",code:"bg-[#6B8E23]"},{color:"#7CFC00",code:"bg-[#7CFC00]"},{color:"#7FFF00",code:"bg-[#7FFF00]"},{color:"#ADFF2F",code:"bg-[#ADFF2F]"},{color:"#00BFFF",code:"bg-[#00BFFF]"},{color:"#1E90FF",code:"bg-[#1E90FF]"},{color:"#6495ED",code:"bg-[#6495ED]"},{color:"#4682B4",code:"bg-[#4682B4]"},{color:"#4169E1",code:"bg-[#4169E1]"},{color:"#8A2BE2",code:"bg-[#8A2BE2]"},{color:"#4B0082",code:"bg-[#4B0082]"},{color:"#6A5ACD",code:"bg-[#6A5ACD]"}];return _.jsxs("div",{ref:t,className:"z-50 h-auto absolute gap-2 top-[50px] flex flex-wrap left-[100px] max-h-[330px] w-[20.5rem] overflow-y-auto scroll-smooth rounded bg-white px-1 py-2 shadow-elevation-3 transition-all",children:[_.jsx(FE,{className:"cursor-pointer",onClick:()=>{n.chain().focus().unsetColor().run(),e(Te.NONE)}}),r.map(s=>_.jsx("div",{onClick:()=>{n.chain().focus().setColor(s.color).run(),e(Te.NONE)},className:je("w-6 drop-shadow rounded-full flex justify-center items-center cursor-pointer ease-in duration-200 hover:scale-[1.05] h-6",s.code),children:_.jsx(Nh,{size:14,className:je(n.isActive("textStyle",{color:s.color})?"visible":"invisible")})},s.color))]})},bF=({editor:n,setVisibility:e,elementRef:t})=>{const r=[{title:"Text",description:"Normal",icon:_.jsx(aF,{size:20}),command:s=>s.chain().focus().toggleNode("paragraph","paragraph").run(),isActive:()=>n.isActive("paragraph")&&!n.isActive("bulletList")&&!n.isActive("orderedList")},{title:"Heading 1",description:"Big",icon:_.jsx(c0,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:1}).run()},isActive:()=>n.isActive("heading",{level:1})},{title:"Heading 2",description:"Medium",icon:_.jsx(u0,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:2}).run()},isActive:()=>n.isActive("heading",{level:2})},{title:"Heading 3",description:"Small",icon:_.jsx(f0,{size:20}),command:s=>{s.chain().focus().toggleHeading({level:3}).run()},isActive:()=>n.isActive("heading",{level:3})}];return _.jsx("div",{ref:t,className:je("absolute top-[50px] z-50 mt-1 flex w-48 flex-col overflow-hidden rounded bg-white p-1 shadow-elevation-3 animate-in fade-in slide-in-from-top-1","left-0"),children:r.map(s=>_.jsxs("button",{onClick:()=>{s.command(n),e(Te.NONE)},className:je("flex w-full items-center space-x-2 rounded-md px-2 py-1 text-left text-sm color-text-default",{"color-bg-brand hover:color-bg-brand-hover":s.isActive(),"hover:bg-[#f2f2f2]":!s.isActive()}),children:[_.jsx("div",{className:"flex h-10 w-10 items-center justify-center rounded bg-white",children:s.icon}),_.jsxs("div",{children:[_.jsx("p",{className:"font-medium",children:s.title}),_.jsxs("p",{className:"text-xs text-stone-500",children:[" ",s.description," "]})]})]},s.title))})},wF=n=>{const e=[{name:"Bold",isActive:()=>n.editor.isActive("bold"),command:()=>n.editor.chain().focus().toggleBold().run(),icon:_.jsx(UE,{size:20})},{name:"Italic",isActive:()=>n.editor.isActive("italic"),command:()=>n.editor.chain().focus().toggleItalic().run(),icon:_.jsx($E,{size:20})},{name:"Underline",isActive:()=>n.editor.isActive("underline"),command:()=>n.editor.chain().focus().toggleUnderline().run(),icon:_.jsx(qE,{size:20})},{name:"Strikethrough",isActive:()=>n.editor.isActive("strike"),command:()=>n.editor.chain().focus().toggleStrike().run(),icon:_.jsx(GE,{size:20})},{name:"Alignment",isActive:()=>f===Te.ALIGNMENT,command:()=>u(Te.ALIGNMENT),icon:_.jsx(l0,{size:20})},{name:"Code",isActive:()=>n.editor.isActive("codeBlock"),command:()=>n.editor.chain().focus().toggleCodeBlock().run(),icon:_.jsx(Rh,{size:20})},{name:"Link",isActive:()=>n.editor.isActive("link"),command:()=>l(!a),icon:_.jsx(zE,{size:20})}],t={...n,shouldShow:({state:d,editor:h})=>{const{selection:p}=d,{empty:g}=p;return!(h.isActive("image")||g||Ux(p))},tippyOptions:{moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",onHidden:()=>{s(!1),o(!1),l(!1)}}},[r,s]=R.useState(!1),[i,o]=R.useState(!1),[a,l]=R.useState(!1),{toolRef:c,setToolVisibility:u,toolVisibilty:f}=ZE({editor:n.editor});return _.jsxs(RE,{...t,className:"flex gap-1 overflow-hidden rounded-[12px] h-[52px] min-w-[472px] w-full py-2 px-4 bg-white items-center shadow-elevation-3",children:[_.jsx(lF,{editor:n.editor,isOpen:r,setIsOpen:()=>{s(!r),o(!1)}}),_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"}),e.map((d,h)=>_.jsxs("div",{className:"flex items-center gap-1",children:[_.jsx("button",{onClick:d.command,className:je("min-w-fit w-8 h-8 px-2",{"color-bg-brand":d.isActive()}),children:d.icon}),(h===4||h===6)&&_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"})]},h)),_.jsx(cF,{editor:n.editor,isOpen:i,setIsOpen:()=>{o(!i),s(!1)}}),_.jsx("button",{onClick:()=>u(Te.HIGHLIGHT),className:je("min-w-fit w-8 h-8 px-2",{"color-bg-brand":f===Te.HIGHLIGHT}),children:_.jsx(jE,{size:20})}),f===Te.ALIGNMENT&&_.jsx(tk,{setToolVisibility:u,editor:n.editor,elementRef:c}),a&&_.jsx(nk,{setToolVisibility:u,editor:n.editor,elementRef:c,bubbleMenu:!0,setIsLinkPopupOpen:l}),f===Te.HIGHLIGHT&&_.jsx(ek,{setVisibility:u,editor:n.editor,elementRef:c})]})};function vF(){const n=["a","b","c","d","e","f","0","1","2","3","4","5","6","7","8","9"];let e=[];for(let t=0;t<36;t++)t===8||t===13||t===18||t===23?e[t]="-":e[t]=n[Math.ceil(Math.random()*n.length-1)];return e.join("")}var AF=vF;const xF=_g(AF),rk=dt.create({name:"column",content:"dBlock+",isolating:!0,addAttributes(){return{position:{default:"",parseHTML:n=>n.getAttribute("data-position"),renderHTML:n=>({"data-position":n.position})}}},renderHTML({HTMLAttributes:n}){return["div",Ue(n,{"data-type":"column"}),0]},parseHTML(){return[{tag:'div[data-type="column"]'}]}}),EF=(n,e)=>Array.from({length:n},(t,r)=>e(r)),Dh=({type:n,content:e})=>e?{type:n,content:e}:{type:n},kF=({content:n})=>Dh({type:"paragraph",content:n}),sk=({content:n})=>Dh({type:"dBlock",content:n}),ik=({content:n})=>Dh({type:"column",content:n}),ok=({content:n})=>Dh({type:"columns",content:n}),ak=n=>{const e=[sk({content:[kF({})]})];return EF(n,()=>ik({content:e}))},lk=(n,e)=>{for(let t=n.depth;t>0;t--){const r=n.node(t),s=t>0?n.before(t):0,i=n.start(t);if(e({node:r,pos:s,start:i}))return{start:i,depth:t,node:r,pos:s}}throw Error("no ancestor found")};class Ih extends xe{constructor(t){const{$from:r,$to:s}=t;super(r,s);j(this,"_$from");j(this,"_$to");this._$from=r,this._$to=s}get $from(){return this._$from}get $to(){return this._$to}map(){return this}content(){return this.$from.doc.slice(this.from,this.to,!0)}eq(t){return t instanceof Ih&&t.anchor==this.anchor}toJSON(){return{type:"column",from:this.from,to:this.to}}expandSelection(t){var l;const r=({pos:c,node:u})=>u.type.name===rk.name?!0:t.resolve(c).depth<=0,{pos:s}=lk(this.$from,r);this._$from=t.resolve(s);const{pos:i,node:o}=lk(this.$to,r);this._$to=t.resolve(i+o.nodeSize),((l=this.getFirstNode())==null?void 0:l.type.name)===_h.name&&(this._$from=t.resolve(this.$from.pos+2),this._$to=t.resolve(this.$to.pos+2));const a=this;a.$anchor=this._$from,a.$head=this._$to,a.ranges=[new Xg(this._$from,this._$to)]}static create(t,r,s){const i=t.resolve(r),o=t.resolve(s),a=new Ae(i,o);return new Ih(a)}getFirstNode(){return this.content().content.firstChild}}var Zo=(n=>(n.AlignLeft="align-left",n.AlignRight="align-right",n.AlignCenter="align-center",n))(Zo||{});const _h=dt.create({name:"columns",group:"columns",content:"column{2,}",defining:!0,draggable:!0,isolating:!0,addAttributes(){return{layout:{default:"align-center"}}},addCommands(){return{unsetColumns:()=>({tr:n,dispatch:e})=>{try{if(!e)return;const t=n.selection.$from,s=By(t,({node:l})=>!this.options.nestedColumns&&l.type==this.type?!0:l.type==this.type);if(s===void 0)return;let i=[];s.node.descendants((l,c,u)=>{(u==null?void 0:u.type.name)===_h.name&&i.push(l)}),i=i.reverse().filter(l=>l.content.size>0);const o=n.doc.resolve(s.pos),a=new ye(o);return n=n.setSelection(a),i.forEach(l=>n=n.insert(s.pos,l)),n=n.deleteSelection(),e(n)}catch(t){console.error(t)}},setColumns:(n,e=!1)=>({tr:t,dispatch:r})=>{try{const{doc:s,selection:i}=t;if(!r){console.log("no dispatch");return}const o=new Ih(i);o.expandSelection(s);const{openStart:a,openEnd:l}=o.content();if(a!==l){console.warn("failed depth check");return}let c;if(e){const h=o.content().toJSON(),p=ik(h),g=ak(n-1);c=ok({content:[p,...g]})}else{const h=ak(n);c=ok({content:h})}const u=s.type.schema.nodeFromJSON(sk({content:[c]}));if(u===null)return;const f=o.$anchor.parent.type;if(!(h=>!(!h.contentMatch.matchType(this.type)||!this.options.nestedColumns&&h.name===_h.name))(f)){console.warn("content not allowed");return}return t=t.setSelection(o),t=t.replaceSelectionWith(u,!1),r(t)}catch(s){console.error(s)}},setLayout:n=>({commands:e})=>e.updateAttributes("columns",{layout:n})}},renderHTML({HTMLAttributes:n}){return["div",{"data-type":"columns",class:`layout-${n.layout}`},0]},parseHTML(){return[{tag:'div[data-type="columns"]'}]}}),CF=(n,e)=>{const{view:t,state:{selection:{from:r}}}=n,s=document.querySelectorAll(".has-focus"),i=s.length,a=s[i-1];if(a&&a.getAttribute("data-type")&&a.getAttribute("data-type")===e||a&&a.classList&&a.classList.contains(e))return a;const l=t.domAtPos(r).node;let c=l;for(c.tagName||(c=l.parentElement);c&&!(c.getAttribute("data-type")&&c.getAttribute("data-type")===e)&&!c.classList.contains(e);)c=c.parentElement;return c},p0=R.forwardRef(({children:n,className:e,withShadow:t=!0,withBorder:r=!0,...s},i)=>{const o=je(e,"bg-white rounded-md",t?"shadow-md":"",r?"border border-neutral-200":"");return _.jsx("div",{className:o,...s,ref:i,children:n})});p0.displayName="Surface";const ck=R.forwardRef(({active:n,buttonSize:e="medium",children:t,disabled:r,variant:s="primary",className:i,activeClassname:o,...a},l)=>{const c=je("flex group items-center justify-center border border-transparent gap-2 text-sm font-semibold rounded disabled:opacity-50 whitespace-nowrap",s==="primary"&&je("text-white bg-black border-black dark:text-black dark:bg-white dark:border-white",!r&&!n&&"hover:bg-neutral-800 active:bg-neutral-900 dark:hover:bg-neutral-200 dark:active:bg-neutral-300",n&&je("bg-neutral-900 dark:bg-neutral-300",o)),s==="secondary"&&je("text-neutral-900 dark:text-white",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-900 dark:active:bg-neutral-800",n&&"bg-neutral-200 dark:bg-neutral-800"),s==="tertiary"&&je("bg-neutral-50 text-neutral-900 dark:bg-neutral-900 dark:text-white dark:border-neutral-900",!r&&!n&&"hover:bg-neutral-100 active:bg-neutral-200 dark:hover:bg-neutral-800 dark:active:bg-neutral-700",n&&je("bg-neutral-200 dark:bg-neutral-800",o)),s==="ghost"&&je("bg-transparent border-transparent text-neutral-500",!r&&!n&&"hover:bg-black/5 hover:text-neutral-700 active:bg-black/10 active:text-neutral-800 ",n&&je("bg-black/10 text-neutral-800 ",o)),e==="medium"&&"py-2 px-3",e==="small"&&"py-1 px-2",e==="icon"&&"w-8 h-8",e==="iconSmall"&&"w-6 h-6",i);return _.jsx("button",{ref:l,disabled:r,className:c,...a,children:t})});ck.displayName="Button";const uk=({content:n,children:e})=>{const[t,r]=R.useState(!1);return _.jsxs("div",{className:"relative inline-block",onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),children:[e,t&&_.jsx("div",{className:"absolute z-10 p-2 mt-2 text-sm text-white bg-gray-800 rounded shadow-lg",children:n})]})},fk=R.forwardRef(({shouldShowContent:n=!0,children:e,isVertical:t=!1,className:r,...s},i)=>{const o=je("text-black inline-flex h-full leading-none gap-0.5",t?"flex-col p-2":"flex-row p-1 items-center",r);return n?n&&_.jsx(p0,{className:o,...s,ref:i,children:e}):null});fk.displayName="Toolbar";const dk=R.forwardRef(({horizontal:n,className:e,...t},r)=>{const s=je("bg-neutral-200",n?"w-full min-w-[1.5rem] h-[1px] my-1 first:mt-0 last:mt-0":"h-full min-h-[1.5rem] w-[1px] mx-1 first:ml-0 last:mr-0",e);return _.jsx("div",{className:s,ref:r,...t})});dk.displayName="Toolbar.Divider";const hk=R.forwardRef(({children:n,buttonSize:e="icon",variant:t="ghost",className:r,tooltip:s,activeClassname:i,...o},a)=>{const l=je("gap-1 min-w-[2rem] px-2 w-auto",r),c=_.jsx(ck,{activeClassname:i,className:l,variant:t,buttonSize:e,ref:a,...o,children:n});return s?_.jsx(uk,{content:s,children:c}):c});hk.displayName="ToolbarButton";const df={Wrapper:fk,Divider:dk,Button:hk},SF=({editor:n,appendTo:e})=>{const t=R.useCallback(()=>{const a=CF(n,"columns");return(a==null?void 0:a.getBoundingClientRect())||new DOMRect(-1e3,-1e3,0,0)},[n]),r=R.useCallback(()=>n.isActive("columns"),[n]),s=R.useCallback(()=>{n.chain().focus().setLayout(Zo.AlignLeft).run()},[n]),i=R.useCallback(()=>{n.chain().focus().setLayout(Zo.AlignRight).run()},[n]),o=R.useCallback(()=>{n.chain().focus().setLayout(Zo.AlignCenter).run()},[n]);return _.jsx(RE,{editor:n,pluginKey:`columnsMenu-${xF()}`,shouldShow:r,updateDelay:0,tippyOptions:{offset:[0,8],popperOptions:{modifiers:[{name:"flip",enabled:!1}]},getReferenceClientRect:t,moveTransition:"transform 0.15s ease-out",duration:200,animation:"shift-toward-subtle",appendTo:()=>e==null?void 0:e.current,plugins:[TB],sticky:"popper"},children:_.jsxs(df.Wrapper,{children:[_.jsx(df.Button,{tooltip:"Align left",active:n.isActive("columns",{layout:Zo.AlignLeft}),onClick:s,children:_.jsx(eF,{size:20})}),_.jsx(df.Button,{tooltip:"Align center",active:n.isActive("columns",{layout:Zo.AlignCenter}),onClick:o,children:_.jsx(HE,{size:20})}),_.jsx(df.Button,{tooltip:"Align right",active:n.isActive("columns",{layout:Zo.AlignRight}),onClick:i,children:_.jsx(tF,{size:20})})]})})},pk=R.createContext(null),Lh=()=>R.useContext(pk),TF=({children:n,isPreviewMode:e})=>_.jsx(pk.Provider,{value:e,children:n}),mk=({height:n,width:e})=>_.jsx("span",{className:"flex items-center justify-center ",children:_.jsx("span",{className:`${e?`w-${e}`:"w-8"} ${n?`h-${n}`:"h-8"} border-4 border-t-4 border-t-[#ccc] border-gray-500 rounded-full animate-spin`})}),OF=({editor:n})=>{var i;const{toolRef:e,toolVisibilty:t,setToolVisibility:r,toolbar:s}=ZE({editor:n});return _.jsxs("div",{className:"w-fit bg-transparent px-4 items-center h-16 flex gap-1 justify-center",children:[_.jsxs("button",{className:"bg-transparent flex items-center gap-2 min-w-[55px]",onClick:()=>r(Te.FONT_FAMILY),children:[_.jsx("span",{className:"text-sm",children:((i=XE.find(o=>n==null?void 0:n.isActive("textStyle",{fontFamily:o.value})))==null?void 0:i.title)||"Font"}),_.jsx(Mh,{size:16})]}),_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"}),_.jsxs("button",{className:"bg-transparent gap-2 flex items-center min-w-[55px]",onClick:()=>r(Te.HEADING),children:[_.jsx("span",{className:"text-sm",children:n!=null&&n.isActive("heading",{level:1})?"Heading 1":n!=null&&n.isActive("heading",{level:2})?"Heading 2":n!=null&&n.isActive("heading",{level:3})?"Heading 3":"Text"}),_.jsx(Mh,{size:16})]}),_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"}),s.map((o,a)=>o?_.jsx("div",{className:"tooltip tooltip-bottom","data-tip":o.title,children:_.jsx("span",{onClick:()=>o.onClick(),className:je("rounded-lg w-8 h-8 p-1 flex cursor-pointer justify-center items-center",o.isActive?"bg-yellow-300":"hover:bg-[#f2f2f2]"),children:typeof o.icon=="string"?_.jsx("img",{src:o.icon,className:"w-4"}):o.icon})},o.title):_.jsx("div",{className:"w-px h-4 bg-gray-400 mx-2"},a)),t===Te.FONT_FAMILY&&_.jsx(mF,{setToolVisibility:r,editor:n,elementRef:e}),t===Te.HEADING&&_.jsx(bF,{setVisibility:r,editor:n,elementRef:e}),t===Te.TEXT_COLOR&&_.jsx(yF,{setVisibility:r,editor:n,elementRef:e}),t===Te.HIGHLIGHT&&_.jsx(ek,{setVisibility:r,editor:n,elementRef:e}),t===Te.ALIGNMENT&&_.jsx(tk,{setToolVisibility:r,editor:n,elementRef:e}),t===Te.LIST&&_.jsx(gF,{setToolVisibility:r,editor:n,elementRef:e}),t===Te.LINK&&_.jsx(nk,{setToolVisibility:r,editor:n,elementRef:e})]})},En=()=>new Map,m0=n=>{const e=En();return n.forEach((t,r)=>{e.set(r,t)}),e},Hn=(n,e,t)=>{let r=n.get(e);return r===void 0&&n.set(e,r=t()),r},NF=(n,e)=>{const t=[];for(const[r,s]of n)t.push(e(s,r));return t},MF=(n,e)=>{for(const[t,r]of n)if(e(r,t))return!0;return!1},Ws=()=>new Set,g0=n=>n[n.length-1],RF=(n,e)=>{for(let t=0;t<e.length;t++)n.push(e[t])},Gs=Array.from,PF=(n,e)=>{for(let t=0;t<n.length;t++)if(e(n[t],t,n))return!0;return!1},y0=Array.isArray;class b0{constructor(){this._observers=En()}on(e,t){return Hn(this._observers,e,Ws).add(t),t}once(e,t){const r=(...s)=>{this.off(e,r),t(...s)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return Gs((this._observers.get(e)||En()).values()).forEach(r=>r(...t))}destroy(){this._observers=En()}}class w0{constructor(){this._observers=En()}on(e,t){Hn(this._observers,e,Ws).add(t)}once(e,t){const r=(...s)=>{this.off(e,r),t(...s)};this.on(e,r)}off(e,t){const r=this._observers.get(e);r!==void 0&&(r.delete(t),r.size===0&&this._observers.delete(e))}emit(e,t){return Gs((this._observers.get(e)||En()).values()).forEach(r=>r(...t))}destroy(){this._observers=En()}}const _r=Math.floor,Bh=Math.abs,DF=Math.log10,zi=(n,e)=>n<e?n:e,Ks=(n,e)=>n>e?n:e,gk=n=>n!==0?n<0:1/n<0,ds=Date.now,IF=1200,_F=2500,Fh=3e4,v0=n=>{if(n.shouldConnect&&n.ws===null){const e=new WebSocket(n.url),t=n.binaryType;let r=null;t&&(e.binaryType=t),n.ws=e,n.connecting=!0,n.connected=!1,e.onmessage=o=>{n.lastMessageReceived=ds();const a=o.data,l=typeof a=="string"?JSON.parse(a):a;l&&l.type==="pong"&&(clearTimeout(r),r=setTimeout(i,Fh/2)),n.emit("message",[l,n])};const s=o=>{n.ws!==null&&(n.ws=null,n.connecting=!1,n.connected?(n.connected=!1,n.emit("disconnect",[{type:"disconnect",error:o},n])):n.unsuccessfulReconnects++,setTimeout(v0,zi(DF(n.unsuccessfulReconnects+1)*IF,_F),n)),clearTimeout(r)},i=()=>{n.ws===e&&n.send({type:"ping"})};e.onclose=()=>s(null),e.onerror=o=>s(o),e.onopen=()=>{n.lastMessageReceived=ds(),n.connecting=!1,n.connected=!0,n.unsuccessfulReconnects=0,n.emit("connect",[{type:"connect"},n]),r=setTimeout(i,Fh/2)}}};class LF extends w0{constructor(e,{binaryType:t}={}){super(),this.url=e,this.ws=null,this.binaryType=t||null,this.connected=!1,this.connecting=!1,this.unsuccessfulReconnects=0,this.lastMessageReceived=0,this.shouldConnect=!0,this._checkInterval=setInterval(()=>{this.connected&&Fh<ds()-this.lastMessageReceived&&this.ws.close()},Fh/2),v0(this)}send(e){this.ws&&this.ws.send(JSON.stringify(e))}destroy(){clearInterval(this._checkInterval),this.disconnect(),super.destroy()}disconnect(){this.shouldConnect=!1,this.ws!==null&&this.ws.close()}connect(){this.shouldConnect=!0,!this.connected&&this.ws===null&&v0(this)}}const Lr=n=>new Error(n),Br=()=>{throw Lr("Method unimplemented")},gr=()=>{throw Lr("Unexpected case")},yk=1,bk=2,A0=4,x0=8,hf=32,Js=64,Zn=128,Uh=31,E0=63,ea=127,BF=2147483647,FF=crypto.getRandomValues.bind(crypto),wk=Math.random,vk=()=>FF(new Uint32Array(1))[0],UF=n=>n[_r(wk()*n.length)],HF="10000000-1000-4000-8000"+-1e11,Ak=()=>HF.replace(/[018]/g,n=>(n^vk()&15>>n/4).toString(16)),xk=Number.MAX_SAFE_INTEGER,jF=Number.isInteger||(n=>typeof n=="number"&&isFinite(n)&&_r(n)===n),$F=String.fromCharCode,zF=n=>n.toLowerCase(),VF=/^\s*/g,WF=n=>n.replace(VF,""),GF=/([A-Z])/g,Ek=(n,e)=>WF(n.replace(GF,t=>`${e}${zF(t)}`)),KF=n=>{const e=unescape(encodeURIComponent(n)),t=e.length,r=new Uint8Array(t);for(let s=0;s<t;s++)r[s]=e.codePointAt(s);return r},pf=typeof TextEncoder<"u"?new TextEncoder:null,k0=pf?n=>pf.encode(n):KF;let mf=typeof TextDecoder>"u"?null:new TextDecoder("utf-8",{fatal:!0,ignoreBOM:!0});mf&&mf.decode(new Uint8Array).length===1&&(mf=null);class gf{constructor(){this.cpos=0,this.cbuf=new Uint8Array(100),this.bufs=[]}}const Jt=()=>new gf,JF=n=>{let e=n.cpos;for(let t=0;t<n.bufs.length;t++)e+=n.bufs[t].length;return e},At=n=>{const e=new Uint8Array(JF(n));let t=0;for(let r=0;r<n.bufs.length;r++){const s=n.bufs[r];e.set(s,t),t+=s.length}return e.set(new Uint8Array(n.cbuf.buffer,0,n.cpos),t),e},qF=(n,e)=>{const t=n.cbuf.length;t-n.cpos<e&&(n.bufs.push(new Uint8Array(n.cbuf.buffer,0,n.cpos)),n.cbuf=new Uint8Array(Ks(t,e)*2),n.cpos=0)},qt=(n,e)=>{const t=n.cbuf.length;n.cpos===t&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(t*2),n.cpos=0),n.cbuf[n.cpos++]=e},yf=qt,ve=(n,e)=>{for(;e>ea;)qt(n,Zn|ea&e),e=_r(e/128);qt(n,ea&e)},C0=(n,e)=>{const t=gk(e);for(t&&(e=-e),qt(n,(e>E0?Zn:0)|(t?Js:0)|E0&e),e=_r(e/64);e>0;)qt(n,(e>ea?Zn:0)|ea&e),e=_r(e/128)},S0=new Uint8Array(3e4),QF=S0.length/3,YF=(n,e)=>{if(e.length<QF){const t=pf.encodeInto(e,S0).written||0;ve(n,t);for(let r=0;r<t;r++)qt(n,S0[r])}else St(n,k0(e))},XF=(n,e)=>{const t=unescape(encodeURIComponent(e)),r=t.length;ve(n,r);for(let s=0;s<r;s++)qt(n,t.codePointAt(s))},hs=pf&&pf.encodeInto?YF:XF,Hh=(n,e)=>{const t=n.cbuf.length,r=n.cpos,s=zi(t-r,e.length),i=e.length-s;n.cbuf.set(e.subarray(0,s),r),n.cpos+=s,i>0&&(n.bufs.push(n.cbuf),n.cbuf=new Uint8Array(Ks(t*2,i)),n.cbuf.set(e.subarray(s)),n.cpos=i)},St=(n,e)=>{ve(n,e.byteLength),Hh(n,e)},T0=(n,e)=>{qF(n,e);const t=new DataView(n.cbuf.buffer,n.cpos,e);return n.cpos+=e,t},ZF=(n,e)=>T0(n,4).setFloat32(0,e,!1),e3=(n,e)=>T0(n,8).setFloat64(0,e,!1),t3=(n,e)=>T0(n,8).setBigInt64(0,e,!1),kk=new DataView(new ArrayBuffer(4)),n3=n=>(kk.setFloat32(0,n),kk.getFloat32(0)===n),Nl=(n,e)=>{switch(typeof e){case"string":qt(n,119),hs(n,e);break;case"number":jF(e)&&Bh(e)<=BF?(qt(n,125),C0(n,e)):n3(e)?(qt(n,124),ZF(n,e)):(qt(n,123),e3(n,e));break;case"bigint":qt(n,122),t3(n,e);break;case"object":if(e===null)qt(n,126);else if(y0(e)){qt(n,117),ve(n,e.length);for(let t=0;t<e.length;t++)Nl(n,e[t])}else if(e instanceof Uint8Array)qt(n,116),St(n,e);else{qt(n,118);const t=Object.keys(e);ve(n,t.length);for(let r=0;r<t.length;r++){const s=t[r];hs(n,s),Nl(n,e[s])}}break;case"boolean":qt(n,e?120:121);break;default:qt(n,127)}};class Ck extends gf{constructor(e){super(),this.w=e,this.s=null,this.count=0}write(e){this.s===e?this.count++:(this.count>0&&ve(this,this.count-1),this.count=1,this.w(this,e),this.s=e)}}const Sk=n=>{n.count>0&&(C0(n.encoder,n.count===1?n.s:-n.s),n.count>1&&ve(n.encoder,n.count-2))};class jh{constructor(){this.encoder=new gf,this.s=0,this.count=0}write(e){this.s===e?this.count++:(Sk(this),this.count=1,this.s=e)}toUint8Array(){return Sk(this),At(this.encoder)}}const Tk=n=>{if(n.count>0){const e=n.diff*2+(n.count===1?0:1);C0(n.encoder,e),n.count>1&&ve(n.encoder,n.count-2)}};class O0{constructor(){this.encoder=new gf,this.s=0,this.count=0,this.diff=0}write(e){this.diff===e-this.s?(this.s=e,this.count++):(Tk(this),this.count=1,this.diff=e-this.s,this.s=e)}toUint8Array(){return Tk(this),At(this.encoder)}}class r3{constructor(){this.sarr=[],this.s="",this.lensE=new jh}write(e){this.s+=e,this.s.length>19&&(this.sarr.push(this.s),this.s=""),this.lensE.write(e.length)}toUint8Array(){const e=new gf;return this.sarr.push(this.s),this.s="",hs(e,this.sarr.join("")),Hh(e,this.lensE.toUint8Array()),At(e)}}const Ok=Lr("Unexpected end of array"),Nk=Lr("Integer out of Range");class $h{constructor(e){this.arr=e,this.pos=0}}const ps=n=>new $h(n),s3=n=>n.pos!==n.arr.length,i3=(n,e)=>{const t=new Uint8Array(n.arr.buffer,n.pos+n.arr.byteOffset,e);return n.pos+=e,t},Qt=n=>i3(n,Oe(n)),ta=n=>n.arr[n.pos++],Oe=n=>{let e=0,t=1;const r=n.arr.length;for(;n.pos<r;){const s=n.arr[n.pos++];if(e=e+(s&ea)*t,t*=128,s<Zn)return e;if(e>xk)throw Nk}throw Ok},N0=n=>{let e=n.arr[n.pos++],t=e&E0,r=64;const s=(e&Js)>0?-1:1;if(!(e&Zn))return s*t;const i=n.arr.length;for(;n.pos<i;){if(e=n.arr[n.pos++],t=t+(e&ea)*r,r*=128,e<Zn)return s*t;if(t>xk)throw Nk}throw Ok},qs=mf?n=>mf.decode(Qt(n)):n=>{let e=Oe(n);if(e===0)return"";{let t=String.fromCodePoint(ta(n));if(--e<100)for(;e--;)t+=String.fromCodePoint(ta(n));else for(;e>0;){const r=e<1e4?e:1e4,s=n.arr.subarray(n.pos,n.pos+r);n.pos+=r,t+=String.fromCodePoint.apply(null,s),e-=r}return decodeURIComponent(escape(t))}},M0=(n,e)=>{const t=new DataView(n.arr.buffer,n.arr.byteOffset+n.pos,e);return n.pos+=e,t},o3=[n=>{},n=>null,N0,n=>M0(n,4).getFloat32(0,!1),n=>M0(n,8).getFloat64(0,!1),n=>M0(n,8).getBigInt64(0,!1),n=>!1,n=>!0,qs,n=>{const e=Oe(n),t={};for(let r=0;r<e;r++){const s=qs(n);t[s]=Ml(n)}return t},n=>{const e=Oe(n),t=[];for(let r=0;r<e;r++)t.push(Ml(n));return t},Qt],Ml=n=>o3[127-ta(n)](n);class Mk extends $h{constructor(e,t){super(e),this.reader=t,this.s=null,this.count=0}read(){return this.count===0&&(this.s=this.reader(this),s3(this)?this.count=Oe(this)+1:this.count=-1),this.count--,this.s}}class zh extends $h{constructor(e){super(e),this.s=0,this.count=0}read(){if(this.count===0){this.s=N0(this);const e=gk(this.s);this.count=1,e&&(this.s=-this.s,this.count=Oe(this)+2)}return this.count--,this.s}}class R0 extends $h{constructor(e){super(e),this.s=0,this.count=0,this.diff=0}read(){if(this.count===0){const e=N0(this),t=e&1;this.diff=_r(e/2),this.count=1,t&&(this.count=Oe(this)+2)}return this.s+=this.diff,this.count--,this.s}}class a3{constructor(e){this.decoder=new zh(e),this.str=qs(this.decoder),this.spos=0}read(){const e=this.spos+this.decoder.read(),t=this.str.slice(this.spos,e);return this.spos=e,t}}const Rk=n=>n===void 0?null:n;class l3{constructor(){this.map=new Map}setItem(e,t){this.map.set(e,t)}getItem(e){return this.map.get(e)}}let Pk=new l3,P0=!0;try{typeof localStorage<"u"&&localStorage&&(Pk=localStorage,P0=!1)}catch{}const Dk=Pk,c3=n=>P0||addEventListener("storage",n),u3=n=>P0||removeEventListener("storage",n),f3=Object.assign,D0=Object.keys,d3=(n,e)=>{for(const t in n)e(n[t],t)},Ik=n=>D0(n).length,_k=n=>D0(n).length,h3=n=>{for(const e in n)return!1;return!0},p3=(n,e)=>{for(const t in n)if(!e(n[t],t))return!1;return!0},Lk=(n,e)=>Object.prototype.hasOwnProperty.call(n,e),m3=(n,e)=>n===e||_k(n)===_k(e)&&p3(n,(t,r)=>(t!==void 0||Lk(e,r))&&e[r]===t),I0=(n,e,t=0)=>{try{for(;t<n.length;t++)n[t](...e)}finally{t<n.length&&I0(n,e,t+1)}},g3=()=>{},y3=n=>n,b3=(n,e)=>n===e,bf=(n,e)=>{if(n==null||e==null)return b3(n,e);if(n.constructor!==e.constructor)return!1;if(n===e)return!0;switch(n.constructor){case ArrayBuffer:n=new Uint8Array(n),e=new Uint8Array(e);case Uint8Array:{if(n.byteLength!==e.byteLength)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;break}case Set:{if(n.size!==e.size)return!1;for(const t of n)if(!e.has(t))return!1;break}case Map:{if(n.size!==e.size)return!1;for(const t of n.keys())if(!e.has(t)||!bf(n.get(t),e.get(t)))return!1;break}case Object:if(Ik(n)!==Ik(e))return!1;for(const t in n)if(!Lk(n,t)||!bf(n[t],e[t]))return!1;break;case Array:if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(!bf(n[t],e[t]))return!1;break;default:return!1}return!0},w3=(n,e)=>e.includes(n),Rl=typeof process<"u"&&process.release&&/node|io\.js/.test(process.release.name)&&Object.prototype.toString.call(typeof process<"u"?process:0)==="[object process]",_0=typeof window<"u"&&typeof document<"u"&&!Rl;let ms;const v3=()=>{if(ms===void 0)if(Rl){ms=En();const n=process.argv;let e=null;for(let t=0;t<n.length;t++){const r=n[t];r[0]==="-"?(e!==null&&ms.set(e,""),e=r):e!==null&&(ms.set(e,r),e=null)}e!==null&&ms.set(e,"")}else typeof location=="object"?(ms=En(),(location.search||"?").slice(1).split("&").forEach(n=>{if(n.length!==0){const[e,t]=n.split("=");ms.set(`--${Ek(e,"-")}`,t),ms.set(`-${Ek(e,"-")}`,t)}})):ms=En();return ms},L0=n=>v3().has(n),Vh=n=>Rk(Rl?process.env[n.toUpperCase().replaceAll("-","_")]:Dk.getItem(n));(n=>L0("--"+n)||Vh(n)!==null)("production");const Bk=Rl&&w3(process.env.FORCE_COLOR,["true","1","2"]),A3=!L0("--no-colors")&&(!Rl||process.stdout.isTTY||Bk)&&(!Rl||L0("--color")||Bk||Vh("COLORTERM")!==null||(Vh("TERM")||"").includes("color"));class x3{constructor(e,t){this.left=e,this.right=t}}const Qs=(n,e)=>new x3(n,e),E3=typeof document<"u"?document:{};typeof DOMParser<"u"&&new DOMParser;const k3=n=>NF(n,(e,t)=>`${t}:${e};`).join(""),C3=JSON.stringify,S3=(n=>class{constructor(t){this._=t}destroy(){n(this._)}})(clearTimeout),B0=(n,e)=>new S3(setTimeout(e,n)),Ys=Symbol,yr=Ys(),na=Ys(),Fk=Ys(),F0=Ys(),Uk=Ys(),Hk=Ys(),jk=Ys(),Wh=Ys(),Gh=Ys(),T3=n=>{var r;n.length===1&&((r=n[0])==null?void 0:r.constructor)===Function&&(n=n[0]());const e=[];let t=0;for(;t<n.length;t++){const s=n[t];s===void 0||s.constructor===String||s.constructor===Number||s.constructor===Object&&e.push(JSON.stringify(s))}return e},$k=[Uk,jk,Wh,Fk];let U0=0,zk=ds();const O3=(n,e)=>{const t=$k[U0],r=Vh("log"),s=r!==null&&(r==="*"||r==="true"||new RegExp(r,"gi").test(e));return U0=(U0+1)%$k.length,e+=": ",s?(...i)=>{var l;i.length===1&&((l=i[0])==null?void 0:l.constructor)===Function&&(i=i[0]());const o=ds(),a=o-zk;zk=o,n(t,e,Gh,...i.map(c=>{switch(c!=null&&c.constructor===Uint8Array&&(c=Array.from(c)),typeof c){case"string":case"symbol":return c;default:return C3(c)}}),t," +"+a+"ms")}:g3},N3={[yr]:Qs("font-weight","bold"),[na]:Qs("font-weight","normal"),[Fk]:Qs("color","blue"),[Uk]:Qs("color","green"),[F0]:Qs("color","grey"),[Hk]:Qs("color","red"),[jk]:Qs("color","purple"),[Wh]:Qs("color","orange"),[Gh]:Qs("color","black")},Vk=A3?n=>{var o;n.length===1&&((o=n[0])==null?void 0:o.constructor)===Function&&(n=n[0]());const e=[],t=[],r=En();let s=[],i=0;for(;i<n.length;i++){const a=n[i],l=N3[a];if(l!==void 0)r.set(l.left,l.right);else{if(a===void 0)break;if(a.constructor===String||a.constructor===Number){const c=k3(r);i>0||c.length>0?(e.push("%c"+a),t.push(c)):e.push(a)}else break}}for(i>0&&(s=t,s.unshift(e.join("")));i<n.length;i++){const a=n[i];a instanceof Symbol||s.push(a)}return s}:T3,Wk=(...n)=>{console.log(...Vk(n)),Gk.forEach(e=>e.print(n))},M3=(...n)=>{console.warn(...Vk(n)),n.unshift(Wh),Gk.forEach(e=>e.print(n))},Gk=Ws(),R3=n=>O3(Wk,n),Pl=n=>new Promise(n);Promise.all.bind(Promise);const P3=n=>Promise.reject(n),H0=n=>Promise.resolve(n),Kk=n=>new Uint8Array(n),D3=(n,e,t)=>new Uint8Array(n,e,t),I3=n=>new Uint8Array(n),_3=n=>{let e="";for(let t=0;t<n.byteLength;t++)e+=$F(n[t]);return btoa(e)},L3=n=>Buffer.from(n.buffer,n.byteOffset,n.byteLength).toString("base64"),B3=n=>{const e=atob(n),t=Kk(e.length);for(let r=0;r<e.length;r++)t[r]=e.charCodeAt(r);return t},F3=n=>{const e=Buffer.from(n,"base64");return D3(e.buffer,e.byteOffset,e.byteLength)},Jk=_0?_3:L3,qk=_0?B3:F3,U3=n=>{const e=Kk(n.byteLength);return e.set(n),e},Qk=new Map;class H3{constructor(e){this.room=e,this.onmessage=null,this._onChange=t=>t.key===e&&this.onmessage!==null&&this.onmessage({data:qk(t.newValue||"")}),c3(this._onChange)}postMessage(e){Dk.setItem(this.room,Jk(I3(e)))}close(){u3(this._onChange)}}const j3=typeof BroadcastChannel>"u"?H3:BroadcastChannel,j0=n=>Hn(Qk,n,()=>{const e=Ws(),t=new j3(n);return t.onmessage=r=>e.forEach(s=>s(r.data,"broadcastchannel")),{bc:t,subs:e}}),$3=(n,e)=>(j0(n).subs.add(e),e),z3=(n,e)=>{const t=j0(n),r=t.subs.delete(e);return r&&t.subs.size===0&&(t.bc.close(),Qk.delete(n)),r},V3=(n,e,t=null)=>{const r=j0(n);r.bc.postMessage(e),r.subs.forEach(s=>s(e,t))},Yk=()=>{let n=!0;return(e,t)=>{if(n){n=!1;try{e()}finally{n=!0}}else t!==void 0&&t()}},Xk=n=>({[Symbol.iterator](){return this},next:n}),W3=(n,e)=>Xk(()=>{let t;do t=n.next();while(!t.done&&!e(t.value));return t}),$0=(n,e)=>Xk(()=>{const{done:t,value:r}=n.next();return{done:t,value:t?void 0:e(r)}});class z0{constructor(e,t){this.clock=e,this.len=t}}class Dl{constructor(){this.clients=new Map}}const Vi=(n,e,t)=>e.clients.forEach((r,s)=>{const i=n.doc.store.clients.get(s);for(let o=0;o<r.length;o++){const a=r[o];vC(n,i,a.clock,a.len,t)}}),G3=(n,e)=>{let t=0,r=n.length-1;for(;t<=r;){const s=_r((t+r)/2),i=n[s],o=i.clock;if(o<=e){if(e<o+i.len)return s;t=s+1}else r=s-1}return null},Il=(n,e)=>{const t=n.clients.get(e.client);return t!==void 0&&G3(t,e.clock)!==null},V0=n=>{n.clients.forEach(e=>{e.sort((s,i)=>s.clock-i.clock);let t,r;for(t=1,r=1;t<e.length;t++){const s=e[r-1],i=e[t];s.clock+s.len>=i.clock?s.len=Ks(s.len,i.clock+i.len-s.clock):(r<t&&(e[r]=i),r++)}e.length=r})},W0=n=>{const e=new Dl;for(let t=0;t<n.length;t++)n[t].clients.forEach((r,s)=>{if(!e.clients.has(s)){const i=r.slice();for(let o=t+1;o<n.length;o++)RF(i,n[o].clients.get(s)||[]);e.clients.set(s,i)}});return V0(e),e},wf=(n,e,t,r)=>{Hn(n.clients,e,()=>[]).push(new z0(t,r))},Zk=()=>new Dl,eC=n=>{const e=Zk();return n.clients.forEach((t,r)=>{const s=[];for(let i=0;i<t.length;i++){const o=t[i];if(o.deleted){const a=o.id.clock;let l=o.length;if(i+1<t.length)for(let c=t[i+1];i+1<t.length&&c.deleted;c=t[++i+1])l+=c.length;s.push(new z0(a,l))}}s.length>0&&e.clients.set(r,s)}),e},_l=(n,e)=>{ve(n.restEncoder,e.clients.size),Gs(e.clients.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{n.resetDsCurVal(),ve(n.restEncoder,t);const s=r.length;ve(n.restEncoder,s);for(let i=0;i<s;i++){const o=r[i];n.writeDsClock(o.clock),n.writeDsLen(o.len)}})},G0=n=>{const e=new Dl,t=Oe(n.restDecoder);for(let r=0;r<t;r++){n.resetDsCurVal();const s=Oe(n.restDecoder),i=Oe(n.restDecoder);if(i>0){const o=Hn(e.clients,s,()=>[]);for(let a=0;a<i;a++)o.push(new z0(n.readDsClock(),n.readDsLen()))}}return e},tC=(n,e,t)=>{const r=new Dl,s=Oe(n.restDecoder);for(let i=0;i<s;i++){n.resetDsCurVal();const o=Oe(n.restDecoder),a=Oe(n.restDecoder),l=t.clients.get(o)||[],c=Mt(t,o);for(let u=0;u<a;u++){const f=n.readDsClock(),d=f+n.readDsLen();if(f<c){c<d&&wf(r,o,c,d-c);let h=gs(l,f),p=l[h];for(!p.deleted&&p.id.clock<f&&(l.splice(h+1,0,ip(e,p,f-p.id.clock)),h++);h<l.length&&(p=l[h++],p.id.clock<d);)p.deleted||(d<p.id.clock+p.length&&l.splice(h,0,ip(e,p,d-p.id.clock)),p.delete(e))}else wf(r,o,f,d-f)}}if(r.clients.size>0){const i=new ra;return ve(i.restEncoder,0),_l(i,r),i.toUint8Array()}return null},nC=vk;class Ll extends b0{constructor({guid:e=Ak(),collectionid:t=null,gc:r=!0,gcFilter:s=()=>!0,meta:i=null,autoLoad:o=!1,shouldLoad:a=!0}={}){super(),this.gc=r,this.gcFilter=s,this.clientID=nC(),this.guid=e,this.collectionid=t,this.share=new Map,this.store=new yC,this._transaction=null,this._transactionCleanups=[],this.subdocs=new Set,this._item=null,this.shouldLoad=a,this.autoLoad=o,this.meta=i,this.isLoaded=!1,this.isSynced=!1,this.whenLoaded=Pl(c=>{this.on("load",()=>{this.isLoaded=!0,c(this)})});const l=()=>Pl(c=>{const u=f=>{(f===void 0||f===!0)&&(this.off("sync",u),c())};this.on("sync",u)});this.on("sync",c=>{c===!1&&this.isSynced&&(this.whenSynced=l()),this.isSynced=c===void 0||c===!0,this.isSynced&&!this.isLoaded&&this.emit("load",[this])}),this.whenSynced=l()}load(){const e=this._item;e!==null&&!this.shouldLoad&&ot(e.parent.doc,t=>{t.subdocsLoaded.add(this)},null,!0),this.shouldLoad=!0}getSubdocs(){return this.subdocs}getSubdocGuids(){return new Set(Gs(this.subdocs).map(e=>e.guid))}transact(e,t=null){return ot(this,e,t)}get(e,t=an){const r=Hn(this.share,e,()=>{const i=new t;return i._integrate(this,null),i}),s=r.constructor;if(t!==an&&s!==t)if(s===an){const i=new t;i._map=r._map,r._map.forEach(o=>{for(;o!==null;o=o.left)o.parent=i}),i._start=r._start;for(let o=i._start;o!==null;o=o.right)o.parent=i;return i._length=r._length,this.share.set(e,i),i._integrate(this,null),i}else throw new Error(`Type with the name ${e} has already been defined with a different constructor`);return r}getArray(e=""){return this.get(e,jl)}getText(e=""){return this.get(e,ia)}getMap(e=""){return this.get(e,$l)}getXmlElement(e=""){return this.get(e,kn)}getXmlFragment(e=""){return this.get(e,oa)}toJSON(){const e={};return this.share.forEach((t,r)=>{e[r]=t.toJSON()}),e}destroy(){Gs(this.subdocs).forEach(t=>t.destroy());const e=this._item;if(e!==null){this._item=null;const t=e.content;t.doc=new Ll({guid:this.guid,...t.opts,shouldLoad:!1}),t.doc._item=e,ot(e.parent.doc,r=>{const s=t.doc;e.deleted||r.subdocsAdded.add(s),r.subdocsRemoved.add(this)},null,!0)}this.emit("destroyed",[!0]),this.emit("destroy",[this]),super.destroy()}}class rC{constructor(e){this.restDecoder=e}resetDsCurVal(){}readDsClock(){return Oe(this.restDecoder)}readDsLen(){return Oe(this.restDecoder)}}class sC extends rC{readLeftID(){return Ne(Oe(this.restDecoder),Oe(this.restDecoder))}readRightID(){return Ne(Oe(this.restDecoder),Oe(this.restDecoder))}readClient(){return Oe(this.restDecoder)}readInfo(){return ta(this.restDecoder)}readString(){return qs(this.restDecoder)}readParentInfo(){return Oe(this.restDecoder)===1}readTypeRef(){return Oe(this.restDecoder)}readLen(){return Oe(this.restDecoder)}readAny(){return Ml(this.restDecoder)}readBuf(){return U3(Qt(this.restDecoder))}readJSON(){return JSON.parse(qs(this.restDecoder))}readKey(){return qs(this.restDecoder)}}class K3{constructor(e){this.dsCurrVal=0,this.restDecoder=e}resetDsCurVal(){this.dsCurrVal=0}readDsClock(){return this.dsCurrVal+=Oe(this.restDecoder),this.dsCurrVal}readDsLen(){const e=Oe(this.restDecoder)+1;return this.dsCurrVal+=e,e}}class Bl extends K3{constructor(e){super(e),this.keys=[],Oe(e),this.keyClockDecoder=new R0(Qt(e)),this.clientDecoder=new zh(Qt(e)),this.leftClockDecoder=new R0(Qt(e)),this.rightClockDecoder=new R0(Qt(e)),this.infoDecoder=new Mk(Qt(e),ta),this.stringDecoder=new a3(Qt(e)),this.parentInfoDecoder=new Mk(Qt(e),ta),this.typeRefDecoder=new zh(Qt(e)),this.lenDecoder=new zh(Qt(e))}readLeftID(){return new Fl(this.clientDecoder.read(),this.leftClockDecoder.read())}readRightID(){return new Fl(this.clientDecoder.read(),this.rightClockDecoder.read())}readClient(){return this.clientDecoder.read()}readInfo(){return this.infoDecoder.read()}readString(){return this.stringDecoder.read()}readParentInfo(){return this.parentInfoDecoder.read()===1}readTypeRef(){return this.typeRefDecoder.read()}readLen(){return this.lenDecoder.read()}readAny(){return Ml(this.restDecoder)}readBuf(){return Qt(this.restDecoder)}readJSON(){return Ml(this.restDecoder)}readKey(){const e=this.keyClockDecoder.read();if(e<this.keys.length)return this.keys[e];{const t=this.stringDecoder.read();return this.keys.push(t),t}}}class iC{constructor(){this.restEncoder=Jt()}toUint8Array(){return At(this.restEncoder)}resetDsCurVal(){}writeDsClock(e){ve(this.restEncoder,e)}writeDsLen(e){ve(this.restEncoder,e)}}class vf extends iC{writeLeftID(e){ve(this.restEncoder,e.client),ve(this.restEncoder,e.clock)}writeRightID(e){ve(this.restEncoder,e.client),ve(this.restEncoder,e.clock)}writeClient(e){ve(this.restEncoder,e)}writeInfo(e){yf(this.restEncoder,e)}writeString(e){hs(this.restEncoder,e)}writeParentInfo(e){ve(this.restEncoder,e?1:0)}writeTypeRef(e){ve(this.restEncoder,e)}writeLen(e){ve(this.restEncoder,e)}writeAny(e){Nl(this.restEncoder,e)}writeBuf(e){St(this.restEncoder,e)}writeJSON(e){hs(this.restEncoder,JSON.stringify(e))}writeKey(e){hs(this.restEncoder,e)}}class oC{constructor(){this.restEncoder=Jt(),this.dsCurrVal=0}toUint8Array(){return At(this.restEncoder)}resetDsCurVal(){this.dsCurrVal=0}writeDsClock(e){const t=e-this.dsCurrVal;this.dsCurrVal=e,ve(this.restEncoder,t)}writeDsLen(e){e===0&&gr(),ve(this.restEncoder,e-1),this.dsCurrVal+=e}}class ra extends oC{constructor(){super(),this.keyMap=new Map,this.keyClock=0,this.keyClockEncoder=new O0,this.clientEncoder=new jh,this.leftClockEncoder=new O0,this.rightClockEncoder=new O0,this.infoEncoder=new Ck(yf),this.stringEncoder=new r3,this.parentInfoEncoder=new Ck(yf),this.typeRefEncoder=new jh,this.lenEncoder=new jh}toUint8Array(){const e=Jt();return ve(e,0),St(e,this.keyClockEncoder.toUint8Array()),St(e,this.clientEncoder.toUint8Array()),St(e,this.leftClockEncoder.toUint8Array()),St(e,this.rightClockEncoder.toUint8Array()),St(e,At(this.infoEncoder)),St(e,this.stringEncoder.toUint8Array()),St(e,At(this.parentInfoEncoder)),St(e,this.typeRefEncoder.toUint8Array()),St(e,this.lenEncoder.toUint8Array()),Hh(e,At(this.restEncoder)),At(e)}writeLeftID(e){this.clientEncoder.write(e.client),this.leftClockEncoder.write(e.clock)}writeRightID(e){this.clientEncoder.write(e.client),this.rightClockEncoder.write(e.clock)}writeClient(e){this.clientEncoder.write(e)}writeInfo(e){this.infoEncoder.write(e)}writeString(e){this.stringEncoder.write(e)}writeParentInfo(e){this.parentInfoEncoder.write(e?1:0)}writeTypeRef(e){this.typeRefEncoder.write(e)}writeLen(e){this.lenEncoder.write(e)}writeAny(e){Nl(this.restEncoder,e)}writeBuf(e){St(this.restEncoder,e)}writeJSON(e){Nl(this.restEncoder,e)}writeKey(e){const t=this.keyMap.get(e);t===void 0?(this.keyClockEncoder.write(this.keyClock++),this.stringEncoder.write(e)):this.keyClockEncoder.write(t)}}const J3=(n,e,t,r)=>{r=Ks(r,e[0].id.clock);const s=gs(e,r);ve(n.restEncoder,e.length-s),n.writeClient(t),ve(n.restEncoder,r);const i=e[s];i.write(n,r-i.id.clock);for(let o=s+1;o<e.length;o++)e[o].write(n,0)},K0=(n,e,t)=>{const r=new Map;t.forEach((s,i)=>{Mt(e,i)>s&&r.set(i,s)}),Cf(e).forEach((s,i)=>{t.has(i)||r.set(i,0)}),ve(n.restEncoder,r.size),Gs(r.entries()).sort((s,i)=>i[0]-s[0]).forEach(([s,i])=>{J3(n,e.clients.get(s),s,i)})},q3=(n,e)=>{const t=En(),r=Oe(n.restDecoder);for(let s=0;s<r;s++){const i=Oe(n.restDecoder),o=new Array(i),a=n.readClient();let l=Oe(n.restDecoder);t.set(a,{i:0,refs:o});for(let c=0;c<i;c++){const u=n.readInfo();switch(Uh&u){case 0:{const f=n.readLen();o[c]=new br(Ne(a,l),f),l+=f;break}case 10:{const f=Oe(n.restDecoder);o[c]=new wr(Ne(a,l),f),l+=f;break}default:{const f=(u&(Js|Zn))===0,d=new ht(Ne(a,l),null,(u&Zn)===Zn?n.readLeftID():null,null,(u&Js)===Js?n.readRightID():null,f?n.readParentInfo()?e.get(n.readString()):n.readLeftID():null,f&&(u&hf)===hf?n.readString():null,YC(n,u));o[c]=d,l+=d.length}}}}return t},Q3=(n,e,t)=>{const r=[];let s=Gs(t.keys()).sort((h,p)=>h-p);if(s.length===0)return null;const i=()=>{if(s.length===0)return null;let h=t.get(s[s.length-1]);for(;h.refs.length===h.i;)if(s.pop(),s.length>0)h=t.get(s[s.length-1]);else return null;return h};let o=i();if(o===null)return null;const a=new yC,l=new Map,c=(h,p)=>{const g=l.get(h);(g==null||g>p)&&l.set(h,p)};let u=o.refs[o.i++];const f=new Map,d=()=>{for(const h of r){const p=h.id.client,g=t.get(p);g?(g.i--,a.clients.set(p,g.refs.slice(g.i)),t.delete(p),g.i=0,g.refs=[]):a.clients.set(p,[h]),s=s.filter(y=>y!==p)}r.length=0};for(;;){if(u.constructor!==wr){const p=Hn(f,u.id.client,()=>Mt(e,u.id.client))-u.id.clock;if(p<0)r.push(u),c(u.id.client,u.id.clock-1),d();else{const g=u.getMissing(n,e);if(g!==null){r.push(u);const y=t.get(g)||{refs:[],i:0};if(y.refs.length===y.i)c(g,Mt(e,g)),d();else{u=y.refs[y.i++];continue}}else(p===0||p<u.length)&&(u.integrate(n,p),f.set(u.id.client,u.id.clock+u.length))}}if(r.length>0)u=r.pop();else if(o!==null&&o.i<o.refs.length)u=o.refs[o.i++];else{if(o=i(),o===null)break;u=o.refs[o.i++]}}if(a.clients.size>0){const h=new ra;return K0(h,a,new Map),ve(h.restEncoder,0),{missing:l,update:h.toUint8Array()}}return null},Y3=(n,e)=>K0(n,e.doc.store,e.beforeState),X3=(n,e,t,r=new Bl(n))=>ot(e,s=>{s.local=!1;let i=!1;const o=s.doc,a=o.store,l=q3(r,o),c=Q3(s,a,l),u=a.pendingStructs;if(u){for(const[d,h]of u.missing)if(h<Mt(a,d)){i=!0;break}if(c){for(const[d,h]of c.missing){const p=u.missing.get(d);(p==null||p>h)&&u.missing.set(d,h)}u.update=qh([u.update,c.update])}}else a.pendingStructs=c;const f=tC(r,s,a);if(a.pendingDs){const d=new Bl(ps(a.pendingDs));Oe(d.restDecoder);const h=tC(d,s,a);f&&h?a.pendingDs=qh([f,h]):a.pendingDs=f||h}else a.pendingDs=f;if(i){const d=a.pendingStructs.update;a.pendingStructs=null,aC(s.doc,d)}},t,!1),aC=(n,e,t,r=Bl)=>{const s=ps(e);X3(s,n,t,new r(s))},lC=(n,e,t)=>aC(n,e,t,sC),Z3=(n,e,t=new Map)=>{K0(n,e.store,t),_l(n,eC(e.store))},e4=(n,e=new Uint8Array([0]),t=new ra)=>{const r=cC(e);Z3(t,n,r);const s=[t.toUint8Array()];if(n.store.pendingDs&&s.push(n.store.pendingDs),n.store.pendingStructs&&s.push(b4(n.store.pendingStructs.update,e)),s.length>1){if(t.constructor===vf)return g4(s.map((i,o)=>o===0?i:v4(i)));if(t.constructor===ra)return qh(s)}return s[0]},J0=(n,e)=>e4(n,e,new vf),t4=n=>{const e=new Map,t=Oe(n.restDecoder);for(let r=0;r<t;r++){const s=Oe(n.restDecoder),i=Oe(n.restDecoder);e.set(s,i)}return e},cC=n=>t4(new rC(ps(n))),uC=(n,e)=>(ve(n.restEncoder,e.size),Gs(e.entries()).sort((t,r)=>r[0]-t[0]).forEach(([t,r])=>{ve(n.restEncoder,t),ve(n.restEncoder,r)}),n),n4=(n,e)=>uC(n,Cf(e.store)),r4=(n,e=new oC)=>(n instanceof Map?uC(e,n):n4(e,n),e.toUint8Array()),s4=n=>r4(n,new iC);class i4{constructor(){this.l=[]}}const fC=()=>new i4,dC=(n,e)=>n.l.push(e),hC=(n,e)=>{const t=n.l,r=t.length;n.l=t.filter(s=>e!==s),r===n.l.length&&console.error("[yjs] Tried to remove event handler that doesn't exist.")},pC=(n,e,t)=>I0(n.l,[e,t]);class Fl{constructor(e,t){this.client=e,this.clock=t}}const Ul=(n,e)=>n===e||n!==null&&e!==null&&n.client===e.client&&n.clock===e.clock,Ne=(n,e)=>new Fl(n,e),Af=n=>{for(const[e,t]of n.doc.share.entries())if(t===n)return e;throw gr()},xf=(n,e)=>{for(;e!==null;){if(e.parent===n)return!0;e=e.parent._item}return!1};class Ef{constructor(e,t,r,s=0){this.type=e,this.tname=t,this.item=r,this.assoc=s}}const kf=n=>new Ef(n.type==null?null:Ne(n.type.client,n.type.clock),n.tname||null,n.item==null?null:Ne(n.item.client,n.item.clock),n.assoc==null?0:n.assoc);class o4{constructor(e,t,r=0){this.type=e,this.index=t,this.assoc=r}}const a4=(n,e,t=0)=>new o4(n,e,t),Kh=(n,e,t)=>{let r=null,s=null;return n._item===null?s=Af(n):r=Ne(n._item.id.client,n._item.id.clock),new Ef(r,s,e,t)},q0=(n,e,t=0)=>{let r=n._start;if(t<0){if(e===0)return Kh(n,null,t);e--}for(;r!==null;){if(!r.deleted&&r.countable){if(r.length>e)return Kh(n,Ne(r.id.client,r.id.clock+e),t);e-=r.length}if(r.right===null&&t<0)return Kh(n,r.lastId,t);r=r.right}return Kh(n,null,t)},l4=(n,e,t=!0)=>{const r=e.store,s=n.item,i=n.type,o=n.tname,a=n.assoc;let l=null,c=0;if(s!==null){if(Mt(r,s.client)<=s.clock)return null;const u=t?cb(r,s):{item:Hl(r,s),diff:0},f=u.item;if(!(f instanceof ht))return null;if(l=f.parent,l._item===null||!l._item.deleted){c=f.deleted||!f.countable?0:u.diff+(a>=0?0:1);let d=f.left;for(;d!==null;)!d.deleted&&d.countable&&(c+=d.length),d=d.left}}else{if(o!==null)l=e.get(o);else if(i!==null){if(Mt(r,i.client)<=i.clock)return null;const{item:u}=t?cb(r,i):{item:Hl(r,i)};if(u instanceof ht&&u.content instanceof Ur)l=u.content.type;else return null}else throw gr();a>=0?c=l._length:c=0}return a4(l,c,n.assoc)},mC=(n,e)=>n===e||n!==null&&e!==null&&n.tname===e.tname&&Ul(n.item,e.item)&&Ul(n.type,e.type)&&n.assoc===e.assoc;class Q0{constructor(e,t){this.ds=e,this.sv=t}}const gC=(n,e)=>new Q0(n,e),c4=n=>gC(eC(n.store),Cf(n.store)),sa=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&(e.sv.get(n.id.client)||0)>n.id.clock&&!Il(e.ds,n.id),Y0=(n,e)=>{const t=Hn(n.meta,Y0,Ws),r=n.doc.store;t.has(e)||(e.sv.forEach((s,i)=>{s<Mt(r,i)&&jn(n,Ne(i,s))}),Vi(n,e.ds,s=>{}),t.add(e))};class yC{constructor(){this.clients=new Map,this.pendingStructs=null,this.pendingDs=null}}const Cf=n=>{const e=new Map;return n.clients.forEach((t,r)=>{const s=t[t.length-1];e.set(r,s.id.clock+s.length)}),e},Mt=(n,e)=>{const t=n.clients.get(e);if(t===void 0)return 0;const r=t[t.length-1];return r.id.clock+r.length},bC=(n,e)=>{let t=n.clients.get(e.id.client);if(t===void 0)t=[],n.clients.set(e.id.client,t);else{const r=t[t.length-1];if(r.id.clock+r.length!==e.id.clock)throw gr()}t.push(e)},gs=(n,e)=>{let t=0,r=n.length-1,s=n[r],i=s.id.clock;if(i===e)return r;let o=_r(e/(i+s.length-1)*r);for(;t<=r;){if(s=n[o],i=s.id.clock,i<=e){if(e<i+s.length)return o;t=o+1}else r=o-1;o=_r((t+r)/2)}throw gr()},Hl=(n,e)=>{const t=n.clients.get(e.client);return t[gs(t,e.clock)]},X0=(n,e,t)=>{const r=gs(e,t),s=e[r];return s.id.clock<t&&s instanceof ht?(e.splice(r+1,0,ip(n,s,t-s.id.clock)),r+1):r},jn=(n,e)=>{const t=n.doc.store.clients.get(e.client);return t[X0(n,t,e.clock)]},wC=(n,e,t)=>{const r=e.clients.get(t.client),s=gs(r,t.clock),i=r[s];return t.clock!==i.id.clock+i.length-1&&i.constructor!==br&&r.splice(s+1,0,ip(n,i,t.clock-i.id.clock+1)),i},u4=(n,e,t)=>{const r=n.clients.get(e.id.client);r[gs(r,e.id.clock)]=t},vC=(n,e,t,r,s)=>{if(r===0)return;const i=t+r;let o=X0(n,e,t),a;do a=e[o++],i<a.id.clock+a.length&&X0(n,e,i),s(a);while(o<e.length&&e[o].id.clock<i)};let f4=class{constructor(e,t,r){this.doc=e,this.deleteSet=new Dl,this.beforeState=Cf(e.store),this.afterState=new Map,this.changed=new Map,this.changedParentTypes=new Map,this._mergeStructs=[],this.origin=t,this.meta=new Map,this.local=r,this.subdocsAdded=new Set,this.subdocsRemoved=new Set,this.subdocsLoaded=new Set,this._needFormattingCleanup=!1}};const AC=(n,e)=>e.deleteSet.clients.size===0&&!MF(e.afterState,(t,r)=>e.beforeState.get(r)!==t)?!1:(V0(e.deleteSet),Y3(n,e),_l(n,e.deleteSet),!0),xC=(n,e,t)=>{const r=e._item;(r===null||r.id.clock<(n.beforeState.get(r.id.client)||0)&&!r.deleted)&&Hn(n.changed,e,Ws).add(t)},Jh=(n,e)=>{let t=n[e],r=n[e-1],s=e;for(;s>0;t=r,r=n[--s-1]){if(r.deleted===t.deleted&&r.constructor===t.constructor&&r.mergeWith(t)){t instanceof ht&&t.parentSub!==null&&t.parent._map.get(t.parentSub)===t&&t.parent._map.set(t.parentSub,r);continue}break}const i=e-s;return i&&n.splice(e+1-i,i),i},d4=(n,e,t)=>{for(const[r,s]of n.clients.entries()){const i=e.clients.get(r);for(let o=s.length-1;o>=0;o--){const a=s[o],l=a.clock+a.len;for(let c=gs(i,a.clock),u=i[c];c<i.length&&u.id.clock<l;u=i[++c]){const f=i[c];if(a.clock+a.len<=f.id.clock)break;f instanceof ht&&f.deleted&&!f.keep&&t(f)&&f.gc(e,!1)}}}},h4=(n,e)=>{n.clients.forEach((t,r)=>{const s=e.clients.get(r);for(let i=t.length-1;i>=0;i--){const o=t[i],a=zi(s.length-1,1+gs(s,o.clock+o.len-1));for(let l=a,c=s[l];l>0&&c.id.clock>=o.clock;c=s[l])l-=1+Jh(s,l)}})},EC=(n,e)=>{if(e<n.length){const t=n[e],r=t.doc,s=r.store,i=t.deleteSet,o=t._mergeStructs;try{V0(i),t.afterState=Cf(t.doc.store),r.emit("beforeObserverCalls",[t,r]);const a=[];t.changed.forEach((l,c)=>a.push(()=>{(c._item===null||!c._item.deleted)&&c._callObserver(t,l)})),a.push(()=>{t.changedParentTypes.forEach((l,c)=>{c._dEH.l.length>0&&(c._item===null||!c._item.deleted)&&(l=l.filter(u=>u.target._item===null||!u.target._item.deleted),l.forEach(u=>{u.currentTarget=c,u._path=null}),l.sort((u,f)=>u.path.length-f.path.length),pC(c._dEH,l,t))})}),a.push(()=>r.emit("afterTransaction",[t,r])),I0(a,[]),t._needFormattingCleanup&&I4(t)}finally{r.gc&&d4(i,s,r.gcFilter),h4(i,s),t.afterState.forEach((u,f)=>{const d=t.beforeState.get(f)||0;if(d!==u){const h=s.clients.get(f),p=Ks(gs(h,d),1);for(let g=h.length-1;g>=p;)g-=1+Jh(h,g)}});for(let u=o.length-1;u>=0;u--){const{client:f,clock:d}=o[u].id,h=s.clients.get(f),p=gs(h,d);p+1<h.length&&Jh(h,p+1)>1||p>0&&Jh(h,p)}if(!t.local&&t.afterState.get(r.clientID)!==t.beforeState.get(r.clientID)&&(Wk(Wh,yr,"[yjs] ",na,Hk,"Changed the client-id because another client seems to be using it."),r.clientID=nC()),r.emit("afterTransactionCleanup",[t,r]),r._observers.has("update")){const u=new vf;AC(u,t)&&r.emit("update",[u.toUint8Array(),t.origin,r,t])}if(r._observers.has("updateV2")){const u=new ra;AC(u,t)&&r.emit("updateV2",[u.toUint8Array(),t.origin,r,t])}const{subdocsAdded:a,subdocsLoaded:l,subdocsRemoved:c}=t;(a.size>0||c.size>0||l.size>0)&&(a.forEach(u=>{u.clientID=r.clientID,u.collectionid==null&&(u.collectionid=r.collectionid),r.subdocs.add(u)}),c.forEach(u=>r.subdocs.delete(u)),r.emit("subdocs",[{loaded:l,added:a,removed:c},r,t]),c.forEach(u=>u.destroy())),n.length<=e+1?(r._transactionCleanups=[],r.emit("afterAllTransactions",[r,n])):EC(n,e+1)}}},ot=(n,e,t=null,r=!0)=>{const s=n._transactionCleanups;let i=!1,o=null;n._transaction===null&&(i=!0,n._transaction=new f4(n,t,r),s.push(n._transaction),s.length===1&&n.emit("beforeAllTransactions",[n]),n.emit("beforeTransaction",[n._transaction,n]));try{o=e(n._transaction)}finally{if(i){const a=n._transaction===s[0];n._transaction=null,a&&EC(s,0)}}return o};class p4{constructor(e,t){this.insertions=t,this.deletions=e,this.meta=new Map}}const kC=(n,e,t)=>{Vi(n,t.deletions,r=>{r instanceof ht&&e.scope.some(s=>xf(s,r))&&ub(r,!1)})},CC=(n,e,t)=>{let r=null;const s=n.doc,i=n.scope;if(ot(s,o=>{for(;e.length>0&&n.currStackItem===null;){const a=s.store,l=e.pop(),c=new Set,u=[];let f=!1;Vi(o,l.insertions,d=>{if(d instanceof ht){if(d.redone!==null){let{item:h,diff:p}=cb(a,d.id);p>0&&(h=jn(o,Ne(h.id.client,h.id.clock+p))),d=h}!d.deleted&&i.some(h=>xf(h,d))&&u.push(d)}}),Vi(o,l.deletions,d=>{d instanceof ht&&i.some(h=>xf(h,d))&&!Il(l.insertions,d.id)&&c.add(d)}),c.forEach(d=>{f=QC(o,d,c,l.insertions,n.ignoreRemoteMapChanges,n)!==null||f});for(let d=u.length-1;d>=0;d--){const h=u[d];n.deleteFilter(h)&&(h.delete(o),f=!0)}n.currStackItem=f?l:null}o.changed.forEach((a,l)=>{a.has(null)&&l._searchMarker&&(l._searchMarker.length=0)}),r=o},n),n.currStackItem!=null){const o=r.changedParentTypes;n.emit("stack-item-popped",[{stackItem:n.currStackItem,type:t,changedParentTypes:o,origin:n},n]),n.currStackItem=null}return n.currStackItem};class SC extends b0{constructor(e,{captureTimeout:t=500,captureTransaction:r=l=>!0,deleteFilter:s=()=>!0,trackedOrigins:i=new Set([null]),ignoreRemoteMapChanges:o=!1,doc:a=y0(e)?e[0].doc:e.doc}={}){super(),this.scope=[],this.doc=a,this.addToScope(e),this.deleteFilter=s,i.add(this),this.trackedOrigins=i,this.captureTransaction=r,this.undoStack=[],this.redoStack=[],this.undoing=!1,this.redoing=!1,this.currStackItem=null,this.lastChange=0,this.ignoreRemoteMapChanges=o,this.captureTimeout=t,this.afterTransactionHandler=l=>{if(!this.captureTransaction(l)||!this.scope.some(y=>l.changedParentTypes.has(y))||!this.trackedOrigins.has(l.origin)&&(!l.origin||!this.trackedOrigins.has(l.origin.constructor)))return;const c=this.undoing,u=this.redoing,f=c?this.redoStack:this.undoStack;c?this.stopCapturing():u||this.clear(!1,!0);const d=new Dl;l.afterState.forEach((y,b)=>{const x=l.beforeState.get(b)||0,v=y-x;v>0&&wf(d,b,x,v)});const h=ds();let p=!1;if(this.lastChange>0&&h-this.lastChange<this.captureTimeout&&f.length>0&&!c&&!u){const y=f[f.length-1];y.deletions=W0([y.deletions,l.deleteSet]),y.insertions=W0([y.insertions,d])}else f.push(new p4(l.deleteSet,d)),p=!0;!c&&!u&&(this.lastChange=h),Vi(l,l.deleteSet,y=>{y instanceof ht&&this.scope.some(b=>xf(b,y))&&ub(y,!0)});const g=[{stackItem:f[f.length-1],origin:l.origin,type:c?"redo":"undo",changedParentTypes:l.changedParentTypes},this];p?this.emit("stack-item-added",g):this.emit("stack-item-updated",g)},this.doc.on("afterTransaction",this.afterTransactionHandler),this.doc.on("destroy",()=>{this.destroy()})}addToScope(e){e=y0(e)?e:[e],e.forEach(t=>{this.scope.every(r=>r!==t)&&(t.doc!==this.doc&&M3("[yjs#509] Not same Y.Doc"),this.scope.push(t))})}addTrackedOrigin(e){this.trackedOrigins.add(e)}removeTrackedOrigin(e){this.trackedOrigins.delete(e)}clear(e=!0,t=!0){(e&&this.canUndo()||t&&this.canRedo())&&this.doc.transact(r=>{e&&(this.undoStack.forEach(s=>kC(r,this,s)),this.undoStack=[]),t&&(this.redoStack.forEach(s=>kC(r,this,s)),this.redoStack=[]),this.emit("stack-cleared",[{undoStackCleared:e,redoStackCleared:t}])})}stopCapturing(){this.lastChange=0}undo(){this.undoing=!0;let e;try{e=CC(this,this.undoStack,"undo")}finally{this.undoing=!1}return e}redo(){this.redoing=!0;let e;try{e=CC(this,this.redoStack,"redo")}finally{this.redoing=!1}return e}canUndo(){return this.undoStack.length>0}canRedo(){return this.redoStack.length>0}destroy(){this.trackedOrigins.delete(this),this.doc.off("afterTransaction",this.afterTransactionHandler),super.destroy()}}function*m4(n){const e=Oe(n.restDecoder);for(let t=0;t<e;t++){const r=Oe(n.restDecoder),s=n.readClient();let i=Oe(n.restDecoder);for(let o=0;o<r;o++){const a=n.readInfo();if(a===10){const l=Oe(n.restDecoder);yield new wr(Ne(s,i),l),i+=l}else if(Uh&a){const l=(a&(Js|Zn))===0,c=new ht(Ne(s,i),null,(a&Zn)===Zn?n.readLeftID():null,null,(a&Js)===Js?n.readRightID():null,l?n.readParentInfo()?n.readString():n.readLeftID():null,l&&(a&hf)===hf?n.readString():null,YC(n,a));yield c,i+=c.length}else{const l=n.readLen();yield new br(Ne(s,i),l),i+=l}}}}class Z0{constructor(e,t){this.gen=m4(e),this.curr=null,this.done=!1,this.filterSkips=t,this.next()}next(){do this.curr=this.gen.next().value||null;while(this.filterSkips&&this.curr!==null&&this.curr.constructor===wr);return this.curr}}class eb{constructor(e){this.currClient=0,this.startClock=0,this.written=0,this.encoder=e,this.clientStructs=[]}}const g4=n=>qh(n,sC,vf),y4=(n,e)=>{if(n.constructor===br){const{client:t,clock:r}=n.id;return new br(Ne(t,r+e),n.length-e)}else if(n.constructor===wr){const{client:t,clock:r}=n.id;return new wr(Ne(t,r+e),n.length-e)}else{const t=n,{client:r,clock:s}=t.id;return new ht(Ne(r,s+e),null,Ne(r,s+e-1),null,t.rightOrigin,t.parent,t.parentSub,t.content.splice(e))}},qh=(n,e=Bl,t=ra)=>{if(n.length===1)return n[0];const r=n.map(u=>new e(ps(u)));let s=r.map(u=>new Z0(u,!0)),i=null;const o=new t,a=new eb(o);for(;s=s.filter(d=>d.curr!==null),s.sort((d,h)=>{if(d.curr.id.client===h.curr.id.client){const p=d.curr.id.clock-h.curr.id.clock;return p===0?d.curr.constructor===h.curr.constructor?0:d.curr.constructor===wr?1:-1:p}else return h.curr.id.client-d.curr.id.client}),s.length!==0;){const u=s[0],f=u.curr.id.client;if(i!==null){let d=u.curr,h=!1;for(;d!==null&&d.id.clock+d.length<=i.struct.id.clock+i.struct.length&&d.id.client>=i.struct.id.client;)d=u.next(),h=!0;if(d===null||d.id.client!==f||h&&d.id.clock>i.struct.id.clock+i.struct.length)continue;if(f!==i.struct.id.client)Wi(a,i.struct,i.offset),i={struct:d,offset:0},u.next();else if(i.struct.id.clock+i.struct.length<d.id.clock)if(i.struct.constructor===wr)i.struct.length=d.id.clock+d.length-i.struct.id.clock;else{Wi(a,i.struct,i.offset);const p=d.id.clock-i.struct.id.clock-i.struct.length;i={struct:new wr(Ne(f,i.struct.id.clock+i.struct.length),p),offset:0}}else{const p=i.struct.id.clock+i.struct.length-d.id.clock;p>0&&(i.struct.constructor===wr?i.struct.length-=p:d=y4(d,p)),i.struct.mergeWith(d)||(Wi(a,i.struct,i.offset),i={struct:d,offset:0},u.next())}}else i={struct:u.curr,offset:0},u.next();for(let d=u.curr;d!==null&&d.id.client===f&&d.id.clock===i.struct.id.clock+i.struct.length&&d.constructor!==wr;d=u.next())Wi(a,i.struct,i.offset),i={struct:d,offset:0}}i!==null&&(Wi(a,i.struct,i.offset),i=null),tb(a);const l=r.map(u=>G0(u)),c=W0(l);return _l(o,c),o.toUint8Array()},b4=(n,e,t=Bl,r=ra)=>{const s=cC(e),i=new r,o=new eb(i),a=new t(ps(n)),l=new Z0(a,!1);for(;l.curr;){const u=l.curr,f=u.id.client,d=s.get(f)||0;if(l.curr.constructor===wr){l.next();continue}if(u.id.clock+u.length>d)for(Wi(o,u,Ks(d-u.id.clock,0)),l.next();l.curr&&l.curr.id.client===f;)Wi(o,l.curr,0),l.next();else for(;l.curr&&l.curr.id.client===f&&l.curr.id.clock+l.curr.length<=d;)l.next()}tb(o);const c=G0(a);return _l(i,c),i.toUint8Array()},TC=n=>{n.written>0&&(n.clientStructs.push({written:n.written,restEncoder:At(n.encoder.restEncoder)}),n.encoder.restEncoder=Jt(),n.written=0)},Wi=(n,e,t)=>{n.written>0&&n.currClient!==e.id.client&&TC(n),n.written===0&&(n.currClient=e.id.client,n.encoder.writeClient(e.id.client),ve(n.encoder.restEncoder,e.id.clock+t)),e.write(n.encoder,t),n.written++},tb=n=>{TC(n);const e=n.encoder.restEncoder;ve(e,n.clientStructs.length);for(let t=0;t<n.clientStructs.length;t++){const r=n.clientStructs[t];ve(e,r.written),Hh(e,r.restEncoder)}},w4=(n,e,t,r)=>{const s=new t(ps(n)),i=new Z0(s,!1),o=new r,a=new eb(o);for(let c=i.curr;c!==null;c=i.next())Wi(a,e(c),0);tb(a);const l=G0(s);return _l(o,l),o.toUint8Array()},v4=n=>w4(n,y3,Bl,vf),OC="You must not compute changes after the event-handler fired.";class Qh{constructor(e,t){this.target=e,this.currentTarget=e,this.transaction=t,this._changes=null,this._keys=null,this._delta=null,this._path=null}get path(){return this._path||(this._path=A4(this.currentTarget,this.target))}deletes(e){return Il(this.transaction.deleteSet,e.id)}get keys(){if(this._keys===null){if(this.transaction.doc._transactionCleanups.length===0)throw Lr(OC);const e=new Map,t=this.target;this.transaction.changed.get(t).forEach(s=>{if(s!==null){const i=t._map.get(s);let o,a;if(this.adds(i)){let l=i.left;for(;l!==null&&this.adds(l);)l=l.left;if(this.deletes(i))if(l!==null&&this.deletes(l))o="delete",a=g0(l.content.getContent());else return;else l!==null&&this.deletes(l)?(o="update",a=g0(l.content.getContent())):(o="add",a=void 0)}else if(this.deletes(i))o="delete",a=g0(i.content.getContent());else return;e.set(s,{action:o,oldValue:a})}}),this._keys=e}return this._keys}get delta(){return this.changes.delta}adds(e){return e.id.clock>=(this.transaction.beforeState.get(e.id.client)||0)}get changes(){let e=this._changes;if(e===null){if(this.transaction.doc._transactionCleanups.length===0)throw Lr(OC);const t=this.target,r=Ws(),s=Ws(),i=[];if(e={added:r,deleted:s,delta:i,keys:this.keys},this.transaction.changed.get(t).has(null)){let a=null;const l=()=>{a&&i.push(a)};for(let c=t._start;c!==null;c=c.right)c.deleted?this.deletes(c)&&!this.adds(c)&&((a===null||a.delete===void 0)&&(l(),a={delete:0}),a.delete+=c.length,s.add(c)):this.adds(c)?((a===null||a.insert===void 0)&&(l(),a={insert:[]}),a.insert=a.insert.concat(c.content.getContent()),r.add(c)):((a===null||a.retain===void 0)&&(l(),a={retain:0}),a.retain+=c.length);a!==null&&a.retain===void 0&&l()}this._changes=e}return e}}const A4=(n,e)=>{const t=[];for(;e._item!==null&&e!==n;){if(e._item.parentSub!==null)t.unshift(e._item.parentSub);else{let r=0,s=e._item.parent._start;for(;s!==e._item&&s!==null;)s.deleted||r++,s=s.right;t.unshift(r)}e=e._item.parent}return t},NC=80;let nb=0;class x4{constructor(e,t){e.marker=!0,this.p=e,this.index=t,this.timestamp=nb++}}const E4=n=>{n.timestamp=nb++},MC=(n,e,t)=>{n.p.marker=!1,n.p=e,e.marker=!0,n.index=t,n.timestamp=nb++},k4=(n,e,t)=>{if(n.length>=NC){const r=n.reduce((s,i)=>s.timestamp<i.timestamp?s:i);return MC(r,e,t),r}else{const r=new x4(e,t);return n.push(r),r}},Yh=(n,e)=>{if(n._start===null||e===0||n._searchMarker===null)return null;const t=n._searchMarker.length===0?null:n._searchMarker.reduce((i,o)=>Bh(e-i.index)<Bh(e-o.index)?i:o);let r=n._start,s=0;for(t!==null&&(r=t.p,s=t.index,E4(t));r.right!==null&&s<e;){if(!r.deleted&&r.countable){if(e<s+r.length)break;s+=r.length}r=r.right}for(;r.left!==null&&s>e;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);for(;r.left!==null&&r.left.id.client===r.id.client&&r.left.id.clock+r.left.length===r.id.clock;)r=r.left,!r.deleted&&r.countable&&(s-=r.length);return t!==null&&Bh(t.index-s)<r.parent.length/NC?(MC(t,r,s),t):k4(n._searchMarker,r,s)},Sf=(n,e,t)=>{for(let r=n.length-1;r>=0;r--){const s=n[r];if(t>0){let i=s.p;for(i.marker=!1;i&&(i.deleted||!i.countable);)i=i.left,i&&!i.deleted&&i.countable&&(s.index-=i.length);if(i===null||i.marker===!0){n.splice(r,1);continue}s.p=i,i.marker=!0}(e<s.index||t>0&&e===s.index)&&(s.index=Ks(e,s.index+t))}},Xh=(n,e,t)=>{const r=n,s=e.changedParentTypes;for(;Hn(s,n,()=>[]).push(t),n._item!==null;)n=n._item.parent;pC(r._eH,t,e)};class an{constructor(){this._item=null,this._map=new Map,this._start=null,this.doc=null,this._length=0,this._eH=fC(),this._dEH=fC(),this._searchMarker=null}get parent(){return this._item?this._item.parent:null}_integrate(e,t){this.doc=e,this._item=t}_copy(){throw Br()}clone(){throw Br()}_write(e){}get _first(){let e=this._start;for(;e!==null&&e.deleted;)e=e.right;return e}_callObserver(e,t){!e.local&&this._searchMarker&&(this._searchMarker.length=0)}observe(e){dC(this._eH,e)}observeDeep(e){dC(this._dEH,e)}unobserve(e){hC(this._eH,e)}unobserveDeep(e){hC(this._dEH,e)}toJSON(){}}const RC=(n,e,t)=>{e<0&&(e=n._length+e),t<0&&(t=n._length+t);let r=t-e;const s=[];let i=n._start;for(;i!==null&&r>0;){if(i.countable&&!i.deleted){const o=i.content.getContent();if(o.length<=e)e-=o.length;else{for(let a=e;a<o.length&&r>0;a++)s.push(o[a]),r--;e=0}}i=i.right}return s},PC=n=>{const e=[];let t=n._start;for(;t!==null;){if(t.countable&&!t.deleted){const r=t.content.getContent();for(let s=0;s<r.length;s++)e.push(r[s])}t=t.right}return e},DC=(n,e)=>{const t=[];let r=n._start;for(;r!==null;){if(r.countable&&sa(r,e)){const s=r.content.getContent();for(let i=0;i<s.length;i++)t.push(s[i])}r=r.right}return t},Tf=(n,e)=>{let t=0,r=n._start;for(;r!==null;){if(r.countable&&!r.deleted){const s=r.content.getContent();for(let i=0;i<s.length;i++)e(s[i],t++,n)}r=r.right}},IC=(n,e)=>{const t=[];return Tf(n,(r,s)=>{t.push(e(r,s,n))}),t},C4=n=>{let e=n._start,t=null,r=0;return{[Symbol.iterator](){return this},next:()=>{if(t===null){for(;e!==null&&e.deleted;)e=e.right;if(e===null)return{done:!0,value:void 0};t=e.content.getContent(),r=0,e=e.right}const s=t[r++];return t.length<=r&&(t=null),{done:!1,value:s}}}},_C=(n,e)=>{const t=Yh(n,e);let r=n._start;for(t!==null&&(r=t.p,e-=t.index);r!==null;r=r.right)if(!r.deleted&&r.countable){if(e<r.length)return r.content.getContent()[e];e-=r.length}},Zh=(n,e,t,r)=>{let s=t;const i=n.doc,o=i.clientID,a=i.store,l=t===null?e._start:t.right;let c=[];const u=()=>{c.length>0&&(s=new ht(Ne(o,Mt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new la(c)),s.integrate(n,0),c=[])};r.forEach(f=>{if(f===null)c.push(f);else switch(f.constructor){case Number:case Object:case Boolean:case Array:case String:c.push(f);break;default:switch(u(),f.constructor){case Uint8Array:case ArrayBuffer:s=new ht(Ne(o,Mt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Of(new Uint8Array(f))),s.integrate(n,0);break;case Ll:s=new ht(Ne(o,Mt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Mf(f)),s.integrate(n,0);break;default:if(f instanceof an)s=new ht(Ne(o,Mt(a,o)),s,s&&s.lastId,l,l&&l.id,e,null,new Ur(f)),s.integrate(n,0);else throw new Error("Unexpected content type in insert operation")}}}),u()},LC=()=>Lr("Length exceeded!"),BC=(n,e,t,r)=>{if(t>e._length)throw LC();if(t===0)return e._searchMarker&&Sf(e._searchMarker,t,r.length),Zh(n,e,null,r);const s=t,i=Yh(e,t);let o=e._start;for(i!==null&&(o=i.p,t-=i.index,t===0&&(o=o.prev,t+=o&&o.countable&&!o.deleted?o.length:0));o!==null;o=o.right)if(!o.deleted&&o.countable){if(t<=o.length){t<o.length&&jn(n,Ne(o.id.client,o.id.clock+t));break}t-=o.length}return e._searchMarker&&Sf(e._searchMarker,s,r.length),Zh(n,e,o,r)},S4=(n,e,t)=>{let s=(e._searchMarker||[]).reduce((i,o)=>o.index>i.index?o:i,{index:0,p:e._start}).p;if(s)for(;s.right;)s=s.right;return Zh(n,e,s,t)},FC=(n,e,t,r)=>{if(r===0)return;const s=t,i=r,o=Yh(e,t);let a=e._start;for(o!==null&&(a=o.p,t-=o.index);a!==null&&t>0;a=a.right)!a.deleted&&a.countable&&(t<a.length&&jn(n,Ne(a.id.client,a.id.clock+t)),t-=a.length);for(;r>0&&a!==null;)a.deleted||(r<a.length&&jn(n,Ne(a.id.client,a.id.clock+r)),a.delete(n),r-=a.length),a=a.right;if(r>0)throw LC();e._searchMarker&&Sf(e._searchMarker,s,-i+r)},ep=(n,e,t)=>{const r=e._map.get(t);r!==void 0&&r.delete(n)},rb=(n,e,t,r)=>{const s=e._map.get(t)||null,i=n.doc,o=i.clientID;let a;if(r==null)a=new la([r]);else switch(r.constructor){case Number:case Object:case Boolean:case Array:case String:a=new la([r]);break;case Uint8Array:a=new Of(r);break;case Ll:a=new Mf(r);break;default:if(r instanceof an)a=new Ur(r);else throw new Error("Unexpected content type")}new ht(Ne(o,Mt(i.store,o)),s,s&&s.lastId,null,null,e,t,a).integrate(n,0)},sb=(n,e)=>{const t=n._map.get(e);return t!==void 0&&!t.deleted?t.content.getContent()[t.length-1]:void 0},UC=n=>{const e={};return n._map.forEach((t,r)=>{t.deleted||(e[r]=t.content.getContent()[t.length-1])}),e},HC=(n,e)=>{const t=n._map.get(e);return t!==void 0&&!t.deleted},T4=(n,e)=>{const t={};return n._map.forEach((r,s)=>{let i=r;for(;i!==null&&(!e.sv.has(i.id.client)||i.id.clock>=(e.sv.get(i.id.client)||0));)i=i.left;i!==null&&sa(i,e)&&(t[s]=i.content.getContent()[i.length-1])}),t},tp=n=>W3(n.entries(),e=>!e[1].deleted);class O4 extends Qh{constructor(e,t){super(e,t),this._transaction=t}}class jl extends an{constructor(){super(),this._prelimContent=[],this._searchMarker=[]}static from(e){const t=new jl;return t.push(e),t}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new jl}clone(){const e=new jl;return e.insert(0,this.toArray().map(t=>t instanceof an?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}_callObserver(e,t){super._callObserver(e,t),Xh(this,e,new O4(this,e))}insert(e,t){this.doc!==null?ot(this.doc,r=>{BC(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}push(e){this.doc!==null?ot(this.doc,t=>{S4(t,this,e)}):this._prelimContent.push(...e)}unshift(e){this.insert(0,e)}delete(e,t=1){this.doc!==null?ot(this.doc,r=>{FC(r,this,e,t)}):this._prelimContent.splice(e,t)}get(e){return _C(this,e)}toArray(){return PC(this)}slice(e=0,t=this.length){return RC(this,e,t)}toJSON(){return this.map(e=>e instanceof an?e.toJSON():e)}map(e){return IC(this,e)}forEach(e){Tf(this,e)}[Symbol.iterator](){return C4(this)}_write(e){e.writeTypeRef(X4)}}const N4=n=>new jl;class M4 extends Qh{constructor(e,t,r){super(e,t),this.keysChanged=r}}class $l extends an{constructor(e){super(),this._prelimContent=null,e===void 0?this._prelimContent=new Map:this._prelimContent=new Map(e)}_integrate(e,t){super._integrate(e,t),this._prelimContent.forEach((r,s)=>{this.set(s,r)}),this._prelimContent=null}_copy(){return new $l}clone(){const e=new $l;return this.forEach((t,r)=>{e.set(r,t instanceof an?t.clone():t)}),e}_callObserver(e,t){Xh(this,e,new M4(this,e,t))}toJSON(){const e={};return this._map.forEach((t,r)=>{if(!t.deleted){const s=t.content.getContent()[t.length-1];e[r]=s instanceof an?s.toJSON():s}}),e}get size(){return[...tp(this._map)].length}keys(){return $0(tp(this._map),e=>e[0])}values(){return $0(tp(this._map),e=>e[1].content.getContent()[e[1].length-1])}entries(){return $0(tp(this._map),e=>[e[0],e[1].content.getContent()[e[1].length-1]])}forEach(e){this._map.forEach((t,r)=>{t.deleted||e(t.content.getContent()[t.length-1],r,this)})}[Symbol.iterator](){return this.entries()}delete(e){this.doc!==null?ot(this.doc,t=>{ep(t,this,e)}):this._prelimContent.delete(e)}set(e,t){return this.doc!==null?ot(this.doc,r=>{rb(r,this,e,t)}):this._prelimContent.set(e,t),t}get(e){return sb(this,e)}has(e){return HC(this,e)}clear(){this.doc!==null?ot(this.doc,e=>{this.forEach(function(t,r,s){ep(e,s,r)})}):this._prelimContent.clear()}_write(e){e.writeTypeRef(Z4)}}const R4=n=>new $l,Gi=(n,e)=>n===e||typeof n=="object"&&typeof e=="object"&&n&&e&&m3(n,e);class ib{constructor(e,t,r,s){this.left=e,this.right=t,this.index=r,this.currentAttributes=s}forward(){switch(this.right===null&&gr(),this.right.content.constructor){case Bt:this.right.deleted||zl(this.currentAttributes,this.right.content);break;default:this.right.deleted||(this.index+=this.right.length);break}this.left=this.right,this.right=this.right.right}}const jC=(n,e,t)=>{for(;e.right!==null&&t>0;){switch(e.right.content.constructor){case Bt:e.right.deleted||zl(e.currentAttributes,e.right.content);break;default:e.right.deleted||(t<e.right.length&&jn(n,Ne(e.right.id.client,e.right.id.clock+t)),e.index+=e.right.length,t-=e.right.length);break}e.left=e.right,e.right=e.right.right}return e},np=(n,e,t,r)=>{const s=new Map,i=r?Yh(e,t):null;if(i){const o=new ib(i.p.left,i.p,i.index,s);return jC(n,o,t-i.index)}else{const o=new ib(null,e._start,0,s);return jC(n,o,t)}},$C=(n,e,t,r)=>{for(;t.right!==null&&(t.right.deleted===!0||t.right.content.constructor===Bt&&Gi(r.get(t.right.content.key),t.right.content.value));)t.right.deleted||r.delete(t.right.content.key),t.forward();const s=n.doc,i=s.clientID;r.forEach((o,a)=>{const l=t.left,c=t.right,u=new ht(Ne(i,Mt(s.store,i)),l,l&&l.lastId,c,c&&c.id,e,null,new Bt(a,o));u.integrate(n,0),t.right=u,t.forward()})},zl=(n,e)=>{const{key:t,value:r}=e;r===null?n.delete(t):n.set(t,r)},zC=(n,e)=>{for(;n.right!==null;){if(!(n.right.deleted||n.right.content.constructor===Bt&&Gi(e[n.right.content.key]??null,n.right.content.value)))break;n.forward()}},VC=(n,e,t,r)=>{const s=n.doc,i=s.clientID,o=new Map;for(const a in r){const l=r[a],c=t.currentAttributes.get(a)??null;if(!Gi(c,l)){o.set(a,c);const{left:u,right:f}=t;t.right=new ht(Ne(i,Mt(s.store,i)),u,u&&u.lastId,f,f&&f.id,e,null,new Bt(a,l)),t.right.integrate(n,0),t.forward()}}return o},ob=(n,e,t,r,s)=>{t.currentAttributes.forEach((d,h)=>{s[h]===void 0&&(s[h]=null)});const i=n.doc,o=i.clientID;zC(t,s);const a=VC(n,e,t,s),l=r.constructor===String?new Fr(r):r instanceof an?new Ur(r):new aa(r);let{left:c,right:u,index:f}=t;e._searchMarker&&Sf(e._searchMarker,t.index,l.getLength()),u=new ht(Ne(o,Mt(i.store,o)),c,c&&c.lastId,u,u&&u.id,e,null,l),u.integrate(n,0),t.right=u,t.index=f,t.forward(),$C(n,e,t,a)},WC=(n,e,t,r,s)=>{const i=n.doc,o=i.clientID;zC(t,s);const a=VC(n,e,t,s);e:for(;t.right!==null&&(r>0||a.size>0&&(t.right.deleted||t.right.content.constructor===Bt));){if(!t.right.deleted)switch(t.right.content.constructor){case Bt:{const{key:l,value:c}=t.right.content,u=s[l];if(u!==void 0){if(Gi(u,c))a.delete(l);else{if(r===0)break e;a.set(l,c)}t.right.delete(n)}else t.currentAttributes.set(l,c);break}default:r<t.right.length&&jn(n,Ne(t.right.id.client,t.right.id.clock+r)),r-=t.right.length;break}t.forward()}if(r>0){let l="";for(;r>0;r--)l+=`
|
373
373
|
`;t.right=new ht(Ne(o,Mt(i.store,o)),t.left,t.left&&t.left.lastId,t.right,t.right&&t.right.id,e,null,new Fr(l)),t.right.integrate(n,0),t.forward()}$C(n,e,t,a)},GC=(n,e,t,r,s)=>{let i=e;const o=En();for(;i&&(!i.countable||i.deleted);){if(!i.deleted&&i.content.constructor===Bt){const c=i.content;o.set(c.key,c)}i=i.right}let a=0,l=!1;for(;e!==i;){if(t===e&&(l=!0),!e.deleted){const c=e.content;switch(c.constructor){case Bt:{const{key:u,value:f}=c,d=r.get(u)??null;(o.get(u)!==c||d===f)&&(e.delete(n),a++,!l&&(s.get(u)??null)===f&&d!==f&&(d===null?s.delete(u):s.set(u,d))),!l&&!e.deleted&&zl(s,c);break}}}e=e.right}return a},P4=(n,e)=>{for(;e&&e.right&&(e.right.deleted||!e.right.countable);)e=e.right;const t=new Set;for(;e&&(e.deleted||!e.countable);){if(!e.deleted&&e.content.constructor===Bt){const r=e.content.key;t.has(r)?e.delete(n):t.add(r)}e=e.left}},D4=n=>{let e=0;return ot(n.doc,t=>{let r=n._start,s=n._start,i=En();const o=m0(i);for(;s;){if(s.deleted===!1)switch(s.content.constructor){case Bt:zl(o,s.content);break;default:e+=GC(t,r,s,i,o),i=m0(o),r=s;break}s=s.right}}),e},I4=n=>{const e=new Set,t=n.doc;for(const[r,s]of n.afterState.entries()){const i=n.beforeState.get(r)||0;s!==i&&vC(n,t.store.clients.get(r),i,s,o=>{!o.deleted&&o.content.constructor===Bt&&o.constructor!==br&&e.add(o.parent)})}ot(t,r=>{Vi(n,n.deleteSet,s=>{if(s instanceof br||!s.parent._hasFormatting||e.has(s.parent))return;const i=s.parent;s.content.constructor===Bt?e.add(i):P4(r,s)});for(const s of e)D4(s)})},KC=(n,e,t)=>{const r=t,s=m0(e.currentAttributes),i=e.right;for(;t>0&&e.right!==null;){if(e.right.deleted===!1)switch(e.right.content.constructor){case Ur:case aa:case Fr:t<e.right.length&&jn(n,Ne(e.right.id.client,e.right.id.clock+t)),t-=e.right.length,e.right.delete(n);break}e.forward()}i&&GC(n,i,e.right,s,e.currentAttributes);const o=(e.left||e.right).parent;return o._searchMarker&&Sf(o._searchMarker,e.index,-r+t),e};class _4 extends Qh{constructor(e,t,r){super(e,t),this.childListChanged=!1,this.keysChanged=new Set,r.forEach(s=>{s===null?this.childListChanged=!0:this.keysChanged.add(s)})}get changes(){if(this._changes===null){const e={keys:this.keys,delta:this.delta,added:new Set,deleted:new Set};this._changes=e}return this._changes}get delta(){if(this._delta===null){const e=this.target.doc,t=[];ot(e,r=>{const s=new Map,i=new Map;let o=this.target._start,a=null;const l={};let c="",u=0,f=0;const d=()=>{if(a!==null){let h=null;switch(a){case"delete":f>0&&(h={delete:f}),f=0;break;case"insert":(typeof c=="object"||c.length>0)&&(h={insert:c},s.size>0&&(h.attributes={},s.forEach((p,g)=>{p!==null&&(h.attributes[g]=p)}))),c="";break;case"retain":u>0&&(h={retain:u},h3(l)||(h.attributes=f3({},l))),u=0;break}h&&t.push(h),a=null}};for(;o!==null;){switch(o.content.constructor){case Ur:case aa:this.adds(o)?this.deletes(o)||(d(),a="insert",c=o.content.getContent()[0],d()):this.deletes(o)?(a!=="delete"&&(d(),a="delete"),f+=1):o.deleted||(a!=="retain"&&(d(),a="retain"),u+=1);break;case Fr:this.adds(o)?this.deletes(o)||(a!=="insert"&&(d(),a="insert"),c+=o.content.str):this.deletes(o)?(a!=="delete"&&(d(),a="delete"),f+=o.length):o.deleted||(a!=="retain"&&(d(),a="retain"),u+=o.length);break;case Bt:{const{key:h,value:p}=o.content;if(this.adds(o)){if(!this.deletes(o)){const g=s.get(h)??null;Gi(g,p)?p!==null&&o.delete(r):(a==="retain"&&d(),Gi(p,i.get(h)??null)?delete l[h]:l[h]=p)}}else if(this.deletes(o)){i.set(h,p);const g=s.get(h)??null;Gi(g,p)||(a==="retain"&&d(),l[h]=g)}else if(!o.deleted){i.set(h,p);const g=l[h];g!==void 0&&(Gi(g,p)?g!==null&&o.delete(r):(a==="retain"&&d(),p===null?delete l[h]:l[h]=p))}o.deleted||(a==="insert"&&d(),zl(s,o.content));break}}o=o.right}for(d();t.length>0;){const h=t[t.length-1];if(h.retain!==void 0&&h.attributes===void 0)t.pop();else break}}),this._delta=t}return this._delta}}class ia extends an{constructor(e){super(),this._pending=e!==void 0?[()=>this.insert(0,e)]:[],this._searchMarker=[],this._hasFormatting=!1}get length(){return this._length}_integrate(e,t){super._integrate(e,t);try{this._pending.forEach(r=>r())}catch(r){console.error(r)}this._pending=null}_copy(){return new ia}clone(){const e=new ia;return e.applyDelta(this.toDelta()),e}_callObserver(e,t){super._callObserver(e,t);const r=new _4(this,e,t);Xh(this,e,r),!e.local&&this._hasFormatting&&(e._needFormattingCleanup=!0)}toString(){let e="",t=this._start;for(;t!==null;)!t.deleted&&t.countable&&t.content.constructor===Fr&&(e+=t.content.str),t=t.right;return e}toJSON(){return this.toString()}applyDelta(e,{sanitize:t=!0}={}){this.doc!==null?ot(this.doc,r=>{const s=new ib(null,this._start,0,new Map);for(let i=0;i<e.length;i++){const o=e[i];if(o.insert!==void 0){const a=!t&&typeof o.insert=="string"&&i===e.length-1&&s.right===null&&o.insert.slice(-1)===`
|
374
374
|
`?o.insert.slice(0,-1):o.insert;(typeof a!="string"||a.length>0)&&ob(r,this,s,a,o.attributes||{})}else o.retain!==void 0?WC(r,this,s,o.retain,o.attributes||{}):o.delete!==void 0&&KC(r,s,o.delete)}}):this._pending.push(()=>this.applyDelta(e))}toDelta(e,t,r){const s=[],i=new Map,o=this.doc;let a="",l=this._start;function c(){if(a.length>0){const f={};let d=!1;i.forEach((p,g)=>{d=!0,f[g]=p});const h={insert:a};d&&(h.attributes=f),s.push(h),a=""}}const u=()=>{for(;l!==null;){if(sa(l,e)||t!==void 0&&sa(l,t))switch(l.content.constructor){case Fr:{const f=i.get("ychange");e!==void 0&&!sa(l,e)?(f===void 0||f.user!==l.id.client||f.type!=="removed")&&(c(),i.set("ychange",r?r("removed",l.id):{type:"removed"})):t!==void 0&&!sa(l,t)?(f===void 0||f.user!==l.id.client||f.type!=="added")&&(c(),i.set("ychange",r?r("added",l.id):{type:"added"})):f!==void 0&&(c(),i.delete("ychange")),a+=l.content.str;break}case Ur:case aa:{c();const f={insert:l.content.getContent()[0]};if(i.size>0){const d={};f.attributes=d,i.forEach((h,p)=>{d[p]=h})}s.push(f);break}case Bt:sa(l,e)&&(c(),zl(i,l.content));break}l=l.right}c()};return e||t?ot(o,f=>{e&&Y0(f,e),t&&Y0(f,t),u()},"cleanup"):u(),s}insert(e,t,r){if(t.length<=0)return;const s=this.doc;s!==null?ot(s,i=>{const o=np(i,this,e,!r);r||(r={},o.currentAttributes.forEach((a,l)=>{r[l]=a})),ob(i,this,o,t,r)}):this._pending.push(()=>this.insert(e,t,r))}insertEmbed(e,t,r){const s=this.doc;s!==null?ot(s,i=>{const o=np(i,this,e,!r);ob(i,this,o,t,r||{})}):this._pending.push(()=>this.insertEmbed(e,t,r||{}))}delete(e,t){if(t===0)return;const r=this.doc;r!==null?ot(r,s=>{KC(s,np(s,this,e,!0),t)}):this._pending.push(()=>this.delete(e,t))}format(e,t,r){if(t===0)return;const s=this.doc;s!==null?ot(s,i=>{const o=np(i,this,e,!1);o.right!==null&&WC(i,this,o,t,r)}):this._pending.push(()=>this.format(e,t,r))}removeAttribute(e){this.doc!==null?ot(this.doc,t=>{ep(t,this,e)}):this._pending.push(()=>this.removeAttribute(e))}setAttribute(e,t){this.doc!==null?ot(this.doc,r=>{rb(r,this,e,t)}):this._pending.push(()=>this.setAttribute(e,t))}getAttribute(e){return sb(this,e)}getAttributes(){return UC(this)}_write(e){e.writeTypeRef(e8)}}const L4=n=>new ia;class ab{constructor(e,t=()=>!0){this._filter=t,this._root=e,this._currentNode=e._start,this._firstCall=!0}[Symbol.iterator](){return this}next(){let e=this._currentNode,t=e&&e.content&&e.content.type;if(e!==null&&(!this._firstCall||e.deleted||!this._filter(t)))do if(t=e.content.type,!e.deleted&&(t.constructor===kn||t.constructor===oa)&&t._start!==null)e=t._start;else for(;e!==null;)if(e.right!==null){e=e.right;break}else e.parent===this._root?e=null:e=e.parent._item;while(e!==null&&(e.deleted||!this._filter(e.content.type)));return this._firstCall=!1,e===null?{value:void 0,done:!0}:(this._currentNode=e,{value:e.content.type,done:!1})}}class oa extends an{constructor(){super(),this._prelimContent=[]}get firstChild(){const e=this._first;return e?e.content.getContent()[0]:null}_integrate(e,t){super._integrate(e,t),this.insert(0,this._prelimContent),this._prelimContent=null}_copy(){return new oa}clone(){const e=new oa;return e.insert(0,this.toArray().map(t=>t instanceof an?t.clone():t)),e}get length(){return this._prelimContent===null?this._length:this._prelimContent.length}createTreeWalker(e){return new ab(this,e)}querySelector(e){e=e.toUpperCase();const r=new ab(this,s=>s.nodeName&&s.nodeName.toUpperCase()===e).next();return r.done?null:r.value}querySelectorAll(e){return e=e.toUpperCase(),Gs(new ab(this,t=>t.nodeName&&t.nodeName.toUpperCase()===e))}_callObserver(e,t){Xh(this,e,new U4(this,t,e))}toString(){return IC(this,e=>e.toString()).join("")}toJSON(){return this.toString()}toDOM(e=document,t={},r){const s=e.createDocumentFragment();return r!==void 0&&r._createAssociation(s,this),Tf(this,i=>{s.insertBefore(i.toDOM(e,t,r),null)}),s}insert(e,t){this.doc!==null?ot(this.doc,r=>{BC(r,this,e,t)}):this._prelimContent.splice(e,0,...t)}insertAfter(e,t){if(this.doc!==null)ot(this.doc,r=>{const s=e&&e instanceof an?e._item:e;Zh(r,this,s,t)});else{const r=this._prelimContent,s=e===null?0:r.findIndex(i=>i===e)+1;if(s===0&&e!==null)throw Lr("Reference item not found");r.splice(s,0,...t)}}delete(e,t=1){this.doc!==null?ot(this.doc,r=>{FC(r,this,e,t)}):this._prelimContent.splice(e,t)}toArray(){return PC(this)}push(e){this.insert(this.length,e)}unshift(e){this.insert(0,e)}get(e){return _C(this,e)}slice(e=0,t=this.length){return RC(this,e,t)}forEach(e){Tf(this,e)}_write(e){e.writeTypeRef(n8)}}const B4=n=>new oa;class kn extends oa{constructor(e="UNDEFINED"){super(),this.nodeName=e,this._prelimAttrs=new Map}get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_integrate(e,t){super._integrate(e,t),this._prelimAttrs.forEach((r,s)=>{this.setAttribute(s,r)}),this._prelimAttrs=null}_copy(){return new kn(this.nodeName)}clone(){const e=new kn(this.nodeName),t=this.getAttributes();return d3(t,(r,s)=>{typeof r=="string"&&e.setAttribute(s,r)}),e.insert(0,this.toArray().map(r=>r instanceof an?r.clone():r)),e}toString(){const e=this.getAttributes(),t=[],r=[];for(const a in e)r.push(a);r.sort();const s=r.length;for(let a=0;a<s;a++){const l=r[a];t.push(l+'="'+e[l]+'"')}const i=this.nodeName.toLocaleLowerCase(),o=t.length>0?" "+t.join(" "):"";return`<${i}${o}>${super.toString()}</${i}>`}removeAttribute(e){this.doc!==null?ot(this.doc,t=>{ep(t,this,e)}):this._prelimAttrs.delete(e)}setAttribute(e,t){this.doc!==null?ot(this.doc,r=>{rb(r,this,e,t)}):this._prelimAttrs.set(e,t)}getAttribute(e){return sb(this,e)}hasAttribute(e){return HC(this,e)}getAttributes(e){return e?T4(this,e):UC(this)}toDOM(e=document,t={},r){const s=e.createElement(this.nodeName),i=this.getAttributes();for(const o in i){const a=i[o];typeof a=="string"&&s.setAttribute(o,a)}return Tf(this,o=>{s.appendChild(o.toDOM(e,t,r))}),r!==void 0&&r._createAssociation(s,this),s}_write(e){e.writeTypeRef(t8),e.writeKey(this.nodeName)}}const F4=n=>new kn(n.readKey());class U4 extends Qh{constructor(e,t,r){super(e,r),this.childListChanged=!1,this.attributesChanged=new Set,t.forEach(s=>{s===null?this.childListChanged=!0:this.attributesChanged.add(s)})}}class rp extends $l{constructor(e){super(),this.hookName=e}_copy(){return new rp(this.hookName)}clone(){const e=new rp(this.hookName);return this.forEach((t,r)=>{e.set(r,t)}),e}toDOM(e=document,t={},r){const s=t[this.hookName];let i;return s!==void 0?i=s.createDom(this):i=document.createElement(this.hookName),i.setAttribute("data-yjs-hook",this.hookName),r!==void 0&&r._createAssociation(i,this),i}_write(e){e.writeTypeRef(r8),e.writeKey(this.hookName)}}const H4=n=>new rp(n.readKey());class er extends ia{get nextSibling(){const e=this._item?this._item.next:null;return e?e.content.type:null}get prevSibling(){const e=this._item?this._item.prev:null;return e?e.content.type:null}_copy(){return new er}clone(){const e=new er;return e.applyDelta(this.toDelta()),e}toDOM(e=document,t,r){const s=e.createTextNode(this.toString());return r!==void 0&&r._createAssociation(s,this),s}toString(){return this.toDelta().map(e=>{const t=[];for(const s in e.attributes){const i=[];for(const o in e.attributes[s])i.push({key:o,value:e.attributes[s][o]});i.sort((o,a)=>o.key<a.key?-1:1),t.push({nodeName:s,attrs:i})}t.sort((s,i)=>s.nodeName<i.nodeName?-1:1);let r="";for(let s=0;s<t.length;s++){const i=t[s];r+=`<${i.nodeName}`;for(let o=0;o<i.attrs.length;o++){const a=i.attrs[o];r+=` ${a.key}="${a.value}"`}r+=">"}r+=e.insert;for(let s=t.length-1;s>=0;s--)r+=`</${t[s].nodeName}>`;return r}).join("")}toJSON(){return this.toString()}_write(e){e.writeTypeRef(s8)}}const j4=n=>new er;class lb{constructor(e,t){this.id=e,this.length=t}get deleted(){throw Br()}mergeWith(e){return!1}write(e,t,r){throw Br()}integrate(e,t){throw Br()}}const $4=0;class br extends lb{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){t>0&&(this.id.clock+=t,this.length-=t),bC(e.doc.store,this)}write(e,t){e.writeInfo($4),e.writeLen(this.length-t)}getMissing(e,t){return null}}class Of{constructor(e){this.content=e}getLength(){return 1}getContent(){return[this.content]}isCountable(){return!0}copy(){return new Of(this.content)}splice(e){throw Br()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeBuf(this.content)}getRef(){return 3}}const z4=n=>new Of(n.readBuf());class Nf{constructor(e){this.len=e}getLength(){return this.len}getContent(){return[]}isCountable(){return!1}copy(){return new Nf(this.len)}splice(e){const t=new Nf(this.len-e);return this.len=e,t}mergeWith(e){return this.len+=e.len,!0}integrate(e,t){wf(e.deleteSet,t.id.client,t.id.clock,this.len),t.markDeleted()}delete(e){}gc(e){}write(e,t){e.writeLen(this.len-t)}getRef(){return 1}}const V4=n=>new Nf(n.readLen()),JC=(n,e)=>new Ll({guid:n,...e,shouldLoad:e.shouldLoad||e.autoLoad||!1});class Mf{constructor(e){e._item&&console.error("This document was already integrated as a sub-document. You should create a second instance instead with the same guid."),this.doc=e;const t={};this.opts=t,e.gc||(t.gc=!1),e.autoLoad&&(t.autoLoad=!0),e.meta!==null&&(t.meta=e.meta)}getLength(){return 1}getContent(){return[this.doc]}isCountable(){return!0}copy(){return new Mf(JC(this.doc.guid,this.opts))}splice(e){throw Br()}mergeWith(e){return!1}integrate(e,t){this.doc._item=t,e.subdocsAdded.add(this.doc),this.doc.shouldLoad&&e.subdocsLoaded.add(this.doc)}delete(e){e.subdocsAdded.has(this.doc)?e.subdocsAdded.delete(this.doc):e.subdocsRemoved.add(this.doc)}gc(e){}write(e,t){e.writeString(this.doc.guid),e.writeAny(this.opts)}getRef(){return 9}}const W4=n=>new Mf(JC(n.readString(),n.readAny()));class aa{constructor(e){this.embed=e}getLength(){return 1}getContent(){return[this.embed]}isCountable(){return!0}copy(){return new aa(this.embed)}splice(e){throw Br()}mergeWith(e){return!1}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeJSON(this.embed)}getRef(){return 5}}const G4=n=>new aa(n.readJSON());class Bt{constructor(e,t){this.key=e,this.value=t}getLength(){return 1}getContent(){return[]}isCountable(){return!1}copy(){return new Bt(this.key,this.value)}splice(e){throw Br()}mergeWith(e){return!1}integrate(e,t){const r=t.parent;r._searchMarker=null,r._hasFormatting=!0}delete(e){}gc(e){}write(e,t){e.writeKey(this.key),e.writeJSON(this.value)}getRef(){return 6}}const K4=n=>new Bt(n.readKey(),n.readJSON());class sp{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new sp(this.arr)}splice(e){const t=new sp(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let s=t;s<r;s++){const i=this.arr[s];e.writeString(i===void 0?"undefined":JSON.stringify(i))}}getRef(){return 2}}const J4=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++){const s=n.readString();s==="undefined"?t.push(void 0):t.push(JSON.parse(s))}return new sp(t)};class la{constructor(e){this.arr=e}getLength(){return this.arr.length}getContent(){return this.arr}isCountable(){return!0}copy(){return new la(this.arr)}splice(e){const t=new la(this.arr.slice(e));return this.arr=this.arr.slice(0,e),t}mergeWith(e){return this.arr=this.arr.concat(e.arr),!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){const r=this.arr.length;e.writeLen(r-t);for(let s=t;s<r;s++){const i=this.arr[s];e.writeAny(i)}}getRef(){return 8}}const q4=n=>{const e=n.readLen(),t=[];for(let r=0;r<e;r++)t.push(n.readAny());return new la(t)};class Fr{constructor(e){this.str=e}getLength(){return this.str.length}getContent(){return this.str.split("")}isCountable(){return!0}copy(){return new Fr(this.str)}splice(e){const t=new Fr(this.str.slice(e));this.str=this.str.slice(0,e);const r=this.str.charCodeAt(e-1);return r>=55296&&r<=56319&&(this.str=this.str.slice(0,e-1)+"�",t.str="�"+t.str.slice(1)),t}mergeWith(e){return this.str+=e.str,!0}integrate(e,t){}delete(e){}gc(e){}write(e,t){e.writeString(t===0?this.str:this.str.slice(t))}getRef(){return 4}}const Q4=n=>new Fr(n.readString()),Y4=[N4,R4,L4,F4,B4,H4,j4],X4=0,Z4=1,e8=2,t8=3,n8=4,r8=5,s8=6;class Ur{constructor(e){this.type=e}getLength(){return 1}getContent(){return[this.type]}isCountable(){return!0}copy(){return new Ur(this.type._copy())}splice(e){throw Br()}mergeWith(e){return!1}integrate(e,t){this.type._integrate(e.doc,t)}delete(e){let t=this.type._start;for(;t!==null;)t.deleted?t.id.clock<(e.beforeState.get(t.id.client)||0)&&e._mergeStructs.push(t):t.delete(e),t=t.right;this.type._map.forEach(r=>{r.deleted?r.id.clock<(e.beforeState.get(r.id.client)||0)&&e._mergeStructs.push(r):r.delete(e)}),e.changed.delete(this.type)}gc(e){let t=this.type._start;for(;t!==null;)t.gc(e,!0),t=t.right;this.type._start=null,this.type._map.forEach(r=>{for(;r!==null;)r.gc(e,!0),r=r.left}),this.type._map=new Map}write(e,t){this.type._write(e)}getRef(){return 7}}const i8=n=>new Ur(Y4[n.readTypeRef()](n)),cb=(n,e)=>{let t=e,r=0,s;do r>0&&(t=Ne(t.client,t.clock+r)),s=Hl(n,t),r=t.clock-s.id.clock,t=s.redone;while(t!==null&&s instanceof ht);return{item:s,diff:r}},ub=(n,e)=>{for(;n!==null&&n.keep!==e;)n.keep=e,n=n.parent._item},ip=(n,e,t)=>{const{client:r,clock:s}=e.id,i=new ht(Ne(r,s+t),e,Ne(r,s+t-1),e.right,e.rightOrigin,e.parent,e.parentSub,e.content.splice(t));return e.deleted&&i.markDeleted(),e.keep&&(i.keep=!0),e.redone!==null&&(i.redone=Ne(e.redone.client,e.redone.clock+t)),e.right=i,i.right!==null&&(i.right.left=i),n._mergeStructs.push(i),i.parentSub!==null&&i.right===null&&i.parent._map.set(i.parentSub,i),e.length=t,i},qC=(n,e)=>PF(n,t=>Il(t.deletions,e)),QC=(n,e,t,r,s,i)=>{const o=n.doc,a=o.store,l=o.clientID,c=e.redone;if(c!==null)return jn(n,c);let u=e.parent._item,f=null,d;if(u!==null&&u.deleted===!0){if(u.redone===null&&(!t.has(u)||QC(n,u,t,r,s,i)===null))return null;for(;u.redone!==null;)u=jn(n,u.redone)}const h=u===null?e.parent:u.content.type;if(e.parentSub===null){for(f=e.left,d=e;f!==null;){let b=f;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:jn(n,b.redone);if(b!==null&&b.parent._item===u){f=b;break}f=f.left}for(;d!==null;){let b=d;for(;b!==null&&b.parent._item!==u;)b=b.redone===null?null:jn(n,b.redone);if(b!==null&&b.parent._item===u){d=b;break}d=d.right}}else if(d=null,e.right&&!s){for(f=e;f!==null&&f.right!==null&&(f.right.redone||Il(r,f.right.id)||qC(i.undoStack,f.right.id)||qC(i.redoStack,f.right.id));)for(f=f.right;f.redone;)f=jn(n,f.redone);if(f&&f.right!==null)return null}else f=h._map.get(e.parentSub)||null;const p=Mt(a,l),g=Ne(l,p),y=new ht(g,f,f&&f.lastId,d,d&&d.id,h,e.parentSub,e.content.copy());return e.redone=g,ub(y,!0),y.integrate(n,0),y};let ht=class t1 extends lb{constructor(e,t,r,s,i,o,a,l){super(e,l.getLength()),this.origin=r,this.left=t,this.right=s,this.rightOrigin=i,this.parent=o,this.parentSub=a,this.redone=null,this.content=l,this.info=this.content.isCountable()?bk:0}set marker(e){(this.info&x0)>0!==e&&(this.info^=x0)}get marker(){return(this.info&x0)>0}get keep(){return(this.info&yk)>0}set keep(e){this.keep!==e&&(this.info^=yk)}get countable(){return(this.info&bk)>0}get deleted(){return(this.info&A0)>0}set deleted(e){this.deleted!==e&&(this.info^=A0)}markDeleted(){this.info|=A0}getMissing(e,t){if(this.origin&&this.origin.client!==this.id.client&&this.origin.clock>=Mt(t,this.origin.client))return this.origin.client;if(this.rightOrigin&&this.rightOrigin.client!==this.id.client&&this.rightOrigin.clock>=Mt(t,this.rightOrigin.client))return this.rightOrigin.client;if(this.parent&&this.parent.constructor===Fl&&this.id.client!==this.parent.client&&this.parent.clock>=Mt(t,this.parent.client))return this.parent.client;if(this.origin&&(this.left=wC(e,t,this.origin),this.origin=this.left.lastId),this.rightOrigin&&(this.right=jn(e,this.rightOrigin),this.rightOrigin=this.right.id),this.left&&this.left.constructor===br||this.right&&this.right.constructor===br)this.parent=null;else if(!this.parent)this.left&&this.left.constructor===t1&&(this.parent=this.left.parent,this.parentSub=this.left.parentSub),this.right&&this.right.constructor===t1&&(this.parent=this.right.parent,this.parentSub=this.right.parentSub);else if(this.parent.constructor===Fl){const r=Hl(t,this.parent);r.constructor===br?this.parent=null:this.parent=r.content.type}return null}integrate(e,t){if(t>0&&(this.id.clock+=t,this.left=wC(e,e.doc.store,Ne(this.id.client,this.id.clock-1)),this.origin=this.left.lastId,this.content=this.content.splice(t),this.length-=t),this.parent){if(!this.left&&(!this.right||this.right.left!==null)||this.left&&this.left.right!==this.right){let r=this.left,s;if(r!==null)s=r.right;else if(this.parentSub!==null)for(s=this.parent._map.get(this.parentSub)||null;s!==null&&s.left!==null;)s=s.left;else s=this.parent._start;const i=new Set,o=new Set;for(;s!==null&&s!==this.right;){if(o.add(s),i.add(s),Ul(this.origin,s.origin)){if(s.id.client<this.id.client)r=s,i.clear();else if(Ul(this.rightOrigin,s.rightOrigin))break}else if(s.origin!==null&&o.has(Hl(e.doc.store,s.origin)))i.has(Hl(e.doc.store,s.origin))||(r=s,i.clear());else break;s=s.right}this.left=r}if(this.left!==null){const r=this.left.right;this.right=r,this.left.right=this}else{let r;if(this.parentSub!==null)for(r=this.parent._map.get(this.parentSub)||null;r!==null&&r.left!==null;)r=r.left;else r=this.parent._start,this.parent._start=this;this.right=r}this.right!==null?this.right.left=this:this.parentSub!==null&&(this.parent._map.set(this.parentSub,this),this.left!==null&&this.left.delete(e)),this.parentSub===null&&this.countable&&!this.deleted&&(this.parent._length+=this.length),bC(e.doc.store,this),this.content.integrate(e,this),xC(e,this.parent,this.parentSub),(this.parent._item!==null&&this.parent._item.deleted||this.parentSub!==null&&this.right!==null)&&this.delete(e)}else new br(this.id,this.length).integrate(e,0)}get next(){let e=this.right;for(;e!==null&&e.deleted;)e=e.right;return e}get prev(){let e=this.left;for(;e!==null&&e.deleted;)e=e.left;return e}get lastId(){return this.length===1?this.id:Ne(this.id.client,this.id.clock+this.length-1)}mergeWith(e){if(this.constructor===e.constructor&&Ul(e.origin,this.lastId)&&this.right===e&&Ul(this.rightOrigin,e.rightOrigin)&&this.id.client===e.id.client&&this.id.clock+this.length===e.id.clock&&this.deleted===e.deleted&&this.redone===null&&e.redone===null&&this.content.constructor===e.content.constructor&&this.content.mergeWith(e.content)){const t=this.parent._searchMarker;return t&&t.forEach(r=>{r.p===e&&(r.p=this,!this.deleted&&this.countable&&(r.index-=this.length))}),e.keep&&(this.keep=!0),this.right=e.right,this.right!==null&&(this.right.left=this),this.length+=e.length,!0}return!1}delete(e){if(!this.deleted){const t=this.parent;this.countable&&this.parentSub===null&&(t._length-=this.length),this.markDeleted(),wf(e.deleteSet,this.id.client,this.id.clock,this.length),xC(e,t,this.parentSub),this.content.delete(e)}}gc(e,t){if(!this.deleted)throw gr();this.content.gc(e),t?u4(e,this,new br(this.id,this.length)):this.content=new Nf(this.length)}write(e,t){const r=t>0?Ne(this.id.client,this.id.clock+t-1):this.origin,s=this.rightOrigin,i=this.parentSub,o=this.content.getRef()&Uh|(r===null?0:Zn)|(s===null?0:Js)|(i===null?0:hf);if(e.writeInfo(o),r!==null&&e.writeLeftID(r),s!==null&&e.writeRightID(s),r===null&&s===null){const a=this.parent;if(a._item!==void 0){const l=a._item;if(l===null){const c=Af(a);e.writeParentInfo(!0),e.writeString(c)}else e.writeParentInfo(!1),e.writeLeftID(l.id)}else a.constructor===String?(e.writeParentInfo(!0),e.writeString(a)):a.constructor===Fl?(e.writeParentInfo(!1),e.writeLeftID(a)):gr();i!==null&&e.writeString(i)}this.content.write(e,t)}};const YC=(n,e)=>o8[e&Uh](n),o8=[()=>{gr()},V4,J4,z4,Q4,G4,K4,i8,q4,W4,()=>{gr()}],a8=10;class wr extends lb{get deleted(){return!0}delete(){}mergeWith(e){return this.constructor!==e.constructor?!1:(this.length+=e.length,!0)}integrate(e,t){gr()}write(e,t){e.writeInfo(a8),ve(e.restEncoder,this.length-t)}getMissing(e,t){return null}}const XC=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:{},ZC="__ $YJS$ __";XC[ZC]===!0&&console.error("Yjs was already imported. This breaks constructor checks and will lead to issues! - https://github.com/yjs/yjs/issues/438"),XC[ZC]=!0;function op(n){throw new Error('Could not dynamically require "'+n+'". Please configure the dynamicRequireTargets or/and ignoreDynamicRequires option of @rollup/plugin-commonjs appropriately for this require call to work.')}var eS={exports:{}};(function(n,e){(function(t){n.exports=t()})(function(){var t=Math.floor,r=Math.abs,s=Math.pow;return function(){function i(o,a,l){function c(d,h){if(!a[d]){if(!o[d]){var p=typeof op=="function"&&op;if(!h&&p)return p(d,!0);if(u)return u(d,!0);var g=new Error("Cannot find module '"+d+"'");throw g.code="MODULE_NOT_FOUND",g}var y=a[d]={exports:{}};o[d][0].call(y.exports,function(b){var x=o[d][1][b];return c(x||b)},y,y.exports,i,o,a,l)}return a[d].exports}for(var u=typeof op=="function"&&op,f=0;f<l.length;f++)c(l[f]);return c}return i}()({1:[function(i,o,a){function l(w){var E=w.length;if(0<E%4)throw new Error("Invalid string. Length must be a multiple of 4");var C=w.indexOf("=");C===-1&&(C=E);var T=C===E?0:4-C%4;return[C,T]}function c(w,E,C){return 3*(E+C)/4-C}function u(w){var E,C,T=l(w),N=T[0],M=T[1],O=new y(c(w,N,M)),I=0,L=0<M?N-4:N;for(C=0;C<L;C+=4)E=g[w.charCodeAt(C)]<<18|g[w.charCodeAt(C+1)]<<12|g[w.charCodeAt(C+2)]<<6|g[w.charCodeAt(C+3)],O[I++]=255&E>>16,O[I++]=255&E>>8,O[I++]=255&E;return M===2&&(E=g[w.charCodeAt(C)]<<2|g[w.charCodeAt(C+1)]>>4,O[I++]=255&E),M===1&&(E=g[w.charCodeAt(C)]<<10|g[w.charCodeAt(C+1)]<<4|g[w.charCodeAt(C+2)]>>2,O[I++]=255&E>>8,O[I++]=255&E),O}function f(w){return p[63&w>>18]+p[63&w>>12]+p[63&w>>6]+p[63&w]}function d(w,E,C){for(var T,N=[],M=E;M<C;M+=3)T=(16711680&w[M]<<16)+(65280&w[M+1]<<8)+(255&w[M+2]),N.push(f(T));return N.join("")}function h(w){for(var E,C=w.length,T=C%3,N=[],M=16383,O=0,I=C-T;O<I;O+=M)N.push(d(w,O,O+M>I?I:O+M));return T===1?(E=w[C-1],N.push(p[E>>2]+p[63&E<<4]+"==")):T===2&&(E=(w[C-2]<<8)+w[C-1],N.push(p[E>>10]+p[63&E>>4]+p[63&E<<2]+"=")),N.join("")}a.byteLength=function(w){var E=l(w),C=E[0],T=E[1];return 3*(C+T)/4-T},a.toByteArray=u,a.fromByteArray=h;for(var p=[],g=[],y=typeof Uint8Array>"u"?Array:Uint8Array,b="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",x=0,v=b.length;x<v;++x)p[x]=b[x],g[b.charCodeAt(x)]=x;g[45]=62,g[95]=63},{}],2:[function(){},{}],3:[function(i,o,a){(function(){(function(){var l=String.fromCharCode,c=Math.min;function u(m){if(2147483647<m)throw new RangeError('The value "'+m+'" is invalid for option "size"');var A=new Uint8Array(m);return A.__proto__=f.prototype,A}function f(m,A,S){if(typeof m=="number"){if(typeof A=="string")throw new TypeError('The "string" argument must be of type string. Received type number');return g(m)}return d(m,A,S)}function d(m,A,S){if(typeof m=="string")return y(m,A);if(ArrayBuffer.isView(m))return b(m);if(m==null)throw TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m);if(z(m,ArrayBuffer)||m&&z(m.buffer,ArrayBuffer))return x(m,A,S);if(typeof m=="number")throw new TypeError('The "value" argument must not be of type number. Received type number');var F=m.valueOf&&m.valueOf();if(F!=null&&F!==m)return f.from(F,A,S);var V=v(m);if(V)return V;if(typeof Symbol<"u"&&Symbol.toPrimitive!=null&&typeof m[Symbol.toPrimitive]=="function")return f.from(m[Symbol.toPrimitive]("string"),A,S);throw new TypeError("The first argument must be one of type string, Buffer, ArrayBuffer, Array, or Array-like Object. Received type "+typeof m)}function h(m){if(typeof m!="number")throw new TypeError('"size" argument must be of type number');if(0>m)throw new RangeError('The value "'+m+'" is invalid for option "size"')}function p(m,A,S){return h(m),0>=m||A===void 0?u(m):typeof S=="string"?u(m).fill(A,S):u(m).fill(A)}function g(m){return h(m),u(0>m?0:0|w(m))}function y(m,A){if((typeof A!="string"||A==="")&&(A="utf8"),!f.isEncoding(A))throw new TypeError("Unknown encoding: "+A);var S=0|E(m,A),F=u(S),V=F.write(m,A);return V!==S&&(F=F.slice(0,V)),F}function b(m){for(var A=0>m.length?0:0|w(m.length),S=u(A),F=0;F<A;F+=1)S[F]=255&m[F];return S}function x(m,A,S){if(0>A||m.byteLength<A)throw new RangeError('"offset" is outside of buffer bounds');if(m.byteLength<A+(S||0))throw new RangeError('"length" is outside of buffer bounds');var F;return F=A===void 0&&S===void 0?new Uint8Array(m):S===void 0?new Uint8Array(m,A):new Uint8Array(m,A,S),F.__proto__=f.prototype,F}function v(m){if(f.isBuffer(m)){var A=0|w(m.length),S=u(A);return S.length===0||m.copy(S,0,0,A),S}return m.length===void 0?m.type==="Buffer"&&Array.isArray(m.data)?b(m.data):void 0:typeof m.length!="number"||K(m.length)?u(0):b(m)}function w(m){if(m>=2147483647)throw new RangeError("Attempt to allocate Buffer larger than maximum size: 0x7fffffff bytes");return 0|m}function E(m,A){if(f.isBuffer(m))return m.length;if(ArrayBuffer.isView(m)||z(m,ArrayBuffer))return m.byteLength;if(typeof m!="string")throw new TypeError('The "string" argument must be one of type string, Buffer, or ArrayBuffer. Received type '+typeof m);var S=m.length,F=2<arguments.length&&arguments[2]===!0;if(!F&&S===0)return 0;for(var V=!1;;)switch(A){case"ascii":case"latin1":case"binary":return S;case"utf8":case"utf-8":return nt(m).length;case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return 2*S;case"hex":return S>>>1;case"base64":return Qe(m).length;default:if(V)return F?-1:nt(m).length;A=(""+A).toLowerCase(),V=!0}}function C(m,A,S){var F=!1;if((A===void 0||0>A)&&(A=0),A>this.length||((S===void 0||S>this.length)&&(S=this.length),0>=S)||(S>>>=0,A>>>=0,S<=A))return"";for(m||(m="utf8");;)switch(m){case"hex":return Me(this,A,S);case"utf8":case"utf-8":return Y(this,A,S);case"ascii":return Z(this,A,S);case"latin1":case"binary":return me(this,A,S);case"base64":return G(this,A,S);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return De(this,A,S);default:if(F)throw new TypeError("Unknown encoding: "+m);m=(m+"").toLowerCase(),F=!0}}function T(m,A,S){var F=m[A];m[A]=m[S],m[S]=F}function N(m,A,S,F,V){if(m.length===0)return-1;if(typeof S=="string"?(F=S,S=0):2147483647<S?S=2147483647:-2147483648>S&&(S=-2147483648),S=+S,K(S)&&(S=V?0:m.length-1),0>S&&(S=m.length+S),S>=m.length){if(V)return-1;S=m.length-1}else if(0>S)if(V)S=0;else return-1;if(typeof A=="string"&&(A=f.from(A,F)),f.isBuffer(A))return A.length===0?-1:M(m,A,S,F,V);if(typeof A=="number")return A&=255,typeof Uint8Array.prototype.indexOf=="function"?V?Uint8Array.prototype.indexOf.call(m,A,S):Uint8Array.prototype.lastIndexOf.call(m,A,S):M(m,[A],S,F,V);throw new TypeError("val must be string, number or Buffer")}function M(m,A,S,F,V){function q(Fs,Q){return de===1?Fs[Q]:Fs.readUInt16BE(Q*de)}var de=1,ke=m.length,et=A.length;if(F!==void 0&&(F=(F+"").toLowerCase(),F==="ucs2"||F==="ucs-2"||F==="utf16le"||F==="utf-16le")){if(2>m.length||2>A.length)return-1;de=2,ke/=2,et/=2,S/=2}var Le;if(V){var Ie=-1;for(Le=S;Le<ke;Le++)if(q(m,Le)!==q(A,Ie===-1?0:Le-Ie))Ie!==-1&&(Le-=Le-Ie),Ie=-1;else if(Ie===-1&&(Ie=Le),Le-Ie+1===et)return Ie*de}else for(S+et>ke&&(S=ke-et),Le=S;0<=Le;Le--){for(var Ct=!0,es=0;es<et;es++)if(q(m,Le+es)!==q(A,es)){Ct=!1;break}if(Ct)return Le}return-1}function O(m,A,S,F){S=+S||0;var V=m.length-S;F?(F=+F,F>V&&(F=V)):F=V;var q=A.length;F>q/2&&(F=q/2);for(var de,ke=0;ke<F;++ke){if(de=parseInt(A.substr(2*ke,2),16),K(de))return ke;m[S+ke]=de}return ke}function I(m,A,S,F){return lt(nt(A,m.length-S),m,S,F)}function L(m,A,S,F){return lt(zt(A),m,S,F)}function $(m,A,S,F){return L(m,A,S,F)}function J(m,A,S,F){return lt(Qe(A),m,S,F)}function U(m,A,S,F){return lt(yt(A,m.length-S),m,S,F)}function G(m,A,S){return A===0&&S===m.length?ee.fromByteArray(m):ee.fromByteArray(m.slice(A,S))}function Y(m,A,S){S=c(m.length,S);for(var F=[],V=A;V<S;){var q=m[V],de=null,ke=239<q?4:223<q?3:191<q?2:1;if(V+ke<=S){var et,Le,Ie,Ct;ke===1?128>q&&(de=q):ke===2?(et=m[V+1],(192&et)==128&&(Ct=(31&q)<<6|63&et,127<Ct&&(de=Ct))):ke===3?(et=m[V+1],Le=m[V+2],(192&et)==128&&(192&Le)==128&&(Ct=(15&q)<<12|(63&et)<<6|63&Le,2047<Ct&&(55296>Ct||57343<Ct)&&(de=Ct))):ke===4&&(et=m[V+1],Le=m[V+2],Ie=m[V+3],(192&et)==128&&(192&Le)==128&&(192&Ie)==128&&(Ct=(15&q)<<18|(63&et)<<12|(63&Le)<<6|63&Ie,65535<Ct&&1114112>Ct&&(de=Ct)))}de===null?(de=65533,ke=1):65535<de&&(de-=65536,F.push(55296|1023&de>>>10),de=56320|1023&de),F.push(de),V+=ke}return re(F)}function re(m){var A=m.length;if(A<=4096)return l.apply(String,m);for(var S="",F=0;F<A;)S+=l.apply(String,m.slice(F,F+=4096));return S}function Z(m,A,S){var F="";S=c(m.length,S);for(var V=A;V<S;++V)F+=l(127&m[V]);return F}function me(m,A,S){var F="";S=c(m.length,S);for(var V=A;V<S;++V)F+=l(m[V]);return F}function Me(m,A,S){var F=m.length;(!A||0>A)&&(A=0),(!S||0>S||S>F)&&(S=F);for(var V="",q=A;q<S;++q)V+=Ze(m[q]);return V}function De(m,A,S){for(var F=m.slice(A,S),V="",q=0;q<F.length;q+=2)V+=l(F[q]+256*F[q+1]);return V}function Se(m,A,S){if(m%1!=0||0>m)throw new RangeError("offset is not uint");if(m+A>S)throw new RangeError("Trying to access beyond buffer length")}function Ee(m,A,S,F,V,q){if(!f.isBuffer(m))throw new TypeError('"buffer" argument must be a Buffer instance');if(A>V||A<q)throw new RangeError('"value" argument is out of bounds');if(S+F>m.length)throw new RangeError("Index out of range")}function He(m,A,S,F){if(S+F>m.length)throw new RangeError("Index out of range");if(0>S)throw new RangeError("Index out of range")}function Ve(m,A,S,F,V){return A=+A,S>>>=0,V||He(m,A,S,4),fe.write(m,A,S,F,23,4),S+4}function Xe(m,A,S,F,V){return A=+A,S>>>=0,V||He(m,A,S,8),fe.write(m,A,S,F,52,8),S+8}function mt(m){if(m=m.split("=")[0],m=m.trim().replace(P,""),2>m.length)return"";for(;m.length%4!=0;)m+="=";return m}function Ze(m){return 16>m?"0"+m.toString(16):m.toString(16)}function nt(m,A){A=A||1/0;for(var S,F=m.length,V=null,q=[],de=0;de<F;++de){if(S=m.charCodeAt(de),55295<S&&57344>S){if(!V){if(56319<S){-1<(A-=3)&&q.push(239,191,189);continue}else if(de+1===F){-1<(A-=3)&&q.push(239,191,189);continue}V=S;continue}if(56320>S){-1<(A-=3)&&q.push(239,191,189),V=S;continue}S=(V-55296<<10|S-56320)+65536}else V&&-1<(A-=3)&&q.push(239,191,189);if(V=null,128>S){if(0>(A-=1))break;q.push(S)}else if(2048>S){if(0>(A-=2))break;q.push(192|S>>6,128|63&S)}else if(65536>S){if(0>(A-=3))break;q.push(224|S>>12,128|63&S>>6,128|63&S)}else if(1114112>S){if(0>(A-=4))break;q.push(240|S>>18,128|63&S>>12,128|63&S>>6,128|63&S)}else throw new Error("Invalid code point")}return q}function zt(m){for(var A=[],S=0;S<m.length;++S)A.push(255&m.charCodeAt(S));return A}function yt(m,A){for(var S,F,V,q=[],de=0;de<m.length&&!(0>(A-=2));++de)S=m.charCodeAt(de),F=S>>8,V=S%256,q.push(V),q.push(F);return q}function Qe(m){return ee.toByteArray(mt(m))}function lt(m,A,S,F){for(var V=0;V<F&&!(V+S>=A.length||V>=m.length);++V)A[V+S]=m[V];return V}function z(m,A){return m instanceof A||m!=null&&m.constructor!=null&&m.constructor.name!=null&&m.constructor.name===A.name}function K(m){return m!==m}var ee=i("base64-js"),fe=i("ieee754");a.Buffer=f,a.SlowBuffer=function(m){return+m!=m&&(m=0),f.alloc(+m)},a.INSPECT_MAX_BYTES=50,a.kMaxLength=2147483647,f.TYPED_ARRAY_SUPPORT=function(){try{var m=new Uint8Array(1);return m.__proto__={__proto__:Uint8Array.prototype,foo:function(){return 42}},m.foo()===42}catch{return!1}}(),f.TYPED_ARRAY_SUPPORT||typeof console>"u"||typeof console.error!="function"||console.error("This browser lacks typed array (Uint8Array) support which is required by `buffer` v5.x. Use `buffer` v4.x if you require old browser support."),Object.defineProperty(f.prototype,"parent",{enumerable:!0,get:function(){return f.isBuffer(this)?this.buffer:void 0}}),Object.defineProperty(f.prototype,"offset",{enumerable:!0,get:function(){return f.isBuffer(this)?this.byteOffset:void 0}}),typeof Symbol<"u"&&Symbol.species!=null&&f[Symbol.species]===f&&Object.defineProperty(f,Symbol.species,{value:null,configurable:!0,enumerable:!1,writable:!1}),f.poolSize=8192,f.from=function(m,A,S){return d(m,A,S)},f.prototype.__proto__=Uint8Array.prototype,f.__proto__=Uint8Array,f.alloc=function(m,A,S){return p(m,A,S)},f.allocUnsafe=function(m){return g(m)},f.allocUnsafeSlow=function(m){return g(m)},f.isBuffer=function(m){return m!=null&&m._isBuffer===!0&&m!==f.prototype},f.compare=function(m,A){if(z(m,Uint8Array)&&(m=f.from(m,m.offset,m.byteLength)),z(A,Uint8Array)&&(A=f.from(A,A.offset,A.byteLength)),!f.isBuffer(m)||!f.isBuffer(A))throw new TypeError('The "buf1", "buf2" arguments must be one of type Buffer or Uint8Array');if(m===A)return 0;for(var S=m.length,F=A.length,V=0,q=c(S,F);V<q;++V)if(m[V]!==A[V]){S=m[V],F=A[V];break}return S<F?-1:F<S?1:0},f.isEncoding=function(m){switch((m+"").toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"latin1":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return!0;default:return!1}},f.concat=function(m,A){if(!Array.isArray(m))throw new TypeError('"list" argument must be an Array of Buffers');if(m.length===0)return f.alloc(0);var S;if(A===void 0)for(A=0,S=0;S<m.length;++S)A+=m[S].length;var F=f.allocUnsafe(A),V=0;for(S=0;S<m.length;++S){var q=m[S];if(z(q,Uint8Array)&&(q=f.from(q)),!f.isBuffer(q))throw new TypeError('"list" argument must be an Array of Buffers');q.copy(F,V),V+=q.length}return F},f.byteLength=E,f.prototype._isBuffer=!0,f.prototype.swap16=function(){var m=this.length;if(m%2!=0)throw new RangeError("Buffer size must be a multiple of 16-bits");for(var A=0;A<m;A+=2)T(this,A,A+1);return this},f.prototype.swap32=function(){var m=this.length;if(m%4!=0)throw new RangeError("Buffer size must be a multiple of 32-bits");for(var A=0;A<m;A+=4)T(this,A,A+3),T(this,A+1,A+2);return this},f.prototype.swap64=function(){var m=this.length;if(m%8!=0)throw new RangeError("Buffer size must be a multiple of 64-bits");for(var A=0;A<m;A+=8)T(this,A,A+7),T(this,A+1,A+6),T(this,A+2,A+5),T(this,A+3,A+4);return this},f.prototype.toString=function(){var m=this.length;return m===0?"":arguments.length===0?Y(this,0,m):C.apply(this,arguments)},f.prototype.toLocaleString=f.prototype.toString,f.prototype.equals=function(m){if(!f.isBuffer(m))throw new TypeError("Argument must be a Buffer");return this===m||f.compare(this,m)===0},f.prototype.inspect=function(){var m="",A=a.INSPECT_MAX_BYTES;return m=this.toString("hex",0,A).replace(/(.{2})/g,"$1 ").trim(),this.length>A&&(m+=" ... "),"<Buffer "+m+">"},f.prototype.compare=function(m,A,S,F,V){if(z(m,Uint8Array)&&(m=f.from(m,m.offset,m.byteLength)),!f.isBuffer(m))throw new TypeError('The "target" argument must be one of type Buffer or Uint8Array. Received type '+typeof m);if(A===void 0&&(A=0),S===void 0&&(S=m?m.length:0),F===void 0&&(F=0),V===void 0&&(V=this.length),0>A||S>m.length||0>F||V>this.length)throw new RangeError("out of range index");if(F>=V&&A>=S)return 0;if(F>=V)return-1;if(A>=S)return 1;if(A>>>=0,S>>>=0,F>>>=0,V>>>=0,this===m)return 0;for(var q=V-F,de=S-A,ke=c(q,de),et=this.slice(F,V),Le=m.slice(A,S),Ie=0;Ie<ke;++Ie)if(et[Ie]!==Le[Ie]){q=et[Ie],de=Le[Ie];break}return q<de?-1:de<q?1:0},f.prototype.includes=function(m,A,S){return this.indexOf(m,A,S)!==-1},f.prototype.indexOf=function(m,A,S){return N(this,m,A,S,!0)},f.prototype.lastIndexOf=function(m,A,S){return N(this,m,A,S,!1)},f.prototype.write=function(m,A,S,F){if(A===void 0)F="utf8",S=this.length,A=0;else if(S===void 0&&typeof A=="string")F=A,S=this.length,A=0;else if(isFinite(A))A>>>=0,isFinite(S)?(S>>>=0,F===void 0&&(F="utf8")):(F=S,S=void 0);else throw new Error("Buffer.write(string, encoding, offset[, length]) is no longer supported");var V=this.length-A;if((S===void 0||S>V)&&(S=V),0<m.length&&(0>S||0>A)||A>this.length)throw new RangeError("Attempt to write outside buffer bounds");F||(F="utf8");for(var q=!1;;)switch(F){case"hex":return O(this,m,A,S);case"utf8":case"utf-8":return I(this,m,A,S);case"ascii":return L(this,m,A,S);case"latin1":case"binary":return $(this,m,A,S);case"base64":return J(this,m,A,S);case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return U(this,m,A,S);default:if(q)throw new TypeError("Unknown encoding: "+F);F=(""+F).toLowerCase(),q=!0}},f.prototype.toJSON=function(){return{type:"Buffer",data:Array.prototype.slice.call(this._arr||this,0)}},f.prototype.slice=function(m,A){var S=this.length;m=~~m,A=A===void 0?S:~~A,0>m?(m+=S,0>m&&(m=0)):m>S&&(m=S),0>A?(A+=S,0>A&&(A=0)):A>S&&(A=S),A<m&&(A=m);var F=this.subarray(m,A);return F.__proto__=f.prototype,F},f.prototype.readUIntLE=function(m,A,S){m>>>=0,A>>>=0,S||Se(m,A,this.length);for(var F=this[m],V=1,q=0;++q<A&&(V*=256);)F+=this[m+q]*V;return F},f.prototype.readUIntBE=function(m,A,S){m>>>=0,A>>>=0,S||Se(m,A,this.length);for(var F=this[m+--A],V=1;0<A&&(V*=256);)F+=this[m+--A]*V;return F},f.prototype.readUInt8=function(m,A){return m>>>=0,A||Se(m,1,this.length),this[m]},f.prototype.readUInt16LE=function(m,A){return m>>>=0,A||Se(m,2,this.length),this[m]|this[m+1]<<8},f.prototype.readUInt16BE=function(m,A){return m>>>=0,A||Se(m,2,this.length),this[m]<<8|this[m+1]},f.prototype.readUInt32LE=function(m,A){return m>>>=0,A||Se(m,4,this.length),(this[m]|this[m+1]<<8|this[m+2]<<16)+16777216*this[m+3]},f.prototype.readUInt32BE=function(m,A){return m>>>=0,A||Se(m,4,this.length),16777216*this[m]+(this[m+1]<<16|this[m+2]<<8|this[m+3])},f.prototype.readIntLE=function(m,A,S){m>>>=0,A>>>=0,S||Se(m,A,this.length);for(var F=this[m],V=1,q=0;++q<A&&(V*=256);)F+=this[m+q]*V;return V*=128,F>=V&&(F-=s(2,8*A)),F},f.prototype.readIntBE=function(m,A,S){m>>>=0,A>>>=0,S||Se(m,A,this.length);for(var F=A,V=1,q=this[m+--F];0<F&&(V*=256);)q+=this[m+--F]*V;return V*=128,q>=V&&(q-=s(2,8*A)),q},f.prototype.readInt8=function(m,A){return m>>>=0,A||Se(m,1,this.length),128&this[m]?-1*(255-this[m]+1):this[m]},f.prototype.readInt16LE=function(m,A){m>>>=0,A||Se(m,2,this.length);var S=this[m]|this[m+1]<<8;return 32768&S?4294901760|S:S},f.prototype.readInt16BE=function(m,A){m>>>=0,A||Se(m,2,this.length);var S=this[m+1]|this[m]<<8;return 32768&S?4294901760|S:S},f.prototype.readInt32LE=function(m,A){return m>>>=0,A||Se(m,4,this.length),this[m]|this[m+1]<<8|this[m+2]<<16|this[m+3]<<24},f.prototype.readInt32BE=function(m,A){return m>>>=0,A||Se(m,4,this.length),this[m]<<24|this[m+1]<<16|this[m+2]<<8|this[m+3]},f.prototype.readFloatLE=function(m,A){return m>>>=0,A||Se(m,4,this.length),fe.read(this,m,!0,23,4)},f.prototype.readFloatBE=function(m,A){return m>>>=0,A||Se(m,4,this.length),fe.read(this,m,!1,23,4)},f.prototype.readDoubleLE=function(m,A){return m>>>=0,A||Se(m,8,this.length),fe.read(this,m,!0,52,8)},f.prototype.readDoubleBE=function(m,A){return m>>>=0,A||Se(m,8,this.length),fe.read(this,m,!1,52,8)},f.prototype.writeUIntLE=function(m,A,S,F){if(m=+m,A>>>=0,S>>>=0,!F){var V=s(2,8*S)-1;Ee(this,m,A,S,V,0)}var q=1,de=0;for(this[A]=255&m;++de<S&&(q*=256);)this[A+de]=255&m/q;return A+S},f.prototype.writeUIntBE=function(m,A,S,F){if(m=+m,A>>>=0,S>>>=0,!F){var V=s(2,8*S)-1;Ee(this,m,A,S,V,0)}var q=S-1,de=1;for(this[A+q]=255&m;0<=--q&&(de*=256);)this[A+q]=255&m/de;return A+S},f.prototype.writeUInt8=function(m,A,S){return m=+m,A>>>=0,S||Ee(this,m,A,1,255,0),this[A]=255&m,A+1},f.prototype.writeUInt16LE=function(m,A,S){return m=+m,A>>>=0,S||Ee(this,m,A,2,65535,0),this[A]=255&m,this[A+1]=m>>>8,A+2},f.prototype.writeUInt16BE=function(m,A,S){return m=+m,A>>>=0,S||Ee(this,m,A,2,65535,0),this[A]=m>>>8,this[A+1]=255&m,A+2},f.prototype.writeUInt32LE=function(m,A,S){return m=+m,A>>>=0,S||Ee(this,m,A,4,4294967295,0),this[A+3]=m>>>24,this[A+2]=m>>>16,this[A+1]=m>>>8,this[A]=255&m,A+4},f.prototype.writeUInt32BE=function(m,A,S){return m=+m,A>>>=0,S||Ee(this,m,A,4,4294967295,0),this[A]=m>>>24,this[A+1]=m>>>16,this[A+2]=m>>>8,this[A+3]=255&m,A+4},f.prototype.writeIntLE=function(m,A,S,F){if(m=+m,A>>>=0,!F){var V=s(2,8*S-1);Ee(this,m,A,S,V-1,-V)}var q=0,de=1,ke=0;for(this[A]=255&m;++q<S&&(de*=256);)0>m&&ke===0&&this[A+q-1]!==0&&(ke=1),this[A+q]=255&(m/de>>0)-ke;return A+S},f.prototype.writeIntBE=function(m,A,S,F){if(m=+m,A>>>=0,!F){var V=s(2,8*S-1);Ee(this,m,A,S,V-1,-V)}var q=S-1,de=1,ke=0;for(this[A+q]=255&m;0<=--q&&(de*=256);)0>m&&ke===0&&this[A+q+1]!==0&&(ke=1),this[A+q]=255&(m/de>>0)-ke;return A+S},f.prototype.writeInt8=function(m,A,S){return m=+m,A>>>=0,S||Ee(this,m,A,1,127,-128),0>m&&(m=255+m+1),this[A]=255&m,A+1},f.prototype.writeInt16LE=function(m,A,S){return m=+m,A>>>=0,S||Ee(this,m,A,2,32767,-32768),this[A]=255&m,this[A+1]=m>>>8,A+2},f.prototype.writeInt16BE=function(m,A,S){return m=+m,A>>>=0,S||Ee(this,m,A,2,32767,-32768),this[A]=m>>>8,this[A+1]=255&m,A+2},f.prototype.writeInt32LE=function(m,A,S){return m=+m,A>>>=0,S||Ee(this,m,A,4,2147483647,-2147483648),this[A]=255&m,this[A+1]=m>>>8,this[A+2]=m>>>16,this[A+3]=m>>>24,A+4},f.prototype.writeInt32BE=function(m,A,S){return m=+m,A>>>=0,S||Ee(this,m,A,4,2147483647,-2147483648),0>m&&(m=4294967295+m+1),this[A]=m>>>24,this[A+1]=m>>>16,this[A+2]=m>>>8,this[A+3]=255&m,A+4},f.prototype.writeFloatLE=function(m,A,S){return Ve(this,m,A,!0,S)},f.prototype.writeFloatBE=function(m,A,S){return Ve(this,m,A,!1,S)},f.prototype.writeDoubleLE=function(m,A,S){return Xe(this,m,A,!0,S)},f.prototype.writeDoubleBE=function(m,A,S){return Xe(this,m,A,!1,S)},f.prototype.copy=function(m,A,S,F){if(!f.isBuffer(m))throw new TypeError("argument should be a Buffer");if(S||(S=0),F||F===0||(F=this.length),A>=m.length&&(A=m.length),A||(A=0),0<F&&F<S&&(F=S),F===S||m.length===0||this.length===0)return 0;if(0>A)throw new RangeError("targetStart out of bounds");if(0>S||S>=this.length)throw new RangeError("Index out of range");if(0>F)throw new RangeError("sourceEnd out of bounds");F>this.length&&(F=this.length),m.length-A<F-S&&(F=m.length-A+S);var V=F-S;if(this===m&&typeof Uint8Array.prototype.copyWithin=="function")this.copyWithin(A,S,F);else if(this===m&&S<A&&A<F)for(var q=V-1;0<=q;--q)m[q+A]=this[q+S];else Uint8Array.prototype.set.call(m,this.subarray(S,F),A);return V},f.prototype.fill=function(m,A,S,F){if(typeof m=="string"){if(typeof A=="string"?(F=A,A=0,S=this.length):typeof S=="string"&&(F=S,S=this.length),F!==void 0&&typeof F!="string")throw new TypeError("encoding must be a string");if(typeof F=="string"&&!f.isEncoding(F))throw new TypeError("Unknown encoding: "+F);if(m.length===1){var V=m.charCodeAt(0);(F==="utf8"&&128>V||F==="latin1")&&(m=V)}}else typeof m=="number"&&(m&=255);if(0>A||this.length<A||this.length<S)throw new RangeError("Out of range index");if(S<=A)return this;A>>>=0,S=S===void 0?this.length:S>>>0,m||(m=0);var q;if(typeof m=="number")for(q=A;q<S;++q)this[q]=m;else{var de=f.isBuffer(m)?m:f.from(m,F),ke=de.length;if(ke===0)throw new TypeError('The value "'+m+'" is invalid for argument "value"');for(q=0;q<S-A;++q)this[q+A]=de[q%ke]}return this};var P=/[^+/0-9A-Za-z-_]/g}).call(this)}).call(this,i("buffer").Buffer)},{"base64-js":1,buffer:3,ieee754:9}],4:[function(i,o,a){(function(l){(function(){function c(){let f;try{f=a.storage.getItem("debug")}catch{}return!f&&typeof l<"u"&&"env"in l&&(f=l.env.DEBUG),f}a.formatArgs=function(f){if(f[0]=(this.useColors?"%c":"")+this.namespace+(this.useColors?" %c":" ")+f[0]+(this.useColors?"%c ":" ")+"+"+o.exports.humanize(this.diff),!this.useColors)return;const d="color: "+this.color;f.splice(1,0,d,"color: inherit");let h=0,p=0;f[0].replace(/%[a-zA-Z%]/g,g=>{g==="%%"||(h++,g==="%c"&&(p=h))}),f.splice(p,0,d)},a.save=function(f){try{f?a.storage.setItem("debug",f):a.storage.removeItem("debug")}catch{}},a.load=c,a.useColors=function(){return!!(typeof window<"u"&&window.process&&(window.process.type==="renderer"||window.process.__nwjs))||!(typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/(edge|trident)\/(\d+)/))&&(typeof document<"u"&&document.documentElement&&document.documentElement.style&&document.documentElement.style.WebkitAppearance||typeof window<"u"&&window.console&&(window.console.firebug||window.console.exception&&window.console.table)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/)&&31<=parseInt(RegExp.$1,10)||typeof navigator<"u"&&navigator.userAgent&&navigator.userAgent.toLowerCase().match(/applewebkit\/(\d+)/))},a.storage=function(){try{return localStorage}catch{}}(),a.destroy=(()=>{let f=!1;return()=>{f||(f=!0,console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`."))}})(),a.colors=["#0000CC","#0000FF","#0033CC","#0033FF","#0066CC","#0066FF","#0099CC","#0099FF","#00CC00","#00CC33","#00CC66","#00CC99","#00CCCC","#00CCFF","#3300CC","#3300FF","#3333CC","#3333FF","#3366CC","#3366FF","#3399CC","#3399FF","#33CC00","#33CC33","#33CC66","#33CC99","#33CCCC","#33CCFF","#6600CC","#6600FF","#6633CC","#6633FF","#66CC00","#66CC33","#9900CC","#9900FF","#9933CC","#9933FF","#99CC00","#99CC33","#CC0000","#CC0033","#CC0066","#CC0099","#CC00CC","#CC00FF","#CC3300","#CC3333","#CC3366","#CC3399","#CC33CC","#CC33FF","#CC6600","#CC6633","#CC9900","#CC9933","#CCCC00","#CCCC33","#FF0000","#FF0033","#FF0066","#FF0099","#FF00CC","#FF00FF","#FF3300","#FF3333","#FF3366","#FF3399","#FF33CC","#FF33FF","#FF6600","#FF6633","#FF9900","#FF9933","#FFCC00","#FFCC33"],a.log=console.debug||console.log||(()=>{}),o.exports=i("./common")(a);const{formatters:u}=o.exports;u.j=function(f){try{return JSON.stringify(f)}catch(d){return"[UnexpectedJSONParseError]: "+d.message}}}).call(this)}).call(this,i("_process"))},{"./common":5,_process:12}],5:[function(i,o){o.exports=function(a){function l(f){function d(...g){if(!d.enabled)return;const y=d,b=+new Date,x=b-(h||b);y.diff=x,y.prev=h,y.curr=b,h=b,g[0]=l.coerce(g[0]),typeof g[0]!="string"&&g.unshift("%O");let v=0;g[0]=g[0].replace(/%([a-zA-Z%])/g,(E,C)=>{if(E==="%%")return"%";v++;const T=l.formatters[C];if(typeof T=="function"){const N=g[v];E=T.call(y,N),g.splice(v,1),v--}return E}),l.formatArgs.call(y,g),(y.log||l.log).apply(y,g)}let h,p=null;return d.namespace=f,d.useColors=l.useColors(),d.color=l.selectColor(f),d.extend=c,d.destroy=l.destroy,Object.defineProperty(d,"enabled",{enumerable:!0,configurable:!1,get:()=>p===null?l.enabled(f):p,set:g=>{p=g}}),typeof l.init=="function"&&l.init(d),d}function c(f,d){const h=l(this.namespace+(typeof d>"u"?":":d)+f);return h.log=this.log,h}function u(f){return f.toString().substring(2,f.toString().length-2).replace(/\.\*\?$/,"*")}return l.debug=l,l.default=l,l.coerce=function(f){return f instanceof Error?f.stack||f.message:f},l.disable=function(){const f=[...l.names.map(u),...l.skips.map(u).map(d=>"-"+d)].join(",");return l.enable(""),f},l.enable=function(f){l.save(f),l.names=[],l.skips=[];let d;const h=(typeof f=="string"?f:"").split(/[\s,]+/),p=h.length;for(d=0;d<p;d++)h[d]&&(f=h[d].replace(/\*/g,".*?"),f[0]==="-"?l.skips.push(new RegExp("^"+f.substr(1)+"$")):l.names.push(new RegExp("^"+f+"$")))},l.enabled=function(f){if(f[f.length-1]==="*")return!0;let d,h;for(d=0,h=l.skips.length;d<h;d++)if(l.skips[d].test(f))return!1;for(d=0,h=l.names.length;d<h;d++)if(l.names[d].test(f))return!0;return!1},l.humanize=i("ms"),l.destroy=function(){console.warn("Instance method `debug.destroy()` is deprecated and no longer does anything. It will be removed in the next major version of `debug`.")},Object.keys(a).forEach(f=>{l[f]=a[f]}),l.names=[],l.skips=[],l.formatters={},l.selectColor=function(f){let d=0;for(let h=0;h<f.length;h++)d=(d<<5)-d+f.charCodeAt(h),d|=0;return l.colors[r(d)%l.colors.length]},l.enable(l.load()),l}},{ms:11}],6:[function(i,o){function a(l,c){for(const u in c)Object.defineProperty(l,u,{value:c[u],enumerable:!0,configurable:!0});return l}o.exports=function(l,c,u){if(!l||typeof l=="string")throw new TypeError("Please pass an Error to err-code");u||(u={}),typeof c=="object"&&(u=c,c=""),c&&(u.code=c);try{return a(l,u)}catch{u.message=l.message,u.stack=l.stack;const d=function(){};return d.prototype=Object.create(Object.getPrototypeOf(l)),a(new d,u)}}},{}],7:[function(i,o){function a(O){console&&console.warn&&console.warn(O)}function l(){l.init.call(this)}function c(O){if(typeof O!="function")throw new TypeError('The "listener" argument must be of type Function. Received type '+typeof O)}function u(O){return O._maxListeners===void 0?l.defaultMaxListeners:O._maxListeners}function f(O,I,L,$){var J,U,G;if(c(L),U=O._events,U===void 0?(U=O._events=Object.create(null),O._eventsCount=0):(U.newListener!==void 0&&(O.emit("newListener",I,L.listener?L.listener:L),U=O._events),G=U[I]),G===void 0)G=U[I]=L,++O._eventsCount;else if(typeof G=="function"?G=U[I]=$?[L,G]:[G,L]:$?G.unshift(L):G.push(L),J=u(O),0<J&&G.length>J&&!G.warned){G.warned=!0;var Y=new Error("Possible EventEmitter memory leak detected. "+G.length+" "+(I+" listeners added. Use emitter.setMaxListeners() to increase limit"));Y.name="MaxListenersExceededWarning",Y.emitter=O,Y.type=I,Y.count=G.length,a(Y)}return O}function d(){if(!this.fired)return this.target.removeListener(this.type,this.wrapFn),this.fired=!0,arguments.length===0?this.listener.call(this.target):this.listener.apply(this.target,arguments)}function h(O,I,L){var $={fired:!1,wrapFn:void 0,target:O,type:I,listener:L},J=d.bind($);return J.listener=L,$.wrapFn=J,J}function p(O,I,L){var $=O._events;if($===void 0)return[];var J=$[I];return J===void 0?[]:typeof J=="function"?L?[J.listener||J]:[J]:L?x(J):y(J,J.length)}function g(O){var I=this._events;if(I!==void 0){var L=I[O];if(typeof L=="function")return 1;if(L!==void 0)return L.length}return 0}function y(O,I){for(var L=Array(I),$=0;$<I;++$)L[$]=O[$];return L}function b(O,I){for(;I+1<O.length;I++)O[I]=O[I+1];O.pop()}function x(O){for(var I=Array(O.length),L=0;L<I.length;++L)I[L]=O[L].listener||O[L];return I}function v(O,I,L){typeof O.on=="function"&&w(O,"error",I,L)}function w(O,I,L,$){if(typeof O.on=="function")$.once?O.once(I,L):O.on(I,L);else if(typeof O.addEventListener=="function")O.addEventListener(I,function J(U){$.once&&O.removeEventListener(I,J),L(U)});else throw new TypeError('The "emitter" argument must be of type EventEmitter. Received type '+typeof O)}var E,C=typeof Reflect=="object"?Reflect:null,T=C&&typeof C.apply=="function"?C.apply:function(O,I,L){return Function.prototype.apply.call(O,I,L)};E=C&&typeof C.ownKeys=="function"?C.ownKeys:Object.getOwnPropertySymbols?function(O){return Object.getOwnPropertyNames(O).concat(Object.getOwnPropertySymbols(O))}:function(O){return Object.getOwnPropertyNames(O)};var N=Number.isNaN||function(O){return O!==O};o.exports=l,o.exports.once=function(O,I){return new Promise(function(L,$){function J(G){O.removeListener(I,U),$(G)}function U(){typeof O.removeListener=="function"&&O.removeListener("error",J),L([].slice.call(arguments))}w(O,I,U,{once:!0}),I!=="error"&&v(O,J,{once:!0})})},l.EventEmitter=l,l.prototype._events=void 0,l.prototype._eventsCount=0,l.prototype._maxListeners=void 0;var M=10;Object.defineProperty(l,"defaultMaxListeners",{enumerable:!0,get:function(){return M},set:function(O){if(typeof O!="number"||0>O||N(O))throw new RangeError('The value of "defaultMaxListeners" is out of range. It must be a non-negative number. Received '+O+".");M=O}}),l.init=function(){(this._events===void 0||this._events===Object.getPrototypeOf(this)._events)&&(this._events=Object.create(null),this._eventsCount=0),this._maxListeners=this._maxListeners||void 0},l.prototype.setMaxListeners=function(O){if(typeof O!="number"||0>O||N(O))throw new RangeError('The value of "n" is out of range. It must be a non-negative number. Received '+O+".");return this._maxListeners=O,this},l.prototype.getMaxListeners=function(){return u(this)},l.prototype.emit=function(O){for(var I=[],L=1;L<arguments.length;L++)I.push(arguments[L]);var $=O==="error",J=this._events;if(J!==void 0)$=$&&J.error===void 0;else if(!$)return!1;if($){var U;if(0<I.length&&(U=I[0]),U instanceof Error)throw U;var G=new Error("Unhandled error."+(U?" ("+U.message+")":""));throw G.context=U,G}var Y=J[O];if(Y===void 0)return!1;if(typeof Y=="function")T(Y,this,I);else for(var re=Y.length,Z=y(Y,re),L=0;L<re;++L)T(Z[L],this,I);return!0},l.prototype.addListener=function(O,I){return f(this,O,I,!1)},l.prototype.on=l.prototype.addListener,l.prototype.prependListener=function(O,I){return f(this,O,I,!0)},l.prototype.once=function(O,I){return c(I),this.on(O,h(this,O,I)),this},l.prototype.prependOnceListener=function(O,I){return c(I),this.prependListener(O,h(this,O,I)),this},l.prototype.removeListener=function(O,I){var L,$,J,U,G;if(c(I),$=this._events,$===void 0)return this;if(L=$[O],L===void 0)return this;if(L===I||L.listener===I)--this._eventsCount==0?this._events=Object.create(null):(delete $[O],$.removeListener&&this.emit("removeListener",O,L.listener||I));else if(typeof L!="function"){for(J=-1,U=L.length-1;0<=U;U--)if(L[U]===I||L[U].listener===I){G=L[U].listener,J=U;break}if(0>J)return this;J===0?L.shift():b(L,J),L.length===1&&($[O]=L[0]),$.removeListener!==void 0&&this.emit("removeListener",O,G||I)}return this},l.prototype.off=l.prototype.removeListener,l.prototype.removeAllListeners=function(O){var I,L,$;if(L=this._events,L===void 0)return this;if(L.removeListener===void 0)return arguments.length===0?(this._events=Object.create(null),this._eventsCount=0):L[O]!==void 0&&(--this._eventsCount==0?this._events=Object.create(null):delete L[O]),this;if(arguments.length===0){var J,U=Object.keys(L);for($=0;$<U.length;++$)J=U[$],J!=="removeListener"&&this.removeAllListeners(J);return this.removeAllListeners("removeListener"),this._events=Object.create(null),this._eventsCount=0,this}if(I=L[O],typeof I=="function")this.removeListener(O,I);else if(I!==void 0)for($=I.length-1;0<=$;$--)this.removeListener(O,I[$]);return this},l.prototype.listeners=function(O){return p(this,O,!0)},l.prototype.rawListeners=function(O){return p(this,O,!1)},l.listenerCount=function(O,I){return typeof O.listenerCount=="function"?O.listenerCount(I):g.call(O,I)},l.prototype.listenerCount=g,l.prototype.eventNames=function(){return 0<this._eventsCount?E(this._events):[]}},{}],8:[function(i,o){o.exports=function(){if(typeof globalThis>"u")return null;var a={RTCPeerConnection:globalThis.RTCPeerConnection||globalThis.mozRTCPeerConnection||globalThis.webkitRTCPeerConnection,RTCSessionDescription:globalThis.RTCSessionDescription||globalThis.mozRTCSessionDescription||globalThis.webkitRTCSessionDescription,RTCIceCandidate:globalThis.RTCIceCandidate||globalThis.mozRTCIceCandidate||globalThis.webkitRTCIceCandidate};return a.RTCPeerConnection?a:null}},{}],9:[function(i,o,a){/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */a.read=function(l,c,u,f,d){var h,p,g=8*d-f-1,y=(1<<g)-1,b=y>>1,x=-7,v=u?d-1:0,w=u?-1:1,E=l[c+v];for(v+=w,h=E&(1<<-x)-1,E>>=-x,x+=g;0<x;h=256*h+l[c+v],v+=w,x-=8);for(p=h&(1<<-x)-1,h>>=-x,x+=f;0<x;p=256*p+l[c+v],v+=w,x-=8);if(h===0)h=1-b;else{if(h===y)return p?NaN:(E?-1:1)*(1/0);p+=s(2,f),h-=b}return(E?-1:1)*p*s(2,h-f)},a.write=function(l,c,u,f,d,h){var p,g,y,b=Math.LN2,x=Math.log,v=8*h-d-1,w=(1<<v)-1,E=w>>1,C=d===23?s(2,-24)-s(2,-77):0,T=f?0:h-1,N=f?1:-1,M=0>c||c===0&&0>1/c?1:0;for(c=r(c),isNaN(c)||c===1/0?(g=isNaN(c)?1:0,p=w):(p=t(x(c)/b),1>c*(y=s(2,-p))&&(p--,y*=2),c+=1<=p+E?C/y:C*s(2,1-E),2<=c*y&&(p++,y/=2),p+E>=w?(g=0,p=w):1<=p+E?(g=(c*y-1)*s(2,d),p+=E):(g=c*s(2,E-1)*s(2,d),p=0));8<=d;l[u+T]=255&g,T+=N,g/=256,d-=8);for(p=p<<d|g,v+=d;0<v;l[u+T]=255&p,T+=N,p/=256,v-=8);l[u+T-N]|=128*M}},{}],10:[function(i,o){o.exports=typeof Object.create=="function"?function(a,l){l&&(a.super_=l,a.prototype=Object.create(l.prototype,{constructor:{value:a,enumerable:!1,writable:!0,configurable:!0}}))}:function(a,l){if(l){a.super_=l;var c=function(){};c.prototype=l.prototype,a.prototype=new c,a.prototype.constructor=a}}},{}],11:[function(i,o){var a=Math.round;function l(d){if(d+="",!(100<d.length)){var h=/^(-?(?:\d+)?\.?\d+) *(milliseconds?|msecs?|ms|seconds?|secs?|s|minutes?|mins?|m|hours?|hrs?|h|days?|d|weeks?|w|years?|yrs?|y)?$/i.exec(d);if(h){var p=parseFloat(h[1]),g=(h[2]||"ms").toLowerCase();return g==="years"||g==="year"||g==="yrs"||g==="yr"||g==="y"?315576e5*p:g==="weeks"||g==="week"||g==="w"?6048e5*p:g==="days"||g==="day"||g==="d"?864e5*p:g==="hours"||g==="hour"||g==="hrs"||g==="hr"||g==="h"?36e5*p:g==="minutes"||g==="minute"||g==="mins"||g==="min"||g==="m"?6e4*p:g==="seconds"||g==="second"||g==="secs"||g==="sec"||g==="s"?1e3*p:g==="milliseconds"||g==="millisecond"||g==="msecs"||g==="msec"||g==="ms"?p:void 0}}}function c(d){var h=r(d);return 864e5<=h?a(d/864e5)+"d":36e5<=h?a(d/36e5)+"h":6e4<=h?a(d/6e4)+"m":1e3<=h?a(d/1e3)+"s":d+"ms"}function u(d){var h=r(d);return 864e5<=h?f(d,h,864e5,"day"):36e5<=h?f(d,h,36e5,"hour"):6e4<=h?f(d,h,6e4,"minute"):1e3<=h?f(d,h,1e3,"second"):d+" ms"}function f(d,h,p,g){return a(d/p)+" "+g+(h>=1.5*p?"s":"")}o.exports=function(d,h){h=h||{};var p=typeof d;if(p=="string"&&0<d.length)return l(d);if(p==="number"&&isFinite(d))return h.long?u(d):c(d);throw new Error("val is not a non-empty string or a valid number. val="+JSON.stringify(d))}},{}],12:[function(i,o){function a(){throw new Error("setTimeout has not been defined")}function l(){throw new Error("clearTimeout has not been defined")}function c(C){if(g===setTimeout)return setTimeout(C,0);if((g===a||!g)&&setTimeout)return g=setTimeout,setTimeout(C,0);try{return g(C,0)}catch{try{return g.call(null,C,0)}catch{return g.call(this,C,0)}}}function u(C){if(y===clearTimeout)return clearTimeout(C);if((y===l||!y)&&clearTimeout)return y=clearTimeout,clearTimeout(C);try{return y(C)}catch{try{return y.call(null,C)}catch{return y.call(this,C)}}}function f(){w&&x&&(w=!1,x.length?v=x.concat(v):E=-1,v.length&&d())}function d(){if(!w){var C=c(f);w=!0;for(var T=v.length;T;){for(x=v,v=[];++E<T;)x&&x[E].run();E=-1,T=v.length}x=null,w=!1,u(C)}}function h(C,T){this.fun=C,this.array=T}function p(){}var g,y,b=o.exports={};(function(){try{g=typeof setTimeout=="function"?setTimeout:a}catch{g=a}try{y=typeof clearTimeout=="function"?clearTimeout:l}catch{y=l}})();var x,v=[],w=!1,E=-1;b.nextTick=function(C){var T=Array(arguments.length-1);if(1<arguments.length)for(var N=1;N<arguments.length;N++)T[N-1]=arguments[N];v.push(new h(C,T)),v.length!==1||w||c(d)},h.prototype.run=function(){this.fun.apply(null,this.array)},b.title="browser",b.browser=!0,b.env={},b.argv=[],b.version="",b.versions={},b.on=p,b.addListener=p,b.once=p,b.off=p,b.removeListener=p,b.removeAllListeners=p,b.emit=p,b.prependListener=p,b.prependOnceListener=p,b.listeners=function(){return[]},b.binding=function(){throw new Error("process.binding is not supported")},b.cwd=function(){return"/"},b.chdir=function(){throw new Error("process.chdir is not supported")},b.umask=function(){return 0}},{}],13:[function(i,o){(function(a){(function(){/*! queue-microtask. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */let l;o.exports=typeof queueMicrotask=="function"?queueMicrotask.bind(typeof window>"u"?a:window):c=>(l||(l=Promise.resolve())).then(c).catch(u=>setTimeout(()=>{throw u},0))}).call(this)}).call(this,typeof ns>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:ns)},{}],14:[function(i,o){(function(a,l){(function(){var c=i("safe-buffer").Buffer,u=l.crypto||l.msCrypto;o.exports=u&&u.getRandomValues?function(f,d){if(f>4294967295)throw new RangeError("requested too many random bytes");var h=c.allocUnsafe(f);if(0<f)if(65536<f)for(var p=0;p<f;p+=65536)u.getRandomValues(h.slice(p,p+65536));else u.getRandomValues(h);return typeof d=="function"?a.nextTick(function(){d(null,h)}):h}:function(){throw new Error(`Secure random number generation is not supported by this browser.
|
375
375
|
Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,i("_process"),typeof ns>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:ns)},{_process:12,"safe-buffer":30}],15:[function(i,o){function a(p,g){p.prototype=Object.create(g.prototype),p.prototype.constructor=p,p.__proto__=g}function l(p,g,y){function b(v,w,E){return typeof g=="string"?g:g(v,w,E)}y||(y=Error);var x=function(v){function w(E,C,T){return v.call(this,b(E,C,T))||this}return a(w,v),w}(y);x.prototype.name=y.name,x.prototype.code=p,h[p]=x}function c(p,g){if(Array.isArray(p)){var y=p.length;return p=p.map(function(b){return b+""}),2<y?"one of ".concat(g," ").concat(p.slice(0,y-1).join(", "),", or ")+p[y-1]:y===2?"one of ".concat(g," ").concat(p[0]," or ").concat(p[1]):"of ".concat(g," ").concat(p[0])}return"of ".concat(g," ").concat(p+"")}function u(p,g,y){return p.substr(0,g.length)===g}function f(p,g,y){return(y===void 0||y>p.length)&&(y=p.length),p.substring(y-g.length,y)===g}function d(p,g,y){return typeof y!="number"&&(y=0),!(y+g.length>p.length)&&p.indexOf(g,y)!==-1}var h={};l("ERR_INVALID_OPT_VALUE",function(p,g){return'The value "'+g+'" is invalid for option "'+p+'"'},TypeError),l("ERR_INVALID_ARG_TYPE",function(p,g,y){var b;typeof g=="string"&&u(g,"not ")?(b="must not be",g=g.replace(/^not /,"")):b="must be";var x;if(f(p," argument"))x="The ".concat(p," ").concat(b," ").concat(c(g,"type"));else{var v=d(p,".")?"property":"argument";x='The "'.concat(p,'" ').concat(v," ").concat(b," ").concat(c(g,"type"))}return x+=". Received type ".concat(typeof y),x},TypeError),l("ERR_STREAM_PUSH_AFTER_EOF","stream.push() after EOF"),l("ERR_METHOD_NOT_IMPLEMENTED",function(p){return"The "+p+" method is not implemented"}),l("ERR_STREAM_PREMATURE_CLOSE","Premature close"),l("ERR_STREAM_DESTROYED",function(p){return"Cannot call "+p+" after a stream was destroyed"}),l("ERR_MULTIPLE_CALLBACK","Callback called multiple times"),l("ERR_STREAM_CANNOT_PIPE","Cannot pipe, not readable"),l("ERR_STREAM_WRITE_AFTER_END","write after end"),l("ERR_STREAM_NULL_VALUES","May not write null values to stream",TypeError),l("ERR_UNKNOWN_ENCODING",function(p){return"Unknown encoding: "+p},TypeError),l("ERR_STREAM_UNSHIFT_AFTER_END_EVENT","stream.unshift() after end event"),o.exports.codes=h},{}],16:[function(i,o){(function(a){(function(){function l(b){return this instanceof l?(d.call(this,b),h.call(this,b),this.allowHalfOpen=!0,void(b&&(b.readable===!1&&(this.readable=!1),b.writable===!1&&(this.writable=!1),b.allowHalfOpen===!1&&(this.allowHalfOpen=!1,this.once("end",c))))):new l(b)}function c(){this._writableState.ended||a.nextTick(u,this)}function u(b){b.end()}var f=Object.keys||function(b){var x=[];for(var v in b)x.push(v);return x};o.exports=l;var d=i("./_stream_readable"),h=i("./_stream_writable");i("inherits")(l,d);for(var p,g=f(h.prototype),y=0;y<g.length;y++)p=g[y],l.prototype[p]||(l.prototype[p]=h.prototype[p]);Object.defineProperty(l.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),Object.defineProperty(l.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(l.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(l.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._writableState!==void 0&&this._readableState.destroyed&&this._writableState.destroyed},set:function(b){this._readableState===void 0||this._writableState===void 0||(this._readableState.destroyed=b,this._writableState.destroyed=b)}})}).call(this)}).call(this,i("_process"))},{"./_stream_readable":18,"./_stream_writable":20,_process:12,inherits:10}],17:[function(i,o){function a(c){return this instanceof a?void l.call(this,c):new a(c)}o.exports=a;var l=i("./_stream_transform");i("inherits")(a,l),a.prototype._transform=function(c,u,f){f(null,c)}},{"./_stream_transform":19,inherits:10}],18:[function(i,o){(function(a,l){(function(){function c(P){return De.from(P)}function u(P){return De.isBuffer(P)||P instanceof Se}function f(P,m,A){return typeof P.prependListener=="function"?P.prependListener(m,A):void(P._events&&P._events[m]?Array.isArray(P._events[m])?P._events[m].unshift(A):P._events[m]=[A,P._events[m]]:P.on(m,A))}function d(P,m,A){re=re||i("./_stream_duplex"),P=P||{},typeof A!="boolean"&&(A=m instanceof re),this.objectMode=!!P.objectMode,A&&(this.objectMode=this.objectMode||!!P.readableObjectMode),this.highWaterMark=zt(this,P,"readableHighWaterMark",A),this.buffer=new mt,this.length=0,this.pipes=null,this.pipesCount=0,this.flowing=null,this.ended=!1,this.endEmitted=!1,this.reading=!1,this.sync=!0,this.needReadable=!1,this.emittedReadable=!1,this.readableListening=!1,this.resumeScheduled=!1,this.paused=!0,this.emitClose=P.emitClose!==!1,this.autoDestroy=!!P.autoDestroy,this.destroyed=!1,this.defaultEncoding=P.defaultEncoding||"utf8",this.awaitDrain=0,this.readingMore=!1,this.decoder=null,this.encoding=null,P.encoding&&(!He&&(He=i("string_decoder/").StringDecoder),this.decoder=new He(P.encoding),this.encoding=P.encoding)}function h(P){if(re=re||i("./_stream_duplex"),!(this instanceof h))return new h(P);var m=this instanceof re;this._readableState=new d(P,this,m),this.readable=!0,P&&(typeof P.read=="function"&&(this._read=P.read),typeof P.destroy=="function"&&(this._destroy=P.destroy)),Me.call(this)}function p(P,m,A,S,F){Z("readableAddChunk",m);var V=P._readableState;if(m===null)V.reading=!1,v(P,V);else{var q;if(F||(q=y(V,m)),q)ee(P,q);else if(!(V.objectMode||m&&0<m.length))S||(V.reading=!1,C(P,V));else if(typeof m=="string"||V.objectMode||Object.getPrototypeOf(m)===De.prototype||(m=c(m)),S)V.endEmitted?ee(P,new K):g(P,V,m,!0);else if(V.ended)ee(P,new lt);else{if(V.destroyed)return!1;V.reading=!1,V.decoder&&!A?(m=V.decoder.write(m),V.objectMode||m.length!==0?g(P,V,m,!1):C(P,V)):g(P,V,m,!1)}}return!V.ended&&(V.length<V.highWaterMark||V.length===0)}function g(P,m,A,S){m.flowing&&m.length===0&&!m.sync?(m.awaitDrain=0,P.emit("data",A)):(m.length+=m.objectMode?1:A.length,S?m.buffer.unshift(A):m.buffer.push(A),m.needReadable&&w(P)),C(P,m)}function y(P,m){var A;return u(m)||typeof m=="string"||m===void 0||P.objectMode||(A=new Qe("chunk",["string","Buffer","Uint8Array"],m)),A}function b(P){return 1073741824<=P?P=1073741824:(P--,P|=P>>>1,P|=P>>>2,P|=P>>>4,P|=P>>>8,P|=P>>>16,P++),P}function x(P,m){return 0>=P||m.length===0&&m.ended?0:m.objectMode?1:P===P?(P>m.highWaterMark&&(m.highWaterMark=b(P)),P<=m.length?P:m.ended?m.length:(m.needReadable=!0,0)):m.flowing&&m.length?m.buffer.head.data.length:m.length}function v(P,m){if(Z("onEofChunk"),!m.ended){if(m.decoder){var A=m.decoder.end();A&&A.length&&(m.buffer.push(A),m.length+=m.objectMode?1:A.length)}m.ended=!0,m.sync?w(P):(m.needReadable=!1,!m.emittedReadable&&(m.emittedReadable=!0,E(P)))}}function w(P){var m=P._readableState;Z("emitReadable",m.needReadable,m.emittedReadable),m.needReadable=!1,m.emittedReadable||(Z("emitReadable",m.flowing),m.emittedReadable=!0,a.nextTick(E,P))}function E(P){var m=P._readableState;Z("emitReadable_",m.destroyed,m.length,m.ended),!m.destroyed&&(m.length||m.ended)&&(P.emit("readable"),m.emittedReadable=!1),m.needReadable=!m.flowing&&!m.ended&&m.length<=m.highWaterMark,$(P)}function C(P,m){m.readingMore||(m.readingMore=!0,a.nextTick(T,P,m))}function T(P,m){for(;!m.reading&&!m.ended&&(m.length<m.highWaterMark||m.flowing&&m.length===0);){var A=m.length;if(Z("maybeReadMore read 0"),P.read(0),A===m.length)break}m.readingMore=!1}function N(P){return function(){var m=P._readableState;Z("pipeOnDrain",m.awaitDrain),m.awaitDrain&&m.awaitDrain--,m.awaitDrain===0&&me(P,"data")&&(m.flowing=!0,$(P))}}function M(P){var m=P._readableState;m.readableListening=0<P.listenerCount("readable"),m.resumeScheduled&&!m.paused?m.flowing=!0:0<P.listenerCount("data")&&P.resume()}function O(P){Z("readable nexttick read 0"),P.read(0)}function I(P,m){m.resumeScheduled||(m.resumeScheduled=!0,a.nextTick(L,P,m))}function L(P,m){Z("resume",m.reading),m.reading||P.read(0),m.resumeScheduled=!1,P.emit("resume"),$(P),m.flowing&&!m.reading&&P.read(0)}function $(P){var m=P._readableState;for(Z("flow",m.flowing);m.flowing&&P.read()!==null;);}function J(P,m){if(m.length===0)return null;var A;return m.objectMode?A=m.buffer.shift():!P||P>=m.length?(A=m.decoder?m.buffer.join(""):m.buffer.length===1?m.buffer.first():m.buffer.concat(m.length),m.buffer.clear()):A=m.buffer.consume(P,m.decoder),A}function U(P){var m=P._readableState;Z("endReadable",m.endEmitted),m.endEmitted||(m.ended=!0,a.nextTick(G,m,P))}function G(P,m){if(Z("endReadableNT",P.endEmitted,P.length),!P.endEmitted&&P.length===0&&(P.endEmitted=!0,m.readable=!1,m.emit("end"),P.autoDestroy)){var A=m._writableState;(!A||A.autoDestroy&&A.finished)&&m.destroy()}}function Y(P,m){for(var A=0,S=P.length;A<S;A++)if(P[A]===m)return A;return-1}o.exports=h;var re;h.ReadableState=d;var Z;i("events").EventEmitter;var me=function(P,m){return P.listeners(m).length},Me=i("./internal/streams/stream"),De=i("buffer").Buffer,Se=l.Uint8Array||function(){},Ee=i("util");Z=Ee&&Ee.debuglog?Ee.debuglog("stream"):function(){};var He,Ve,Xe,mt=i("./internal/streams/buffer_list"),Ze=i("./internal/streams/destroy"),nt=i("./internal/streams/state"),zt=nt.getHighWaterMark,yt=i("../errors").codes,Qe=yt.ERR_INVALID_ARG_TYPE,lt=yt.ERR_STREAM_PUSH_AFTER_EOF,z=yt.ERR_METHOD_NOT_IMPLEMENTED,K=yt.ERR_STREAM_UNSHIFT_AFTER_END_EVENT;i("inherits")(h,Me);var ee=Ze.errorOrDestroy,fe=["error","close","destroy","pause","resume"];Object.defineProperty(h.prototype,"destroyed",{enumerable:!1,get:function(){return this._readableState!==void 0&&this._readableState.destroyed},set:function(P){this._readableState&&(this._readableState.destroyed=P)}}),h.prototype.destroy=Ze.destroy,h.prototype._undestroy=Ze.undestroy,h.prototype._destroy=function(P,m){m(P)},h.prototype.push=function(P,m){var A,S=this._readableState;return S.objectMode?A=!0:typeof P=="string"&&(m=m||S.defaultEncoding,m!==S.encoding&&(P=De.from(P,m),m=""),A=!0),p(this,P,m,!1,A)},h.prototype.unshift=function(P){return p(this,P,null,!0,!1)},h.prototype.isPaused=function(){return this._readableState.flowing===!1},h.prototype.setEncoding=function(P){He||(He=i("string_decoder/").StringDecoder);var m=new He(P);this._readableState.decoder=m,this._readableState.encoding=this._readableState.decoder.encoding;for(var A=this._readableState.buffer.head,S="";A!==null;)S+=m.write(A.data),A=A.next;return this._readableState.buffer.clear(),S!==""&&this._readableState.buffer.push(S),this._readableState.length=S.length,this},h.prototype.read=function(P){Z("read",P),P=parseInt(P,10);var m=this._readableState,A=P;if(P!==0&&(m.emittedReadable=!1),P===0&&m.needReadable&&((m.highWaterMark===0?0<m.length:m.length>=m.highWaterMark)||m.ended))return Z("read: emitReadable",m.length,m.ended),m.length===0&&m.ended?U(this):w(this),null;if(P=x(P,m),P===0&&m.ended)return m.length===0&&U(this),null;var S=m.needReadable;Z("need readable",S),(m.length===0||m.length-P<m.highWaterMark)&&(S=!0,Z("length less than watermark",S)),m.ended||m.reading?(S=!1,Z("reading or ended",S)):S&&(Z("do read"),m.reading=!0,m.sync=!0,m.length===0&&(m.needReadable=!0),this._read(m.highWaterMark),m.sync=!1,!m.reading&&(P=x(A,m)));var F;return F=0<P?J(P,m):null,F===null?(m.needReadable=m.length<=m.highWaterMark,P=0):(m.length-=P,m.awaitDrain=0),m.length===0&&(!m.ended&&(m.needReadable=!0),A!==P&&m.ended&&U(this)),F!==null&&this.emit("data",F),F},h.prototype._read=function(){ee(this,new z("_read()"))},h.prototype.pipe=function(P,m){function A(le,we){Z("onunpipe"),le===Le&&we&&we.hasUnpiped===!1&&(we.hasUnpiped=!0,F())}function S(){Z("onend"),P.end()}function F(){Z("cleanup"),P.removeListener("close",de),P.removeListener("finish",ke),P.removeListener("drain",Fs),P.removeListener("error",q),P.removeListener("unpipe",A),Le.removeListener("end",S),Le.removeListener("end",et),Le.removeListener("data",V),Q=!0,Ie.awaitDrain&&(!P._writableState||P._writableState.needDrain)&&Fs()}function V(le){Z("ondata");var we=P.write(le);Z("dest.write",we),we===!1&&((Ie.pipesCount===1&&Ie.pipes===P||1<Ie.pipesCount&&Y(Ie.pipes,P)!==-1)&&!Q&&(Z("false write response, pause",Ie.awaitDrain),Ie.awaitDrain++),Le.pause())}function q(le){Z("onerror",le),et(),P.removeListener("error",q),me(P,"error")===0&&ee(P,le)}function de(){P.removeListener("finish",ke),et()}function ke(){Z("onfinish"),P.removeListener("close",de),et()}function et(){Z("unpipe"),Le.unpipe(P)}var Le=this,Ie=this._readableState;switch(Ie.pipesCount){case 0:Ie.pipes=P;break;case 1:Ie.pipes=[Ie.pipes,P];break;default:Ie.pipes.push(P)}Ie.pipesCount+=1,Z("pipe count=%d opts=%j",Ie.pipesCount,m);var Ct=(!m||m.end!==!1)&&P!==a.stdout&&P!==a.stderr,es=Ct?S:et;Ie.endEmitted?a.nextTick(es):Le.once("end",es),P.on("unpipe",A);var Fs=N(Le);P.on("drain",Fs);var Q=!1;return Le.on("data",V),f(P,"error",q),P.once("close",de),P.once("finish",ke),P.emit("pipe",Le),Ie.flowing||(Z("pipe resume"),Le.resume()),P},h.prototype.unpipe=function(P){var m=this._readableState,A={hasUnpiped:!1};if(m.pipesCount===0)return this;if(m.pipesCount===1)return P&&P!==m.pipes?this:(P||(P=m.pipes),m.pipes=null,m.pipesCount=0,m.flowing=!1,P&&P.emit("unpipe",this,A),this);if(!P){var S=m.pipes,F=m.pipesCount;m.pipes=null,m.pipesCount=0,m.flowing=!1;for(var V=0;V<F;V++)S[V].emit("unpipe",this,{hasUnpiped:!1});return this}var q=Y(m.pipes,P);return q===-1?this:(m.pipes.splice(q,1),m.pipesCount-=1,m.pipesCount===1&&(m.pipes=m.pipes[0]),P.emit("unpipe",this,A),this)},h.prototype.on=function(P,m){var A=Me.prototype.on.call(this,P,m),S=this._readableState;return P==="data"?(S.readableListening=0<this.listenerCount("readable"),S.flowing!==!1&&this.resume()):P=="readable"&&!S.endEmitted&&!S.readableListening&&(S.readableListening=S.needReadable=!0,S.flowing=!1,S.emittedReadable=!1,Z("on readable",S.length,S.reading),S.length?w(this):!S.reading&&a.nextTick(O,this)),A},h.prototype.addListener=h.prototype.on,h.prototype.removeListener=function(P,m){var A=Me.prototype.removeListener.call(this,P,m);return P==="readable"&&a.nextTick(M,this),A},h.prototype.removeAllListeners=function(P){var m=Me.prototype.removeAllListeners.apply(this,arguments);return(P==="readable"||P===void 0)&&a.nextTick(M,this),m},h.prototype.resume=function(){var P=this._readableState;return P.flowing||(Z("resume"),P.flowing=!P.readableListening,I(this,P)),P.paused=!1,this},h.prototype.pause=function(){return Z("call pause flowing=%j",this._readableState.flowing),this._readableState.flowing!==!1&&(Z("pause"),this._readableState.flowing=!1,this.emit("pause")),this._readableState.paused=!0,this},h.prototype.wrap=function(P){var m=this,A=this._readableState,S=!1;for(var F in P.on("end",function(){if(Z("wrapped end"),A.decoder&&!A.ended){var q=A.decoder.end();q&&q.length&&m.push(q)}m.push(null)}),P.on("data",function(q){if(Z("wrapped data"),A.decoder&&(q=A.decoder.write(q)),!(A.objectMode&&q==null)&&(A.objectMode||q&&q.length)){var de=m.push(q);de||(S=!0,P.pause())}}),P)this[F]===void 0&&typeof P[F]=="function"&&(this[F]=function(q){return function(){return P[q].apply(P,arguments)}}(F));for(var V=0;V<fe.length;V++)P.on(fe[V],this.emit.bind(this,fe[V]));return this._read=function(q){Z("wrapped _read",q),S&&(S=!1,P.resume())},this},typeof Symbol=="function"&&(h.prototype[Symbol.asyncIterator]=function(){return Ve===void 0&&(Ve=i("./internal/streams/async_iterator")),Ve(this)}),Object.defineProperty(h.prototype,"readableHighWaterMark",{enumerable:!1,get:function(){return this._readableState.highWaterMark}}),Object.defineProperty(h.prototype,"readableBuffer",{enumerable:!1,get:function(){return this._readableState&&this._readableState.buffer}}),Object.defineProperty(h.prototype,"readableFlowing",{enumerable:!1,get:function(){return this._readableState.flowing},set:function(P){this._readableState&&(this._readableState.flowing=P)}}),h._fromList=J,Object.defineProperty(h.prototype,"readableLength",{enumerable:!1,get:function(){return this._readableState.length}}),typeof Symbol=="function"&&(h.from=function(P,m){return Xe===void 0&&(Xe=i("./internal/streams/from")),Xe(h,P,m)})}).call(this)}).call(this,i("_process"),typeof ns>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:ns)},{"../errors":15,"./_stream_duplex":16,"./internal/streams/async_iterator":21,"./internal/streams/buffer_list":22,"./internal/streams/destroy":23,"./internal/streams/from":25,"./internal/streams/state":27,"./internal/streams/stream":28,_process:12,buffer:3,events:7,inherits:10,"string_decoder/":31,util:2}],19:[function(i,o){function a(b,x){var v=this._transformState;v.transforming=!1;var w=v.writecb;if(w===null)return this.emit("error",new h);v.writechunk=null,v.writecb=null,x!=null&&this.push(x),w(b);var E=this._readableState;E.reading=!1,(E.needReadable||E.length<E.highWaterMark)&&this._read(E.highWaterMark)}function l(b){return this instanceof l?(y.call(this,b),this._transformState={afterTransform:a.bind(this),needTransform:!1,transforming:!1,writecb:null,writechunk:null,writeencoding:null},this._readableState.needReadable=!0,this._readableState.sync=!1,b&&(typeof b.transform=="function"&&(this._transform=b.transform),typeof b.flush=="function"&&(this._flush=b.flush)),void this.on("prefinish",c)):new l(b)}function c(){var b=this;typeof this._flush!="function"||this._readableState.destroyed?u(this,null,null):this._flush(function(x,v){u(b,x,v)})}function u(b,x,v){if(x)return b.emit("error",x);if(v!=null&&b.push(v),b._writableState.length)throw new g;if(b._transformState.transforming)throw new p;return b.push(null)}o.exports=l;var f=i("../errors").codes,d=f.ERR_METHOD_NOT_IMPLEMENTED,h=f.ERR_MULTIPLE_CALLBACK,p=f.ERR_TRANSFORM_ALREADY_TRANSFORMING,g=f.ERR_TRANSFORM_WITH_LENGTH_0,y=i("./_stream_duplex");i("inherits")(l,y),l.prototype.push=function(b,x){return this._transformState.needTransform=!1,y.prototype.push.call(this,b,x)},l.prototype._transform=function(b,x,v){v(new d("_transform()"))},l.prototype._write=function(b,x,v){var w=this._transformState;if(w.writecb=v,w.writechunk=b,w.writeencoding=x,!w.transforming){var E=this._readableState;(w.needTransform||E.needReadable||E.length<E.highWaterMark)&&this._read(E.highWaterMark)}},l.prototype._read=function(){var b=this._transformState;b.writechunk===null||b.transforming?b.needTransform=!0:(b.transforming=!0,this._transform(b.writechunk,b.writeencoding,b.afterTransform))},l.prototype._destroy=function(b,x){y.prototype._destroy.call(this,b,function(v){x(v)})}},{"../errors":15,"./_stream_duplex":16,inherits:10}],20:[function(i,o){(function(a,l){(function(){function c(z){var K=this;this.next=null,this.entry=null,this.finish=function(){U(K,z)}}function u(z){return Z.from(z)}function f(z){return Z.isBuffer(z)||z instanceof me}function d(){}function h(z,K,ee){G=G||i("./_stream_duplex"),z=z||{},typeof ee!="boolean"&&(ee=K instanceof G),this.objectMode=!!z.objectMode,ee&&(this.objectMode=this.objectMode||!!z.writableObjectMode),this.highWaterMark=Se(this,z,"writableHighWaterMark",ee),this.finalCalled=!1,this.needDrain=!1,this.ending=!1,this.ended=!1,this.finished=!1,this.destroyed=!1;var fe=z.decodeStrings===!1;this.decodeStrings=!fe,this.defaultEncoding=z.defaultEncoding||"utf8",this.length=0,this.writing=!1,this.corked=0,this.sync=!0,this.bufferProcessing=!1,this.onwrite=function(P){C(K,P)},this.writecb=null,this.writelen=0,this.bufferedRequest=null,this.lastBufferedRequest=null,this.pendingcb=0,this.prefinished=!1,this.errorEmitted=!1,this.emitClose=z.emitClose!==!1,this.autoDestroy=!!z.autoDestroy,this.bufferedRequestCount=0,this.corkedRequestsFree=new c(this)}function p(z){G=G||i("./_stream_duplex");var K=this instanceof G;return K||lt.call(p,this)?(this._writableState=new h(z,this,K),this.writable=!0,z&&(typeof z.write=="function"&&(this._write=z.write),typeof z.writev=="function"&&(this._writev=z.writev),typeof z.destroy=="function"&&(this._destroy=z.destroy),typeof z.final=="function"&&(this._final=z.final)),void re.call(this)):new p(z)}function g(z,K){var ee=new zt;Qe(z,ee),a.nextTick(K,ee)}function y(z,K,ee,fe){var P;return ee===null?P=new nt:typeof ee!="string"&&!K.objectMode&&(P=new He("chunk",["string","Buffer"],ee)),!P||(Qe(z,P),a.nextTick(fe,P),!1)}function b(z,K,ee){return z.objectMode||z.decodeStrings===!1||typeof K!="string"||(K=Z.from(K,ee)),K}function x(z,K,ee,fe,P,m){if(!ee){var A=b(K,fe,P);fe!==A&&(ee=!0,P="buffer",fe=A)}var S=K.objectMode?1:fe.length;K.length+=S;var F=K.length<K.highWaterMark;if(F||(K.needDrain=!0),K.writing||K.corked){var V=K.lastBufferedRequest;K.lastBufferedRequest={chunk:fe,encoding:P,isBuf:ee,callback:m,next:null},V?V.next=K.lastBufferedRequest:K.bufferedRequest=K.lastBufferedRequest,K.bufferedRequestCount+=1}else v(z,K,!1,S,fe,P,m);return F}function v(z,K,ee,fe,P,m,A){K.writelen=fe,K.writecb=A,K.writing=!0,K.sync=!0,K.destroyed?K.onwrite(new Ze("write")):ee?z._writev(P,K.onwrite):z._write(P,m,K.onwrite),K.sync=!1}function w(z,K,ee,fe,P){--K.pendingcb,ee?(a.nextTick(P,fe),a.nextTick($,z,K),z._writableState.errorEmitted=!0,Qe(z,fe)):(P(fe),z._writableState.errorEmitted=!0,Qe(z,fe),$(z,K))}function E(z){z.writing=!1,z.writecb=null,z.length-=z.writelen,z.writelen=0}function C(z,K){var ee=z._writableState,fe=ee.sync,P=ee.writecb;if(typeof P!="function")throw new Xe;if(E(ee),K)w(z,ee,fe,K,P);else{var m=O(ee)||z.destroyed;m||ee.corked||ee.bufferProcessing||!ee.bufferedRequest||M(z,ee),fe?a.nextTick(T,z,ee,m,P):T(z,ee,m,P)}}function T(z,K,ee,fe){ee||N(z,K),K.pendingcb--,fe(),$(z,K)}function N(z,K){K.length===0&&K.needDrain&&(K.needDrain=!1,z.emit("drain"))}function M(z,K){K.bufferProcessing=!0;var ee=K.bufferedRequest;if(z._writev&&ee&&ee.next){var fe=K.bufferedRequestCount,P=Array(fe),m=K.corkedRequestsFree;m.entry=ee;for(var A=0,S=!0;ee;)P[A]=ee,ee.isBuf||(S=!1),ee=ee.next,A+=1;P.allBuffers=S,v(z,K,!0,K.length,P,"",m.finish),K.pendingcb++,K.lastBufferedRequest=null,m.next?(K.corkedRequestsFree=m.next,m.next=null):K.corkedRequestsFree=new c(K),K.bufferedRequestCount=0}else{for(;ee;){var F=ee.chunk,V=ee.encoding,q=ee.callback,de=K.objectMode?1:F.length;if(v(z,K,!1,de,F,V,q),ee=ee.next,K.bufferedRequestCount--,K.writing)break}ee===null&&(K.lastBufferedRequest=null)}K.bufferedRequest=ee,K.bufferProcessing=!1}function O(z){return z.ending&&z.length===0&&z.bufferedRequest===null&&!z.finished&&!z.writing}function I(z,K){z._final(function(ee){K.pendingcb--,ee&&Qe(z,ee),K.prefinished=!0,z.emit("prefinish"),$(z,K)})}function L(z,K){K.prefinished||K.finalCalled||(typeof z._final!="function"||K.destroyed?(K.prefinished=!0,z.emit("prefinish")):(K.pendingcb++,K.finalCalled=!0,a.nextTick(I,z,K)))}function $(z,K){var ee=O(K);if(ee&&(L(z,K),K.pendingcb===0&&(K.finished=!0,z.emit("finish"),K.autoDestroy))){var fe=z._readableState;(!fe||fe.autoDestroy&&fe.endEmitted)&&z.destroy()}return ee}function J(z,K,ee){K.ending=!0,$(z,K),ee&&(K.finished?a.nextTick(ee):z.once("finish",ee)),K.ended=!0,z.writable=!1}function U(z,K,ee){var fe=z.entry;for(z.entry=null;fe;){var P=fe.callback;K.pendingcb--,P(ee),fe=fe.next}K.corkedRequestsFree.next=z}o.exports=p;var G;p.WritableState=h;var Y={deprecate:i("util-deprecate")},re=i("./internal/streams/stream"),Z=i("buffer").Buffer,me=l.Uint8Array||function(){},Me=i("./internal/streams/destroy"),De=i("./internal/streams/state"),Se=De.getHighWaterMark,Ee=i("../errors").codes,He=Ee.ERR_INVALID_ARG_TYPE,Ve=Ee.ERR_METHOD_NOT_IMPLEMENTED,Xe=Ee.ERR_MULTIPLE_CALLBACK,mt=Ee.ERR_STREAM_CANNOT_PIPE,Ze=Ee.ERR_STREAM_DESTROYED,nt=Ee.ERR_STREAM_NULL_VALUES,zt=Ee.ERR_STREAM_WRITE_AFTER_END,yt=Ee.ERR_UNKNOWN_ENCODING,Qe=Me.errorOrDestroy;i("inherits")(p,re),h.prototype.getBuffer=function(){for(var z=this.bufferedRequest,K=[];z;)K.push(z),z=z.next;return K},function(){try{Object.defineProperty(h.prototype,"buffer",{get:Y.deprecate(function(){return this.getBuffer()},"_writableState.buffer is deprecated. Use _writableState.getBuffer instead.","DEP0003")})}catch{}}();var lt;typeof Symbol=="function"&&Symbol.hasInstance&&typeof Function.prototype[Symbol.hasInstance]=="function"?(lt=Function.prototype[Symbol.hasInstance],Object.defineProperty(p,Symbol.hasInstance,{value:function(z){return!!lt.call(this,z)||this===p&&z&&z._writableState instanceof h}})):lt=function(z){return z instanceof this},p.prototype.pipe=function(){Qe(this,new mt)},p.prototype.write=function(z,K,ee){var fe=this._writableState,P=!1,m=!fe.objectMode&&f(z);return m&&!Z.isBuffer(z)&&(z=u(z)),typeof K=="function"&&(ee=K,K=null),m?K="buffer":!K&&(K=fe.defaultEncoding),typeof ee!="function"&&(ee=d),fe.ending?g(this,ee):(m||y(this,fe,z,ee))&&(fe.pendingcb++,P=x(this,fe,m,z,K,ee)),P},p.prototype.cork=function(){this._writableState.corked++},p.prototype.uncork=function(){var z=this._writableState;z.corked&&(z.corked--,!z.writing&&!z.corked&&!z.bufferProcessing&&z.bufferedRequest&&M(this,z))},p.prototype.setDefaultEncoding=function(z){if(typeof z=="string"&&(z=z.toLowerCase()),!(-1<["hex","utf8","utf-8","ascii","binary","base64","ucs2","ucs-2","utf16le","utf-16le","raw"].indexOf((z+"").toLowerCase())))throw new yt(z);return this._writableState.defaultEncoding=z,this},Object.defineProperty(p.prototype,"writableBuffer",{enumerable:!1,get:function(){return this._writableState&&this._writableState.getBuffer()}}),Object.defineProperty(p.prototype,"writableHighWaterMark",{enumerable:!1,get:function(){return this._writableState.highWaterMark}}),p.prototype._write=function(z,K,ee){ee(new Ve("_write()"))},p.prototype._writev=null,p.prototype.end=function(z,K,ee){var fe=this._writableState;return typeof z=="function"?(ee=z,z=null,K=null):typeof K=="function"&&(ee=K,K=null),z!=null&&this.write(z,K),fe.corked&&(fe.corked=1,this.uncork()),fe.ending||J(this,fe,ee),this},Object.defineProperty(p.prototype,"writableLength",{enumerable:!1,get:function(){return this._writableState.length}}),Object.defineProperty(p.prototype,"destroyed",{enumerable:!1,get:function(){return this._writableState!==void 0&&this._writableState.destroyed},set:function(z){this._writableState&&(this._writableState.destroyed=z)}}),p.prototype.destroy=Me.destroy,p.prototype._undestroy=Me.undestroy,p.prototype._destroy=function(z,K){K(z)}}).call(this)}).call(this,i("_process"),typeof ns>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:ns)},{"../errors":15,"./_stream_duplex":16,"./internal/streams/destroy":23,"./internal/streams/state":27,"./internal/streams/stream":28,_process:12,buffer:3,inherits:10,"util-deprecate":32}],21:[function(i,o){(function(a){(function(){function l(N,M,O){return M in N?Object.defineProperty(N,M,{value:O,enumerable:!0,configurable:!0,writable:!0}):N[M]=O,N}function c(N,M){return{value:N,done:M}}function u(N){var M=N[g];if(M!==null){var O=N[E].read();O!==null&&(N[v]=null,N[g]=null,N[y]=null,M(c(O,!1)))}}function f(N){a.nextTick(u,N)}function d(N,M){return function(O,I){N.then(function(){return M[x]?void O(c(void 0,!0)):void M[w](O,I)},I)}}var h,p=i("./end-of-stream"),g=Symbol("lastResolve"),y=Symbol("lastReject"),b=Symbol("error"),x=Symbol("ended"),v=Symbol("lastPromise"),w=Symbol("handlePromise"),E=Symbol("stream"),C=Object.getPrototypeOf(function(){}),T=Object.setPrototypeOf((h={get stream(){return this[E]},next:function(){var N=this,M=this[b];if(M!==null)return Promise.reject(M);if(this[x])return Promise.resolve(c(void 0,!0));if(this[E].destroyed)return new Promise(function($,J){a.nextTick(function(){N[b]?J(N[b]):$(c(void 0,!0))})});var O,I=this[v];if(I)O=new Promise(d(I,this));else{var L=this[E].read();if(L!==null)return Promise.resolve(c(L,!1));O=new Promise(this[w])}return this[v]=O,O}},l(h,Symbol.asyncIterator,function(){return this}),l(h,"return",function(){var N=this;return new Promise(function(M,O){N[E].destroy(null,function(I){return I?void O(I):void M(c(void 0,!0))})})}),h),C);o.exports=function(N){var M,O=Object.create(T,(M={},l(M,E,{value:N,writable:!0}),l(M,g,{value:null,writable:!0}),l(M,y,{value:null,writable:!0}),l(M,b,{value:null,writable:!0}),l(M,x,{value:N._readableState.endEmitted,writable:!0}),l(M,w,{value:function(I,L){var $=O[E].read();$?(O[v]=null,O[g]=null,O[y]=null,I(c($,!1))):(O[g]=I,O[y]=L)},writable:!0}),M));return O[v]=null,p(N,function(I){if(I&&I.code!=="ERR_STREAM_PREMATURE_CLOSE"){var L=O[y];return L!==null&&(O[v]=null,O[g]=null,O[y]=null,L(I)),void(O[b]=I)}var $=O[g];$!==null&&(O[v]=null,O[g]=null,O[y]=null,$(c(void 0,!0))),O[x]=!0}),N.on("readable",f.bind(null,O)),O}}).call(this)}).call(this,i("_process"))},{"./end-of-stream":24,_process:12}],22:[function(i,o){function a(v,w){var E=Object.keys(v);if(Object.getOwnPropertySymbols){var C=Object.getOwnPropertySymbols(v);w&&(C=C.filter(function(T){return Object.getOwnPropertyDescriptor(v,T).enumerable})),E.push.apply(E,C)}return E}function l(v){for(var w,E=1;E<arguments.length;E++)w=arguments[E]==null?{}:arguments[E],E%2?a(Object(w),!0).forEach(function(C){c(v,C,w[C])}):Object.getOwnPropertyDescriptors?Object.defineProperties(v,Object.getOwnPropertyDescriptors(w)):a(Object(w)).forEach(function(C){Object.defineProperty(v,C,Object.getOwnPropertyDescriptor(w,C))});return v}function c(v,w,E){return w in v?Object.defineProperty(v,w,{value:E,enumerable:!0,configurable:!0,writable:!0}):v[w]=E,v}function u(v,w){if(!(v instanceof w))throw new TypeError("Cannot call a class as a function")}function f(v,w){for(var E,C=0;C<w.length;C++)E=w[C],E.enumerable=E.enumerable||!1,E.configurable=!0,"value"in E&&(E.writable=!0),Object.defineProperty(v,E.key,E)}function d(v,w,E){return w&&f(v.prototype,w),v}function h(v,w,E){g.prototype.copy.call(v,w,E)}var p=i("buffer"),g=p.Buffer,y=i("util"),b=y.inspect,x=b&&b.custom||"inspect";o.exports=function(){function v(){u(this,v),this.head=null,this.tail=null,this.length=0}return d(v,[{key:"push",value:function(w){var E={data:w,next:null};0<this.length?this.tail.next=E:this.head=E,this.tail=E,++this.length}},{key:"unshift",value:function(w){var E={data:w,next:this.head};this.length===0&&(this.tail=E),this.head=E,++this.length}},{key:"shift",value:function(){if(this.length!==0){var w=this.head.data;return this.head=this.length===1?this.tail=null:this.head.next,--this.length,w}}},{key:"clear",value:function(){this.head=this.tail=null,this.length=0}},{key:"join",value:function(w){if(this.length===0)return"";for(var E=this.head,C=""+E.data;E=E.next;)C+=w+E.data;return C}},{key:"concat",value:function(w){if(this.length===0)return g.alloc(0);for(var E=g.allocUnsafe(w>>>0),C=this.head,T=0;C;)h(C.data,E,T),T+=C.data.length,C=C.next;return E}},{key:"consume",value:function(w,E){var C;return w<this.head.data.length?(C=this.head.data.slice(0,w),this.head.data=this.head.data.slice(w)):w===this.head.data.length?C=this.shift():C=E?this._getString(w):this._getBuffer(w),C}},{key:"first",value:function(){return this.head.data}},{key:"_getString",value:function(w){var E=this.head,C=1,T=E.data;for(w-=T.length;E=E.next;){var N=E.data,M=w>N.length?N.length:w;if(T+=M===N.length?N:N.slice(0,w),w-=M,w===0){M===N.length?(++C,this.head=E.next?E.next:this.tail=null):(this.head=E,E.data=N.slice(M));break}++C}return this.length-=C,T}},{key:"_getBuffer",value:function(w){var E=g.allocUnsafe(w),C=this.head,T=1;for(C.data.copy(E),w-=C.data.length;C=C.next;){var N=C.data,M=w>N.length?N.length:w;if(N.copy(E,E.length-w,0,M),w-=M,w===0){M===N.length?(++T,this.head=C.next?C.next:this.tail=null):(this.head=C,C.data=N.slice(M));break}++T}return this.length-=T,E}},{key:x,value:function(w,E){return b(this,l({},E,{depth:0,customInspect:!1}))}}]),v}()},{buffer:3,util:2}],23:[function(i,o){(function(a){(function(){function l(f,d){u(f,d),c(f)}function c(f){f._writableState&&!f._writableState.emitClose||f._readableState&&!f._readableState.emitClose||f.emit("close")}function u(f,d){f.emit("error",d)}o.exports={destroy:function(f,d){var h=this,p=this._readableState&&this._readableState.destroyed,g=this._writableState&&this._writableState.destroyed;return p||g?(d?d(f):f&&(this._writableState?!this._writableState.errorEmitted&&(this._writableState.errorEmitted=!0,a.nextTick(u,this,f)):a.nextTick(u,this,f)),this):(this._readableState&&(this._readableState.destroyed=!0),this._writableState&&(this._writableState.destroyed=!0),this._destroy(f||null,function(y){!d&&y?h._writableState?h._writableState.errorEmitted?a.nextTick(c,h):(h._writableState.errorEmitted=!0,a.nextTick(l,h,y)):a.nextTick(l,h,y):d?(a.nextTick(c,h),d(y)):a.nextTick(c,h)}),this)},undestroy:function(){this._readableState&&(this._readableState.destroyed=!1,this._readableState.reading=!1,this._readableState.ended=!1,this._readableState.endEmitted=!1),this._writableState&&(this._writableState.destroyed=!1,this._writableState.ended=!1,this._writableState.ending=!1,this._writableState.finalCalled=!1,this._writableState.prefinished=!1,this._writableState.finished=!1,this._writableState.errorEmitted=!1)},errorOrDestroy:function(f,d){var h=f._readableState,p=f._writableState;h&&h.autoDestroy||p&&p.autoDestroy?f.destroy(d):f.emit("error",d)}}}).call(this)}).call(this,i("_process"))},{_process:12}],24:[function(i,o){function a(d){var h=!1;return function(){if(!h){h=!0;for(var p=arguments.length,g=Array(p),y=0;y<p;y++)g[y]=arguments[y];d.apply(this,g)}}}function l(){}function c(d){return d.setHeader&&typeof d.abort=="function"}function u(d,h,p){if(typeof h=="function")return u(d,null,h);h||(h={}),p=a(p||l);var g=h.readable||h.readable!==!1&&d.readable,y=h.writable||h.writable!==!1&&d.writable,b=function(){d.writable||v()},x=d._writableState&&d._writableState.finished,v=function(){y=!1,x=!0,g||p.call(d)},w=d._readableState&&d._readableState.endEmitted,E=function(){g=!1,w=!0,y||p.call(d)},C=function(M){p.call(d,M)},T=function(){var M;return g&&!w?(d._readableState&&d._readableState.ended||(M=new f),p.call(d,M)):y&&!x?(d._writableState&&d._writableState.ended||(M=new f),p.call(d,M)):void 0},N=function(){d.req.on("finish",v)};return c(d)?(d.on("complete",v),d.on("abort",T),d.req?N():d.on("request",N)):y&&!d._writableState&&(d.on("end",b),d.on("close",b)),d.on("end",E),d.on("finish",v),h.error!==!1&&d.on("error",C),d.on("close",T),function(){d.removeListener("complete",v),d.removeListener("abort",T),d.removeListener("request",N),d.req&&d.req.removeListener("finish",v),d.removeListener("end",b),d.removeListener("close",b),d.removeListener("finish",v),d.removeListener("end",E),d.removeListener("error",C),d.removeListener("close",T)}}var f=i("../../../errors").codes.ERR_STREAM_PREMATURE_CLOSE;o.exports=u},{"../../../errors":15}],25:[function(i,o){o.exports=function(){throw new Error("Readable.from is not available in the browser")}},{}],26:[function(i,o){function a(x){var v=!1;return function(){v||(v=!0,x.apply(void 0,arguments))}}function l(x){if(x)throw x}function c(x){return x.setHeader&&typeof x.abort=="function"}function u(x,v,w,E){E=a(E);var C=!1;x.on("close",function(){C=!0}),p===void 0&&(p=i("./end-of-stream")),p(x,{readable:v,writable:w},function(N){return N?E(N):(C=!0,void E())});var T=!1;return function(N){if(!C)return T?void 0:(T=!0,c(x)?x.abort():typeof x.destroy=="function"?x.destroy():void E(N||new b("pipe")))}}function f(x){x()}function d(x,v){return x.pipe(v)}function h(x){return x.length&&typeof x[x.length-1]=="function"?x.pop():l}var p,g=i("../../../errors").codes,y=g.ERR_MISSING_ARGS,b=g.ERR_STREAM_DESTROYED;o.exports=function(){for(var x=arguments.length,v=Array(x),w=0;w<x;w++)v[w]=arguments[w];var E=h(v);if(Array.isArray(v[0])&&(v=v[0]),2>v.length)throw new y("streams");var C,T=v.map(function(N,M){var O=M<v.length-1;return u(N,O,0<M,function(I){C||(C=I),I&&T.forEach(f),O||(T.forEach(f),E(C))})});return v.reduce(d)}},{"../../../errors":15,"./end-of-stream":24}],27:[function(i,o){function a(c,u,f){return c.highWaterMark==null?u?c[f]:null:c.highWaterMark}var l=i("../../../errors").codes.ERR_INVALID_OPT_VALUE;o.exports={getHighWaterMark:function(c,u,f,d){var h=a(u,d,f);if(h!=null){if(!(isFinite(h)&&t(h)===h)||0>h){var p=d?f:"highWaterMark";throw new l(p,h)}return t(h)}return c.objectMode?16:16384}}},{"../../../errors":15}],28:[function(i,o){o.exports=i("events").EventEmitter},{events:7}],29:[function(i,o,a){a=o.exports=i("./lib/_stream_readable.js"),a.Stream=a,a.Readable=a,a.Writable=i("./lib/_stream_writable.js"),a.Duplex=i("./lib/_stream_duplex.js"),a.Transform=i("./lib/_stream_transform.js"),a.PassThrough=i("./lib/_stream_passthrough.js"),a.finished=i("./lib/internal/streams/end-of-stream.js"),a.pipeline=i("./lib/internal/streams/pipeline.js")},{"./lib/_stream_duplex.js":16,"./lib/_stream_passthrough.js":17,"./lib/_stream_readable.js":18,"./lib/_stream_transform.js":19,"./lib/_stream_writable.js":20,"./lib/internal/streams/end-of-stream.js":24,"./lib/internal/streams/pipeline.js":26}],30:[function(i,o,a){function l(d,h){for(var p in d)h[p]=d[p]}function c(d,h,p){return f(d,h,p)}/*! safe-buffer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */var u=i("buffer"),f=u.Buffer;f.from&&f.alloc&&f.allocUnsafe&&f.allocUnsafeSlow?o.exports=u:(l(u,a),a.Buffer=c),c.prototype=Object.create(f.prototype),l(f,c),c.from=function(d,h,p){if(typeof d=="number")throw new TypeError("Argument must not be a number");return f(d,h,p)},c.alloc=function(d,h,p){if(typeof d!="number")throw new TypeError("Argument must be a number");var g=f(d);return h===void 0?g.fill(0):typeof p=="string"?g.fill(h,p):g.fill(h),g},c.allocUnsafe=function(d){if(typeof d!="number")throw new TypeError("Argument must be a number");return f(d)},c.allocUnsafeSlow=function(d){if(typeof d!="number")throw new TypeError("Argument must be a number");return u.SlowBuffer(d)}},{buffer:3}],31:[function(i,o,a){function l(T){if(!T)return"utf8";for(var N;;)switch(T){case"utf8":case"utf-8":return"utf8";case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":return"utf16le";case"latin1":case"binary":return"latin1";case"base64":case"ascii":case"hex":return T;default:if(N)return;T=(""+T).toLowerCase(),N=!0}}function c(T){var N=l(T);if(typeof N!="string"&&(E.isEncoding===C||!C(T)))throw new Error("Unknown encoding: "+T);return N||T}function u(T){this.encoding=c(T);var N;switch(this.encoding){case"utf16le":this.text=g,this.end=y,N=4;break;case"utf8":this.fillLast=p,N=4;break;case"base64":this.text=b,this.end=x,N=3;break;default:return this.write=v,void(this.end=w)}this.lastNeed=0,this.lastTotal=0,this.lastChar=E.allocUnsafe(N)}function f(T){return 127>=T?0:T>>5==6?2:T>>4==14?3:T>>3==30?4:T>>6==2?-1:-2}function d(T,N,M){var O=N.length-1;if(O<M)return 0;var I=f(N[O]);return 0<=I?(0<I&&(T.lastNeed=I-1),I):--O<M||I===-2?0:(I=f(N[O]),0<=I?(0<I&&(T.lastNeed=I-2),I):--O<M||I===-2?0:(I=f(N[O]),0<=I?(0<I&&(I===2?I=0:T.lastNeed=I-3),I):0))}function h(T,N){if((192&N[0])!=128)return T.lastNeed=0,"�";if(1<T.lastNeed&&1<N.length){if((192&N[1])!=128)return T.lastNeed=1,"�";if(2<T.lastNeed&&2<N.length&&(192&N[2])!=128)return T.lastNeed=2,"�"}}function p(T){var N=this.lastTotal-this.lastNeed,M=h(this,T);return M===void 0?this.lastNeed<=T.length?(T.copy(this.lastChar,N,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(T.copy(this.lastChar,N,0,T.length),void(this.lastNeed-=T.length)):M}function g(T,N){if((T.length-N)%2==0){var M=T.toString("utf16le",N);if(M){var O=M.charCodeAt(M.length-1);if(55296<=O&&56319>=O)return this.lastNeed=2,this.lastTotal=4,this.lastChar[0]=T[T.length-2],this.lastChar[1]=T[T.length-1],M.slice(0,-1)}return M}return this.lastNeed=1,this.lastTotal=2,this.lastChar[0]=T[T.length-1],T.toString("utf16le",N,T.length-1)}function y(T){var N=T&&T.length?this.write(T):"";if(this.lastNeed){var M=this.lastTotal-this.lastNeed;return N+this.lastChar.toString("utf16le",0,M)}return N}function b(T,N){var M=(T.length-N)%3;return M==0?T.toString("base64",N):(this.lastNeed=3-M,this.lastTotal=3,M==1?this.lastChar[0]=T[T.length-1]:(this.lastChar[0]=T[T.length-2],this.lastChar[1]=T[T.length-1]),T.toString("base64",N,T.length-M))}function x(T){var N=T&&T.length?this.write(T):"";return this.lastNeed?N+this.lastChar.toString("base64",0,3-this.lastNeed):N}function v(T){return T.toString(this.encoding)}function w(T){return T&&T.length?this.write(T):""}var E=i("safe-buffer").Buffer,C=E.isEncoding||function(T){switch(T=""+T,T&&T.toLowerCase()){case"hex":case"utf8":case"utf-8":case"ascii":case"binary":case"base64":case"ucs2":case"ucs-2":case"utf16le":case"utf-16le":case"raw":return!0;default:return!1}};a.StringDecoder=u,u.prototype.write=function(T){if(T.length===0)return"";var N,M;if(this.lastNeed){if(N=this.fillLast(T),N===void 0)return"";M=this.lastNeed,this.lastNeed=0}else M=0;return M<T.length?N?N+this.text(T,M):this.text(T,M):N||""},u.prototype.end=function(T){var N=T&&T.length?this.write(T):"";return this.lastNeed?N+"�":N},u.prototype.text=function(T,N){var M=d(this,T,N);if(!this.lastNeed)return T.toString("utf8",N);this.lastTotal=M;var O=T.length-(M-this.lastNeed);return T.copy(this.lastChar,0,O),T.toString("utf8",N,O)},u.prototype.fillLast=function(T){return this.lastNeed<=T.length?(T.copy(this.lastChar,this.lastTotal-this.lastNeed,0,this.lastNeed),this.lastChar.toString(this.encoding,0,this.lastTotal)):(T.copy(this.lastChar,this.lastTotal-this.lastNeed,0,T.length),void(this.lastNeed-=T.length))}},{"safe-buffer":30}],32:[function(i,o){(function(a){(function(){function l(c){try{if(!a.localStorage)return!1}catch{return!1}var u=a.localStorage[c];return u!=null&&(u+"").toLowerCase()==="true"}o.exports=function(c,u){function f(){if(!d){if(l("throwDeprecation"))throw new Error(u);l("traceDeprecation")?console.trace(u):console.warn(u),d=!0}return c.apply(this,arguments)}if(l("noDeprecation"))return c;var d=!1;return f}}).call(this)}).call(this,typeof ns>"u"?typeof self>"u"?typeof window>"u"?{}:window:self:ns)},{}],"/":[function(i,o){function a(x){return x.replace(/a=ice-options:trickle\s\n/g,"")}function l(x){console.warn(x)}/*! simple-peer. MIT License. Feross Aboukhadijeh <https://feross.org/opensource> */const c=i("debug")("simple-peer"),u=i("get-browser-rtc"),f=i("randombytes"),d=i("readable-stream"),h=i("queue-microtask"),p=i("err-code"),{Buffer:g}=i("buffer"),y=65536;class b extends d.Duplex{constructor(v){if(v=Object.assign({allowHalfOpen:!1},v),super(v),this._id=f(4).toString("hex").slice(0,7),this._debug("new peer %o",v),this.channelName=v.initiator?v.channelName||f(20).toString("hex"):null,this.initiator=v.initiator||!1,this.channelConfig=v.channelConfig||b.channelConfig,this.channelNegotiated=this.channelConfig.negotiated,this.config=Object.assign({},b.config,v.config),this.offerOptions=v.offerOptions||{},this.answerOptions=v.answerOptions||{},this.sdpTransform=v.sdpTransform||(w=>w),this.streams=v.streams||(v.stream?[v.stream]:[]),this.trickle=v.trickle===void 0||v.trickle,this.allowHalfTrickle=v.allowHalfTrickle!==void 0&&v.allowHalfTrickle,this.iceCompleteTimeout=v.iceCompleteTimeout||5e3,this.destroyed=!1,this.destroying=!1,this._connected=!1,this.remoteAddress=void 0,this.remoteFamily=void 0,this.remotePort=void 0,this.localAddress=void 0,this.localFamily=void 0,this.localPort=void 0,this._wrtc=v.wrtc&&typeof v.wrtc=="object"?v.wrtc:u(),!this._wrtc)throw p(typeof window>"u"?new Error("No WebRTC support: Specify `opts.wrtc` option in this environment"):new Error("No WebRTC support: Not a supported browser"),"ERR_WEBRTC_SUPPORT");this._pcReady=!1,this._channelReady=!1,this._iceComplete=!1,this._iceCompleteTimer=null,this._channel=null,this._pendingCandidates=[],this._isNegotiating=!1,this._firstNegotiation=!0,this._batchedNegotiation=!1,this._queuedNegotiation=!1,this._sendersAwaitingStable=[],this._senderMap=new Map,this._closingInterval=null,this._remoteTracks=[],this._remoteStreams=[],this._chunk=null,this._cb=null,this._interval=null;try{this._pc=new this._wrtc.RTCPeerConnection(this.config)}catch(w){return void this.destroy(p(w,"ERR_PC_CONSTRUCTOR"))}this._isReactNativeWebrtc=typeof this._pc._peerConnectionId=="number",this._pc.oniceconnectionstatechange=()=>{this._onIceStateChange()},this._pc.onicegatheringstatechange=()=>{this._onIceStateChange()},this._pc.onconnectionstatechange=()=>{this._onConnectionStateChange()},this._pc.onsignalingstatechange=()=>{this._onSignalingStateChange()},this._pc.onicecandidate=w=>{this._onIceCandidate(w)},typeof this._pc.peerIdentity=="object"&&this._pc.peerIdentity.catch(w=>{this.destroy(p(w,"ERR_PC_PEER_IDENTITY"))}),this.initiator||this.channelNegotiated?this._setupData({channel:this._pc.createDataChannel(this.channelName,this.channelConfig)}):this._pc.ondatachannel=w=>{this._setupData(w)},this.streams&&this.streams.forEach(w=>{this.addStream(w)}),this._pc.ontrack=w=>{this._onTrack(w)},this._debug("initial negotiation"),this._needsNegotiation(),this._onFinishBound=()=>{this._onFinish()},this.once("finish",this._onFinishBound)}get bufferSize(){return this._channel&&this._channel.bufferedAmount||0}get connected(){return this._connected&&this._channel.readyState==="open"}address(){return{port:this.localPort,family:this.localFamily,address:this.localAddress}}signal(v){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot signal after peer is destroyed"),"ERR_DESTROYED");if(typeof v=="string")try{v=JSON.parse(v)}catch{v={}}this._debug("signal()"),v.renegotiate&&this.initiator&&(this._debug("got request to renegotiate"),this._needsNegotiation()),v.transceiverRequest&&this.initiator&&(this._debug("got request for transceiver"),this.addTransceiver(v.transceiverRequest.kind,v.transceiverRequest.init)),v.candidate&&(this._pc.remoteDescription&&this._pc.remoteDescription.type?this._addIceCandidate(v.candidate):this._pendingCandidates.push(v.candidate)),v.sdp&&this._pc.setRemoteDescription(new this._wrtc.RTCSessionDescription(v)).then(()=>{this.destroyed||(this._pendingCandidates.forEach(w=>{this._addIceCandidate(w)}),this._pendingCandidates=[],this._pc.remoteDescription.type==="offer"&&this._createAnswer())}).catch(w=>{this.destroy(p(w,"ERR_SET_REMOTE_DESCRIPTION"))}),v.sdp||v.candidate||v.renegotiate||v.transceiverRequest||this.destroy(p(new Error("signal() called with invalid signal data"),"ERR_SIGNALING"))}}_addIceCandidate(v){const w=new this._wrtc.RTCIceCandidate(v);this._pc.addIceCandidate(w).catch(E=>{!w.address||w.address.endsWith(".local")?l("Ignoring unsupported ICE candidate."):this.destroy(p(E,"ERR_ADD_ICE_CANDIDATE"))})}send(v){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot send after peer is destroyed"),"ERR_DESTROYED");this._channel.send(v)}}addTransceiver(v,w){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot addTransceiver after peer is destroyed"),"ERR_DESTROYED");if(this._debug("addTransceiver()"),this.initiator)try{this._pc.addTransceiver(v,w),this._needsNegotiation()}catch(E){this.destroy(p(E,"ERR_ADD_TRANSCEIVER"))}else this.emit("signal",{type:"transceiverRequest",transceiverRequest:{kind:v,init:w}})}}addStream(v){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot addStream after peer is destroyed"),"ERR_DESTROYED");this._debug("addStream()"),v.getTracks().forEach(w=>{this.addTrack(w,v)})}}addTrack(v,w){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot addTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("addTrack()");const E=this._senderMap.get(v)||new Map;let C=E.get(w);if(!C)C=this._pc.addTrack(v,w),E.set(w,C),this._senderMap.set(v,E),this._needsNegotiation();else throw C.removed?p(new Error("Track has been removed. You should enable/disable tracks that you want to re-add."),"ERR_SENDER_REMOVED"):p(new Error("Track has already been added to that stream."),"ERR_SENDER_ALREADY_ADDED")}replaceTrack(v,w,E){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot replaceTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("replaceTrack()");const C=this._senderMap.get(v),T=C?C.get(E):null;if(!T)throw p(new Error("Cannot replace track that was never added."),"ERR_TRACK_NOT_ADDED");w&&this._senderMap.set(w,C),T.replaceTrack==null?this.destroy(p(new Error("replaceTrack is not supported in this browser"),"ERR_UNSUPPORTED_REPLACETRACK")):T.replaceTrack(w)}removeTrack(v,w){if(this.destroying)return;if(this.destroyed)throw p(new Error("cannot removeTrack after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSender()");const E=this._senderMap.get(v),C=E?E.get(w):null;if(!C)throw p(new Error("Cannot remove track that was never added."),"ERR_TRACK_NOT_ADDED");try{C.removed=!0,this._pc.removeTrack(C)}catch(T){T.name==="NS_ERROR_UNEXPECTED"?this._sendersAwaitingStable.push(C):this.destroy(p(T,"ERR_REMOVE_TRACK"))}this._needsNegotiation()}removeStream(v){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot removeStream after peer is destroyed"),"ERR_DESTROYED");this._debug("removeSenders()"),v.getTracks().forEach(w=>{this.removeTrack(w,v)})}}_needsNegotiation(){this._debug("_needsNegotiation"),this._batchedNegotiation||(this._batchedNegotiation=!0,h(()=>{this._batchedNegotiation=!1,this.initiator||!this._firstNegotiation?(this._debug("starting batched negotiation"),this.negotiate()):this._debug("non-initiator initial negotiation request discarded"),this._firstNegotiation=!1}))}negotiate(){if(!this.destroying){if(this.destroyed)throw p(new Error("cannot negotiate after peer is destroyed"),"ERR_DESTROYED");this.initiator?this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("start negotiation"),setTimeout(()=>{this._createOffer()},0)):this._isNegotiating?(this._queuedNegotiation=!0,this._debug("already negotiating, queueing")):(this._debug("requesting negotiation from initiator"),this.emit("signal",{type:"renegotiate",renegotiate:!0})),this._isNegotiating=!0}}destroy(v){this._destroy(v,()=>{})}_destroy(v,w){this.destroyed||this.destroying||(this.destroying=!0,this._debug("destroying (error: %s)",v&&(v.message||v)),h(()=>{if(this.destroyed=!0,this.destroying=!1,this._debug("destroy (error: %s)",v&&(v.message||v)),this.readable=this.writable=!1,this._readableState.ended||this.push(null),this._writableState.finished||this.end(),this._connected=!1,this._pcReady=!1,this._channelReady=!1,this._remoteTracks=null,this._remoteStreams=null,this._senderMap=null,clearInterval(this._closingInterval),this._closingInterval=null,clearInterval(this._interval),this._interval=null,this._chunk=null,this._cb=null,this._onFinishBound&&this.removeListener("finish",this._onFinishBound),this._onFinishBound=null,this._channel){try{this._channel.close()}catch{}this._channel.onmessage=null,this._channel.onopen=null,this._channel.onclose=null,this._channel.onerror=null}if(this._pc){try{this._pc.close()}catch{}this._pc.oniceconnectionstatechange=null,this._pc.onicegatheringstatechange=null,this._pc.onsignalingstatechange=null,this._pc.onicecandidate=null,this._pc.ontrack=null,this._pc.ondatachannel=null}this._pc=null,this._channel=null,v&&this.emit("error",v),this.emit("close"),w()}))}_setupData(v){if(!v.channel)return this.destroy(p(new Error("Data channel event is missing `channel` property"),"ERR_DATA_CHANNEL"));this._channel=v.channel,this._channel.binaryType="arraybuffer",typeof this._channel.bufferedAmountLowThreshold=="number"&&(this._channel.bufferedAmountLowThreshold=y),this.channelName=this._channel.label,this._channel.onmessage=E=>{this._onChannelMessage(E)},this._channel.onbufferedamountlow=()=>{this._onChannelBufferedAmountLow()},this._channel.onopen=()=>{this._onChannelOpen()},this._channel.onclose=()=>{this._onChannelClose()},this._channel.onerror=E=>{const C=E.error instanceof Error?E.error:new Error(`Datachannel error: ${E.message} ${E.filename}:${E.lineno}:${E.colno}`);this.destroy(p(C,"ERR_DATA_CHANNEL"))};let w=!1;this._closingInterval=setInterval(()=>{this._channel&&this._channel.readyState==="closing"?(w&&this._onChannelClose(),w=!0):w=!1},5e3)}_read(){}_write(v,w,E){if(this.destroyed)return E(p(new Error("cannot write after peer is destroyed"),"ERR_DATA_CHANNEL"));if(this._connected){try{this.send(v)}catch(C){return this.destroy(p(C,"ERR_DATA_CHANNEL"))}this._channel.bufferedAmount>y?(this._debug("start backpressure: bufferedAmount %d",this._channel.bufferedAmount),this._cb=E):E(null)}else this._debug("write before connect"),this._chunk=v,this._cb=E}_onFinish(){if(!this.destroyed){const v=()=>{setTimeout(()=>this.destroy(),1e3)};this._connected?v():this.once("connect",v)}}_startIceCompleteTimeout(){this.destroyed||this._iceCompleteTimer||(this._debug("started iceComplete timeout"),this._iceCompleteTimer=setTimeout(()=>{this._iceComplete||(this._iceComplete=!0,this._debug("iceComplete timeout completed"),this.emit("iceTimeout"),this.emit("_iceComplete"))},this.iceCompleteTimeout))}_createOffer(){this.destroyed||this._pc.createOffer(this.offerOptions).then(v=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(v.sdp=a(v.sdp)),v.sdp=this.sdpTransform(v.sdp);const w=()=>{if(!this.destroyed){const E=this._pc.localDescription||v;this._debug("signal"),this.emit("signal",{type:E.type,sdp:E.sdp})}};this._pc.setLocalDescription(v).then(()=>{this._debug("createOffer success"),this.destroyed||(this.trickle||this._iceComplete?w():this.once("_iceComplete",w))}).catch(E=>{this.destroy(p(E,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(v=>{this.destroy(p(v,"ERR_CREATE_OFFER"))})}_requestMissingTransceivers(){this._pc.getTransceivers&&this._pc.getTransceivers().forEach(v=>{v.mid||!v.sender.track||v.requested||(v.requested=!0,this.addTransceiver(v.sender.track.kind))})}_createAnswer(){this.destroyed||this._pc.createAnswer(this.answerOptions).then(v=>{if(this.destroyed)return;this.trickle||this.allowHalfTrickle||(v.sdp=a(v.sdp)),v.sdp=this.sdpTransform(v.sdp);const w=()=>{if(!this.destroyed){const E=this._pc.localDescription||v;this._debug("signal"),this.emit("signal",{type:E.type,sdp:E.sdp}),this.initiator||this._requestMissingTransceivers()}};this._pc.setLocalDescription(v).then(()=>{this.destroyed||(this.trickle||this._iceComplete?w():this.once("_iceComplete",w))}).catch(E=>{this.destroy(p(E,"ERR_SET_LOCAL_DESCRIPTION"))})}).catch(v=>{this.destroy(p(v,"ERR_CREATE_ANSWER"))})}_onConnectionStateChange(){this.destroyed||this._pc.connectionState==="failed"&&this.destroy(p(new Error("Connection failed."),"ERR_CONNECTION_FAILURE"))}_onIceStateChange(){if(this.destroyed)return;const v=this._pc.iceConnectionState,w=this._pc.iceGatheringState;this._debug("iceStateChange (connection: %s) (gathering: %s)",v,w),this.emit("iceStateChange",v,w),(v==="connected"||v==="completed")&&(this._pcReady=!0,this._maybeReady()),v==="failed"&&this.destroy(p(new Error("Ice connection failed."),"ERR_ICE_CONNECTION_FAILURE")),v==="closed"&&this.destroy(p(new Error("Ice connection closed."),"ERR_ICE_CONNECTION_CLOSED"))}getStats(v){const w=E=>(Object.prototype.toString.call(E.values)==="[object Array]"&&E.values.forEach(C=>{Object.assign(E,C)}),E);this._pc.getStats.length===0||this._isReactNativeWebrtc?this._pc.getStats().then(E=>{const C=[];E.forEach(T=>{C.push(w(T))}),v(null,C)},E=>v(E)):0<this._pc.getStats.length?this._pc.getStats(E=>{if(this.destroyed)return;const C=[];E.result().forEach(T=>{const N={};T.names().forEach(M=>{N[M]=T.stat(M)}),N.id=T.id,N.type=T.type,N.timestamp=T.timestamp,C.push(w(N))}),v(null,C)},E=>v(E)):v(null,[])}_maybeReady(){if(this._debug("maybeReady pc %s channel %s",this._pcReady,this._channelReady),this._connected||this._connecting||!this._pcReady||!this._channelReady)return;this._connecting=!0;const v=()=>{this.destroyed||this.getStats((w,E)=>{if(this.destroyed)return;w&&(E=[]);const C={},T={},N={};let M=!1;E.forEach(I=>{(I.type==="remotecandidate"||I.type==="remote-candidate")&&(C[I.id]=I),(I.type==="localcandidate"||I.type==="local-candidate")&&(T[I.id]=I),(I.type==="candidatepair"||I.type==="candidate-pair")&&(N[I.id]=I)});const O=I=>{M=!0;let L=T[I.localCandidateId];L&&(L.ip||L.address)?(this.localAddress=L.ip||L.address,this.localPort=+L.port):L&&L.ipAddress?(this.localAddress=L.ipAddress,this.localPort=+L.portNumber):typeof I.googLocalAddress=="string"&&(L=I.googLocalAddress.split(":"),this.localAddress=L[0],this.localPort=+L[1]),this.localAddress&&(this.localFamily=this.localAddress.includes(":")?"IPv6":"IPv4");let $=C[I.remoteCandidateId];$&&($.ip||$.address)?(this.remoteAddress=$.ip||$.address,this.remotePort=+$.port):$&&$.ipAddress?(this.remoteAddress=$.ipAddress,this.remotePort=+$.portNumber):typeof I.googRemoteAddress=="string"&&($=I.googRemoteAddress.split(":"),this.remoteAddress=$[0],this.remotePort=+$[1]),this.remoteAddress&&(this.remoteFamily=this.remoteAddress.includes(":")?"IPv6":"IPv4"),this._debug("connect local: %s:%s remote: %s:%s",this.localAddress,this.localPort,this.remoteAddress,this.remotePort)};if(E.forEach(I=>{I.type==="transport"&&I.selectedCandidatePairId&&O(N[I.selectedCandidatePairId]),(I.type==="googCandidatePair"&&I.googActiveConnection==="true"||(I.type==="candidatepair"||I.type==="candidate-pair")&&I.selected)&&O(I)}),!M&&(!Object.keys(N).length||Object.keys(T).length))return void setTimeout(v,100);if(this._connecting=!1,this._connected=!0,this._chunk){try{this.send(this._chunk)}catch(L){return this.destroy(p(L,"ERR_DATA_CHANNEL"))}this._chunk=null,this._debug('sent chunk from "write before connect"');const I=this._cb;this._cb=null,I(null)}typeof this._channel.bufferedAmountLowThreshold!="number"&&(this._interval=setInterval(()=>this._onInterval(),150),this._interval.unref&&this._interval.unref()),this._debug("connect"),this.emit("connect")})};v()}_onInterval(){this._cb&&this._channel&&!(this._channel.bufferedAmount>y)&&this._onChannelBufferedAmountLow()}_onSignalingStateChange(){this.destroyed||(this._pc.signalingState==="stable"&&(this._isNegotiating=!1,this._debug("flushing sender queue",this._sendersAwaitingStable),this._sendersAwaitingStable.forEach(v=>{this._pc.removeTrack(v),this._queuedNegotiation=!0}),this._sendersAwaitingStable=[],this._queuedNegotiation?(this._debug("flushing negotiation queue"),this._queuedNegotiation=!1,this._needsNegotiation()):(this._debug("negotiated"),this.emit("negotiated"))),this._debug("signalingStateChange %s",this._pc.signalingState),this.emit("signalingStateChange",this._pc.signalingState))}_onIceCandidate(v){this.destroyed||(v.candidate&&this.trickle?this.emit("signal",{type:"candidate",candidate:{candidate:v.candidate.candidate,sdpMLineIndex:v.candidate.sdpMLineIndex,sdpMid:v.candidate.sdpMid}}):!v.candidate&&!this._iceComplete&&(this._iceComplete=!0,this.emit("_iceComplete")),v.candidate&&this._startIceCompleteTimeout())}_onChannelMessage(v){if(this.destroyed)return;let w=v.data;w instanceof ArrayBuffer&&(w=g.from(w)),this.push(w)}_onChannelBufferedAmountLow(){if(!this.destroyed&&this._cb){this._debug("ending backpressure: bufferedAmount %d",this._channel.bufferedAmount);const v=this._cb;this._cb=null,v(null)}}_onChannelOpen(){this._connected||this.destroyed||(this._debug("on channel open"),this._channelReady=!0,this._maybeReady())}_onChannelClose(){this.destroyed||(this._debug("on channel close"),this.destroy())}_onTrack(v){this.destroyed||v.streams.forEach(w=>{this._debug("on track"),this.emit("track",v.track,w),this._remoteTracks.push({track:v.track,stream:w}),this._remoteStreams.some(E=>E.id===w.id)||(this._remoteStreams.push(w),h(()=>{this._debug("on stream"),this.emit("stream",w)}))})}_debug(){const v=[].slice.call(arguments);v[0]="["+this._id+"] "+v[0],c.apply(null,v)}}b.WEBRTC_SUPPORT=!!u(),b.config={iceServers:[{urls:["stun:stun.l.google.com:19302","stun:global.stun.twilio.com:3478"]}],sdpSemantics:"unified-plan"},b.channelConfig={},o.exports=b},{buffer:3,debug:4,"err-code":6,"get-browser-rtc":8,"queue-microtask":13,randombytes:14,"readable-stream":29}]},{},[])("/")})})(eS);var l8=eS.exports;const c8=_g(l8),fb=0,db=1,tS=2,nS=(n,e)=>{ve(n,fb);const t=s4(e);St(n,t)},rS=(n,e,t)=>{ve(n,db),St(n,J0(e,t))},u8=(n,e,t)=>rS(e,t,Qt(n)),sS=(n,e,t)=>{try{lC(e,Qt(n),t)}catch(r){console.error("Caught error while handling a Yjs update",r)}},f8=(n,e)=>{ve(n,tS),St(n,e)},d8=sS,h8=(n,e,t,r)=>{const s=Oe(n);switch(s){case fb:u8(n,e,t);break;case db:sS(n,t,r);break;case tS:d8(n,t,r);break;default:throw new Error("Unknown message type")}return s},hb=3e4;class p8 extends w0{constructor(e){super(),this.doc=e,this.clientID=e.clientID,this.states=new Map,this.meta=new Map,this._checkInterval=setInterval(()=>{const t=ds();this.getLocalState()!==null&&hb/2<=t-this.meta.get(this.clientID).lastUpdated&&this.setLocalState(this.getLocalState());const r=[];this.meta.forEach((s,i)=>{i!==this.clientID&&hb<=t-s.lastUpdated&&this.states.has(i)&&r.push(i)}),r.length>0&&pb(this,r,"timeout")},_r(hb/10)),e.on("destroy",()=>{this.destroy()}),this.setLocalState({})}destroy(){this.emit("destroy",[this]),this.setLocalState(null),super.destroy(),clearInterval(this._checkInterval)}getLocalState(){return this.states.get(this.clientID)||null}setLocalState(e){const t=this.clientID,r=this.meta.get(t),s=r===void 0?0:r.clock+1,i=this.states.get(t);e===null?this.states.delete(t):this.states.set(t,e),this.meta.set(t,{clock:s,lastUpdated:ds()});const o=[],a=[],l=[],c=[];e===null?c.push(t):i==null?e!=null&&o.push(t):(a.push(t),bf(i,e)||l.push(t)),(o.length>0||l.length>0||c.length>0)&&this.emit("change",[{added:o,updated:l,removed:c},"local"]),this.emit("update",[{added:o,updated:a,removed:c},"local"])}setLocalStateField(e,t){const r=this.getLocalState();r!==null&&this.setLocalState({...r,[e]:t})}getStates(){return this.states}}const pb=(n,e,t)=>{const r=[];for(let s=0;s<e.length;s++){const i=e[s];if(n.states.has(i)){if(n.states.delete(i),i===n.clientID){const o=n.meta.get(i);n.meta.set(i,{clock:o.clock+1,lastUpdated:ds()})}r.push(i)}}r.length>0&&(n.emit("change",[{added:[],updated:[],removed:r},t]),n.emit("update",[{added:[],updated:[],removed:r},t]))},ap=(n,e,t=n.states)=>{const r=e.length,s=Jt();ve(s,r);for(let i=0;i<r;i++){const o=e[i],a=t.get(o)||null,l=n.meta.get(o).clock;ve(s,o),ve(s,l),hs(s,JSON.stringify(a))}return At(s)},m8=(n,e,t)=>{const r=ps(e),s=ds(),i=[],o=[],a=[],l=[],c=Oe(r);for(let u=0;u<c;u++){const f=Oe(r);let d=Oe(r);const h=JSON.parse(qs(r)),p=n.meta.get(f),g=n.states.get(f),y=p===void 0?0:p.clock;(y<d||y===d&&h===null&&n.states.has(f))&&(h===null?f===n.clientID&&n.getLocalState()!=null?d++:n.states.delete(f):n.states.set(f,h),n.meta.set(f,{clock:d,lastUpdated:s}),p===void 0&&h!==null?i.push(f):p!==void 0&&h===null?l.push(f):h!==null&&(bf(h,g)||a.push(f),o.push(f)))}(i.length>0||a.length>0||l.length>0)&&n.emit("change",[{added:i,updated:a,removed:l},t]),(i.length>0||o.length>0||l.length>0)&&n.emit("update",[{added:i,updated:o,removed:l},t])},g8=(n,e)=>{const t=k0(n).buffer,r=k0(e).buffer;return crypto.subtle.importKey("raw",t,"PBKDF2",!1,["deriveKey"]).then(s=>crypto.subtle.deriveKey({name:"PBKDF2",salt:r,iterations:1e5,hash:"SHA-256"},s,{name:"AES-GCM",length:256},!0,["encrypt","decrypt"]))},iS=(n,e)=>{if(!e)return H0(n);const t=crypto.getRandomValues(new Uint8Array(12));return crypto.subtle.encrypt({name:"AES-GCM",iv:t},e,n).then(r=>{const s=Jt();return hs(s,"AES-GCM"),St(s,t),St(s,new Uint8Array(r)),At(s)})},y8=(n,e)=>{const t=Jt();return Nl(t,n),iS(At(t),e)},oS=(n,e)=>{if(!e)return H0(n);const t=ps(n);qs(t)!=="AES-GCM"&&P3(Lr("Unknown encryption algorithm"));const s=Qt(t),i=Qt(t);return crypto.subtle.decrypt({name:"AES-GCM",iv:s},e,i).then(o=>new Uint8Array(o))},b8=(n,e)=>oS(n,e).then(t=>Ml(ps(new Uint8Array(t)))),tr=R3("y-webrtc"),Vl=0,aS=3,Rf=1,mb=4,lp=new Map,ca=new Map,lS=n=>{let e=!0;n.webrtcConns.forEach(t=>{t.synced||(e=!1)}),(!e&&n.synced||e&&!n.synced)&&(n.synced=e,n.provider.emit("synced",[{synced:e}]),tr("synced ",yr,n.name,na," with all peers"))},cS=(n,e,t)=>{const r=ps(e),s=Jt(),i=Oe(r);if(n===void 0)return null;const o=n.awareness,a=n.doc;let l=!1;switch(i){case Vl:{ve(s,Vl);const c=h8(r,s,a,n);c===db&&!n.synced&&t(),c===fb&&(l=!0);break}case aS:ve(s,Rf),St(s,ap(o,Array.from(o.getStates().keys()))),l=!0;break;case Rf:m8(o,Qt(r),n);break;case mb:{const c=ta(r)===1,u=qs(r);if(u!==n.peerId&&(n.bcConns.has(u)&&!c||!n.bcConns.has(u)&&c)){const f=[],d=[];c?(n.bcConns.add(u),d.push(u)):(n.bcConns.delete(u),f.push(u)),n.provider.emit("peers",[{added:d,removed:f,webrtcPeers:Array.from(n.webrtcConns.keys()),bcPeers:Array.from(n.bcConns)}]),dS(n)}break}default:return console.error("Unable to compute message"),s}return l?s:null},w8=(n,e)=>{const t=n.room;return tr("received message from ",yr,n.remotePeerId,F0," (",t.name,")",na,Gh),cS(t,e,()=>{n.synced=!0,tr("synced ",yr,t.name,na," with ",yr,n.remotePeerId),lS(t)})},gb=(n,e)=>{tr("send message to ",yr,n.remotePeerId,na,F0," (",n.room.name,")",Gh);try{n.peer.send(At(e))}catch{}},v8=(n,e)=>{tr("broadcast message in ",yr,n.name,na),n.webrtcConns.forEach(t=>{try{t.peer.send(e)}catch{}})};class uS{constructor(e,t,r,s){tr("establishing connection to ",yr,r),this.room=s,this.remotePeerId=r,this.glareToken=void 0,this.closed=!1,this.connected=!1,this.synced=!1,this.peer=new c8({initiator:t,...s.provider.peerOpts}),this.peer.on("signal",i=>{this.glareToken===void 0&&(this.glareToken=Date.now()+Math.random()),bb(e,s,{to:r,from:s.peerId,type:"signal",token:this.glareToken,signal:i})}),this.peer.on("connect",()=>{tr("connected to ",yr,r),this.connected=!0;const o=s.provider.doc,a=s.awareness,l=Jt();ve(l,Vl),nS(l,o),gb(this,l);const c=a.getStates();if(c.size>0){const u=Jt();ve(u,Rf),St(u,ap(a,Array.from(c.keys()))),gb(this,u)}}),this.peer.on("close",()=>{this.connected=!1,this.closed=!0,s.webrtcConns.has(this.remotePeerId)&&(s.webrtcConns.delete(this.remotePeerId),s.provider.emit("peers",[{removed:[this.remotePeerId],added:[],webrtcPeers:Array.from(s.webrtcConns.keys()),bcPeers:Array.from(s.bcConns)}])),lS(s),this.peer.destroy(),tr("closed connection to ",yr,r),yb(s)}),this.peer.on("error",i=>{tr("Error in connection to ",yr,r,": ",i),yb(s)}),this.peer.on("data",i=>{const o=w8(this,i);o!==null&&gb(this,o)})}destroy(){this.peer.destroy()}}const Ki=(n,e)=>iS(e,n.key).then(t=>n.mux(()=>V3(n.name,t))),fS=(n,e)=>{n.bcconnected&&Ki(n,e),v8(n,e)},yb=n=>{lp.forEach(e=>{e.connected&&(e.send({type:"subscribe",topics:[n.name]}),n.webrtcConns.size<n.provider.maxConns&&bb(e,n,{type:"announce",from:n.peerId}))})},dS=n=>{if(n.provider.filterBcConns){const e=Jt();ve(e,mb),yf(e,1),hs(e,n.peerId),Ki(n,At(e))}};class A8{constructor(e,t,r,s){this.peerId=Ak(),this.doc=e,this.awareness=t.awareness,this.provider=t,this.synced=!1,this.name=r,this.key=s,this.webrtcConns=new Map,this.bcConns=new Set,this.mux=Yk(),this.bcconnected=!1,this._bcSubscriber=i=>oS(new Uint8Array(i),s).then(o=>this.mux(()=>{const a=cS(this,o,()=>{});a&&Ki(this,At(a))})),this._docUpdateHandler=(i,o)=>{const a=Jt();ve(a,Vl),f8(a,i),fS(this,At(a))},this._awarenessUpdateHandler=({added:i,updated:o,removed:a},l)=>{const c=i.concat(o).concat(a),u=Jt();ve(u,Rf),St(u,ap(this.awareness,c)),fS(this,At(u))},this._beforeUnloadHandler=()=>{pb(this.awareness,[e.clientID],"window unload"),ca.forEach(i=>{i.disconnect()})},typeof window<"u"?window.addEventListener("beforeunload",this._beforeUnloadHandler):typeof process<"u"&&process.on("exit",this._beforeUnloadHandler)}connect(){this.doc.on("update",this._docUpdateHandler),this.awareness.on("update",this._awarenessUpdateHandler),yb(this);const e=this.name;$3(e,this._bcSubscriber),this.bcconnected=!0,dS(this);const t=Jt();ve(t,Vl),nS(t,this.doc),Ki(this,At(t));const r=Jt();ve(r,Vl),rS(r,this.doc),Ki(this,At(r));const s=Jt();ve(s,aS),Ki(this,At(s));const i=Jt();ve(i,Rf),St(i,ap(this.awareness,[this.doc.clientID])),Ki(this,At(i))}disconnect(){lp.forEach(t=>{t.connected&&t.send({type:"unsubscribe",topics:[this.name]})}),pb(this.awareness,[this.doc.clientID],"disconnect");const e=Jt();ve(e,mb),yf(e,0),hs(e,this.peerId),Ki(this,At(e)),z3(this.name,this._bcSubscriber),this.bcconnected=!1,this.doc.off("update",this._docUpdateHandler),this.awareness.off("update",this._awarenessUpdateHandler),this.webrtcConns.forEach(t=>t.destroy())}destroy(){this.disconnect(),typeof window<"u"?window.removeEventListener("beforeunload",this._beforeUnloadHandler):typeof process<"u"&&process.off("exit",this._beforeUnloadHandler)}}const x8=(n,e,t,r)=>{if(ca.has(t))throw Lr(`A Yjs Doc connected to room "${t}" already exists!`);const s=new A8(n,e,t,r);return ca.set(t,s),s},bb=(n,e,t)=>{e.key?y8(t,e.key).then(r=>{n.send({type:"publish",topic:e.name,data:Jk(r)})}):n.send({type:"publish",topic:e.name,data:t})};class E8 extends LF{constructor(e){super(e),this.providers=new Set,this.on("connect",()=>{tr(`connected (${e})`);const t=Array.from(ca.keys());this.send({type:"subscribe",topics:t}),ca.forEach(r=>bb(this,r,{type:"announce",from:r.peerId}))}),this.on("message",t=>{switch(t.type){case"publish":{const r=t.topic,s=ca.get(r);if(s==null||typeof r!="string")return;const i=o=>{const a=s.webrtcConns,l=s.peerId;if(o==null||o.from===l||o.to!==void 0&&o.to!==l||s.bcConns.has(o.from))return;const c=a.has(o.from)?()=>{}:()=>s.provider.emit("peers",[{removed:[],added:[o.from],webrtcPeers:Array.from(s.webrtcConns.keys()),bcPeers:Array.from(s.bcConns)}]);switch(o.type){case"announce":a.size<s.provider.maxConns&&(Hn(a,o.from,()=>new uS(this,!0,o.from,s)),c());break;case"signal":if(o.signal.type==="offer"){const u=a.get(o.from);if(u){const f=o.token,d=u.glareToken;if(d&&d>f){tr("offer rejected: ",o.from);return}u.glareToken=void 0}}if(o.signal.type==="answer"){tr("offer answered by: ",o.from);const u=a.get(o.from);u.glareToken=void 0}o.to===l&&(Hn(a,o.from,()=>new uS(this,!1,o.from,s)).peer.signal(o.signal),c());break}};s.key?typeof t.data=="string"&&b8(qk(t.data),s.key).then(i):i(t.data)}}}),this.on("disconnect",()=>tr(`disconnect (${e})`))}}const wb=n=>{n.emit("status",[{connected:n.connected}])};class k8 extends b0{constructor(e,t,{signaling:r=["wss://y-webrtc-eu.fly.dev"],password:s=null,awareness:i=new p8(t),maxConns:o=20+_r(wk()*15),filterBcConns:a=!0,peerOpts:l={}}={}){super(),this.roomName=e,this.doc=t,this.filterBcConns=a,this.awareness=i,this.shouldConnect=!1,this.signalingUrls=r,this.signalingConns=[],this.maxConns=o,this.peerOpts=l,this.key=s?g8(s,e):H0(null),this.room=null,this.key.then(c=>{this.room=x8(t,this,e,c),this.shouldConnect?this.room.connect():this.room.disconnect(),wb(this)}),this.connect(),this.destroy=this.destroy.bind(this),t.on("destroy",this.destroy)}get connected(){return this.room!==null&&this.shouldConnect}connect(){this.shouldConnect=!0,this.signalingUrls.forEach(e=>{const t=Hn(lp,e,()=>new E8(e));this.signalingConns.push(t),t.providers.add(this)}),this.room&&(this.room.connect(),wb(this))}disconnect(){this.shouldConnect=!1,this.signalingConns.forEach(e=>{e.providers.delete(this),e.providers.size===0&&(e.destroy(),lp.delete(e.url))}),this.room&&(this.room.disconnect(),wb(this))}destroy(){this.doc.off("destroy",this.destroy),this.key.then(()=>{this.room.destroy(),ca.delete(this.roomName)}),super.destroy()}}const hS={attributes:{class:"prose-lg prose-headings:font-display prose prose-p:my-2 prose-h1:my-2 prose-h2:my-2 prose-h3:my-2 prose-ul:my-2 prose-ol:my-2 max-w-none focus:outline-none w-full",spellcheck:"false",suppressContentEditableWarning:"true"},handleDOMEvents:{keydown:(n,e)=>{if(["ArrowUp","ArrowDown","Enter"].includes(e.key)&&document.querySelector("#slash-command"))return!0}}},C8=/[\uD800-\uDBFF]/,S8=/[\uDC00-\uDFFF]/,T8=(n,e)=>{let t=0,r=0;for(;t<n.length&&t<e.length&&n[t]===e[t];)t++;for(t>0&&C8.test(n[t-1])&&t--;r+t<n.length&&r+t<e.length&&n[n.length-r-1]===e[e.length-r-1];)r++;return r>0&&S8.test(n[n.length-r])&&r--,{index:t,remove:n.length-t-r,insert:e.slice(t,e.length-r)}},xt=new vt("y-sync"),Xs=new vt("y-undo"),cp=new vt("yjs-cursor"),up=(n,e)=>e===void 0?!n.deleted:e.sv.has(n.id.client)&&e.sv.get(n.id.client)>n.id.clock&&!Il(e.ds,n.id),O8=[{light:"#ecd44433",dark:"#ecd444"}],N8=(n,e,t)=>{if(!n.has(t)){if(n.size<e.length){const r=Ws();n.forEach(s=>r.add(s)),e=e.filter(s=>!r.has(s))}n.set(t,UF(e))}return n.get(t)},M8=(n,{colors:e=O8,colorMapping:t=new Map,permanentUserData:r=null,onFirstRender:s=()=>{}}={})=>{let i=!1;const o=new ut({props:{editable:a=>{const l=xt.getState(a);return l.snapshot==null&&l.prevSnapshot==null}},key:xt,state:{init:(a,l)=>({type:n,doc:n.doc,binding:null,snapshot:null,prevSnapshot:null,isChangeOrigin:!1,isUndoRedoOperation:!1,addToHistory:!0,colors:e,colorMapping:t,permanentUserData:r}),apply:(a,l)=>{const c=a.getMeta(xt);if(c!==void 0){l=Object.assign({},l);for(const u in c)l[u]=c[u]}return l.addToHistory=a.getMeta("addToHistory")!==!1,l.isChangeOrigin=c!==void 0&&!!c.isChangeOrigin,l.isUndoRedoOperation=c!==void 0&&!!c.isChangeOrigin&&!!c.isUndoRedoOperation,l.binding!==null&&c!==void 0&&(c.snapshot!=null||c.prevSnapshot!=null)&&B0(0,()=>{l.binding==null||l.binding.isDestroyed||(c.restore==null?l.binding._renderSnapshot(c.snapshot,c.prevSnapshot,l):(l.binding._renderSnapshot(c.snapshot,c.snapshot,l),delete l.restore,delete l.snapshot,delete l.prevSnapshot,l.binding.mux(()=>{l.binding._prosemirrorChanged(l.binding.prosemirrorView.state.doc)})))}),l}},view:a=>{const l=new P8(n,a);return l._forceRerender(),s(),{update:()=>{const c=o.getState(a.state);if(c.snapshot==null&&c.prevSnapshot==null&&(i||a.state.doc.content.findDiffStart(a.state.doc.type.createAndFill().content)!==null)){if(i=!0,c.addToHistory===!1&&!c.isChangeOrigin){const u=Xs.getState(a.state),f=u&&u.undoManager;f&&f.stopCapturing()}l.mux(()=>{c.doc.transact(u=>{u.meta.set("addToHistory",c.addToHistory),l._prosemirrorChanged(a.state.doc)},xt)})}},destroy:()=>{l.destroy()}}}});return o},R8=(n,e,t)=>{if(e!==null&&e.anchor!==null&&e.head!==null){const r=If(t.doc,t.type,e.anchor,t.mapping),s=If(t.doc,t.type,e.head,t.mapping);r!==null&&s!==null&&(n=n.setSelection(Ae.create(n.doc,r,s)))}},vb=(n,e)=>({anchor:pp(e.selection.anchor,n.type,n.mapping),head:pp(e.selection.head,n.type,n.mapping)});class P8{constructor(e,t){this.type=e,this.prosemirrorView=t,this.mux=Yk(),this.isDestroyed=!1,this.mapping=new Map,this._observeFunction=this._typeChanged.bind(this),this.doc=e.doc,this.beforeTransactionSelection=null,this.beforeAllTransactions=()=>{this.beforeTransactionSelection===null&&(this.beforeTransactionSelection=vb(this,t.state))},this.afterAllTransactions=()=>{this.beforeTransactionSelection=null},this.doc.on("beforeAllTransactions",this.beforeAllTransactions),this.doc.on("afterAllTransactions",this.afterAllTransactions),e.observeDeep(this._observeFunction),this._domSelectionInView=null}get _tr(){return this.prosemirrorView.state.tr.setMeta("addToHistory",!1)}_isLocalCursorInView(){return this.prosemirrorView.hasFocus()?(_0&&this._domSelectionInView===null&&(B0(0,()=>{this._domSelectionInView=null}),this._domSelectionInView=this._isDomSelectionInView()),this._domSelectionInView):!1}_isDomSelectionInView(){const e=this.prosemirrorView._root.getSelection(),t=this.prosemirrorView._root.createRange();t.setStart(e.anchorNode,e.anchorOffset),t.setEnd(e.focusNode,e.focusOffset),t.getClientRects().length===0&&t.startContainer&&t.collapsed&&t.selectNodeContents(t.startContainer);const s=t.getBoundingClientRect(),i=E3.documentElement;return s.bottom>=0&&s.right>=0&&s.left<=(window.innerWidth||i.clientWidth||0)&&s.top<=(window.innerHeight||i.clientHeight||0)}renderSnapshot(e,t){t||(t=gC(Zk(),new Map)),this.prosemirrorView.dispatch(this._tr.setMeta(xt,{snapshot:e,prevSnapshot:t}))}unrenderSnapshot(){this.mapping=new Map,this.mux(()=>{const e=this.type.toArray().map(r=>fp(r,this.prosemirrorView.state.schema,this.mapping)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new se(ne.from(e),0,0));t.setMeta(xt,{snapshot:null,prevSnapshot:null}),this.prosemirrorView.dispatch(t)})}_forceRerender(){this.mapping=new Map,this.mux(()=>{const e=this.type.toArray().map(r=>fp(r,this.prosemirrorView.state.schema,this.mapping)).filter(r=>r!==null),t=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new se(ne.from(e),0,0));this.prosemirrorView.dispatch(t.setMeta(xt,{isChangeOrigin:!0,binding:this}))})}_renderSnapshot(e,t,r){e||(e=c4(this.doc)),this.mapping=new Map,this.mux(()=>{this.doc.transact(s=>{const i=r.permanentUserData;i&&i.dss.forEach(c=>{Vi(s,c,u=>{})});const o=(c,u)=>{const f=c==="added"?i.getUserByClientId(u.client):i.getUserByDeletedId(u);return{user:f,type:c,color:N8(r.colorMapping,r.colors,f)}},a=DC(this.type,new Q0(t.ds,e.sv)).map(c=>!c._item.deleted||up(c._item,e)||up(c._item,t)?fp(c,this.prosemirrorView.state.schema,new Map,e,t,o):null).filter(c=>c!==null),l=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new se(ne.from(a),0,0));this.prosemirrorView.dispatch(l.setMeta(xt,{isChangeOrigin:!0}))},xt)})}_typeChanged(e,t){const r=xt.getState(this.prosemirrorView.state);if(e.length===0||r.snapshot!=null||r.prevSnapshot!=null){this.renderSnapshot(r.snapshot,r.prevSnapshot);return}this.mux(()=>{const s=(a,l)=>this.mapping.delete(l);Vi(t,t.deleteSet,a=>{if(a.constructor===ht){const l=a.content.type;l&&this.mapping.delete(l)}}),t.changed.forEach(s),t.changedParentTypes.forEach(s);const i=this.type.toArray().map(a=>pS(a,this.prosemirrorView.state.schema,this.mapping)).filter(a=>a!==null);let o=this._tr.replace(0,this.prosemirrorView.state.doc.content.size,new se(ne.from(i),0,0));R8(o,this.beforeTransactionSelection,this),o=o.setMeta(xt,{isChangeOrigin:!0,isUndoRedoOperation:t.origin instanceof SC}),this.beforeTransactionSelection!==null&&this._isLocalCursorInView()&&o.scrollIntoView(),this.prosemirrorView.dispatch(o)})}_prosemirrorChanged(e){this.doc.transact(()=>{Eb(this.doc,this.type,e,this.mapping),this.beforeTransactionSelection=vb(this,this.prosemirrorView.state)},xt)}destroy(){this.isDestroyed=!0,this.type.unobserveDeep(this._observeFunction),this.doc.off("beforeAllTransactions",this.beforeAllTransactions),this.doc.off("afterAllTransactions",this.afterAllTransactions)}}const pS=(n,e,t,r,s,i)=>{const o=t.get(n);if(o===void 0){if(n instanceof kn)return fp(n,e,t,r,s,i);throw Br()}return o},fp=(n,e,t,r,s,i)=>{const o=[],a=l=>{if(l.constructor===kn){const c=pS(l,e,t,r,s,i);c!==null&&o.push(c)}else{const c=D8(l,e,t,r,s,i);c!==null&&c.forEach(u=>{u!==null&&o.push(u)})}};r===void 0||s===void 0?n.toArray().forEach(a):DC(n,new Q0(s.ds,r.sv)).forEach(a);try{const l=n.getAttributes(r);r!==void 0&&(up(n._item,r)?up(n._item,s)||(l.ychange=i?i("added",n._item.id):{type:"added"}):l.ychange=i?i("removed",n._item.id):{type:"removed"});const c=e.node(n.nodeName,l,o);return t.set(n,c),c}catch{return n.doc.transact(c=>{n._item.delete(c)},xt),t.delete(n),null}},D8=(n,e,t,r,s,i)=>{const o=[],a=n.toDelta(r,s,i);try{for(let l=0;l<a.length;l++){const c=a[l],u=[];for(const f in c.attributes)u.push(e.mark(f,c.attributes[f]));o.push(e.text(c.insert,u))}}catch{return n.doc.transact(c=>{n._item.delete(c)},xt),null}return o},I8=(n,e)=>{const t=new er,r=n.map(s=>({insert:s.text,attributes:bS(s.marks)}));return t.applyDelta(r),e.set(t,n),t},_8=(n,e)=>{const t=new kn(n.type.name);for(const r in n.attrs){const s=n.attrs[r];s!==null&&r!=="ychange"&&t.setAttribute(r,s)}return t.insert(0,dp(n).map(r=>Ab(r,e))),e.set(t,n),t},Ab=(n,e)=>n instanceof Array?I8(n,e):_8(n,e),mS=n=>typeof n=="object"&&n!==null,xb=(n,e)=>{const t=Object.keys(n).filter(s=>n[s]!==null);let r=t.length===Object.keys(e).filter(s=>e[s]!==null).length;for(let s=0;s<t.length&&r;s++){const i=t[s],o=n[i],a=e[i];r=i==="ychange"||o===a||mS(o)&&mS(a)&&xb(o,a)}return r},dp=n=>{const e=n.content.content,t=[];for(let r=0;r<e.length;r++){const s=e[r];if(s.isText){const i=[];for(let o=e[r];r<e.length&&o.isText;o=e[++r])i.push(o);r--,t.push(i)}else t.push(s)}return t},gS=(n,e)=>{const t=n.toDelta();return t.length===e.length&&t.every((r,s)=>r.insert===e[s].text&&D0(r.attributes||{}).length===e[s].marks.length&&e[s].marks.every(i=>xb(r.attributes[i.type.name]||{},i.attrs)))},Pf=(n,e)=>{if(n instanceof kn&&!(e instanceof Array)&&kb(n,e)){const t=dp(e);return n._length===t.length&&xb(n.getAttributes(),e.attrs)&&n.toArray().every((r,s)=>Pf(r,t[s]))}return n instanceof er&&e instanceof Array&&gS(n,e)},hp=(n,e)=>n===e||n instanceof Array&&e instanceof Array&&n.length===e.length&&n.every((t,r)=>e[r]===t),yS=(n,e,t)=>{const r=n.toArray(),s=dp(e),i=s.length,o=r.length,a=zi(o,i);let l=0,c=0,u=!1;for(;l<a;l++){const f=r[l],d=s[l];if(hp(t.get(f),d))u=!0;else if(!Pf(f,d))break}for(;l+c<a;c++){const f=r[o-c-1],d=s[i-c-1];if(hp(t.get(f),d))u=!0;else if(!Pf(f,d))break}return{equalityFactor:l+c,foundMappedChild:u}},L8=n=>{let e="",t=n._start;const r={};for(;t!==null;)t.deleted||(t.countable&&t.content instanceof Fr?e+=t.content.str:t.content instanceof Bt&&(r[t.content.key]=null)),t=t.right;return{str:e,nAttrs:r}},B8=(n,e,t)=>{t.set(n,e);const{nAttrs:r,str:s}=L8(n),i=e.map(c=>({insert:c.text,attributes:Object.assign({},r,bS(c.marks))})),{insert:o,remove:a,index:l}=T8(s,i.map(c=>c.insert).join(""));n.delete(l,a),n.insert(l,o),n.applyDelta(i.map(c=>({retain:c.insert.length,attributes:c.attributes})))},bS=n=>{const e={};return n.forEach(t=>{t.type.name!=="ychange"&&(e[t.type.name]=t.attrs)}),e},Eb=(n,e,t,r)=>{if(e instanceof kn&&e.nodeName!==t.type.name)throw new Error("node name mismatch!");if(r.set(e,t),e instanceof kn){const f=e.getAttributes(),d=t.attrs;for(const h in d)d[h]!==null?f[h]!==d[h]&&h!=="ychange"&&e.setAttribute(h,d[h]):e.removeAttribute(h);for(const h in f)d[h]===void 0&&e.removeAttribute(h)}const s=dp(t),i=s.length,o=e.toArray(),a=o.length,l=zi(i,a);let c=0,u=0;for(;c<l;c++){const f=o[c],d=s[c];if(!hp(r.get(f),d))if(Pf(f,d))r.set(f,d);else break}for(;u+c+1<l;u++){const f=o[a-u-1],d=s[i-u-1];if(!hp(r.get(f),d))if(Pf(f,d))r.set(f,d);else break}n.transact(()=>{for(;a-c-u>0&&i-c-u>0;){const d=o[c],h=s[c],p=o[a-u-1],g=s[i-u-1];if(d instanceof er&&h instanceof Array)gS(d,h)||B8(d,h,r),c+=1;else{let y=d instanceof kn&&kb(d,h),b=p instanceof kn&&kb(p,g);if(y&&b){const x=yS(d,h,r),v=yS(p,g,r);x.foundMappedChild&&!v.foundMappedChild?b=!1:!x.foundMappedChild&&v.foundMappedChild||x.equalityFactor<v.equalityFactor?y=!1:b=!1}y?(Eb(n,d,h,r),c+=1):b?(Eb(n,p,g,r),u+=1):(r.delete(e.get(c)),e.delete(c,1),e.insert(c,[Ab(h,r)]),c+=1)}}const f=a-c-u;if(a===1&&i===0&&o[0]instanceof er?(r.delete(o[0]),o[0].delete(0,o[0].length)):f>0&&(e.slice(c,c+f).forEach(d=>r.delete(d)),e.delete(c,f)),c+u<i){const d=[];for(let h=c;h<i-u;h++)d.push(Ab(s[h],r));e.insert(c,d)}},xt)},kb=(n,e)=>!(e instanceof Array)&&n.nodeName===e.type.name;let Df=null;const F8=()=>{const n=Df;Df=null,n.forEach((e,t)=>{const r=t.state.tr,s=xt.getState(t.state);s&&s.binding&&!s.binding.isDestroyed&&(e.forEach((i,o)=>{r.setMeta(o,i)}),t.dispatch(r))})},U8=(n,e,t)=>{Df||(Df=new Map,B0(0,F8)),Hn(Df,n,En).set(e,t)},pp=(n,e,t)=>{if(n===0)return q0(e,0);let r=e._first===null?null:e._first.content.type;for(;r!==null&&e!==r;){if(r instanceof er){if(r._length>=n)return q0(r,n);if(n-=r._length,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{do r=r._item===null?null:r._item.parent,n--;while(r!==e&&r!==null&&r._item!==null&&r._item.next===null);r!==null&&r!==e&&(r=r._item===null?null:r._item.next.content.type)}}else{const s=(t.get(r)||{nodeSize:0}).nodeSize;if(r._first!==null&&n<s)r=r._first.content.type,n--;else{if(n===1&&r._length===0&&s>1)return new Ef(r._item===null?null:r._item.id,r._item===null?Af(r):null,null);if(n-=s,r._item!==null&&r._item.next!==null)r=r._item.next.content.type;else{if(n===0)return r=r._item===null?r:r._item.parent,new Ef(r._item===null?null:r._item.id,r._item===null?Af(r):null,null);do r=r._item.parent,n--;while(r!==e&&r._item.next===null);r!==e&&(r=r._item.next.content.type)}}}if(r===null)throw gr();if(n===0&&r.constructor!==er&&r!==e)return H8(r._item.parent,r._item)}return q0(e,e._length)},H8=(n,e)=>{let t=null,r=null;return n._item===null?r=Af(n):t=Ne(n._item.id.client,n._item.id.clock),new Ef(t,r,e.id)},If=(n,e,t,r)=>{const s=l4(t,n);if(s===null||s.type!==e&&!xf(e,s.type._item))return null;let i=s.type,o=0;if(i.constructor===er)o=s.index;else if(i._item===null||!i._item.deleted){let a=i._first,l=0;for(;l<i._length&&l<s.index&&a!==null;){if(!a.deleted){const c=a.content.type;l++,c instanceof er?o+=c._length:o+=r.get(c).nodeSize}a=a.right}o+=1}for(;i!==e&&i._item!==null;){const a=i._item.parent;if(a._item===null||!a._item.deleted){o+=1;let l=a._first;for(;l!==null;){const c=l.content.type;if(c===i)break;l.deleted||(c instanceof er?o+=c._length:o+=r.get(c).nodeSize),l=l.right}}i=a}return o-1},j8=(n,e,t)=>n!==e,$8=n=>{const e=document.createElement("span");e.classList.add("ProseMirror-yjs-cursor"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null);const r=document.createTextNode(""),s=document.createTextNode("");return e.insertBefore(r,null),e.insertBefore(t,null),e.insertBefore(s,null),e},wS=n=>({style:`background-color: ${n.color}70`,class:"ProseMirror-yjs-selection"}),z8=/^#[0-9a-fA-F]{6}$/,vS=(n,e,t,r,s)=>{const i=xt.getState(n),o=i.doc,a=[];return i.snapshot!=null||i.prevSnapshot!=null||i.binding===null?ft.create(n.doc,[]):(e.getStates().forEach((l,c)=>{if(t(o.clientID,c,l)&&l.cursor!=null){const u=l.user||{};u.color==null?u.color="#ffa500":z8.test(u.color)||console.warn("A user uses an unsupported color format",u),u.name==null&&(u.name=`User: ${c}`);let f=If(o,i.type,kf(l.cursor.anchor),i.binding.mapping),d=If(o,i.type,kf(l.cursor.head),i.binding.mapping);if(f!==null&&d!==null){const h=Ks(n.doc.content.size-1,0);f=zi(f,h),d=zi(d,h),a.push(Ht.widget(d,()=>r(u),{key:c+"",side:10}));const p=zi(f,d),g=Ks(f,d);a.push(Ht.inline(p,g,s(u),{inclusiveEnd:!0,inclusiveStart:!1}))}}}),ft.create(n.doc,a))},V8=(n,{awarenessStateFilter:e=j8,cursorBuilder:t=$8,selectionBuilder:r=wS,getSelection:s=o=>o.selection}={},i="cursor")=>new ut({key:cp,state:{init(o,a){return vS(a,n,e,t,r)},apply(o,a,l,c){const u=xt.getState(c),f=o.getMeta(cp);return u&&u.isChangeOrigin||f&&f.awarenessUpdated?vS(c,n,e,t,r):a.map(o.mapping,o.doc)}},props:{decorations:o=>cp.getState(o)},view:o=>{const a=()=>{o.docView&&U8(o,cp,{awarenessUpdated:!0})},l=()=>{const c=xt.getState(o.state),u=n.getLocalState()||{};if(c.binding!=null)if(o.hasFocus()){const f=s(o.state),d=pp(f.anchor,c.type,c.binding.mapping),h=pp(f.head,c.type,c.binding.mapping);(u.cursor==null||!mC(kf(u.cursor.anchor),d)||!mC(kf(u.cursor.head),h))&&n.setLocalStateField(i,{anchor:d,head:h})}else u.cursor!=null&&If(c.doc,c.type,kf(u.cursor.anchor),c.binding.mapping)!==null&&n.setLocalStateField(i,null)};return n.on("change",a),o.dom.addEventListener("focusin",l),o.dom.addEventListener("focusout",l),{update:l,destroy:()=>{o.dom.removeEventListener("focusin",l),o.dom.removeEventListener("focusout",l),n.off("change",a),n.setLocalStateField(i,null)}}}}),W8=n=>{const e=Xs.getState(n).undoManager;if(e!=null)return e.undo(),!0},G8=n=>{const e=Xs.getState(n).undoManager;if(e!=null)return e.redo(),!0},K8=new Set(["paragraph"]),J8=(n,e)=>!(n instanceof ht)||!(n.content instanceof Ur)||!(n.content.type instanceof ia||n.content.type instanceof kn&&e.has(n.content.type.nodeName))||n.content.type._length===0,q8=({protectedNodes:n=K8,trackedOrigins:e=[],undoManager:t=null}={})=>new ut({key:Xs,state:{init:(r,s)=>{const i=xt.getState(s),o=t||new SC(i.type,{trackedOrigins:new Set([xt].concat(e)),deleteFilter:a=>J8(a,n),captureTransaction:a=>a.meta.get("addToHistory")!==!1});return{undoManager:o,prevSel:null,hasUndoOps:o.undoStack.length>0,hasRedoOps:o.redoStack.length>0}},apply:(r,s,i,o)=>{const a=xt.getState(o).binding,l=s.undoManager,c=l.undoStack.length>0,u=l.redoStack.length>0;return a?{undoManager:l,prevSel:vb(a,i),hasUndoOps:c,hasRedoOps:u}:c!==s.hasUndoOps||u!==s.hasRedoOps?Object.assign({},s,{hasUndoOps:l.undoStack.length>0,hasRedoOps:l.redoStack.length>0}):s}},view:r=>{const s=xt.getState(r.state),i=Xs.getState(r.state).undoManager;return i.on("stack-item-added",({stackItem:o})=>{const a=s.binding;a&&o.meta.set(a,Xs.getState(r.state).prevSel)}),i.on("stack-item-popped",({stackItem:o})=>{const a=s.binding;a&&(a.beforeTransactionSelection=o.meta.get(a)||a.beforeTransactionSelection)}),{destroy:()=>{i.destroy()}}}}),Q8=bt.create({name:"collaboration",priority:1e3,addOptions(){return{document:null,field:"default",fragment:null}},onCreate(){this.editor.extensionManager.extensions.find(n=>n.name==="history")&&console.warn('[tiptap warn]: "@tiptap/extension-collaboration" comes with its own history support and is not compatible with "@tiptap/extension-history".')},addCommands(){return{undo:()=>({tr:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),Xs.getState(e).undoManager.undoStack.length===0?!1:t?W8(e):!0),redo:()=>({tr:n,state:e,dispatch:t})=>(n.setMeta("preventDispatch",!0),Xs.getState(e).undoManager.redoStack.length===0?!1:t?G8(e):!0)}},addKeyboardShortcuts(){return{"Mod-z":()=>this.editor.commands.undo(),"Mod-y":()=>this.editor.commands.redo(),"Shift-Mod-z":()=>this.editor.commands.redo()}},addProseMirrorPlugins(){const n=this.options.fragment?this.options.fragment:this.options.document.getXmlFragment(this.options.field),e=q8(),t=e.spec.view;e.spec.view=a=>{const{undoManager:l}=Xs.getState(a.state);l.restore&&(l.restore(),l.restore=()=>{});const c=t?t(a):void 0;return{destroy:()=>{const u=l.trackedOrigins.has(l),f=l._observers;l.restore=()=>{u&&l.trackedOrigins.add(l),l.doc.on("afterTransaction",l.afterTransactionHandler),l._observers=f},c!=null&&c.destroy&&c.destroy()}}};const r=this.options.ySyncOptions,s=this.options.onFirstRender,i={...r?{...r}:{},...s?{onFirstRender:s}:{}};return[M8(n,i),e]}}),AS=n=>Array.from(n.entries()).map(([e,t])=>({clientId:e,...t.user})),xS=()=>null,Y8=bt.create({name:"collaborationCursor",addOptions(){return{provider:null,user:{name:null,color:null},render:n=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");return t.classList.add("collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null),e.insertBefore(t,null),e},selectionRender:wS,onUpdate:xS}},onCreate(){this.options.onUpdate!==xS&&console.warn('[tiptap warn]: DEPRECATED: The "onUpdate" option is deprecated. Please use `editor.storage.collaborationCursor.users` instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor')},addStorage(){return{users:[]}},addCommands(){return{updateUser:n=>()=>(this.options.user=n,this.options.provider.awareness.setLocalStateField("user",this.options.user),!0),user:n=>({editor:e})=>(console.warn('[tiptap warn]: DEPRECATED: The "user" command is deprecated. Please use "updateUser" instead. Read more: https://tiptap.dev/api/extensions/collaboration-cursor'),e.commands.updateUser(n))}},addProseMirrorPlugins(){return[V8((this.options.provider.awareness.setLocalStateField("user",this.options.user),this.storage.users=AS(this.options.provider.awareness.states),this.options.provider.awareness.on("update",()=>{this.storage.users=AS(this.options.provider.awareness.states)}),this.options.provider.awareness),{cursorBuilder:this.options.render,selectionBuilder:this.options.selectionRender})]}}),X8=/^\s*>\s$/,Z8=dt.create({name:"blockquote",addOptions(){return{HTMLAttributes:{}}},content:"block+",group:"block",defining:!0,parseHTML(){return[{tag:"blockquote"}]},renderHTML({HTMLAttributes:n}){return["blockquote",Ue(this.options.HTMLAttributes,n),0]},addCommands(){return{setBlockquote:()=>({commands:n})=>n.wrapIn(this.name),toggleBlockquote:()=>({commands:n})=>n.toggleWrap(this.name),unsetBlockquote:()=>({commands:n})=>n.lift(this.name)}},addKeyboardShortcuts(){return{"Mod-Shift-b":()=>this.editor.commands.toggleBlockquote()}},addInputRules(){return[xl({find:X8,type:this.type})]}}),e6=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))$/,t6=/(?:^|\s)(\*\*(?!\s+\*\*)((?:[^*]+))\*\*(?!\s+\*\*))/g,n6=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))$/,r6=/(?:^|\s)(__(?!\s+__)((?:[^_]+))__(?!\s+__))/g,s6=Bn.create({name:"bold",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"strong"},{tag:"b",getAttrs:n=>n.style.fontWeight!=="normal"&&null},{style:"font-weight",getAttrs:n=>/^(bold(er)?|[5-9]\d{2,})$/.test(n)&&null}]},renderHTML({HTMLAttributes:n}){return["strong",Ue(this.options.HTMLAttributes,n),0]},addCommands(){return{setBold:()=>({commands:n})=>n.setMark(this.name),toggleBold:()=>({commands:n})=>n.toggleMark(this.name),unsetBold:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-b":()=>this.editor.commands.toggleBold(),"Mod-B":()=>this.editor.commands.toggleBold()}},addInputRules(){return[Ko({find:e6,type:this.type}),Ko({find:n6,type:this.type})]},addPasteRules(){return[ji({find:t6,type:this.type}),ji({find:r6,type:this.type})]}}),i6=dt.create({name:"listItem",addOptions(){return{HTMLAttributes:{},bulletListTypeName:"bulletList",orderedListTypeName:"orderedList"}},content:"paragraph block*",defining:!0,parseHTML(){return[{tag:"li"}]},renderHTML({HTMLAttributes:n}){return["li",Ue(this.options.HTMLAttributes,n),0]},addKeyboardShortcuts(){return{Enter:()=>this.editor.commands.splitListItem(this.name),Tab:()=>this.editor.commands.sinkListItem(this.name),"Shift-Tab":()=>this.editor.commands.liftListItem(this.name)}}}),ES=Bn.create({name:"textStyle",addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:"span",getAttrs:n=>n.hasAttribute("style")?{}:!1}]},renderHTML({HTMLAttributes:n}){return["span",Ue(this.options.HTMLAttributes,n),0]},addCommands(){return{removeEmptyTextStyle:()=>({state:n,commands:e})=>{const t=Xu(n,this.type);return Object.entries(t).some(([,s])=>!!s)?!0:e.unsetMark(this.name)}}}}),kS=/^\s*([-+*])\s$/,o6=dt.create({name:"bulletList",addOptions(){return{itemTypeName:"listItem",HTMLAttributes:{},keepMarks:!1,keepAttributes:!1}},group:"block list",content(){return`${this.options.itemTypeName}+`},parseHTML(){return[{tag:"ul"}]},renderHTML({HTMLAttributes:n}){return["ul",Ue(this.options.HTMLAttributes,n),0]},addCommands(){return{toggleBulletList:()=>({commands:n,chain:e})=>this.options.keepAttributes?e().toggleList(this.name,this.options.itemTypeName,this.options.keepMarks).updateAttributes(i6.name,this.editor.getAttributes(ES.name)).run():n.toggleList(this.name,this.options.itemTypeName,this.options.keepMarks)}},addKeyboardShortcuts(){return{"Mod-Shift-8":()=>this.editor.commands.toggleBulletList()}},addInputRules(){let n=xl({find:kS,type:this.type});return(this.options.keepMarks||this.options.keepAttributes)&&(n=xl({find:kS,type:this.type,keepMarks:this.options.keepMarks,keepAttributes:this.options.keepAttributes,getAttributes:()=>this.editor.getAttributes(ES.name),editor:this.editor})),[n]}}),a6=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))$/,l6=/(?:^|\s)(`(?!\s+`)((?:[^`]+))`(?!\s+`))/g,c6=Bn.create({name:"code",addOptions(){return{HTMLAttributes:{}}},excludes:"_",code:!0,exitable:!0,parseHTML(){return[{tag:"code"}]},renderHTML({HTMLAttributes:n}){return["code",Ue(this.options.HTMLAttributes,n),0]},addCommands(){return{setCode:()=>({commands:n})=>n.setMark(this.name),toggleCode:()=>({commands:n})=>n.toggleMark(this.name),unsetCode:()=>({commands:n})=>n.unsetMark(this.name)}},addKeyboardShortcuts(){return{"Mod-e":()=>this.editor.commands.toggleCode()}},addInputRules(){return[Ko({find:a6,type:this.type})]},addPasteRules(){return[ji({find:l6,type:this.type})]}}),u6=/^```([a-z]+)?[\s\n]$/,f6=/^~~~([a-z]+)?[\s\n]$/,d6=dt.create({name:"codeBlock",addOptions(){return{languageClassPrefix:"language-",exitOnTripleEnter:!0,exitOnArrowDown:!0,HTMLAttributes:{}}},content:"text*",marks:"",group:"block",code:!0,defining:!0,addAttributes(){return{language:{default:null,parseHTML:n=>{var e;const{languageClassPrefix:t}=this.options,i=[...((e=n.firstElementChild)===null||e===void 0?void 0:e.classList)||[]].filter(o=>o.startsWith(t)).map(o=>o.replace(t,""))[0];return i||null},rendered:!1}}},parseHTML(){return[{tag:"pre",preserveWhitespace:"full"}]},renderHTML({node:n,HTMLAttributes:e}){return["pre",Ue(this.options.HTMLAttributes,e),["code",{class:n.attrs.language?this.options.languageClassPrefix+n.attrs.language:null},0]]},addCommands(){return{setCodeBlock:n=>({commands:e})=>e.setNode(this.name,n),toggleCodeBlock:n=>({commands:e})=>e.toggleNode(this.name,"paragraph",n)}},addKeyboardShortcuts(){return{"Mod-Alt-c":()=>this.editor.commands.toggleCodeBlock(),Backspace:()=>{const{empty:n,$anchor:e}=this.editor.state.selection,t=e.pos===1;return!n||e.parent.type.name!==this.name?!1:t||!e.parent.textContent.length?this.editor.commands.clearNodes():!1},Enter:({editor:n})=>{if(!this.options.exitOnTripleEnter)return!1;const{state:e}=n,{selection:t}=e,{$from:r,empty:s}=t;if(!s||r.parent.type!==this.type)return!1;const i=r.parentOffset===r.parent.nodeSize-2,o=r.parent.textContent.endsWith(`
|
@@ -421,4 +421,4 @@ Use Chrome, Firefox or Internet Explorer 11`)}}).call(this)}).call(this,i("_proc
|
|
421
421
|
.block-interactivity-`.concat(n,` {pointer-events: none;}
|
422
422
|
.allow-interactivity-`).concat(n,` {pointer-events: all;}
|
423
423
|
`)},vj=0,sc=[];function Aj(n){var e=ge.useRef([]),t=ge.useRef([0,0]),r=ge.useRef(),s=ge.useState(vj++)[0],i=ge.useState(function(){return zT()})[0],o=ge.useRef(n);ge.useEffect(function(){o.current=n},[n]),ge.useEffect(function(){if(n.inert){document.body.classList.add("block-interactivity-".concat(s));var g=$H([n.lockRef.current],(n.shards||[]).map(QT),!0).filter(Boolean);return g.forEach(function(y){return y.classList.add("allow-interactivity-".concat(s))}),function(){document.body.classList.remove("block-interactivity-".concat(s)),g.forEach(function(y){return y.classList.remove("allow-interactivity-".concat(s))})}}},[n.inert,n.lockRef.current,n.shards]);var a=ge.useCallback(function(g,y){if("touches"in g&&g.touches.length===2)return!o.current.allowPinchZoom;var b=pm(g),x=t.current,v="deltaX"in g?g.deltaX:x[0]-b[0],w="deltaY"in g?g.deltaY:x[1]-b[1],E,C=g.target,T=Math.abs(v)>Math.abs(w)?"h":"v";if("touches"in g&&T==="h"&&C.type==="range")return!1;var N=GT(T,C);if(!N)return!0;if(N?E=T:(E=T==="v"?"h":"v",N=GT(T,C)),!N)return!1;if(!r.current&&"changedTouches"in g&&(v||w)&&(r.current=E),!E)return!0;var M=r.current||E;return yj(M,y,g,M==="h"?v:w,!0)},[]),l=ge.useCallback(function(g){var y=g;if(!(!sc.length||sc[sc.length-1]!==i)){var b="deltaY"in y?qT(y):pm(y),x=e.current.filter(function(E){return E.name===y.type&&E.target===y.target&&bj(E.delta,b)})[0];if(x&&x.should){y.cancelable&&y.preventDefault();return}if(!x){var v=(o.current.shards||[]).map(QT).filter(Boolean).filter(function(E){return E.contains(y.target)}),w=v.length>0?a(y,v[0]):!o.current.noIsolation;w&&y.cancelable&&y.preventDefault()}}},[]),c=ge.useCallback(function(g,y,b,x){var v={name:g,delta:y,target:b,should:x};e.current.push(v),setTimeout(function(){e.current=e.current.filter(function(w){return w!==v})},1)},[]),u=ge.useCallback(function(g){t.current=pm(g),r.current=void 0},[]),f=ge.useCallback(function(g){c(g.type,qT(g),g.target,a(g,n.lockRef.current))},[]),d=ge.useCallback(function(g){c(g.type,pm(g),g.target,a(g,n.lockRef.current))},[]);ge.useEffect(function(){return sc.push(i),n.setCallbacks({onScrollCapture:f,onWheelCapture:f,onTouchMoveCapture:d}),document.addEventListener("wheel",l,rc),document.addEventListener("touchmove",l,rc),document.addEventListener("touchstart",u,rc),function(){sc=sc.filter(function(g){return g!==i}),document.removeEventListener("wheel",l,rc),document.removeEventListener("touchmove",l,rc),document.removeEventListener("touchstart",u,rc)}},[]);var h=n.removeScrollBar,p=n.inert;return ge.createElement(ge.Fragment,null,p?ge.createElement(i,{styles:wj(s)}):null,h?ge.createElement(uj,{gapMode:"margin"}):null)}const xj=YH($T,Aj);var YT=ge.forwardRef(function(n,e){return ge.createElement(dm,ks({},n,{ref:e,sideCar:xj}))});YT.classNames=dm.classNames;const XT="Popover",[ZT,nK]=nT(XT,[PT]),mw=PT(),[Ej,ic]=ZT(XT),kj=n=>{const{__scopePopover:e,children:t,open:r,defaultOpen:s,onOpenChange:i,modal:o=!1}=n,a=mw(e),l=R.useRef(null),[c,u]=R.useState(!1),[f=!1,d]=LH({prop:r,defaultProp:s,onChange:i});return R.createElement(RH,a,R.createElement(Ej,{scope:e,contentId:wU(),triggerRef:l,open:f,onOpenChange:d,onOpenToggle:R.useCallback(()=>d(h=>!h),[d]),hasCustomAnchor:c,onCustomAnchorAdd:R.useCallback(()=>u(!0),[]),onCustomAnchorRemove:R.useCallback(()=>u(!1),[]),modal:o},t))},Cj="PopoverTrigger",Sj=R.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=ic(Cj,t),i=mw(t),o=da(e,s.triggerRef),a=R.createElement(ha.button,jt({type:"button","aria-haspopup":"dialog","aria-expanded":s.open,"aria-controls":s.contentId,"data-state":t2(s.open)},r,{ref:o,onClick:Xi(n.onClick,s.onOpenToggle)}));return s.hasCustomAnchor?a:R.createElement(PH,jt({asChild:!0},i),a)}),Tj="PopoverPortal",[rK,Oj]=ZT(Tj,{forceMount:void 0}),zf="PopoverContent",Nj=R.forwardRef((n,e)=>{const t=Oj(zf,n.__scopePopover),{forceMount:r=t.forceMount,...s}=n,i=ic(zf,n.__scopePopover);return R.createElement(BT,{present:r||i.open},i.modal?R.createElement(Mj,jt({},s,{ref:e})):R.createElement(Rj,jt({},s,{ref:e})))}),Mj=R.forwardRef((n,e)=>{const t=ic(zf,n.__scopePopover),r=R.useRef(null),s=da(e,r),i=R.useRef(!1);return R.useEffect(()=>{const o=r.current;if(o)return jH(o)},[]),R.createElement(YT,{as:Jb,allowPinchZoom:!0},R.createElement(e2,jt({},n,{ref:s,trapFocus:t.open,disableOutsidePointerEvents:!0,onCloseAutoFocus:Xi(n.onCloseAutoFocus,o=>{var a;o.preventDefault(),i.current||(a=t.triggerRef.current)===null||a===void 0||a.focus()}),onPointerDownOutside:Xi(n.onPointerDownOutside,o=>{const a=o.detail.originalEvent,l=a.button===0&&a.ctrlKey===!0,c=a.button===2||l;i.current=c},{checkForDefaultPrevented:!1}),onFocusOutside:Xi(n.onFocusOutside,o=>o.preventDefault(),{checkForDefaultPrevented:!1})})))}),Rj=R.forwardRef((n,e)=>{const t=ic(zf,n.__scopePopover),r=R.useRef(!1),s=R.useRef(!1);return R.createElement(e2,jt({},n,{ref:e,trapFocus:!1,disableOutsidePointerEvents:!1,onCloseAutoFocus:i=>{var o;if((o=n.onCloseAutoFocus)===null||o===void 0||o.call(n,i),!i.defaultPrevented){var a;r.current||(a=t.triggerRef.current)===null||a===void 0||a.focus(),i.preventDefault()}r.current=!1,s.current=!1},onInteractOutside:i=>{var o,a;(o=n.onInteractOutside)===null||o===void 0||o.call(n,i),i.defaultPrevented||(r.current=!0,i.detail.originalEvent.type==="pointerdown"&&(s.current=!0));const l=i.target;((a=t.triggerRef.current)===null||a===void 0?void 0:a.contains(l))&&i.preventDefault(),i.detail.originalEvent.type==="focusin"&&s.current&&i.preventDefault()}}))}),e2=R.forwardRef((n,e)=>{const{__scopePopover:t,trapFocus:r,onOpenAutoFocus:s,onCloseAutoFocus:i,disableOutsidePointerEvents:o,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onInteractOutside:u,...f}=n,d=ic(zf,t),h=mw(t);return cU(),R.createElement(uU,{asChild:!0,loop:!0,trapped:r,onMountAutoFocus:s,onUnmountAutoFocus:i},R.createElement(oU,{asChild:!0,disableOutsidePointerEvents:o,onInteractOutside:u,onEscapeKeyDown:a,onPointerDownOutside:l,onFocusOutside:c,onDismiss:()=>d.onOpenChange(!1)},R.createElement(DH,jt({"data-state":t2(d.open),role:"dialog",id:d.contentId},h,f,{ref:e,style:{...f.style,"--radix-popover-content-transform-origin":"var(--radix-popper-transform-origin)","--radix-popover-content-available-width":"var(--radix-popper-available-width)","--radix-popover-content-available-height":"var(--radix-popper-available-height)","--radix-popover-trigger-width":"var(--radix-popper-anchor-width)","--radix-popover-trigger-height":"var(--radix-popper-anchor-height)"}}))))}),Pj="PopoverClose",Dj=R.forwardRef((n,e)=>{const{__scopePopover:t,...r}=n,s=ic(Pj,t);return R.createElement(ha.button,jt({type:"button"},r,{ref:e,onClick:Xi(n.onClick,()=>s.onOpenChange(!1))}))});function t2(n){return n?"open":"closed"}const Ij=kj,_j=Sj,Lj=Nj,mm=Dj,gm=({children:n,isActive:e,onClick:t,disabled:r,className:s})=>{const i=je("flex items-center gap-2 p-1.5 text-xs font-medium text-neutral-500 text-left w-full rounded-md border border-transparent transition-all",!e&&!r,"hover:border-neutral-200 hover:bg-neutral-100",e&&!r&&"bg-neutral-200 text-neutral-800",r&&"text-neutral-300 cursor-not-allowed",s);return _.jsx("button",{className:i,disabled:r,onClick:t,children:n})},Bj=(n,e,t)=>{const r=R.useCallback(()=>{const a=n.chain();a.setNodeSelection(t).unsetAllMarks(),(e==null?void 0:e.type.name)!=="paragraph"&&a.setParagraph(),a.run()},[n,t,e==null?void 0:e.type.name]),s=R.useCallback(()=>{n.commands.setNodeSelection(t);const{$anchor:a}=n.state.selection,l=a.node(1)||n.state.selection.node;n.chain().setMeta("hideDragHandle",!0).insertContentAt(t+((e==null?void 0:e.nodeSize)||0),l.toJSON()).run()},[n,t,e==null?void 0:e.nodeSize]),i=R.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).run(),document.execCommand("copy"),alert("copied")},[n,t]),o=R.useCallback(()=>{n.chain().setMeta("hideDragHandle",!0).setNodeSelection(t).deleteSelection().run()},[n,t]);return{resetTextFormatting:r,duplicateNode:s,copyNodeToClipboard:i,deleteNode:o}},Fj=({node:n,getPos:e,editor:t,deleteNode:r})=>{const[s,i]=R.useState(!1),o=Bj(t,n,e()),a=Lh(),l=["https://twitter.com","https://x.com"],c=R.useMemo(()=>{const{content:M}=n.content;return M[0].type.name==="table"},[n.content]),u=R.useMemo(()=>{var O;const{content:M}=n.content;return(O=M[0].content.content[0])==null?void 0:O.text},[n.content]),f=R.useMemo(()=>{var O;const{content:M}=n.content;return(O=M[0].content.content[1])==null?void 0:O.text},[n.content]),d=R.useMemo(()=>{const{content:M}=n.content;return M[0].content.content.find(O=>{var I;return(I=O==null?void 0:O.text)==null?void 0:I.match(/\/status\/([0-9]*)/)})},[n.content]),h=()=>{if(!u)return;let M=u;if(u.includes("<iframe"))M=f;else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(u):{const J=u.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);J&&J.length>0&&(M=`https://www.youtube.com/embed/${J[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(u):{const J=u.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);J&&J.length>0&&(M=`https://player.vimeo.com/video/${J[1]}`);break}default:return}const O=640,I=360,L=e(),$=L+n.nodeSize;M&&(t==null||t.chain().focus(L).deleteRange({from:L===0?L:L+1,to:$}).setIframe({src:M,width:O,height:I}).run())},p=M=>{const O=M.match(/\/status\/([0-9]*)/);return O&&O.length>0?O[1]:null},g=()=>{if(!u)return;let M=u;const O=l.some(J=>u.includes(J)),I=p(u);O&&I?M=I:d&&(M=p(d.text));const L=e(),$=L+n.nodeSize;M&&(t==null||t.chain().focus(L).deleteRange({from:L===2?L:L+1,to:$}).setTweetEmbed({tweetId:M}).run())},y=()=>{const M=e()+n.nodeSize;t.commands.insertContentAt(M,{type:"dBlock",content:[{type:"paragraph"}]})},b=()=>{const M=e();t.commands.insertContentAt(M,{type:"dBlock",content:[{type:"paragraph"}]})},x=()=>{r()},v=M=>{M.altKey?E():w()},w=()=>{y()},E=()=>{b()},C=M=>{M.altKey&&x()},N=Kb(()=>{if(l.some(M=>u.includes(M))||d!=null&&d.text){g();return}else{h();return}},1e3);return R.useEffect(()=>{u&&N()},[u]),_.jsxs(uf,{as:"div",className:je("flex gap-2 group w-full relative justify-center items-start",a&&"pointer-events-none",c&&"2xl:ml-4 pointer-events-auto"),children:[_.jsxs("section",{className:"lg:flex gap-1 hidden","aria-label":"left-menu",contentEditable:!1,children:[_.jsx(uk,{content:_.jsxs("div",{className:"flex flex-col w-40",children:[_.jsx("div",{className:"text-xs",children:"Click to add below"}),_.jsx("div",{className:"text-xs",children:"Opt + Click to add above"})]}),children:_.jsx("div",{className:`d-block-button cursor-pointer ${!a&&"group-hover:opacity-100"}`,contentEditable:!1,onClick:v,children:_.jsx(nF,{size:18})})}),_.jsxs(Ij,{open:s,onOpenChange:i,children:[_.jsx(_j,{asChild:!0,children:_.jsx("div",{className:`d-block-button cursor-pointer ${!a&&"group-hover:opacity-100"}`,contentEditable:!1,draggable:!0,"data-drag-handle":!0,onClick:C,children:_.jsx(QB,{size:18})})}),_.jsx(Lj,{side:"bottom",align:"start",sideOffset:8,className:"z-10",children:_.jsxs(p0,{className:"p-2 flex flex-col min-w-[16rem]",children:[_.jsx(mm,{children:_.jsxs(gm,{onClick:o.resetTextFormatting,children:[_.jsx(rF,{size:18}),"Clear formatting"]})}),_.jsx(mm,{children:_.jsxs(gm,{onClick:o.copyNodeToClipboard,children:[_.jsx(GB,{size:18}),"Copy to clipboard"]})}),_.jsx(mm,{children:_.jsxs(gm,{onClick:o.duplicateNode,children:[_.jsx(JB,{size:18}),"Duplicate"]})}),_.jsx(df.Divider,{horizontal:!0}),_.jsx(mm,{children:_.jsxs(gm,{onClick:o.deleteNode,className:"text-red-500 hover:bg-red-500 bg-opacity-10 hover:bg-opacity-20",children:[_.jsx(oF,{size:18}),"Delete"]})})]})})]})]}),_.jsx(IE,{className:je("node-view-content w-full",{"is-table min-w-auto":c})})]})},Uj=dt.create({name:"dBlock",priority:1e3,group:"dBlock",content:"(block|columns)",draggable:!0,selectable:!1,inline:!1,addOptions(){return{HTMLAttributes:{}}},parseHTML(){return[{tag:'div[data-type="d-block"]'}]},renderHTML({HTMLAttributes:n}){return["div",Ue(n,{"data-type":"d-block"}),0]},addCommands(){return{setDBlock:n=>({state:e,chain:t})=>{const{selection:{from:r}}=e,s=n!==void 0||n!==null?r:n;return t().insertContentAt(s,{type:this.name,content:[{type:"paragraph"}]}).focus(s+2).run()},mergeDBlocksIntoList:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:s}=e.selection;let i=e.tr;const o=[];if(e.doc.nodesBetween(r,s,l=>{if(l.type.name===this.name){const c=e.schema.nodes.listItem.create(null,l.content);c&&o.push(c)}}),o.length===0)return!1;const a=e.schema.nodes[n].create(null,o);return a?(i=i.replaceRangeWith(r,s,a),t(i),!0):!1},splitListToDBlocks:n=>({state:e,dispatch:t})=>{if(!t)throw new Error("Dispatch function is not provided.");const{from:r,to:s}=e.selection;let i=e.tr;return e.doc.nodesBetween(r,s,(o,a)=>{if(o.type.name===n){const l=e.schema.nodes[this.name].create(null,o.content);i=i.insert(a,l)}}),t(i),!0}}},addNodeView(){return Xo(Fj)},addKeyboardShortcuts(){return{"Mod-Alt-0":()=>this.editor.commands.setDBlock(),Enter:({editor:n})=>{var c;const{selection:{$head:e,from:t,to:r},doc:s}=n.state,i=e.node(e.depth-1);if((i==null?void 0:i.type.name)!=="dBlock")return!1;let o=-1,a="";s.descendants((u,f)=>{if(o!==-1)return!1;if(u.type.name===this.name)return;const[d,h]=[f,f+u.nodeSize];return d<=t&&r<=h&&(o=h,a=u.type.name),!1});const l=(c=s.slice(t,o))==null?void 0:c.toJSON().content;try{return a==="codeBlock"?n.chain().insertContentAt({from:t,to:o},`
|
424
|
-
`).focus(o+1).run():["columns","heading"].includes(a)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:o},{type:this.name,content:l}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let gw,yw;if(typeof WeakMap<"u"){let n=new WeakMap;gw=e=>n.get(e),yw=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;gw=r=>{for(let s=0;s<n.length;s+=2)if(n[s]==r)return n[s+1]},yw=(r,s)=>(t==e&&(t=0),n[t++]=r,n[t++]=s)}class oc{constructor(e,t,r,s){this.left=e,this.top=t,this.right=r,this.bottom=s}}class Ot{constructor(e,t,r,s){this.width=e,this.height=t,this.map=r,this.problems=s}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let s=t%this.width,i=t/this.width|0,o=s+1,a=i+1;for(let l=1;o<this.width&&this.map[t+l]==r;l++)o++;for(let l=1;a<this.height&&this.map[t+this.width*l]==r;l++)a++;return new oc(s,i,o,a)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:s,right:i,top:o,bottom:a}=this.findCell(e);return t=="horiz"?(r<0?s==0:i==this.width)?null:this.map[o*this.width+(r<0?s-1:i)]:(r<0?o==0:a==this.height)?null:this.map[s+this.width*(r<0?o-1:a)]}rectBetween(e,t){let{left:r,right:s,top:i,bottom:o}=this.findCell(e),{left:a,right:l,top:c,bottom:u}=this.findCell(t);return new oc(Math.min(r,a),Math.min(i,c),Math.max(s,l),Math.max(o,u))}cellsInRect(e){let t=[],r={};for(let s=e.top;s<e.bottom;s++)for(let i=e.left;i<e.right;i++){let o=s*this.width+i,a=this.map[o];r[a]||(r[a]=!0,(i!=e.left||!i||this.map[o-1]!=a)&&(s!=e.top||!s||this.map[o-this.width]!=a)&&t.push(a))}return t}positionAt(e,t,r){for(let s=0,i=0;;s++){let o=i+r.child(s).nodeSize;if(s==e){let a=t+e*this.width,l=(e+1)*this.width;for(;a<l&&this.map[a]<i;)a++;return a==l?o-1:this.map[a]}i=o}}static get(e){return gw(e)||yw(e,Hj(e))}}function Hj(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=jj(n),t=n.childCount,r=[],s=0,i=null,o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let f=n.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==f.childCount)break;let g=f.child(p),{colspan:y,rowspan:b,colwidth:x}=g.attrs;for(let v=0;v<b;v++){if(v+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:b-v});break}let w=s+v*e;for(let E=0;E<y;E++){r[w+E]==0?r[w+E]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:y-E});let C=x&&x[E];if(C){let T=(w+E)%e*2,N=o[T];N==null||N!=C&&o[T+1]==1?(o[T]=C,o[T+1]=1):N==C&&o[T+1]++}}}s+=y,u+=g.nodeSize}let d=(c+1)*e,h=0;for(;s<d;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}let a=new Ot(e,t,r,i),l=!1;for(let c=0;!l&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(l=!0);return l&&$j(a,o,n),a}function jj(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let s=n.child(r),i=0;if(t)for(let o=0;o<r;o++){let a=n.child(o);for(let l=0;l<a.childCount;l++){let c=a.child(l);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){let a=s.child(o);i+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function $j(n,e,t){n.problems||(n.problems=[]);for(let r=0,s={};r<n.map.length;r++){let i=n.map[r];if(s[i])continue;s[i]=!0;let o=t.nodeAt(i),a=null;for(let l=0;l<o.attrs.colspan;l++){let c=(r+l)%n.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[l]!=u)&&((a||(a=zj(o.attrs)))[l]=u)}a&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function zj(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function hn(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const ro=new vt("selectingCells");function ac(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function Vj(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function $r(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function ym(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:ac(e.$head)||Wj(e.$head)}function Wj(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function bw(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function Gj(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function ww(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function n2(n,e,t){let r=n.start(-1),i=Ot.get(n.node(-1)).nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function Xt(n,e,t){let r={};for(let s in n)r[s]=n[s];return r[e]=t,r}function ma(n,e,t=1){let r=Xt(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function r2(n,e,t=1){let r=Xt(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<t;s++)r.colwidth.splice(e,0,0)}return r}function Kj(n,e,t){let r=hn(e.type.schema).header_cell;for(let s=0;s<n.height;s++)if(e.nodeAt(n.map[t+s*n.width]).type!=r)return!1;return!0}class ze extends xe{constructor(e,t=e){let r=e.node(-1),s=Ot.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,t.pos-i),a=e.node(0),l=s.cellsInRect(o).filter(u=>u!=t.pos-i);l.unshift(t.pos-i);let c=l.map(u=>{let f=r.nodeAt(u),d=u+i+1;return new Xg(a.resolve(d),a.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(bw(r)&&bw(s)&&ww(r,s)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?ze.rowSelection(r,s):i&&this.isColSelection()?ze.colSelection(r,s):new ze(r,s)}return Ae.between(r,s)}content(){let e=this.$anchorCell.node(-1),t=Ot.get(e),r=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let l=s.top;l<s.bottom;l++){let c=[];for(let u=l*t.width+s.left,f=s.left;f<s.right;f++,u++){let d=t.map[u];if(!i[d]){i[d]=!0;let h=t.findCell(d),p=e.nodeAt(d),g=s.left-h.left,y=h.right-s.right;if(g>0||y>0){let b=p.attrs;g>0&&(b=ma(b,0,g)),y>0&&(b=ma(b,b.colspan-y,y)),h.left<s.left?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}if(h.top<s.top||h.bottom>s.bottom){let b=Xt(p.attrs,"rowspan",Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top));h.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}}o.push(e.child(l).copy(ne.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:o;return new se(ne.from(a),1,1)}replace(e,t=se.empty){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),o?se.empty:t)}let i=xe.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new se(ne.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=Ot.get(t),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(t.nodeAt(i[o]),s+i[o])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=Ot.get(e.node(-1)),s=e.start(-1),i=r.findCell(e.pos-s),o=r.findCell(t.pos-s),a=e.node(0);return i.top<=o.top?(i.top>0&&(e=a.resolve(s+r.map[i.left])),o.bottom<r.height&&(t=a.resolve(s+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(t=a.resolve(s+r.map[o.left])),i.bottom<r.height&&(e=a.resolve(s+r.map[r.width*(r.height-1)+i.right-1]))),new ze(e,t)}isRowSelection(){let e=Ot.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),s=e.colCount(this.$headCell.pos-t);if(Math.min(r,s)>0)return!1;let i=r+this.$anchorCell.nodeAfter.attrs.colspan,o=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,o)==e.width}eq(e){return e instanceof ze&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=Ot.get(e.node(-1)),s=e.start(-1),i=r.findCell(e.pos-s),o=r.findCell(t.pos-s),a=e.node(0);return i.left<=o.left?(i.left>0&&(e=a.resolve(s+r.map[i.top*r.width])),o.right<r.width&&(t=a.resolve(s+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(t=a.resolve(s+r.map[o.top*r.width])),i.right<r.width&&(e=a.resolve(s+r.map[r.width*(i.top+1)-1]))),new ze(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ze(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new ze(e.resolve(t),e.resolve(r))}getBookmark(){return new vw(this.$anchorCell.pos,this.$headCell.pos)}}ze.prototype.visible=!1,xe.jsonID("cell",ze);class vw{constructor(e,t){this.anchor=e,this.head=t}map(e){return new vw(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&ww(t,r)?new ze(t,r):xe.near(r,1)}}function Jj(n){if(!(n.selection instanceof ze))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(Ht.node(r,r+t.nodeSize,{class:"selectedCell"}))}),ft.create(n.doc,e)}function qj({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(s).type.spec.tableRole)}function Qj({$from:n,$to:e}){let t,r;for(let s=n.depth;s>0;s--){let i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){let i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function Yj(n,e,t){let r=(e||n).selection,s=(e||n).doc,i,o;if(r instanceof ye&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=ze.create(s,r.from);else if(o=="row"){let a=s.resolve(r.from+1);i=ze.rowSelection(a,a)}else if(!t){let a=Ot.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];i=ze.create(s,l+1,c)}}else r instanceof Ae&&qj(r)?i=Ae.create(s,r.from):r instanceof Ae&&Qj(r)&&(i=Ae.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}function Xj(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,r--,e=e.firstChild.content;let s=e.firstChild,i=s.type.spec.tableRole,o=s.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content,u=l?0:Math.max(0,t-1),f=l<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=Aw(hn(o).row,new se(c,u,f)).content),a.push(c)}else if(i=="cell"||i=="header_cell")a.push(t||r?Aw(hn(o).row,new se(e,t,r)).content:e);else return null;return Zj(o,a)}function Zj(n,e){let t=[];for(let s=0;s<e.length;s++){let i=e[s];for(let o=i.childCount-1;o>=0;o--){let{rowspan:a,colspan:l}=i.child(o).attrs;for(let c=s;c<s+a;c++)t[c]=(t[c]||0)+l}}let r=0;for(let s=0;s<t.length;s++)r=Math.max(r,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(ne.empty),t[s]<r){let i=hn(n).cell.createAndFill(),o=[];for(let a=t[s];a<r;a++)o.push(i);e[s]=e[s].append(ne.from(o))}return{height:e.length,width:r,rows:e}}function Aw(n,e){let t=n.createAndFill();return new Qg(t).replace(0,t.content.size,e).doc}function e$({width:n,height:e,rows:t},r,s){if(n!=r){let i=[],o=[];for(let a=0;a<t.length;a++){let l=t[a],c=[];for(let u=i[a]||0,f=0;u<r;f++){let d=l.child(f%l.childCount);u+d.attrs.colspan>r&&(d=d.type.create(ma(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let h=1;h<d.attrs.rowspan;h++)i[a+h]=(i[a+h]||0)+d.attrs.colspan}o.push(ne.from(c))}t=o,n=r}if(e!=s){let i=[];for(let o=0,a=0;o<s;o++,a++){let l=[],c=t[a%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);o+f.attrs.rowspan>s&&(f=f.type.create(Xt(f.attrs,"rowspan",Math.max(1,s-f.attrs.rowspan)),f.content)),l.push(f)}i.push(ne.from(l))}t=i,e=s}return{width:n,height:e,rows:t}}function t$(n,e,t,r,s,i,o){let a=n.doc.type.schema,l=hn(a),c,u;if(s>e.width)for(let f=0,d=0;f<e.height;f++){let h=t.child(f);d+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==l.cell?g=c||(c=l.cell.createAndFill()):g=u||(u=l.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(g);n.insert(n.mapping.slice(o).map(d-1+r),p)}if(i>e.height){let f=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,s);p++){let y=p>=e.width?!1:t.nodeAt(e.map[g+p]).type==l.header_cell;f.push(y?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}let d=l.row.create(null,ne.from(f)),h=[];for(let p=e.height;p<i;p++)h.push(d);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function s2(n,e,t,r,s,i,o,a){if(o==0||o==e.height)return!1;let l=!1;for(let c=s;c<i;c++){let u=o*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){l=!0;let d=t.nodeAt(f),{top:h,left:p}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(a).map(f+r),null,Xt(d.attrs,"rowspan",o-h)),n.insert(n.mapping.slice(a).map(e.positionAt(o,p,t)),d.type.createAndFill(Xt(d.attrs,"rowspan",h+d.attrs.rowspan-o))),c+=d.attrs.colspan-1}}return l}function i2(n,e,t,r,s,i,o,a){if(o==0||o==e.width)return!1;let l=!1;for(let c=s;c<i;c++){let u=c*e.width+o,f=e.map[u];if(e.map[u-1]==f){l=!0;let d=t.nodeAt(f),h=e.colCount(f),p=n.mapping.slice(a).map(f+r);n.setNodeMarkup(p,null,ma(d.attrs,o-h,d.attrs.colspan-(o-h))),n.insert(p+d.nodeSize,d.type.createAndFill(ma(d.attrs,0,o-h))),c+=d.attrs.rowspan-1}}return l}function o2(n,e,t,r,s){let i=t?n.doc.nodeAt(t-1):n.doc,o=Ot.get(i),{top:a,left:l}=r,c=l+s.width,u=a+s.height,f=n.tr,d=0;function h(){i=t?f.doc.nodeAt(t-1):f.doc,o=Ot.get(i),d=f.mapping.maps.length}t$(f,o,i,t,c,u,d)&&h(),s2(f,o,i,t,l,c,a,d)&&h(),s2(f,o,i,t,l,c,u,d)&&h(),i2(f,o,i,t,a,u,l,d)&&h(),i2(f,o,i,t,a,u,c,d)&&h();for(let p=a;p<u;p++){let g=o.positionAt(p,l,i),y=o.positionAt(p,c,i);f.replace(f.mapping.slice(d).map(g+t),f.mapping.slice(d).map(y+t),new se(s.rows[p-a],0,0))}h(),f.setSelection(new ze(f.doc.resolve(t+o.positionAt(a,l,i)),f.doc.resolve(t+o.positionAt(u-1,c-1,i)))),e(f)}const n$=Ty({ArrowLeft:wm("horiz",-1),ArrowRight:wm("horiz",1),ArrowUp:wm("vert",-1),ArrowDown:wm("vert",1),"Shift-ArrowLeft":vm("horiz",-1),"Shift-ArrowRight":vm("horiz",1),"Shift-ArrowUp":vm("vert",-1),"Shift-ArrowDown":vm("vert",1),Backspace:Am,"Mod-Backspace":Am,Delete:Am,"Mod-Delete":Am});function bm(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function wm(n,e){return(t,r,s)=>{let i=t.selection;if(i instanceof ze)return bm(t,r,xe.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let o=a2(s,n,e);if(o==null)return!1;if(n=="horiz")return bm(t,r,xe.near(t.doc.resolve(i.head+e),e));{let a=t.doc.resolve(o),l=n2(a,n,e),c;return l?c=xe.near(l,1):e<0?c=xe.near(t.doc.resolve(a.before(-1)),-1):c=xe.near(t.doc.resolve(a.after(-1)),1),bm(t,r,c)}}}function vm(n,e){return(t,r,s)=>{let i=t.selection;if(!(i instanceof ze)){let a=a2(s,n,e);if(a==null)return!1;i=new ze(t.doc.resolve(a))}let o=n2(i.$headCell,n,e);return o?bm(t,r,new ze(i.$anchorCell,o)):!1}}function Am(n,e){let t=n.selection;if(!(t instanceof ze))return!1;if(e){let r=n.tr,s=hn(n.schema).cell.createAndFill().content;t.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new se(s,0,0))}),r.docChanged&&e(r)}return!0}function r$(n,e){let t=n.state.doc,r=ac(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new ze(r))),!0):!1}function s$(n,e,t){if(!$r(n.state))return!1;let r=Xj(t),s=n.state.selection;if(s instanceof ze){r||(r={width:1,height:1,rows:[ne.from(Aw(hn(n.state.schema).cell,t))]});let i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),a=Ot.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=e$(r,a.right-a.left,a.bottom-a.top),o2(n.state,n.dispatch,o,a,r),!0}else if(r){let i=ym(n.state),o=i.start(-1);return o2(n.state,n.dispatch,o,Ot.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function i$(n,e){if(e.ctrlKey||e.metaKey)return;let t=l2(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof ze)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=ac(n.state.selection.$anchor))!=null&&xw(n,e).pos!=r.pos)s(r,e),e.preventDefault();else if(!t)return;function s(a,l){let c=xw(n,l),u=ro.getState(n.state)==null;if(!c||!ww(a,c))if(u)c=a;else return;let f=new ze(a,c);if(u||!n.state.selection.eq(f)){let d=n.state.tr.setSelection(f);u&&d.setMeta(ro,a.pos),n.dispatch(d)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",o),ro.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(ro,-1))}function o(a){let l=ro.getState(n.state),c;if(l!=null)c=n.state.doc.resolve(l);else if(l2(n,a.target)!=t&&(c=xw(n,e),!c))return i();c&&s(c,a)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",o)}function a2(n,e,t){if(!(n.state.selection instanceof Ae))return null;let{$head:r}=n.state.selection;for(let s=r.depth-1;s>=0;s--){let i=r.node(s);if((t<0?r.index(s):r.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let a=r.before(s),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?a:null}}return null}function l2(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function xw(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?ac(n.state.doc.resolve(t.pos)):null}const o$=new vt("fix-tables");function c2(n,e,t,r){let s=n.childCount,i=e.childCount;e:for(let o=0,a=0;o<i;o++){let l=e.child(o);for(let c=a,u=Math.min(s,o+3);c<u;c++)if(n.child(c)==l){a=c+1,t+=l.nodeSize;continue e}r(l,t),a<s&&n.child(a).sameMarkup(l)?c2(n.child(a),l,t+1,r):l.nodesBetween(0,l.content.size,r,t+1),t+=l.nodeSize}}function u2(n,e){let t,r=(s,i)=>{s.type.spec.tableRole=="table"&&(t=a$(n,s,i,t))};return e?e.doc!=n.doc&&c2(e.doc,n.doc,0,r):n.doc.descendants(r),t}function a$(n,e,t,r){let s=Ot.get(e);if(!s.problems)return r;r||(r=n.tr);let i=[];for(let l=0;l<s.height;l++)i.push(0);for(let l=0;l<s.problems.length;l++){let c=s.problems[l];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let f=0;f<u.attrs.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,ma(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Xt(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Xt(u.attrs,"colwidth",c.colwidth))}}let o,a;for(let l=0;l<i.length;l++)i[l]&&(o==null&&(o=l),a=l);for(let l=0,c=t+1;l<s.height;l++){let u=e.child(l),f=c+u.nodeSize,d=i[l];if(d>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let y=0;y<d;y++)p.push(hn(n.schema)[h].createAndFill());let g=(l==0||o==l-1)&&a==l?c+1:f-1;r.insert(r.mapping.map(g),p)}c=f}return r.setMeta(o$,{fixTables:!0})}function Cs(n){let e=n.selection,t=ym(n),r=t.node(-1),s=t.start(-1),i=Ot.get(r),o;return e instanceof ze?o=i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):o=i.findCell(t.pos-s),o.tableStart=s,o.map=i,o.table=r,o}function f2(n,{map:e,tableStart:t,table:r},s){let i=s>0?-1:0;Kj(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){let a=o*e.width+s;if(s>0&&s<e.width&&e.map[a-1]==e.map[a]){let l=e.map[a],c=r.nodeAt(l);n.setNodeMarkup(n.mapping.map(t+l),null,r2(c.attrs,s-e.colCount(l))),o+=c.attrs.rowspan-1}else{let l=i==null?hn(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,c=e.positionAt(o,s,r);n.insert(n.mapping.map(t+c),l.createAndFill())}}return n}function l$(n,e){if(!$r(n))return!1;if(e){let t=Cs(n);e(f2(n.tr,t,t.left))}return!0}function c$(n,e){if(!$r(n))return!1;if(e){let t=Cs(n);e(f2(n.tr,t,t.right))}return!0}function u$(n,{map:e,table:t,tableStart:r},s){let i=n.mapping.maps.length;for(let o=0;o<e.height;){let a=o*e.width+s,l=e.map[a],c=t.nodeAt(l);if(s>0&&e.map[a-1]==l||s<e.width-1&&e.map[a+1]==l)n.setNodeMarkup(n.mapping.slice(i).map(r+l),null,ma(c.attrs,s-e.colCount(l)));else{let u=n.mapping.slice(i).map(r+l);n.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function f$(n,e){if(!$r(n))return!1;if(e){let t=Cs(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;u$(r,t,s),s!=t.left;s--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=Ot.get(t.table);e(r)}return!0}function d$(n,e,t){let r=hn(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(e.nodeAt(n.map[s+t*n.width]).type!=r)return!1;return!0}function d2(n,{map:e,tableStart:t,table:r},s){let i=t;for(let l=0;l<s;l++)i+=r.child(l).nodeSize;let o=[],a=s>0?-1:0;d$(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let l=0,c=e.width*s;l<e.width;l++,c++)if(s>0&&s<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],f=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,Xt(f,"rowspan",f.rowspan+1)),l+=f.colspan-1}else{let u=a==null?hn(r.type.schema).cell:r.nodeAt(e.map[c+a*e.width]).type;o.push(u.createAndFill())}return n.insert(i,hn(r.type.schema).row.create(null,o)),n}function h$(n,e){if(!$r(n))return!1;if(e){let t=Cs(n);e(d2(n.tr,t,t.top))}return!0}function p$(n,e){if(!$r(n))return!1;if(e){let t=Cs(n);e(d2(n.tr,t,t.bottom))}return!0}function m$(n,{map:e,table:t,tableStart:r},s){let i=0;for(let l=0;l<s;l++)i+=t.child(l).nodeSize;let o=i+t.child(s).nodeSize,a=n.mapping.maps.length;n.delete(i+r,o+r);for(let l=0,c=s*e.width;l<e.width;l++,c++){let u=e.map[c];if(s>0&&u==e.map[c-e.width]){let f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,Xt(f,"rowspan",f.rowspan-1)),l+=f.colspan-1}else if(s<e.width&&u==e.map[c+e.width]){let f=t.nodeAt(u),d=f.type.create(Xt(f.attrs,"rowspan",f.attrs.rowspan-1),f.content),h=e.positionAt(s+1,l,t);n.insert(n.mapping.slice(a).map(r+h),d),l+=f.attrs.colspan-1}}}function g$(n,e){if(!$r(n))return!1;if(e){let t=Cs(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;m$(r,t,s),s!=t.top;s--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=Ot.get(t.table);e(r)}return!0}function h2(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function y$({width:n,height:e,map:t},r){let s=r.top*n+r.left,i=s,o=(r.bottom-1)*n+r.left,a=s+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[a]==t[a+1])return!0;i+=n,a+=n}for(let l=r.left;l<r.right;l++){if(r.top>0&&t[s]==t[s-n]||r.bottom<e&&t[o]==t[o+n])return!0;s++,o++}return!1}function p2(n,e){let t=n.selection;if(!(t instanceof ze)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Cs(n),{map:s}=r;if(y$(s,r))return!1;if(e){let i=n.tr,o={},a=ne.empty,l,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){let d=s.map[u*s.width+f],h=r.table.nodeAt(d);if(!o[d])if(o[d]=!0,l==null)l=d,c=h;else{h2(h)||(a=a.append(h.content));let p=i.mapping.map(d+r.tableStart);i.delete(p,p+h.nodeSize)}}if(i.setNodeMarkup(l+r.tableStart,null,Xt(r2(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),a.size){let u=l+1+c.content.size,f=h2(c)?l+1:u;i.replaceWith(f+r.tableStart,u+r.tableStart,a)}i.setSelection(new ze(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function m2(n,e){const t=hn(n.schema);return b$(({node:r})=>t[r.type.spec.tableRole])(n,e)}function b$(n){return(e,t)=>{let r=e.selection,s,i;if(r instanceof ze){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{if(s=Vj(r.$from),!s)return!1;i=ac(r.$from).pos}if(s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let o=s.attrs,a=[],l=o.colwidth;o.rowspan>1&&(o=Xt(o,"rowspan",1)),o.colspan>1&&(o=Xt(o,"colspan",1));let c=Cs(e),u=e.tr;for(let d=0;d<c.right-c.left;d++)a.push(l?Xt(o,"colwidth",l&&l[d]?[l[d]]:null):o);let f;for(let d=c.top;d<c.bottom;d++){let h=c.map.positionAt(d,c.left,c.table);d==c.top&&(h+=s.nodeSize);for(let p=c.left,g=0;p<c.right;p++,g++)p==c.left&&d==c.top||u.insert(f=u.mapping.map(h+c.tableStart,1),n({node:s,row:d,col:p}).createAndFill(a[g]))}u.setNodeMarkup(i,n({node:s,row:c.top,col:c.left}),a[0]),r instanceof ze&&u.setSelection(new ze(u.doc.resolve(r.$anchorCell.pos),f&&u.doc.resolve(f))),t(u)}return!0}}function w$(n,e){return function(t,r){if(!$r(t))return!1;let s=ym(t);if(s.nodeAfter.attrs[n]===e)return!1;if(r){let i=t.tr;t.selection instanceof ze?t.selection.forEachCell((o,a)=>{o.attrs[n]!==e&&i.setNodeMarkup(a,null,Xt(o.attrs,n,e))}):i.setNodeMarkup(s.pos,null,Xt(s.nodeAfter.attrs,n,e)),r(i)}return!0}}function v$(n){return function(e,t){if(!$r(e))return!1;if(t){let r=hn(e.schema),s=Cs(e),i=e.tr,o=s.map.cellsInRect(n=="column"?new oc(s.left,0,s.right,s.map.height):n=="row"?new oc(0,s.top,s.map.width,s.bottom):s),a=o.map(l=>s.table.nodeAt(l));for(let l=0;l<o.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[l],r.cell,a[l].attrs);if(i.steps.length==0)for(let l=0;l<o.length;l++)i.setNodeMarkup(s.tableStart+o[l],r.header_cell,a[l].attrs);t(i)}return!0}}function g2(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function Vf(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?v$(n):function(t,r){if(!$r(t))return!1;if(r){let s=hn(t.schema),i=Cs(t),o=t.tr,a=g2("row",i,s),l=g2("column",i,s),u=(n==="column"?a:n==="row"?l:!1)?1:0,f=n=="column"?new oc(0,u,1,i.map.height):n=="row"?new oc(u,0,i.map.width,1):i,d=n=="column"?l?s.cell:s.header_cell:n=="row"?a?s.cell:s.header_cell:s.cell;i.map.cellsInRect(f).forEach(h=>{const p=h+i.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,d,g.attrs)}),r(o)}return!0}}Vf("row",{useDeprecatedLogic:!0}),Vf("column",{useDeprecatedLogic:!0});let A$=Vf("cell",{useDeprecatedLogic:!0});function x$(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,s=n.before();r>=0;r--){let i=n.node(-1).child(r);if(i.childCount)return s-1-i.lastChild.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),s=n.after();r<t.childCount;r++){let i=t.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}}function y2(n){return function(e,t){if(!$r(e))return!1;let r=x$(ym(e),n);if(r!=null){if(t){let s=e.doc.resolve(r);t(e.tr.setSelection(Ae.between(s,Gj(s))).scrollIntoView())}return!0}}}function E$(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let k$=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ew(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Ew(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ew(n,e,t,r,s,i){let o=0,a=!0,l=e.firstChild,c=n.firstChild;for(let u=0,f=0;u<c.childCount;u++){let{colspan:d,colwidth:h}=c.child(u).attrs;for(let p=0;p<d;p++,f++){let g=s==f?i:h&&h[p],y=g?g+"px":"";o+=g||r,g||(a=!1),l?(l.style.width!=y&&(l.style.width=y),l=l.nextSibling):e.appendChild(document.createElement("col")).style.width=y}}for(;l;){let u=l.nextSibling;l.parentNode.removeChild(l),l=u}a?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}const xr=new vt("tableColumnResizing");function C$({handleWidth:n=5,cellMinWidth:e=25,View:t=k$,lastColumnResizable:r=!0}={}){return new ut({key:xr,state:{init(i,o){return this.spec.props.nodeViews[hn(o.schema).table.name]=(a,l)=>new t(a,e,l),new Wf(-1,!1)},apply(i,o){return o.apply(i)}},props:{attributes(i){return xr.getState(i).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(i,o){S$(i,o,n,e,r)},mouseleave(i){T$(i)},mousedown(i,o){O$(i,o,e)}},decorations(i){let o=xr.getState(i);if(o.activeHandle>-1)return I$(i,o.activeHandle)},nodeViews:{}}})}class Wf{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(xr);if(r&&r.setHandle!=null)return new Wf(r.setHandle,null);if(r&&r.setDragging!==void 0)return new Wf(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);bw(e.doc.resolve(s))||(s=null),t=new Wf(s,t.dragging)}return t}}function S$(n,e,t,r,s){let i=xr.getState(n.state);if(!i.dragging){let o=M$(e.target),a=-1;if(o){let{left:l,right:c}=o.getBoundingClientRect();e.clientX-l<=t?a=b2(n,e,"left"):c-e.clientX<=t&&(a=b2(n,e,"right"))}if(a!=i.activeHandle){if(!s&&a!==-1){let l=n.state.doc.resolve(a),c=l.node(-1),u=Ot.get(c),f=l.start(-1);if(u.colCount(l.pos-f)+l.nodeAfter.attrs.colspan-1==u.width-1)return}v2(n,a)}}}function T$(n){let e=xr.getState(n.state);e.activeHandle>-1&&!e.dragging&&v2(n,-1)}function O$(n,e,t){let r=xr.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let s=n.state.doc.nodeAt(r.activeHandle),i=N$(n,r.activeHandle,s.attrs);n.dispatch(n.state.tr.setMeta(xr,{setDragging:{startX:e.clientX,startWidth:i}}));function o(l){window.removeEventListener("mouseup",o),window.removeEventListener("mousemove",a);let c=xr.getState(n.state);c.dragging&&(R$(n,c.activeHandle,w2(c.dragging,l,t)),n.dispatch(n.state.tr.setMeta(xr,{setDragging:null})))}function a(l){if(!l.which)return o(l);let c=xr.getState(n.state),u=w2(c.dragging,l,t);P$(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",a),e.preventDefault(),!0}function N$(n,e,{colspan:t,colwidth:r}){let s=r&&r[r.length-1];if(s)return s;let i=n.domAtPos(e),a=i.node.childNodes[i.offset].offsetWidth,l=t;if(r)for(let c=0;c<t;c++)r[c]&&(a-=r[c],l--);return a/l}function M$(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function b2(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:s}=r,i=ac(n.state.doc.resolve(s));if(!i)return-1;if(t=="right")return i.pos;let o=Ot.get(i.node(-1)),a=i.start(-1),l=o.map.indexOf(i.pos-a);return l%o.width==0?-1:a+o.map[l-1]}function w2(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function v2(n,e){n.dispatch(n.state.tr.setMeta(xr,{setHandle:e}))}function R$(n,e,t){let r=n.state.doc.resolve(e),s=r.node(-1),i=Ot.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,l=n.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+a;if(c&&i.map[u]==i.map[u-i.width])continue;let f=i.map[u],{attrs:d}=s.nodeAt(f),h=d.colspan==1?0:a-i.colCount(f);if(d.colwidth&&d.colwidth[h]==t)continue;let p=d.colwidth?d.colwidth.slice():D$(d.colspan);p[h]=t,l.setNodeMarkup(o+f,null,Xt(d,"colwidth",p))}l.docChanged&&n.dispatch(l)}function P$(n,e,t,r){let s=n.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),a=Ot.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1,l=n.domAtPos(s.start(-1)).node;for(;l.nodeName!="TABLE";)l=l.parentNode;Ew(i,l.firstChild,l,r,a,t)}function D$(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function I$(n,e){let t=[],r=n.doc.resolve(e),s=r.node(-1),i=Ot.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan;for(let l=0;l<i.height;l++){let c=a+l*i.width-1;if((a==i.width||i.map[c]!=i.map[c+1])&&(l==0||i.map[c-1]!=i.map[c-1-i.width])){let u=i.map[c],f=o+u+s.nodeAt(u).nodeSize-1,d=document.createElement("div");d.className="column-resize-handle",t.push(Ht.widget(f,d))}}return ft.create(n.doc,t)}function _$({allowTableNodeSelection:n=!1}={}){return new ut({key:ro,state:{init(){return null},apply(e,t){let r=e.getMeta(ro);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:Jj,handleDOMEvents:{mousedown:i$},createSelectionBetween(e){if(ro.getState(e.state)!=null)return e.state.selection},handleTripleClick:r$,handleKeyDown:n$,handlePaste:s$},appendTransaction(e,t,r){return Yj(r,u2(r,t),n)}})}function A2(n,e,t,r,s,i){var u;let o=0,a=!0,l=e.firstChild;const c=n.firstChild;if(c)for(let f=0,d=0;f<c.childCount;f+=1){const{colspan:h,colwidth:p}=c.child(f).attrs;for(let g=0;g<h;g+=1,d+=1){const y=s===d?i:p&&p[g],b=y?`${y}px`:"";o+=y||r,y||(a=!1),l?(l.style.width!==b&&(l.style.width=b),l=l.nextSibling):e.appendChild(document.createElement("col")).style.width=b}}for(;l;){const f=l.nextSibling;(u=l==null?void 0:l.parentNode)==null||u.removeChild(l),l=f}a?(t.style.width=`${o}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${o}px`)}class L${constructor(e,t){j(this,"node");j(this,"cellMinWidth");j(this,"dom");j(this,"table");j(this,"colgroup");j(this,"contentDOM");this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),A2(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,A2(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function x2(n,e){return n.createAndFill()}function B$(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function F$(n,e,t,r,s){const i=B$(n),o=[],a=[];for(let c=0;c<t;c+=1){const u=x2(i.cell);if(u&&a.push(u),r){const f=x2(i.header_cell);f&&o.push(f)}}const l=[];for(let c=0;c<e;c+=1)l.push(i.row.createChecked(null,r&&c===0?o:a));return i.table.createChecked(null,l)}function U$(n){return n instanceof ze}const xm=({editor:n})=>{const{selection:e}=n.state;if(!U$(e))return!1;let t=0;const r=By(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},H$=dt.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:L$,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(i=>{if(i.attrs.colwidth)i.attrs.colwidth.forEach(o=>{o?t+=o:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const o=i.attrs.colspan?i.attrs.colspan:1;t+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",Ue(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const{selection:o}=r,a=F$(i.schema,n,e,t);if(s){const l=r.selection.anchor+1;r.replaceRangeWith(o.from-1,o.to,a).scrollIntoView().setSelection(Ae.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>l$(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>c$(n,e),deleteColumn:()=>({state:n,dispatch:e})=>f$(n,e),addRowBefore:()=>({state:n,dispatch:e})=>h$(n,e),addRowAfter:()=>({state:n,dispatch:e})=>p$(n,e),deleteRow:()=>({state:n,dispatch:e})=>g$(n,e),deleteTable:()=>({state:n,dispatch:e})=>E$(n,e),mergeCells:()=>({state:n,dispatch:e})=>p2(n,e),splitCell:()=>({state:n,dispatch:e})=>m2(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Vf("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Vf("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>A$(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>p2(n,e)?!0:m2(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>w$(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>y2(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>y2(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&u2(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=ze.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:xm,"Mod-Backspace":xm,Delete:xm,"Mod-Delete":xm}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[C$({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],_$({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:_e(he(n,"tableRole",e))}}});function E2(n,e){if(n==null)return{};var t={},r=Object.keys(n),s,i;for(i=0;i<r.length;i++)s=r[i],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}var k2=typeof window<"u"&&typeof document<"u";function kw(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function C2(){return k2&&document.createElement("div")}function j$(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function S2(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!S2(n[t],e[t]))return!1}else return!1;return!0}else return!1}function $$(n){var e=[];return n.forEach(function(t){e.find(function(r){return S2(t,r)})||e.push(t)}),e}function z$(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:$$([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var Cw=k2?R.useLayoutEffect:R.useEffect;function V$(n){var e=R.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function T2(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var W$={name:"className",defaultValue:"",fn:function(e){var t=e.popper.firstElementChild,r=function(){var a;return!!((a=e.props.render)!=null&&a.$$tippy)};function s(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}T2(t,"add",e.props.className)}function i(){r()&&T2(t,"remove",e.props.className)}return{onCreate:s,onBeforeUpdate:i,onAfterUpdate:s}}};function G$(n){function e(t){var r=t.children,s=t.content,i=t.visible,o=t.singleton,a=t.render,l=t.reference,c=t.disabled,u=c===void 0?!1:c,f=t.ignoreAttributes,d=f===void 0?!0:f;t.__source,t.__self;var h=E2(t,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=i!==void 0,g=o!==void 0,y=R.useState(!1),b=y[0],x=y[1],v=R.useState({}),w=v[0],E=v[1],C=R.useState(),T=C[0],N=C[1],M=V$(function(){return{container:C2(),renders:1}}),O=Object.assign({ignoreAttributes:d},h,{content:M.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(J){O[J]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+J+"` prop in","controlled mode (`visible` prop)"].join(" "))}),O.trigger="manual",O.hideOnClick=!1),g&&(u=!0);var I=O,L=O.plugins||[];a&&(I=Object.assign({},O,{plugins:g&&o.data!=null?[].concat(L,[{fn:function(){return{onTrigger:function(G,Y){var re=o.data.children.find(function(Z){var me=Z.instance;return me.reference===Y.currentTarget});G.state.$$activeSingletonInstance=re.instance,N(re.content)}}}}]):L,render:function(){return{popper:M.container}}}));var $=[l].concat(r?[r.type]:[]);return Cw(function(){var J=l;l&&l.hasOwnProperty("current")&&(J=l.current);var U=n(J||M.ref||C2(),Object.assign({},I,{plugins:[W$].concat(O.plugins||[])}));return M.instance=U,u&&U.disable(),i&&U.show(),g&&o.hook({instance:U,content:s,props:I,setSingletonContent:N}),x(!0),function(){U.destroy(),o==null||o.cleanup(U)}},$),Cw(function(){var J;if(M.renders===1){M.renders++;return}var U=M.instance;U.setProps(z$(U.props,I)),(J=U.popperInstance)==null||J.forceUpdate(),u?U.disable():U.enable(),p&&(i?U.show():U.hide()),g&&o.hook({instance:U,content:s,props:I,setSingletonContent:N})}),Cw(function(){var J;if(a){var U=M.instance;U.setProps({popperOptions:Object.assign({},U.props.popperOptions,{modifiers:[].concat((((J=U.props.popperOptions)==null?void 0:J.modifiers)||[]).filter(function(G){var Y=G.name;return Y!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Y){var re,Z=Y.state,me=(re=Z.modifiersData)==null?void 0:re.hide;(w.placement!==Z.placement||w.referenceHidden!==(me==null?void 0:me.isReferenceHidden)||w.escaped!==(me==null?void 0:me.hasPopperEscaped))&&E({placement:Z.placement,referenceHidden:me==null?void 0:me.isReferenceHidden,escaped:me==null?void 0:me.hasPopperEscaped}),Z.attributes.popper={}}}])})})}},[w.placement,w.referenceHidden,w.escaped].concat($)),R.createElement(R.Fragment,null,r?R.cloneElement(r,{ref:function(U){M.ref=U,kw(r.ref,U)}}):null,b&&at.createPortal(a?a(j$(w),T,M.instance):s,M.container))}return e}var K$=function(n,e){return R.forwardRef(function(r,s){var i=r.children,o=E2(r,["children"]);return R.createElement(n,Object.assign({},e,o),i?R.cloneElement(i,{ref:function(l){kw(s,l),kw(i.ref,l)}}):null)})},J$=K$(G$(Yo));const q$=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:n=>n.chain().focus().addRowAfter().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:n=>n.chain().focus().addColumnBefore().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:n=>n.chain().focus().addColumnAfter().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:n=>n.chain().focus().deleteRow().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:n=>n.chain().focus().deleteColumn().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:n=>n.chain().focus().toggleHeaderRow().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:n=>n.chain().focus().toggleHeaderColumn().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:n=>n.chain().focus().toggleHeaderCell().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:n=>n.chain().focus().deleteTable().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],O2=({node:n,getPos:e,selected:t,editor:r})=>{const[s,i]=R.useState(!1),o=Lh(),a=R.useRef(null),l=()=>{const{from:u,to:f}=r.state.selection,d=e(),h=d+n.nodeSize;i(d<=u&&f<=h)};R.useEffect(()=>(r.on("selectionUpdate",l),setTimeout(l,100),()=>{r.off("selectionUpdate",l)}));const c=()=>{var d,h;let u=(d=a.current)==null?void 0:d.clientTop;u&&(u+=5);let f=(h=a.current)==null?void 0:h.clientLeft;return f&&(f+=5),{top:`${u}px`,left:`${f}px`}};return _.jsxs(uf,{className:"group",children:[_.jsx(IE,{as:"span"}),(s||t)&&_.jsx(J$,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:_.jsx("article",{className:"dropdown",contentEditable:!1,children:_.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:q$.map(u=>_.jsx("li",{children:_.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[_.jsx("span",{children:u.icon}),_.jsx("span",{children:u.name})]})},u.name))})}),children:_.jsx("label",{tabIndex:0,className:je("trigger-button",{hidden:o}),contentEditable:!1,children:_.jsx(qB,{fontSize:"small"})})})]})},Q$=dt.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",Ue(this.options.HTMLAttributes,n),0]},addNodeView(){return Xo(O2,{as:"td",className:"relative"})}}),Y$=dt.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",Ue(this.options.HTMLAttributes,n),0]},addNodeView(){return Xo(O2,{as:"th",className:"relative"})}}),N2=n=>(n.stopPropagation(),n.preventDefault(),n),X$=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},M2=function(n){return!n||n===document.body?document.body:X$(n)?n:M2(n.parentNode)},Sw=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([s,i])=>r.setAttribute(s,i)),t&&Object.entries(t).forEach(([s,i])=>r.addEventListener(s,i)),r},Z$=dt.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",Ue(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),s=M2(n.options.element);let i=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const b=r(),x=n.state.doc.resolve(b),v=new ye(x);n.view.dispatch(n.state.tr.setSelection(v))}},a=()=>{i=!0},l=()=>{i=!1},c=Sw("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:b=>{b&&N2(b),o.selectRow()},mouseenter:()=>{a()},mouseover:()=>{a()},mouseleave:()=>{l(),d()}}),u=Sw("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:b=>{b&&N2(b),o.deleteRow()}}),f=()=>{g(),c.classList.remove("hidden")},d=()=>{setTimeout(()=>{i||c.classList.add("hidden")},100)},h=Sw("tr",{...e},{mouseenter:f,mouseover:f,mouseleave:d});c.append(u),document.body.append(c);let p="";const g=()=>{setTimeout(()=>{const b=h.getBoundingClientRect(),x=JSON.stringify(b);p!==x&&(c.style.top=`${b.top+document.documentElement.scrollTop}px`,c.style.left=`${b.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${b.height+1}px`,p=x)})};return setTimeout(()=>{g()},100),n.on("selectionUpdate",g),n.on("update",g),s==null||s.addEventListener("scroll",g),document.addEventListener("scroll",g),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",g),n.off("update",g),s==null||s.removeEventListener("scroll",g),document.removeEventListener("scroll",g)}}}}}),ez=[H$.configure({resizable:!0}),Q$,Y$,Z$],tz=CS.extend({content:"(dBlock|columns)+"});function R2({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const nz=bt.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new vt(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new ut({key:n,appendTransaction:(t,r,s)=>{const{doc:i,tr:o,schema:a}=s,l=n.getState(s),c=i.content.size,u=a.nodes[this.options.node];if(l)return o.insert(c,u.create())},state:{init:(t,r)=>{const s=r.tr.doc.lastChild;return!R2({node:s,types:e})},apply:(t,r)=>{var i,o,a;if(!t.docChanged)return r;const s=(a=(o=(i=t.doc.lastChild)==null?void 0:i.content)==null?void 0:o.content)==null?void 0:a[0];return!R2({node:s,types:e})}}})]}}),rz=({node:n,editor:e,getPos:t})=>{const[r,s]=R.useState(""),i=Lh(),o=["https://twitter.com","https://x.com"],a=()=>{switch(n.attrs.data){case"twitter":return _.jsx(JE,{});case"iframe":return _.jsx(QE,{});default:return _.jsx(iF,{})}},l=()=>{switch(n.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const v=r.match(/src="([^"]*)"/);v&&v.length>0&&(p=v[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const v=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);v&&v.length>0&&(p=`https://www.youtube.com/embed/${v[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const v=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);v&&v.length>0&&(p=`https://player.vimeo.com/video/${v[1]}`);break}default:{alert("Please enter a valid url");return}}const g=640,y=360,b=t(),x=b+n.nodeSize;p&&(e==null||e.chain().focus(b).deleteRange({from:b,to:x}).setIframe({src:p,width:g,height:y}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const g=o.some(w=>r.includes(w)),y=r.match(/\/status\/([0-9]*)/),b=y&&y.length>0;if(g&&b)p=y[1];else{alert("invalid url");return}const x=t(),v=x+n.nodeSize;p&&(e==null||e.chain().focus(x).deleteRange({from:x,to:v}).setTweetEmbed({tweetId:p}).run())},d=Kb(()=>{switch(n.attrs.data){case"twitter":u();break;default:c();break}},500);R.useEffect(()=>{r&&d()},[r]),R.useEffect(()=>{e==null||e.chain().focus()},[]);const h=R.useRef(null);return R.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),_.jsx(uf,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!i&&_.jsxs("div",{className:"relative w-full",children:[_.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:a()}),_.jsx("input",{ref:h,value:r,placeholder:l(),onChange:p=>s(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},sz=dt.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return Xo(rz)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return console.log("action"),["div",Ue(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),iz=[q6,K6.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-stone-100 p-5 font-serif italic text-stone-800"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-stone-800"}},code:{HTMLAttributes:{class:"rounded-md bg-stone-200 p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),Q6.configure({types:["heading","paragraph"]}),B5,w5.configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),v5.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),E5.configure({multicolor:!0}),L5,T5.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),J6,H5,k5.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),S5.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),SS.configure({width:3,color:"#d1d5db"}),TS,Uj,nz,tz,...ez,q5.configure({uploadFn:pF}),U5,j5,W5,sz.extend({addInputRules(){return[P2(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),P2(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),F5],P2=(n,e,t)=>new Qu({find:n,handler:({state:r,range:s,commands:i})=>{const o={data:e},{tr:a}=r,l=s.from,c=s.to;a.insert(l-1,t.create(o)).delete(a.mapping.map(l),a.mapping.map(c)),i.focus(c-1)}}),ga=n=>Pl((e,t)=>{n.onerror=r=>t(new Error(r.target.error)),n.onsuccess=r=>e(r.target.result)}),oz=(n,e)=>Pl((t,r)=>{const s=indexedDB.open(n);s.onupgradeneeded=i=>e(i.target.result),s.onerror=i=>r(Lr(i.target.error)),s.onsuccess=i=>{const o=i.target.result;o.onversionchange=()=>{o.close()},t(o)}}),az=n=>ga(indexedDB.deleteDatabase(n)),lz=(n,e)=>e.forEach(t=>n.createObjectStore.apply(n,t)),Gf=(n,e,t="readwrite")=>{const r=n.transaction(e,t);return e.map(s=>gz(r,s))},D2=(n,e)=>ga(n.count(e)),cz=(n,e)=>ga(n.get(e)),I2=(n,e)=>ga(n.delete(e)),uz=(n,e,t)=>ga(n.put(e,t)),Tw=(n,e)=>ga(n.add(e)),fz=(n,e,t)=>ga(n.getAll(e,t)),dz=(n,e,t)=>{let r=null;return mz(n,e,s=>(r=s,!1),t).then(()=>r)},hz=(n,e=null)=>dz(n,e,"prev"),pz=(n,e)=>Pl((t,r)=>{n.onerror=r,n.onsuccess=async s=>{const i=s.target.result;if(i===null||await e(i)===!1)return t();i.continue()}}),mz=(n,e,t,r="next")=>pz(n.openKeyCursor(e,r),s=>t(s.key)),gz=(n,e)=>n.objectStore(e),yz=(n,e)=>IDBKeyRange.upperBound(n,e),bz=(n,e)=>IDBKeyRange.lowerBound(n,e),Ow="custom",_2="updates",L2=500,B2=(n,e=()=>{},t=()=>{})=>{const[r]=Gf(n.db,[_2]);return fz(r,bz(n._dbref,!1)).then(s=>{n._destroyed||(e(r),ot(n.doc,()=>{s.forEach(i=>lC(n.doc,i))},n,!1),t(r))}).then(()=>hz(r).then(s=>{n._dbref=s+1})).then(()=>D2(r).then(s=>{n._dbsize=s})).then(()=>r)},wz=(n,e=!0)=>B2(n).then(t=>{(e||n._dbsize>=L2)&&Tw(t,J0(n.doc)).then(()=>I2(t,yz(n._dbref,!0))).then(()=>D2(t).then(r=>{n._dbsize=r}))});class vz extends w0{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=oz(e,r=>lz(r,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=Pl(r=>this.on("synced",()=>r(this))),this._db.then(r=>{this.db=r,B2(this,o=>Tw(o,J0(t)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(r,s)=>{if(this.db&&s!==this){const[i]=Gf(this.db,[_2]);Tw(i,r),++this._dbsize>=L2&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{wz(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),t.on("destroy",this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{az(this.name)})}get(e){return this._db.then(t=>{const[r]=Gf(t,[Ow],"readonly");return cz(r,e)})}set(e,t){return this._db.then(r=>{const[s]=Gf(r,[Ow]);return uz(s,t,e)})}del(e){return this._db.then(t=>{const[r]=Gf(t,[Ow]);return I2(r,e)})}}const Az="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAOCAYAAAD0f5bSAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAE/SURBVHgBhVJBTsJQEH3zMcElR+gRuIF6gwYPAOwkLoQTUE6ArEA3xbWJ4gnQE8gNwBuwhMR2fPNLk9o0ZZImM/P/e39e3wgqojPXXiPFJnFovw1kWT53xSKca3C70LXlr/eySYFdZ6Fb61eCePnBCb6VF3P21UA+WX+wv+086fgfyMbh4aPlqWJSZH2/k6EINlBEJI6tdxHG2tIDrsUqxYzsO5Qi+UXfNfwUPT7w49wRU1EyZWNFqIgV9REw84Wga+P1Uj7PsW5QE9pEZMT8Aq+JQmNcYl8HwgEtEvf9fc3RR4zrMCRe84WA6dJRz8upPwyftV0FOP3ugHqu0iZGzsSbF3bYUMRlgDdWMcyE4WvVl73XRC9CNiaqaHMDpkUQrYh8kmKUmy5lVpvdBNs2mOk0tptk9a5AVKHhzML+AZaSjR/r++n9AAAAAElFTkSuQmCC",xz="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAEjSURBVHgBjZJBToNQEIb/NzTeoMbGjTeoN5Au1S7wBrqwyk5OoD1B46pRF9UbsEBc9nmEHsI08QhGZnxMpaGUEv4EwoP/mxnyj0GNTp++AoPORA+Gx+mo91r1mOJh+LL0WYwDqC8i/obJGCuSfRJ1bHLdtWtQIaY5WoiYBknYtZQfmOGjpTIvC7TAahTvpMksmUQCvK0A6itzNl1egmi2k2K+2gPsD+mvHGkh4MIVoPuSLYbIYxOk3YAJVRuktwd3DhjvggqRB0Slc3D+/D1Lw95DE5Rnq3E487ySXeyu4zooz/R9tD/QUYV5Ufke1HbKvW4RdFS9icRoKeKO1c7Fi+HUbQ/BzzPdXjmxDCy8TOIk7G2CZf1nqzEJfqOPm8Otif4AFnp3K1F5HHAAAAAASUVORK5CYII=",Ez=n=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");return t.classList.add("collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null),e.insertBefore(t,null),e},kz=n=>{const e=document.createElement("span");e.classList.add("custom-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");t.classList.add("custom-cursor__label-container"),t.setAttribute("style",`border: 1px solid ${n.color}`);const r=document.createElement("img");r.src=Az,r.classList.add("custom-cursor__icon");const s=document.createElement("div");s.classList.add("custom-cursor__label");const i=document.createElement("span");i.classList.add("custom-cursor__text"),i.textContent=n.name;const o=document.createElement("img");return o.src=xz,o.classList.add("custom-cursor__badge"),s.appendChild(i),t.appendChild(r),t.appendChild(s),t.appendChild(o),e.appendChild(t),e},Cz=n=>n.isEns?kz(n):Ez(n),Sz="6.13.1";function Tz(n,e,t){const r=e.split("|").map(i=>i.trim());for(let i=0;i<r.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=n,s}async function pn(n){const e=Object.keys(n);return(await Promise.all(e.map(r=>Promise.resolve(n[r])))).reduce((r,s,i)=>(r[e[i]]=s,r),{})}function be(n,e,t){for(let r in e){let s=e[r];const i=t?t[r]:null;i&&Tz(s,i,r),Object.defineProperty(n,r,{enumerable:!0,value:s,writable:!1})}}function lc(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(lc).join(", ")+" ]";if(n instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let r=0;r<n.length;r++)t+=e[n[r]>>4],t+=e[n[r]&15];return t}if(typeof n=="object"&&typeof n.toJSON=="function")return lc(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{ "+e.map(t=>`${lc(t)}: ${lc(n[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Zt(n,e){return n&&n.code===e}function Nw(n){return Zt(n,"CALL_EXCEPTION")}function wt(n,e,t){let r=n;{const i=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${lc(t)}`);for(const o in t){if(o==="shortMessage")continue;const a=t[o];i.push(o+"="+lc(a))}}i.push(`code=${e}`),i.push(`version=${Sz}`),i.length&&(n+=" ("+i.join(", ")+")")}let s;switch(e){case"INVALID_ARGUMENT":s=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":s=new RangeError(n);break;default:s=new Error(n)}return be(s,{code:e}),t&&Object.assign(s,t),s.shortMessage==null&&be(s,{shortMessage:r}),s}function X(n,e,t,r){if(!n)throw wt(e,t,r)}function H(n,e,t,r){X(n,e,"INVALID_ARGUMENT",{argument:t,value:r})}function F2(n,e,t){t==null&&(t=""),t&&(t=": "+t),X(n>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:n,expectedCount:e}),X(n<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((n,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");n.push(e)}catch{}return n},[]);function Em(n,e,t){if(t==null&&(t=""),n!==e){let r=t,s="new";t&&(r+=".",s+=" "+t),X(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function U2(n,e,t){if(n instanceof Uint8Array)return t?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let s=2;for(let i=0;i<r.length;i++)r[i]=parseInt(n.substring(s,s+2),16),s+=2;return r}H(!1,"invalid BytesLike value",e||"value",n)}function qe(n,e){return U2(n,e,!1)}function Cn(n,e){return U2(n,e,!0)}function pt(n,e){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&n.length!==2+2*e||e===!0&&n.length%2!==0)}function Mw(n){return pt(n,!0)||n instanceof Uint8Array}const H2="0123456789abcdef";function ce(n){const e=qe(n);let t="0x";for(let r=0;r<e.length;r++){const s=e[r];t+=H2[(s&240)>>4]+H2[s&15]}return t}function Rt(n){return"0x"+n.map(e=>ce(e).substring(2)).join("")}function cc(n){return pt(n,!0)?(n.length-2)/2:qe(n).length}function Nt(n,e,t){const r=qe(n);return t!=null&&t>r.length&&X(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:t}),ce(r.slice(e??0,t??r.length))}function j2(n,e,t){const r=qe(n);X(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(r,e-r.length):s.set(r,0),ce(s)}function ya(n,e){return j2(n,e,!0)}function Oz(n,e){return j2(n,e,!1)}const km=BigInt(0),zr=BigInt(1),uc=9007199254740991;function Nz(n,e){const t=Cm(n,"value"),r=BigInt(Pe(e,"width"));if(X(t>>r===km,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),t>>r-zr){const s=(zr<<r)-zr;return-((~t&s)+zr)}return t}function $2(n,e){let t=pe(n,"value");const r=BigInt(Pe(e,"width")),s=zr<<r-zr;if(t<km){t=-t,X(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const i=(zr<<r)-zr;return(~t&i)+zr}else X(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return t}function Kf(n,e){const t=Cm(n,"value"),r=BigInt(Pe(e,"bits"));return t&(zr<<r)-zr}function pe(n,e){switch(typeof n){case"bigint":return n;case"number":return H(Number.isInteger(n),"underflow",e||"value",n),H(n>=-uc&&n<=uc,"overflow",e||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(t){H(!1,`invalid BigNumberish string: ${t.message}`,e||"value",n)}}H(!1,"invalid BigNumberish value",e||"value",n)}function Cm(n,e){const t=pe(n,e);return X(t>=km,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),t}const z2="0123456789abcdef";function Rw(n){if(n instanceof Uint8Array){let e="0x0";for(const t of n)e+=z2[t>>4],e+=z2[t&15];return BigInt(e)}return pe(n)}function Pe(n,e){switch(typeof n){case"bigint":return H(n>=-uc&&n<=uc,"overflow",e||"value",n),Number(n);case"number":return H(Number.isInteger(n),"underflow",e||"value",n),H(n>=-uc&&n<=uc,"overflow",e||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return Pe(BigInt(n),e)}catch(t){H(!1,`invalid numeric string: ${t.message}`,e||"value",n)}}H(!1,"invalid numeric value",e||"value",n)}function Mz(n){return Pe(Rw(n))}function so(n,e){let r=Cm(n,"value").toString(16);if(e==null)r.length%2&&(r="0"+r);else{const s=Pe(e,"width");for(X(s*2>=r.length,`value exceeds width (${s} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<s*2;)r="0"+r}return"0x"+r}function Sn(n){const e=Cm(n,"value");if(e===km)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const r=new Uint8Array(t.length/2);for(let s=0;s<r.length;s++){const i=s*2;r[s]=parseInt(t.substring(i,i+2),16)}return r}function ba(n){let e=ce(Mw(n)?n:Sn(n)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const V2="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const W2=BigInt(58);function Rz(n){const e=qe(n);let t=Rw(e),r="";for(;t;)r=V2[Number(t%W2)]+r,t/=W2;for(let s=0;s<e.length&&!e[s];s++)r=V2[0]+r;return r}function Pz(n){n=atob(n);const e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return qe(e)}function Dz(n){const e=qe(n);let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}class G2{constructor(e,t,r){j(this,"filter");j(this,"emitter");W(this,Mc,void 0);D(this,Mc,t),be(this,{emitter:e,filter:r})}async removeListener(){k(this,Mc)!=null&&await this.emitter.off(this.filter,k(this,Mc))}}Mc=new WeakMap;function Iz(n,e,t,r,s){H(!1,`invalid codepoint at offset ${e}; ${n}`,"bytes",t)}function K2(n,e,t,r,s){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return n==="OVERRUN"?t.length-e-1:0}function _z(n,e,t,r,s){return n==="OVERLONG"?(H(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),K2(n,e,t))}const Lz=Object.freeze({error:Iz,ignore:K2,replace:_z});function Bz(n,e){e==null&&(e=Lz.error);const t=qe(n,"bytes"),r=[];let s=0;for(;s<t.length;){const i=t[s++];if(!(i>>7)){r.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,r):s+=e("BAD_PREFIX",s-1,t,r);continue}if(s-1+o>=t.length){s+=e("OVERRUN",s-1,t,r);continue}let l=i&(1<<8-o-1)-1;for(let c=0;c<o;c++){let u=t[s];if((u&192)!=128){s+=e("MISSING_CONTINUE",s,t,r),l=null;break}l=l<<6|u&63,s++}if(l!==null){if(l>1114111){s+=e("OUT_OF_RANGE",s-1-o,t,r,l);continue}if(l>=55296&&l<=57343){s+=e("UTF16_SURROGATE",s-1-o,t,r,l);continue}if(l<=a){s+=e("OVERLONG",s-1-o,t,r,l);continue}r.push(l)}}return r}function ri(n,e){H(typeof n=="string","invalid string value","str",n);let t=[];for(let r=0;r<n.length;r++){const s=n.charCodeAt(r);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){r++;const i=n.charCodeAt(r);H(r<n.length&&(i&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((s&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function Fz(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function fc(n,e){return Fz(Bz(n,e))}function J2(n){async function e(t,r){X(r==null||!r.cancelled,"request cancelled before sending","CANCELLED");const s=t.url.split(":")[0].toLowerCase();X(s==="http"||s==="https",`unsupported protocol ${s}`,"UNSUPPORTED_OPERATION",{info:{protocol:s},operation:"request"}),X(s==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const o=new AbortController,a=setTimeout(()=>{i=wt("request timeout","TIMEOUT"),o.abort()},t.timeout);r&&r.addListener(()=>{i=wt("request cancelled","CANCELLED"),o.abort()});const l={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:o.signal};let c;try{c=await fetch(t.url,l)}catch(h){throw clearTimeout(a),i||h}clearTimeout(a);const u={};c.headers.forEach((h,p)=>{u[p.toLowerCase()]=h});const f=await c.arrayBuffer(),d=f==null?null:new Uint8Array(f);return{statusCode:c.status,statusMessage:c.statusText,headers:u,body:d}}return e}const Uz=12,Hz=250;let q2=J2();const jz=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),$z=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let Pw=!1;async function Q2(n,e){try{const t=n.match(jz);if(!t)throw new Error("invalid data");return new io(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?Pz(t[3]):Vz(t[3]))}catch{return new io(599,"BAD REQUEST (invalid data: URI)",{},null,new Tn(n))}}function Y2(n){async function e(t,r){try{const s=t.match($z);if(!s)throw new Error("invalid link");return new Tn(`${n}${s[2]}`)}catch{return new io(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Tn(t))}}return e}const Sm={data:Q2,ipfs:Y2("https://gateway.ipfs.io/ipfs/")},X2=new WeakMap;class zz{constructor(e){W(this,Pa,void 0);W(this,po,void 0);D(this,Pa,[]),D(this,po,!1),X2.set(e,()=>{if(!k(this,po)){D(this,po,!0);for(const t of k(this,Pa))setTimeout(()=>{t()},0);D(this,Pa,[])}})}addListener(e){X(!k(this,po),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),k(this,Pa).push(e)}get cancelled(){return k(this,po)}checkSignal(){X(!this.cancelled,"cancelled","CANCELLED",{})}}Pa=new WeakMap,po=new WeakMap;function Tm(n){if(n==null)throw new Error("missing signal; should not happen");return n.checkSignal(),n}const yg=class yg{constructor(e){W(this,La);W(this,Rc,void 0);W(this,Pc,void 0);W(this,Jr,void 0);W(this,di,void 0);W(this,Dc,void 0);W(this,Ic,void 0);W(this,nn,void 0);W(this,ir,void 0);W(this,hi,void 0);W(this,Da,void 0);W(this,Ia,void 0);W(this,_a,void 0);W(this,Ns,void 0);W(this,qr,void 0);W(this,mo,void 0);D(this,Ic,String(e)),D(this,Rc,!1),D(this,Pc,!0),D(this,Jr,{}),D(this,di,""),D(this,Dc,3e5),D(this,qr,{slotInterval:Hz,maxAttempts:Uz}),D(this,mo,null)}get url(){return k(this,Ic)}set url(e){D(this,Ic,String(e))}get body(){return k(this,nn)==null?null:new Uint8Array(k(this,nn))}set body(e){if(e==null)D(this,nn,void 0),D(this,ir,void 0);else if(typeof e=="string")D(this,nn,ri(e)),D(this,ir,"text/plain");else if(e instanceof Uint8Array)D(this,nn,e),D(this,ir,"application/octet-stream");else if(typeof e=="object")D(this,nn,ri(JSON.stringify(e))),D(this,ir,"application/json");else throw new Error("invalid body")}hasBody(){return k(this,nn)!=null}get method(){return k(this,di)?k(this,di):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),D(this,di,String(e).toUpperCase())}get headers(){const e=Object.assign({},k(this,Jr));return k(this,hi)&&(e.authorization=`Basic ${Dz(ri(k(this,hi)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&k(this,ir)&&(e["content-type"]=k(this,ir)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){k(this,Jr)[String(e).toLowerCase()]=String(t)}clearHeaders(){D(this,Jr,{})}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let r=0;return{next:()=>{if(r<t.length){const s=t[r++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return k(this,hi)||null}setCredentials(e,t){H(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),D(this,hi,`${e}:${t}`)}get allowGzip(){return k(this,Pc)}set allowGzip(e){D(this,Pc,!!e)}get allowInsecureAuthentication(){return!!k(this,Rc)}set allowInsecureAuthentication(e){D(this,Rc,!!e)}get timeout(){return k(this,Dc)}set timeout(e){H(e>=0,"timeout must be non-zero","timeout",e),D(this,Dc,e)}get preflightFunc(){return k(this,Da)||null}set preflightFunc(e){D(this,Da,e)}get processFunc(){return k(this,Ia)||null}set processFunc(e){D(this,Ia,e)}get retryFunc(){return k(this,_a)||null}set retryFunc(e){D(this,_a,e)}get getUrlFunc(){return k(this,mo)||q2}set getUrlFunc(e){D(this,mo,e)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${k(this,nn)?ce(k(this,nn)):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(k(this,qr).slotInterval=e.slotInterval),e.maxAttempts!=null&&(k(this,qr).maxAttempts=e.maxAttempts)}send(){return X(k(this,Ns)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),D(this,Ns,new zz(this)),ie(this,La,jd).call(this,0,Z2()+this.timeout,0,this,new io(0,"",{},null,this))}cancel(){X(k(this,Ns)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=X2.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),r=e.split(":")[0].toLowerCase();X(this.method==="GET"&&(t!=="https"||r!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const s=new yg(e);return s.method="GET",s.allowGzip=this.allowGzip,s.timeout=this.timeout,D(s,Jr,Object.assign({},k(this,Jr))),k(this,nn)&&D(s,nn,new Uint8Array(k(this,nn))),D(s,ir,k(this,ir)),s}clone(){const e=new yg(this.url);return D(e,di,k(this,di)),k(this,nn)&&D(e,nn,k(this,nn)),D(e,ir,k(this,ir)),D(e,Jr,Object.assign({},k(this,Jr))),D(e,hi,k(this,hi)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),D(e,Da,k(this,Da)),D(e,Ia,k(this,Ia)),D(e,_a,k(this,_a)),D(e,qr,Object.assign({},k(this,qr))),D(e,mo,k(this,mo)),e}static lockConfig(){Pw=!0}static getGateway(e){return Sm[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(Pw)throw new Error("gateways locked");Sm[e]=t}static registerGetUrl(e){if(Pw)throw new Error("gateways locked");q2=e}static createGetUrlFunc(e){return J2()}static createDataGateway(){return Q2}static createIpfsGatewayFunc(e){return Y2(e)}};Rc=new WeakMap,Pc=new WeakMap,Jr=new WeakMap,di=new WeakMap,Dc=new WeakMap,Ic=new WeakMap,nn=new WeakMap,ir=new WeakMap,hi=new WeakMap,Da=new WeakMap,Ia=new WeakMap,_a=new WeakMap,Ns=new WeakMap,qr=new WeakMap,mo=new WeakMap,La=new WeakSet,jd=async function(e,t,r,s,i){var u,f,d;if(e>=k(this,qr).maxAttempts)return i.makeServerError("exceeded maximum retry limit");X(Z2()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:s}),r>0&&await Wz(r);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in Sm){const h=await Sm[a](o.url,Tm(k(s,Ns)));if(h instanceof io){let p=h;if(this.processFunc){Tm(k(s,Ns));try{p=await this.processFunc(o,p)}catch(g){(g.throttle==null||typeof g.stall!="number")&&p.makeServerError("error in post-processing function",g).assertOk()}}return p}o=h}this.preflightFunc&&(o=await this.preflightFunc(o));const l=await this.getUrlFunc(o,Tm(k(s,Ns)));let c=new io(l.statusCode,l.statusMessage,l.headers,l.body,s);if(c.statusCode===301||c.statusCode===302){try{const h=c.headers.location||"";return ie(u=o.redirect(h),La,jd).call(u,e+1,t,0,s,c)}catch{}return c}else if(c.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,c,e))){const h=c.headers["retry-after"];let p=k(this,qr).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof h=="string"&&h.match(/^[1-9][0-9]*$/)&&(p=parseInt(h)),ie(f=o.clone(),La,jd).call(f,e+1,t,p,s,c)}if(this.processFunc){Tm(k(s,Ns));try{c=await this.processFunc(o,c)}catch(h){(h.throttle==null||typeof h.stall!="number")&&c.makeServerError("error in post-processing function",h).assertOk();let p=k(this,qr).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return h.stall>=0&&(p=h.stall),ie(d=o.clone(),La,jd).call(d,e+1,t,p,s,c)}}return c};let Tn=yg;const Wv=class Wv{constructor(e,t,r,s,i){W(this,yd,void 0);W(this,bd,void 0);W(this,wd,void 0);W(this,or,void 0);W(this,_c,void 0);W(this,Ba,void 0);D(this,yd,e),D(this,bd,t),D(this,wd,Object.keys(r).reduce((o,a)=>(o[a.toLowerCase()]=String(r[a]),o),{})),D(this,or,s==null?null:new Uint8Array(s)),D(this,_c,i||null),D(this,Ba,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${k(this,or)?ce(k(this,or)):"null"}>`}get statusCode(){return k(this,yd)}get statusMessage(){return k(this,bd)}get headers(){return Object.assign({},k(this,wd))}get body(){return k(this,or)==null?null:new Uint8Array(k(this,or))}get bodyText(){try{return k(this,or)==null?"":fc(k(this,or))}catch{X(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{X(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let r=0;return{next:()=>{if(r<t.length){const s=t[r++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,t){let r;e?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${e})`);const s=new Wv(599,r,this.headers,this.body,k(this,_c)||void 0);return D(s,Ba,{message:e,error:t}),s}throwThrottleError(e,t){t==null?t=-1:H(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const r=new Error(e||"throttling requests");throw be(r,{stall:t,throttle:!0}),r}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return k(this,or)!=null}get request(){return k(this,_c)}ok(){return k(this,Ba).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=k(this,Ba);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let s=null;try{k(this,or)&&(s=fc(k(this,or)))}catch{}X(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:r,responseBody:s,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};yd=new WeakMap,bd=new WeakMap,wd=new WeakMap,or=new WeakMap,_c=new WeakMap,Ba=new WeakMap;let io=Wv;function Z2(){return new Date().getTime()}function Vz(n){return ri(n.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function Wz(n){return new Promise(e=>setTimeout(e,n))}function Gz(n){let e=n.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function eO(n,e,t){let r=0;for(let s=0;s<t;s++)r=r*256+n[e+s];return r}function tO(n,e,t,r){const s=[];for(;t<e+1+r;){const i=nO(n,t);s.push(i.result),t+=i.consumed,X(t<=e+1+r,"child data too short","BUFFER_OVERRUN",{buffer:n,length:r,offset:e})}return{consumed:1+r,result:s}}function nO(n,e){X(n.length!==0,"data too short","BUFFER_OVERRUN",{buffer:n,length:0,offset:1});const t=r=>{X(r<=n.length,"data short segment too short","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r})};if(n[e]>=248){const r=n[e]-247;t(e+1+r);const s=eO(n,e+1,r);return t(e+1+r+s),tO(n,e,e+1+r,r+s)}else if(n[e]>=192){const r=n[e]-192;return t(e+1+r),tO(n,e,e+1,r)}else if(n[e]>=184){const r=n[e]-183;t(e+1+r);const s=eO(n,e+1,r);t(e+1+r+s);const i=ce(n.slice(e+1+r,e+1+r+s));return{consumed:1+r+s,result:i}}else if(n[e]>=128){const r=n[e]-128;t(e+1+r);const s=ce(n.slice(e+1,e+1+r));return{consumed:1+r,result:s}}return{consumed:1,result:Gz(n[e])}}function Om(n){const e=qe(n,"data"),t=nO(e,0);return H(t.consumed===e.length,"unexpected junk after rlp payload","data",n),t.result}function rO(n){const e=[];for(;n;)e.unshift(n&255),n>>=8;return e}function sO(n){if(Array.isArray(n)){let r=[];if(n.forEach(function(i){r=r.concat(sO(i))}),r.length<=55)return r.unshift(192+r.length),r;const s=rO(r.length);return s.unshift(247+s.length),s.concat(r)}const e=Array.prototype.slice.call(qe(n,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=rO(e.length);return t.unshift(183+t.length),t.concat(e)}const iO="0123456789abcdef";function wa(n){let e="0x";for(const t of sO(n))e+=iO[t>>4],e+=iO[t&15];return e}const On=32,Dw=new Uint8Array(On),Kz=["then"],Nm={},oO=new WeakMap;function va(n){return oO.get(n)}function aO(n,e){oO.set(n,e)}function Jf(n,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw t.error=e,t}function Iw(n,e,t){return n.indexOf(null)>=0?e.map((r,s)=>r instanceof dc?Iw(va(r),r,t):r):n.reduce((r,s,i)=>{let o=e.getValue(s);return s in r||(t&&o instanceof dc&&(o=Iw(va(o),o,t)),r[s]=o),r},{})}const Bc=class Bc extends Array{constructor(...t){const r=t[0];let s=t[1],i=(t[2]||[]).slice(),o=!0;r!==Nm&&(s=t,i=[],o=!1);super(s.length);W(this,Lc,void 0);s.forEach((c,u)=>{this[u]=c});const a=i.reduce((c,u)=>(typeof u=="string"&&c.set(u,(c.get(u)||0)+1),c),new Map);if(aO(this,Object.freeze(s.map((c,u)=>{const f=i[u];return f!=null&&a.get(f)===1?f:null}))),D(this,Lc,[]),k(this,Lc)==null&&k(this,Lc),!o)return;Object.freeze(this);const l=new Proxy(this,{get:(c,u,f)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const h=Pe(u,"%index");if(h<0||h>=this.length)throw new RangeError("out of result range");const p=c[h];return p instanceof Error&&Jf(`index ${h}`,p),p}if(Kz.indexOf(u)>=0)return Reflect.get(c,u,f);const d=c[u];if(d instanceof Function)return function(...h){return d.apply(this===f?c:this,h)};if(!(u in c))return c.getValue.apply(this===f?c:this,[u])}return Reflect.get(c,u,f)}});return aO(l,va(this)),l}toArray(t){const r=[];return this.forEach((s,i)=>{s instanceof Error&&Jf(`index ${i}`,s),t&&s instanceof Bc&&(s=s.toArray(t)),r.push(s)}),r}toObject(t){const r=va(this);return r.reduce((s,i,o)=>(X(i!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Iw(r,this,t)),{})}slice(t,r){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const s=va(this),i=[],o=[];for(let a=t;a<r;a++)i.push(this[a]),o.push(s[a]);return new Bc(Nm,i,o)}filter(t,r){const s=va(this),i=[],o=[];for(let a=0;a<this.length;a++){const l=this[a];l instanceof Error&&Jf(`index ${a}`,l),t.call(r,l,a,this)&&(i.push(l),o.push(s[a]))}return new Bc(Nm,i,o)}map(t,r){const s=[];for(let i=0;i<this.length;i++){const o=this[i];o instanceof Error&&Jf(`index ${i}`,o),s.push(t.call(r,o,i,this))}return s}getValue(t){const r=va(this).indexOf(t);if(r===-1)return;const s=this[r];return s instanceof Error&&Jf(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,r){return new Bc(Nm,t,r)}};Lc=new WeakMap;let dc=Bc;function lO(n){let e=Sn(n);return X(e.length<=On,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:On,offset:e.length}),e.length!==On&&(e=Cn(Rt([Dw.slice(e.length%On),e]))),e}class si{constructor(e,t,r,s){j(this,"name");j(this,"type");j(this,"localName");j(this,"dynamic");be(this,{name:e,type:t,localName:r,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){H(!1,e,this.localName,t)}}class _w{constructor(){W(this,Fc);W(this,pi,void 0);W(this,Fa,void 0);D(this,pi,[]),D(this,Fa,0)}get data(){return Rt(k(this,pi))}get length(){return k(this,Fa)}appendWriter(e){return ie(this,Fc,Og).call(this,Cn(e.data))}writeBytes(e){let t=Cn(e);const r=t.length%On;return r&&(t=Cn(Rt([t,Dw.slice(r)]))),ie(this,Fc,Og).call(this,t)}writeValue(e){return ie(this,Fc,Og).call(this,lO(e))}writeUpdatableValue(){const e=k(this,pi).length;return k(this,pi).push(Dw),D(this,Fa,k(this,Fa)+On),t=>{k(this,pi)[e]=lO(t)}}}pi=new WeakMap,Fa=new WeakMap,Fc=new WeakSet,Og=function(e){return k(this,pi).push(e),D(this,Fa,k(this,Fa)+e.length),e.length};const Gv=class Gv{constructor(e,t,r){W(this,vd);W(this,bg);j(this,"allowLoose");W(this,Gn,void 0);W(this,ar,void 0);W(this,Ua,void 0);W(this,Ha,void 0);W(this,go,void 0);be(this,{allowLoose:!!t}),D(this,Gn,Cn(e)),D(this,Ua,0),D(this,Ha,null),D(this,go,r??1024),D(this,ar,0)}get data(){return ce(k(this,Gn))}get dataLength(){return k(this,Gn).length}get consumed(){return k(this,ar)}get bytes(){return new Uint8Array(k(this,Gn))}subReader(e){const t=new Gv(k(this,Gn).slice(k(this,ar)+e),this.allowLoose,k(this,go));return D(t,Ha,this),t}readBytes(e,t){let r=ie(this,bg,GM).call(this,0,e,!!t);return ie(this,vd,n1).call(this,e),D(this,ar,k(this,ar)+r.length),r.slice(0,e)}readValue(){return Rw(this.readBytes(On))}readIndex(){return Mz(this.readBytes(On))}};Gn=new WeakMap,ar=new WeakMap,Ua=new WeakMap,Ha=new WeakMap,go=new WeakMap,vd=new WeakSet,n1=function(e){var t;if(k(this,Ha))return ie(t=k(this,Ha),vd,n1).call(t,e);D(this,Ua,k(this,Ua)+e),X(k(this,go)<1||k(this,Ua)<=k(this,go)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${k(this,go)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Cn(k(this,Gn)),offset:k(this,ar),length:e,info:{bytesRead:k(this,Ua),dataLength:this.dataLength}})},bg=new WeakSet,GM=function(e,t,r){let s=Math.ceil(t/On)*On;return k(this,ar)+s>k(this,Gn).length&&(this.allowLoose&&r&&k(this,ar)+t<=k(this,Gn).length?s=t:X(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Cn(k(this,Gn)),length:k(this,Gn).length,offset:k(this,ar)+s})),k(this,Gn).slice(k(this,ar),k(this,ar)+s)};let Lw=Gv;function Mm(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function Bw(n,...e){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(n.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${n.length}`)}function Jz(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mm(n.outputLen),Mm(n.blockLen)}function hc(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function cO(n,e){Bw(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Fw=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const uO=n=>n instanceof Uint8Array,qz=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Uw=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Ss=(n,e)=>n<<32-e|n>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function Qz(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Rm(n){if(typeof n=="string"&&(n=Qz(n)),!uO(n))throw new Error(`expected Uint8Array, got ${typeof n}`);return n}function Yz(...n){const e=new Uint8Array(n.reduce((r,s)=>r+s.length,0));let t=0;return n.forEach(r=>{if(!uO(r))throw new Error("Uint8Array expected");e.set(r,t),t+=r.length}),e}class Hw{clone(){return this._cloneInto()}}function jw(n){const e=r=>n().update(Rm(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function Xz(n=32){if(Fw&&typeof Fw.getRandomValues=="function")return Fw.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}class fO extends Hw{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Jz(e);const r=Rm(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return hc(this),this.iHash.update(e),this}digestInto(e){hc(this),Bw(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const dO=(n,e,t)=>new fO(n,e).update(t).digest();dO.create=(n,e)=>new fO(n,e);function Zz(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),l=r?4:0,c=r?0:4;n.setUint32(e+l,o,r),n.setUint32(e+c,a,r)}class hO extends Hw{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Uw(this.buffer)}update(e){hc(this);const{view:t,buffer:r,blockLen:s}=this;e=Rm(e);const i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const l=Uw(e);for(;s<=i-o;o+=s)this.process(l,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){hc(this),cO(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let f=o;f<s;f++)t[f]=0;Zz(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Uw(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=l/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<c;f++)a.setUint32(4*f,u[f],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(r),e}}const eV=(n,e,t)=>n&e^~n&t,tV=(n,e,t)=>n&e^n&t^e&t,nV=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),oo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ao=new Uint32Array(64);class rV extends hO{constructor(){super(64,32,8,!1),this.A=oo[0]|0,this.B=oo[1]|0,this.C=oo[2]|0,this.D=oo[3]|0,this.E=oo[4]|0,this.F=oo[5]|0,this.G=oo[6]|0,this.H=oo[7]|0}get(){const{A:e,B:t,C:r,D:s,E:i,F:o,G:a,H:l}=this;return[e,t,r,s,i,o,a,l]}set(e,t,r,s,i,o,a,l){this.A=e|0,this.B=t|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=l|0}process(e,t){for(let f=0;f<16;f++,t+=4)ao[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){const d=ao[f-15],h=ao[f-2],p=Ss(d,7)^Ss(d,18)^d>>>3,g=Ss(h,17)^Ss(h,19)^h>>>10;ao[f]=g+ao[f-7]+p+ao[f-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:l,G:c,H:u}=this;for(let f=0;f<64;f++){const d=Ss(a,6)^Ss(a,11)^Ss(a,25),h=u+d+eV(a,l,c)+nV[f]+ao[f]|0,g=(Ss(r,2)^Ss(r,13)^Ss(r,22))+tV(r,s,i)|0;u=c,c=l,l=a,a=o+h|0,o=i,i=s,s=r,r=h+g|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,s,i,o,a,l,c,u)}roundClean(){ao.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const pO=jw(()=>new rV),Pm=BigInt(2**32-1),$w=BigInt(32);function mO(n,e=!1){return e?{h:Number(n&Pm),l:Number(n>>$w&Pm)}:{h:Number(n>>$w&Pm)|0,l:Number(n&Pm)|0}}function gO(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=mO(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const sV=(n,e)=>BigInt(n>>>0)<<$w|BigInt(e>>>0),iV=(n,e,t)=>n>>>t,oV=(n,e,t)=>n<<32-t|e>>>t,aV=(n,e,t)=>n>>>t|e<<32-t,lV=(n,e,t)=>n<<32-t|e>>>t,cV=(n,e,t)=>n<<64-t|e>>>t-32,uV=(n,e,t)=>n>>>t-32|e<<64-t,fV=(n,e)=>e,dV=(n,e)=>n,yO=(n,e,t)=>n<<t|e>>>32-t,bO=(n,e,t)=>e<<t|n>>>32-t,wO=(n,e,t)=>e<<t-32|n>>>64-t,vO=(n,e,t)=>n<<t-32|e>>>64-t;function hV(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/2**32|0)|0,l:s|0}}const Fe={fromBig:mO,split:gO,toBig:sV,shrSH:iV,shrSL:oV,rotrSH:aV,rotrSL:lV,rotrBH:cV,rotrBL:uV,rotr32H:fV,rotr32L:dV,rotlSH:yO,rotlSL:bO,rotlBH:wO,rotlBL:vO,add:hV,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,add5H:(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,add5L:(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)},[pV,mV]=Fe.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),lo=new Uint32Array(80),co=new Uint32Array(80);class gV extends hO{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:l,Eh:c,El:u,Fh:f,Fl:d,Gh:h,Gl:p,Hh:g,Hl:y}=this;return[e,t,r,s,i,o,a,l,c,u,f,d,h,p,g,y]}set(e,t,r,s,i,o,a,l,c,u,f,d,h,p,g,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=l|0,this.Eh=c|0,this.El=u|0,this.Fh=f|0,this.Fl=d|0,this.Gh=h|0,this.Gl=p|0,this.Hh=g|0,this.Hl=y|0}process(e,t){for(let v=0;v<16;v++,t+=4)lo[v]=e.getUint32(t),co[v]=e.getUint32(t+=4);for(let v=16;v<80;v++){const w=lo[v-15]|0,E=co[v-15]|0,C=Fe.rotrSH(w,E,1)^Fe.rotrSH(w,E,8)^Fe.shrSH(w,E,7),T=Fe.rotrSL(w,E,1)^Fe.rotrSL(w,E,8)^Fe.shrSL(w,E,7),N=lo[v-2]|0,M=co[v-2]|0,O=Fe.rotrSH(N,M,19)^Fe.rotrBH(N,M,61)^Fe.shrSH(N,M,6),I=Fe.rotrSL(N,M,19)^Fe.rotrBL(N,M,61)^Fe.shrSL(N,M,6),L=Fe.add4L(T,I,co[v-7],co[v-16]),$=Fe.add4H(L,C,O,lo[v-7],lo[v-16]);lo[v]=$|0,co[v]=L|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:l,Dh:c,Dl:u,Eh:f,El:d,Fh:h,Fl:p,Gh:g,Gl:y,Hh:b,Hl:x}=this;for(let v=0;v<80;v++){const w=Fe.rotrSH(f,d,14)^Fe.rotrSH(f,d,18)^Fe.rotrBH(f,d,41),E=Fe.rotrSL(f,d,14)^Fe.rotrSL(f,d,18)^Fe.rotrBL(f,d,41),C=f&h^~f&g,T=d&p^~d&y,N=Fe.add5L(x,E,T,mV[v],co[v]),M=Fe.add5H(N,b,w,C,pV[v],lo[v]),O=N|0,I=Fe.rotrSH(r,s,28)^Fe.rotrBH(r,s,34)^Fe.rotrBH(r,s,39),L=Fe.rotrSL(r,s,28)^Fe.rotrBL(r,s,34)^Fe.rotrBL(r,s,39),$=r&i^r&a^i&a,J=s&o^s&l^o&l;b=g|0,x=y|0,g=h|0,y=p|0,h=f|0,p=d|0,{h:f,l:d}=Fe.add(c|0,u|0,M|0,O|0),c=a|0,u=l|0,a=i|0,l=o|0,i=r|0,o=s|0;const U=Fe.add3L(O,L,J);r=Fe.add3H(U,M,I,$),s=U|0}({h:r,l:s}=Fe.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=Fe.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l}=Fe.add(this.Ch|0,this.Cl|0,a|0,l|0),{h:c,l:u}=Fe.add(this.Dh|0,this.Dl|0,c|0,u|0),{h:f,l:d}=Fe.add(this.Eh|0,this.El|0,f|0,d|0),{h,l:p}=Fe.add(this.Fh|0,this.Fl|0,h|0,p|0),{h:g,l:y}=Fe.add(this.Gh|0,this.Gl|0,g|0,y|0),{h:b,l:x}=Fe.add(this.Hh|0,this.Hl|0,b|0,x|0),this.set(r,s,i,o,a,l,c,u,f,d,h,p,g,y,b,x)}roundClean(){lo.fill(0),co.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const yV=jw(()=>new gV);function bV(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const AO=bV();AO.crypto||AO.msCrypto;function wV(n){switch(n){case"sha256":return pO.create();case"sha512":return yV.create()}H(!1,"invalid hashing algorithm name","algorithm",n)}const[xO,EO,kO]=[[],[],[]],vV=BigInt(0),qf=BigInt(1),AV=BigInt(2),xV=BigInt(7),EV=BigInt(256),kV=BigInt(113);for(let n=0,e=qf,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],xO.push(2*(5*r+t)),EO.push((n+1)*(n+2)/2%64);let s=vV;for(let i=0;i<7;i++)e=(e<<qf^(e>>xV)*kV)%EV,e&AV&&(s^=qf<<(qf<<BigInt(i))-qf);kO.push(s)}const[CV,SV]=gO(kO,!0),CO=(n,e,t)=>t>32?wO(n,e,t):yO(n,e,t),SO=(n,e,t)=>t>32?vO(n,e,t):bO(n,e,t);function TV(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],u=t[l+1],f=CO(c,u,1)^t[a],d=SO(c,u,1)^t[a+1];for(let h=0;h<50;h+=10)n[o+h]^=f,n[o+h+1]^=d}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=EO[o],l=CO(s,i,a),c=SO(s,i,a),u=xO[o];s=n[u],i=n[u+1],n[u]=l,n[u+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=CV[r],n[1]^=SV[r]}t.fill(0)}class zw extends Hw{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Mm(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=qz(this.state)}keccak(){TV(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){hc(this);const{blockLen:t,state:r}=this;e=Rm(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){hc(this,!1),Bw(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Mm(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(cO(e,this),this.finished)throw new 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){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new zw(t,r,s,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=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const OV=((n,e,t)=>jw(()=>new zw(e,n,t)))(1,136,256/8);let TO=!1;const OO=function(n){return OV(n)};let NO=OO;function Ft(n){const e=qe(n,"data");return ce(NO(e))}Ft._=OO,Ft.lock=function(){TO=!0},Ft.register=function(n){if(TO)throw new TypeError("keccak256 is locked");NO=n},Object.freeze(Ft);const MO=function(n){return wV("sha256").update(n).digest()};let RO=MO,PO=!1;function pc(n){const e=qe(n,"data");return ce(RO(e))}pc._=MO,pc.lock=function(){PO=!0},pc.register=function(n){if(PO)throw new Error("sha256 is locked");RO=n},Object.freeze(pc),Object.freeze(pc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const DO=BigInt(0),Dm=BigInt(1),NV=BigInt(2),Im=n=>n instanceof Uint8Array,MV=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function mc(n){if(!Im(n))throw new Error("Uint8Array expected");let e="";for(let t=0;t<n.length;t++)e+=MV[n[t]];return e}function IO(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function Vw(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}function gc(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let r=0;r<t.length;r++){const s=r*2,i=n.slice(s,s+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t}function Aa(n){return Vw(mc(n))}function Ww(n){if(!Im(n))throw new Error("Uint8Array expected");return Vw(mc(Uint8Array.from(n).reverse()))}function yc(n,e){return gc(n.toString(16).padStart(e*2,"0"))}function Gw(n,e){return yc(n,e).reverse()}function RV(n){return gc(IO(n))}function Vr(n,e,t){let r;if(typeof e=="string")try{r=gc(e)}catch(i){throw new Error(`${n} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Im(e))r=Uint8Array.from(e);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof t=="number"&&s!==t)throw new Error(`${n} expected ${t} bytes, got ${s}`);return r}function Qf(...n){const e=new Uint8Array(n.reduce((r,s)=>r+s.length,0));let t=0;return n.forEach(r=>{if(!Im(r))throw new Error("Uint8Array expected");e.set(r,t),t+=r.length}),e}function PV(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function DV(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function IV(n){let e;for(e=0;n>DO;n>>=Dm,e+=1);return e}function _V(n,e){return n>>BigInt(e)&Dm}const LV=(n,e,t)=>n|(t?Dm:DO)<<BigInt(e),Kw=n=>(NV<<BigInt(n-1))-Dm,Jw=n=>new Uint8Array(n),_O=n=>Uint8Array.from(n);function LO(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=Jw(n),s=Jw(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...f)=>t(s,r,...f),l=(f=Jw())=>{s=a(_O([0]),f),r=a(),f.length!==0&&(s=a(_O([1]),f),r=a())},c=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0;const d=[];for(;f<e;){r=a();const h=r.slice();d.push(h),f+=r.length}return Qf(...d)};return(f,d)=>{o(),l(f);let h;for(;!(h=d(c()));)l();return o(),h}}const BV={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||n instanceof Uint8Array,isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function Yf(n,e,t={}){const r=(s,i,o)=>{const a=BV[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const l=n[s];if(!(o&&l===void 0)&&!a(l,n))throw new Error(`Invalid param ${String(s)}=${l} (${typeof l}), expected ${i}`)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(t))r(s,i,!0);return n}const FV=Object.freeze(Object.defineProperty({__proto__:null,bitGet:_V,bitLen:IV,bitMask:Kw,bitSet:LV,bytesToHex:mc,bytesToNumberBE:Aa,bytesToNumberLE:Ww,concatBytes:Qf,createHmacDrbg:LO,ensureBytes:Vr,equalBytes:PV,hexToBytes:gc,hexToNumber:Vw,numberToBytesBE:yc,numberToBytesLE:Gw,numberToHexUnpadded:IO,numberToVarBytesBE:RV,utf8ToBytes:DV,validateObject:Yf},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const en=BigInt(0),Pt=BigInt(1),xa=BigInt(2),UV=BigInt(3),qw=BigInt(4),BO=BigInt(5),FO=BigInt(8);BigInt(9),BigInt(16);function zn(n,e){const t=n%e;return t>=en?t:e+t}function HV(n,e,t){if(t<=en||e<en)throw new Error("Expected power/modulo > 0");if(t===Pt)return en;let r=Pt;for(;e>en;)e&Pt&&(r=r*n%t),n=n*n%t,e>>=Pt;return r}function Er(n,e,t){let r=n;for(;e-- >en;)r*=r,r%=t;return r}function Qw(n,e){if(n===en||e<=en)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=zn(n,e),r=e,s=en,i=Pt;for(;t!==en;){const a=r/t,l=r%t,c=s-i*a;r=t,t=l,s=i,i=c}if(r!==Pt)throw new Error("invert: does not exist");return zn(s,e)}function jV(n){const e=(n-Pt)/xa;let t,r,s;for(t=n-Pt,r=0;t%xa===en;t/=xa,r++);for(s=xa;s<n&&HV(s,e,n)!==n-Pt;s++);if(r===1){const o=(n+Pt)/qw;return function(l,c){const u=l.pow(c,o);if(!l.eql(l.sqr(u),c))throw new Error("Cannot find square root");return u}}const i=(t+Pt)/xa;return function(a,l){if(a.pow(l,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let c=r,u=a.pow(a.mul(a.ONE,s),t),f=a.pow(l,i),d=a.pow(l,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let h=1;for(let g=a.sqr(d);h<c&&!a.eql(g,a.ONE);h++)g=a.sqr(g);const p=a.pow(u,Pt<<BigInt(c-h-1));u=a.sqr(p),f=a.mul(f,p),d=a.mul(d,u),c=h}return f}}function $V(n){if(n%qw===UV){const e=(n+Pt)/qw;return function(r,s){const i=r.pow(s,e);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%FO===BO){const e=(n-BO)/FO;return function(r,s){const i=r.mul(s,xa),o=r.pow(i,e),a=r.mul(s,o),l=r.mul(r.mul(a,xa),o),c=r.mul(a,r.sub(l,r.ONE));if(!r.eql(r.sqr(c),s))throw new Error("Cannot find square root");return c}}return jV(n)}const zV=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function VV(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=zV.reduce((r,s)=>(r[s]="function",r),e);return Yf(n,t)}function WV(n,e,t){if(t<en)throw new Error("Expected power > 0");if(t===en)return n.ONE;if(t===Pt)return e;let r=n.ONE,s=e;for(;t>en;)t&Pt&&(r=n.mul(r,s)),s=n.sqr(s),t>>=Pt;return r}function GV(n,e){const t=new Array(e.length),r=e.reduce((i,o,a)=>n.is0(o)?i:(t[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return e.reduceRight((i,o,a)=>n.is0(o)?i:(t[a]=n.mul(i,t[a]),n.mul(i,o)),s),t}function UO(n,e){const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function KV(n,e,t=!1,r={}){if(n<=en)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=UO(n,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=$V(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:Kw(s),ZERO:en,ONE:Pt,create:l=>zn(l,n),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return en<=l&&l<n},is0:l=>l===en,isOdd:l=>(l&Pt)===Pt,neg:l=>zn(-l,n),eql:(l,c)=>l===c,sqr:l=>zn(l*l,n),add:(l,c)=>zn(l+c,n),sub:(l,c)=>zn(l-c,n),mul:(l,c)=>zn(l*c,n),pow:(l,c)=>WV(a,l,c),div:(l,c)=>zn(l*Qw(c,n),n),sqrN:l=>l*l,addN:(l,c)=>l+c,subN:(l,c)=>l-c,mulN:(l,c)=>l*c,inv:l=>Qw(l,n),sqrt:r.sqrt||(l=>o(a,l)),invertBatch:l=>GV(a,l),cmov:(l,c,u)=>u?c:l,toBytes:l=>t?Gw(l,i):yc(l,i),fromBytes:l=>{if(l.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${l.length}`);return t?Ww(l):Aa(l)}});return Object.freeze(a)}function HO(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function jO(n){const e=HO(n);return e+Math.ceil(e/2)}function JV(n,e,t=!1){const r=n.length,s=HO(e),i=jO(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=t?Aa(n):Ww(n),a=zn(o,e-Pt)+Pt;return t?Gw(a,s):yc(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const qV=BigInt(0),Yw=BigInt(1);function QV(n,e){const t=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>qV;)i&Yw&&(o=o.add(a)),a=a.double(),i>>=Yw;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),l=[];let c=s,u=c;for(let f=0;f<o;f++){u=c,l.push(u);for(let d=1;d<a;d++)u=u.add(c),l.push(u);c=u.double()}return l},wNAF(s,i,o){const{windows:a,windowSize:l}=r(s);let c=n.ZERO,u=n.BASE;const f=BigInt(2**s-1),d=2**s,h=BigInt(s);for(let p=0;p<a;p++){const g=p*l;let y=Number(o&f);o>>=h,y>l&&(y-=d,o+=Yw);const b=g,x=g+Math.abs(y)-1,v=p%2!==0,w=y<0;y===0?u=u.add(t(v,i[b])):c=c.add(t(w,i[x]))}return{p:c,f:u}},wNAFCached(s,i,o,a){const l=s._WINDOW_SIZE||1;let c=i.get(s);return c||(c=this.precomputeWindow(s,l),l!==1&&i.set(s,a(c))),this.wNAF(l,c,o)}}}function $O(n){return VV(n.Fp),Yf(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...UO(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function YV(n){const e=$O(n);Yf(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:s}=e;if(t){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:XV,hexToBytes:ZV}=FV,Ea={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(n){const{Err:e}=Ea;if(n.length<2||n[0]!==2)throw new e("Invalid signature integer tag");const t=n[1],r=n.subarray(2,t+2);if(!t||r.length!==t)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:XV(r),l:n.subarray(t+2)}},toSig(n){const{Err:e}=Ea,t=typeof n=="string"?ZV(n):n;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let r=t.length;if(r<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=Ea._parseInt(t.subarray(2)),{d:o,l:a}=Ea._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const e=c=>Number.parseInt(c[0],16)&8?"00"+c:c,t=c=>{const u=c.toString(16);return u.length&1?`0${u}`:u},r=e(t(n.s)),s=e(t(n.r)),i=r.length/2,o=s.length/2,a=t(i),l=t(o);return`30${t(o+i+4)}02${l}${s}02${a}${r}`}},ii=BigInt(0),kr=BigInt(1);BigInt(2);const zO=BigInt(3);BigInt(4);function e9(n){const e=YV(n),{Fp:t}=e,r=e.toBytes||((p,g,y)=>{const b=g.toAffine();return Qf(Uint8Array.from([4]),t.toBytes(b.x),t.toBytes(b.y))}),s=e.fromBytes||(p=>{const g=p.subarray(1),y=t.fromBytes(g.subarray(0,t.BYTES)),b=t.fromBytes(g.subarray(t.BYTES,2*t.BYTES));return{x:y,y:b}});function i(p){const{a:g,b:y}=e,b=t.sqr(p),x=t.mul(b,p);return t.add(t.add(x,t.mul(p,g)),y)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function o(p){return typeof p=="bigint"&&ii<p&&p<e.n}function a(p){if(!o(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(p){const{allowedPrivateKeyLengths:g,nByteLength:y,wrapPrivateKey:b,n:x}=e;if(g&&typeof p!="bigint"){if(p instanceof Uint8Array&&(p=mc(p)),typeof p!="string"||!g.includes(p.length))throw new Error("Invalid key");p=p.padStart(y*2,"0")}let v;try{v=typeof p=="bigint"?p:Aa(Vr("private key",p,y))}catch{throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof p}`)}return b&&(v=zn(v,x)),a(v),v}const c=new Map;function u(p){if(!(p instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(g,y,b){if(this.px=g,this.py=y,this.pz=b,g==null||!t.isValid(g))throw new Error("x required");if(y==null||!t.isValid(y))throw new Error("y required");if(b==null||!t.isValid(b))throw new Error("z required")}static fromAffine(g){const{x:y,y:b}=g||{};if(!g||!t.isValid(y)||!t.isValid(b))throw new Error("invalid affine point");if(g instanceof f)throw new Error("projective point not allowed");const x=v=>t.eql(v,t.ZERO);return x(y)&&x(b)?f.ZERO:new f(y,b,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){const y=t.invertBatch(g.map(b=>b.pz));return g.map((b,x)=>b.toAffine(y[x])).map(f.fromAffine)}static fromHex(g){const y=f.fromAffine(s(Vr("pointHex",g)));return y.assertValidity(),y}static fromPrivateKey(g){return f.BASE.multiply(l(g))}_setWindowSize(g){this._WINDOW_SIZE=g,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:g,y}=this.toAffine();if(!t.isValid(g)||!t.isValid(y))throw new Error("bad point: x or y not FE");const b=t.sqr(y),x=i(g);if(!t.eql(b,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:g}=this.toAffine();if(t.isOdd)return!t.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){u(g);const{px:y,py:b,pz:x}=this,{px:v,py:w,pz:E}=g,C=t.eql(t.mul(y,E),t.mul(v,x)),T=t.eql(t.mul(b,E),t.mul(w,x));return C&&T}negate(){return new f(this.px,t.neg(this.py),this.pz)}double(){const{a:g,b:y}=e,b=t.mul(y,zO),{px:x,py:v,pz:w}=this;let E=t.ZERO,C=t.ZERO,T=t.ZERO,N=t.mul(x,x),M=t.mul(v,v),O=t.mul(w,w),I=t.mul(x,v);return I=t.add(I,I),T=t.mul(x,w),T=t.add(T,T),E=t.mul(g,T),C=t.mul(b,O),C=t.add(E,C),E=t.sub(M,C),C=t.add(M,C),C=t.mul(E,C),E=t.mul(I,E),T=t.mul(b,T),O=t.mul(g,O),I=t.sub(N,O),I=t.mul(g,I),I=t.add(I,T),T=t.add(N,N),N=t.add(T,N),N=t.add(N,O),N=t.mul(N,I),C=t.add(C,N),O=t.mul(v,w),O=t.add(O,O),N=t.mul(O,I),E=t.sub(E,N),T=t.mul(O,M),T=t.add(T,T),T=t.add(T,T),new f(E,C,T)}add(g){u(g);const{px:y,py:b,pz:x}=this,{px:v,py:w,pz:E}=g;let C=t.ZERO,T=t.ZERO,N=t.ZERO;const M=e.a,O=t.mul(e.b,zO);let I=t.mul(y,v),L=t.mul(b,w),$=t.mul(x,E),J=t.add(y,b),U=t.add(v,w);J=t.mul(J,U),U=t.add(I,L),J=t.sub(J,U),U=t.add(y,x);let G=t.add(v,E);return U=t.mul(U,G),G=t.add(I,$),U=t.sub(U,G),G=t.add(b,x),C=t.add(w,E),G=t.mul(G,C),C=t.add(L,$),G=t.sub(G,C),N=t.mul(M,U),C=t.mul(O,$),N=t.add(C,N),C=t.sub(L,N),N=t.add(L,N),T=t.mul(C,N),L=t.add(I,I),L=t.add(L,I),$=t.mul(M,$),U=t.mul(O,U),L=t.add(L,$),$=t.sub(I,$),$=t.mul(M,$),U=t.add(U,$),I=t.mul(L,U),T=t.add(T,I),I=t.mul(G,U),C=t.mul(J,C),C=t.sub(C,I),I=t.mul(J,L),N=t.mul(G,N),N=t.add(N,I),new f(C,T,N)}subtract(g){return this.add(g.negate())}is0(){return this.equals(f.ZERO)}wNAF(g){return h.wNAFCached(this,c,g,y=>{const b=t.invertBatch(y.map(x=>x.pz));return y.map((x,v)=>x.toAffine(b[v])).map(f.fromAffine)})}multiplyUnsafe(g){const y=f.ZERO;if(g===ii)return y;if(a(g),g===kr)return this;const{endo:b}=e;if(!b)return h.unsafeLadder(this,g);let{k1neg:x,k1:v,k2neg:w,k2:E}=b.splitScalar(g),C=y,T=y,N=this;for(;v>ii||E>ii;)v&kr&&(C=C.add(N)),E&kr&&(T=T.add(N)),N=N.double(),v>>=kr,E>>=kr;return x&&(C=C.negate()),w&&(T=T.negate()),T=new f(t.mul(T.px,b.beta),T.py,T.pz),C.add(T)}multiply(g){a(g);let y=g,b,x;const{endo:v}=e;if(v){const{k1neg:w,k1:E,k2neg:C,k2:T}=v.splitScalar(y);let{p:N,f:M}=this.wNAF(E),{p:O,f:I}=this.wNAF(T);N=h.constTimeNegate(w,N),O=h.constTimeNegate(C,O),O=new f(t.mul(O.px,v.beta),O.py,O.pz),b=N.add(O),x=M.add(I)}else{const{p:w,f:E}=this.wNAF(y);b=w,x=E}return f.normalizeZ([b,x])[0]}multiplyAndAddUnsafe(g,y,b){const x=f.BASE,v=(E,C)=>C===ii||C===kr||!E.equals(x)?E.multiplyUnsafe(C):E.multiply(C),w=v(this,y).add(v(g,b));return w.is0()?void 0:w}toAffine(g){const{px:y,py:b,pz:x}=this,v=this.is0();g==null&&(g=v?t.ONE:t.inv(x));const w=t.mul(y,g),E=t.mul(b,g),C=t.mul(x,g);if(v)return{x:t.ZERO,y:t.ZERO};if(!t.eql(C,t.ONE))throw new Error("invZ was invalid");return{x:w,y:E}}isTorsionFree(){const{h:g,isTorsionFree:y}=e;if(g===kr)return!0;if(y)return y(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:g,clearCofactor:y}=e;return g===kr?this:y?y(f,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return this.assertValidity(),r(f,this,g)}toHex(g=!0){return mc(this.toRawBytes(g))}}f.BASE=new f(e.Gx,e.Gy,t.ONE),f.ZERO=new f(t.ZERO,t.ONE,t.ZERO);const d=e.nBitLength,h=QV(f,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:o}}function t9(n){const e=$O(n);return Yf(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function n9(n){const e=t9(n),{Fp:t,n:r}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(U){return ii<U&&U<t.ORDER}function a(U){return zn(U,r)}function l(U){return Qw(U,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:f,isWithinCurveOrder:d}=e9({...e,toBytes(U,G,Y){const re=G.toAffine(),Z=t.toBytes(re.x),me=Qf;return Y?me(Uint8Array.from([G.hasEvenY()?2:3]),Z):me(Uint8Array.from([4]),Z,t.toBytes(re.y))},fromBytes(U){const G=U.length,Y=U[0],re=U.subarray(1);if(G===s&&(Y===2||Y===3)){const Z=Aa(re);if(!o(Z))throw new Error("Point is not on curve");const me=f(Z);let Me=t.sqrt(me);const De=(Me&kr)===kr;return(Y&1)===1!==De&&(Me=t.neg(Me)),{x:Z,y:Me}}else if(G===i&&Y===4){const Z=t.fromBytes(re.subarray(0,t.BYTES)),me=t.fromBytes(re.subarray(t.BYTES,2*t.BYTES));return{x:Z,y:me}}else throw new Error(`Point of length ${G} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),h=U=>mc(yc(U,e.nByteLength));function p(U){const G=r>>kr;return U>G}function g(U){return p(U)?a(-U):U}const y=(U,G,Y)=>Aa(U.slice(G,Y));class b{constructor(G,Y,re){this.r=G,this.s=Y,this.recovery=re,this.assertValidity()}static fromCompact(G){const Y=e.nByteLength;return G=Vr("compactSignature",G,Y*2),new b(y(G,0,Y),y(G,Y,2*Y))}static fromDER(G){const{r:Y,s:re}=Ea.toSig(Vr("DER",G));return new b(Y,re)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(G){return new b(this.r,this.s,G)}recoverPublicKey(G){const{r:Y,s:re,recovery:Z}=this,me=T(Vr("msgHash",G));if(Z==null||![0,1,2,3].includes(Z))throw new Error("recovery id invalid");const Me=Z===2||Z===3?Y+e.n:Y;if(Me>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const De=Z&1?"03":"02",Se=c.fromHex(De+h(Me)),Ee=l(Me),He=a(-me*Ee),Ve=a(re*Ee),Xe=c.BASE.multiplyAndAddUnsafe(Se,He,Ve);if(!Xe)throw new Error("point at infinify");return Xe.assertValidity(),Xe}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return gc(this.toDERHex())}toDERHex(){return Ea.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return gc(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const x={isValidPrivateKey(U){try{return u(U),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const U=jO(e.n);return JV(e.randomBytes(U),e.n)},precompute(U=8,G=c.BASE){return G._setWindowSize(U),G.multiply(BigInt(3)),G}};function v(U,G=!0){return c.fromPrivateKey(U).toRawBytes(G)}function w(U){const G=U instanceof Uint8Array,Y=typeof U=="string",re=(G||Y)&&U.length;return G?re===s||re===i:Y?re===2*s||re===2*i:U instanceof c}function E(U,G,Y=!0){if(w(U))throw new Error("first arg must be private key");if(!w(G))throw new Error("second arg must be public key");return c.fromHex(G).multiply(u(U)).toRawBytes(Y)}const C=e.bits2int||function(U){const G=Aa(U),Y=U.length*8-e.nBitLength;return Y>0?G>>BigInt(Y):G},T=e.bits2int_modN||function(U){return a(C(U))},N=Kw(e.nBitLength);function M(U){if(typeof U!="bigint")throw new Error("bigint expected");if(!(ii<=U&&U<N))throw new Error(`bigint expected < 2^${e.nBitLength}`);return yc(U,e.nByteLength)}function O(U,G,Y=I){if(["recovered","canonical"].some(Ze=>Ze in Y))throw new Error("sign() legacy options not supported");const{hash:re,randomBytes:Z}=e;let{lowS:me,prehash:Me,extraEntropy:De}=Y;me==null&&(me=!0),U=Vr("msgHash",U),Me&&(U=Vr("prehashed msgHash",re(U)));const Se=T(U),Ee=u(G),He=[M(Ee),M(Se)];if(De!=null){const Ze=De===!0?Z(t.BYTES):De;He.push(Vr("extraEntropy",Ze))}const Ve=Qf(...He),Xe=Se;function mt(Ze){const nt=C(Ze);if(!d(nt))return;const zt=l(nt),yt=c.BASE.multiply(nt).toAffine(),Qe=a(yt.x);if(Qe===ii)return;const lt=a(zt*a(Xe+Qe*Ee));if(lt===ii)return;let z=(yt.x===Qe?0:2)|Number(yt.y&kr),K=lt;return me&&p(lt)&&(K=g(lt),z^=1),new b(Qe,K,z)}return{seed:Ve,k2sig:mt}}const I={lowS:e.lowS,prehash:!1},L={lowS:e.lowS,prehash:!1};function $(U,G,Y=I){const{seed:re,k2sig:Z}=O(U,G,Y),me=e;return LO(me.hash.outputLen,me.nByteLength,me.hmac)(re,Z)}c.BASE._setWindowSize(8);function J(U,G,Y,re=L){var yt;const Z=U;if(G=Vr("msgHash",G),Y=Vr("publicKey",Y),"strict"in re)throw new Error("options.strict was renamed to lowS");const{lowS:me,prehash:Me}=re;let De,Se;try{if(typeof Z=="string"||Z instanceof Uint8Array)try{De=b.fromDER(Z)}catch(Qe){if(!(Qe instanceof Ea.Err))throw Qe;De=b.fromCompact(Z)}else if(typeof Z=="object"&&typeof Z.r=="bigint"&&typeof Z.s=="bigint"){const{r:Qe,s:lt}=Z;De=new b(Qe,lt)}else throw new Error("PARSE");Se=c.fromHex(Y)}catch(Qe){if(Qe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(me&&De.hasHighS())return!1;Me&&(G=e.hash(G));const{r:Ee,s:He}=De,Ve=T(G),Xe=l(He),mt=a(Ve*Xe),Ze=a(Ee*Xe),nt=(yt=c.BASE.multiplyAndAddUnsafe(Se,mt,Ze))==null?void 0:yt.toAffine();return nt?a(nt.x)===Ee:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:E,sign:$,verify:J,ProjectivePoint:c,Signature:b,utils:x}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function r9(n){return{hash:n,hmac:(e,...t)=>dO(n,e,Yz(...t)),randomBytes:Xz}}function s9(n,e){const t=r=>n9({...n,...r9(r)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const VO=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),WO=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),i9=BigInt(1),Xw=BigInt(2),GO=(n,e)=>(n+e/Xw)/e;function o9(n){const e=VO,t=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),c=n*n*n%e,u=c*c*n%e,f=Er(u,t,e)*u%e,d=Er(f,t,e)*u%e,h=Er(d,Xw,e)*c%e,p=Er(h,s,e)*h%e,g=Er(p,i,e)*p%e,y=Er(g,a,e)*g%e,b=Er(y,l,e)*y%e,x=Er(b,a,e)*g%e,v=Er(x,t,e)*u%e,w=Er(v,o,e)*p%e,E=Er(w,r,e)*c%e,C=Er(E,Xw,e);if(!Zw.eql(Zw.sqr(C),n))throw new Error("Cannot find square root");return C}const Zw=KV(VO,void 0,void 0,{sqrt:o9}),uo=s9({a:BigInt(0),b:BigInt(7),Fp:Zw,n:WO,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=WO,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-i9*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),a=GO(i*n,e),l=GO(-r*n,e);let c=zn(n-a*t-l*s,e),u=zn(-a*r-l*i,e);const f=c>o,d=u>o;if(f&&(c=e-c),d&&(u=e-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:f,k1:c,k2neg:d,k2:u}}}},pO);BigInt(0),uo.ProjectivePoint;const Xf="0x0000000000000000000000000000000000000000",KO="0x0000000000000000000000000000000000000000000000000000000000000000",JO=BigInt(0),qO=BigInt(1),QO=BigInt(2),YO=BigInt(27),XO=BigInt(28),_m=BigInt(35),bc={};function ZO(n){return ya(Sn(n),32)}const Qr=class Qr{constructor(e,t,r,s){W(this,Uc,void 0);W(this,Hc,void 0);W(this,jc,void 0);W(this,ja,void 0);Em(e,bc,"Signature"),D(this,Uc,t),D(this,Hc,r),D(this,jc,s),D(this,ja,null)}get r(){return k(this,Uc)}set r(e){H(cc(e)===32,"invalid r","value",e),D(this,Uc,ce(e))}get s(){return k(this,Hc)}set s(e){H(cc(e)===32,"invalid s","value",e);const t=ce(e);H(parseInt(t.substring(0,3))<8,"non-canonical s","value",t),D(this,Hc,t)}get v(){return k(this,jc)}set v(e){const t=Pe(e,"value");H(t===27||t===28,"invalid v","v",e),D(this,jc,t)}get networkV(){return k(this,ja)}get legacyChainId(){const e=this.networkV;return e==null?null:Qr.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=qe(this.s);return this.yParity&&(e[0]|=128),ce(e)}get compactSerialized(){return Rt([this.r,this.yParityAndS])}get serialized(){return Rt([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new Qr(bc,this.r,this.s,this.v);return this.networkV&&D(e,ja,this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(e){const t=pe(e,"v");return t==YO||t==XO?JO:(H(t>=_m,"invalid EIP-155 v","v",e),(t-_m)/QO)}static getChainIdV(e,t){return pe(e)*QO+BigInt(35+t-27)}static getNormalizedV(e){const t=pe(e);return t===JO||t===YO?27:t===qO||t===XO?28:(H(t>=_m,"invalid v","v",e),t&qO?27:28)}static from(e){function t(c,u){H(c,u,"signature",e)}if(e==null)return new Qr(bc,KO,KO,27);if(typeof e=="string"){const c=qe(e,"signature");if(c.length===64){const u=ce(c.slice(0,32)),f=c.slice(32,64),d=f[0]&128?28:27;return f[0]&=127,new Qr(bc,u,ce(f),d)}if(c.length===65){const u=ce(c.slice(0,32)),f=c.slice(32,64);t((f[0]&128)===0,"non-canonical s");const d=Qr.getNormalizedV(c[64]);return new Qr(bc,u,ce(f),d)}t(!1,"invalid raw signature length")}if(e instanceof Qr)return e.clone();const r=e.r;t(r!=null,"missing r");const s=ZO(r),i=function(c,u){if(c!=null)return ZO(c);if(u!=null){t(pt(u,32),"invalid yParityAndS");const f=qe(u);return f[0]&=127,ce(f)}t(!1,"missing s")}(e.s,e.yParityAndS);t((qe(i)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(c,u,f){if(c!=null){const d=pe(c);return{networkV:d>=_m?d:void 0,v:Qr.getNormalizedV(d)}}if(u!=null)return t(pt(u,32),"invalid yParityAndS"),{v:qe(u)[0]&128?28:27};if(f!=null){switch(Pe(f,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new Qr(bc,s,i,a);return o&&D(l,ja,o),t(e.yParity==null||Pe(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}};Uc=new WeakMap,Hc=new WeakMap,jc=new WeakMap,ja=new WeakMap;let Wr=Qr;const $a=class $a{constructor(e){W(this,mi,void 0);H(cc(e)===32,"invalid private key","privateKey","[REDACTED]"),D(this,mi,ce(e))}get privateKey(){return k(this,mi)}get publicKey(){return $a.computePublicKey(k(this,mi))}get compressedPublicKey(){return $a.computePublicKey(k(this,mi),!0)}sign(e){H(cc(e)===32,"invalid digest length","digest",e);const t=uo.sign(Cn(e),Cn(k(this,mi)),{lowS:!0});return Wr.from({r:so(t.r,32),s:so(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=$a.computePublicKey(e);return ce(uo.getSharedSecret(Cn(k(this,mi)),qe(t),!1))}static computePublicKey(e,t){let r=qe(e,"key");if(r.length===32){const i=uo.getPublicKey(r,!!t);return ce(i)}if(r.length===64){const i=new Uint8Array(65);i[0]=4,i.set(r,1),r=i}const s=uo.ProjectivePoint.fromHex(r);return ce(s.toRawBytes(t))}static recoverPublicKey(e,t){H(cc(e)===32,"invalid digest length","digest",e);const r=Wr.from(t);let s=uo.Signature.fromCompact(Cn(Rt([r.r,r.s])));s=s.addRecoveryBit(r.yParity);const i=s.recoverPublicKey(Cn(e));return H(i!=null,"invalid signautre for digest","signature",t),"0x"+i.toHex(!1)}static addPoints(e,t,r){const s=uo.ProjectivePoint.fromHex($a.computePublicKey(e).substring(2)),i=uo.ProjectivePoint.fromHex($a.computePublicKey(t).substring(2));return"0x"+s.add(i).toHex(!!r)}};mi=new WeakMap;let Zf=$a;const a9=BigInt(0),l9=BigInt(36);function eN(n){n=n.toLowerCase();const e=n.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const r=qe(Ft(t));for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(r[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const ev={};for(let n=0;n<10;n++)ev[String(n)]=String(n);for(let n=0;n<26;n++)ev[String.fromCharCode(65+n)]=String(10+n);const tN=15;function c9(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let e=n.split("").map(r=>ev[r]).join("");for(;e.length>=tN;){let r=e.substring(0,tN);e=parseInt(r,10)%97+e.substring(r.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const u9=function(){const n={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];n[t]=BigInt(e)}return n}();function f9(n){n=n.toLowerCase();let e=a9;for(let t=0;t<n.length;t++)e=e*l9+u9[n[t]];return e}function st(n){if(H(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const e=eN(n);return H(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===n,"bad address checksum","address",n),e}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){H(n.substring(2,4)===c9(n),"bad icap checksum","address",n);let e=f9(n.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return eN("0x"+e)}H(!1,"invalid address","address",n)}function d9(n){const e=st(n.from);let r=pe(n.nonce,"tx.nonce").toString(16);return r==="0"?r="0x":r.length%2?r="0x0"+r:r="0x"+r,st(Nt(Ft(wa([e,r])),12))}function nN(n){return n&&typeof n.getAddress=="function"}function h9(n){try{return st(n),!0}catch{}return!1}async function tv(n,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(X(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),H(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),st(t)}function Nn(n,e){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?st(n):(X(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),tv(n,e.resolveName(n)));if(nN(n))return tv(n,n.getAddress());if(n&&typeof n.then=="function")return tv(n,n);H(!1,"unsupported addressable value","target",n)}const oi={};function ue(n,e){let t=!1;return e<0&&(t=!0,e*=-1),new mn(oi,`${t?"":"u"}int${e}`,n,{signed:t,width:e})}function Ye(n,e){return new mn(oi,`bytes${e||""}`,n,{size:e})}const rN=Symbol.for("_ethers_typed"),gi=class gi{constructor(e,t,r,s){j(this,"type");j(this,"value");W(this,za,void 0);j(this,"_typedSymbol");s==null&&(s=null),Em(oi,e,"Typed"),be(this,{_typedSymbol:rN,type:t,value:r}),D(this,za,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return k(this,za)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return k(this,za)===!0?-1:k(this,za)===!1?this.value.length:null}static from(e,t){return new gi(oi,e,t)}static uint8(e){return ue(e,8)}static uint16(e){return ue(e,16)}static uint24(e){return ue(e,24)}static uint32(e){return ue(e,32)}static uint40(e){return ue(e,40)}static uint48(e){return ue(e,48)}static uint56(e){return ue(e,56)}static uint64(e){return ue(e,64)}static uint72(e){return ue(e,72)}static uint80(e){return ue(e,80)}static uint88(e){return ue(e,88)}static uint96(e){return ue(e,96)}static uint104(e){return ue(e,104)}static uint112(e){return ue(e,112)}static uint120(e){return ue(e,120)}static uint128(e){return ue(e,128)}static uint136(e){return ue(e,136)}static uint144(e){return ue(e,144)}static uint152(e){return ue(e,152)}static uint160(e){return ue(e,160)}static uint168(e){return ue(e,168)}static uint176(e){return ue(e,176)}static uint184(e){return ue(e,184)}static uint192(e){return ue(e,192)}static uint200(e){return ue(e,200)}static uint208(e){return ue(e,208)}static uint216(e){return ue(e,216)}static uint224(e){return ue(e,224)}static uint232(e){return ue(e,232)}static uint240(e){return ue(e,240)}static uint248(e){return ue(e,248)}static uint256(e){return ue(e,256)}static uint(e){return ue(e,256)}static int8(e){return ue(e,-8)}static int16(e){return ue(e,-16)}static int24(e){return ue(e,-24)}static int32(e){return ue(e,-32)}static int40(e){return ue(e,-40)}static int48(e){return ue(e,-48)}static int56(e){return ue(e,-56)}static int64(e){return ue(e,-64)}static int72(e){return ue(e,-72)}static int80(e){return ue(e,-80)}static int88(e){return ue(e,-88)}static int96(e){return ue(e,-96)}static int104(e){return ue(e,-104)}static int112(e){return ue(e,-112)}static int120(e){return ue(e,-120)}static int128(e){return ue(e,-128)}static int136(e){return ue(e,-136)}static int144(e){return ue(e,-144)}static int152(e){return ue(e,-152)}static int160(e){return ue(e,-160)}static int168(e){return ue(e,-168)}static int176(e){return ue(e,-176)}static int184(e){return ue(e,-184)}static int192(e){return ue(e,-192)}static int200(e){return ue(e,-200)}static int208(e){return ue(e,-208)}static int216(e){return ue(e,-216)}static int224(e){return ue(e,-224)}static int232(e){return ue(e,-232)}static int240(e){return ue(e,-240)}static int248(e){return ue(e,-248)}static int256(e){return ue(e,-256)}static int(e){return ue(e,-256)}static bytes1(e){return Ye(e,1)}static bytes2(e){return Ye(e,2)}static bytes3(e){return Ye(e,3)}static bytes4(e){return Ye(e,4)}static bytes5(e){return Ye(e,5)}static bytes6(e){return Ye(e,6)}static bytes7(e){return Ye(e,7)}static bytes8(e){return Ye(e,8)}static bytes9(e){return Ye(e,9)}static bytes10(e){return Ye(e,10)}static bytes11(e){return Ye(e,11)}static bytes12(e){return Ye(e,12)}static bytes13(e){return Ye(e,13)}static bytes14(e){return Ye(e,14)}static bytes15(e){return Ye(e,15)}static bytes16(e){return Ye(e,16)}static bytes17(e){return Ye(e,17)}static bytes18(e){return Ye(e,18)}static bytes19(e){return Ye(e,19)}static bytes20(e){return Ye(e,20)}static bytes21(e){return Ye(e,21)}static bytes22(e){return Ye(e,22)}static bytes23(e){return Ye(e,23)}static bytes24(e){return Ye(e,24)}static bytes25(e){return Ye(e,25)}static bytes26(e){return Ye(e,26)}static bytes27(e){return Ye(e,27)}static bytes28(e){return Ye(e,28)}static bytes29(e){return Ye(e,29)}static bytes30(e){return Ye(e,30)}static bytes31(e){return Ye(e,31)}static bytes32(e){return Ye(e,32)}static address(e){return new gi(oi,"address",e)}static bool(e){return new gi(oi,"bool",!!e)}static bytes(e){return new gi(oi,"bytes",e)}static string(e){return new gi(oi,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new gi(oi,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===rN}static dereference(e,t){if(gi.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};za=new WeakMap;let mn=gi;class p9 extends si{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let r=mn.dereference(t,"string");try{r=st(r)}catch(s){return this._throwError(s.message,t)}return e.writeValue(r)}decode(e){return st(so(e.readValue(),20))}}class m9 extends si{constructor(t){super(t.name,t.type,"_",t.dynamic);j(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,r){return this.coder.encode(t,r)}decode(t){return this.coder.decode(t)}}function sN(n,e,t){let r=[];if(Array.isArray(t))r=t;else if(t&&typeof t=="object"){let l={};r=e.map(c=>{const u=c.localName;return X(u,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),X(!l[u],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),l[u]=!0,t[u]})}else H(!1,"invalid tuple value","tuple",t);H(e.length===r.length,"types/value length mismatch","tuple",t);let s=new _w,i=new _w,o=[];e.forEach((l,c)=>{let u=r[c];if(l.dynamic){let f=i.length;l.encode(i,u);let d=s.writeUpdatableValue();o.push(h=>{d(h+f)})}else l.encode(s,u)}),o.forEach(l=>{l(s.length)});let a=n.appendWriter(s);return a+=n.appendWriter(i),a}function iN(n,e){let t=[],r=[],s=n.subReader(0);return e.forEach(i=>{let o=null;if(i.dynamic){let a=n.readIndex(),l=s.subReader(a);try{o=i.decode(l)}catch(c){if(Zt(c,"BUFFER_OVERRUN"))throw c;o=c,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(n)}catch(a){if(Zt(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");t.push(o),r.push(i.localName||null)}),dc.fromItems(t,r)}class g9 extends si{constructor(t,r,s){const i=t.type+"["+(r>=0?r:"")+"]",o=r===-1||t.dynamic;super("array",i,s,o);j(this,"coder");j(this,"length");be(this,{coder:t,length:r})}defaultValue(){const t=this.coder.defaultValue(),r=[];for(let s=0;s<this.length;s++)r.push(t);return r}encode(t,r){const s=mn.dereference(r,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,t.writeValue(s.length)),F2(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return sN(t,o,s)}decode(t){let r=this.length;r===-1&&(r=t.readIndex(),X(r*On<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:r*On,length:t.dataLength}));let s=[];for(let i=0;i<r;i++)s.push(new m9(this.coder));return iN(t,s)}}class y9 extends si{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const r=mn.dereference(t,"bool");return e.writeValue(r?1:0)}decode(e){return!!e.readValue()}}class oN extends si{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Cn(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readIndex(),!0)}}class b9 extends oN{constructor(e){super("bytes",e)}decode(e){return ce(super.decode(e))}}class w9 extends si{constructor(t,r){let s="bytes"+String(t);super(s,s,r,!1);j(this,"size");be(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,r){let s=Cn(mn.dereference(r,this.type));return s.length!==this.size&&this._throwError("incorrect data length",r),t.writeBytes(s)}decode(t){return ce(t.readBytes(this.size))}}const v9=new Uint8Array([]);class A9 extends si{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(v9)}decode(e){return e.readBytes(0),null}}const x9=BigInt(0),E9=BigInt(1),k9=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class C9 extends si{constructor(t,r,s){const i=(r?"int":"uint")+t*8;super(i,i,s,!1);j(this,"size");j(this,"signed");be(this,{size:t,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,r){let s=pe(mn.dereference(r,this.type)),i=Kf(k9,On*8);if(this.signed){let o=Kf(i,this.size*8-1);(s>o||s<-(o+E9))&&this._throwError("value out-of-bounds",r),s=$2(s,8*On)}else(s<x9||s>Kf(i,this.size*8))&&this._throwError("value out-of-bounds",r);return t.writeValue(s)}decode(t){let r=Kf(t.readValue(),this.size*8);return this.signed&&(r=Nz(r,this.size*8)),r}}class S9 extends oN{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,ri(mn.dereference(t,"string")))}decode(e){return fc(super.decode(e))}}class Lm extends si{constructor(t,r){let s=!1;const i=[];t.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,r,s);j(this,"coders");be(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(s=>{t.push(s.defaultValue())});const r=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[i]))}),Object.freeze(t)}encode(t,r){const s=mn.dereference(r,"tuple");return sN(t,this.coders,s)}decode(t){return iN(t,this.coders)}}function ka(n){return Ft(ri(n))}var T9="AEEUdwmgDS8BxQKKAP4BOgDjATAAngDUAIMAoABoAOAAagCOAEQAhABMAHIAOwA9ACsANgAmAGIAHgAuACgAJwAXAC0AGgAjAB8ALwAUACkAEgAeAAkAGwARABkAFgA5ACgALQArADcAFQApABAAHgAiABAAGgAeABMAGAUhBe8BFxREN8sF2wC5AK5HAW8ArQkDzQCuhzc3NzcBP68NEfMABQdHBuw5BV8FYAA9MzkI9r4ZBg7QyQAWA9CeOwLNCjcCjqkChuA/lm+RAsXTAoP6ASfnEQDytQFJAjWVCkeXAOsA6godAB/cwdAUE0WlBCN/AQUCQRjFD/MRBjHxDQSJbw0jBzUAswBxme+tnIcAYwabAysG8QAjAEMMmxcDqgPKQyDXCMMxA7kUQwD3NXOrAKmFIAAfBC0D3x4BJQDBGdUFAhEgVD8JnwmQJiNWYUzrg0oAGwAUAB0AFnNcACkAFgBP9h3gPfsDOWDKneY2ChglX1UDYD30ABsAFAAdABZzIGRAnwDD8wAjAEEMzRbDqgMB2sAFYwXqAtCnAsS4AwpUJKRtFHsadUz9AMMVbwLpABM1NJEX0ZkCgYMBEyMAxRVvAukAEzUBUFAtmUwSAy4DBTER33EftQHfSwB5MxJ/AjkWKQLzL8E/cwBB6QH9LQDPDtO9ASNriQC5DQANAwCK21EFI91zHwCoL9kBqQcHBwcHKzUDowBvAQohPvU3fAQgHwCyAc8CKQMA5zMSezr7ULgFmDp/LzVQBgEGAi8FYQVgt8AFcTtlQhpCWEmfe5tmZ6IAExsDzQ8t+X8rBKtTAltbAn0jsy8Bl6utPWMDTR8Ei2kRANkDBrNHNysDBzECQWUAcwFpJ3kAiyUhAJ0BUb8AL3EfAbfNAz81KUsFWwF3YQZtAm0A+VEfAzEJDQBRSQCzAQBlAHsAM70GD/v3IZWHBwARKQAxALsjTwHZAeMPEzmXgIHwABIAGQA8AEUAQDt3gdvIEGcQZAkGTRFMdEIVEwK0D64L7REdDNkq09PgADSxB/MDWwfzA1sDWwfzB/MDWwfzA1sDWwNbA1scEvAi28gQZw9QBHUFlgWTBN4IiyZREYkHMAjaVBV0JhxPA00BBCMtSSQ7mzMTJUpMFE0LCAQ2SmyvfUADTzGzVP2QqgPTMlc5dAkGHnkSqAAyD3skNb1OhnpPcagKU0+2tYdJak5vAsY6sEAACikJm2/Dd1YGRRAfJ6kQ+ww3AbkBPw3xS9wE9QY/BM0fgRkdD9GVoAipLeEM8SbnLqWAXiP5KocF8Uv4POELUVFsD10LaQnnOmeBUgMlAREijwrhDT0IcRD3Cs1vDekRSQc9A9lJngCpBwULFR05FbkmFGKwCw05ewb/GvoLkyazEy17AAXXGiUGUQEtGwMA0y7rhbRaNVwgT2MGBwspI8sUrFAkDSlAu3hMGh8HGSWtApVDdEqLUToelyH6PEENai4XUYAH+TwJGVMLhTyiRq9FEhHWPpE9TCJNTDAEOYMsMyePCdMPiQy9fHYBXQklCbUMdRM1ERs3yQg9Bx0xlygnGQglRplgngT7owP3E9UDDwVDCUUHFwO5HDETMhUtBRGBKNsC9zbZLrcCk1aEARsFzw8pH+MQVEfkDu0InwJpA4cl7wAxFSUAGyKfCEdnAGOP3FMJLs8Iy2pwI3gDaxTrZRF3B5UOWwerHDcVwxzlcMxeD4YMKKezCV8BeQmdAWME5wgNNV+MpCBFZ1eLXBifIGVBQ14AAjUMaRWjRMGHfAKPD28SHwE5AXcHPQ0FAnsR8RFvEJkI74YINbkz/DopBFMhhyAVCisDU2zSCysm/Qz8bQGnEmYDEDRBd/Jnr2C6KBgBBx0yyUFkIfULlk/RDKAaxRhGVDIZ6AfDA/ca9yfuQVsGAwOnBxc6UTPyBMELbQiPCUMATQ6nGwfbGG4KdYzUATWPAbudA1uVhwJzkwY7Bw8Aaw+LBX3pACECqwinAAkA0wNbAD0CsQehAB0AiUUBQQMrMwEl6QKTA5cINc8BmTMB9y0EH8cMGQD7O25OAsO1AoBuZqYF4VwCkgJNOQFRKQQJUktVA7N15QDfAE8GF+NLARmvTs8e50cB43MvAMsA/wAJOQcJRQHRAfdxALsBYws1Caa3uQFR7S0AhwAZbwHbAo0A4QA5AIP1AVcAUQVd/QXXAlNNARU1HC9bZQG/AyMBNwERAH0Gz5GpzQsjBHEH1wIQHxXlAu8yB7kFAyLjE9FCyQK94lkAMhoKPAqrCqpgX2Q3CjV2PVQAEh+sPss/UgVVO1c7XDtXO1w7VztcO1c7XDtXO1wDm8Pmw+YKcF9JYe8Mqg3YRMw6TRPfYFVgNhPMLbsUxRXSJVoZQRrAJwkl6FUNDwgt12Y0CDA0eRfAAEMpbINFY4oeNApPHOtTlVT8LR8AtUumM7MNsBsZREQFS3XxYi4WEgomAmSFAmJGX1GzAV83JAKh+wJonAJmDQKfiDgfDwJmPwJmKgRyBIMDfxcDfpY5Cjl7GzmGOicnAmwhAjI6OA4CbcsCbbLzjgM3a0kvAWsA4gDlAE4JB5wMkQECD8YAEbkCdzMCdqZDAnlPRwJ4viFg30WyRvcCfEMCeswCfQ0CfPRIBEiBZygALxlJXEpfGRtK0ALRBQLQ0EsrA4hTA4fqRMmRNgLypV0HAwOyS9JMMSkH001QTbMCi0MCitzFHwshR2sJuwKOOwKOYESbhQKO3QKOYHxRuFM5AQ5S2FSJApP/ApMQAO0AIFUiVbNV1AosHymZijLleGpFPz0Cl6MC77ZYJawAXSkClpMCloCgAK1ZsFoNhVEAPwKWuQKWUlxIXNUCmc8CmWhczl0LHQKcnznGOqECnBoCn58CnryOACETNS4TAp31Ap6WALlBYThh8wKe1wKgcgGtAp6jIwKeUqljzGQrKS8CJ7MCJoICoP8CoFDbAqYzAqXSAqgDAIECp/ZogGi1AAdNaiBq1QKs5wKssgKtawKtBgJXIQJV4AKx5dsDH1JsmwKywRECsuwbbORtZ21MYwMl0QK2YD9DbpQDKUkCuGICuUsZArkue3A6cOUCvR0DLbYDMhUCvoxyBgMzdQK+HnMmc1MCw88CwwhzhnRPOUl05AM8qwEDPJ4DPcMCxYACxksCxhSNAshtVQLISALJUwLJMgJkoQLd1nh9ZXiyeSlL1AMYp2cGAmH4GfeVKHsPXpZevxUCz28Cz3AzT1fW9xejAMqxAs93AS3uA04Wfk8JAtwrAtuOAtJTA1JgA1NjAQUDVZCAjUMEzxrxZEl5A4LSg5EC2ssC2eKEFIRNp0ADhqkAMwNkEoZ1Xf0AWQLfaQLevHd7AuIz7RgB8zQrAfSfAfLWiwLr9wLpdH0DAur9AuroAP1LAb0C7o0C66CWrpcHAu5DA4XkmH1w5HGlAvMHAG0DjhqZlwL3FwORcgOSiwL3nAL53QL4apogmq+/O5siA52HAv7+AR8APZ8gAZ+3AwWRA6ZuA6bdANXJAwZuoYyiCQ0DDE0BEwEjB3EGZb1rCQC/BG/DFY8etxEAG3k9ACcDNxJRA42DAWcrJQCM8wAlAOanC6OVCLsGI6fJBgCvBRnDBvElRUYFFoAFcD9GSDNCKUK8X3kZX8QAls0FOgCQVCGbwTsuYDoZutcONxjOGJHJ/gVfBWAFXwVgBWsFYAVfBWAFXwVgBV8FYAVfBWBOHQjfjW8KCgoKbF7xMwTRA7kGN8PDAMMEr8MA70gxFroFTj5xPnhCR0K+X30/X/AAWBkzswCNBsxzzASm70aCRS4rDDMeLz49fnXfcsH5GcoscQFz13Y4HwVnBXLJycnACNdRYwgICAqEXoWTxgA7P4kACxbZBu21Kw0AjMsTAwkVAOVtJUUsJ1JCuULESUArXy9gPi9AKwnJRQYKTD9LPoA+iT54PnkCkULEUUpDX9NWV3JVEjQAc1w3A3IBE3YnX+g7QiMJb6MKaiszRCUuQrNCxDPMCcwEX9EWJzYREBEEBwIHKn6l33JCNVIfybPJtAltydPUCmhBZw/tEKsZAJOVJU1CLRuxbUHOQAo7P0s+eEJHHA8SJVRPdGM0NVrpvBoKhfUlM0JHHGUQUhEWO1xLSj8MO0ucNAqJIzVCRxv9EFsqKyA4OQgNj2nwZgp5ZNFgE2A1K3YHS2AhQQojJmC7DgpzGG1WYFUZCQYHZO9gHWCdYIVgu2BTYJlwFh8GvRbcXbG8YgtDHrMBwzPVyQonHQgkCyYBgQJ0Ajc4nVqIAwGSCsBPIgDsK3SWEtIVBa5N8gGjAo+kVwVIZwD/AEUSCDweX4ITrRQsJ8K3TwBXFDwEAB0TvzVcAtoTS20RIwDgVgZ9BBImYgA5AL4Coi8LFnezOkCnIQFjAY4KBAPh9RcGsgZSBsEAJctdsWIRu2kTkQstRw7DAcMBKgpPBGIGMDAwKCYnKTQaLg4AKRSVAFwCdl+YUZ0JdicFD3lPAdt1F9ZZKCGxuE3yBxkFVGcA/wBFEgiCBwAOLHQSjxOtQDg1z7deFRMAZ8QTAGtKb1ApIiPHADkAvgKiLy1DFtYCmBiDAlDDWNB0eo7fpaMO/aEVRRv0ATEQZBIODyMEAc8JQhCbDRgzFD4TAEMAu9YBCgCsAOkAm5I3ABwAYxvONnR+MhXJAxgKQyxL2+kkJhMbhQKDBMkSsvF0AD9BNQ6uQC7WqSQHwxEAEEIu1hkhAH2z4iQPwyJPHNWpdyYBRSpnJALzoBAEVPPsH20MxA0CCEQKRgAFyAtFAlMNwwjEDUQJRArELtapMg7DDZgJIw+TGukEIwvDFkMAqAtDEMMMBhioe+QAO3MMRAACrgnEBSPY9Q0FDnbSBoMAB8MSYxkSxAEJAPIJAAB8FWMOFtMc/HcXwxhDAC7DAvOowwAewwJdKDKHAAHDAALrFUQVwwAbwyvzpWMWv8wA/ABpAy++bcYDUKPD0KhDCwKmJ1MAAmMA5+UZwxAagwipBRL/eADfw6fDGOMCGsOjk3l6BwOpo4sAEsMOGxMAA5sAbcMOAAvDp0MJGkMDwgipnNIPAwfIqUMGAOGDAAPzABXDAAcDAAnDAGmTABrDAA7DChjDjnEWAwABYwAOcwAuUyYABsMAF8MIKQANUgC6wy4AA8MADqMq8wCyYgAcIwAB8wqpAAXOCx0V4wAHowBCwwEKAGnDAAuDAB3DAAjDCakABdIAbqcZ3QCZCCkABdIAAAFDAAfjAB2jCCkABqIACYMAGzMAbSMA5sOIAAhjAAhDABTDBAkpAAbSAOOTAAlDC6kOzPtnAAdDAG6kQFAATwAKwwwAA0MACbUDPwAHIwAZgwACE6cDAAojAApDAAoDp/MGwwAJIwADEwAQQwgAFEMAEXMAD5MADfMADcMAGRMOFiMAFUMAbqMWuwHDAMIAE0MLAGkzEgDhUwACQwAEWgAXgwUjAAbYABjDBSYBgzBaAEFNALcQBxUMegAwMngBrA0IZgJ0KxQHBREPd1N0ZzKRJwaIHAZqNT4DqQq8BwngAB4DAwt2AX56T1ocKQNXAh1GATQGC3tOxYNagkgAMQA5CQADAQEAWxLjAIOYNAEzAH7tFRk6TglSAF8NAAlYAQ+S1ACAQwQorQBiAN4dAJ1wPyeTANVzuQDX3AIeEMp9eyMgXiUAEdkBkJizKltbVVAaRMqRAAEAhyQ/SDEz6BmfVwB6ATEsOClKIRcDOF0E/832AFNt5AByAnkCRxGCOs94NjXdAwINGBonDBwPALW2AwICAgAAAAAAAAYDBQMDARrUAwAtAAAAAgEGBgYGBgYFBQUFBQUEBQYHCAkEBQUFBQQAAAICAAAAIgCNAJAAlT0A6gC7ANwApEQAwgCyAK0AqADuAKYA2gCjAOcBCAEDAMcAgQBiANIA1AEDAN4A8gCQAKkBMQDqAN8A3AsBCQ8yO9ra2tq8xuLT1tRJOB0BUgFcNU0BWgFpAWgBWwFMUUlLbhMBUxsNEAs6PhMOACcUKy0vMj5AQENDQ0RFFEYGJFdXV1dZWVhZL1pbXVxcI2NnZ2ZoZypsbnZ1eHh4eHh4enp6enp6enp6enp8fH18e2IARPIASQCaAHgAMgBm+ACOAFcAVwA3AnbvAIsABfj4AGQAk/IAnwBPAGIAZP//sACFAIUAaQBWALEAJAC2AIMCQAJDAPwA5wD+AP4A6AD/AOkA6QDoAOYALwJ7AVEBQAE+AVQBPgE+AT4BOQE4ATgBOAEcAVgXADEQCAEAUx8SHgsdHhYAjgCWAKYAUQBqIAIxAHYAbwCXAxUDJzIDIUlGTzEAkQJPAMcCVwKkAMAClgKWApYClgKWApYCiwKWApYClgKWApYClgKVApUCmAKgApcClgKWApQClAKUApQCkgKVAnUB1AKXAp8ClgKWApUeAIETBQD+DQOfAmECOh8BVBg9AuIZEjMbAU4/G1WZAXusRAFpYQEFA0FPAQYAmTEeIJdyADFoAHEANgCRA5zMk/C2jGINwjMWygIZCaXdfDILBCs5dAE7YnQBugDlhoiHhoiGiYqKhouOjIaNkI6Ij4qQipGGkoaThpSSlYaWhpeKmIaZhpqGm4aci52QnoqfhuIC4XTpAt90AIp0LHSoAIsAdHQEQwRABEIERQRDBEkERgRBBEcESQRIBEQERgRJAJ5udACrA490ALxuAQ10ANFZdHQA13QCFHQA/mJ0AP4BIQD+APwA/AD9APwDhGZ03ASMK23HAP4A/AD8AP0A/CR0dACRYnQA/gCRASEA/gCRAvQA/gCRA4RmdNwEjCttxyR0AP9idAEhAP4A/gD8APwA/QD8AP8A/AD8AP0A/AOEZnTcBIwrbcckdHQAkWJ0ASEA/gCRAP4AkQL0AP4AkQOEZnTcBIwrbcckdAJLAT50AlIBQXQCU8l0dAJfdHQDpgL0A6YDpgOnA6cDpwOnA4RmdNwEjCttxyR0dACRYnQBIQOmAJEDpgCRAvQDpgCRA4RmdNwEjCttxyR0BDh0AJEEOQCRDpU5dSgCADR03gV2CwArdAEFAM5iCnR0AF1iAAYcOgp0dACRCnQAXAEIwWZ0CnRmdHQAkWZ0CnRmdEXgAFF03gp0dEY0tlT2u3SOAQTwscwhjZZKrhYcBSfFp9XNbKiVDOD2b+cpe4/Z17mQnbtzzhaeQtE2GGj0IDNTjRUSyTxxw/RPHW/+vS7d1NfRt9z9QPZg4X7QFfhCnkvgNPIItOsC2eV6hPannZNHlZ9xrwZXIMOlu3jSoQSq78WEjwLjw1ELSlF1aBvfzwk5ZX7AUvQzjPQKbDuQ+sm4wNOp4A6AdVuRS0t1y/DZpg4R6m7FNjM9HgvW7Bi88zaMjOo6lM8wtBBdj8LP4ylv3zCXPhebMKJc066o9sF71oFW/8JXu86HJbwDID5lzw5GWLR/LhT0Qqnp2JQxNZNfcbLIzPy+YypqRm/lBmGmex+82+PisxUumSeJkALIT6rJezxMH+CTJmQtt5uwTVbL3ptmjDUQzlSIvWi8Tl7ng1NpuRn1Ng4n14Qc+3Iil7OwkvNWogLSPkn3pihIFytyIGmMhOe3n1tWsuMy9BdKyqF4Z3v2SgggTL9KVvMXPnCbRe+oOuFFP3HejBG/w9gvmfNYvg6JuWia2lcSSN1uIjBktzoIazOHPJZ7kKHPz8mRWVdW3lA8WGF9dQF6Bm673boov3BUWDU2JNcahR23GtfHKLOz/viZ+rYnZFaIznXO67CYEJ1fXuTRpZhYZkKe54xeoagkNGLs+NTZHE0rX45/XvQ2RGADX6vcAvdxIUBV27wxGm2zjZo4X3ILgAlrOFheuZ6wtsvaIj4yLY7qqawlliaIcrz2G+c3vscAnCkCuMzMmZvMfu9lLwTvfX+3cVSyPdN9ZwgDZhfjRgNJcLiJ67b9xx8JHswprbiE3v9UphotAPIgnXVIN5KmMc0piXhc6cChPnN+MRhG9adtdttQTTwSIpl8I4/j//d3sz1326qTBTpPRM/Hgh3kzqEXs8ZAk4ErQhNO8hzrQ0DLkWMA/N+91tn2MdOJnWC2FCZehkQrwzwbKOjhvZsbM95QoeL9skYyMf4srVPVJSgg7pOLUtr/n9eT99oe9nLtFRpjA9okV2Kj8h9k5HaC0oivRD8VyXkJ81tcd4fHNXPCfloIQasxsuO18/46dR2jgul/UIet2G0kRvnyONMKhHs6J26FEoqSqd+rfYjeEGwHWVDpX1fh1jBBcKGMqRepju9Y00mDVHC+Xdij/j44rKfvfjGinNs1jO/0F3jB83XCDINN/HB84axlP+3E/klktRo+vl3U/aiyMJbIodE1XSsDn6UAzIoMtUObY2+k/4gY/l+AkZJ5Sj2vQrkyLm3FoxjhDX+31UXBFf9XrAH31fFqoBmDEZvhvvpnZ87N+oZEu7U9O/nnk+QWj3x8uyoRbEnf+O5UMr9i0nHP38IF5AvzrBW8YWBUR0mIAzIvndQq9N3v/Jto3aPjPXUPl8ASdPPyAp7jENf8bk7VMM9ol9XGmlBmeDMuGqt+WzuL6CXAxXjIhCPM5vACchgMJ/8XBGLO/D1isVvGhwwHHr1DLaI5mn2Jr/b1pUD90uciDaS8cXNDzCWvNmT/PhQe5e8nTnnnkt8Ds/SIjibcum/fqDhKopxAY8AkSrPn+IGDEKOO+U3XOP6djFs2H5N9+orhOahiQk5KnEUWa+CzkVzhp8bMHRbg81qhjjXuIKbHjSLSIBKWqockGtKinY+z4/RdBUF6pcc3JmnlxVcNgrI4SEzKUZSwcD2QCyxzKve+gAmg6ZuSRkpPFa6mfThu7LJNu3H5K42uCpNvPAsoedolKV/LHe/eJ+BbaG5MG0NaSGVPRUmNFMFFSSpXEcXwbVh7UETOZZtoVNRGOIbbkig3McEtR68cG0RZAoJevWYo7Dg/lZ1CQzblWeUvVHmr8fY4Nqd9JJiH/zEX24mJviH60fAyFr0A3c4bC1j3yZU60VgJxXn8JgJXLUIsiBnmKmMYz+7yBQFBvqb2eYnuW59joZBf56/wXvWIR4R8wTmV80i1mZy+S4+BUES+hzjk0uXpC///z/IlqHZ1monzlXp8aCfhGKMti73FI1KbL1q6IKO4fuBuZ59gagjn5xU79muMpHXg6S+e+gDM/U9BKLHbl9l6o8czQKl4RUkJJiqftQG2i3BMg/TQlUYFkJDYBOOvAugYuzYSDnZbDDd/aSd9x0Oe6F+bJcHfl9+gp6L5/TgA+BdFFovbfCrQ40s5vMPw8866pNX8zyFGeFWdxIpPVp9Rg1UPOVFbFZrvaFq/YAzHQgqMWpahMYfqHpmwXfHL1/kpYmGuHFwT55mQu0dylfNuq2Oq0hTMCPwqfxnuBIPLXfci4Y1ANy+1CUipQxld/izVh16WyG2Q0CQQ9NqtAnx1HCHwDj7sYxOSB0wopZSnOzxQOcExmxrVTF2BkOthVpGfuhaGECfCJpJKpjnihY+xOT2QJxN61+9K6QSqtv2Shr82I3jgJrqBg0wELFZPjvHpvzTtaJnLK6Vb97Yn933koO/saN7fsjwNKzp4l2lJVx2orjCGzC/4ZL4zCver6aQYtC5sdoychuFE6ufOiog+VWi5UDkbmvmtah/3aArEBIi39s5ILUnlFLgilcGuz9CQshEY7fw2ouoILAYPVT/gyAIq3TFAIwVsl+ktkRz/qGfnCDGrm5gsl/l9QdvCWGsjPz3dU7XuqKfdUrr/6XIgjp4rey6AJBmCmUJMjITHVdFb5m1p+dLMCL8t55zD42cmftmLEJC0Da04YiRCVUBLLa8D071/N5UBNBXDh0LFsmhV/5B5ExOB4j3WVG/S3lfK5o+V6ELHvy6RR9n4ac+VsK4VE4yphPvV+kG9FegTBH4ZRXL2HytUHCduJazB/KykjfetYxOXTLws267aGOd+I+JhKP//+VnXmS90OD/jvLcVu0asyqcuYN1mSb6XTlCkqv1vigZPIYwNF/zpWcT1GR/6aEIRjkh0yhg4LXJfaGobYJTY4JI58KiAKgmmgAKWdl5nYCeLqavRJGQNuYuZtZFGx+IkI4w4NS2xwbetNMunOjBu/hmKCI/w7tfiiyUd//4rbTeWt4izBY8YvGIN6vyKYmP/8X8wHKCeN+WRcKM70+tXKNGyevU9H2Dg5BsljnTf8YbsJ1TmMs74Ce2XlHisleguhyeg44rQOHZuw/6HTkhnnurK2d62q6yS7210SsAIaR+jXMQA+svkrLpsUY+F30Uw89uOdGAR6vo4FIME0EfVVeHTu6eKicfhSqOeXJhbftcd08sWEnNUL1C9fnprTgd83IMut8onVUF0hvqzZfHduPjbjwEXIcoYmy+P6tcJZHmeOv6VrvEdkHDJecjHuHeWANe79VG662qTjA/HCvumVv3qL+LrOcpqGps2ZGwQdFJ7PU4iuyRlBrwfO+xnPyr47s2cXVbWzAyznDiBGjCM3ksxjjqM62GE9C8f5U38kB3VjtabKp/nRdvMESPGDG90bWRLAt1Qk5DyLuazRR1YzdC1c+hZXvAWV8xA72S4A8B67vjVhbba3MMop293FeEXpe7zItMWrJG/LOH9ByOXmYnNJfjmfuX9KbrpgLOba4nZ+fl8Gbdv/ihv+6wFGKHCYrVwmhFC0J3V2bn2tIB1wCc1CST3d3X2OyxhguXcs4sm679UngzofuSeBewMFJboIQHbUh/m2JhW2hG9DIvG2t7yZIzKBTz9wBtnNC+2pCRYhSIuQ1j8xsz5VvqnyUIthvuoyyu7fNIrg/KQUVmGQaqkqZk/Vx5b33/gsEs8yX7SC1J+NV4icz6bvIE7C5G6McBaI8rVg56q5QBJWxn/87Q1sPK4+sQa8fLU5gXo4paaq4cOcQ4wR0VBHPGjKh+UlPCbA1nLXyEUX45qZ8J7/Ln4FPJE2TdzD0Z8MLSNQiykMMmSyOCiFfy84Rq60emYB2vD09KjYwsoIpeDcBDTElBbXxND72yhd9pC/1CMid/5HUMvAL27OtcIJDzNKpRPNqPOpyt2aPGz9QWIs9hQ9LiX5s8m9hjTUu/f7MyIatjjd+tSfQ3ufZxPpmJhTaBtZtKLUcfOCUqADuO+QoH8B9v6U+P0HV1GLQmtoNFTb3s74ivZgjES0qfK+8RdGgBbcCMSy8eBvh98+et1KIFqSe1KQPyXULBMTsIYnysIwiZBJYdI20vseV+wuJkcqGemehKjaAb9L57xZm3g2zX0bZ2xk/fU+bCo7TlnbW7JuF1YdURo/2Gw7VclDG1W7LOtas2LX4upifZ/23rzpsnY/ALfRgrcWP5hYmV9VxVOQA1fZvp9F2UNU+7d7xRyVm5wiLp3/0dlV7vdw1PMiZrbDAYzIVqEjRY2YU03sJhPnlwIPcZUG5ltL6S8XCxU1eYS5cjr34veBmXAvy7yN4ZjArIG0dfD/5UpBNlX1ZPoxJOwyqRi3wQWtOzd4oNKh0LkoTm8cwqgIfKhqqGOhwo71I+zXnMemTv2B2AUzABWyFztGgGULjDDzWYwJUVBTjKCn5K2QGMK1CQT7SzziOjo+BhAmqBjzuc3xYym2eedGeOIRJVyTwDw37iCMe4g5Vbnsb5ZBdxOAnMT7HU4DHpxWGuQ7GeiY30Cpbvzss55+5Km1YsbD5ea3NI9QNYIXol5apgSu9dZ8f8xS5dtHpido5BclDuLWY4lhik0tbJa07yJhH0BOyEut/GRbYTS6RfiTYWGMCkNpfSHi7HvdiTglEVHKZXaVhezH4kkXiIvKopYAlPusftpE4a5IZwvw1x/eLvoDIh/zpo9FiQInsTb2SAkKHV42XYBjpJDg4374XiVb3ws4qM0s9eSQ5HzsMU4OZJKuopFjBM+dAZEl8RUMx5uU2N486Kr141tVsGQfGjORYMCJAMsxELeNT4RmWjRcpdTGBwcx6XN9drWqPmJzcrGrH4+DRc7+n1w3kPZwu0BkNr6hQrqgo7JTB9A5kdJ/H7P4cWBMwsmuixAzJB3yrQpnGIq90lxAXLzDCdn1LPibsRt7rHNjgQBklRgPZ8vTbjXdgXrTWQsK5MdrXXQVPp0Rinq3frzZKJ0qD6Qhc40VzAraUXlob1gvkhK3vpmHgI6FRlQZNx6eRqkp0zy4AQlX813fAPtL3jMRaitGFFjo0zmErloC+h+YYdVQ6k4F/epxAoF0BmqEoKNTt6j4vQZNQ2BoqF9Vj53TOIoNmDiu9Xp15RkIgQIGcoLpfoIbenzpGUAtqFJp5W+LLnx38jHeECTJ/navKY1NWfN0sY1T8/pB8kIH3DU3DX+u6W3YwpypBMYOhbSxGjq84RZ84fWJow8pyHqn4S/9J15EcCMsXqrfwyd9mhiu3+rEo9pPpoJkdZqHjra4NvzFwuThNKy6hao/SlLw3ZADUcUp3w3SRVfW2rhl80zOgTYnKE0Hs2qp1J6H3xqPqIkvUDRMFDYyRbsFI3M9MEyovPk8rlw7/0a81cDVLmBsR2ze2pBuKb23fbeZC0uXoIvDppfTwIDxk1Oq2dGesGc+oJXWJLGkOha3CX+DUnzgAp9HGH9RsPZN63Hn4RMA5eSVhPHO+9RcRb/IOgtW31V1Q5IPGtoxPjC+MEJbVlIMYADd9aHYWUIQKopuPOHmoqSkubnAKnzgKHqgIOfW5RdAgotN6BN+O2ZYHkuemLnvQ8U9THVrS1RtLmKbcC7PeeDsYznvqzeg6VCNwmr0Yyx1wnLjyT84BZz3EJyCptD3yeueAyDWIs0L2qs/VQ3HUyqfrja0V1LdDzqAikeWuV4sc7RLIB69jEIBjCkyZedoUHqCrOvShVzyd73OdrJW0hPOuQv2qOoHDc9xVb6Yu6uq3Xqp2ZaH46A7lzevbxQEmfrzvAYSJuZ4WDk1Hz3QX1LVdiUK0EvlAGAYlG3Md30r7dcPN63yqBCIj25prpvZP0nI4+EgWoFG95V596CurXpKRBGRjQlHCvy5Ib/iW8nZJWwrET3mgd6mEhfP4KCuaLjopWs7h+MdXFdIv8dHQJgg1xi1eYqB0uDYjxwVmri0Sv5XKut/onqapC+FQiC2C1lvYJ9MVco6yDYsS3AANUfMtvtbYI2hfwZatiSsnoUeMZd34GVjkMMKA+XnjJpXgRW2SHTZplVowPmJsvXy6w3cfO1AK2dvtZEKTkC/TY9LFiKHCG0DnrMQdGm2lzlBHM9iEYynH2UcVMhUEjsc0oDBTgo2ZSQ1gzkAHeWeBXYFjYLuuf8yzTCy7/RFR81WDjXMbq2BOH5dURnxo6oivmxL3cKzKInlZkD31nvpHB9Kk7GfcfE1t+1V64b9LtgeJGlpRFxQCAqWJ5DoY77ski8gsOEOr2uywZaoO/NGa0X0y1pNQHBi3b2SUGNpcZxDT7rLbBf1FSnQ8guxGW3W+36BW0gBje4DOz6Ba6SVk0xiKgt+q2JOFyr4SYfnu+Ic1QZYIuwHBrgzr6UvOcSCzPTOo7D6IC4ISeS7zkl4h+2VoeHpnG/uWR3+ysNgPcOIXQbv0n4mr3BwQcdKJxgPSeyuP/z1Jjg4e9nUvoXegqQVIE30EHx5GHv+FAVUNTowYDJgyFhf5IvlYmEqRif6+WN1MkEJmDcQITx9FX23a4mxy1AQRsOHO/+eImX9l8EMJI3oPWzVXxSOeHU1dUWYr2uAA7AMb+vAEZSbU3qob9ibCyXeypEMpZ6863o6QPqlqGHZkuWABSTVNd4cOh9hv3qEpSx2Zy/DJMP6cItEmiBJ5PFqQnDEIt3NrA3COlOSgz43D7gpNFNJ5MBh4oFzhDPiglC2ypsNU4ISywY2erkyb1NC3Qh/IfWj0eDgZI4/ln8WPfBsT3meTjq1Uqt1E7Zl/qftqkx6aM9KueMCekSnMrcHj1CqTWWzEzPsZGcDe3Ue4Ws+XFYVxNbOFF8ezkvQGR6ZOtOLU2lQEnMBStx47vE6Pb7AYMBRj2OOfZXfisjJnpTfSNjo6sZ6qSvNxZNmDeS7Gk3yYyCk1HtKN2UnhMIjOXUzAqDv90lx9O/q/AT1ZMnit5XQe9wmQxnE/WSH0CqZ9/2Hy+Sfmpeg8RwsHI5Z8kC8H293m/LHVVM/BA7HaTJYg5Enk7M/xWpq0192ACfBai2LA/qrCjCr6Dh1BIMzMXINBmX96MJ5Hn2nxln/RXPFhwHxUmSV0EV2V0jm86/dxxuYSU1W7sVkEbN9EzkG0QFwPhyHKyb3t+Fj5WoUUTErcazE/N6EW6Lvp0d//SDPj7EV9UdJN+Amnf3Wwk3A0SlJ9Z00yvXZ7n3z70G47Hfsow8Wq1JXcfwnA+Yxa5mFsgV464KKP4T31wqIgzFPd3eCe3j5ory5fBF2hgCFyVFrLzI9eetNXvM7oQqyFgDo4CTp/hDV9NMX9JDHQ/nyHTLvZLNLF6ftn2OxjGm8+PqOwhxnPHWipkE/8wbtyri80Sr7pMNkQGMfo4ZYK9OcCC4ESVFFbLMIvlxSoRqWie0wxqnLfcLSXMSpMMQEJYDVObYsXIQNv4TGNwjq1kvT1UOkicTrG3IaBZ3XdScS3u8sgeZPVpOLkbiF940FjbCeNRINNvDbd01EPBrTCPpm12m43ze1bBB59Ia6Ovhnur/Nvx3IxwSWol+3H2qfCJR8df6aQf4v6WiONxkK+IqT4pKQrZK/LplgDI/PJZbOep8dtbV7oCr6CgfpWa8NczOkPx81iSHbsNhVSJBOtrLIMrL31LK9TqHqAbAHe0RLmmV806kRLDLNEhUEJfm9u0sxpkL93Zgd6rw+tqBfTMi59xqXHLXSHwSbSBl0EK0+loECOPtrl+/nsaFe197di4yUgoe4jKoAJDXc6DGDjrQOoFDWZJ9HXwt8xDrQP+7aRwWKWI1GF8s8O4KzxWBBcwnl3vnl1Oez3oh6Ea1vjR7/z7DDTrFtqU2W/KAEzAuXDNZ7MY73MF216dzdSbWmUp4lcm7keJfWaMHgut9x5C9mj66Z0lJ+yhsjVvyiWrfk1lzPOTdhG15Y7gQlXtacvI7qv/XNSscDwqkgwHT/gUsD5yB7LdRRvJxQGYINn9hTpodKFVSTPrtGvyQw+HlRFXIkodErAGu9Iy1YpfSPc3jkFh5CX3lPxv7aqjE/JAfTIpEjGb/H7MO0e2vsViSW1qa/Lmi4/n4DEI3g7lYrcanspDfEpKkdV1OjSLOy0BCUqVoECaB55vs06rXl4jqmLsPsFM/7vYJ0vrBhDCm/00A/H81l1uekJ/6Lml3Hb9+NKiLqATJmDpyzfYZFHumEjC662L0Bwkxi7E9U4cQA0XMVDuMYAIeLMPgQaMVOd8fmt5SflFIfuBoszeAw7ow5gXPE2Y/yBc/7jExARUf/BxIHQBF5Sn3i61w4z5xJdCyO1F1X3+3ax+JSvMeZ7S6QSKp1Fp/sjYz6Z+VgCZzibGeEoujryfMulH7Rai5kAft9ebcW50DyJr2uo2z97mTWIu45YsSnNSMrrNUuG1XsYBtD9TDYzQffKB87vWbkM4EbPAFgoBV4GQS+vtFDUqOFAoi1nTtmIOvg38N4hT2Sn8r8clmBCXspBlMBYTnrqFJGBT3wZOzAyJDre9dHH7+x7qaaKDOB4UQALD5ecS0DE4obubQEiuJZ0EpBVpLuYcce8Aa4PYd/V4DLDAJBYKQPCWTcrEaZ5HYbJi11Gd6hjGom1ii18VHYnG28NKpkz2UKVPxlhYSp8uZr367iOmoy7zsxehW9wzcy2zG0a80PBMCRQMb32hnaHeOR8fnNDzZhaNYhkOdDsBUZ3loDMa1YP0uS0cjUP3b/6DBlqmZOeNABDsLl5BI5QJups8uxAuWJdkUB/pO6Zax6tsg7fN5mjjDgMGngO+DPcKqiHIDbFIGudxtPTIyDi9SFMKBDcfdGQRv41q1AqmxgkVfJMnP8w/Bc7N9/TR6C7mGObFqFkIEom8sKi2xYqJLTCHK7cxzaZvqODo22c3wisBCP4HeAgcRbNPAsBkNRhSmD48dHupdBRw4mIvtS5oeF6zeT1KMCyhMnmhpkFAGWnGscoNkwvQ8ZM5lE/vgTHFYL99OuNxdFBxTEDd5v2qLR8y9WkXsWgG6kZNndFG+pO/UAkOCipqIhL3hq7cRSdrCq7YhUsTocEcnaFa6nVkhnSeRYUA1YO0z5itF9Sly3VlxYDw239TJJH6f3EUfYO5lb7bcFcz8Bp7Oo8QmnsUHOz/fagVUBtKEw1iT88j+aKkv8cscKNkMxjYr8344D1kFoZ7/td1W6LCNYN594301tUGRmFjAzeRg5vyoM1F6+bJZ/Q54jN/k8SFd3DxPTYaAUsivsBfgTn7Mx8H2SpPt4GOdYRnEJOH6jHM2p6SgB0gzIRq6fHxGMmSmqaPCmlfwxiuloaVIitLGN8wie2CDWhkzLoCJcODh7KIOAqbHEvXdUxaS4TTTs07Clzj/6GmVs9kiZDerMxEnhUB6QQPlcfqkG9882RqHoLiHGBoHfQuXIsAG8GTAtao2KVwRnvvam8jo1e312GQAKWEa4sUVEAMG4G6ckcONDwRcg1e2D3+ohXgY4UAWF8wHKQMrSnzCgfFpsxh+aHXMGtPQroQasRY4U6UdG0rz1Vjbka0MekOGRZQEvqQFlxseFor8zWFgHek3v29+WqN6gaK5gZOTOMZzpQIC1201LkMCXild3vWXSc5UX9xcFYfbRPzGFa1FDcPfPB/jUEq/FeGt419CI3YmBlVoHsa4KdcwQP5ZSwHHhFJ7/Ph/Rap/4vmG91eDwPP0lDfCDRCLszTqfzM71xpmiKi2HwS4WlqvGNwtvwF5Dqpn6KTq8ax00UMPkxDcZrEEEsIvHiUXXEphdb4GB4FymlPwBz4Gperqq5pW7TQ6/yNRhW8VT5NhuP0udlxo4gILq5ZxAZk8ZGh3g4CqxJlPKY7AQxupfUcVpWT5VItp1+30UqoyP4wWsRo3olRRgkWZZ2ZN6VC3OZFeXB8NbnUrSdikNptD1QiGuKkr8EmSR/AK9Rw+FF3s5uwuPbvHGiPeFOViltMK7AUaOsq9+x9cndk3iJEE5LKZRlWJbKOZweROzmPNVPkjE3K/TyA57Rs68TkZ3MR8akKpm7cFjnjPd/DdkWjgYoKHSr5Wu5ssoBYU4acRs5g2DHxUmdq8VXOXRbunD8QN0LhgkssgahcdoYsNvuXGUK/KXD/7oFb+VGdhqIn02veuM5bLudJOc2Ky0GMaG4W/xWBxIJcL7yliJOXOpx0AkBqUgzlDczmLT4iILXDxxtRR1oZa2JWFgiAb43obrJnG/TZC2KSK2wqOzRZTXavZZFMb1f3bXvVaNaK828w9TO610gk8JNf3gMfETzXXsbcvRGCG9JWQZ6+cDPqc4466Yo2RcKH+PILeKOqtnlbInR3MmBeGG3FH10yzkybuqEC2HSQwpA0An7d9+73BkDUTm30bZmoP/RGbgFN+GrCOfADgqr0WbI1a1okpFms8iHYw9hm0zUvlEMivBRxModrbJJ+9/p3jUdQQ9BCtQdxnOGrT5dzRUmw0593/mbRSdBg0nRvRZM5/E16m7ZHmDEtWhwvfdZCZ8J8M12W0yRMszXamWfQTwIZ4ayYktrnscQuWr8idp3PjT2eF/jmtdhIfcpMnb+IfZY2FebW6UY/AK3jP4u3Tu4zE4qlnQgLFbM19EBIsNf7KhjdbqQ/D6yiDb+NlEi2SKD+ivXVUK8ib0oBo366gXkR8ZxGjpJIDcEgZPa9TcYe0TIbiPl/rPUQDu3XBJ9X/GNq3FAUsKsll57DzaGMrjcT+gctp+9MLYXCq+sqP81eVQ0r9lt+gcQfZbACRbEjvlMskztZG8gbC8Qn9tt26Q7y7nDrbZq/LEz7kR6Jc6pg3N9rVX8Y5MJrGlML9p9lU4jbTkKqCveeZUJjHB03m2KRKR2TytoFkTXOLg7keU1s1lrPMQJpoOKLuAAC+y1HlJucU6ysB5hsXhvSPPLq5J7JtnqHKZ4vYjC4Vy8153QY+6780xDuGARsGbOs1WqzH0QS765rnSKEbbKlkO8oI/VDwUd0is13tKpqILu1mDJFNy/iJAWcvDgjxvusIT+PGz3ST/J9r9Mtfd0jpaGeiLYIqXc7DiHSS8TcjFVksi66PEkxW1z6ujbLLUGNNYnzOWpH8BZGK4bCK7iR+MbIv8ncDAz1u4StN3vTTzewr9IQjk9wxFxn+6N1ddKs0vffJiS08N3a4G1SVrlZ97Q/M+8G9fe5AP6d9/Qq4WRnORVhofPIKEdCr3llspUfE0oKIIYoByBRPh+bX1HLS3JWGJRhIvE1aW4NTd8ePi4Z+kXb+Z8snYfSNcqijhAgVsx4RCM54cXUiYkjeBmmC4ajOHrChoELscJJC7+9jjMjw5BagZKlgRMiSNYz7h7vvZIoQqbtQmspc0cUk1G/73iXtSpROl5wtLgQi0mW2Ex8i3WULhcggx6E1LMVHUsdc9GHI1PH3U2Ko0PyGdn9KdVOLm7FPBui0i9a0HpA60MsewVE4z8CAt5d401Gv6zXlIT5Ybit1VIA0FCs7wtvYreru1fUyW3oLAZ/+aTnZrOcYRNVA8spoRtlRoWflsRClFcgzkqiHOrf0/SVw+EpVaFlJ0g4Kxq1MMOmiQdpMNpte8lMMQqm6cIFXlnGbfJllysKDi+0JJMotkqgIxOSQgU9dn/lWkeVf8nUm3iwX2Nl3WDw9i6AUK3vBAbZZrcJpDQ/N64AVwjT07Jef30GSSmtNu2WlW7YoyW2FlWfZFQUwk867EdLYKk9VG6JgEnBiBxkY7LMo4YLQJJlAo9l/oTvJkSARDF/XtyAzM8O2t3eT/iXa6wDN3WewNmQHdPfsxChU/KtLG2Mn8i4ZqKdSlIaBZadxJmRzVS/o4yA65RTSViq60oa395Lqw0pzY4SipwE0SXXsKV+GZraGSkr/RW08wPRvqvSUkYBMA9lPx4m24az+IHmCbXA+0faxTRE9wuGeO06DIXa6QlKJ3puIyiuAVfPr736vzo2pBirS+Vxel3TMm3JKhz9o2ZoRvaFVpIkykb0Hcm4oHFBMcNSNj7/4GJt43ogonY2Vg4nsDQIWxAcorpXACzgBqQPjYsE/VUpXpwNManEru4NwMCFPkXvMoqvoeLN3qyu/N1eWEHttMD65v19l/0kH2mR35iv/FI+yjoHJ9gPMz67af3Mq/BoWXqu3rphiWMXVkmnPSEkpGpUI2h1MThideGFEOK6YZHPwYzMBvpNC7+ZHxPb7epfefGyIB4JzO9DTNEYnDLVVHdQyvOEVefrk6Uv5kTQYVYWWdqrdcIl7yljwwIWdfQ/y+2QB3eR/qxYObuYyB4gTbo2in4PzarU1sO9nETkmj9/AoxDA+JM3GMqQtJR4jtduHtnoCLxd1gQUscHRB/MoRYIEsP2pDZ9KvHgtlk1iTbWWbHhohwFEYX7y51fUV2nuUmnoUcqnWIQAAgl9LTVX+Bc0QGNEhChxHR4YjfE51PUdGfsSFE6ck7BL3/hTf9jLq4G1IafINxOLKeAtO7quulYvH5YOBc+zX7CrMgWnW47/jfRsWnJjYYoE7xMfWV2HN2iyIqLI";const aN=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),lN=4;function O9(n){let e=0;function t(){return n[e++]<<8|n[e++]}let r=t(),s=1,i=[0,1];for(let E=1;E<r;E++)i.push(s+=t());let o=t(),a=e;e+=o;let l=0,c=0;function u(){return l==0&&(c=c<<8|n[e++],l=8),c>>--l&1}const f=31,d=2**f,h=d>>>1,p=h>>1,g=d-1;let y=0;for(let E=0;E<f;E++)y=y<<1|u();let b=[],x=0,v=d;for(;;){let E=Math.floor(((y-x+1)*s-1)/v),C=0,T=r;for(;T-C>1;){let O=C+T>>>1;E<i[O]?T=O:C=O}if(C==0)break;b.push(C);let N=x+Math.floor(v*i[C]/s),M=x+Math.floor(v*i[C+1]/s)-1;for(;!((N^M)&h);)y=y<<1&g|u(),N=N<<1&g,M=M<<1&g|1;for(;N&~M&p;)y=y&h|y<<1&g>>>1|u(),N=N<<1^h,M=(M^h)<<1|h|1;x=N,v=1+M-N}let w=r-4;return b.map(E=>{switch(E-w){case 3:return w+65792+(n[a++]<<16|n[a++]<<8|n[a++]);case 2:return w+256+(n[a++]<<8|n[a++]);case 1:return w+n[a++];default:return E-1}})}function N9(n){let e=0;return()=>n[e++]}function cN(n){return N9(O9(M9(n)))}function M9(n){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((s,i)=>e[s.charCodeAt(0)]=i);let t=n.length,r=new Uint8Array(6*t>>3);for(let s=0,i=0,o=0,a=0;s<t;s++)a=a<<6|e[n.charCodeAt(s)],o+=6,o>=8&&(r[i++]=a>>(o-=8));return r}function R9(n){return n&1?~n>>1:n>>1}function P9(n,e){let t=Array(n);for(let r=0,s=0;r<n;r++)t[r]=s+=R9(e());return t}function ed(n,e=0){let t=[];for(;;){let r=n(),s=n();if(!s)break;e+=r;for(let i=0;i<s;i++)t.push(e+i);e+=s+1}return t}function uN(n){return td(()=>{let e=ed(n);if(e.length)return e})}function fN(n){let e=[];for(;;){let t=n();if(t==0)break;e.push(D9(t,n))}for(;;){let t=n()-1;if(t<0)break;e.push(I9(t,n))}return e.flat()}function td(n){let e=[];for(;;){let t=n(e.length);if(!t)break;e.push(t)}return e}function dN(n,e,t){let r=Array(n).fill().map(()=>[]);for(let s=0;s<e;s++)P9(n,t).forEach((i,o)=>r[o].push(i));return r}function D9(n,e){let t=1+e(),r=e(),s=td(e);return dN(s.length,1+n,e).flatMap((o,a)=>{let[l,...c]=o;return Array(s[a]).fill().map((u,f)=>{let d=f*r;return[l+f*t,c.map(h=>h+d)]})})}function I9(n,e){let t=1+e();return dN(t,1+n,e).map(s=>[s[0],s.slice(1)])}function _9(n){let e=[],t=ed(n);return s(r([]),[]),e;function r(i){let o=n(),a=td(()=>{let l=ed(n).map(c=>t[c]);if(l.length)return r(l)});return{S:o,B:a,Q:i}}function s({S:i,B:o},a,l){if(!(i&4&&l===a[a.length-1])){i&2&&(l=a[a.length-1]),i&1&&e.push(a);for(let c of o)for(let u of c.Q)s(c,[...a,u],l)}}}function L9(n){return n.toString(16).toUpperCase().padStart(2,"0")}function hN(n){return`{${L9(n)}}`}function B9(n){let e=[];for(let t=0,r=n.length;t<r;){let s=n.codePointAt(t);t+=s<65536?1:2,e.push(s)}return e}function wc(n){let t=n.length;if(t<4096)return String.fromCodePoint(...n);let r=[];for(let s=0;s<t;)r.push(String.fromCodePoint(...n.slice(s,s+=4096)));return r.join("")}function F9(n,e){let t=n.length,r=t-e.length;for(let s=0;r==0&&s<t;s++)r=n[s]-e[s];return r}var U9="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";const nd=44032,Bm=4352,Fm=4449,Um=4519,pN=19,mN=21,vc=28,Hm=mN*vc,H9=pN*Hm,j9=nd+H9,$9=Bm+pN,z9=Fm+mN,V9=Um+vc;function rd(n){return n>>24&255}function gN(n){return n&16777215}let nv,yN,rv,jm;function W9(){let n=cN(U9);nv=new Map(uN(n).flatMap((e,t)=>e.map(r=>[r,t+1<<24]))),yN=new Set(ed(n)),rv=new Map,jm=new Map;for(let[e,t]of fN(n)){if(!yN.has(e)&&t.length==2){let[r,s]=t,i=jm.get(r);i||(i=new Map,jm.set(r,i)),i.set(s,e)}rv.set(e,t.reverse())}}function bN(n){return n>=nd&&n<j9}function G9(n,e){if(n>=Bm&&n<$9&&e>=Fm&&e<z9)return nd+(n-Bm)*Hm+(e-Fm)*vc;if(bN(n)&&e>Um&&e<V9&&(n-nd)%vc==0)return n+(e-Um);{let t=jm.get(n);return t&&(t=t.get(e),t)?t:-1}}function wN(n){nv||W9();let e=[],t=[],r=!1;function s(i){let o=nv.get(i);o&&(r=!0,i|=o),e.push(i)}for(let i of n)for(;;){if(i<128)e.push(i);else if(bN(i)){let o=i-nd,a=o/Hm|0,l=o%Hm/vc|0,c=o%vc;s(Bm+a),s(Fm+l),c>0&&s(Um+c)}else{let o=rv.get(i);o?t.push(...o):s(i)}if(!t.length)break;i=t.pop()}if(r&&e.length>1){let i=rd(e[0]);for(let o=1;o<e.length;o++){let a=rd(e[o]);if(a==0||i<=a){i=a;continue}let l=o-1;for(;;){let c=e[l+1];if(e[l+1]=e[l],e[l]=c,!l||(i=rd(e[--l]),i<=a))break}i=rd(e[o])}}return e}function K9(n){let e=[],t=[],r=-1,s=0;for(let i of n){let o=rd(i),a=gN(i);if(r==-1)o==0?r=a:e.push(a);else if(s>0&&s>=o)o==0?(e.push(r,...t),t.length=0,r=a):t.push(a),s=o;else{let l=G9(r,a);l>=0?r=l:s==0&&o==0?(e.push(r),r=a):(t.push(a),s=o)}}return r>=0&&e.push(r,...t),e}function vN(n){return wN(n).map(gN)}function J9(n){return K9(wN(n))}const AN=45,xN=".",EN=65039,kN=1,$m=n=>Array.from(n);function sd(n,e){return n.P.has(e)||n.Q.has(e)}class q9 extends Array{get is_emoji(){return!0}}let sv,CN,Ca,iv,SN,Ac,ov,xc,Sa,TN,av;function lv(){if(sv)return;let n=cN(T9);const e=()=>ed(n),t=()=>new Set(e()),r=(u,f)=>f.forEach(d=>u.add(d));sv=new Map(fN(n)),CN=t(),Ca=e(),iv=new Set(e().map(u=>Ca[u])),Ca=new Set(Ca),SN=t(),t();let s=uN(n),i=n();const o=()=>{let u=new Set;return e().forEach(f=>r(u,s[f])),r(u,e()),u};Ac=td(u=>{let f=td(n).map(d=>d+96);if(f.length){let d=u>=i;f[0]-=32,f=wc(f),d&&(f=`Restricted[${f}]`);let h=o(),p=o(),g=!n();return{N:f,P:h,Q:p,M:g,R:d}}}),ov=t(),xc=new Map;let a=e().concat($m(ov)).sort((u,f)=>u-f);a.forEach((u,f)=>{let d=n(),h=a[f]=d?a[f-d]:{V:[],M:new Map};h.V.push(u),ov.has(u)||xc.set(u,h)});for(let{V:u,M:f}of new Set(xc.values())){let d=[];for(let p of u){let g=Ac.filter(b=>sd(b,p)),y=d.find(({G:b})=>g.some(x=>b.has(x)));y||(y={G:new Set,V:[]},d.push(y)),y.V.push(p),r(y.G,g)}let h=d.flatMap(p=>$m(p.G));for(let{G:p,V:g}of d){let y=new Set(h.filter(b=>!p.has(b)));for(let b of g)f.set(b,y)}}Sa=new Set;let l=new Set;const c=u=>Sa.has(u)?l.add(u):Sa.add(u);for(let u of Ac){for(let f of u.P)c(f);for(let f of u.Q)c(f)}for(let u of Sa)!xc.has(u)&&!l.has(u)&&xc.set(u,kN);r(Sa,vN(Sa)),TN=_9(n).map(u=>q9.from(u)).sort(F9),av=new Map;for(let u of TN){let f=[av];for(let d of u){let h=f.map(p=>{let g=p.get(d);return g||(g=new Map,p.set(d,g)),g});d===EN?f.push(...h):f=h}for(let d of f)d.V=u}}function cv(n){return(ON(n)?"":`${uv(zm([n]))} `)+hN(n)}function uv(n){return`"${n}"`}function Q9(n){if(n.length>=4&&n[2]==AN&&n[3]==AN)throw new Error(`invalid label extension: "${wc(n.slice(0,4))}"`)}function Y9(n){for(let t=n.lastIndexOf(95);t>0;)if(n[--t]!==95)throw new Error("underscore allowed only at start")}function X9(n){let e=n[0],t=aN.get(e);if(t)throw id(`leading ${t}`);let r=n.length,s=-1;for(let i=1;i<r;i++){e=n[i];let o=aN.get(e);if(o){if(s==i)throw id(`${t} + ${o}`);s=i+1,t=o}}if(s==r)throw id(`trailing ${t}`)}function zm(n,e=1/0,t=hN){let r=[];Z9(n[0])&&r.push("◌"),n.length>e&&(e>>=1,n=[...n.slice(0,e),8230,...n.slice(-e)]);let s=0,i=n.length;for(let o=0;o<i;o++){let a=n[o];ON(a)&&(r.push(wc(n.slice(s,o))),r.push(t(a)),s=o+1)}return r.push(wc(n.slice(s,i))),r.join("")}function Z9(n){return lv(),Ca.has(n)}function ON(n){return lv(),SN.has(n)}function e7(n){return s7(t7(n,J9,a7))}function t7(n,e,t){if(!n)return[];lv();let r=0;return n.split(xN).map(s=>{let i=B9(s),o={input:i,offset:r};r+=i.length+1;try{let a=o.tokens=o7(i,e,t),l=a.length,c;if(!l)throw new Error("empty label");let u=o.output=a.flat();if(Y9(u),!(o.emoji=l>1||a[0].is_emoji)&&u.every(d=>d<128))Q9(u),c="ASCII";else{let d=a.flatMap(h=>h.is_emoji?[]:h);if(!d.length)c="Emoji";else{if(Ca.has(u[0]))throw id("leading combining mark");for(let g=1;g<l;g++){let y=a[g];if(!y.is_emoji&&Ca.has(y[0]))throw id(`emoji + combining mark: "${wc(a[g-1])} + ${zm([y[0]])}"`)}X9(u);let h=$m(new Set(d)),[p]=r7(h);i7(p,d),n7(p,h),c=p.N}}o.type=c}catch(a){o.error=a}return o})}function n7(n,e){let t,r=[];for(let s of e){let i=xc.get(s);if(i===kN)return;if(i){let o=i.M.get(s);if(t=t?t.filter(a=>o.has(a)):$m(o),!t.length)return}else r.push(s)}if(t){for(let s of t)if(r.every(i=>sd(s,i)))throw new Error(`whole-script confusable: ${n.N}/${s.N}`)}}function r7(n){let e=Ac;for(let t of n){let r=e.filter(s=>sd(s,t));if(!r.length)throw Ac.some(s=>sd(s,t))?MN(e[0],t):NN(t);if(e=r,r.length==1)break}return e}function s7(n){return n.map(({input:e,error:t,output:r})=>{if(t){let s=t.message;throw new Error(n.length==1?s:`Invalid label ${uv(zm(e,63))}: ${s}`)}return wc(r)}).join(xN)}function NN(n){return new Error(`disallowed character: ${cv(n)}`)}function MN(n,e){let t=cv(e),r=Ac.find(s=>s.P.has(e));return r&&(t=`${r.N} ${t}`),new Error(`illegal mixture: ${n.N} + ${t}`)}function id(n){return new Error(`illegal placement: ${n}`)}function i7(n,e){for(let t of e)if(!sd(n,t))throw MN(n,t);if(n.M){let t=vN(e);for(let r=1,s=t.length;r<s;r++)if(iv.has(t[r])){let i=r+1;for(let o;i<s&&iv.has(o=t[i]);i++)for(let a=r;a<i;a++)if(t[a]==o)throw new Error(`duplicate non-spacing marks: ${cv(o)}`);if(i-r>lN)throw new Error(`excessive non-spacing marks: ${uv(zm(t.slice(r-1,i)))} (${i-r}/${lN})`);r=i}}}function o7(n,e,t){let r=[],s=[];for(n=n.slice().reverse();n.length;){let i=l7(n);if(i)s.length&&(r.push(e(s)),s=[]),r.push(t(i));else{let o=n.pop();if(Sa.has(o))s.push(o);else{let a=sv.get(o);if(a)s.push(...a);else if(!CN.has(o))throw NN(o)}}}return s.length&&r.push(e(s)),r}function a7(n){return n.filter(e=>e!=EN)}function l7(n,e){let t=av,r,s=n.length;for(;s&&(t=t.get(n[--s]),!!t);){let{V:i}=t;i&&(r=i,n.length=s)}return r}const RN=new Uint8Array(32);RN.fill(0);function PN(n){return H(n.length!==0,"invalid ENS name; empty component","comp",n),n}function DN(n){const e=ri(c7(n)),t=[];if(n.length===0)return t;let r=0;for(let s=0;s<e.length;s++)e[s]===46&&(t.push(PN(e.slice(r,s))),r=s+1);return H(r<e.length,"invalid ENS name; empty component","name",n),t.push(PN(e.slice(r))),t}function c7(n){try{if(n.length===0)throw new Error("empty label");return e7(n)}catch(e){H(!1,`invalid ENS name (${e.message})`,"name",n)}}function fv(n){H(typeof n=="string","invalid ENS name; not a string","name",n),H(n.length,"invalid ENS name (empty label)","name",n);let e=RN;const t=DN(n);for(;t.length;)e=Ft(Rt([e,Ft(t.pop())]));return ce(e)}function u7(n,e){const t=e;return H(t<=255,"DNS encoded label cannot exceed 255","length",t),ce(Rt(DN(n).map(r=>{H(r.length<=t,`label ${JSON.stringify(n)} exceeds ${t} bytes`,"name",n);const s=new Uint8Array(r.length+1);return s.set(r,1),s[0]=s.length-1,s})))+"00"}function dv(n,e){return{address:st(n),storageKeys:e.map((t,r)=>(H(pt(t,32),"invalid slot",`storageKeys[${r}]`,t),t.toLowerCase()))}}function fo(n){if(Array.isArray(n))return n.map((t,r)=>Array.isArray(t)?(H(t.length===2,"invalid slot set",`value[${r}]`,t),dv(t[0],t[1])):(H(t!=null&&typeof t=="object","invalid address-slot set","value",n),dv(t.address,t.storageKeys)));H(n!=null&&typeof n=="object","invalid access list","value",n);const e=Object.keys(n).map(t=>{const r=n[t].reduce((s,i)=>(s[i]=!0,s),{});return dv(t,Object.keys(r).sort())});return e.sort((t,r)=>t.address.localeCompare(r.address)),e}function f7(n){let e;return typeof n=="string"?e=Zf.computePublicKey(n,!1):e=n.publicKey,st(Ft("0x"+e.substring(4)).substring(26))}function d7(n,e){return f7(Zf.recoverPublicKey(n,e))}const tn=BigInt(0),h7=BigInt(2),p7=BigInt(27),m7=BigInt(28),g7=BigInt(35),y7=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),hv=4096*32;function IN(n,e){let t=n.toString(16);for(;t.length<2;)t="0"+t;return t+=pc(e).substring(4),"0x"+t}function Vm(n){return n==="0x"?null:st(n)}function pv(n,e){try{return fo(n)}catch(t){H(!1,t.message,e,n)}}function od(n,e){return n==="0x"?0:Pe(n,e)}function Dt(n,e){if(n==="0x")return tn;const t=pe(n,e);return H(t<=y7,"value exceeds uint size",e,t),t}function gt(n,e){const t=pe(n,"value"),r=Sn(t);return H(r.length<=32,"value too large",`tx.${e}`,t),r}function mv(n){return fo(n).map(e=>[e.address,e.storageKeys])}function b7(n,e){H(Array.isArray(n),`invalid ${e}`,"value",n);for(let t=0;t<n.length;t++)H(pt(n[t],32),"invalid ${ param } hash",`value[${t}]`,n[t]);return n}function w7(n){const e=Om(n);H(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",n);const t={type:0,nonce:od(e[0],"nonce"),gasPrice:Dt(e[1],"gasPrice"),gasLimit:Dt(e[2],"gasLimit"),to:Vm(e[3]),value:Dt(e[4],"value"),data:ce(e[5]),chainId:tn};if(e.length===6)return t;const r=Dt(e[6],"v"),s=Dt(e[7],"r"),i=Dt(e[8],"s");if(s===tn&&i===tn)t.chainId=r;else{let o=(r-g7)/h7;o<tn&&(o=tn),t.chainId=o,H(o!==tn||r===p7||r===m7,"non-canonical legacy v","v",e[6]),t.signature=Wr.from({r:ya(e[7],32),s:ya(e[8],32),v:r})}return t}function v7(n,e){const t=[gt(n.nonce,"nonce"),gt(n.gasPrice||0,"gasPrice"),gt(n.gasLimit,"gasLimit"),n.to||"0x",gt(n.value,"value"),n.data];let r=tn;if(n.chainId!=tn)r=pe(n.chainId,"tx.chainId"),H(!e||e.networkV==null||e.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",e);else if(n.signature){const i=n.signature.legacyChainId;i!=null&&(r=i)}if(!e)return r!==tn&&(t.push(Sn(r)),t.push("0x"),t.push("0x")),wa(t);let s=BigInt(27+e.yParity);return r!==tn?s=Wr.getChainIdV(r,e.v):BigInt(e.v)!==s&&H(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(Sn(s)),t.push(Sn(e.r)),t.push(Sn(e.s)),wa(t)}function gv(n,e){let t;try{if(t=od(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{H(!1,"invalid yParity","yParity",e[0])}const r=ya(e[1],32),s=ya(e[2],32),i=Wr.from({r,s,yParity:t});n.signature=i}function A7(n){const e=Om(qe(n).slice(1));H(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",ce(n));const t={type:2,chainId:Dt(e[0],"chainId"),nonce:od(e[1],"nonce"),maxPriorityFeePerGas:Dt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Dt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Dt(e[4],"gasLimit"),to:Vm(e[5]),value:Dt(e[6],"value"),data:ce(e[7]),accessList:pv(e[8],"accessList")};return e.length===9||gv(t,e.slice(9)),t}function x7(n,e){const t=[gt(n.chainId,"chainId"),gt(n.nonce,"nonce"),gt(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gt(n.maxFeePerGas||0,"maxFeePerGas"),gt(n.gasLimit,"gasLimit"),n.to||"0x",gt(n.value,"value"),n.data,mv(n.accessList||[])];return e&&(t.push(gt(e.yParity,"yParity")),t.push(Sn(e.r)),t.push(Sn(e.s))),Rt(["0x02",wa(t)])}function E7(n){const e=Om(qe(n).slice(1));H(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",ce(n));const t={type:1,chainId:Dt(e[0],"chainId"),nonce:od(e[1],"nonce"),gasPrice:Dt(e[2],"gasPrice"),gasLimit:Dt(e[3],"gasLimit"),to:Vm(e[4]),value:Dt(e[5],"value"),data:ce(e[6]),accessList:pv(e[7],"accessList")};return e.length===8||gv(t,e.slice(8)),t}function k7(n,e){const t=[gt(n.chainId,"chainId"),gt(n.nonce,"nonce"),gt(n.gasPrice||0,"gasPrice"),gt(n.gasLimit,"gasLimit"),n.to||"0x",gt(n.value,"value"),n.data,mv(n.accessList||[])];return e&&(t.push(gt(e.yParity,"recoveryParam")),t.push(Sn(e.r)),t.push(Sn(e.s))),Rt(["0x01",wa(t)])}function C7(n){let e=Om(qe(n).slice(1)),t="3",r=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const i=e[1],o=e[2],a=e[3];H(Array.isArray(i),"invalid network format: blobs not an array","fields[1]",i),H(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),H(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),H(i.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),H(i.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",e),r=[];for(let l=0;l<e[1].length;l++)r.push({data:i[l],commitment:o[l],proof:a[l]});e=e[0]}H(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",ce(n));const s={type:3,chainId:Dt(e[0],"chainId"),nonce:od(e[1],"nonce"),maxPriorityFeePerGas:Dt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Dt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Dt(e[4],"gasLimit"),to:Vm(e[5]),value:Dt(e[6],"value"),data:ce(e[7]),accessList:pv(e[8],"accessList"),maxFeePerBlobGas:Dt(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};r&&(s.blobs=r),H(s.to!=null,`invalid address for transaction type: ${t}`,"data",n),H(Array.isArray(s.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",n);for(let i=0;i<s.blobVersionedHashes.length;i++)H(pt(s.blobVersionedHashes[i],32),`invalid blobVersionedHash at index ${i}: must be length 32`,"data",n);return e.length===11||gv(s,e.slice(11)),s}function S7(n,e,t){const r=[gt(n.chainId,"chainId"),gt(n.nonce,"nonce"),gt(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gt(n.maxFeePerGas||0,"maxFeePerGas"),gt(n.gasLimit,"gasLimit"),n.to||Xf,gt(n.value,"value"),n.data,mv(n.accessList||[]),gt(n.maxFeePerBlobGas||0,"maxFeePerBlobGas"),b7(n.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(r.push(gt(e.yParity,"yParity")),r.push(Sn(e.r)),r.push(Sn(e.s)),t)?Rt(["0x03",wa([r,t.map(s=>s.data),t.map(s=>s.commitment),t.map(s=>s.proof)])]):Rt(["0x03",wa(r)])}const bi=class bi{constructor(){W(this,Zc);W(this,Ms,void 0);W(this,$c,void 0);W(this,zc,void 0);W(this,Vc,void 0);W(this,Wc,void 0);W(this,Gc,void 0);W(this,Kc,void 0);W(this,Jc,void 0);W(this,qc,void 0);W(this,Qc,void 0);W(this,Yc,void 0);W(this,Xc,void 0);W(this,Va,void 0);W(this,yo,void 0);W(this,yi,void 0);W(this,bo,void 0);D(this,Ms,null),D(this,$c,null),D(this,Vc,0),D(this,Wc,tn),D(this,Gc,null),D(this,Kc,null),D(this,Jc,null),D(this,zc,"0x"),D(this,qc,tn),D(this,Qc,tn),D(this,Yc,null),D(this,Xc,null),D(this,Va,null),D(this,yo,null),D(this,bo,null),D(this,yi,null)}get type(){return k(this,Ms)}set type(e){switch(e){case null:D(this,Ms,null);break;case 0:case"legacy":D(this,Ms,0);break;case 1:case"berlin":case"eip-2930":D(this,Ms,1);break;case 2:case"london":case"eip-1559":D(this,Ms,2);break;case 3:case"cancun":case"eip-4844":D(this,Ms,3);break;default:H(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const e=k(this,$c);return e==null&&this.type===3?Xf:e}set to(e){D(this,$c,e==null?null:st(e))}get nonce(){return k(this,Vc)}set nonce(e){D(this,Vc,Pe(e,"value"))}get gasLimit(){return k(this,Wc)}set gasLimit(e){D(this,Wc,pe(e))}get gasPrice(){const e=k(this,Gc);return e==null&&(this.type===0||this.type===1)?tn:e}set gasPrice(e){D(this,Gc,e==null?null:pe(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=k(this,Kc);return e??(this.type===2||this.type===3?tn:null)}set maxPriorityFeePerGas(e){D(this,Kc,e==null?null:pe(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=k(this,Jc);return e??(this.type===2||this.type===3?tn:null)}set maxFeePerGas(e){D(this,Jc,e==null?null:pe(e,"maxFeePerGas"))}get data(){return k(this,zc)}set data(e){D(this,zc,ce(e))}get value(){return k(this,qc)}set value(e){D(this,qc,pe(e,"value"))}get chainId(){return k(this,Qc)}set chainId(e){D(this,Qc,pe(e))}get signature(){return k(this,Yc)||null}set signature(e){D(this,Yc,e==null?null:Wr.from(e))}get accessList(){const e=k(this,Xc)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){D(this,Xc,e==null?null:fo(e))}get maxFeePerBlobGas(){const e=k(this,Va);return e==null&&this.type===3?tn:e}set maxFeePerBlobGas(e){D(this,Va,e==null?null:pe(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=k(this,yo);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){H(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)H(pt(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}D(this,yo,e)}get blobs(){return k(this,bo)==null?null:k(this,bo).map(e=>Object.assign({},e))}set blobs(e){if(e==null){D(this,bo,null);return}const t=[],r=[];for(let s=0;s<e.length;s++){const i=e[s];if(Mw(i)){X(k(this,yi),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=qe(i);if(H(o.length<=hv,"blob is too large",`blobs[${s}]`,i),o.length!==hv){const c=new Uint8Array(hv);c.set(o),o=c}const a=k(this,yi).blobToKzgCommitment(o),l=ce(k(this,yi).computeBlobKzgProof(o,a));t.push({data:ce(o),commitment:ce(a),proof:l}),r.push(IN(1,a))}else{const o=ce(i.commitment);t.push({data:ce(i.data),commitment:o,proof:ce(i.proof)}),r.push(IN(1,o))}}D(this,bo,t),D(this,yo,r)}get kzg(){return k(this,yi)}set kzg(e){D(this,yi,e)}get hash(){return this.signature==null?null:Ft(ie(this,Zc,Ng).call(this,!0,!1))}get unsignedHash(){return Ft(this.unsignedSerialized)}get from(){return this.signature==null?null:d7(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:Zf.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return ie(this,Zc,Ng).call(this,!0,!0)}get unsignedSerialized(){return ie(this,Zc,Ng).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,r=this.accessList!=null,s=k(this,Va)!=null||k(this,yo);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&X(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),X(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),X(this.type!==0||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return this.type!=null?i.push(this.type):t?i.push(2):e?(i.push(1),r||i.push(0)):r?(i.push(1),i.push(2)):(s&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return bi.from(this)}toJSON(){const e=t=>t==null?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(e==null)return new bi;if(typeof e=="string"){const r=qe(e);if(r[0]>=127)return bi.from(w7(r));switch(r[0]){case 1:return bi.from(E7(r));case 2:return bi.from(A7(r));case 3:return bi.from(C7(r))}X(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new bi;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=Wr.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(H(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),H(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(H(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),H(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}};Ms=new WeakMap,$c=new WeakMap,zc=new WeakMap,Vc=new WeakMap,Wc=new WeakMap,Gc=new WeakMap,Kc=new WeakMap,Jc=new WeakMap,qc=new WeakMap,Qc=new WeakMap,Yc=new WeakMap,Xc=new WeakMap,Va=new WeakMap,yo=new WeakMap,yi=new WeakMap,bo=new WeakMap,Zc=new WeakSet,Ng=function(e,t){X(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=e?this.signature:null;switch(this.inferType()){case 0:return v7(this,r);case 1:return k7(this,r);case 2:return x7(this,r);case 3:return S7(this,r,t?this.blobs:null)}X(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let ad=bi;const _N=new Uint8Array(32);_N.fill(0);const T7=BigInt(-1),LN=BigInt(0),BN=BigInt(1),O7=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function N7(n){const e=qe(n),t=e.length%32;return t?Rt([e,_N.slice(t)]):ce(e)}const M7=so(BN,32),R7=so(LN,32),FN={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},yv=["name","version","chainId","verifyingContract","salt"];function UN(n){return function(e){return H(typeof e=="string",`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,e),e}}const P7={name:UN("name"),version:UN("version"),chainId:function(n){const e=pe(n,"domain.chainId");return H(e>=0,"invalid chain ID","domain.chainId",n),Number.isSafeInteger(e)?Number(e):ba(e)},verifyingContract:function(n){try{return st(n).toLowerCase()}catch{}H(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){const e=qe(n,"domain.salt");return H(e.length===32,'invalid domain value "salt"',"domain.salt",n),ce(e)}};function bv(n){{const e=n.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",r=parseInt(e[2]);H(r%8===0&&r!==0&&r<=256&&e[2]===String(r),"invalid numeric width","type",n);const s=Kf(O7,t?r-1:r),i=t?(s+BN)*T7:LN;return function(o){const a=pe(o,"value");return H(a>=i&&a<=s,`value out-of-bounds for ${n}`,"value",a),so(t?$2(a,256):a,32)}}}{const e=n.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return H(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",n),function(r){const s=qe(r);return H(s.length===t,`invalid length for ${n}`,"value",r),N7(r)}}}switch(n){case"address":return function(e){return ya(st(e),32)};case"bool":return function(e){return e?M7:R7};case"bytes":return function(e){return Ft(e)};case"string":return function(e){return ka(e)}}return null}function HN(n,e){return`${n}(${e.map(({name:t,type:r})=>r+" "+t).join(",")})`}function Wm(n){const e=n.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:n}}const Cr=class Cr{constructor(e){W(this,wg);j(this,"primaryType");W(this,Ad,void 0);W(this,wi,void 0);W(this,eu,void 0);D(this,wi,new Map),D(this,eu,new Map);const t=new Map,r=new Map,s=new Map,i={};Object.keys(e).forEach(l=>{i[l]=e[l].map(({name:c,type:u})=>{let{base:f,index:d}=Wm(u);return f==="int"&&!e.int&&(f="int256"),f==="uint"&&!e.uint&&(f="uint256"),{name:c,type:f+(d||"")}}),t.set(l,new Set),r.set(l,[]),s.set(l,new Set)}),D(this,Ad,JSON.stringify(i));for(const l in i){const c=new Set;for(const u of i[l]){H(!c.has(u.name),`duplicate variable name ${JSON.stringify(u.name)} in ${JSON.stringify(l)}`,"types",e),c.add(u.name);const f=Wm(u.type).base;H(f!==l,`circular type reference to ${JSON.stringify(f)}`,"types",e),!bv(f)&&(H(r.has(f),`unknown type ${JSON.stringify(f)}`,"types",e),r.get(f).push(l),t.get(l).add(f))}}const o=Array.from(r.keys()).filter(l=>r.get(l).length===0);H(o.length!==0,"missing primary type","types",e),H(o.length===1,`ambiguous primary types or unused types: ${o.map(l=>JSON.stringify(l)).join(", ")}`,"types",e),be(this,{primaryType:o[0]});function a(l,c){H(!c.has(l),`circular type reference to ${JSON.stringify(l)}`,"types",e),c.add(l);for(const u of t.get(l))if(r.has(u)){a(u,c);for(const f of c)s.get(f).add(u)}c.delete(l)}a(this.primaryType,new Set);for(const[l,c]of s){const u=Array.from(c);u.sort(),k(this,wi).set(l,HN(l,i[l])+u.map(f=>HN(f,i[f])).join(""))}}get types(){return JSON.parse(k(this,Ad))}getEncoder(e){let t=k(this,eu).get(e);return t||(t=ie(this,wg,KM).call(this,e),k(this,eu).set(e,t)),t}encodeType(e){const t=k(this,wi).get(e);return H(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return Ft(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,r){if(bv(e))return r(e,t);const s=Wm(e).array;if(s)return H(s.count===-1||s.count===t.length,`array length mismatch; expected length ${s.count}`,"value",t),t.map(o=>this._visit(s.prefix,o,r));const i=this.types[e];if(i)return i.reduce((o,{name:a,type:l})=>(o[a]=this._visit(l,t[a],r),o),{});H(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new Cr(e)}static getPrimaryType(e){return Cr.from(e).primaryType}static hashStruct(e,t,r){return Cr.from(t).hashStruct(e,r)}static hashDomain(e){const t=[];for(const r in e){if(e[r]==null)continue;const s=FN[r];H(s,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",e),t.push({name:r,type:s})}return t.sort((r,s)=>yv.indexOf(r.name)-yv.indexOf(s.name)),Cr.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,r){return Rt(["0x1901",Cr.hashDomain(e),Cr.from(t).hash(r)])}static hash(e,t,r){return Ft(Cr.encode(e,t,r))}static async resolveNames(e,t,r,s){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const i={};e.verifyingContract&&!pt(e.verifyingContract,20)&&(i[e.verifyingContract]="0x");const o=Cr.from(t);o.visit(r,(a,l)=>(a==="address"&&!pt(l,20)&&(i[l]="0x"),l));for(const a in i)i[a]=await s(a);return e.verifyingContract&&i[e.verifyingContract]&&(e.verifyingContract=i[e.verifyingContract]),r=o.visit(r,(a,l)=>a==="address"&&i[l]?i[l]:l),{domain:e,value:r}}static getPayload(e,t,r){Cr.hashDomain(e);const s={},i=[];yv.forEach(l=>{const c=e[l];c!=null&&(s[l]=P7[l](c),i.push({name:l,type:FN[l]}))});const o=Cr.from(t);t=o.types;const a=Object.assign({},t);return H(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=i,o.encode(r),{types:a,domain:s,primaryType:o.primaryType,message:o.visit(r,(l,c)=>{if(l.match(/^bytes(\d*)/))return ce(qe(c));if(l.match(/^u?int/))return pe(c).toString();switch(l){case"address":return c.toLowerCase();case"bool":return!!c;case"string":return H(typeof c=="string","invalid string","value",c),c}H(!1,"unsupported type","type",l)})}}};Ad=new WeakMap,wi=new WeakMap,eu=new WeakMap,wg=new WeakSet,KM=function(e){{const s=bv(e);if(s)return s}const t=Wm(e).array;if(t){const s=t.prefix,i=this.getEncoder(s);return o=>{H(t.count===-1||t.count===o.length,`array length mismatch; expected length ${t.count}`,"value",o);let a=o.map(i);return k(this,wi).has(s)&&(a=a.map(Ft)),Ft(Rt(a))}}const r=this.types[e];if(r){const s=ka(k(this,wi).get(e));return i=>{const o=r.map(({name:a,type:l})=>{const c=this.getEncoder(l)(i[a]);return k(this,wi).has(l)?Ft(c):c});return o.unshift(s),Rt(o)}}H(!1,`unknown type: ${e}`,"type",e)};let Gm=Cr;function Mn(n){const e=new Set;return n.forEach(t=>e.add(t)),Object.freeze(e)}const D7=Mn("external public payable override".split(" ")),jN="constant external internal payable private public pure view override",I7=Mn(jN.split(" ")),$N="constructor error event fallback function receive struct",zN=Mn($N.split(" ")),VN="calldata memory storage payable indexed",_7=Mn(VN.split(" ")),L7=[$N,VN,"tuple returns",jN].join(" "),B7=Mn(L7.split(" ")),F7={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},U7=new RegExp("^(\\s*)"),H7=new RegExp("^([0-9]+)"),j7=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),WN=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),GN=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),vg=class vg{constructor(e){W(this,xd);W(this,un,void 0);W(this,Yr,void 0);D(this,un,0),D(this,Yr,e.slice())}get offset(){return k(this,un)}get length(){return k(this,Yr).length-k(this,un)}clone(){return new vg(k(this,Yr))}reset(){D(this,un,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=ie(this,xd,r1).call(this,k(this,un)+1,e.match+1);return D(this,un,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;k(this,un)<e.match-1;){const r=this.peek().linkNext;t.push(ie(this,xd,r1).call(this,k(this,un)+1,r)),D(this,un,r)}return D(this,un,e.match+1),t}peek(){if(k(this,un)>=k(this,Yr).length)throw new Error("out-of-bounds");return k(this,Yr)[k(this,un)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return Hd(this,un)._++,e}toString(){const e=[];for(let t=k(this,un);t<k(this,Yr).length;t++){const r=k(this,Yr)[t];e.push(`${r.type}:${r.text}`)}return`<TokenString ${e.join(" ")}>`}};un=new WeakMap,Yr=new WeakMap,xd=new WeakSet,r1=function(e=0,t=0){return new vg(k(this,Yr).slice(e,t).map(r=>Object.freeze(Object.assign({},r,{match:r.match-e,linkBack:r.linkBack-e,linkNext:r.linkNext-e}))))};let Gr=vg;function ho(n){const e=[],t=o=>{const a=i<n.length?JSON.stringify(n[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let r=[],s=[],i=0;for(;i<n.length;){let o=n.substring(i),a=o.match(U7);a&&(i+=a[1].length,o=n.substring(i));const l={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(l);let c=F7[o[0]]||"";if(c){if(l.type=c,l.text=o[0],i++,c==="OPEN_PAREN")r.push(e.length-1),s.push(e.length-1);else if(c=="CLOSE_PAREN")r.length===0&&t("no matching open bracket"),l.match=r.pop(),e[l.match].match=e.length-1,l.depth--,l.linkBack=s.pop(),e[l.linkBack].linkNext=e.length-1;else if(c==="COMMA")l.linkBack=s.pop(),e[l.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(c==="OPEN_BRACKET")l.type="BRACKET";else if(c==="CLOSE_BRACKET"){let u=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const f=e.pop().text;u=f+u,e[e.length-1].value=Pe(f)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=u}continue}if(a=o.match(j7),a){if(l.text=a[1],i+=l.text.length,B7.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(GN)){l.type="TYPE";continue}l.type="ID";continue}if(a=o.match(H7),a){l.text=a[1],l.type="NUMBER",i+=l.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new Gr(e.map(o=>Object.freeze(o)))}function KN(n,e){let t=[];for(const r in e.keys())n.has(r)&&t.push(r);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function Km(n,e){if(e.peekKeyword(zN)){const t=e.pop().text;if(t!==n)throw new Error(`expected ${n}, got ${t}`)}return e.popType("ID")}function ai(n,e){const t=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||e&&!e.has(r))break;if(n.pop(),t.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);t.add(r)}return Object.freeze(t)}function JN(n){let e=ai(n,I7);return KN(e,Mn("constant payable nonpayable".split(" "))),KN(e,Mn("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function li(n,e){return n.popParams().map(t=>ln.from(t,e))}function qN(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return pe(n.pop().text);throw new Error("invalid gas")}return null}function Ta(n){if(n.length)throw new Error(`unexpected tokens at offset ${n.offset}: ${n.toString()}`)}const $7=new RegExp(/^(.*)\[([0-9]*)\]$/);function QN(n){const e=n.match(GN);if(H(e,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(e[2]){const t=parseInt(e[2]);H(t!==0&&t<=32,"invalid bytes length","type",n)}else if(e[3]){const t=parseInt(e[3]);H(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",n)}return n}const kt={},Vn=Symbol.for("_ethers_internal"),YN="_ParamTypeInternal",XN="_ErrorInternal",ZN="_EventInternal",eM="_ConstructorInternal",tM="_FallbackInternal",nM="_FunctionInternal",rM="_StructInternal",Sr=class Sr{constructor(e,t,r,s,i,o,a,l){W(this,tu);j(this,"name");j(this,"type");j(this,"baseType");j(this,"indexed");j(this,"components");j(this,"arrayLength");j(this,"arrayChildren");if(Em(e,kt,"ParamType"),Object.defineProperty(this,Vn,{value:YN}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||l==null)throw new Error("")}else if(a!=null||l!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");be(this,{name:t,type:r,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:l})}format(e){if(e==null&&(e="sighash"),e==="json"){const r=this.name||"";if(this.isArray()){const i=JSON.parse(this.arrayChildren.format("json"));return i.name=r,i.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(i)}const s={type:this.baseType==="tuple"?"tuple":this.type,name:r};return typeof this.indexed=="boolean"&&(s.indexed=this.indexed),this.isTuple()&&(s.components=this.components.map(i=>JSON.parse(i.format(e)))),JSON.stringify(s)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(r=>r.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return e.map(s=>r.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const r=this;return e.map((s,i)=>r.components[i].walk(s,t))}return t(this.type,e)}async walkAsync(e,t){const r=[],s=[e];return ie(this,tu,Mg).call(this,r,e,t,i=>{s[0]=i}),r.length&&await Promise.all(r),s[0]}static from(e,t){if(Sr.isParamType(e))return e;if(typeof e=="string")try{return Sr.from(ho(e),t)}catch{H(!1,"invalid param type","obj",e)}else if(e instanceof Gr){let a="",l="",c=null;ai(e,Mn(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(l="tuple",c=e.popParams().map(g=>Sr.from(g)),a=`tuple(${c.map(g=>g.format()).join(",")})`):(a=QN(e.popType("TYPE")),l=a);let u=null,f=null;for(;e.length&&e.peekType("BRACKET");){const g=e.pop();u=new Sr(kt,"",a,l,null,c,f,u),f=g.value,a+=g.text,l="array",c=null}let d=null;if(ai(e,_7).has("indexed")){if(!t)throw new Error("");d=!0}const p=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new Sr(kt,p,a,l,d,c,f,u)}const r=e.name;H(!r||typeof r=="string"&&r.match(WN),"invalid name","obj.name",r);let s=e.indexed;s!=null&&(H(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let i=e.type,o=i.match($7);if(o){const a=parseInt(o[2]||"-1"),l=Sr.from({type:o[1],components:e.components});return new Sr(kt,r||"",i,"array",s,null,a,l)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=e.components!=null?e.components.map(c=>Sr.from(c)):null;return new Sr(kt,r||"",i,"tuple",s,a,null,null)}return i=QN(e.type),new Sr(kt,r||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[Vn]===YN}};tu=new WeakSet,Mg=function(e,t,r,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((l,c)=>{var u;ie(u=o,tu,Mg).call(u,e,l,r,f=>{a[c]=f})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(l=>{if(!l.name)throw new Error("cannot use object value with unnamed components");if(!(l.name in t))throw new Error(`missing value for component ${l.name}`);return t[l.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((l,c)=>{var u;ie(u=o[c],tu,Mg).call(u,e,l,r,f=>{a[c]=f})}),s(a);return}const i=r(this.type,t);i.then?e.push(async function(){s(await i)}()):s(i)};let ln=Sr;class Oa{constructor(e,t,r){j(this,"type");j(this,"inputs");Em(e,kt,"Fragment"),r=Object.freeze(r.slice()),be(this,{type:t,inputs:r})}static from(e){if(typeof e=="string"){try{Oa.from(JSON.parse(e))}catch{}return Oa.from(ho(e))}if(e instanceof Gr)switch(e.peekKeyword(zN)){case"constructor":return ci.from(e);case"error":return Wn.from(e);case"event":return Ts.from(e);case"fallback":case"receive":return ui.from(e);case"function":return Os.from(e);case"struct":return Na.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return ci.from(e);case"error":return Wn.from(e);case"event":return Ts.from(e);case"fallback":case"receive":return ui.from(e);case"function":return Os.from(e);case"struct":return Na.from(e)}X(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}H(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return ci.isFragment(e)}static isError(e){return Wn.isFragment(e)}static isEvent(e){return Ts.isFragment(e)}static isFunction(e){return Os.isFragment(e)}static isStruct(e){return Na.isFragment(e)}}class Jm extends Oa{constructor(t,r,s,i){super(t,r,i);j(this,"name");H(typeof s=="string"&&s.match(WN),"invalid identifier","name",s),i=Object.freeze(i.slice()),be(this,{name:s})}}function ld(n,e){return"("+e.map(t=>t.format(n)).join(n==="full"?", ":",")+")"}class Wn extends Jm{constructor(e,t,r){super(e,"error",t,r),Object.defineProperty(this,Vn,{value:XN})}get selector(){return ka(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+ld(e,this.inputs)),t.join(" ")}static from(e){if(Wn.isFragment(e))return e;if(typeof e=="string")return Wn.from(ho(e));if(e instanceof Gr){const t=Km("error",e),r=li(e);return Ta(e),new Wn(kt,t,r)}return new Wn(kt,e.name,e.inputs?e.inputs.map(ln.from):[])}static isFragment(e){return e&&e[Vn]===XN}}class Ts extends Jm{constructor(t,r,s,i){super(t,"event",r,s);j(this,"anonymous");Object.defineProperty(this,Vn,{value:ZN}),be(this,{anonymous:i})}get topicHash(){return ka(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("event"),r.push(this.name+ld(t,this.inputs)),t!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(t,r){return r=(r||[]).map(i=>ln.from(i)),new Ts(kt,t,r,!1).topicHash}static from(t){if(Ts.isFragment(t))return t;if(typeof t=="string")try{return Ts.from(ho(t))}catch{H(!1,"invalid event fragment","obj",t)}else if(t instanceof Gr){const r=Km("event",t),s=li(t,!0),i=!!ai(t,Mn(["anonymous"])).has("anonymous");return Ta(t),new Ts(kt,r,s,i)}return new Ts(kt,t.name,t.inputs?t.inputs.map(r=>ln.from(r,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[Vn]===ZN}}class ci extends Oa{constructor(t,r,s,i,o){super(t,r,s);j(this,"payable");j(this,"gas");Object.defineProperty(this,Vn,{value:eM}),be(this,{payable:i,gas:o})}format(t){if(X(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[`constructor${ld(t,this.inputs)}`];return this.payable&&r.push("payable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(t){if(ci.isFragment(t))return t;if(typeof t=="string")try{return ci.from(ho(t))}catch{H(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Gr){ai(t,Mn(["constructor"]));const r=li(t),s=!!ai(t,D7).has("payable"),i=qN(t);return Ta(t),new ci(kt,"constructor",r,s,i)}return new ci(kt,"constructor",t.inputs?t.inputs.map(ln.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Vn]===eM}}class ui extends Oa{constructor(t,r,s){super(t,"fallback",r);j(this,"payable");Object.defineProperty(this,Vn,{value:tM}),be(this,{payable:s})}format(t){const r=this.inputs.length===0?"receive":"fallback";if(t==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:s})}return`${r}()${this.payable?" payable":""}`}static from(t){if(ui.isFragment(t))return t;if(typeof t=="string")try{return ui.from(ho(t))}catch{H(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Gr){const r=t.toString(),s=t.peekKeyword(Mn(["fallback","receive"]));if(H(s,"type must be fallback or receive","obj",r),t.popKeyword(Mn(["fallback","receive"]))==="receive"){const l=li(t);return H(l.length===0,"receive cannot have arguments","obj.inputs",l),ai(t,Mn(["payable"])),Ta(t),new ui(kt,[],!0)}let o=li(t);o.length?H(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(l=>l.format("minimal")).join(", ")):o=[ln.from("bytes")];const a=JN(t);if(H(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),ai(t,Mn(["returns"])).has("returns")){const l=li(t);H(l.length===1&&l[0].type==="bytes","invalid fallback outputs","obj.outputs",l.map(c=>c.format("minimal")).join(", "))}return Ta(t),new ui(kt,o,a==="payable")}if(t.type==="receive")return new ui(kt,[],!0);if(t.type==="fallback"){const r=[ln.from("bytes")],s=t.stateMutability==="payable";return new ui(kt,r,s)}H(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Vn]===tM}}class Os extends Jm{constructor(t,r,s,i,o,a){super(t,"function",r,i);j(this,"constant");j(this,"outputs");j(this,"stateMutability");j(this,"payable");j(this,"gas");Object.defineProperty(this,Vn,{value:nM}),o=Object.freeze(o.slice()),be(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return ka(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t))),outputs:this.outputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("function"),r.push(this.name+ld(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(ld(t,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(t,r){return r=(r||[]).map(i=>ln.from(i)),new Os(kt,t,"view",r,[],null).selector}static from(t){if(Os.isFragment(t))return t;if(typeof t=="string")try{return Os.from(ho(t))}catch{H(!1,"invalid function fragment","obj",t)}else if(t instanceof Gr){const s=Km("function",t),i=li(t),o=JN(t);let a=[];ai(t,Mn(["returns"])).has("returns")&&(a=li(t));const l=qN(t);return Ta(t),new Os(kt,s,o,i,a,l)}let r=t.stateMutability;return r==null&&(r="payable",typeof t.constant=="boolean"?(r="view",t.constant||(r="payable",typeof t.payable=="boolean"&&!t.payable&&(r="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(r="nonpayable")),new Os(kt,t.name,r,t.inputs?t.inputs.map(ln.from):[],t.outputs?t.outputs.map(ln.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Vn]===nM}}class Na extends Jm{constructor(e,t,r){super(e,"struct",t,r),Object.defineProperty(this,Vn,{value:rM})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return Na.from(ho(e))}catch{H(!1,"invalid struct fragment","obj",e)}else if(e instanceof Gr){const t=Km("struct",e),r=li(e);return Ta(e),new Na(kt,t,r)}return new Na(kt,e.name,e.inputs?e.inputs.map(ln.from):[])}static isFragment(e){return e&&e[Vn]===rM}}const Kr=new Map;Kr.set(0,"GENERIC_PANIC"),Kr.set(1,"ASSERT_FALSE"),Kr.set(17,"OVERFLOW"),Kr.set(18,"DIVIDE_BY_ZERO"),Kr.set(33,"ENUM_RANGE_ERROR"),Kr.set(34,"BAD_STORAGE_DATA"),Kr.set(49,"STACK_UNDERFLOW"),Kr.set(50,"ARRAY_RANGE_ERROR"),Kr.set(65,"OUT_OF_MEMORY"),Kr.set(81,"UNINITIALIZED_FUNCTION_CALL");const z7=new RegExp(/^bytes([0-9]*)$/),V7=new RegExp(/^(u?int)([0-9]*)$/);let wv=null,sM=1024;function W7(n,e,t,r){let s="missing revert data",i=null;const o=null;let a=null;if(t){s="execution reverted";const c=qe(t);if(t=ce(t),c.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(c.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(ce(c.slice(0,4))==="0x08c379a0")try{i=r.decode(["string"],c.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(ce(c.slice(0,4))==="0x4e487b71")try{const u=Number(r.decode(["uint256"],c.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[u]},i=`Panic due to ${Kr.get(u)||"UNKNOWN"}(${u})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const l={to:e.to?st(e.to):null,data:e.data||"0x"};return e.from&&(l.from=st(e.from)),wt(s,"CALL_EXCEPTION",{action:n,data:t,reason:i,transaction:l,invocation:o,revert:a})}const Ag=class Ag{constructor(){W(this,wo)}getDefaultValue(e){const t=e.map(s=>ie(this,wo,Nu).call(this,ln.from(s)));return new Lm(t,"_").defaultValue()}encode(e,t){F2(t.length,e.length,"types/values length mismatch");const r=e.map(o=>ie(this,wo,Nu).call(this,ln.from(o))),s=new Lm(r,"_"),i=new _w;return s.encode(i,t),i.data}decode(e,t,r){const s=e.map(o=>ie(this,wo,Nu).call(this,ln.from(o)));return new Lm(s,"_").decode(new Lw(t,r,sM))}static _setDefaultMaxInflation(e){H(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),sM=e}static defaultAbiCoder(){return wv==null&&(wv=new Ag),wv}static getBuiltinCallException(e,t,r){return W7(e,t,r,Ag.defaultAbiCoder())}};wo=new WeakSet,Nu=function(e){if(e.isArray())return new g9(ie(this,wo,Nu).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new Lm(e.components.map(r=>ie(this,wo,Nu).call(this,r)),e.name);switch(e.baseType){case"address":return new p9(e.name);case"bool":return new y9(e.name);case"string":return new S9(e.name);case"bytes":return new b9(e.name);case"":return new A9(e.name)}let t=e.type.match(V7);if(t){let r=parseInt(t[2]||"256");return H(r!==0&&r<=256&&r%8===0,"invalid "+t[1]+" bit length","param",e),new C9(r/8,t[1]==="int",e.name)}if(t=e.type.match(z7),t){let r=parseInt(t[1]);return H(r!==0&&r<=32,"invalid bytes length","param",e),new w9(r,e.name)}H(!1,"invalid type","type",e.type)};let Ec=Ag;class G7{constructor(e,t,r){j(this,"fragment");j(this,"name");j(this,"signature");j(this,"topic");j(this,"args");const s=e.name,i=e.format();be(this,{fragment:e,name:s,signature:i,topic:t,args:r})}}class K7{constructor(e,t,r,s){j(this,"fragment");j(this,"name");j(this,"args");j(this,"signature");j(this,"selector");j(this,"value");const i=e.name,o=e.format();be(this,{fragment:e,name:i,args:r,signature:o,selector:t,value:s})}}class J7{constructor(e,t,r){j(this,"fragment");j(this,"name");j(this,"args");j(this,"signature");j(this,"selector");const s=e.name,i=e.format();be(this,{fragment:e,name:s,args:r,signature:i,selector:t})}}class iM{constructor(e){j(this,"hash");j(this,"_isIndexed");be(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const oM={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},aM={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let e="unknown panic code";return n>=0&&n<=255&&oM[n.toString()]&&(e=oM[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${e})`}}},Wa=class Wa{constructor(e){W(this,nu);W(this,ru);j(this,"fragments");j(this,"deploy");j(this,"fallback");j(this,"receive");W(this,Rs,void 0);W(this,Ps,void 0);W(this,Ds,void 0);W(this,gn,void 0);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,D(this,Ds,new Map),D(this,Rs,new Map),D(this,Ps,new Map);const r=[];for(const o of t)try{r.push(Oa.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}be(this,{fragments:Object.freeze(r)});let s=null,i=!1;D(this,gn,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let l;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}be(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(H(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":l=k(this,Ds);break;case"event":l=k(this,Ps);break;case"error":l=k(this,Rs);break;default:return}const c=o.format();l.has(c)||l.set(c,o)}),this.deploy||be(this,{deploy:ci.from("constructor()")}),be(this,{fallback:s,receive:i})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Ec.defaultAbiCoder()}getFunctionName(e){const t=ie(this,nu,Rg).call(this,e,null,!1);return H(t,"no matching function","key",e),t.name}hasFunction(e){return!!ie(this,nu,Rg).call(this,e,null,!1)}getFunction(e,t){return ie(this,nu,Rg).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(k(this,Ds).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(k(this,Ds).get(s),r)}}getEventName(e){const t=ie(this,ru,Pg).call(this,e,null,!1);return H(t,"no matching event","key",e),t.name}hasEvent(e){return!!ie(this,ru,Pg).call(this,e,null,!1)}getEvent(e,t){return ie(this,ru,Pg).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(k(this,Ps).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(k(this,Ps).get(s),r)}}getError(e,t){if(pt(e)){const s=e.toLowerCase();if(aM[s])return Wn.from(aM[s].signature);for(const i of k(this,Rs).values())if(s===i.selector)return i;return null}if(e.indexOf("(")===-1){const s=[];for(const[i,o]of k(this,Rs))i.split("(")[0]===e&&s.push(o);if(s.length===0)return e==="Error"?Wn.from("error Error(string)"):e==="Panic"?Wn.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");H(!1,`ambiguous error description (i.e. ${i})`,"name",e)}return s[0]}if(e=Wn.from(e).format(),e==="Error(string)")return Wn.from("error Error(string)");if(e==="Panic(uint256)")return Wn.from("error Panic(uint256)");const r=k(this,Rs).get(e);return r||null}forEachError(e){const t=Array.from(k(this,Rs).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(k(this,Rs).get(s),r)}}_decodeParams(e,t){return k(this,gn).decode(e,t)}_encodeParams(e,t){return k(this,gn).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);H(r,"unknown error","fragment",e),e=r}return H(Nt(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,Nt(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);H(r,"unknown error","fragment",e),e=r}return Rt([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);H(r,"unknown function","fragment",e),e=r}return H(Nt(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,Nt(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);H(r,"unknown function","fragment",e),e=r}return Rt([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const i=this.getFunction(e);H(i,"unknown function","fragment",e),e=i}let r="invalid length for result data";const s=Cn(t);if(s.length%32===0)try{return k(this,gn).decode(e.outputs,s)}catch{r="could not decode result data"}X(!1,r,"BAD_DATA",{value:ce(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const r=qe(e,"data"),s=Ec.getBuiltinCallException("call",t,r);if(s.message.startsWith("execution reverted (unknown custom error)")){const a=ce(r.slice(0,4)),l=this.getError(a);if(l)try{const c=k(this,gn).decode(l.inputs,r.slice(4));s.revert={name:l.name,signature:l.format(),args:c},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const r=this.getFunction(e);H(r,"unknown function","fragment",e),e=r}return ce(k(this,gn).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const i=this.getEvent(e);H(i,"unknown event","eventFragment",e),e=i}X(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const r=[];e.anonymous||r.push(e.topicHash);const s=(i,o)=>i.type==="string"?ka(o):i.type==="bytes"?Ft(ce(o)):(i.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":i.type.match(/^u?int/)?o=so(o):i.type.match(/^bytes/)?o=Oz(o,32):i.type==="address"&&k(this,gn).encode(["address"],[o]),ya(ce(o),32));for(t.forEach((i,o)=>{const a=e.inputs[o];if(!a.indexed){H(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?r.push(null):a.baseType==="array"||a.baseType==="tuple"?H(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?r.push(i.map(l=>s(a,l))):r.push(s(a,i))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);H(o,"unknown event","eventFragment",e),e=o}const r=[],s=[],i=[];return e.anonymous||r.push(e.topicHash),H(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const l=t[a];if(o.indexed)if(o.type==="string")r.push(ka(l));else if(o.type==="bytes")r.push(Ft(l));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(k(this,gn).encode([o.type],[l]))}else s.push(o),i.push(l)}),{data:k(this,gn).encode(s,i),topics:r}}decodeEventLog(e,t,r){if(typeof e=="string"){const h=this.getEvent(e);H(h,"unknown event","eventFragment",e),e=h}if(r!=null&&!e.anonymous){const h=e.topicHash;H(pt(r[0],32)&&r[0].toLowerCase()===h,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const s=[],i=[],o=[];e.inputs.forEach((h,p)=>{h.indexed?h.type==="string"||h.type==="bytes"||h.baseType==="tuple"||h.baseType==="array"?(s.push(ln.from({type:"bytes32",name:h.name})),o.push(!0)):(s.push(h),o.push(!1)):(i.push(h),o.push(!1))});const a=r!=null?k(this,gn).decode(s,Rt(r)):null,l=k(this,gn).decode(i,t,!0),c=[],u=[];let f=0,d=0;return e.inputs.forEach((h,p)=>{let g=null;if(h.indexed)if(a==null)g=new iM(null);else if(o[p])g=new iM(a[d++]);else try{g=a[d++]}catch(y){g=y}else try{g=l[f++]}catch(y){g=y}c.push(g),u.push(h.name||null)}),dc.fromItems(c,u)}parseTransaction(e){const t=qe(e.data,"tx.data"),r=pe(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(ce(t.slice(0,4)));if(!s)return null;const i=k(this,gn).decode(s.inputs,t.slice(4));return new K7(s,s.selector,i,r)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new G7(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=ce(e),r=this.getError(Nt(t,0,4));if(!r)return null;const s=k(this,gn).decode(r.inputs,Nt(t,4));return new J7(r,r.selector,s)}static from(e){return e instanceof Wa?e:typeof e=="string"?new Wa(JSON.parse(e)):typeof e.formatJson=="function"?new Wa(e.formatJson()):typeof e.format=="function"?new Wa(e.format("json")):new Wa(e)}};Rs=new WeakMap,Ps=new WeakMap,Ds=new WeakMap,gn=new WeakMap,nu=new WeakSet,Rg=function(e,t,r){if(pt(e)){const i=e.toLowerCase();for(const o of k(this,Ds).values())if(i===o.selector)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of k(this,Ds))o.split("(")[0]===e&&i.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,l=!0;mn.isTyped(o)&&o.type==="overrides"&&(l=!1,a--);for(let c=i.length-1;c>=0;c--){const u=i[c].inputs.length;u!==a&&(!l||u!==a-1)&&i.splice(c,1)}for(let c=i.length-1;c>=0;c--){const u=i[c].inputs;for(let f=0;f<t.length;f++)if(mn.isTyped(t[f])){if(f>=u.length){if(t[f].type==="overrides")continue;i.splice(c,1);break}if(t[f].type!==u[f].baseType){i.splice(c,1);break}}}}if(i.length===1&&t&&t.length!==i[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");H(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return i[0]}const s=k(this,Ds).get(Os.from(e).format());return s||null},ru=new WeakSet,Pg=function(e,t,r){if(pt(e)){const i=e.toLowerCase();for(const o of k(this,Ps).values())if(i===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of k(this,Ps))o.split("(")[0]===e&&i.push(a);if(t){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<t.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let l=0;l<t.length;l++)if(mn.isTyped(t[l])&&t[l].type!==a[l].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");H(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return i[0]}const s=k(this,Ps).get(Ts.from(e).format());return s||null};let vv=Wa;const lM=BigInt(0);function kc(n){return n??null}function It(n){return n==null?null:n.toString()}class cM{constructor(e,t,r){j(this,"gasPrice");j(this,"maxFeePerGas");j(this,"maxPriorityFeePerGas");be(this,{gasPrice:kc(e),maxFeePerGas:kc(t),maxPriorityFeePerGas:kc(r)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:It(e),maxFeePerGas:It(t),maxPriorityFeePerGas:It(r)}}}function qm(n){const e={};n.to&&(e.to=n.to),n.from&&(e.from=n.from),n.data&&(e.data=ce(n.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in n)||n[s]==null||(e[s]=pe(n[s],`request.${s}`));const r="type,nonce".split(/,/);for(const s of r)!(s in n)||n[s]==null||(e[s]=Pe(n[s],`request.${s}`));return n.accessList&&(e.accessList=fo(n.accessList)),"blockTag"in n&&(e.blockTag=n.blockTag),"enableCcipRead"in n&&(e.enableCcipRead=!!n.enableCcipRead),"customData"in n&&(e.customData=n.customData),"blobVersionedHashes"in n&&n.blobVersionedHashes&&(e.blobVersionedHashes=n.blobVersionedHashes.slice()),"kzg"in n&&(e.kzg=n.kzg),"blobs"in n&&n.blobs&&(e.blobs=n.blobs.map(s=>Mw(s)?ce(s):Object.assign({},s))),e}class q7{constructor(e,t){j(this,"provider");j(this,"number");j(this,"hash");j(this,"timestamp");j(this,"parentHash");j(this,"parentBeaconBlockRoot");j(this,"nonce");j(this,"difficulty");j(this,"gasLimit");j(this,"gasUsed");j(this,"stateRoot");j(this,"receiptsRoot");j(this,"blobGasUsed");j(this,"excessBlobGas");j(this,"miner");j(this,"prevRandao");j(this,"extraData");j(this,"baseFeePerGas");W(this,vi,void 0);D(this,vi,e.transactions.map(r=>typeof r!="string"?new ud(r,t):r)),be(this,{provider:t,hash:kc(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:kc(e.prevRandao),extraData:e.extraData,baseFeePerGas:kc(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return k(this,vi).map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=k(this,vi).slice();return e.length===0?[]:(X(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:r,gasLimit:s,gasUsed:i,hash:o,miner:a,prevRandao:l,nonce:c,number:u,parentHash:f,parentBeaconBlockRoot:d,stateRoot:h,receiptsRoot:p,timestamp:g,transactions:y}=this;return{_type:"Block",baseFeePerGas:It(e),difficulty:It(t),extraData:r,gasLimit:It(s),gasUsed:It(i),blobGasUsed:It(this.blobGasUsed),excessBlobGas:It(this.excessBlobGas),hash:o,miner:a,prevRandao:l,nonce:c,number:u,parentHash:f,timestamp:g,parentBeaconBlockRoot:d,stateRoot:h,receiptsRoot:p,transactions:y}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return k(this,vi).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=k(this,vi)[e];else{const r=e.toLowerCase();for(const s of k(this,vi))if(typeof s=="string"){if(s!==r)continue;t=s;break}else{if(s.hash===r)continue;t=s;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const r of t)if(r.hash===e)return r;H(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return Q7(this)}}vi=new WeakMap;class cd{constructor(e,t){j(this,"provider");j(this,"transactionHash");j(this,"blockHash");j(this,"blockNumber");j(this,"removed");j(this,"address");j(this,"data");j(this,"topics");j(this,"index");j(this,"transactionIndex");this.provider=t;const r=Object.freeze(e.topics.slice());be(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:r,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:l,transactionIndex:c}=this;return{_type:"log",address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:l,transactionIndex:c}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return X(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return X(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return X(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return Y7(this)}}class uM{constructor(e,t){j(this,"provider");j(this,"to");j(this,"from");j(this,"contractAddress");j(this,"hash");j(this,"index");j(this,"blockHash");j(this,"blockNumber");j(this,"logsBloom");j(this,"gasUsed");j(this,"blobGasUsed");j(this,"cumulativeGasUsed");j(this,"gasPrice");j(this,"blobGasPrice");j(this,"type");j(this,"status");j(this,"root");W(this,Ed,void 0);D(this,Ed,Object.freeze(e.logs.map(s=>new cd(s,t))));let r=lM;e.effectiveGasPrice!=null?r=e.effectiveGasPrice:e.gasPrice!=null&&(r=e.gasPrice),be(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:r,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return k(this,Ed)}toJSON(){const{to:e,from:t,contractAddress:r,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:l,logs:c,status:u,root:f}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:r,cumulativeGasUsed:It(this.cumulativeGasUsed),from:t,gasPrice:It(this.gasPrice),blobGasUsed:It(this.blobGasUsed),blobGasPrice:It(this.blobGasPrice),gasUsed:It(this.gasUsed),hash:s,index:i,logs:c,logsBloom:l,root:f,status:u,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return dM(this)}reorderedEvent(e){return X(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),fM(this,e)}}Ed=new WeakMap;const Kv=class Kv{constructor(e,t){j(this,"provider");j(this,"blockNumber");j(this,"blockHash");j(this,"index");j(this,"hash");j(this,"type");j(this,"to");j(this,"from");j(this,"nonce");j(this,"gasLimit");j(this,"gasPrice");j(this,"maxPriorityFeePerGas");j(this,"maxFeePerGas");j(this,"maxFeePerBlobGas");j(this,"data");j(this,"value");j(this,"chainId");j(this,"signature");j(this,"accessList");j(this,"blobVersionedHashes");W(this,vo,void 0);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,D(this,vo,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:r,hash:s,type:i,to:o,from:a,nonce:l,data:c,signature:u,accessList:f,blobVersionedHashes:d}=this;return{_type:"TransactionResponse",accessList:f,blockNumber:e,blockHash:t,blobVersionedHashes:d,chainId:It(this.chainId),data:c,from:a,gasLimit:It(this.gasLimit),gasPrice:It(this.gasPrice),hash:s,maxFeePerGas:It(this.maxFeePerGas),maxPriorityFeePerGas:It(this.maxPriorityFeePerGas),maxFeePerBlobGas:It(this.maxFeePerBlobGas),nonce:l,signature:u,to:o,index:r,type:i,value:It(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const r=await this.getTransaction();r&&(e=r.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:r}=await pn({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:r-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const r=e??1,s=t??0;let i=k(this,vo),o=-1,a=i===-1;const l=async()=>{if(a)return null;const{blockNumber:d,nonce:h}=await pn({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(h<this.nonce){i=d;return}if(a)return null;const p=await this.getTransaction();if(!(p&&p.blockNumber!=null))for(o===-1&&(o=i-3,o<k(this,vo)&&(o=k(this,vo)));o<=d;){if(a)return null;const g=await this.provider.getBlock(o,!0);if(g==null)return;for(const y of g)if(y===this.hash)return;for(let y=0;y<g.length;y++){const b=await g.getTransaction(y);if(b.from===this.from&&b.nonce===this.nonce){if(a)return null;const x=await this.provider.getTransactionReceipt(b.hash);if(x==null||d-x.blockNumber+1<r)return;let v="replaced";b.data===this.data&&b.to===this.to&&b.value===this.value?v="repriced":b.data==="0x"&&b.from===b.to&&b.value===lM&&(v="cancelled"),X(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:v==="replaced"||v==="cancelled",reason:v,replacement:b.replaceableTransaction(i),hash:b.hash,receipt:x})}}o++}},c=d=>{if(d==null||d.status!==0)return d;X(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:d.to,from:d.from,data:""},receipt:d})},u=await this.provider.getTransactionReceipt(this.hash);if(r===0)return c(u);if(u){if(await u.confirmations()>=r)return c(u)}else if(await l(),r===0)return null;return await new Promise((d,h)=>{const p=[],g=()=>{p.forEach(b=>b())};if(p.push(()=>{a=!0}),s>0){const b=setTimeout(()=>{g(),h(wt("wait for transaction timeout","TIMEOUT"))},s);p.push(()=>{clearTimeout(b)})}const y=async b=>{if(await b.confirmations()>=r){g();try{d(c(b))}catch(x){h(x)}}};if(p.push(()=>{this.provider.off(this.hash,y)}),this.provider.on(this.hash,y),i>=0){const b=async()=>{try{await l()}catch(x){if(Zt(x,"TRANSACTION_REPLACED")){g(),h(x);return}}a||this.provider.once("block",b)};p.push(()=>{this.provider.off("block",b)}),this.provider.once("block",b)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return X(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),dM(this)}reorderedEvent(e){return X(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),X(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),fM(this,e)}replaceableTransaction(e){H(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new Kv(this,this.provider);return D(t,vo,e),t}};vo=new WeakMap;let ud=Kv;function Q7(n){return{orphan:"drop-block",hash:n.hash,number:n.number}}function fM(n,e){return{orphan:"reorder-transaction",tx:n,other:e}}function dM(n){return{orphan:"drop-transaction",tx:n}}function Y7(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class Av extends cd{constructor(t,r,s){super(t,t.provider);j(this,"interface");j(this,"fragment");j(this,"args");const i=r.decodeEventLog(s,t.data,t.topics);be(this,{args:i,fragment:s,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class hM extends cd{constructor(t,r){super(t,t.provider);j(this,"error");be(this,{error:r})}}class X7 extends uM{constructor(t,r,s){super(s,r);W(this,su,void 0);D(this,su,t)}get logs(){return super.logs.map(t=>{const r=t.topics.length?k(this,su).getEvent(t.topics[0]):null;if(r)try{return new Av(t,k(this,su),r)}catch(s){return new hM(t,s)}return t})}}su=new WeakMap;class xv extends ud{constructor(t,r,s){super(s,r);W(this,kd,void 0);D(this,kd,t)}async wait(t,r){const s=await super.wait(t,r);return s==null?null:new X7(k(this,kd),this.provider,s)}}kd=new WeakMap;class pM extends G2{constructor(t,r,s,i){super(t,r,s);j(this,"log");be(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class Z7 extends pM{constructor(e,t,r,s,i){super(e,t,r,new Av(i,e.interface,s));const o=e.interface.decodeEventLog(s,this.log.data,this.log.topics);be(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const mM=BigInt(0);function gM(n){return n&&typeof n.call=="function"}function yM(n){return n&&typeof n.estimateGas=="function"}function Qm(n){return n&&typeof n.resolveName=="function"}function bM(n){return n&&typeof n.sendTransaction=="function"}function wM(n){if(n!=null){if(Qm(n))return n;if(n.provider)return n.provider}}class eW{constructor(e,t,r){W(this,Cd,void 0);j(this,"fragment");if(be(this,{fragment:t}),t.inputs.length<r.length)throw new Error("too many arguments");const s=Ma(e.runner,"resolveName"),i=Qm(s)?s:null;D(this,Cd,async function(){const o=await Promise.all(t.inputs.map((a,l)=>r[l]==null?null:a.walkAsync(r[l],(u,f)=>u==="address"?Array.isArray(f)?Promise.all(f.map(d=>Nn(d,i))):Nn(f,i):f)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return k(this,Cd)}}Cd=new WeakMap;function Ma(n,e){return n==null?null:typeof n[e]=="function"?n:n.provider&&typeof n.provider[e]=="function"?n.provider:null}function Ra(n){return n==null?null:n.provider||null}async function vM(n,e){const t=mn.dereference(n,"overrides");H(typeof t=="object","invalid overrides parameter","overrides",n);const r=qm(t);return H(r.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),H(r.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}async function tW(n,e,t){const r=Ma(n,"resolveName"),s=Qm(r)?r:null;return await Promise.all(e.map((i,o)=>i.walkAsync(t[o],(a,l)=>(l=mn.dereference(l,a),a==="address"?Nn(l,s):l))))}function nW(n){const e=async function(o){const a=await vM(o,["data"]);a.to=await n.getAddress(),a.from&&(a.from=await Nn(a.from,wM(n.runner)));const l=n.interface,c=pe(a.value||mM,"overrides.value")===mM,u=(a.data||"0x")==="0x";l.fallback&&!l.fallback.payable&&l.receive&&!u&&!c&&H(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),H(l.fallback||u,"cannot send data to receive-only contract","overrides.data",a.data);const f=l.receive||l.fallback&&l.fallback.payable;return H(f||c,"cannot send value to non-payable fallback","overrides.value",a.value),H(l.fallback||u,"cannot send data to receive-only contract","overrides.data",a.data),a},t=async function(o){const a=Ma(n.runner,"call");X(gM(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const l=await e(o);try{return await a.call(l)}catch(c){throw Nw(c)&&c.data?n.interface.makeError(c.data,l):c}},r=async function(o){const a=n.runner;X(bM(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const l=await a.sendTransaction(await e(o)),c=Ra(n.runner);return new xv(n.interface,c,l)},s=async function(o){const a=Ma(n.runner,"estimateGas");return X(yM(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await e(o))},i=async o=>await r(o);return be(i,{_contract:n,estimateGas:s,populateTransaction:e,send:r,staticCall:t}),i}function rW(n,e){const t=function(...c){const u=n.interface.getFunction(e,c);return X(u,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:c}}),u},r=async function(...c){const u=t(...c);let f={};if(u.inputs.length+1===c.length&&(f=await vM(c.pop()),f.from&&(f.from=await Nn(f.from,wM(n.runner)))),u.inputs.length!==c.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const d=await tW(n.runner,u.inputs,c);return Object.assign({},f,await pn({to:n.getAddress(),data:n.interface.encodeFunctionData(u,d)}))},s=async function(...c){const u=await a(...c);return u.length===1?u[0]:u},i=async function(...c){const u=n.runner;X(bM(u),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const f=await u.sendTransaction(await r(...c)),d=Ra(n.runner);return new xv(n.interface,d,f)},o=async function(...c){const u=Ma(n.runner,"estimateGas");return X(yM(u),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await u.estimateGas(await r(...c))},a=async function(...c){const u=Ma(n.runner,"call");X(gM(u),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const f=await r(...c);let d="0x";try{d=await u.call(f)}catch(p){throw Nw(p)&&p.data?n.interface.makeError(p.data,f):p}const h=t(...c);return n.interface.decodeFunctionResult(h,d)},l=async(...c)=>t(...c).constant?await s(...c):await i(...c);return be(l,{name:n.interface.getFunctionName(e),_contract:n,_key:e,getFragment:t,estimateGas:o,populateTransaction:r,send:i,staticCall:s,staticCallResult:a}),Object.defineProperty(l,"fragment",{configurable:!1,enumerable:!0,get:()=>{const c=n.interface.getFunction(e);return X(c,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),c}}),l}function sW(n,e){const t=function(...s){const i=n.interface.getEvent(e,s);return X(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:s}}),i},r=function(...s){return new eW(n,t(...s),s)};return be(r,{name:n.interface.getEventName(e),_contract:n,_key:e,getFragment:t}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const s=n.interface.getEvent(e);return X(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),s}}),r}const Ym=Symbol.for("_ethersInternal_contract"),AM=new WeakMap;function iW(n,e){AM.set(n[Ym],e)}function sr(n){return AM.get(n[Ym])}function oW(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function Ev(n,e){let t,r=null;if(Array.isArray(e)){const i=function(o){if(pt(o,32))return o;const a=n.interface.getEvent(o);return H(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else e==="*"?t=[null]:typeof e=="string"?pt(e,32)?t=[e]:(r=n.interface.getEvent(e),H(r,"unknown fragment","event",e),t=[r.topicHash]):oW(e)?t=await e.getTopicFilter():"fragment"in e?(r=e.fragment,t=[r.topicHash]):H(!1,"unknown event name","event",e);t=t.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=t.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:r,tag:s,topics:t}}async function fd(n,e){const{subs:t}=sr(n);return t.get((await Ev(n,e)).tag)||null}async function xM(n,e,t){const r=Ra(n.runner);X(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:i,topics:o}=await Ev(n,t),{addr:a,subs:l}=sr(n);let c=l.get(i);if(!c){const f={address:a||n,topics:o},d=y=>{let b=s;if(b==null)try{b=n.interface.getEvent(y.topics[0])}catch{}if(b){const x=b,v=s?n.interface.decodeEventLog(s,y.data,y.topics):[];Cv(n,t,v,w=>new Z7(n,w,t,x,y))}else Cv(n,t,[],x=>new pM(n,x,t,y))};let h=[];c={tag:i,listeners:[],start:()=>{h.length||h.push(r.on(f,d))},stop:async()=>{if(h.length==0)return;let y=h;h=[],await Promise.all(y),r.off(f,d)}},l.set(i,c)}return c}let kv=Promise.resolve();async function aW(n,e,t,r){await kv;const s=await fd(n,e);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const l=Array.from(t);r&&l.push(r(a?null:o));try{o.call(n,...l)}catch{}return!a}),s.listeners.length===0&&(s.stop(),sr(n).subs.delete(s.tag)),i>0}async function Cv(n,e,t,r){try{await kv}catch{}const s=aW(n,e,t,r);return kv=s,await s}const Xm=["then"],Sd=class Sd{constructor(e,t,r,s){j(this,"target");j(this,"interface");j(this,"runner");j(this,"filters");j(this,xG);j(this,"fallback");H(typeof e=="string"||nN(e),"invalid value for Contract target","target",e),r==null&&(r=null);const i=vv.from(t);be(this,{target:e,runner:r,interface:i}),Object.defineProperty(this,Ym,{value:{}});let o,a=null,l=null;if(s){const f=Ra(r);l=new xv(this.interface,f,s)}let c=new Map;if(typeof e=="string")if(pt(e))a=e,o=Promise.resolve(e);else{const f=Ma(r,"resolveName");if(!Qm(f))throw wt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=f.resolveName(e).then(d=>{if(d==null)throw wt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return sr(this).addr=d,d})}else o=e.getAddress().then(f=>{if(f==null)throw new Error("TODO");return sr(this).addr=f,f});iW(this,{addrPromise:o,addr:a,deployTx:l,subs:c});const u=new Proxy({},{get:(f,d,h)=>{if(typeof d=="symbol"||Xm.indexOf(d)>=0)return Reflect.get(f,d,h);try{return this.getEvent(d)}catch(p){if(!Zt(p,"INVALID_ARGUMENT")||p.argument!=="key")throw p}},has:(f,d)=>Xm.indexOf(d)>=0?Reflect.has(f,d):Reflect.has(f,d)||this.interface.hasEvent(String(d))});return be(this,{filters:u}),be(this,{fallback:i.receive||i.fallback?nW(this):null}),new Proxy(this,{get:(f,d,h)=>{if(typeof d=="symbol"||d in f||Xm.indexOf(d)>=0)return Reflect.get(f,d,h);try{return f.getFunction(d)}catch(p){if(!Zt(p,"INVALID_ARGUMENT")||p.argument!=="key")throw p}},has:(f,d)=>typeof d=="symbol"||d in f||Xm.indexOf(d)>=0?Reflect.has(f,d):f.interface.hasFunction(d)})}connect(e){return new Sd(this.target,this.interface,e)}attach(e){return new Sd(e,this.interface,this.runner)}async getAddress(){return await sr(this).addrPromise}async getDeployedCode(){const e=Ra(this.runner);X(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=Ra(this.runner);return X(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);r.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return sr(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),rW(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),sW(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,r){t==null&&(t=0),r==null&&(r="latest");const{addr:s,addrPromise:i}=sr(this),o=s||await i,{fragment:a,topics:l}=await Ev(this,e),c={address:o,topics:l,fromBlock:t,toBlock:r},u=Ra(this.runner);return X(u,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await u.getLogs(c)).map(f=>{let d=a;if(d==null)try{d=this.interface.getEvent(f.topics[0])}catch{}if(d)try{return new Av(f,this.interface,d)}catch(h){return new hM(f,h)}return new cd(f,u)})}async on(e,t){const r=await xM(this,"on",e);return r.listeners.push({listener:t,once:!1}),r.start(),this}async once(e,t){const r=await xM(this,"once",e);return r.listeners.push({listener:t,once:!0}),r.start(),this}async emit(e,...t){return await Cv(this,e,t,null)}async listenerCount(e){if(e){const s=await fd(this,e);return s?s.listeners.length:0}const{subs:t}=sr(this);let r=0;for(const{listeners:s}of t.values())r+=s.length;return r}async listeners(e){if(e){const s=await fd(this,e);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:t}=sr(this);let r=[];for(const{listeners:s}of t.values())r=r.concat(s.map(({listener:i})=>i));return r}async off(e,t){const r=await fd(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(t==null||r.listeners.length===0)&&(r.stop(),sr(this).subs.delete(r.tag)),this}async removeAllListeners(e){if(e){const t=await fd(this,e);if(!t)return this;t.stop(),sr(this).subs.delete(t.tag)}else{const{subs:t}=sr(this);for(const{tag:r,stop:s}of t.values())s(),t.delete(r)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends Sd{constructor(s,i=null){super(s,e,i)}}return t}static from(e,t,r){return r==null&&(r=null),new this(e,t,r)}};xG=Ym;let Sv=Sd;function lW(){return Sv}class Cc extends lW(){}function Tv(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):H(!1,"unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}class cW{constructor(e){j(this,"name");be(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const EM=new RegExp("^(ipfs)://(.*)$","i"),kM=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),EM,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],iu=class iu{constructor(e,t,r){W(this,xo);j(this,"provider");j(this,"address");j(this,"name");W(this,Ao,void 0);W(this,Ga,void 0);be(this,{provider:e,address:t,name:r}),D(this,Ao,null),D(this,Ga,new Cc(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e))}async supportsWildcard(){return k(this,Ao)==null&&D(this,Ao,(async()=>{try{return await k(this,Ga).supportsInterface("0x9061b923")}catch(e){if(Zt(e,"CALL_EXCEPTION"))return!1;throw D(this,Ao,null),e}})()),await k(this,Ao)}async getAddress(e){if(e==null&&(e=60),e===60)try{const i=await ie(this,xo,Mu).call(this,"addr(bytes32)");return i==null||i===Xf?null:i}catch(i){if(Zt(i,"CALL_EXCEPTION"))return null;throw i}if(e>=0&&e<2147483648){let i=e+2147483648;const o=await ie(this,xo,Mu).call(this,"addr(bytes32,uint)",[i]);if(pt(o,20))return st(o)}let t=null;for(const i of this.provider.plugins)if(i instanceof cW&&i.supportsCoinType(e)){t=i;break}if(t==null)return null;const r=await ie(this,xo,Mu).call(this,"addr(bytes32,uint)",[e]);if(r==null||r==="0x")return null;const s=await t.decodeAddress(e,r);if(s!=null)return s;X(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:r}})}async getText(e){const t=await ie(this,xo,Mu).call(this,"text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await ie(this,xo,Mu).call(this,"contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const s=t[1]==="e3010170"?"ipfs":"ipns",i=parseInt(t[4],16);if(t[5].length===i*2)return`${s}://${Rz("0x"+t[2])}`}const r=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&r[1].length===64)return`bzz://${r[1]}`;X(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let r=0;r<kM.length;r++){const s=t.match(kM[r]);if(s==null)continue;const i=s[1].toLowerCase();switch(i){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const o=Tv(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:o}),{linkage:e,url:o}}case"erc721":case"erc1155":{const o=i==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:i,value:t});const a=await this.getAddress();if(a==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const l=(s[2]||"").split("/");if(l.length!==2)return e.push({type:`!${i}caip`,value:s[2]||""}),{url:null,linkage:e};const c=l[1],u=new Cc(l[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(i==="erc721"){const g=await u.ownerOf(c);if(a!==g)return e.push({type:"!owner",value:g}),{url:null,linkage:e};e.push({type:"owner",value:g})}else if(i==="erc1155"){const g=await u.balanceOf(a,c);if(!g)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:g.toString()})}let f=await u[o](c);if(f==null||f==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:f}),i==="erc1155"&&(f=f.replace("{id}",so(c,32).substring(2)),e.push({type:"metadata-url-expanded",value:f})),f.match(/^ipfs:/i)&&(f=Tv(f)),e.push({type:"metadata-url",value:f});let d={};const h=await new Tn(f).send();h.assertOk();try{d=h.bodyJson}catch{try{e.push({type:"!metadata",value:h.bodyText})}catch{const b=h.body;return b&&e.push({type:"!metadata",value:ce(b)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!d)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(d)});let p=d.image;if(typeof p!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!p.match(/^(https:\/\/|data:)/i)){if(p.match(EM)==null)return e.push({type:"!imageUrl-ipfs",value:p}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:p}),p=Tv(p)}return e.push({type:"url",value:p}),{linkage:e,url:p}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),r=t.getPlugin("org.ethers.plugins.network.Ens");return X(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),r.address}static async fromName(e,t){var s;let r=t;for(;;){if(r===""||r==="."||t!=="eth"&&r==="eth")return null;const i=await ie(s=iu,xg,JM).call(s,e,r);if(i!=null){const o=new iu(e,i,t);return r!==t&&!await o.supportsWildcard()?null:o}r=r.split(".").slice(1).join(".")}}};Ao=new WeakMap,Ga=new WeakMap,xo=new WeakSet,Mu=async function(e,t){t=(t||[]).slice();const r=k(this,Ga).interface;t.unshift(fv(this.name));let s=null;await this.supportsWildcard()&&(s=r.getFunction(e),X(s,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[u7(this.name,255),r.encodeFunctionData(s,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const i=await k(this,Ga)[e](...t);return s?r.decodeFunctionResult(s,i)[0]:i}catch(i){if(!Zt(i,"CALL_EXCEPTION"))throw i}return null},xg=new WeakSet,JM=async function(e,t){const r=await iu.getEnsAddress(e);try{const i=await new Cc(r,["function resolver(bytes32) view returns (address)"],e).resolver(fv(t),{enableCcipRead:!0});return i===Xf?null:i}catch(s){throw s}return null},W(iu,xg);let Zm=iu;const CM=BigInt(0);function Ge(n,e){return function(t){return t==null?e:n(t)}}function eg(n,e){return t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(r=>n(r))}}function dd(n,e){return t=>{const r={};for(const s in n){let i=s;if(e&&s in e&&!(i in t)){for(const o of e[s])if(o in t){i=o;break}}try{const o=n[s](t[i]);o!==void 0&&(r[s]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";X(!1,`invalid value for value.${s} (${a})`,"BAD_DATA",{value:t})}}return r}}function uW(n){switch(n){case!0:case"true":return!0;case!1:case"false":return!1}H(!1,`invalid boolean; ${JSON.stringify(n)}`,"value",n)}function Sc(n){return H(pt(n,!0),"invalid data","value",n),n}function cn(n){return H(pt(n,32),"invalid hash","value",n),n}const fW=dd({address:st,blockHash:cn,blockNumber:Pe,data:Sc,index:Pe,removed:Ge(uW,!1),topics:eg(cn),transactionHash:cn,transactionIndex:Pe},{index:["logIndex"]});function dW(n){return fW(n)}const hW=dd({hash:Ge(cn),parentHash:cn,parentBeaconBlockRoot:Ge(cn,null),number:Pe,timestamp:Pe,nonce:Ge(Sc),difficulty:pe,gasLimit:pe,gasUsed:pe,stateRoot:Ge(cn,null),receiptsRoot:Ge(cn,null),blobGasUsed:Ge(pe,null),excessBlobGas:Ge(pe,null),miner:Ge(st),prevRandao:Ge(cn,null),extraData:Sc,baseFeePerGas:Ge(pe)},{prevRandao:["mixHash"]});function pW(n){const e=hW(n);return e.transactions=n.transactions.map(t=>typeof t=="string"?t:SM(t)),e}const mW=dd({transactionIndex:Pe,blockNumber:Pe,transactionHash:cn,address:st,topics:eg(cn),data:Sc,index:Pe,blockHash:cn},{index:["logIndex"]});function gW(n){return mW(n)}const yW=dd({to:Ge(st,null),from:Ge(st,null),contractAddress:Ge(st,null),index:Pe,root:Ge(ce),gasUsed:pe,blobGasUsed:Ge(pe,null),logsBloom:Ge(Sc),blockHash:cn,hash:cn,logs:eg(gW),blockNumber:Pe,cumulativeGasUsed:pe,effectiveGasPrice:Ge(pe),blobGasPrice:Ge(pe,null),status:Ge(Pe),type:Ge(Pe,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function bW(n){return yW(n)}function SM(n){n.to&&pe(n.to)===CM&&(n.to="0x0000000000000000000000000000000000000000");const e=dd({hash:cn,index:Ge(Pe,void 0),type:t=>t==="0x"||t==null?0:Pe(t),accessList:Ge(fo,null),blobVersionedHashes:Ge(eg(cn,!0),null),blockHash:Ge(cn,null),blockNumber:Ge(Pe,null),transactionIndex:Ge(Pe,null),from:st,gasPrice:Ge(pe),maxPriorityFeePerGas:Ge(pe),maxFeePerGas:Ge(pe),maxFeePerBlobGas:Ge(pe,null),gasLimit:pe,to:Ge(st,null),value:pe,nonce:Pe,data:Sc,creates:Ge(st,null),chainId:Ge(pe,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(n);if(e.to==null&&e.creates==null&&(e.creates=d9(e)),(n.type===1||n.type===2)&&n.accessList==null&&(e.accessList=[]),n.signature?e.signature=Wr.from(n.signature):e.signature=Wr.from(n),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&pe(e.blockHash)===CM&&(e.blockHash=null),e}const wW="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class hd{constructor(e){j(this,"name");be(this,{name:e})}clone(){return new hd(this.name)}}class tg extends hd{constructor(t,r){t==null&&(t=0);super(`org.ethers.network.plugins.GasCost#${t||0}`);j(this,"effectiveBlock");j(this,"txBase");j(this,"txCreate");j(this,"txDataZero");j(this,"txDataNonzero");j(this,"txAccessListStorageKey");j(this,"txAccessListAddress");const s={effectiveBlock:t};function i(o,a){let l=(r||{})[o];l==null&&(l=a),H(typeof l=="number",`invalud value for ${o}`,"costs",r),s[o]=l}i("txBase",21e3),i("txCreate",32e3),i("txDataZero",4),i("txDataNonzero",16),i("txAccessListStorageKey",1900),i("txAccessListAddress",2400),be(this,s)}clone(){return new tg(this.effectiveBlock,this)}}class ng extends hd{constructor(t,r){super("org.ethers.plugins.network.Ens");j(this,"address");j(this,"targetNetwork");be(this,{address:t||wW,targetNetwork:r??1})}clone(){return new ng(this.address,this.targetNetwork)}}class vW extends hd{constructor(t,r){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");W(this,Td,void 0);W(this,Od,void 0);D(this,Td,t),D(this,Od,r)}get url(){return k(this,Td)}get processFunc(){return k(this,Od)}clone(){return this}}Td=new WeakMap,Od=new WeakMap;const Ov=new Map,lu=class lu{constructor(e,t){W(this,ou,void 0);W(this,au,void 0);W(this,Eo,void 0);D(this,ou,e),D(this,au,pe(t)),D(this,Eo,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return k(this,ou)}set name(e){D(this,ou,e)}get chainId(){return k(this,au)}set chainId(e){D(this,au,pe(e,"chainId"))}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===pe(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===pe(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===pe(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(k(this,Eo).values())}attachPlugin(e){if(k(this,Eo).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return k(this,Eo).set(e.name,e.clone()),this}getPlugin(e){return k(this,Eo).get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new lu(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new tg;let r=t.txBase;if(e.to==null&&(r+=t.txCreate),e.data)for(let s=2;s<e.data.length;s+=2)e.data.substring(s,s+2)==="00"?r+=t.txDataZero:r+=t.txDataNonzero;if(e.accessList){const s=fo(e.accessList);for(const i in s)r+=t.txAccessListAddress+t.txAccessListStorageKey*s[i].storageKeys.length}return r}static from(e){if(AW(),e==null)return lu.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=Ov.get(e);if(t)return t();if(typeof e=="bigint")return new lu("unknown",e);H(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){H(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new lu(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new ng(e.ensAddress,e.ensNetwork)),t}H(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const r=Ov.get(e);r&&H(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",e),Ov.set(e,t)}};ou=new WeakMap,au=new WeakMap,Eo=new WeakMap;let $t=lu;function TM(n,e){const t=String(n);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${n}`);const r=t.split(".");if(r.length===1&&r.push(""),r.length!==2)throw new Error(`invalid gwei value: ${n}`);for(;r[1].length<e;)r[1]+="0";if(r[1].length>9){let s=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||s++,r[1]=s.toString()}return BigInt(r[0]+r[1])}function OM(n){return new vW(n,async(e,t,r)=>{r.setHeader("User-Agent","ethers");let s;try{const[i,o]=await Promise.all([r.send(),e()]);s=i;const a=s.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:TM(a.maxFee,9),maxPriorityFeePerGas:TM(a.maxPriorityFee,9)}}catch(i){X(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:s,error:i})}})}let NM=!1;function AW(){if(NM)return;NM=!0;function n(e,t,r){const s=function(){const i=new $t(e,t);return r.ensNetwork!=null&&i.attachPlugin(new ng(null,r.ensNetwork)),i.attachPlugin(new tg),(r.plugins||[]).forEach(o=>{i.attachPlugin(o)}),i};$t.register(e,s),$t.register(t,s),r.altNames&&r.altNames.forEach(i=>{$t.register(i,s)})}n("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),n("ropsten",3,{ensNetwork:3}),n("rinkeby",4,{ensNetwork:4}),n("goerli",5,{ensNetwork:5}),n("kovan",42,{ensNetwork:42}),n("sepolia",11155111,{ensNetwork:11155111}),n("holesky",17e3,{ensNetwork:17e3}),n("classic",61,{}),n("classicKotti",6,{}),n("arbitrum",42161,{ensNetwork:1}),n("arbitrum-goerli",421613,{}),n("arbitrum-sepolia",421614,{}),n("base",8453,{ensNetwork:1}),n("base-goerli",84531,{}),n("base-sepolia",84532,{}),n("bnb",56,{ensNetwork:1}),n("bnbt",97,{}),n("linea",59144,{ensNetwork:1}),n("linea-goerli",59140,{}),n("linea-sepolia",59141,{}),n("matic",137,{ensNetwork:1,plugins:[OM("https://gasstation.polygon.technology/v2")]}),n("matic-amoy",80002,{}),n("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[OM("https://gasstation-testnet.polygon.technology/v2")]}),n("optimism",10,{ensNetwork:1,plugins:[]}),n("optimism-goerli",420,{}),n("optimism-sepolia",11155420,{}),n("xdai",100,{ensNetwork:1})}function Nv(n){return JSON.parse(JSON.stringify(n))}class xW{constructor(e){W(this,cu);W(this,Ai,void 0);W(this,Tr,void 0);W(this,ko,void 0);W(this,Is,void 0);D(this,Ai,e),D(this,Tr,null),D(this,ko,4e3),D(this,Is,-2)}get pollingInterval(){return k(this,ko)}set pollingInterval(e){D(this,ko,e)}start(){k(this,Tr)||(D(this,Tr,k(this,Ai)._setTimeout(ie(this,cu,Dg).bind(this),k(this,ko))),ie(this,cu,Dg).call(this))}stop(){k(this,Tr)&&(k(this,Ai)._clearTimeout(k(this,Tr)),D(this,Tr,null))}pause(e){this.stop(),e&&D(this,Is,-2)}resume(){this.start()}}Ai=new WeakMap,Tr=new WeakMap,ko=new WeakMap,Is=new WeakMap,cu=new WeakSet,Dg=async function(){try{const e=await k(this,Ai).getBlockNumber();if(k(this,Is)===-2){D(this,Is,e);return}if(e!==k(this,Is)){for(let t=k(this,Is)+1;t<=e;t++){if(k(this,Tr)==null)return;await k(this,Ai).emit("block",t)}D(this,Is,e)}}catch{}k(this,Tr)!=null&&D(this,Tr,k(this,Ai)._setTimeout(ie(this,cu,Dg).bind(this),k(this,ko)))};class Mv{constructor(e){W(this,Ka,void 0);W(this,Ja,void 0);W(this,Co,void 0);D(this,Ka,e),D(this,Co,!1),D(this,Ja,t=>{this._poll(t,k(this,Ka))})}async _poll(e,t){throw new Error("sub-classes must override this")}start(){k(this,Co)||(D(this,Co,!0),k(this,Ja).call(this,-2),k(this,Ka).on("block",k(this,Ja)))}stop(){k(this,Co)&&(D(this,Co,!1),k(this,Ka).off("block",k(this,Ja)))}pause(e){this.stop()}resume(){this.start()}}Ka=new WeakMap,Ja=new WeakMap,Co=new WeakMap;class EW extends Mv{constructor(t,r){super(t);W(this,uu,void 0);W(this,xi,void 0);D(this,uu,r),D(this,xi,-2)}pause(t){t&&D(this,xi,-2),super.pause(t)}async _poll(t,r){const s=await r.getBlock(k(this,uu));s!=null&&(k(this,xi)===-2?D(this,xi,s.number):s.number>k(this,xi)&&(r.emit(k(this,uu),s.number),D(this,xi,s.number)))}}uu=new WeakMap,xi=new WeakMap;class kW extends Mv{constructor(t,r){super(t);W(this,Eg,void 0);D(this,Eg,Nv(r))}async _poll(t,r){throw new Error("@TODO")}}Eg=new WeakMap;class CW extends Mv{constructor(t,r){super(t);W(this,fu,void 0);D(this,fu,r)}async _poll(t,r){const s=await r.getTransactionReceipt(k(this,fu));s&&r.emit(k(this,fu),s)}}fu=new WeakMap;class Rv{constructor(e,t){W(this,kg);W(this,Ei,void 0);W(this,du,void 0);W(this,hu,void 0);W(this,So,void 0);W(this,Or,void 0);D(this,Ei,e),D(this,du,Nv(t)),D(this,hu,ie(this,kg,qM).bind(this)),D(this,So,!1),D(this,Or,-2)}start(){k(this,So)||(D(this,So,!0),k(this,Or)===-2&&k(this,Ei).getBlockNumber().then(e=>{D(this,Or,e)}),k(this,Ei).on("block",k(this,hu)))}stop(){k(this,So)&&(D(this,So,!1),k(this,Ei).off("block",k(this,hu)))}pause(e){this.stop(),e&&D(this,Or,-2)}resume(){this.start()}}Ei=new WeakMap,du=new WeakMap,hu=new WeakMap,So=new WeakMap,Or=new WeakMap,kg=new WeakSet,qM=async function(e){if(k(this,Or)===-2)return;const t=Nv(k(this,du));t.fromBlock=k(this,Or)+1,t.toBlock=e;const r=await k(this,Ei).getLogs(t);if(r.length===0){k(this,Or)<e-60&&D(this,Or,e-60);return}for(const s of r)k(this,Ei).emit(k(this,du),s),D(this,Or,s.blockNumber)};const SW=BigInt(2),TW=10;function rg(n){return n&&typeof n.then=="function"}function sg(n,e){return n+":"+JSON.stringify(e,(t,r)=>{if(r==null)return"null";if(typeof r=="bigint")return`bigint:${r.toString()}`;if(typeof r=="string")return r.toLowerCase();if(typeof r=="object"&&!Array.isArray(r)){const s=Object.keys(r);return s.sort(),s.reduce((i,o)=>(i[o]=r[o],i),{})}return r})}class ig{constructor(e){j(this,"name");be(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function OW(n){return JSON.parse(JSON.stringify(n))}function Pv(n){return n=Array.from(new Set(n).values()),n.sort(),n}async function Dv(n,e){if(n==null)throw new Error("invalid event");if(Array.isArray(n)&&(n={topics:n}),typeof n=="string")switch(n){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:n,tag:n}}if(pt(n,32)){const t=n.toLowerCase();return{type:"transaction",tag:sg("tx",{hash:t}),hash:t}}if(n.orphan){const t=n;return{type:"orphan",tag:sg("orphan",t),filter:OW(t)}}if(n.address||n.topics){const t=n,r={topics:(t.topics||[]).map(s=>s==null?null:Array.isArray(s)?Pv(s.map(i=>i.toLowerCase())):s.toLowerCase())};if(t.address){const s=[],i=[],o=a=>{pt(a)?s.push(a):i.push((async()=>{s.push(await Nn(a,e))})())};Array.isArray(t.address)?t.address.forEach(o):o(t.address),i.length&&await Promise.all(i),r.address=Pv(s.map(a=>a.toLowerCase()))}return{filter:r,tag:sg("event",r),type:"event"}}H(!1,"unknown ProviderEvent","event",n)}function Iv(){return new Date().getTime()}const NW={cacheTimeout:250,pollingInterval:4e3};class og{constructor(e,t){W(this,Rn);W(this,Md);W(this,Rd);W(this,Qa);W(this,Pd);W(this,Ya);W(this,yu);W(this,yn,void 0);W(this,To,void 0);W(this,bn,void 0);W(this,pu,void 0);W(this,lr,void 0);W(this,qa,void 0);W(this,Oo,void 0);W(this,ki,void 0);W(this,Nd,void 0);W(this,Nr,void 0);W(this,mu,void 0);W(this,gu,void 0);if(D(this,gu,Object.assign({},NW,t||{})),e==="any")D(this,qa,!0),D(this,lr,null);else if(e){const r=$t.from(e);D(this,qa,!1),D(this,lr,Promise.resolve(r)),setTimeout(()=>{this.emit("network",r,null)},0)}else D(this,qa,!1),D(this,lr,null);D(this,ki,-1),D(this,Oo,new Map),D(this,yn,new Map),D(this,To,new Map),D(this,bn,null),D(this,pu,!1),D(this,Nd,1),D(this,Nr,new Map),D(this,mu,!1)}get pollingInterval(){return k(this,gu).pollingInterval}get provider(){return this}get plugins(){return Array.from(k(this,To).values())}attachPlugin(e){if(k(this,To).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return k(this,To).set(e.name,e.connect(this)),this}getPlugin(e){return k(this,To).get(e)||null}get disableCcipRead(){return k(this,mu)}set disableCcipRead(e){D(this,mu,!!e)}async ccipReadFetch(e,t,r){if(this.disableCcipRead||r.length===0||e.to==null)return null;const s=e.to.toLowerCase(),i=t.toLowerCase(),o=[];for(let a=0;a<r.length;a++){const l=r[a],c=l.replace("{sender}",s).replace("{data}",i),u=new Tn(c);l.indexOf("{data}")===-1&&(u.body={data:i,sender:s}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:u,index:a,urls:r});let f="unknown error";const d=await u.send();try{const h=d.bodyJson;if(h.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:u,result:h}),h.data;h.message&&(f=h.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:u,result:h})}catch{}X(d.statusCode<400||d.statusCode>=500,`response not found during CCIP fetch: ${f}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:l,errorMessage:f}}),o.push(f)}X(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:r,errorMessages:o}})}_wrapBlock(e,t){return new q7(pW(e),this)}_wrapLog(e,t){return new cd(dW(e),this)}_wrapTransactionReceipt(e,t){return new uM(bW(e),this)}_wrapTransactionResponse(e,t){return new ud(SM(e),this)}_detectNetwork(){X(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){X(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=Pe(await ie(this,Rn,ur).call(this,{method:"getBlockNumber"}),"%response");return k(this,ki)>=0&&D(this,ki,e),e}_getAddress(e){return Nn(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(pt(e))return pt(e,32)?e:ba(e);if(typeof e=="bigint"&&(e=Pe(e,"blockTag")),typeof e=="number")return e>=0?ba(e):k(this,ki)>=0?ba(k(this,ki)+e):this.getBlockNumber().then(t=>ba(t+e));H(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(l=>l==null?null:Array.isArray(l)?Pv(l.map(c=>c.toLowerCase())):l.toLowerCase()),r="blockHash"in e?e.blockHash:void 0,s=(l,c,u)=>{let f;switch(l.length){case 0:break;case 1:f=l[0];break;default:l.sort(),f=l}if(r&&(c!=null||u!=null))throw new Error("invalid filter");const d={};return f&&(d.address=f),t.length&&(d.topics=t),c&&(d.fromBlock=c),u&&(d.toBlock=u),r&&(d.blockHash=r),d};let i=[];if(e.address)if(Array.isArray(e.address))for(const l of e.address)i.push(this._getAddress(l));else i.push(this._getAddress(e.address));let o;"fromBlock"in e&&(o=this._getBlockTag(e.fromBlock));let a;return"toBlock"in e&&(a=this._getBlockTag(e.toBlock)),i.filter(l=>typeof l!="string").length||o!=null&&typeof o!="string"||a!=null&&typeof a!="string"?Promise.all([Promise.all(i),o,a]).then(l=>s(l[0],l[1],l[2])):s(i,o,a)}_getTransactionRequest(e){const t=qm(e),r=[];if(["to","from"].forEach(s=>{if(t[s]==null)return;const i=Nn(t[s],this);rg(i)?r.push(async function(){t[s]=await i}()):t[s]=i}),t.blockTag!=null){const s=this._getBlockTag(t.blockTag);rg(s)?r.push(async function(){t.blockTag=await s}()):t.blockTag=s}return r.length?async function(){return await Promise.all(r),t}():t}async getNetwork(){if(k(this,lr)==null){const s=(async()=>{try{const i=await this._detectNetwork();return this.emit("network",i,null),i}catch(i){throw k(this,lr)===s&&D(this,lr,null),i}})();return D(this,lr,s),(await s).clone()}const e=k(this,lr),[t,r]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==r.chainId&&(k(this,qa)?(this.emit("network",r,t),k(this,lr)===e&&D(this,lr,Promise.resolve(r))):X(!1,`network changed: ${t.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:s,gasPrice:i,priorityFee:o}=await pn({_block:ie(this,Pd,o1).call(this,"latest",!1),gasPrice:(async()=>{try{const u=await ie(this,Rn,ur).call(this,{method:"getGasPrice"});return pe(u,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const u=await ie(this,Rn,ur).call(this,{method:"getPriorityFee"});return pe(u,"%response")}catch{}return null})()});let a=null,l=null;const c=this._wrapBlock(s,e);return c&&c.baseFeePerGas&&(l=o??BigInt("1000000000"),a=c.baseFeePerGas*SW+l),new cM(i,a,l)},r=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const s=new Tn(r.url),i=await r.processFunc(t,this,s);return new cM(i.gasPrice,i.maxFeePerGas,i.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return rg(t)&&(t=await t),pe(await ie(this,Rn,ur).call(this,{method:"estimateGas",transaction:t}),"%response")}async call(e){const{tx:t,blockTag:r}=await pn({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await ie(this,Rd,i1).call(this,ie(this,Md,s1).call(this,t,r,e.enableCcipRead?0:-1))}async getBalance(e,t){return pe(await ie(this,Qa,$d).call(this,{method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return Pe(await ie(this,Qa,$d).call(this,{method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return ce(await ie(this,Qa,$d).call(this,{method:"getCode"},e,t))}async getStorage(e,t,r){const s=pe(t,"position");return ce(await ie(this,Qa,$d).call(this,{method:"getStorage",position:s},e,r))}async broadcastTransaction(e){const{blockNumber:t,hash:r,network:s}=await pn({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),i=ad.from(e);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,s).replaceableTransaction(t)}async getBlock(e,t){const{network:r,params:s}=await pn({network:this.getNetwork(),params:ie(this,Pd,o1).call(this,e,!!t)});return s==null?null:this._wrapBlock(s,r)}async getTransaction(e){const{network:t,params:r}=await pn({network:this.getNetwork(),params:ie(this,Rn,ur).call(this,{method:"getTransaction",hash:e})});return r==null?null:this._wrapTransactionResponse(r,t)}async getTransactionReceipt(e){const{network:t,params:r}=await pn({network:this.getNetwork(),params:ie(this,Rn,ur).call(this,{method:"getTransactionReceipt",hash:e})});if(r==null)return null;if(r.gasPrice==null&&r.effectiveGasPrice==null){const s=await ie(this,Rn,ur).call(this,{method:"getTransaction",hash:e});if(s==null)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=s.gasPrice}return this._wrapTransactionReceipt(r,t)}async getTransactionResult(e){const{result:t}=await pn({network:this.getNetwork(),result:ie(this,Rn,ur).call(this,{method:"getTransactionResult",hash:e})});return t==null?null:ce(t)}async getLogs(e){let t=this._getFilter(e);rg(t)&&(t=await t);const{network:r,params:s}=await pn({network:this.getNetwork(),params:ie(this,Rn,ur).call(this,{method:"getLogs",filter:t})});return s.map(i=>this._wrapLog(i,r))}_getProvider(e){X(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await Zm.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=st(e);const t=fv(e.substring(2).toLowerCase()+".addr.reverse");try{const r=await Zm.getEnsAddress(this),i=await new Cc(r,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(i==null||i===Xf)return null;const a=await new Cc(i,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(a)!==e?null:a}catch(r){if(Zt(r,"BAD_DATA")&&r.value==="0x"||Zt(r,"CALL_EXCEPTION"))return null;throw r}return null}async waitForTransaction(e,t,r){const s=t??1;return s===0?this.getTransactionReceipt(e):new Promise(async(i,o)=>{let a=null;const l=async c=>{try{const u=await this.getTransactionReceipt(e);if(u!=null&&c-u.blockNumber+1>=s){i(u),a&&(clearTimeout(a),a=null);return}}catch(u){console.log("EEE",u)}this.once("block",l)};r!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",l),o(wt("timeout","TIMEOUT",{reason:"timeout"})))},r)),l(await this.getBlockNumber())})}async waitForBlock(e){X(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=k(this,Nr).get(e);t&&(t.timer&&clearTimeout(t.timer),k(this,Nr).delete(e))}_setTimeout(e,t){t==null&&(t=0);const r=Hd(this,Nd)._++,s=()=>{k(this,Nr).delete(r),e()};if(this.paused)k(this,Nr).set(r,{timer:null,func:s,time:t});else{const i=setTimeout(s,t);k(this,Nr).set(r,{timer:i,func:s,time:Iv()})}return r}_forEachSubscriber(e){for(const t of k(this,yn).values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new ig(e.type);case"block":{const t=new xW(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new EW(this,e.type);case"event":return new Rv(this,e.filter);case"transaction":return new CW(this,e.hash);case"orphan":return new kW(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const r of k(this,yn).values())if(r.subscriber===e){r.started&&r.subscriber.stop(),r.subscriber=t,r.started&&t.start(),k(this,bn)!=null&&t.pause(k(this,bn));break}}async on(e,t){const r=await ie(this,yu,Ig).call(this,e);return r.listeners.push({listener:t,once:!1}),r.started||(r.subscriber.start(),r.started=!0,k(this,bn)!=null&&r.subscriber.pause(k(this,bn))),this}async once(e,t){const r=await ie(this,yu,Ig).call(this,e);return r.listeners.push({listener:t,once:!0}),r.started||(r.subscriber.start(),r.started=!0,k(this,bn)!=null&&r.subscriber.pause(k(this,bn))),this}async emit(e,...t){const r=await ie(this,Ya,zd).call(this,e,t);if(!r||r.listeners.length===0)return!1;const s=r.listeners.length;return r.listeners=r.listeners.filter(({listener:i,once:o})=>{const a=new G2(this,o?null:i,e);try{i.call(this,...t,a)}catch{}return!o}),r.listeners.length===0&&(r.started&&r.subscriber.stop(),k(this,yn).delete(r.tag)),s>0}async listenerCount(e){if(e){const r=await ie(this,Ya,zd).call(this,e);return r?r.listeners.length:0}let t=0;for(const{listeners:r}of k(this,yn).values())t+=r.length;return t}async listeners(e){if(e){const r=await ie(this,Ya,zd).call(this,e);return r?r.listeners.map(({listener:s})=>s):[]}let t=[];for(const{listeners:r}of k(this,yn).values())t=t.concat(r.map(({listener:s})=>s));return t}async off(e,t){const r=await ie(this,Ya,zd).call(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(!t||r.listeners.length===0)&&(r.started&&r.subscriber.stop(),k(this,yn).delete(r.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:r,subscriber:s}=await ie(this,yu,Ig).call(this,e);r&&s.stop(),k(this,yn).delete(t)}else for(const[t,{started:r,subscriber:s}]of k(this,yn))r&&s.stop(),k(this,yn).delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return k(this,pu)}destroy(){this.removeAllListeners();for(const e of k(this,Nr).keys())this._clearTimeout(e);D(this,pu,!0)}get paused(){return k(this,bn)!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(D(this,ki,-1),k(this,bn)!=null){if(k(this,bn)==!!e)return;X(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),D(this,bn,!!e);for(const t of k(this,Nr).values())t.timer&&clearTimeout(t.timer),t.time=Iv()-t.time}resume(){if(k(this,bn)!=null){this._forEachSubscriber(e=>e.resume()),D(this,bn,null);for(const e of k(this,Nr).values()){let t=e.time;t<0&&(t=0),e.time=Iv(),setTimeout(e.func,t)}}}}yn=new WeakMap,To=new WeakMap,bn=new WeakMap,pu=new WeakMap,lr=new WeakMap,qa=new WeakMap,Oo=new WeakMap,ki=new WeakMap,Nd=new WeakMap,Nr=new WeakMap,mu=new WeakMap,gu=new WeakMap,Rn=new WeakSet,ur=async function(e){const t=k(this,gu).cacheTimeout;if(t<0)return await this._perform(e);const r=sg(e.method,e);let s=k(this,Oo).get(r);return s||(s=this._perform(e),k(this,Oo).set(r,s),setTimeout(()=>{k(this,Oo).get(r)===s&&k(this,Oo).delete(r)},t)),await s},Md=new WeakSet,s1=async function(e,t,r){X(r<TW,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const s=qm(e);try{return ce(await this._perform({method:"call",transaction:s,blockTag:t}))}catch(i){if(!this.disableCcipRead&&Nw(i)&&i.data&&r>=0&&t==="latest"&&s.to!=null&&Nt(i.data,0,4)==="0x556f1830"){const o=i.data,a=await Nn(s.to,this);let l;try{l=IW(Nt(i.data,4))}catch(f){X(!1,f.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:s,info:{data:o}})}X(l.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:s,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:l.errorArgs}});const c=await this.ccipReadFetch(s,l.calldata,l.urls);X(c!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:s,info:{data:i.data,errorArgs:l.errorArgs}});const u={to:a,data:Rt([l.selector,DW([c,l.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:u});try{const f=await ie(this,Md,s1).call(this,u,t,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},u),result:f}),f}catch(f){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},u),error:f}),f}}throw i}},Rd=new WeakSet,i1=async function(e){const{value:t}=await pn({network:this.getNetwork(),value:e});return t},Qa=new WeakSet,$d=async function(e,t,r){let s=this._getAddress(t),i=this._getBlockTag(r);return(typeof s!="string"||typeof i!="string")&&([s,i]=await Promise.all([s,i])),await ie(this,Rd,i1).call(this,ie(this,Rn,ur).call(this,Object.assign(e,{address:s,blockTag:i})))},Pd=new WeakSet,o1=async function(e,t){if(pt(e,32))return await ie(this,Rn,ur).call(this,{method:"getBlock",blockHash:e,includeTransactions:t});let r=this._getBlockTag(e);return typeof r!="string"&&(r=await r),await ie(this,Rn,ur).call(this,{method:"getBlock",blockTag:r,includeTransactions:t})},Ya=new WeakSet,zd=async function(e,t){let r=await Dv(e,this);return r.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(r=await Dv({orphan:"drop-log",log:t[0]},this)),k(this,yn).get(r.tag)||null},yu=new WeakSet,Ig=async function(e){const t=await Dv(e,this),r=t.tag;let s=k(this,yn).get(r);return s||(s={subscriber:this._getSubscriber(t),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},k(this,yn).set(r,s)),s};function MW(n,e){try{const t=_v(n,e);if(t)return fc(t)}catch{}return null}function _v(n,e){if(n==="0x")return null;try{const t=Pe(Nt(n,e,e+32)),r=Pe(Nt(n,t,t+32));return Nt(n,t+32,t+32+r)}catch{}return null}function MM(n){const e=Sn(n);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function RW(n){if(n.length%32===0)return n;const e=new Uint8Array(Math.ceil(n.length/32)*32);return e.set(n),e}const PW=new Uint8Array([]);function DW(n){const e=[];let t=0;for(let r=0;r<n.length;r++)e.push(PW),t+=32;for(let r=0;r<n.length;r++){const s=qe(n[r]);e[r]=MM(t),e.push(MM(s.length)),e.push(RW(s)),t+=32+Math.ceil(s.length/32)*32}return Rt(e)}const RM="0x0000000000000000000000000000000000000000000000000000000000000000";function IW(n){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};X(cc(n)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=Nt(n,0,32);X(Nt(t,0,12)===Nt(RM,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=Nt(t,12);try{const r=[],s=Pe(Nt(n,32,64)),i=Pe(Nt(n,s,s+32)),o=Nt(n,s+32);for(let a=0;a<i;a++){const l=MW(o,a*32);if(l==null)throw new Error("abort");r.push(l)}e.urls=r}catch{X(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=_v(n,64);if(r==null)throw new Error("abort");e.calldata=r}catch{X(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}X(Nt(n,100,128)===Nt(RM,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=Nt(n,96,100);try{const r=_v(n,128);if(r==null)throw new Error("abort");e.extraData=r}catch{X(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(r=>e[r]),e}function Tc(n,e){if(n.provider)return n.provider;X(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function PM(n,e){let t=qm(e);if(t.to!=null&&(t.to=Nn(t.to,n)),t.from!=null){const r=t.from;t.from=Promise.all([n.getAddress(),Nn(r,n)]).then(([s,i])=>(H(s.toLowerCase()===i.toLowerCase(),"transaction from mismatch","tx.from",i),s))}else t.from=n.getAddress();return await pn(t)}class _W{constructor(e){j(this,"provider");be(this,{provider:e||null})}async getNonce(e){return Tc(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await PM(this,e)}async populateTransaction(e){const t=Tc(this,"populateTransaction"),r=await PM(this,e);r.nonce==null&&(r.nonce=await this.getNonce("pending")),r.gasLimit==null&&(r.gasLimit=await this.estimateGas(r));const s=await this.provider.getNetwork();if(r.chainId!=null){const o=pe(r.chainId);H(o===s.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else r.chainId=s.chainId;const i=r.maxFeePerGas!=null||r.maxPriorityFeePerGas!=null;if(r.gasPrice!=null&&(r.type===2||i)?H(!1,"eip-1559 transaction do not support gasPrice","tx",e):(r.type===0||r.type===1)&&i&&H(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(r.type===2||r.type==null)&&r.maxFeePerGas!=null&&r.maxPriorityFeePerGas!=null)r.type=2;else if(r.type===0||r.type===1){const o=await t.getFeeData();X(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice)}else{const o=await t.getFeeData();if(r.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(r.type=2,r.gasPrice!=null){const a=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=a,r.maxPriorityFeePerGas=a}else r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(X(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice),r.type=0):X(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(r.type===2||r.type===3)&&(r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await pn(r)}async estimateGas(e){return Tc(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return Tc(this,"call").call(await this.populateCall(e))}async resolveName(e){return await Tc(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=Tc(this,"sendTransaction"),r=await this.populateTransaction(e);delete r.from;const s=ad.from(r);return await t.broadcastTransaction(await this.signTransaction(s))}}const DM=new Set;function Oc(n){DM.has(n)||(DM.add(n),console.log("========= NOTICE ========="),console.log(`Request-Rate Exceeded for ${n} (this message will not be repeated)`),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.org/api-keys/"),console.log("=========================="))}function LW(n){return JSON.parse(JSON.stringify(n))}class IM{constructor(e){W(this,Dd);W(this,Id);W(this,Pn,void 0);W(this,_s,void 0);W(this,Xa,void 0);W(this,No,void 0);W(this,Za,void 0);W(this,bu,void 0);D(this,Pn,e),D(this,_s,null),D(this,Xa,ie(this,Dd,a1).bind(this)),D(this,No,!1),D(this,Za,null),D(this,bu,!1)}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}start(){k(this,No)||(D(this,No,!0),ie(this,Dd,a1).call(this,-2))}stop(){k(this,No)&&(D(this,No,!1),D(this,bu,!0),ie(this,Id,l1).call(this),k(this,Pn).off("block",k(this,Xa)))}pause(e){e&&ie(this,Id,l1).call(this),k(this,Pn).off("block",k(this,Xa))}resume(){this.start()}}Pn=new WeakMap,_s=new WeakMap,Xa=new WeakMap,No=new WeakMap,Za=new WeakMap,bu=new WeakMap,Dd=new WeakSet,a1=async function(e){try{k(this,_s)==null&&D(this,_s,this._subscribe(k(this,Pn)));let t=null;try{t=await k(this,_s)}catch(i){if(!Zt(i,"UNSUPPORTED_OPERATION")||i.operation!=="eth_newFilter")throw i}if(t==null){D(this,_s,null),k(this,Pn)._recoverSubscriber(this,this._recover(k(this,Pn)));return}const r=await k(this,Pn).getNetwork();if(k(this,Za)||D(this,Za,r),k(this,Za).chainId!==r.chainId)throw new Error("chaid changed");if(k(this,bu))return;const s=await k(this,Pn).send("eth_getFilterChanges",[t]);await this._emitResults(k(this,Pn),s)}catch(t){console.log("@TODO",t)}k(this,Pn).once("block",k(this,Xa))},Id=new WeakSet,l1=function(){const e=k(this,_s);e&&(D(this,_s,null),e.then(t=>{k(this,Pn).destroyed||k(this,Pn).send("eth_uninstallFilter",[t])}))};class BW extends IM{constructor(t,r){super(t);W(this,el,void 0);D(this,el,LW(r))}_recover(t){return new Rv(t,k(this,el))}async _subscribe(t){return await t.send("eth_newFilter",[k(this,el)])}async _emitResults(t,r){for(const s of r)t.emit(k(this,el),t._wrapLog(s,t._network))}}el=new WeakMap;class FW extends IM{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const r of t)e.emit("pending",r)}}const UW="bigint,boolean,function,number,string,symbol".split(/,/g);function ag(n){if(n==null||UW.indexOf(typeof n)>=0||typeof n.getAddress=="function")return n;if(Array.isArray(n))return n.map(ag);if(typeof n=="object")return Object.keys(n).reduce((e,t)=>(e[t]=n[t],e),{});throw new Error(`should not happen: ${n} (${typeof n})`)}function HW(n){return new Promise(e=>{setTimeout(e,n)})}function Nc(n){return n&&n.toLowerCase()}function _M(n){return n&&typeof n.pollingInterval=="number"}const LM={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class Lv extends _W{constructor(t,r){super(t);j(this,"address");r=st(r),be(this,{address:r})}connect(t){X(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const r=ag(t),s=[];if(r.from){const o=r.from;s.push((async()=>{const a=await Nn(o,this.provider);H(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),r.from=a})())}else r.from=this.address;if(r.gasLimit==null&&s.push((async()=>{r.gasLimit=await this.provider.estimateGas({...r,from:this.address})})()),r.to!=null){const o=r.to;s.push((async()=>{r.to=await Nn(o,this.provider)})())}s.length&&await Promise.all(s);const i=this.provider.getRpcTransaction(r);return this.provider.send("eth_sendTransaction",[i])}async sendTransaction(t){const r=await this.provider.getBlockNumber(),s=await this.sendUncheckedTransaction(t);return await new Promise((i,o)=>{const a=[1e3,100];let l=0;const c=async()=>{try{const u=await this.provider.getTransaction(s);if(u!=null){i(u.replaceableTransaction(r));return}}catch(u){if(Zt(u,"CANCELLED")||Zt(u,"BAD_DATA")||Zt(u,"NETWORK_ERROR")){u.info==null&&(u.info={}),u.info.sendTransactionHash=s,o(u);return}if(Zt(u,"INVALID_ARGUMENT")&&(l++,u.info==null&&(u.info={}),u.info.sendTransactionHash=s,l>10)){o(u);return}this.provider.emit("error",wt("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:u}))}this.provider._setTimeout(()=>{c()},a.pop()||4e3)};c()})}async signTransaction(t){const r=ag(t);if(r.from){const i=await Nn(r.from,this.provider);H(i!=null&&i.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),r.from=i}else r.from=this.address;const s=this.provider.getRpcTransaction(r);return await this.provider.send("eth_signTransaction",[s])}async signMessage(t){const r=typeof t=="string"?ri(t):t;return await this.provider.send("personal_sign",[ce(r),this.address.toLowerCase()])}async signTypedData(t,r,s){const i=ag(s),o=await Gm.resolveNames(t,r,i,async a=>{const l=await Nn(a);return H(l!=null,"TypedData does not support null address","value",a),l});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(Gm.getPayload(o.domain,r,o.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const r=typeof t=="string"?ri(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),ce(r)])}}class BM extends og{constructor(t,r){super(t,r);W(this,_d);W(this,tl,void 0);W(this,wu,void 0);W(this,Ci,void 0);W(this,Ls,void 0);W(this,Xr,void 0);W(this,Mr,void 0);W(this,Kn,void 0);D(this,wu,1),D(this,tl,Object.assign({},LM,r||{})),D(this,Ci,[]),D(this,Ls,null),D(this,Mr,null),D(this,Kn,null);{let i=null;const o=new Promise(a=>{i=a});D(this,Xr,{promise:o,resolve:i})}const s=this._getOption("staticNetwork");typeof s=="boolean"?(H(!s||t!=="any","staticNetwork cannot be used on special network 'any'","options",r),s&&t!=null&&D(this,Mr,$t.from(t))):s&&(H(t==null||s.matches(t),"staticNetwork MUST match network object","options",r),D(this,Mr,s))}_getOption(t){return k(this,tl)[t]}get _network(){return X(k(this,Mr),"network is not available yet","NETWORK_ERROR"),k(this,Mr)}async _perform(t){if(t.method==="call"||t.method==="estimateGas"){let s=t.transaction;if(s&&s.type!=null&&pe(s.type)&&s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null){const i=await this.getFeeData();i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null&&(t=Object.assign({},t,{transaction:Object.assign({},s,{type:void 0})}))}}const r=this.getRpcRequest(t);return r!=null?await this.send(r.method,r.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t)if(t===!0){if(k(this,Mr))return k(this,Mr)}else return t;return k(this,Kn)?await k(this,Kn):this.ready?(D(this,Kn,(async()=>{try{const r=$t.from(pe(await this.send("eth_chainId",[])));return D(this,Kn,null),r}catch(r){throw D(this,Kn,null),r}})()),await k(this,Kn)):(D(this,Kn,(async()=>{const r={id:Hd(this,wu)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:r});let s;try{s=(await this._send(r))[0],D(this,Kn,null)}catch(i){throw D(this,Kn,null),this.emit("debug",{action:"receiveRpcError",error:i}),i}if(this.emit("debug",{action:"receiveRpcResult",result:s}),"result"in s)return $t.from(pe(s.result));throw this.getRpcError(r,s)})()),await k(this,Kn))}_start(){k(this,Xr)==null||k(this,Xr).resolve==null||(k(this,Xr).resolve(),D(this,Xr,null),(async()=>{for(;k(this,Mr)==null&&!this.destroyed;)try{D(this,Mr,await this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",wt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await HW(1e3)}ie(this,_d,c1).call(this)})())}async _waitUntilReady(){if(k(this,Xr)!=null)return await k(this,Xr).promise}_getSubscriber(t){return t.type==="pending"?new FW(this):t.type==="event"?this._getOption("polling")?new Rv(this,t.filter):new BW(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new ig("orphan"):super._getSubscriber(t)}get ready(){return k(this,Xr)==null}getRpcTransaction(t){const r={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(s=>{if(t[s]==null)return;let i=s;s==="gasLimit"&&(i="gas"),r[i]=ba(pe(t[s],`tx.${s}`))}),["from","to","data"].forEach(s=>{t[s]!=null&&(r[s]=ce(t[s]))}),t.accessList&&(r.accessList=fo(t.accessList)),t.blobVersionedHashes&&(r.blobVersionedHashes=t.blobVersionedHashes.map(s=>s.toLowerCase())),r}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[Nc(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Nc(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[Nc(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Nc(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&t.filter.address!=null&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(Nc):t.filter.address=Nc(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,r){const{method:s}=t,{error:i}=r;if(s==="eth_estimateGas"&&i.message){const l=i.message;if(!l.match(/revert/i)&&l.match(/insufficient funds/i))return wt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:i}})}if(s==="eth_call"||s==="eth_estimateGas"){const l=Bv(i),c=Ec.getBuiltinCallException(s==="eth_call"?"call":"estimateGas",t.params[0],l?l.data:null);return c.info={error:i,payload:t},c}const o=JSON.stringify($W(i));if(typeof i.message=="string"&&i.message.match(/user denied|ethers-user-denied/i))return wt("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[s]||"unknown",reason:"rejected",info:{payload:t,error:i}});if(s==="eth_sendRawTransaction"||s==="eth_sendTransaction"){const l=t.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return wt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:l,info:{error:i}});if(o.match(/nonce/i)&&o.match(/too low/i))return wt("nonce has already been used","NONCE_EXPIRED",{transaction:l,info:{error:i}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return wt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:l,info:{error:i}});if(o.match(/only replay-protected/i))return wt("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:s,info:{transaction:l,info:{error:i}}})}let a=!!o.match(/the method .* does not exist/i);return a||i&&i.details&&i.details.startsWith("Unauthorized method:")&&(a=!0),a?wt("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:i,payload:t}}):wt("could not coalesce error","UNKNOWN_ERROR",{error:i,payload:t})}send(t,r){if(this.destroyed)return Promise.reject(wt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const s=Hd(this,wu)._++,i=new Promise((o,a)=>{k(this,Ci).push({resolve:o,reject:a,payload:{method:t,params:r,id:s,jsonrpc:"2.0"}})});return ie(this,_d,c1).call(this),i}async getSigner(t){t==null&&(t=0);const r=this.send("eth_accounts",[]);if(typeof t=="number"){const i=await r;if(t>=i.length)throw new Error("no such account");return new Lv(this,i[t])}const{accounts:s}=await pn({network:this.getNetwork(),accounts:r});t=st(t);for(const i of s)if(st(i)===t)return new Lv(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(r=>new Lv(this,r))}destroy(){k(this,Ls)&&(clearTimeout(k(this,Ls)),D(this,Ls,null));for(const{payload:t,reject:r}of k(this,Ci))r(wt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));D(this,Ci,[]),super.destroy()}}tl=new WeakMap,wu=new WeakMap,Ci=new WeakMap,Ls=new WeakMap,Xr=new WeakMap,Mr=new WeakMap,Kn=new WeakMap,_d=new WeakSet,c1=function(){if(k(this,Ls))return;const t=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");D(this,Ls,setTimeout(()=>{D(this,Ls,null);const r=k(this,Ci);for(D(this,Ci,[]);r.length;){const s=[r.shift()];for(;r.length&&s.length!==k(this,tl).batchMaxCount;)if(s.push(r.shift()),JSON.stringify(s.map(o=>o.payload)).length>k(this,tl).batchMaxSize){r.unshift(s.pop());break}(async()=>{const i=s.length===1?s[0].payload:s.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:i});try{const o=await this._send(i);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:a,reject:l,payload:c}of s){if(this.destroyed){l(wt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:c.method}));continue}const u=o.filter(f=>f.id===c.id)[0];if(u==null){const f=wt("missing response for request","BAD_DATA",{value:o,info:{payload:c}});this.emit("error",f),l(f);continue}if("error"in u){l(this.getRpcError(c,u));continue}a(u.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of s)a(o)}})()}},t))};class jW extends BM{constructor(t,r){super(t,r);W(this,Mo,void 0);let s=this._getOption("pollingInterval");s==null&&(s=LM.pollingInterval),D(this,Mo,s)}_getSubscriber(t){const r=super._getSubscriber(t);return _M(r)&&(r.pollingInterval=k(this,Mo)),r}get pollingInterval(){return k(this,Mo)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");D(this,Mo,t),this._forEachSubscriber(r=>{_M(r)&&(r.pollingInterval=k(this,Mo))})}}Mo=new WeakMap;class fi extends jW{constructor(t,r,s){t==null&&(t="http://localhost:8545");super(r,s);W(this,vu,void 0);typeof t=="string"?D(this,vu,new Tn(t)):D(this,vu,t.clone())}_getConnection(){return k(this,vu).clone()}async send(t,r){return await this._start(),await super.send(t,r)}async _send(t){const r=this._getConnection();r.body=JSON.stringify(t),r.setHeader("content-type","application/json");const s=await r.send();s.assertOk();let i=s.bodyJson;return Array.isArray(i)||(i=[i]),i}}vu=new WeakMap;function Bv(n){if(n==null)return null;if(typeof n.message=="string"&&n.message.match(/revert/i)&&pt(n.data))return{message:n.message,data:n.data};if(typeof n=="object"){for(const e in n){const t=Bv(n[e]);if(t)return t}return null}if(typeof n=="string")try{return Bv(JSON.parse(n))}catch{}return null}function Fv(n,e){if(n!=null){if(typeof n.message=="string"&&e.push(n.message),typeof n=="object")for(const t in n)Fv(n[t],e);if(typeof n=="string")try{return Fv(JSON.parse(n),e)}catch{}}}function $W(n){const e=[];return Fv(n,e),e}const lg="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function zW(n){switch(n){case"mainnet":return"rpc.ankr.com/eth";case"goerli":return"rpc.ankr.com/eth_goerli";case"sepolia":return"rpc.ankr.com/eth_sepolia";case"arbitrum":return"rpc.ankr.com/arbitrum";case"base":return"rpc.ankr.com/base";case"base-goerli":return"rpc.ankr.com/base_goerli";case"base-sepolia":return"rpc.ankr.com/base_sepolia";case"bnb":return"rpc.ankr.com/bsc";case"bnbt":return"rpc.ankr.com/bsc_testnet_chapel";case"matic":return"rpc.ankr.com/polygon";case"matic-mumbai":return"rpc.ankr.com/polygon_mumbai";case"optimism":return"rpc.ankr.com/optimism";case"optimism-goerli":return"rpc.ankr.com/optimism_testnet";case"optimism-sepolia":return"rpc.ankr.com/optimism_sepolia"}H(!1,"unsupported network","network",n)}class cg extends fi{constructor(t,r){t==null&&(t="mainnet");const s=$t.from(t);r==null&&(r=lg);const i={polling:!0,staticNetwork:s},o=cg.getRequest(s,r);super(o,s,i);j(this,"apiKey");be(this,{apiKey:r})}_getProvider(t){try{return new cg(t,this.apiKey)}catch{}return super._getProvider(t)}static getRequest(t,r){r==null&&(r=lg);const s=new Tn(`https://${zW(t.name)}/${r}`);return s.allowGzip=!0,r===lg&&(s.retryFunc=async(i,o,a)=>(Oc("AnkrProvider"),!0)),s}getRpcError(t,r){return t.method==="eth_sendRawTransaction"&&r&&r.error&&r.error.message==="INTERNAL_ERROR: could not replace existing tx"&&(r.error.message="replacement transaction underpriced"),super.getRpcError(t,r)}isCommunityResource(){return this.apiKey===lg}}const ug="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";function VW(n){switch(n){case"mainnet":return"eth-mainnet.alchemyapi.io";case"goerli":return"eth-goerli.g.alchemy.com";case"sepolia":return"eth-sepolia.g.alchemy.com";case"arbitrum":return"arb-mainnet.g.alchemy.com";case"arbitrum-goerli":return"arb-goerli.g.alchemy.com";case"arbitrum-sepolia":return"arb-sepolia.g.alchemy.com";case"base":return"base-mainnet.g.alchemy.com";case"base-goerli":return"base-goerli.g.alchemy.com";case"base-sepolia":return"base-sepolia.g.alchemy.com";case"matic":return"polygon-mainnet.g.alchemy.com";case"matic-amoy":return"polygon-amoy.g.alchemy.com";case"matic-mumbai":return"polygon-mumbai.g.alchemy.com";case"optimism":return"opt-mainnet.g.alchemy.com";case"optimism-goerli":return"opt-goerli.g.alchemy.com";case"optimism-sepolia":return"opt-sepolia.g.alchemy.com"}H(!1,"unsupported network","network",n)}class fg extends fi{constructor(t,r){t==null&&(t="mainnet");const s=$t.from(t);r==null&&(r=ug);const i=fg.getRequest(s,r);super(i,s,{staticNetwork:s});j(this,"apiKey");be(this,{apiKey:r})}_getProvider(t){try{return new fg(t,this.apiKey)}catch{}return super._getProvider(t)}async _perform(t){if(t.method==="getTransactionResult"){const{trace:r,tx:s}=await pn({trace:this.send("trace_transaction",[t.hash]),tx:this.getTransaction(t.hash)});if(r==null||s==null)return null;let i,o=!1;try{i=r[0].result.output,o=r[0].error==="Reverted"}catch{}if(i)return X(!o,"an error occurred during transaction executions","CALL_EXCEPTION",{action:"getTransactionResult",data:i,reason:null,transaction:s,invocation:null,revert:null}),i;X(!1,"could not parse trace result","BAD_DATA",{value:r})}return await super._perform(t)}isCommunityResource(){return this.apiKey===ug}static getRequest(t,r){r==null&&(r=ug);const s=new Tn(`https://${VW(t.name)}/v2/${r}`);return s.allowGzip=!0,r===ug&&(s.retryFunc=async(i,o,a)=>(Oc("alchemy"),!0)),s}}function dg(n){switch(n){case"mainnet":return"39f1d67cedf8b7831010a665328c9197";case"arbitrum":return"0550c209db33c3abf4cc927e1e18cea1";case"bnb":return"98b5a77e531614387366f6fc5da097f8";case"matic":return"cd9d4d70377471aa7c142ec4a4205249"}H(!1,"unsupported network","network",n)}function WW(n){switch(n){case"mainnet":return"ethereum-mainnet.core.chainstack.com";case"arbitrum":return"arbitrum-mainnet.core.chainstack.com";case"bnb":return"bsc-mainnet.core.chainstack.com";case"matic":return"polygon-mainnet.core.chainstack.com"}H(!1,"unsupported network","network",n)}class hg extends fi{constructor(t,r){t==null&&(t="mainnet");const s=$t.from(t);r==null&&(r=dg(s.name));const i=hg.getRequest(s,r);super(i,s,{staticNetwork:s});j(this,"apiKey");be(this,{apiKey:r})}_getProvider(t){try{return new hg(t,this.apiKey)}catch{}return super._getProvider(t)}isCommunityResource(){return this.apiKey===dg(this._network.name)}static getRequest(t,r){r==null&&(r=dg(t.name));const s=new Tn(`https://${WW(t.name)}/${r}`);return s.allowGzip=!0,r===dg(t.name)&&(s.retryFunc=async(i,o,a)=>(Oc("ChainstackProvider"),!0)),s}}class GW extends fi{constructor(e){e==null&&(e="mainnet");const t=$t.from(e);H(t.name==="mainnet","unsupported network","network",e),super("https://cloudflare-eth.com/",t,{staticNetwork:t})}}const FM=2e3;function KW(n){return n&&typeof n.then=="function"}const JW="org.ethers.plugins.provider.Etherscan",qW=["enableCcipRead"];let QW=1;class YW extends og{constructor(t,r){const s=r??null;super();j(this,"network");j(this,"apiKey");W(this,Au,void 0);const i=$t.from(t);D(this,Au,i.getPlugin(JW)),be(this,{apiKey:s,network:i}),this.getBaseUrl()}getBaseUrl(){if(k(this,Au))return k(this,Au).baseUrl;switch(this.network.name){case"mainnet":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"holesky":return"https://api-holesky.etherscan.io";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"base":return"https://api.basescan.org";case"base-sepolia":return"https://api-sepolia.basescan.org";case"bnb":return"https://api.bscscan.com";case"bnbt":return"https://api-testnet.bscscan.com";case"matic":return"https://api.polygonscan.com";case"matic-amoy":return"https://api-amoy.polygonscan.com";case"matic-mumbai":return"https://api-testnet.polygonscan.com";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io"}H(!1,"unsupported network","network",this.network)}getUrl(t,r){const s=Object.keys(r).reduce((o,a)=>{const l=r[a];return l!=null&&(o+=`&${a}=${l}`),o},""),i=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.getBaseUrl()}/api?module=${t}${s}${i}`}getPostUrl(){return`${this.getBaseUrl()}/api`}getPostData(t,r){return r.module=t,r.apikey=this.apiKey,r}async detectNetwork(){return this.network}async fetch(t,r,s){const i=QW++,o=s?this.getPostUrl():this.getUrl(t,r),a=s?this.getPostData(t,r):null;this.emit("debug",{action:"sendRequest",id:i,url:o,payload:a});const l=new Tn(o);l.setThrottleParams({slotInterval:1e3}),l.retryFunc=(f,d,h)=>(this.isCommunityResource()&&Oc("Etherscan"),Promise.resolve(!0)),l.processFunc=async(f,d)=>{const h=d.hasBody()?JSON.parse(fc(d.body)):{},p=(typeof h.result=="string"?h.result:"").toLowerCase().indexOf("rate limit")>=0;return t==="proxy"?h&&h.status==0&&h.message=="NOTOK"&&p&&(this.emit("debug",{action:"receiveError",id:i,reason:"proxy-NOTOK",error:h}),d.throwThrottleError(h.result,FM)):p&&(this.emit("debug",{action:"receiveError",id:i,reason:"null result",error:h.result}),d.throwThrottleError(h.result,FM)),d},a&&(l.setHeader("content-type","application/x-www-form-urlencoded; charset=UTF-8"),l.body=Object.keys(a).map(f=>`${f}=${a[f]}`).join("&"));const c=await l.send();try{c.assertOk()}catch(f){this.emit("debug",{action:"receiveError",id:i,error:f,reason:"assertOk"}),X(!1,"response error","SERVER_ERROR",{request:l,response:c})}c.hasBody()||(this.emit("debug",{action:"receiveError",id:i,error:"missing body",reason:"null body"}),X(!1,"missing response","SERVER_ERROR",{request:l,response:c}));const u=JSON.parse(fc(c.body));return t==="proxy"?(u.jsonrpc!="2.0"&&(this.emit("debug",{action:"receiveError",id:i,result:u,reason:"invalid JSON-RPC"}),X(!1,"invalid JSON-RPC response (missing jsonrpc='2.0')","SERVER_ERROR",{request:l,response:c,info:{result:u}})),u.error&&(this.emit("debug",{action:"receiveError",id:i,result:u,reason:"JSON-RPC error"}),X(!1,"error response","SERVER_ERROR",{request:l,response:c,info:{result:u}})),this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result):u.status==0&&(u.message==="No records found"||u.message==="No transactions found")?(this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result):((u.status!=1||typeof u.message=="string"&&!u.message.match(/^OK/))&&(this.emit("debug",{action:"receiveError",id:i,result:u}),X(!1,"error response","SERVER_ERROR",{request:l,response:c,info:{result:u}})),this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result)}_getTransactionPostData(t){const r={};for(let s in t){if(qW.indexOf(s)>=0||t[s]==null)continue;let i=t[s];if(!(s==="type"&&i===0)&&!(s==="blockTag"&&i==="latest")){if({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[s])i=ba(i);else if(s==="accessList")i="["+fo(i).map(o=>`{address:"${o.address}",storageKeys:["${o.storageKeys.join('","')}"]}`).join(",")+"]";else if(s==="blobVersionedHashes"){if(i.length===0)continue;X(!1,"Etherscan API does not support blobVersionedHashes","UNSUPPORTED_OPERATION",{operation:"_getTransactionPostData",info:{transaction:t}})}else i=ce(i);r[s]=i}}return r}_checkError(t,r,s){let i="";if(Zt(r,"SERVER_ERROR")){try{i=r.info.result.error.message}catch{}if(!i)try{i=r.info.message}catch{}}if(t.method==="estimateGas"&&!i.match(/revert/i)&&i.match(/insufficient funds/i)&&X(!1,"insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.transaction}),(t.method==="call"||t.method==="estimateGas")&&i.match(/execution reverted/i)){let o="";try{o=r.info.result.error.data}catch{}const a=Ec.getBuiltinCallException(t.method,t.transaction,o);throw a.info={request:t,error:r},a}if(i&&t.method==="broadcastTransaction"){const o=ad.from(t.signedTransaction);i.match(/replacement/i)&&i.match(/underpriced/i)&&X(!1,"replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:o}),i.match(/insufficient funds/)&&X(!1,"insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:o}),i.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&X(!1,"nonce has already been used","NONCE_EXPIRED",{transaction:o})}throw r}async _detectNetwork(){return this.network}async _perform(t){switch(t.method){case"chainId":return this.network.chainId;case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getPriorityFee":if(this.network.name==="mainnet")return"1000000000";if(this.network.name==="optimism")return"1000000";throw new Error("fallback onto the AbstractProvider default");case"getBalance":return this.fetch("account",{action:"balance",address:t.address,tag:t.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:t.address,tag:t.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:t.address,tag:t.blockTag});case"getStorage":return this.fetch("proxy",{action:"eth_getStorageAt",address:t.address,position:t.position,tag:t.blockTag});case"broadcastTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:t.signedTransaction},!0).catch(r=>this._checkError(t,r,t.signedTransaction));case"getBlock":if("blockTag"in t)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:t.blockTag,boolean:t.includeTransactions?"true":"false"});X(!1,"getBlock by blockHash not supported by Etherscan","UNSUPPORTED_OPERATION",{operation:"getBlock(blockHash)"});case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:t.hash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:t.hash});case"call":{if(t.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");const r=this._getTransactionPostData(t.transaction);r.module="proxy",r.action="eth_call";try{return await this.fetch("proxy",r,!0)}catch(s){return this._checkError(t,s,t.transaction)}}case"estimateGas":{const r=this._getTransactionPostData(t.transaction);r.module="proxy",r.action="eth_estimateGas";try{return await this.fetch("proxy",r,!0)}catch(s){return this._checkError(t,s,t.transaction)}}}return super._perform(t)}async getNetwork(){return this.network}async getEtherPrice(){return this.network.name!=="mainnet"?0:parseFloat((await this.fetch("stats",{action:"ethprice"})).ethusd)}async getContract(t){let r=this._getAddress(t);KW(r)&&(r=await r);try{const s=await this.fetch("contract",{action:"getabi",address:r}),i=JSON.parse(s);return new Cc(r,i,this)}catch{return null}}isCommunityResource(){return this.apiKey==null}}Au=new WeakMap;function XW(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const ZW=XW().WebSocket;class Uv{constructor(e,t){W(this,Bs,void 0);W(this,Ld,void 0);W(this,Ro,void 0);W(this,nl,void 0);W(this,Po,void 0);D(this,Bs,e),D(this,Ld,JSON.stringify(t)),D(this,Ro,null),D(this,nl,null),D(this,Po,null)}get filter(){return JSON.parse(k(this,Ld))}start(){D(this,Ro,k(this,Bs).send("eth_subscribe",this.filter).then(e=>(k(this,Bs)._register(e,this),e)))}stop(){k(this,Ro).then(e=>{k(this,Bs).destroyed||k(this,Bs).send("eth_unsubscribe",[e])}),D(this,Ro,null)}pause(e){X(e,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),D(this,nl,!!e)}resume(){D(this,nl,null)}_handleMessage(e){if(k(this,Ro)!=null&&k(this,nl)===null){let t=k(this,Po);t==null?t=this._emit(k(this,Bs),e):t=t.then(async()=>{await this._emit(k(this,Bs),e)}),D(this,Po,t.then(()=>{k(this,Po)===t&&D(this,Po,null)}))}}async _emit(e,t){throw new Error("sub-classes must implemente this; _emit")}}Bs=new WeakMap,Ld=new WeakMap,Ro=new WeakMap,nl=new WeakMap,Po=new WeakMap;class eG extends Uv{constructor(e){super(e,["newHeads"])}async _emit(e,t){e.emit("block",parseInt(t.number))}}class tG extends Uv{constructor(e){super(e,["newPendingTransactions"])}async _emit(e,t){e.emit("pending",t)}}class nG extends Uv{constructor(t,r){super(t,["logs",r]);W(this,Bd,void 0);D(this,Bd,JSON.stringify(r))}get logFilter(){return JSON.parse(k(this,Bd))}async _emit(t,r){t.emit(this.logFilter,t._wrapLog(r,t._network))}}Bd=new WeakMap;class rG extends BM{constructor(t,r){const s=Object.assign({},r??{});H(s.batchMaxCount==null||s.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",r),s.batchMaxCount=1,s.staticNetwork==null&&(s.staticNetwork=!0);super(t,s);W(this,rl,void 0);W(this,xu,void 0);W(this,Do,void 0);D(this,rl,new Map),D(this,xu,new Map),D(this,Do,new Map)}_getSubscriber(t){switch(t.type){case"close":return new ig("close");case"block":return new eG(this);case"pending":return new tG(this);case"event":return new nG(this,t.filter);case"orphan":if(t.filter.orphan==="drop-log")return new ig("drop-log")}return super._getSubscriber(t)}_register(t,r){k(this,xu).set(t,r);const s=k(this,Do).get(t);if(s){for(const i of s)r._handleMessage(i);k(this,Do).delete(t)}}async _send(t){H(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const r=new Promise((s,i)=>{k(this,rl).set(t.id,{payload:t,resolve:s,reject:i})});return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await r]}async _processMessage(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&"id"in r){const s=k(this,rl).get(r.id);if(s==null){this.emit("error",wt("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:r}));return}k(this,rl).delete(r.id),s.resolve(r)}else if(r&&r.method==="eth_subscription"){const s=r.params.subscription,i=k(this,xu).get(s);if(i)i._handleMessage(r.params.result);else{let o=k(this,Do).get(s);o==null&&(o=[],k(this,Do).set(s,o)),o.push(r.params.result)}}else{this.emit("error",wt("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:r}));return}}async _write(t){throw new Error("sub-classes must override this")}}rl=new WeakMap,xu=new WeakMap,Do=new WeakMap;class UM extends rG{constructor(t,r,s){super(r,s);W(this,sl,void 0);W(this,Zr,void 0);typeof t=="string"?(D(this,sl,()=>new ZW(t)),D(this,Zr,k(this,sl).call(this))):typeof t=="function"?(D(this,sl,t),D(this,Zr,t())):(D(this,sl,null),D(this,Zr,t)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(i){console.log("failed to start WebsocketProvider",i)}},this.websocket.onmessage=i=>{this._processMessage(i.data)}}get websocket(){if(k(this,Zr)==null)throw new Error("websocket closed");return k(this,Zr)}async _write(t){this.websocket.send(t)}async destroy(){k(this,Zr)!=null&&(k(this,Zr).close(),D(this,Zr,null)),super.destroy()}}sl=new WeakMap,Zr=new WeakMap;const pd="84842078b09946638c03157f83405213";function sG(n){switch(n){case"mainnet":return"mainnet.infura.io";case"goerli":return"goerli.infura.io";case"sepolia":return"sepolia.infura.io";case"arbitrum":return"arbitrum-mainnet.infura.io";case"arbitrum-goerli":return"arbitrum-goerli.infura.io";case"arbitrum-sepolia":return"arbitrum-sepolia.infura.io";case"base":return"base-mainnet.infura.io";case"base-goerlia":return"base-goerli.infura.io";case"base-sepolia":return"base-sepolia.infura.io";case"bnb":return"bnbsmartchain-mainnet.infura.io";case"bnbt":return"bnbsmartchain-testnet.infura.io";case"linea":return"linea-mainnet.infura.io";case"linea-goerli":return"linea-goerli.infura.io";case"linea-sepolia":return"linea-sepolia.infura.io";case"matic":return"polygon-mainnet.infura.io";case"matic-amoy":return"polygon-amoy.infura.io";case"matic-mumbai":return"polygon-mumbai.infura.io";case"optimism":return"optimism-mainnet.infura.io";case"optimism-goerli":return"optimism-goerli.infura.io";case"optimism-sepolia":return"optimism-sepolia.infura.io"}H(!1,"unsupported network","network",n)}class iG extends UM{constructor(t,r){const s=new md(t,r),i=s._getConnection();X(!i.credentials,"INFURA WebSocket project secrets unsupported","UNSUPPORTED_OPERATION",{operation:"InfuraProvider.getWebSocketProvider()"});const o=i.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(o,s._network);j(this,"projectId");j(this,"projectSecret");be(this,{projectId:s.projectId,projectSecret:s.projectSecret})}isCommunityResource(){return this.projectId===pd}}class md extends fi{constructor(t,r,s){t==null&&(t="mainnet");const i=$t.from(t);r==null&&(r=pd),s==null&&(s=null);const o=md.getRequest(i,r,s);super(o,i,{staticNetwork:i});j(this,"projectId");j(this,"projectSecret");be(this,{projectId:r,projectSecret:s})}_getProvider(t){try{return new md(t,this.projectId,this.projectSecret)}catch{}return super._getProvider(t)}isCommunityResource(){return this.projectId===pd}static getWebSocketProvider(t,r){return new iG(t,r)}static getRequest(t,r,s){r==null&&(r=pd),s==null&&(s=null);const i=new Tn(`https://${sG(t.name)}/v3/${r}`);return i.allowGzip=!0,s&&i.setCredentials("",s),r===pd&&(i.retryFunc=async(o,a,l)=>(Oc("InfuraProvider"),!0)),i}}const pg="919b412a057b5e9c9b6dce193c5a60242d6efadb";function oG(n){switch(n){case"mainnet":return"ethers.quiknode.pro";case"goerli":return"ethers.ethereum-goerli.quiknode.pro";case"sepolia":return"ethers.ethereum-sepolia.quiknode.pro";case"holesky":return"ethers.ethereum-holesky.quiknode.pro";case"arbitrum":return"ethers.arbitrum-mainnet.quiknode.pro";case"arbitrum-goerli":return"ethers.arbitrum-goerli.quiknode.pro";case"arbitrum-sepolia":return"ethers.arbitrum-sepolia.quiknode.pro";case"base":return"ethers.base-mainnet.quiknode.pro";case"base-goerli":return"ethers.base-goerli.quiknode.pro";case"base-spolia":return"ethers.base-sepolia.quiknode.pro";case"bnb":return"ethers.bsc.quiknode.pro";case"bnbt":return"ethers.bsc-testnet.quiknode.pro";case"matic":return"ethers.matic.quiknode.pro";case"matic-mumbai":return"ethers.matic-testnet.quiknode.pro";case"optimism":return"ethers.optimism.quiknode.pro";case"optimism-goerli":return"ethers.optimism-goerli.quiknode.pro";case"optimism-sepolia":return"ethers.optimism-sepolia.quiknode.pro";case"xdai":return"ethers.xdai.quiknode.pro"}H(!1,"unsupported network","network",n)}class mg extends fi{constructor(t,r){t==null&&(t="mainnet");const s=$t.from(t);r==null&&(r=pg);const i=mg.getRequest(s,r);super(i,s,{staticNetwork:s});j(this,"token");be(this,{token:r})}_getProvider(t){try{return new mg(t,this.token)}catch{}return super._getProvider(t)}isCommunityResource(){return this.token===pg}static getRequest(t,r){r==null&&(r=pg);const s=new Tn(`https://${oG(t.name)}/${r}`);return s.allowGzip=!0,r===pg&&(s.retryFunc=async(i,o,a)=>(Oc("QuickNodeProvider"),!0)),s}}const aG=BigInt("1"),lG=BigInt("2");function cG(n){for(let e=n.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}}function uG(n){return new Promise(e=>{setTimeout(e,n)})}function Hv(){return new Date().getTime()}function jv(n){return JSON.stringify(n,(e,t)=>typeof t=="bigint"?{type:"bigint",value:t.toString()}:t)}const HM={stallTimeout:400,priority:1,weight:1},jM={blockNumber:-2,requests:0,lateResponses:0,errorResponses:0,outOfSync:-1,unsupportedEvents:0,rollingDuration:0,score:0,_network:null,_updateNumber:null,_totalTime:0,_lastFatalError:null,_lastFatalErrorTimestamp:0};async function fG(n,e){for(;(n.blockNumber<0||n.blockNumber<e)&&(n._updateNumber||(n._updateNumber=(async()=>{try{const t=await n.provider.getBlockNumber();t>n.blockNumber&&(n.blockNumber=t)}catch(t){n.blockNumber=-2,n._lastFatalError=t,n._lastFatalErrorTimestamp=Hv()}n._updateNumber=null})()),await n._updateNumber,n.outOfSync++,!n._lastFatalError););}function gd(n){if(n==null)return"null";if(Array.isArray(n))return"["+n.map(gd).join(",")+"]";if(typeof n=="object"&&typeof n.toJSON=="function")return gd(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":case"number":return BigInt(n).toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{"+e.map(t=>`${JSON.stringify(t)}:${gd(n[t])}`).join(",")+"}"}}throw console.log("Could not serialize",n),new Error("Hmm...")}function $v(n){if("error"in n){const t=n.error;return{tag:gd(t),value:t}}const e=n.result;return{tag:gd(e),value:e}}function gg(n,e){const t=new Map;for(const{value:s,tag:i,weight:o}of e){const a=t.get(i)||{value:s,weight:0};a.weight+=o,t.set(i,a)}let r=null;for(const s of t.values())s.weight>=n&&(!r||s.weight>r.weight)&&(r=s);if(r)return r.value}function zv(n,e){let t=0;const r=new Map;let s=null;const i=[];for(const{value:a,tag:l,weight:c}of e)if(a instanceof Error){const u=r.get(l)||{value:a,weight:0};u.weight+=c,r.set(l,u),(s==null||u.weight>s.weight)&&(s=u)}else i.push(BigInt(a)),t+=c;if(t<n)return s&&s.weight>=n?s.value:void 0;i.sort((a,l)=>a<l?-1:l>a?1:0);const o=Math.floor(i.length/2);return i.length%2?i[o]:(i[o-1]+i[o]+aG)/lG}function Vv(n,e){const t=gg(n,e);if(t!==void 0)return t;for(const r of e)if(r.value)return r.value}function dG(n,e){if(n===1)return Pe(zv(n,e),"%internal");const t=new Map,r=(o,a)=>{const l=t.get(o)||{result:o,weight:0};l.weight+=a,t.set(o,l)};for(const{weight:o,value:a}of e){const l=Pe(a);r(l-1,o),r(l,o),r(l+1,o)}let s=0,i;for(const{weight:o,result:a}of t.values())o>=n&&(o>s||i!=null&&o===s&&a>i)&&(s=o,i=a);return i}class hG extends og{constructor(t,r,s){super(r,s);W(this,Cg);W(this,Fd);W(this,Sg);W(this,Tg);W(this,Ud);j(this,"quorum");j(this,"eventQuorum");j(this,"eventWorkers");W(this,Jn,void 0);W(this,Si,void 0);W(this,Eu,void 0);D(this,Jn,t.map(i=>i instanceof og?Object.assign({provider:i},HM,jM):Object.assign({},HM,i,jM))),D(this,Si,-2),D(this,Eu,null),s&&s.quorum!=null?this.quorum=s.quorum:this.quorum=Math.ceil(k(this,Jn).reduce((i,o)=>(i+=o.weight,i),0)/2),this.eventQuorum=1,this.eventWorkers=1,H(this.quorum<=k(this,Jn).reduce((i,o)=>i+o.weight,0),"quorum exceed provider weight","quorum",this.quorum)}get providerConfigs(){return k(this,Jn).map(t=>{const r=Object.assign({},t);for(const s in r)s[0]==="_"&&delete r[s];return r})}async _detectNetwork(){return $t.from(pe(await this._perform({method:"chainId"})))}async _translatePerform(t,r){switch(r.method){case"broadcastTransaction":return await t.broadcastTransaction(r.signedTransaction);case"call":return await t.call(Object.assign({},r.transaction,{blockTag:r.blockTag}));case"chainId":return(await t.getNetwork()).chainId;case"estimateGas":return await t.estimateGas(r.transaction);case"getBalance":return await t.getBalance(r.address,r.blockTag);case"getBlock":{const s="blockHash"in r?r.blockHash:r.blockTag;return await t.getBlock(s,r.includeTransactions)}case"getBlockNumber":return await t.getBlockNumber();case"getCode":return await t.getCode(r.address,r.blockTag);case"getGasPrice":return(await t.getFeeData()).gasPrice;case"getPriorityFee":return(await t.getFeeData()).maxPriorityFeePerGas;case"getLogs":return await t.getLogs(r.filter);case"getStorage":return await t.getStorage(r.address,r.position,r.blockTag);case"getTransaction":return await t.getTransaction(r.hash);case"getTransactionCount":return await t.getTransactionCount(r.address,r.blockTag);case"getTransactionReceipt":return await t.getTransactionReceipt(r.hash);case"getTransactionResult":return await t.getTransactionResult(r.hash)}}async _perform(t){if(t.method==="broadcastTransaction"){const o=k(this,Jn).map(c=>null),a=k(this,Jn).map(async({provider:c,weight:u},f)=>{try{const d=await c._perform(t);o[f]=Object.assign($v({result:d}),{weight:u})}catch(d){o[f]=Object.assign($v({error:d}),{weight:u})}});for(;;){const c=o.filter(d=>d!=null);for(const{value:d}of c)if(!(d instanceof Error))return d;const u=gg(this.quorum,o.filter(d=>d!=null));if(Zt(u,"INSUFFICIENT_FUNDS"))throw u;const f=a.filter((d,h)=>o[h]==null);if(f.length===0)break;await Promise.race(f)}const l=Vv(this.quorum,o);if(X(l!==void 0,"problem multi-broadcasting","SERVER_ERROR",{request:"%sub-requests",info:{request:t,results:o.map(jv)}}),l instanceof Error)throw l;return l}await ie(this,Sg,YM).call(this);const r=new Set;let s=0;for(;;){const o=ie(this,Fd,u1).call(this,r,t);if(o==null||(s+=o.config.weight,s>=this.quorum))break}const i=await ie(this,Ud,f1).call(this,r,t);for(const o of r)o.perform&&o.result==null&&o.config.lateResponses++;return i}async destroy(){for(const{provider:t}of k(this,Jn))t.destroy();super.destroy()}}Jn=new WeakMap,Si=new WeakMap,Eu=new WeakMap,Cg=new WeakSet,QM=function(t){const r=Array.from(t).map(i=>i.config),s=k(this,Jn).slice();cG(s),s.sort((i,o)=>i.priority-o.priority);for(const i of s)if(!i._lastFatalError&&r.indexOf(i)===-1)return i;return null},Fd=new WeakSet,u1=function(t,r){const s=ie(this,Cg,QM).call(this,t);if(s==null)return null;const i={config:s,result:null,didBump:!1,perform:null,staller:null},o=Hv();return i.perform=(async()=>{try{s.requests++;const l=await this._translatePerform(s.provider,r);i.result={result:l}}catch(l){s.errorResponses++,i.result={error:l}}const a=Hv()-o;s._totalTime+=a,s.rollingDuration=.95*s.rollingDuration+.05*a,i.perform=null})(),i.staller=(async()=>{await uG(s.stallTimeout),i.staller=null})(),t.add(i),i},Sg=new WeakSet,YM=async function(){let t=k(this,Eu);if(!t){const r=[];k(this,Jn).forEach(s=>{r.push((async()=>{await fG(s,0),s._lastFatalError||(s._network=await s.provider.getNetwork())})())}),D(this,Eu,t=(async()=>{await Promise.all(r);let s=null;for(const i of k(this,Jn)){if(i._lastFatalError)continue;const o=i._network;s==null?s=o.chainId:o.chainId!==s&&X(!1,"cannot mix providers on different networks","UNSUPPORTED_OPERATION",{operation:"new FallbackProvider"})}})())}await t},Tg=new WeakSet,XM=async function(t,r){const s=[];for(const i of t)if(i.result!=null){const{tag:o,value:a}=$v(i.result);s.push({tag:o,value:a,weight:i.config.weight})}if(!(s.reduce((i,o)=>i+o.weight,0)<this.quorum)){switch(r.method){case"getBlockNumber":{k(this,Si)===-2&&D(this,Si,Math.ceil(Pe(zv(this.quorum,k(this,Jn).filter(o=>!o._lastFatalError).map(o=>({value:o.blockNumber,tag:Pe(o.blockNumber).toString(),weight:o.weight}))))));const i=dG(this.quorum,s);return i===void 0?void 0:(i>k(this,Si)&&D(this,Si,i),k(this,Si))}case"getGasPrice":case"getPriorityFee":case"estimateGas":return zv(this.quorum,s);case"getBlock":return"blockTag"in r&&r.blockTag==="pending"?Vv(this.quorum,s):gg(this.quorum,s);case"call":case"chainId":case"getBalance":case"getTransactionCount":case"getCode":case"getStorage":case"getTransaction":case"getTransactionReceipt":case"getLogs":return gg(this.quorum,s);case"broadcastTransaction":return Vv(this.quorum,s)}X(!1,"unsupported method","UNSUPPORTED_OPERATION",{operation:`_perform(${jv(r.method)})`})}},Ud=new WeakSet,f1=async function(t,r){if(t.size===0)throw new Error("no runners?!");const s=[];let i=0;for(const a of t){if(a.perform&&s.push(a.perform),a.staller){s.push(a.staller);continue}a.didBump||(a.didBump=!0,i++)}const o=await ie(this,Tg,XM).call(this,t,r);if(o!==void 0){if(o instanceof Error)throw o;return o}for(let a=0;a<i;a++)ie(this,Fd,u1).call(this,t,r);return X(s.length>0,"quorum not met","SERVER_ERROR",{request:"%sub-requests",info:{request:r,results:Array.from(t).map(a=>jv(a.result))}}),await Promise.race(s),await ie(this,Ud,f1).call(this,t,r)};function pG(n){return n&&typeof n.send=="function"&&typeof n.close=="function"}const mG="goerli kovan sepolia classicKotti optimism-goerli arbitrum-goerli matic-mumbai bnbt".split(" ");function gG(n,e){e==null&&(e={});const t=o=>e[o]==="-"?!1:typeof e.exclusive=="string"?o===e.exclusive:Array.isArray(e.exclusive)?e.exclusive.indexOf(o)!==-1:!0;if(typeof n=="string"&&n.match(/^https?:/))return new fi(n);if(typeof n=="string"&&n.match(/^wss?:/)||pG(n))return new UM(n);let r=null;try{r=$t.from(n)}catch{}const s=[];if(t("publicPolygon")&&r&&(r.name==="matic"?s.push(new fi("https://polygon-rpc.com/",r,{staticNetwork:r})):r.name==="matic-amoy"&&s.push(new fi("https://rpc-amoy.polygon.technology/",r,{staticNetwork:r}))),t("alchemy"))try{s.push(new fg(n,e.alchemy))}catch{}if(t("ankr")&&e.ankr!=null)try{s.push(new cg(n,e.ankr))}catch{}if(t("chainstack"))try{s.push(new hg(n,e.chainstack))}catch{}if(t("cloudflare"))try{s.push(new GW(n))}catch{}if(t("etherscan"))try{s.push(new YW(n,e.etherscan))}catch{}if(t("infura"))try{let o=e.infura,a;typeof o=="object"&&(a=o.projectSecret,o=o.projectId),s.push(new md(n,o,a))}catch{}if(t("quicknode"))try{let o=e.quicknode;s.push(new mg(n,o))}catch{}if(X(s.length,"unsupported default network","UNSUPPORTED_OPERATION",{operation:"getDefaultProvider"}),s.length===1)return s[0];let i=Math.floor(s.length/2);return i>2&&(i=2),r&&mG.indexOf(r.name)!==-1&&(i=1),e&&e.quorum&&(i=e.quorum),new hG(s,void 0,{quorum:i})}const yG=async(n,e)=>{const t={name:n,isEns:!1};if(!e)throw new Error("cannot fetch ens name without a provider url");if(!h9(n))return t;try{const r=await bG(n,e);r&&(t.name=r,t.isEns=!0)}catch(r){console.log(r)}return t},bG=async(n,e)=>await wG(e).lookupAddress(n),wG=n=>gG(n),$M=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],vG=({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r,ensProviderUrl:s,username:i,onAutoSave:o})=>{const[a,l]=R.useState({plugin:{title:"Untitled"}}),[c]=R.useState(new Ll),[u,f]=R.useState(!1),[d,h]=R.useState([...iz]),p=NE({extensions:d,editorProps:hS,autofocus:"start"},[d]),g=NE({extensions:d,editorProps:hS,autofocus:"start"}),y=(C,T=!1)=>{if(!t||!r||!C)throw new Error("docId or username is not provided");f(!0);const N=new k8(r,c,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});h([...d,Q8.configure({document:c}),Y8.configure({provider:N,user:{name:C,color:$M[Math.floor(Math.random()*$M.length)],isEns:T},render:Cz})]);const M=setTimeout(()=>{f(!1)},100);return()=>{clearTimeout(M),N.destroy(),c.destroy(),f(!1)}};R.useEffect(()=>{r&&new vz(r,c)},[r]);const b=R.useRef(null),x=R.useMemo(()=>t&&r&&p&&!u?p:g,[p,g,u]),v=C=>{var T;(T=b.current)!=null&&T.contains(C.target)||x==null||x.chain().focus().run()};R.useEffect(()=>{x==null||x.chain().focus()},[]),R.useEffect(()=>{x==null||x.setEditable(!n)},[n]),R.useEffect(()=>{e&&x&&(x==null||x.commands.setContent(e.editorJSONData),l(e.metaData))},[e,x]);const w=async()=>{if(!i)return;let C=i,T=!1;if(s){const{name:N,isEns:M}=await yG(i,s);C=N,T=M}y(C,T)};R.useEffect(()=>{t&&i&&w()},[t]);const E=R.useCallback(Kb(()=>{x&&o&&o({metaData:a,editorJSONData:x.getJSON()})},1e3),[x,o,a]);return R.useEffect(()=>{if(x&&o)return E(),x.on("update",()=>{E()}),()=>{x.off("destroy",()=>{E()})}},[x,o,a,E]),{editor:x,pluginMetaData:a,setPluginMetaData:l,focusEditor:v,ref:b,loading:u,connect:y}},AG=({isPreviewMode:n=!1,data:e,enableCollaboration:t,collaborationId:r,username:s,onAutoSave:i,renderToolRightSection:o,ensProviderUrl:a})=>{const{editor:l,pluginMetaData:c,focusEditor:u,setPluginMetaData:f,ref:d,loading:h}=vG({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r,ensProviderUrl:a,username:s,onAutoSave:i});return!l||h?_.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[_.jsx(mk,{}),_.jsx("p",{children:"Loading Editor..."})]}):_.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f8f9fa]",children:_.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:_.jsxs("div",{className:"w-full h-screen",children:[_.jsx("div",{className:"h-fit relative bg-[#f8f9fa]",children:_.jsxs("div",{className:"flex items-center justify-center pl-4 pr-4 gap-2 h-16",children:[_.jsx("div",{className:"grow",children:_.jsx(nR,{isPreviewMode:n,metaData:c,setMetaData:f})}),!n&&_.jsx("div",{className:"grow relative",children:_.jsx(OF,{editor:l})}),o==null?void 0:o({editor:l,pluginMetaData:c})]})}),_.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:_.jsx("div",{onClick:u,className:"w-full flex justify-center relative",children:_.jsx("div",{className:"p-12 sm:p-[96px] mt-4 min-h-[900px] bg-white overflow-scroll no-scrollbar w-full sm:w-[70%] max-w-[856px]",children:_.jsxs("div",{ref:d,className:"w-full pt-4 h-full",children:[!n&&_.jsxs("div",{children:[_.jsx(wF,{editor:l}),_.jsx(SF,{editor:l,appendTo:d})]}),_.jsx(TF,{isPreviewMode:n,children:_.jsx(DB,{editor:l})})]})})})})]})})})};Je.DdocEditor=AG,Object.defineProperty(Je,Symbol.toStringTag,{value:"Module"})});
|
424
|
+
`).focus(o+1).run():["columns","heading"].includes(a)?n.chain().insertContent({type:"dBlock",content:[{type:"paragraph"}]}).focus().run():n.chain().insertContentAt({from:t,to:o},{type:this.name,content:l}).focus(t+4).run()}catch(u){return console.error(`Error inserting content into dBlock node: ${u}`),!1}}}}});let gw,yw;if(typeof WeakMap<"u"){let n=new WeakMap;gw=e=>n.get(e),yw=(e,t)=>(n.set(e,t),t)}else{let n=[],e=10,t=0;gw=r=>{for(let s=0;s<n.length;s+=2)if(n[s]==r)return n[s+1]},yw=(r,s)=>(t==e&&(t=0),n[t++]=r,n[t++]=s)}class oc{constructor(e,t,r,s){this.left=e,this.top=t,this.right=r,this.bottom=s}}class Ot{constructor(e,t,r,s){this.width=e,this.height=t,this.map=r,this.problems=s}findCell(e){for(let t=0;t<this.map.length;t++){let r=this.map[t];if(r!=e)continue;let s=t%this.width,i=t/this.width|0,o=s+1,a=i+1;for(let l=1;o<this.width&&this.map[t+l]==r;l++)o++;for(let l=1;a<this.height&&this.map[t+this.width*l]==r;l++)a++;return new oc(s,i,o,a)}throw new RangeError("No cell with offset "+e+" found")}colCount(e){for(let t=0;t<this.map.length;t++)if(this.map[t]==e)return t%this.width;throw new RangeError("No cell with offset "+e+" found")}nextCell(e,t,r){let{left:s,right:i,top:o,bottom:a}=this.findCell(e);return t=="horiz"?(r<0?s==0:i==this.width)?null:this.map[o*this.width+(r<0?s-1:i)]:(r<0?o==0:a==this.height)?null:this.map[s+this.width*(r<0?o-1:a)]}rectBetween(e,t){let{left:r,right:s,top:i,bottom:o}=this.findCell(e),{left:a,right:l,top:c,bottom:u}=this.findCell(t);return new oc(Math.min(r,a),Math.min(i,c),Math.max(s,l),Math.max(o,u))}cellsInRect(e){let t=[],r={};for(let s=e.top;s<e.bottom;s++)for(let i=e.left;i<e.right;i++){let o=s*this.width+i,a=this.map[o];r[a]||(r[a]=!0,(i!=e.left||!i||this.map[o-1]!=a)&&(s!=e.top||!s||this.map[o-this.width]!=a)&&t.push(a))}return t}positionAt(e,t,r){for(let s=0,i=0;;s++){let o=i+r.child(s).nodeSize;if(s==e){let a=t+e*this.width,l=(e+1)*this.width;for(;a<l&&this.map[a]<i;)a++;return a==l?o-1:this.map[a]}i=o}}static get(e){return gw(e)||yw(e,Hj(e))}}function Hj(n){if(n.type.spec.tableRole!="table")throw new RangeError("Not a table node: "+n.type.name);let e=jj(n),t=n.childCount,r=[],s=0,i=null,o=[];for(let c=0,u=e*t;c<u;c++)r[c]=0;for(let c=0,u=0;c<t;c++){let f=n.child(c);u++;for(let p=0;;p++){for(;s<r.length&&r[s]!=0;)s++;if(p==f.childCount)break;let g=f.child(p),{colspan:y,rowspan:b,colwidth:x}=g.attrs;for(let v=0;v<b;v++){if(v+c>=t){(i||(i=[])).push({type:"overlong_rowspan",pos:u,n:b-v});break}let w=s+v*e;for(let E=0;E<y;E++){r[w+E]==0?r[w+E]=u:(i||(i=[])).push({type:"collision",row:c,pos:u,n:y-E});let C=x&&x[E];if(C){let T=(w+E)%e*2,N=o[T];N==null||N!=C&&o[T+1]==1?(o[T]=C,o[T+1]=1):N==C&&o[T+1]++}}}s+=y,u+=g.nodeSize}let d=(c+1)*e,h=0;for(;s<d;)r[s++]==0&&h++;h&&(i||(i=[])).push({type:"missing",row:c,n:h}),u++}let a=new Ot(e,t,r,i),l=!1;for(let c=0;!l&&c<o.length;c+=2)o[c]!=null&&o[c+1]<t&&(l=!0);return l&&$j(a,o,n),a}function jj(n){let e=-1,t=!1;for(let r=0;r<n.childCount;r++){let s=n.child(r),i=0;if(t)for(let o=0;o<r;o++){let a=n.child(o);for(let l=0;l<a.childCount;l++){let c=a.child(l);o+c.attrs.rowspan>r&&(i+=c.attrs.colspan)}}for(let o=0;o<s.childCount;o++){let a=s.child(o);i+=a.attrs.colspan,a.attrs.rowspan>1&&(t=!0)}e==-1?e=i:e!=i&&(e=Math.max(e,i))}return e}function $j(n,e,t){n.problems||(n.problems=[]);for(let r=0,s={};r<n.map.length;r++){let i=n.map[r];if(s[i])continue;s[i]=!0;let o=t.nodeAt(i),a=null;for(let l=0;l<o.attrs.colspan;l++){let c=(r+l)%n.width,u=e[c*2];u!=null&&(!o.attrs.colwidth||o.attrs.colwidth[l]!=u)&&((a||(a=zj(o.attrs)))[l]=u)}a&&n.problems.unshift({type:"colwidth mismatch",pos:i,colwidth:a})}}function zj(n){if(n.colwidth)return n.colwidth.slice();let e=[];for(let t=0;t<n.colspan;t++)e.push(0);return e}function hn(n){let e=n.cached.tableNodeTypes;if(!e){e=n.cached.tableNodeTypes={};for(let t in n.nodes){let r=n.nodes[t],s=r.spec.tableRole;s&&(e[s]=r)}}return e}const ro=new vt("selectingCells");function ac(n){for(let e=n.depth-1;e>0;e--)if(n.node(e).type.spec.tableRole=="row")return n.node(0).resolve(n.before(e+1));return null}function Vj(n){for(let e=n.depth;e>0;e--){const t=n.node(e).type.spec.tableRole;if(t==="cell"||t==="header_cell")return n.node(e)}return null}function $r(n){let e=n.selection.$head;for(let t=e.depth;t>0;t--)if(e.node(t).type.spec.tableRole=="row")return!0;return!1}function ym(n){let e=n.selection;return e.$anchorCell?e.$anchorCell.pos>e.$headCell.pos?e.$anchorCell:e.$headCell:e.node&&e.node.type.spec.tableRole=="cell"?e.$anchor:ac(e.$head)||Wj(e.$head)}function Wj(n){for(let e=n.nodeAfter,t=n.pos;e;e=e.firstChild,t++){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t)}for(let e=n.nodeBefore,t=n.pos;e;e=e.lastChild,t--){let r=e.type.spec.tableRole;if(r=="cell"||r=="header_cell")return n.doc.resolve(t-e.nodeSize)}}function bw(n){return n.parent.type.spec.tableRole=="row"&&n.nodeAfter}function Gj(n){return n.node(0).resolve(n.pos+n.nodeAfter.nodeSize)}function ww(n,e){return n.depth==e.depth&&n.pos>=e.start(-1)&&n.pos<=e.end(-1)}function n2(n,e,t){let r=n.start(-1),i=Ot.get(n.node(-1)).nextCell(n.pos-r,e,t);return i==null?null:n.node(0).resolve(r+i)}function Xt(n,e,t){let r={};for(let s in n)r[s]=n[s];return r[e]=t,r}function ma(n,e,t=1){let r=Xt(n,"colspan",n.colspan-t);return r.colwidth&&(r.colwidth=r.colwidth.slice(),r.colwidth.splice(e,t),r.colwidth.some(s=>s>0)||(r.colwidth=null)),r}function r2(n,e,t=1){let r=Xt(n,"colspan",n.colspan+t);if(r.colwidth){r.colwidth=r.colwidth.slice();for(let s=0;s<t;s++)r.colwidth.splice(e,0,0)}return r}function Kj(n,e,t){let r=hn(e.type.schema).header_cell;for(let s=0;s<n.height;s++)if(e.nodeAt(n.map[t+s*n.width]).type!=r)return!1;return!0}class ze extends xe{constructor(e,t=e){let r=e.node(-1),s=Ot.get(r),i=e.start(-1),o=s.rectBetween(e.pos-i,t.pos-i),a=e.node(0),l=s.cellsInRect(o).filter(u=>u!=t.pos-i);l.unshift(t.pos-i);let c=l.map(u=>{let f=r.nodeAt(u),d=u+i+1;return new Xg(a.resolve(d),a.resolve(d+f.content.size))});super(c[0].$from,c[0].$to,c),this.$anchorCell=e,this.$headCell=t}map(e,t){let r=e.resolve(t.map(this.$anchorCell.pos)),s=e.resolve(t.map(this.$headCell.pos));if(bw(r)&&bw(s)&&ww(r,s)){let i=this.$anchorCell.node(-1)!=r.node(-1);return i&&this.isRowSelection()?ze.rowSelection(r,s):i&&this.isColSelection()?ze.colSelection(r,s):new ze(r,s)}return Ae.between(r,s)}content(){let e=this.$anchorCell.node(-1),t=Ot.get(e),r=this.$anchorCell.start(-1),s=t.rectBetween(this.$anchorCell.pos-r,this.$headCell.pos-r),i={},o=[];for(let l=s.top;l<s.bottom;l++){let c=[];for(let u=l*t.width+s.left,f=s.left;f<s.right;f++,u++){let d=t.map[u];if(!i[d]){i[d]=!0;let h=t.findCell(d),p=e.nodeAt(d),g=s.left-h.left,y=h.right-s.right;if(g>0||y>0){let b=p.attrs;g>0&&(b=ma(b,0,g)),y>0&&(b=ma(b,b.colspan-y,y)),h.left<s.left?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}if(h.top<s.top||h.bottom>s.bottom){let b=Xt(p.attrs,"rowspan",Math.min(h.bottom,s.bottom)-Math.max(h.top,s.top));h.top<s.top?p=p.type.createAndFill(b):p=p.type.create(b,p.content)}c.push(p)}}o.push(e.child(l).copy(ne.from(c)))}const a=this.isColSelection()&&this.isRowSelection()?e:o;return new se(ne.from(a),1,1)}replace(e,t=se.empty){let r=e.steps.length,s=this.ranges;for(let o=0;o<s.length;o++){let{$from:a,$to:l}=s[o],c=e.mapping.slice(r);e.replace(c.map(a.pos),c.map(l.pos),o?se.empty:t)}let i=xe.findFrom(e.doc.resolve(e.mapping.slice(r).map(this.to)),-1);i&&e.setSelection(i)}replaceWith(e,t){this.replace(e,new se(ne.from(t),0,0))}forEachCell(e){let t=this.$anchorCell.node(-1),r=Ot.get(t),s=this.$anchorCell.start(-1),i=r.cellsInRect(r.rectBetween(this.$anchorCell.pos-s,this.$headCell.pos-s));for(let o=0;o<i.length;o++)e(t.nodeAt(i[o]),s+i[o])}isColSelection(){let e=this.$anchorCell.index(-1),t=this.$headCell.index(-1);if(Math.min(e,t)>0)return!1;let r=e+this.$anchorCell.nodeAfter.attrs.rowspan,s=t+this.$headCell.nodeAfter.attrs.rowspan;return Math.max(r,s)==this.$headCell.node(-1).childCount}static colSelection(e,t=e){let r=Ot.get(e.node(-1)),s=e.start(-1),i=r.findCell(e.pos-s),o=r.findCell(t.pos-s),a=e.node(0);return i.top<=o.top?(i.top>0&&(e=a.resolve(s+r.map[i.left])),o.bottom<r.height&&(t=a.resolve(s+r.map[r.width*(r.height-1)+o.right-1]))):(o.top>0&&(t=a.resolve(s+r.map[o.left])),i.bottom<r.height&&(e=a.resolve(s+r.map[r.width*(r.height-1)+i.right-1]))),new ze(e,t)}isRowSelection(){let e=Ot.get(this.$anchorCell.node(-1)),t=this.$anchorCell.start(-1),r=e.colCount(this.$anchorCell.pos-t),s=e.colCount(this.$headCell.pos-t);if(Math.min(r,s)>0)return!1;let i=r+this.$anchorCell.nodeAfter.attrs.colspan,o=s+this.$headCell.nodeAfter.attrs.colspan;return Math.max(i,o)==e.width}eq(e){return e instanceof ze&&e.$anchorCell.pos==this.$anchorCell.pos&&e.$headCell.pos==this.$headCell.pos}static rowSelection(e,t=e){let r=Ot.get(e.node(-1)),s=e.start(-1),i=r.findCell(e.pos-s),o=r.findCell(t.pos-s),a=e.node(0);return i.left<=o.left?(i.left>0&&(e=a.resolve(s+r.map[i.top*r.width])),o.right<r.width&&(t=a.resolve(s+r.map[r.width*(o.top+1)-1]))):(o.left>0&&(t=a.resolve(s+r.map[o.top*r.width])),i.right<r.width&&(e=a.resolve(s+r.map[r.width*(i.top+1)-1]))),new ze(e,t)}toJSON(){return{type:"cell",anchor:this.$anchorCell.pos,head:this.$headCell.pos}}static fromJSON(e,t){return new ze(e.resolve(t.anchor),e.resolve(t.head))}static create(e,t,r=t){return new ze(e.resolve(t),e.resolve(r))}getBookmark(){return new vw(this.$anchorCell.pos,this.$headCell.pos)}}ze.prototype.visible=!1,xe.jsonID("cell",ze);class vw{constructor(e,t){this.anchor=e,this.head=t}map(e){return new vw(e.map(this.anchor),e.map(this.head))}resolve(e){let t=e.resolve(this.anchor),r=e.resolve(this.head);return t.parent.type.spec.tableRole=="row"&&r.parent.type.spec.tableRole=="row"&&t.index()<t.parent.childCount&&r.index()<r.parent.childCount&&ww(t,r)?new ze(t,r):xe.near(r,1)}}function Jj(n){if(!(n.selection instanceof ze))return null;let e=[];return n.selection.forEachCell((t,r)=>{e.push(Ht.node(r,r+t.nodeSize,{class:"selectedCell"}))}),ft.create(n.doc,e)}function qj({$from:n,$to:e}){if(n.pos==e.pos||n.pos<n.pos-6)return!1;let t=n.pos,r=e.pos,s=n.depth;for(;s>=0&&!(n.after(s+1)<n.end(s));s--,t++);for(let i=e.depth;i>=0&&!(e.before(i+1)>e.start(i));i--,r--);return t==r&&/row|table/.test(n.node(s).type.spec.tableRole)}function Qj({$from:n,$to:e}){let t,r;for(let s=n.depth;s>0;s--){let i=n.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){t=i;break}}for(let s=e.depth;s>0;s--){let i=e.node(s);if(i.type.spec.tableRole==="cell"||i.type.spec.tableRole==="header_cell"){r=i;break}}return t!==r&&e.parentOffset===0}function Yj(n,e,t){let r=(e||n).selection,s=(e||n).doc,i,o;if(r instanceof ye&&(o=r.node.type.spec.tableRole)){if(o=="cell"||o=="header_cell")i=ze.create(s,r.from);else if(o=="row"){let a=s.resolve(r.from+1);i=ze.rowSelection(a,a)}else if(!t){let a=Ot.get(r.node),l=r.from+1,c=l+a.map[a.width*a.height-1];i=ze.create(s,l+1,c)}}else r instanceof Ae&&qj(r)?i=Ae.create(s,r.from):r instanceof Ae&&Qj(r)&&(i=Ae.create(s,r.$from.start(),r.$from.end()));return i&&(e||(e=n.tr)).setSelection(i),e}function Xj(n){if(!n.size)return null;let{content:e,openStart:t,openEnd:r}=n;for(;e.childCount==1&&(t>0&&r>0||e.firstChild.type.spec.tableRole=="table");)t--,r--,e=e.firstChild.content;let s=e.firstChild,i=s.type.spec.tableRole,o=s.type.schema,a=[];if(i=="row")for(let l=0;l<e.childCount;l++){let c=e.child(l).content,u=l?0:Math.max(0,t-1),f=l<e.childCount-1?0:Math.max(0,r-1);(u||f)&&(c=Aw(hn(o).row,new se(c,u,f)).content),a.push(c)}else if(i=="cell"||i=="header_cell")a.push(t||r?Aw(hn(o).row,new se(e,t,r)).content:e);else return null;return Zj(o,a)}function Zj(n,e){let t=[];for(let s=0;s<e.length;s++){let i=e[s];for(let o=i.childCount-1;o>=0;o--){let{rowspan:a,colspan:l}=i.child(o).attrs;for(let c=s;c<s+a;c++)t[c]=(t[c]||0)+l}}let r=0;for(let s=0;s<t.length;s++)r=Math.max(r,t[s]);for(let s=0;s<t.length;s++)if(s>=e.length&&e.push(ne.empty),t[s]<r){let i=hn(n).cell.createAndFill(),o=[];for(let a=t[s];a<r;a++)o.push(i);e[s]=e[s].append(ne.from(o))}return{height:e.length,width:r,rows:e}}function Aw(n,e){let t=n.createAndFill();return new Qg(t).replace(0,t.content.size,e).doc}function e$({width:n,height:e,rows:t},r,s){if(n!=r){let i=[],o=[];for(let a=0;a<t.length;a++){let l=t[a],c=[];for(let u=i[a]||0,f=0;u<r;f++){let d=l.child(f%l.childCount);u+d.attrs.colspan>r&&(d=d.type.create(ma(d.attrs,d.attrs.colspan,u+d.attrs.colspan-r),d.content)),c.push(d),u+=d.attrs.colspan;for(let h=1;h<d.attrs.rowspan;h++)i[a+h]=(i[a+h]||0)+d.attrs.colspan}o.push(ne.from(c))}t=o,n=r}if(e!=s){let i=[];for(let o=0,a=0;o<s;o++,a++){let l=[],c=t[a%e];for(let u=0;u<c.childCount;u++){let f=c.child(u);o+f.attrs.rowspan>s&&(f=f.type.create(Xt(f.attrs,"rowspan",Math.max(1,s-f.attrs.rowspan)),f.content)),l.push(f)}i.push(ne.from(l))}t=i,e=s}return{width:n,height:e,rows:t}}function t$(n,e,t,r,s,i,o){let a=n.doc.type.schema,l=hn(a),c,u;if(s>e.width)for(let f=0,d=0;f<e.height;f++){let h=t.child(f);d+=h.nodeSize;let p=[],g;h.lastChild==null||h.lastChild.type==l.cell?g=c||(c=l.cell.createAndFill()):g=u||(u=l.header_cell.createAndFill());for(let y=e.width;y<s;y++)p.push(g);n.insert(n.mapping.slice(o).map(d-1+r),p)}if(i>e.height){let f=[];for(let p=0,g=(e.height-1)*e.width;p<Math.max(e.width,s);p++){let y=p>=e.width?!1:t.nodeAt(e.map[g+p]).type==l.header_cell;f.push(y?u||(u=l.header_cell.createAndFill()):c||(c=l.cell.createAndFill()))}let d=l.row.create(null,ne.from(f)),h=[];for(let p=e.height;p<i;p++)h.push(d);n.insert(n.mapping.slice(o).map(r+t.nodeSize-2),h)}return!!(c||u)}function s2(n,e,t,r,s,i,o,a){if(o==0||o==e.height)return!1;let l=!1;for(let c=s;c<i;c++){let u=o*e.width+c,f=e.map[u];if(e.map[u-e.width]==f){l=!0;let d=t.nodeAt(f),{top:h,left:p}=e.findCell(f);n.setNodeMarkup(n.mapping.slice(a).map(f+r),null,Xt(d.attrs,"rowspan",o-h)),n.insert(n.mapping.slice(a).map(e.positionAt(o,p,t)),d.type.createAndFill(Xt(d.attrs,"rowspan",h+d.attrs.rowspan-o))),c+=d.attrs.colspan-1}}return l}function i2(n,e,t,r,s,i,o,a){if(o==0||o==e.width)return!1;let l=!1;for(let c=s;c<i;c++){let u=c*e.width+o,f=e.map[u];if(e.map[u-1]==f){l=!0;let d=t.nodeAt(f),h=e.colCount(f),p=n.mapping.slice(a).map(f+r);n.setNodeMarkup(p,null,ma(d.attrs,o-h,d.attrs.colspan-(o-h))),n.insert(p+d.nodeSize,d.type.createAndFill(ma(d.attrs,0,o-h))),c+=d.attrs.rowspan-1}}return l}function o2(n,e,t,r,s){let i=t?n.doc.nodeAt(t-1):n.doc,o=Ot.get(i),{top:a,left:l}=r,c=l+s.width,u=a+s.height,f=n.tr,d=0;function h(){i=t?f.doc.nodeAt(t-1):f.doc,o=Ot.get(i),d=f.mapping.maps.length}t$(f,o,i,t,c,u,d)&&h(),s2(f,o,i,t,l,c,a,d)&&h(),s2(f,o,i,t,l,c,u,d)&&h(),i2(f,o,i,t,a,u,l,d)&&h(),i2(f,o,i,t,a,u,c,d)&&h();for(let p=a;p<u;p++){let g=o.positionAt(p,l,i),y=o.positionAt(p,c,i);f.replace(f.mapping.slice(d).map(g+t),f.mapping.slice(d).map(y+t),new se(s.rows[p-a],0,0))}h(),f.setSelection(new ze(f.doc.resolve(t+o.positionAt(a,l,i)),f.doc.resolve(t+o.positionAt(u-1,c-1,i)))),e(f)}const n$=Ty({ArrowLeft:wm("horiz",-1),ArrowRight:wm("horiz",1),ArrowUp:wm("vert",-1),ArrowDown:wm("vert",1),"Shift-ArrowLeft":vm("horiz",-1),"Shift-ArrowRight":vm("horiz",1),"Shift-ArrowUp":vm("vert",-1),"Shift-ArrowDown":vm("vert",1),Backspace:Am,"Mod-Backspace":Am,Delete:Am,"Mod-Delete":Am});function bm(n,e,t){return t.eq(n.selection)?!1:(e&&e(n.tr.setSelection(t).scrollIntoView()),!0)}function wm(n,e){return(t,r,s)=>{let i=t.selection;if(i instanceof ze)return bm(t,r,xe.near(i.$headCell,e));if(n!="horiz"&&!i.empty)return!1;let o=a2(s,n,e);if(o==null)return!1;if(n=="horiz")return bm(t,r,xe.near(t.doc.resolve(i.head+e),e));{let a=t.doc.resolve(o),l=n2(a,n,e),c;return l?c=xe.near(l,1):e<0?c=xe.near(t.doc.resolve(a.before(-1)),-1):c=xe.near(t.doc.resolve(a.after(-1)),1),bm(t,r,c)}}}function vm(n,e){return(t,r,s)=>{let i=t.selection;if(!(i instanceof ze)){let a=a2(s,n,e);if(a==null)return!1;i=new ze(t.doc.resolve(a))}let o=n2(i.$headCell,n,e);return o?bm(t,r,new ze(i.$anchorCell,o)):!1}}function Am(n,e){let t=n.selection;if(!(t instanceof ze))return!1;if(e){let r=n.tr,s=hn(n.schema).cell.createAndFill().content;t.forEachCell((i,o)=>{i.content.eq(s)||r.replace(r.mapping.map(o+1),r.mapping.map(o+i.nodeSize-1),new se(s,0,0))}),r.docChanged&&e(r)}return!0}function r$(n,e){let t=n.state.doc,r=ac(t.resolve(e));return r?(n.dispatch(n.state.tr.setSelection(new ze(r))),!0):!1}function s$(n,e,t){if(!$r(n.state))return!1;let r=Xj(t),s=n.state.selection;if(s instanceof ze){r||(r={width:1,height:1,rows:[ne.from(Aw(hn(n.state.schema).cell,t))]});let i=s.$anchorCell.node(-1),o=s.$anchorCell.start(-1),a=Ot.get(i).rectBetween(s.$anchorCell.pos-o,s.$headCell.pos-o);return r=e$(r,a.right-a.left,a.bottom-a.top),o2(n.state,n.dispatch,o,a,r),!0}else if(r){let i=ym(n.state),o=i.start(-1);return o2(n.state,n.dispatch,o,Ot.get(i.node(-1)).findCell(i.pos-o),r),!0}else return!1}function i$(n,e){if(e.ctrlKey||e.metaKey)return;let t=l2(n,e.target),r;if(e.shiftKey&&n.state.selection instanceof ze)s(n.state.selection.$anchorCell,e),e.preventDefault();else if(e.shiftKey&&t&&(r=ac(n.state.selection.$anchor))!=null&&xw(n,e).pos!=r.pos)s(r,e),e.preventDefault();else if(!t)return;function s(a,l){let c=xw(n,l),u=ro.getState(n.state)==null;if(!c||!ww(a,c))if(u)c=a;else return;let f=new ze(a,c);if(u||!n.state.selection.eq(f)){let d=n.state.tr.setSelection(f);u&&d.setMeta(ro,a.pos),n.dispatch(d)}}function i(){n.root.removeEventListener("mouseup",i),n.root.removeEventListener("dragstart",i),n.root.removeEventListener("mousemove",o),ro.getState(n.state)!=null&&n.dispatch(n.state.tr.setMeta(ro,-1))}function o(a){let l=ro.getState(n.state),c;if(l!=null)c=n.state.doc.resolve(l);else if(l2(n,a.target)!=t&&(c=xw(n,e),!c))return i();c&&s(c,a)}n.root.addEventListener("mouseup",i),n.root.addEventListener("dragstart",i),n.root.addEventListener("mousemove",o)}function a2(n,e,t){if(!(n.state.selection instanceof Ae))return null;let{$head:r}=n.state.selection;for(let s=r.depth-1;s>=0;s--){let i=r.node(s);if((t<0?r.index(s):r.indexAfter(s))!=(t<0?0:i.childCount))return null;if(i.type.spec.tableRole=="cell"||i.type.spec.tableRole=="header_cell"){let a=r.before(s),l=e=="vert"?t>0?"down":"up":t>0?"right":"left";return n.endOfTextblock(l)?a:null}}return null}function l2(n,e){for(;e&&e!=n.dom;e=e.parentNode)if(e.nodeName=="TD"||e.nodeName=="TH")return e}function xw(n,e){let t=n.posAtCoords({left:e.clientX,top:e.clientY});return t&&t?ac(n.state.doc.resolve(t.pos)):null}const o$=new vt("fix-tables");function c2(n,e,t,r){let s=n.childCount,i=e.childCount;e:for(let o=0,a=0;o<i;o++){let l=e.child(o);for(let c=a,u=Math.min(s,o+3);c<u;c++)if(n.child(c)==l){a=c+1,t+=l.nodeSize;continue e}r(l,t),a<s&&n.child(a).sameMarkup(l)?c2(n.child(a),l,t+1,r):l.nodesBetween(0,l.content.size,r,t+1),t+=l.nodeSize}}function u2(n,e){let t,r=(s,i)=>{s.type.spec.tableRole=="table"&&(t=a$(n,s,i,t))};return e?e.doc!=n.doc&&c2(e.doc,n.doc,0,r):n.doc.descendants(r),t}function a$(n,e,t,r){let s=Ot.get(e);if(!s.problems)return r;r||(r=n.tr);let i=[];for(let l=0;l<s.height;l++)i.push(0);for(let l=0;l<s.problems.length;l++){let c=s.problems[l];if(c.type=="collision"){let u=e.nodeAt(c.pos);for(let f=0;f<u.attrs.rowspan;f++)i[c.row+f]+=c.n;r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,ma(u.attrs,u.attrs.colspan-c.n,c.n))}else if(c.type=="missing")i[c.row]+=c.n;else if(c.type=="overlong_rowspan"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Xt(u.attrs,"rowspan",u.attrs.rowspan-c.n))}else if(c.type=="colwidth mismatch"){let u=e.nodeAt(c.pos);r.setNodeMarkup(r.mapping.map(t+1+c.pos),null,Xt(u.attrs,"colwidth",c.colwidth))}}let o,a;for(let l=0;l<i.length;l++)i[l]&&(o==null&&(o=l),a=l);for(let l=0,c=t+1;l<s.height;l++){let u=e.child(l),f=c+u.nodeSize,d=i[l];if(d>0){let h="cell";u.firstChild&&(h=u.firstChild.type.spec.tableRole);let p=[];for(let y=0;y<d;y++)p.push(hn(n.schema)[h].createAndFill());let g=(l==0||o==l-1)&&a==l?c+1:f-1;r.insert(r.mapping.map(g),p)}c=f}return r.setMeta(o$,{fixTables:!0})}function Cs(n){let e=n.selection,t=ym(n),r=t.node(-1),s=t.start(-1),i=Ot.get(r),o;return e instanceof ze?o=i.rectBetween(e.$anchorCell.pos-s,e.$headCell.pos-s):o=i.findCell(t.pos-s),o.tableStart=s,o.map=i,o.table=r,o}function f2(n,{map:e,tableStart:t,table:r},s){let i=s>0?-1:0;Kj(e,r,s+i)&&(i=s==0||s==e.width?null:0);for(let o=0;o<e.height;o++){let a=o*e.width+s;if(s>0&&s<e.width&&e.map[a-1]==e.map[a]){let l=e.map[a],c=r.nodeAt(l);n.setNodeMarkup(n.mapping.map(t+l),null,r2(c.attrs,s-e.colCount(l))),o+=c.attrs.rowspan-1}else{let l=i==null?hn(r.type.schema).cell:r.nodeAt(e.map[a+i]).type,c=e.positionAt(o,s,r);n.insert(n.mapping.map(t+c),l.createAndFill())}}return n}function l$(n,e){if(!$r(n))return!1;if(e){let t=Cs(n);e(f2(n.tr,t,t.left))}return!0}function c$(n,e){if(!$r(n))return!1;if(e){let t=Cs(n);e(f2(n.tr,t,t.right))}return!0}function u$(n,{map:e,table:t,tableStart:r},s){let i=n.mapping.maps.length;for(let o=0;o<e.height;){let a=o*e.width+s,l=e.map[a],c=t.nodeAt(l);if(s>0&&e.map[a-1]==l||s<e.width-1&&e.map[a+1]==l)n.setNodeMarkup(n.mapping.slice(i).map(r+l),null,ma(c.attrs,s-e.colCount(l)));else{let u=n.mapping.slice(i).map(r+l);n.delete(u,u+c.nodeSize)}o+=c.attrs.rowspan}}function f$(n,e){if(!$r(n))return!1;if(e){let t=Cs(n),r=n.tr;if(t.left==0&&t.right==t.map.width)return!1;for(let s=t.right-1;u$(r,t,s),s!=t.left;s--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=Ot.get(t.table);e(r)}return!0}function d$(n,e,t){let r=hn(e.type.schema).header_cell;for(let s=0;s<n.width;s++)if(e.nodeAt(n.map[s+t*n.width]).type!=r)return!1;return!0}function d2(n,{map:e,tableStart:t,table:r},s){let i=t;for(let l=0;l<s;l++)i+=r.child(l).nodeSize;let o=[],a=s>0?-1:0;d$(e,r,s+a)&&(a=s==0||s==e.height?null:0);for(let l=0,c=e.width*s;l<e.width;l++,c++)if(s>0&&s<e.height&&e.map[c]==e.map[c-e.width]){let u=e.map[c],f=r.nodeAt(u).attrs;n.setNodeMarkup(t+u,null,Xt(f,"rowspan",f.rowspan+1)),l+=f.colspan-1}else{let u=a==null?hn(r.type.schema).cell:r.nodeAt(e.map[c+a*e.width]).type;o.push(u.createAndFill())}return n.insert(i,hn(r.type.schema).row.create(null,o)),n}function h$(n,e){if(!$r(n))return!1;if(e){let t=Cs(n);e(d2(n.tr,t,t.top))}return!0}function p$(n,e){if(!$r(n))return!1;if(e){let t=Cs(n);e(d2(n.tr,t,t.bottom))}return!0}function m$(n,{map:e,table:t,tableStart:r},s){let i=0;for(let l=0;l<s;l++)i+=t.child(l).nodeSize;let o=i+t.child(s).nodeSize,a=n.mapping.maps.length;n.delete(i+r,o+r);for(let l=0,c=s*e.width;l<e.width;l++,c++){let u=e.map[c];if(s>0&&u==e.map[c-e.width]){let f=t.nodeAt(u).attrs;n.setNodeMarkup(n.mapping.slice(a).map(u+r),null,Xt(f,"rowspan",f.rowspan-1)),l+=f.colspan-1}else if(s<e.width&&u==e.map[c+e.width]){let f=t.nodeAt(u),d=f.type.create(Xt(f.attrs,"rowspan",f.attrs.rowspan-1),f.content),h=e.positionAt(s+1,l,t);n.insert(n.mapping.slice(a).map(r+h),d),l+=f.attrs.colspan-1}}}function g$(n,e){if(!$r(n))return!1;if(e){let t=Cs(n),r=n.tr;if(t.top==0&&t.bottom==t.map.height)return!1;for(let s=t.bottom-1;m$(r,t,s),s!=t.top;s--)t.table=t.tableStart?r.doc.nodeAt(t.tableStart-1):r.doc,t.map=Ot.get(t.table);e(r)}return!0}function h2(n){let e=n.content;return e.childCount==1&&e.firstChild.isTextblock&&e.firstChild.childCount==0}function y$({width:n,height:e,map:t},r){let s=r.top*n+r.left,i=s,o=(r.bottom-1)*n+r.left,a=s+(r.right-r.left-1);for(let l=r.top;l<r.bottom;l++){if(r.left>0&&t[i]==t[i-1]||r.right<n&&t[a]==t[a+1])return!0;i+=n,a+=n}for(let l=r.left;l<r.right;l++){if(r.top>0&&t[s]==t[s-n]||r.bottom<e&&t[o]==t[o+n])return!0;s++,o++}return!1}function p2(n,e){let t=n.selection;if(!(t instanceof ze)||t.$anchorCell.pos==t.$headCell.pos)return!1;let r=Cs(n),{map:s}=r;if(y$(s,r))return!1;if(e){let i=n.tr,o={},a=ne.empty,l,c;for(let u=r.top;u<r.bottom;u++)for(let f=r.left;f<r.right;f++){let d=s.map[u*s.width+f],h=r.table.nodeAt(d);if(!o[d])if(o[d]=!0,l==null)l=d,c=h;else{h2(h)||(a=a.append(h.content));let p=i.mapping.map(d+r.tableStart);i.delete(p,p+h.nodeSize)}}if(i.setNodeMarkup(l+r.tableStart,null,Xt(r2(c.attrs,c.attrs.colspan,r.right-r.left-c.attrs.colspan),"rowspan",r.bottom-r.top)),a.size){let u=l+1+c.content.size,f=h2(c)?l+1:u;i.replaceWith(f+r.tableStart,u+r.tableStart,a)}i.setSelection(new ze(i.doc.resolve(l+r.tableStart))),e(i)}return!0}function m2(n,e){const t=hn(n.schema);return b$(({node:r})=>t[r.type.spec.tableRole])(n,e)}function b$(n){return(e,t)=>{let r=e.selection,s,i;if(r instanceof ze){if(r.$anchorCell.pos!=r.$headCell.pos)return!1;s=r.$anchorCell.nodeAfter,i=r.$anchorCell.pos}else{if(s=Vj(r.$from),!s)return!1;i=ac(r.$from).pos}if(s.attrs.colspan==1&&s.attrs.rowspan==1)return!1;if(t){let o=s.attrs,a=[],l=o.colwidth;o.rowspan>1&&(o=Xt(o,"rowspan",1)),o.colspan>1&&(o=Xt(o,"colspan",1));let c=Cs(e),u=e.tr;for(let d=0;d<c.right-c.left;d++)a.push(l?Xt(o,"colwidth",l&&l[d]?[l[d]]:null):o);let f;for(let d=c.top;d<c.bottom;d++){let h=c.map.positionAt(d,c.left,c.table);d==c.top&&(h+=s.nodeSize);for(let p=c.left,g=0;p<c.right;p++,g++)p==c.left&&d==c.top||u.insert(f=u.mapping.map(h+c.tableStart,1),n({node:s,row:d,col:p}).createAndFill(a[g]))}u.setNodeMarkup(i,n({node:s,row:c.top,col:c.left}),a[0]),r instanceof ze&&u.setSelection(new ze(u.doc.resolve(r.$anchorCell.pos),f&&u.doc.resolve(f))),t(u)}return!0}}function w$(n,e){return function(t,r){if(!$r(t))return!1;let s=ym(t);if(s.nodeAfter.attrs[n]===e)return!1;if(r){let i=t.tr;t.selection instanceof ze?t.selection.forEachCell((o,a)=>{o.attrs[n]!==e&&i.setNodeMarkup(a,null,Xt(o.attrs,n,e))}):i.setNodeMarkup(s.pos,null,Xt(s.nodeAfter.attrs,n,e)),r(i)}return!0}}function v$(n){return function(e,t){if(!$r(e))return!1;if(t){let r=hn(e.schema),s=Cs(e),i=e.tr,o=s.map.cellsInRect(n=="column"?new oc(s.left,0,s.right,s.map.height):n=="row"?new oc(0,s.top,s.map.width,s.bottom):s),a=o.map(l=>s.table.nodeAt(l));for(let l=0;l<o.length;l++)a[l].type==r.header_cell&&i.setNodeMarkup(s.tableStart+o[l],r.cell,a[l].attrs);if(i.steps.length==0)for(let l=0;l<o.length;l++)i.setNodeMarkup(s.tableStart+o[l],r.header_cell,a[l].attrs);t(i)}return!0}}function g2(n,e,t){const r=e.map.cellsInRect({left:0,top:0,right:n=="row"?e.map.width:1,bottom:n=="column"?e.map.height:1});for(let s=0;s<r.length;s++){const i=e.table.nodeAt(r[s]);if(i&&i.type!==t.header_cell)return!1}return!0}function Vf(n,e){return e=e||{useDeprecatedLogic:!1},e.useDeprecatedLogic?v$(n):function(t,r){if(!$r(t))return!1;if(r){let s=hn(t.schema),i=Cs(t),o=t.tr,a=g2("row",i,s),l=g2("column",i,s),u=(n==="column"?a:n==="row"?l:!1)?1:0,f=n=="column"?new oc(0,u,1,i.map.height):n=="row"?new oc(u,0,i.map.width,1):i,d=n=="column"?l?s.cell:s.header_cell:n=="row"?a?s.cell:s.header_cell:s.cell;i.map.cellsInRect(f).forEach(h=>{const p=h+i.tableStart,g=o.doc.nodeAt(p);g&&o.setNodeMarkup(p,d,g.attrs)}),r(o)}return!0}}Vf("row",{useDeprecatedLogic:!0}),Vf("column",{useDeprecatedLogic:!0});let A$=Vf("cell",{useDeprecatedLogic:!0});function x$(n,e){if(e<0){let t=n.nodeBefore;if(t)return n.pos-t.nodeSize;for(let r=n.index(-1)-1,s=n.before();r>=0;r--){let i=n.node(-1).child(r);if(i.childCount)return s-1-i.lastChild.nodeSize;s-=i.nodeSize}}else{if(n.index()<n.parent.childCount-1)return n.pos+n.nodeAfter.nodeSize;let t=n.node(-1);for(let r=n.indexAfter(-1),s=n.after();r<t.childCount;r++){let i=t.child(r);if(i.childCount)return s+1;s+=i.nodeSize}}}function y2(n){return function(e,t){if(!$r(e))return!1;let r=x$(ym(e),n);if(r!=null){if(t){let s=e.doc.resolve(r);t(e.tr.setSelection(Ae.between(s,Gj(s))).scrollIntoView())}return!0}}}function E$(n,e){let t=n.selection.$anchor;for(let r=t.depth;r>0;r--)if(t.node(r).type.spec.tableRole=="table")return e&&e(n.tr.delete(t.before(r),t.after(r)).scrollIntoView()),!0;return!1}let k$=class{constructor(e,t){this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),Ew(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!=this.node.type?!1:(this.node=e,Ew(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type=="attributes"&&(e.target==this.table||this.colgroup.contains(e.target))}};function Ew(n,e,t,r,s,i){let o=0,a=!0,l=e.firstChild,c=n.firstChild;for(let u=0,f=0;u<c.childCount;u++){let{colspan:d,colwidth:h}=c.child(u).attrs;for(let p=0;p<d;p++,f++){let g=s==f?i:h&&h[p],y=g?g+"px":"";o+=g||r,g||(a=!1),l?(l.style.width!=y&&(l.style.width=y),l=l.nextSibling):e.appendChild(document.createElement("col")).style.width=y}}for(;l;){let u=l.nextSibling;l.parentNode.removeChild(l),l=u}a?(t.style.width=o+"px",t.style.minWidth=""):(t.style.width="",t.style.minWidth=o+"px")}const xr=new vt("tableColumnResizing");function C$({handleWidth:n=5,cellMinWidth:e=25,View:t=k$,lastColumnResizable:r=!0}={}){return new ut({key:xr,state:{init(i,o){return this.spec.props.nodeViews[hn(o.schema).table.name]=(a,l)=>new t(a,e,l),new Wf(-1,!1)},apply(i,o){return o.apply(i)}},props:{attributes(i){return xr.getState(i).activeHandle>-1?{class:"resize-cursor"}:null},handleDOMEvents:{mousemove(i,o){S$(i,o,n,e,r)},mouseleave(i){T$(i)},mousedown(i,o){O$(i,o,e)}},decorations(i){let o=xr.getState(i);if(o.activeHandle>-1)return I$(i,o.activeHandle)},nodeViews:{}}})}class Wf{constructor(e,t){this.activeHandle=e,this.dragging=t}apply(e){let t=this,r=e.getMeta(xr);if(r&&r.setHandle!=null)return new Wf(r.setHandle,null);if(r&&r.setDragging!==void 0)return new Wf(t.activeHandle,r.setDragging);if(t.activeHandle>-1&&e.docChanged){let s=e.mapping.map(t.activeHandle,-1);bw(e.doc.resolve(s))||(s=null),t=new Wf(s,t.dragging)}return t}}function S$(n,e,t,r,s){let i=xr.getState(n.state);if(!i.dragging){let o=M$(e.target),a=-1;if(o){let{left:l,right:c}=o.getBoundingClientRect();e.clientX-l<=t?a=b2(n,e,"left"):c-e.clientX<=t&&(a=b2(n,e,"right"))}if(a!=i.activeHandle){if(!s&&a!==-1){let l=n.state.doc.resolve(a),c=l.node(-1),u=Ot.get(c),f=l.start(-1);if(u.colCount(l.pos-f)+l.nodeAfter.attrs.colspan-1==u.width-1)return}v2(n,a)}}}function T$(n){let e=xr.getState(n.state);e.activeHandle>-1&&!e.dragging&&v2(n,-1)}function O$(n,e,t){let r=xr.getState(n.state);if(r.activeHandle==-1||r.dragging)return!1;let s=n.state.doc.nodeAt(r.activeHandle),i=N$(n,r.activeHandle,s.attrs);n.dispatch(n.state.tr.setMeta(xr,{setDragging:{startX:e.clientX,startWidth:i}}));function o(l){window.removeEventListener("mouseup",o),window.removeEventListener("mousemove",a);let c=xr.getState(n.state);c.dragging&&(R$(n,c.activeHandle,w2(c.dragging,l,t)),n.dispatch(n.state.tr.setMeta(xr,{setDragging:null})))}function a(l){if(!l.which)return o(l);let c=xr.getState(n.state),u=w2(c.dragging,l,t);P$(n,c.activeHandle,u,t)}return window.addEventListener("mouseup",o),window.addEventListener("mousemove",a),e.preventDefault(),!0}function N$(n,e,{colspan:t,colwidth:r}){let s=r&&r[r.length-1];if(s)return s;let i=n.domAtPos(e),a=i.node.childNodes[i.offset].offsetWidth,l=t;if(r)for(let c=0;c<t;c++)r[c]&&(a-=r[c],l--);return a/l}function M$(n){for(;n&&n.nodeName!="TD"&&n.nodeName!="TH";)n=n.classList.contains("ProseMirror")?null:n.parentNode;return n}function b2(n,e,t){let r=n.posAtCoords({left:e.clientX,top:e.clientY});if(!r)return-1;let{pos:s}=r,i=ac(n.state.doc.resolve(s));if(!i)return-1;if(t=="right")return i.pos;let o=Ot.get(i.node(-1)),a=i.start(-1),l=o.map.indexOf(i.pos-a);return l%o.width==0?-1:a+o.map[l-1]}function w2(n,e,t){let r=e.clientX-n.startX;return Math.max(t,n.startWidth+r)}function v2(n,e){n.dispatch(n.state.tr.setMeta(xr,{setHandle:e}))}function R$(n,e,t){let r=n.state.doc.resolve(e),s=r.node(-1),i=Ot.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan-1,l=n.state.tr;for(let c=0;c<i.height;c++){let u=c*i.width+a;if(c&&i.map[u]==i.map[u-i.width])continue;let f=i.map[u],{attrs:d}=s.nodeAt(f),h=d.colspan==1?0:a-i.colCount(f);if(d.colwidth&&d.colwidth[h]==t)continue;let p=d.colwidth?d.colwidth.slice():D$(d.colspan);p[h]=t,l.setNodeMarkup(o+f,null,Xt(d,"colwidth",p))}l.docChanged&&n.dispatch(l)}function P$(n,e,t,r){let s=n.state.doc.resolve(e),i=s.node(-1),o=s.start(-1),a=Ot.get(i).colCount(s.pos-o)+s.nodeAfter.attrs.colspan-1,l=n.domAtPos(s.start(-1)).node;for(;l.nodeName!="TABLE";)l=l.parentNode;Ew(i,l.firstChild,l,r,a,t)}function D$(n){let e=[];for(let t=0;t<n;t++)e.push(0);return e}function I$(n,e){let t=[],r=n.doc.resolve(e),s=r.node(-1),i=Ot.get(s),o=r.start(-1),a=i.colCount(r.pos-o)+r.nodeAfter.attrs.colspan;for(let l=0;l<i.height;l++){let c=a+l*i.width-1;if((a==i.width||i.map[c]!=i.map[c+1])&&(l==0||i.map[c-1]!=i.map[c-1-i.width])){let u=i.map[c],f=o+u+s.nodeAt(u).nodeSize-1,d=document.createElement("div");d.className="column-resize-handle",t.push(Ht.widget(f,d))}}return ft.create(n.doc,t)}function _$({allowTableNodeSelection:n=!1}={}){return new ut({key:ro,state:{init(){return null},apply(e,t){let r=e.getMeta(ro);if(r!=null)return r==-1?null:r;if(t==null||!e.docChanged)return t;let{deleted:s,pos:i}=e.mapping.mapResult(t);return s?null:i}},props:{decorations:Jj,handleDOMEvents:{mousedown:i$},createSelectionBetween(e){if(ro.getState(e.state)!=null)return e.state.selection},handleTripleClick:r$,handleKeyDown:n$,handlePaste:s$},appendTransaction(e,t,r){return Yj(r,u2(r,t),n)}})}function A2(n,e,t,r,s,i){var u;let o=0,a=!0,l=e.firstChild;const c=n.firstChild;if(c)for(let f=0,d=0;f<c.childCount;f+=1){const{colspan:h,colwidth:p}=c.child(f).attrs;for(let g=0;g<h;g+=1,d+=1){const y=s===d?i:p&&p[g],b=y?`${y}px`:"";o+=y||r,y||(a=!1),l?(l.style.width!==b&&(l.style.width=b),l=l.nextSibling):e.appendChild(document.createElement("col")).style.width=b}}for(;l;){const f=l.nextSibling;(u=l==null?void 0:l.parentNode)==null||u.removeChild(l),l=f}a?(t.style.width=`${o}px`,t.style.minWidth=""):(t.style.width="",t.style.minWidth=`${o}px`)}class L${constructor(e,t){j(this,"node");j(this,"cellMinWidth");j(this,"dom");j(this,"table");j(this,"colgroup");j(this,"contentDOM");this.node=e,this.cellMinWidth=t,this.dom=document.createElement("div"),this.dom.className="tableWrapper",this.table=this.dom.appendChild(document.createElement("table")),this.colgroup=this.table.appendChild(document.createElement("colgroup")),A2(e,this.colgroup,this.table,t),this.contentDOM=this.table.appendChild(document.createElement("tbody"))}update(e){return e.type!==this.node.type?!1:(this.node=e,A2(e,this.colgroup,this.table,this.cellMinWidth),!0)}ignoreMutation(e){return e.type==="attributes"&&(e.target===this.table||this.colgroup.contains(e.target))}}function x2(n,e){return n.createAndFill()}function B$(n){if(n.cached.tableNodeTypes)return n.cached.tableNodeTypes;const e={};return Object.keys(n.nodes).forEach(t=>{const r=n.nodes[t];r.spec.tableRole&&(e[r.spec.tableRole]=r)}),n.cached.tableNodeTypes=e,e}function F$(n,e,t,r,s){const i=B$(n),o=[],a=[];for(let c=0;c<t;c+=1){const u=x2(i.cell);if(u&&a.push(u),r){const f=x2(i.header_cell);f&&o.push(f)}}const l=[];for(let c=0;c<e;c+=1)l.push(i.row.createChecked(null,r&&c===0?o:a));return i.table.createChecked(null,l)}function U$(n){return n instanceof ze}const xm=({editor:n})=>{const{selection:e}=n.state;if(!U$(e))return!1;let t=0;const r=By(e.ranges[0].$from,i=>i.type.name==="table");return r==null||r.node.descendants(i=>{if(i.type.name==="table")return!1;["tableCell","tableHeader"].includes(i.type.name)&&(t+=1)}),t===e.ranges.length?(n.commands.deleteTable(),!0):!1},H$=dt.create({name:"table",addOptions(){return{HTMLAttributes:{},resizable:!1,handleWidth:5,cellMinWidth:25,View:L$,lastColumnResizable:!0,allowTableNodeSelection:!1}},content:"tableRow+",tableRole:"table",isolating:!0,group:"block",parseHTML(){return[{tag:"table"}]},renderHTML({node:n,HTMLAttributes:e}){let t=0,r=!0;try{n.content.firstChild.content.forEach(i=>{if(i.attrs.colwidth)i.attrs.colwidth.forEach(o=>{o?t+=o:(r=!1,t+=this.options.cellMinWidth)});else{r=!1;const o=i.attrs.colspan?i.attrs.colspan:1;t+=this.options.cellMinWidth*o}})}catch{r=!1}return r&&t>0?e.style=`width: ${t}px;`:t&&t>0?e.style=`min-width: ${t}px`:e.style=null,["div",{class:"table-wrapper"},["table",Ue(this.options.HTMLAttributes,e),["tbody",0]]]},addCommands(){return{insertTable:({rows:n=3,cols:e=3,withHeaderRow:t=!0}={})=>({tr:r,dispatch:s,editor:i})=>{const{selection:o}=r,a=F$(i.schema,n,e,t);if(s){const l=r.selection.anchor+1;r.replaceRangeWith(o.from-1,o.to,a).scrollIntoView().setSelection(Ae.near(r.doc.resolve(l)))}return!0},addColumnBefore:()=>({state:n,dispatch:e})=>l$(n,e),addColumnAfter:()=>({state:n,dispatch:e})=>c$(n,e),deleteColumn:()=>({state:n,dispatch:e})=>f$(n,e),addRowBefore:()=>({state:n,dispatch:e})=>h$(n,e),addRowAfter:()=>({state:n,dispatch:e})=>p$(n,e),deleteRow:()=>({state:n,dispatch:e})=>g$(n,e),deleteTable:()=>({state:n,dispatch:e})=>E$(n,e),mergeCells:()=>({state:n,dispatch:e})=>p2(n,e),splitCell:()=>({state:n,dispatch:e})=>m2(n,e),toggleHeaderColumn:()=>({state:n,dispatch:e})=>Vf("column")(n,e),toggleHeaderRow:()=>({state:n,dispatch:e})=>Vf("row")(n,e),toggleHeaderCell:()=>({state:n,dispatch:e})=>A$(n,e),mergeOrSplit:()=>({state:n,dispatch:e})=>p2(n,e)?!0:m2(n,e),setCellAttribute:(n,e)=>({state:t,dispatch:r})=>w$(n,e)(t,r),goToNextCell:()=>({state:n,dispatch:e})=>y2(1)(n,e),goToPreviousCell:()=>({state:n,dispatch:e})=>y2(-1)(n,e),fixTables:()=>({state:n,dispatch:e})=>(e&&u2(n),!0),setCellSelection:n=>({tr:e,dispatch:t})=>{if(t){const r=ze.create(e.doc,n.anchorCell,n.headCell);e.setSelection(r)}return!0}}},addKeyboardShortcuts(){return{Tab:()=>this.editor.commands.goToNextCell()?!0:this.editor.can().addRowAfter()?this.editor.chain().addRowAfter().goToNextCell().run():!1,"Shift-Tab":()=>this.editor.commands.goToPreviousCell(),Backspace:xm,"Mod-Backspace":xm,Delete:xm,"Mod-Delete":xm}},addProseMirrorPlugins(){return[...this.options.resizable&&this.editor.isEditable?[C$({handleWidth:this.options.handleWidth,cellMinWidth:this.options.cellMinWidth,View:this.options.View,lastColumnResizable:this.options.lastColumnResizable})]:[],_$({allowTableNodeSelection:this.options.allowTableNodeSelection})]},extendNodeSchema(n){const e={name:n.name,options:n.options,storage:n.storage};return{tableRole:_e(he(n,"tableRole",e))}}});function E2(n,e){if(n==null)return{};var t={},r=Object.keys(n),s,i;for(i=0;i<r.length;i++)s=r[i],!(e.indexOf(s)>=0)&&(t[s]=n[s]);return t}var k2=typeof window<"u"&&typeof document<"u";function kw(n,e){n&&(typeof n=="function"&&n(e),{}.hasOwnProperty.call(n,"current")&&(n.current=e))}function C2(){return k2&&document.createElement("div")}function j$(n){var e={"data-placement":n.placement};return n.referenceHidden&&(e["data-reference-hidden"]=""),n.escaped&&(e["data-escaped"]=""),e}function S2(n,e){if(n===e)return!0;if(typeof n=="object"&&n!=null&&typeof e=="object"&&e!=null){if(Object.keys(n).length!==Object.keys(e).length)return!1;for(var t in n)if(e.hasOwnProperty(t)){if(!S2(n[t],e[t]))return!1}else return!1;return!0}else return!1}function $$(n){var e=[];return n.forEach(function(t){e.find(function(r){return S2(t,r)})||e.push(t)}),e}function z$(n,e){var t,r;return Object.assign({},e,{popperOptions:Object.assign({},n.popperOptions,e.popperOptions,{modifiers:$$([].concat(((t=n.popperOptions)==null?void 0:t.modifiers)||[],((r=e.popperOptions)==null?void 0:r.modifiers)||[]))})})}var Cw=k2?R.useLayoutEffect:R.useEffect;function V$(n){var e=R.useRef();return e.current||(e.current=typeof n=="function"?n():n),e.current}function T2(n,e,t){t.split(/\s+/).forEach(function(r){r&&n.classList[e](r)})}var W$={name:"className",defaultValue:"",fn:function(e){var t=e.popper.firstElementChild,r=function(){var a;return!!((a=e.props.render)!=null&&a.$$tippy)};function s(){if(e.props.className&&!r()){process.env.NODE_ENV!=="production"&&console.warn(["@tippyjs/react: Cannot use `className` prop in conjunction with","`render` prop. Place the className on the element you are","rendering."].join(" "));return}T2(t,"add",e.props.className)}function i(){r()&&T2(t,"remove",e.props.className)}return{onCreate:s,onBeforeUpdate:i,onAfterUpdate:s}}};function G$(n){function e(t){var r=t.children,s=t.content,i=t.visible,o=t.singleton,a=t.render,l=t.reference,c=t.disabled,u=c===void 0?!1:c,f=t.ignoreAttributes,d=f===void 0?!0:f;t.__source,t.__self;var h=E2(t,["children","content","visible","singleton","render","reference","disabled","ignoreAttributes","__source","__self"]),p=i!==void 0,g=o!==void 0,y=R.useState(!1),b=y[0],x=y[1],v=R.useState({}),w=v[0],E=v[1],C=R.useState(),T=C[0],N=C[1],M=V$(function(){return{container:C2(),renders:1}}),O=Object.assign({ignoreAttributes:d},h,{content:M.container});p&&(process.env.NODE_ENV!=="production"&&["trigger","hideOnClick","showOnCreate"].forEach(function(J){O[J]!==void 0&&console.warn(["@tippyjs/react: Cannot specify `"+J+"` prop in","controlled mode (`visible` prop)"].join(" "))}),O.trigger="manual",O.hideOnClick=!1),g&&(u=!0);var I=O,L=O.plugins||[];a&&(I=Object.assign({},O,{plugins:g&&o.data!=null?[].concat(L,[{fn:function(){return{onTrigger:function(G,Y){var re=o.data.children.find(function(Z){var me=Z.instance;return me.reference===Y.currentTarget});G.state.$$activeSingletonInstance=re.instance,N(re.content)}}}}]):L,render:function(){return{popper:M.container}}}));var $=[l].concat(r?[r.type]:[]);return Cw(function(){var J=l;l&&l.hasOwnProperty("current")&&(J=l.current);var U=n(J||M.ref||C2(),Object.assign({},I,{plugins:[W$].concat(O.plugins||[])}));return M.instance=U,u&&U.disable(),i&&U.show(),g&&o.hook({instance:U,content:s,props:I,setSingletonContent:N}),x(!0),function(){U.destroy(),o==null||o.cleanup(U)}},$),Cw(function(){var J;if(M.renders===1){M.renders++;return}var U=M.instance;U.setProps(z$(U.props,I)),(J=U.popperInstance)==null||J.forceUpdate(),u?U.disable():U.enable(),p&&(i?U.show():U.hide()),g&&o.hook({instance:U,content:s,props:I,setSingletonContent:N})}),Cw(function(){var J;if(a){var U=M.instance;U.setProps({popperOptions:Object.assign({},U.props.popperOptions,{modifiers:[].concat((((J=U.props.popperOptions)==null?void 0:J.modifiers)||[]).filter(function(G){var Y=G.name;return Y!=="$$tippyReact"}),[{name:"$$tippyReact",enabled:!0,phase:"beforeWrite",requires:["computeStyles"],fn:function(Y){var re,Z=Y.state,me=(re=Z.modifiersData)==null?void 0:re.hide;(w.placement!==Z.placement||w.referenceHidden!==(me==null?void 0:me.isReferenceHidden)||w.escaped!==(me==null?void 0:me.hasPopperEscaped))&&E({placement:Z.placement,referenceHidden:me==null?void 0:me.isReferenceHidden,escaped:me==null?void 0:me.hasPopperEscaped}),Z.attributes.popper={}}}])})})}},[w.placement,w.referenceHidden,w.escaped].concat($)),R.createElement(R.Fragment,null,r?R.cloneElement(r,{ref:function(U){M.ref=U,kw(r.ref,U)}}):null,b&&at.createPortal(a?a(j$(w),T,M.instance):s,M.container))}return e}var K$=function(n,e){return R.forwardRef(function(r,s){var i=r.children,o=E2(r,["children"]);return R.createElement(n,Object.assign({},e,o),i?R.cloneElement(i,{ref:function(l){kw(s,l),kw(i.ref,l)}}):null)})},J$=K$(G$(Yo));const q$=[{name:"Add row above",action:n=>n.chain().focus().addRowBefore().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v7h2v-2h4v2h2v-2h4v2h2v-2h4v2h2v-7M4 14h4v3H4v-3m6 0h4v3h-4v-3m10 0v3h-4v-3h4m-9-4h2V7h3V5h-3V2h-2v3H8v2h3v3Z"})})},{name:"Add row below",action:n=>n.chain().focus().addRowAfter().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M22 10a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V3h2v2h4V3h2v2h4V3h2v2h4V3h2v7M4 10h4V7H4v3m6 0h4V7h-4v3m10 0V7h-4v3h4m-9 4h2v3h3v2h-3v3h-2v-3H8v-2h3v-3Z"})})},{name:"Add left column",action:n=>n.chain().focus().addColumnBefore().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M13 2a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h9V2h-9m7 8v4h-7v-4h7m0 6v4h-7v-4h7m0-12v4h-7V4h7M9 11H6V8H4v3H1v2h3v3h2v-3h3v-2Z"})})},{name:"Add right column",action:n=>n.chain().focus().addColumnAfter().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M11 2a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H2V2h9m-7 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m11 7h3V8h2v3h3v2h-3v3h-2v-3h-3v-2Z"})})},{name:"Remove row",action:n=>n.chain().focus().deleteRow().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M9.41 13L12 15.59L14.59 13L16 14.41L13.41 17L16 19.59L14.59 21L12 18.41L9.41 21L8 19.59L10.59 17L8 14.41L9.41 13M22 9a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V6a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v3M4 9h4V6H4v3m6 0h4V6h-4v3m6 0h4V6h-4v3Z"})})},{name:"Remove column",action:n=>n.chain().focus().deleteColumn().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M4 2h7a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h7v-4H4m0 6v4h7v-4H4M4 4v4h7V4H4m13.59 8L15 9.41L16.41 8L19 10.59L21.59 8L23 9.41L20.41 12L23 14.59L21.59 16L19 13.41L16.41 16L15 14.59L17.59 12Z"})})},{name:"Toggle header row",action:n=>n.chain().focus().toggleHeaderRow().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M22 14a2 2 0 0 1-2 2H4a2 2 0 0 1-2-2v-4a2 2 0 0 1 2-2h16a2 2 0 0 1 2 2v4M4 14h4v-4H4v4m6 0h4v-4h-4v4m6 0h4v-4h-4v4Z"})})},{name:"Toggle header column",action:n=>n.chain().focus().toggleHeaderColumn().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M8 2h8a2 2 0 0 1 2 2v16a2 2 0 0 1-2 2H8a2 2 0 0 1-2-2V4a2 2 0 0 1 2-2m0 8v4h8v-4H8m0 6v4h8v-4H8M8 4v4h8V4H8Z"})})},{name:"Toggle header cell",action:n=>n.chain().focus().toggleHeaderCell().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M21 19a1 1 0 0 1-1 1h-1v-2h2v1m-6 1v-2h2v2h-2m-4 0v-2h2v2h-2m-4 0v-2h2v2H7m-3 0a1 1 0 0 1-1-1v-1h2v2H4M19 4H5a2 2 0 0 0-2 2v2h18V6c0-1.11-.89-2-2-2M5 14H3v2h2v-2m0-4H3v2h2v-2m16 0h-2v2h2v-2m0 4h-2v2h2v-2m-10 2v-2h2v2h-2m0-4v-2h2v2h-2"})})},{name:"Remove table",action:n=>n.chain().focus().deleteTable().run(),icon:_.jsx("svg",{viewBox:"0 0 24 24",children:_.jsx("path",{fill:"currentColor",d:"M12.35 20H10v-3h2.09c.12-.72.37-1.39.72-2H10v-3h4v1.54c.58-.54 1.25-.93 2-1.19V12h4v.35c.75.26 1.42.65 2 1.19V5c0-1.1-.9-2-2-2H4c-1.1 0-2 .9-2 2v15c0 1.1.9 2 2 2h9.54c-.54-.58-.93-1.25-1.19-2M16 7h4v3h-4V7m-6 0h4v3h-4V7M8 20H4v-3h4v3m0-5H4v-3h4v3m0-5H4V7h4v3m6.46 5.88l1.42-1.42L18 16.59l2.12-2.13l1.42 1.42L19.41 18l2.13 2.12l-1.42 1.42L18 19.41l-2.12 2.13l-1.42-1.42L16.59 18l-2.13-2.12"})})}],O2=({node:n,getPos:e,selected:t,editor:r})=>{const[s,i]=R.useState(!1),o=Lh(),a=R.useRef(null),l=()=>{const{from:u,to:f}=r.state.selection,d=e(),h=d+n.nodeSize;i(d<=u&&f<=h)};R.useEffect(()=>(r.on("selectionUpdate",l),setTimeout(l,100),()=>{r.off("selectionUpdate",l)}));const c=()=>{var d,h;let u=(d=a.current)==null?void 0:d.clientTop;u&&(u+=5);let f=(h=a.current)==null?void 0:h.clientLeft;return f&&(f+=5),{top:`${u}px`,left:`${f}px`}};return _.jsxs(uf,{className:"group",children:[_.jsx(IE,{as:"span"}),(s||t)&&_.jsx(J$,{appendTo:document.body,trigger:"click",interactive:!0,animation:"shift-toward-subtle",placement:"right-start",content:_.jsx("article",{className:"dropdown",contentEditable:!1,children:_.jsx("ul",{tabIndex:0,className:"dropdown-content fixed menu menu-compact p-2 shadow bg-base-100 rounded-box w-56",style:c(),children:q$.map(u=>_.jsx("li",{children:_.jsxs("button",{type:"button",className:"button",onClick:()=>u.action(r),children:[_.jsx("span",{children:u.icon}),_.jsx("span",{children:u.name})]})},u.name))})}),children:_.jsx("label",{tabIndex:0,className:je("trigger-button",{hidden:o}),contentEditable:!1,children:_.jsx(qB,{fontSize:"small"})})})]})},Q$=dt.create({name:"tableCell",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"cell",isolating:!0,parseHTML(){return[{tag:"td"}]},renderHTML({HTMLAttributes:n}){return["td",Ue(this.options.HTMLAttributes,n),0]},addNodeView(){return Xo(O2,{as:"td",className:"relative"})}}),Y$=dt.create({name:"tableHeader",addOptions(){return{HTMLAttributes:{}}},content:"block+",addAttributes(){return{colspan:{default:1},rowspan:{default:1},colwidth:{default:null,parseHTML:n=>{const e=n.getAttribute("colwidth");return e?[parseInt(e,10)]:null}}}},tableRole:"header_cell",isolating:!0,parseHTML(){return[{tag:"th"}]},renderHTML({HTMLAttributes:n}){return["th",Ue(this.options.HTMLAttributes,n),0]},addNodeView(){return Xo(O2,{as:"th",className:"relative"})}}),N2=n=>(n.stopPropagation(),n.preventDefault(),n),X$=function(n){const e=n.scrollHeight>n.clientHeight,r=window.getComputedStyle(n).overflowY.indexOf("hidden")!==-1;return e&&!r},M2=function(n){return!n||n===document.body?document.body:X$(n)?n:M2(n.parentNode)},Sw=(n,e,t)=>{const r=document.createElement(n);if(!r)throw new Error(`Element with name ${n} can't be created.`);return e&&Object.entries(e).forEach(([s,i])=>r.setAttribute(s,i)),t&&Object.entries(t).forEach(([s,i])=>r.addEventListener(s,i)),r},Z$=dt.create({name:"tableRow",addOptions(){return{HTMLAttributes:{}}},content:"(tableCell | tableHeader)*",tableRole:"row",parseHTML(){return[{tag:"tr"}]},renderHTML({HTMLAttributes:n}){return["tr",Ue(this.options.HTMLAttributes,n),0]},addNodeView(){return({editor:n,HTMLAttributes:e,getPos:t})=>{const r=()=>t(),s=M2(n.options.element);let i=!1;const o={deleteRow:()=>{this.editor.chain().deleteNode("tableRow").focus().run()},selectRow:()=>{const b=r(),x=n.state.doc.resolve(b),v=new ye(x);n.view.dispatch(n.state.tr.setSelection(v))}},a=()=>{i=!0},l=()=>{i=!1},c=Sw("section",{class:"absolute hidden flex items-center w-2 bg-gray-200 z-50 cursor-pointer border-1 border-indigo-600 rounded-l opacity-25 hover:opacity-100",contenteditable:"false"},{click:b=>{b&&N2(b),o.selectRow()},mouseenter:()=>{a()},mouseover:()=>{a()},mouseleave:()=>{l(),d()}}),u=Sw("button",{class:"text-sm px-1 absolute -translate-x-[125%] hover:active:-translate-x-[125%] mr-2"},{click:b=>{b&&N2(b),o.deleteRow()}}),f=()=>{g(),c.classList.remove("hidden")},d=()=>{setTimeout(()=>{i||c.classList.add("hidden")},100)},h=Sw("tr",{...e},{mouseenter:f,mouseover:f,mouseleave:d});c.append(u),document.body.append(c);let p="";const g=()=>{setTimeout(()=>{const b=h.getBoundingClientRect(),x=JSON.stringify(b);p!==x&&(c.style.top=`${b.top+document.documentElement.scrollTop}px`,c.style.left=`${b.x+document.documentElement.scrollLeft-8}px`,c.style.height=`${b.height+1}px`,p=x)})};return setTimeout(()=>{g()},100),n.on("selectionUpdate",g),n.on("update",g),s==null||s.addEventListener("scroll",g),document.addEventListener("scroll",g),{dom:h,contentDOM:h,destroy:()=>{c.remove(),n.off("selectionUpdate",g),n.off("update",g),s==null||s.removeEventListener("scroll",g),document.removeEventListener("scroll",g)}}}}}),ez=[H$.configure({resizable:!0}),Q$,Y$,Z$],tz=CS.extend({content:"(dBlock|columns)+"});function R2({types:n,node:e}){return e!=null&&e.type?Array.isArray(n)&&n.includes(e.type)||e.type===n:!1}const nz=bt.create({name:"trailingNode",addOptions(){return{node:"paragraph",notAfter:["paragraph"]}},addProseMirrorPlugins(){const n=new vt(this.name),e=Object.entries(this.editor.schema.nodes).map(([,t])=>t).filter(t=>this.options.notAfter.includes(t.name));return[new ut({key:n,appendTransaction:(t,r,s)=>{const{doc:i,tr:o,schema:a}=s,l=n.getState(s),c=i.content.size,u=a.nodes[this.options.node];if(l)return o.insert(c,u.create())},state:{init:(t,r)=>{const s=r.tr.doc.lastChild;return!R2({node:s,types:e})},apply:(t,r)=>{var i,o,a;if(!t.docChanged)return r;const s=(a=(o=(i=t.doc.lastChild)==null?void 0:i.content)==null?void 0:o.content)==null?void 0:a[0];return!R2({node:s,types:e})}}})]}}),rz=({node:n,editor:e,getPos:t})=>{const[r,s]=R.useState(""),i=Lh(),o=["https://twitter.com","https://x.com"],a=()=>{switch(n.attrs.data){case"twitter":return _.jsx(JE,{});case"iframe":return _.jsx(QE,{});default:return _.jsx(iF,{})}},l=()=>{switch(n.attrs.data){case"twitter":return"Embed a Twitter tweet";case"iframe":return"Embed a video";default:return"Embed an URL"}},c=()=>{if(!r){alert("Please enter a url");return}let p=r;if(r.includes("<iframe")){const v=r.match(/src="([^"]*)"/);v&&v.length>0&&(p=v[1])}else switch(!0){case/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/.test(r):{const v=r.match(/youtu\.?be(?:\.com)?\/(?:.*v(?:\/|=)|(?:.*\/)?)([a-zA-Z0-9-_]+)/);v&&v.length>0&&(p=`https://www.youtube.com/embed/${v[1]}`);break}case/vimeo\.com\/([a-zA-Z0-9-_]+)/.test(r):{const v=r.match(/vimeo\.com\/([a-zA-Z0-9-_]+)/);v&&v.length>0&&(p=`https://player.vimeo.com/video/${v[1]}`);break}default:{alert("Please enter a valid url");return}}const g=640,y=360,b=t(),x=b+n.nodeSize;p&&(e==null||e.chain().focus(b).deleteRange({from:b,to:x}).setIframe({src:p,width:g,height:y}).run())},u=()=>{if(!r){alert("Please enter a url");return}let p=r;const g=o.some(w=>r.includes(w)),y=r.match(/\/status\/([0-9]*)/),b=y&&y.length>0;if(g&&b)p=y[1];else{alert("invalid url");return}const x=t(),v=x+n.nodeSize;p&&(e==null||e.chain().focus(x).deleteRange({from:x,to:v}).setTweetEmbed({tweetId:p}).run())},d=Kb(()=>{switch(n.attrs.data){case"twitter":u();break;default:c();break}},500);R.useEffect(()=>{r&&d()},[r]),R.useEffect(()=>{e==null||e.chain().focus()},[]);const h=R.useRef(null);return R.useEffect(()=>{var p;(p=h.current)==null||p.focus()},[]),_.jsx(uf,{as:"div",className:"flex gap-2 group w-full relative justify-center items-start",children:!i&&_.jsxs("div",{className:"relative w-full",children:[_.jsx("div",{className:"absolute inset-y-0 left-0 flex items-center pl-3 pointer-events-none",children:a()}),_.jsx("input",{ref:h,value:r,placeholder:l(),onChange:p=>s(p.target.value),onClick:p=>p.stopPropagation(),className:"bg-stone-200 p-3 pl-10 rounded-xl w-full hover:bg-stone-300 cursor-pointer transition-all ease-in-out"})]})})},sz=dt.create({name:"actionButton",group:"block",content:"block*",atom:!0,draggable:!0,addOptions(){return{HTMLAttributes:{class:"rounded-lg bg-stone-500"}}},addAttributes(){return{data:{default:null}}},addNodeView(){return Xo(rz)},parseHTML(){return[{tag:"div[data-action-node]"}]},renderHTML({HTMLAttributes:n}){return console.log("action"),["div",Ue(n,{"data-action-node":""}),0]},addCommands(){return{setActionButton:n=>({commands:e})=>e.insertContent({type:this.name,attrs:{data:n},content:[]})}}}),iz=[q6,K6.configure({strike:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bold:{HTMLAttributes:{class:"select-text pointer-events-auto"}},italic:{HTMLAttributes:{class:"select-text pointer-events-auto"}},heading:{HTMLAttributes:{class:"select-text pointer-events-auto"}},paragraph:{HTMLAttributes:{class:"select-text pointer-events-auto"}},bulletList:{HTMLAttributes:{class:"flex flex-col items-start list-disc list-outside space-y-4 ml-6"}},orderedList:{HTMLAttributes:{class:"flex flex-col items-start list-decimal list-outside space-y-4 ml-6"}},listItem:{HTMLAttributes:{class:"leading-normal"}},blockquote:{HTMLAttributes:{class:"rounded-lg bg-stone-100 p-5 font-serif italic text-stone-800"}},codeBlock:{HTMLAttributes:{class:"rounded-lg bg-transparent border border-[#DDE2E4] p-5 font-mono font-medium text-stone-800"}},code:{HTMLAttributes:{class:"rounded-md bg-stone-200 p-1.5 font-mono font-medium text-black text-sm",spellcheck:"false"}},history:!1,gapcursor:!1,dropcursor:!1,document:!1,horizontalRule:!1}),Q6.configure({types:["heading","paragraph"]}),B5,w5.configure({HTMLAttributes:{class:"text-blue-500 font-bold transition-colors cursor-pointer select-text pointer-events-auto"},openOnClick:!0}),v5.configure({placeholder:()=>"",includeChildren:!0,showOnlyCurrent:!0}),E5.configure({multicolor:!0}),L5,T5.configure({HTMLAttributes:{class:"select-text pointer-events-auto"}}),J6,H5,k5.configure({HTMLAttributes:{class:"not-prose space-y-4 ml-2"}}),S5.configure({HTMLAttributes:{class:"flex items-start"},nested:!0}),SS.configure({width:3,color:"#d1d5db"}),TS,Uj,nz,tz,...ez,q5.configure({uploadFn:pF}),U5,j5,W5,sz.extend({addInputRules(){return[P2(/^(?:twt|###|___\s|\*\*\*\s)$/,"twitter",this.type),P2(/^(?:ytb|@@@|___\s|\*\*\*\s)$/,"iframe",this.type)]}}),F5],P2=(n,e,t)=>new Qu({find:n,handler:({state:r,range:s,commands:i})=>{const o={data:e},{tr:a}=r,l=s.from,c=s.to;a.insert(l-1,t.create(o)).delete(a.mapping.map(l),a.mapping.map(c)),i.focus(c-1)}}),ga=n=>Pl((e,t)=>{n.onerror=r=>t(new Error(r.target.error)),n.onsuccess=r=>e(r.target.result)}),oz=(n,e)=>Pl((t,r)=>{const s=indexedDB.open(n);s.onupgradeneeded=i=>e(i.target.result),s.onerror=i=>r(Lr(i.target.error)),s.onsuccess=i=>{const o=i.target.result;o.onversionchange=()=>{o.close()},t(o)}}),az=n=>ga(indexedDB.deleteDatabase(n)),lz=(n,e)=>e.forEach(t=>n.createObjectStore.apply(n,t)),Gf=(n,e,t="readwrite")=>{const r=n.transaction(e,t);return e.map(s=>gz(r,s))},D2=(n,e)=>ga(n.count(e)),cz=(n,e)=>ga(n.get(e)),I2=(n,e)=>ga(n.delete(e)),uz=(n,e,t)=>ga(n.put(e,t)),Tw=(n,e)=>ga(n.add(e)),fz=(n,e,t)=>ga(n.getAll(e,t)),dz=(n,e,t)=>{let r=null;return mz(n,e,s=>(r=s,!1),t).then(()=>r)},hz=(n,e=null)=>dz(n,e,"prev"),pz=(n,e)=>Pl((t,r)=>{n.onerror=r,n.onsuccess=async s=>{const i=s.target.result;if(i===null||await e(i)===!1)return t();i.continue()}}),mz=(n,e,t,r="next")=>pz(n.openKeyCursor(e,r),s=>t(s.key)),gz=(n,e)=>n.objectStore(e),yz=(n,e)=>IDBKeyRange.upperBound(n,e),bz=(n,e)=>IDBKeyRange.lowerBound(n,e),Ow="custom",_2="updates",L2=500,B2=(n,e=()=>{},t=()=>{})=>{const[r]=Gf(n.db,[_2]);return fz(r,bz(n._dbref,!1)).then(s=>{n._destroyed||(e(r),ot(n.doc,()=>{s.forEach(i=>lC(n.doc,i))},n,!1),t(r))}).then(()=>hz(r).then(s=>{n._dbref=s+1})).then(()=>D2(r).then(s=>{n._dbsize=s})).then(()=>r)},wz=(n,e=!0)=>B2(n).then(t=>{(e||n._dbsize>=L2)&&Tw(t,J0(n.doc)).then(()=>I2(t,yz(n._dbref,!0))).then(()=>D2(t).then(r=>{n._dbsize=r}))});class vz extends w0{constructor(e,t){super(),this.doc=t,this.name=e,this._dbref=0,this._dbsize=0,this._destroyed=!1,this.db=null,this.synced=!1,this._db=oz(e,r=>lz(r,[["updates",{autoIncrement:!0}],["custom"]])),this.whenSynced=Pl(r=>this.on("synced",()=>r(this))),this._db.then(r=>{this.db=r,B2(this,o=>Tw(o,J0(t)),()=>{if(this._destroyed)return this;this.synced=!0,this.emit("synced",[this])})}),this._storeTimeout=1e3,this._storeTimeoutId=null,this._storeUpdate=(r,s)=>{if(this.db&&s!==this){const[i]=Gf(this.db,[_2]);Tw(i,r),++this._dbsize>=L2&&(this._storeTimeoutId!==null&&clearTimeout(this._storeTimeoutId),this._storeTimeoutId=setTimeout(()=>{wz(this,!1),this._storeTimeoutId=null},this._storeTimeout))}},t.on("update",this._storeUpdate),this.destroy=this.destroy.bind(this),t.on("destroy",this.destroy)}destroy(){return this._storeTimeoutId&&clearTimeout(this._storeTimeoutId),this.doc.off("update",this._storeUpdate),this.doc.off("destroy",this.destroy),this._destroyed=!0,this._db.then(e=>{e.close()})}clearData(){return this.destroy().then(()=>{az(this.name)})}get(e){return this._db.then(t=>{const[r]=Gf(t,[Ow],"readonly");return cz(r,e)})}set(e,t){return this._db.then(r=>{const[s]=Gf(r,[Ow]);return uz(s,t,e)})}del(e){return this._db.then(t=>{const[r]=Gf(t,[Ow]);return I2(r,e)})}}const Az="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA0AAAAOCAYAAAD0f5bSAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAE/SURBVHgBhVJBTsJQEH3zMcElR+gRuIF6gwYPAOwkLoQTUE6ArEA3xbWJ4gnQE8gNwBuwhMR2fPNLk9o0ZZImM/P/e39e3wgqojPXXiPFJnFovw1kWT53xSKca3C70LXlr/eySYFdZ6Fb61eCePnBCb6VF3P21UA+WX+wv+086fgfyMbh4aPlqWJSZH2/k6EINlBEJI6tdxHG2tIDrsUqxYzsO5Qi+UXfNfwUPT7w49wRU1EyZWNFqIgV9REw84Wga+P1Uj7PsW5QE9pEZMT8Aq+JQmNcYl8HwgEtEvf9fc3RR4zrMCRe84WA6dJRz8upPwyftV0FOP3ugHqu0iZGzsSbF3bYUMRlgDdWMcyE4WvVl73XRC9CNiaqaHMDpkUQrYh8kmKUmy5lVpvdBNs2mOk0tptk9a5AVKHhzML+AZaSjR/r++n9AAAAAElFTkSuQmCC",xz="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAA4AAAAOCAYAAAAfSC3RAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAEjSURBVHgBjZJBToNQEIb/NzTeoMbGjTeoN5Au1S7wBrqwyk5OoD1B46pRF9UbsEBc9nmEHsI08QhGZnxMpaGUEv4EwoP/mxnyj0GNTp++AoPORA+Gx+mo91r1mOJh+LL0WYwDqC8i/obJGCuSfRJ1bHLdtWtQIaY5WoiYBknYtZQfmOGjpTIvC7TAahTvpMksmUQCvK0A6itzNl1egmi2k2K+2gPsD+mvHGkh4MIVoPuSLYbIYxOk3YAJVRuktwd3DhjvggqRB0Slc3D+/D1Lw95DE5Rnq3E487ySXeyu4zooz/R9tD/QUYV5Ufke1HbKvW4RdFS9icRoKeKO1c7Fi+HUbQ/BzzPdXjmxDCy8TOIk7G2CZf1nqzEJfqOPm8Otif4AFnp3K1F5HHAAAAAASUVORK5CYII=",Ez=n=>{const e=document.createElement("span");e.classList.add("collaboration-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");return t.classList.add("collaboration-cursor__label"),t.setAttribute("style",`background-color: ${n.color}`),t.insertBefore(document.createTextNode(n.name),null),e.insertBefore(t,null),e},kz=n=>{const e=document.createElement("span");e.classList.add("custom-cursor__caret"),e.setAttribute("style",`border-color: ${n.color}`);const t=document.createElement("div");t.classList.add("custom-cursor__label-container"),t.setAttribute("style",`border: 1px solid ${n.color}`);const r=document.createElement("img");r.src=Az,r.classList.add("custom-cursor__icon");const s=document.createElement("div");s.classList.add("custom-cursor__label");const i=document.createElement("span");i.classList.add("custom-cursor__text"),i.textContent=n.name;const o=document.createElement("img");return o.src=xz,o.classList.add("custom-cursor__badge"),s.appendChild(i),t.appendChild(r),t.appendChild(s),t.appendChild(o),e.appendChild(t),e},Cz=n=>n.isEns?kz(n):Ez(n),Sz="6.13.1";function Tz(n,e,t){const r=e.split("|").map(i=>i.trim());for(let i=0;i<r.length;i++)switch(e){case"any":return;case"bigint":case"boolean":case"number":case"string":if(typeof n===e)return}const s=new Error(`invalid value for type ${e}`);throw s.code="INVALID_ARGUMENT",s.argument=`value.${t}`,s.value=n,s}async function pn(n){const e=Object.keys(n);return(await Promise.all(e.map(r=>Promise.resolve(n[r])))).reduce((r,s,i)=>(r[e[i]]=s,r),{})}function be(n,e,t){for(let r in e){let s=e[r];const i=t?t[r]:null;i&&Tz(s,i,r),Object.defineProperty(n,r,{enumerable:!0,value:s,writable:!1})}}function lc(n){if(n==null)return"null";if(Array.isArray(n))return"[ "+n.map(lc).join(", ")+" ]";if(n instanceof Uint8Array){const e="0123456789abcdef";let t="0x";for(let r=0;r<n.length;r++)t+=e[n[r]>>4],t+=e[n[r]&15];return t}if(typeof n=="object"&&typeof n.toJSON=="function")return lc(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":return BigInt(n).toString();case"number":return n.toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{ "+e.map(t=>`${lc(t)}: ${lc(n[t])}`).join(", ")+" }"}}return"[ COULD NOT SERIALIZE ]"}function Zt(n,e){return n&&n.code===e}function Nw(n){return Zt(n,"CALL_EXCEPTION")}function wt(n,e,t){let r=n;{const i=[];if(t){if("message"in t||"code"in t||"name"in t)throw new Error(`value will overwrite populated values: ${lc(t)}`);for(const o in t){if(o==="shortMessage")continue;const a=t[o];i.push(o+"="+lc(a))}}i.push(`code=${e}`),i.push(`version=${Sz}`),i.length&&(n+=" ("+i.join(", ")+")")}let s;switch(e){case"INVALID_ARGUMENT":s=new TypeError(n);break;case"NUMERIC_FAULT":case"BUFFER_OVERRUN":s=new RangeError(n);break;default:s=new Error(n)}return be(s,{code:e}),t&&Object.assign(s,t),s.shortMessage==null&&be(s,{shortMessage:r}),s}function X(n,e,t,r){if(!n)throw wt(e,t,r)}function H(n,e,t,r){X(n,e,"INVALID_ARGUMENT",{argument:t,value:r})}function F2(n,e,t){t==null&&(t=""),t&&(t=": "+t),X(n>=e,"missing arguemnt"+t,"MISSING_ARGUMENT",{count:n,expectedCount:e}),X(n<=e,"too many arguments"+t,"UNEXPECTED_ARGUMENT",{count:n,expectedCount:e})}["NFD","NFC","NFKD","NFKC"].reduce((n,e)=>{try{if("test".normalize(e)!=="test")throw new Error("bad");if(e==="NFD"&&"é".normalize("NFD")!=="é")throw new Error("broken");n.push(e)}catch{}return n},[]);function Em(n,e,t){if(t==null&&(t=""),n!==e){let r=t,s="new";t&&(r+=".",s+=" "+t),X(!1,`private constructor; use ${r}from* methods`,"UNSUPPORTED_OPERATION",{operation:s})}}function U2(n,e,t){if(n instanceof Uint8Array)return t?new Uint8Array(n):n;if(typeof n=="string"&&n.match(/^0x(?:[0-9a-f][0-9a-f])*$/i)){const r=new Uint8Array((n.length-2)/2);let s=2;for(let i=0;i<r.length;i++)r[i]=parseInt(n.substring(s,s+2),16),s+=2;return r}H(!1,"invalid BytesLike value",e||"value",n)}function qe(n,e){return U2(n,e,!1)}function Cn(n,e){return U2(n,e,!0)}function pt(n,e){return!(typeof n!="string"||!n.match(/^0x[0-9A-Fa-f]*$/)||typeof e=="number"&&n.length!==2+2*e||e===!0&&n.length%2!==0)}function Mw(n){return pt(n,!0)||n instanceof Uint8Array}const H2="0123456789abcdef";function ce(n){const e=qe(n);let t="0x";for(let r=0;r<e.length;r++){const s=e[r];t+=H2[(s&240)>>4]+H2[s&15]}return t}function Rt(n){return"0x"+n.map(e=>ce(e).substring(2)).join("")}function cc(n){return pt(n,!0)?(n.length-2)/2:qe(n).length}function Nt(n,e,t){const r=qe(n);return t!=null&&t>r.length&&X(!1,"cannot slice beyond data bounds","BUFFER_OVERRUN",{buffer:r,length:r.length,offset:t}),ce(r.slice(e??0,t??r.length))}function j2(n,e,t){const r=qe(n);X(e>=r.length,"padding exceeds data length","BUFFER_OVERRUN",{buffer:new Uint8Array(r),length:e,offset:e+1});const s=new Uint8Array(e);return s.fill(0),t?s.set(r,e-r.length):s.set(r,0),ce(s)}function ya(n,e){return j2(n,e,!0)}function Oz(n,e){return j2(n,e,!1)}const km=BigInt(0),zr=BigInt(1),uc=9007199254740991;function Nz(n,e){const t=Cm(n,"value"),r=BigInt(Pe(e,"width"));if(X(t>>r===km,"overflow","NUMERIC_FAULT",{operation:"fromTwos",fault:"overflow",value:n}),t>>r-zr){const s=(zr<<r)-zr;return-((~t&s)+zr)}return t}function $2(n,e){let t=pe(n,"value");const r=BigInt(Pe(e,"width")),s=zr<<r-zr;if(t<km){t=-t,X(t<=s,"too low","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});const i=(zr<<r)-zr;return(~t&i)+zr}else X(t<s,"too high","NUMERIC_FAULT",{operation:"toTwos",fault:"overflow",value:n});return t}function Kf(n,e){const t=Cm(n,"value"),r=BigInt(Pe(e,"bits"));return t&(zr<<r)-zr}function pe(n,e){switch(typeof n){case"bigint":return n;case"number":return H(Number.isInteger(n),"underflow",e||"value",n),H(n>=-uc&&n<=uc,"overflow",e||"value",n),BigInt(n);case"string":try{if(n==="")throw new Error("empty string");return n[0]==="-"&&n[1]!=="-"?-BigInt(n.substring(1)):BigInt(n)}catch(t){H(!1,`invalid BigNumberish string: ${t.message}`,e||"value",n)}}H(!1,"invalid BigNumberish value",e||"value",n)}function Cm(n,e){const t=pe(n,e);return X(t>=km,"unsigned value cannot be negative","NUMERIC_FAULT",{fault:"overflow",operation:"getUint",value:n}),t}const z2="0123456789abcdef";function Rw(n){if(n instanceof Uint8Array){let e="0x0";for(const t of n)e+=z2[t>>4],e+=z2[t&15];return BigInt(e)}return pe(n)}function Pe(n,e){switch(typeof n){case"bigint":return H(n>=-uc&&n<=uc,"overflow",e||"value",n),Number(n);case"number":return H(Number.isInteger(n),"underflow",e||"value",n),H(n>=-uc&&n<=uc,"overflow",e||"value",n),n;case"string":try{if(n==="")throw new Error("empty string");return Pe(BigInt(n),e)}catch(t){H(!1,`invalid numeric string: ${t.message}`,e||"value",n)}}H(!1,"invalid numeric value",e||"value",n)}function Mz(n){return Pe(Rw(n))}function so(n,e){let r=Cm(n,"value").toString(16);if(e==null)r.length%2&&(r="0"+r);else{const s=Pe(e,"width");for(X(s*2>=r.length,`value exceeds width (${s} bytes)`,"NUMERIC_FAULT",{operation:"toBeHex",fault:"overflow",value:n});r.length<s*2;)r="0"+r}return"0x"+r}function Sn(n){const e=Cm(n,"value");if(e===km)return new Uint8Array([]);let t=e.toString(16);t.length%2&&(t="0"+t);const r=new Uint8Array(t.length/2);for(let s=0;s<r.length;s++){const i=s*2;r[s]=parseInt(t.substring(i,i+2),16)}return r}function ba(n){let e=ce(Mw(n)?n:Sn(n)).substring(2);for(;e.startsWith("0");)e=e.substring(1);return e===""&&(e="0"),"0x"+e}const V2="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";BigInt(0);const W2=BigInt(58);function Rz(n){const e=qe(n);let t=Rw(e),r="";for(;t;)r=V2[Number(t%W2)]+r,t/=W2;for(let s=0;s<e.length&&!e[s];s++)r=V2[0]+r;return r}function Pz(n){n=atob(n);const e=new Uint8Array(n.length);for(let t=0;t<n.length;t++)e[t]=n.charCodeAt(t);return qe(e)}function Dz(n){const e=qe(n);let t="";for(let r=0;r<e.length;r++)t+=String.fromCharCode(e[r]);return btoa(t)}class G2{constructor(e,t,r){j(this,"filter");j(this,"emitter");W(this,Mc,void 0);D(this,Mc,t),be(this,{emitter:e,filter:r})}async removeListener(){k(this,Mc)!=null&&await this.emitter.off(this.filter,k(this,Mc))}}Mc=new WeakMap;function Iz(n,e,t,r,s){H(!1,`invalid codepoint at offset ${e}; ${n}`,"bytes",t)}function K2(n,e,t,r,s){if(n==="BAD_PREFIX"||n==="UNEXPECTED_CONTINUE"){let i=0;for(let o=e+1;o<t.length&&t[o]>>6===2;o++)i++;return i}return n==="OVERRUN"?t.length-e-1:0}function _z(n,e,t,r,s){return n==="OVERLONG"?(H(typeof s=="number","invalid bad code point for replacement","badCodepoint",s),r.push(s),0):(r.push(65533),K2(n,e,t))}const Lz=Object.freeze({error:Iz,ignore:K2,replace:_z});function Bz(n,e){e==null&&(e=Lz.error);const t=qe(n,"bytes"),r=[];let s=0;for(;s<t.length;){const i=t[s++];if(!(i>>7)){r.push(i);continue}let o=null,a=null;if((i&224)===192)o=1,a=127;else if((i&240)===224)o=2,a=2047;else if((i&248)===240)o=3,a=65535;else{(i&192)===128?s+=e("UNEXPECTED_CONTINUE",s-1,t,r):s+=e("BAD_PREFIX",s-1,t,r);continue}if(s-1+o>=t.length){s+=e("OVERRUN",s-1,t,r);continue}let l=i&(1<<8-o-1)-1;for(let c=0;c<o;c++){let u=t[s];if((u&192)!=128){s+=e("MISSING_CONTINUE",s,t,r),l=null;break}l=l<<6|u&63,s++}if(l!==null){if(l>1114111){s+=e("OUT_OF_RANGE",s-1-o,t,r,l);continue}if(l>=55296&&l<=57343){s+=e("UTF16_SURROGATE",s-1-o,t,r,l);continue}if(l<=a){s+=e("OVERLONG",s-1-o,t,r,l);continue}r.push(l)}}return r}function ri(n,e){H(typeof n=="string","invalid string value","str",n);let t=[];for(let r=0;r<n.length;r++){const s=n.charCodeAt(r);if(s<128)t.push(s);else if(s<2048)t.push(s>>6|192),t.push(s&63|128);else if((s&64512)==55296){r++;const i=n.charCodeAt(r);H(r<n.length&&(i&64512)===56320,"invalid surrogate pair","str",n);const o=65536+((s&1023)<<10)+(i&1023);t.push(o>>18|240),t.push(o>>12&63|128),t.push(o>>6&63|128),t.push(o&63|128)}else t.push(s>>12|224),t.push(s>>6&63|128),t.push(s&63|128)}return new Uint8Array(t)}function Fz(n){return n.map(e=>e<=65535?String.fromCharCode(e):(e-=65536,String.fromCharCode((e>>10&1023)+55296,(e&1023)+56320))).join("")}function fc(n,e){return Fz(Bz(n,e))}function J2(n){async function e(t,r){X(r==null||!r.cancelled,"request cancelled before sending","CANCELLED");const s=t.url.split(":")[0].toLowerCase();X(s==="http"||s==="https",`unsupported protocol ${s}`,"UNSUPPORTED_OPERATION",{info:{protocol:s},operation:"request"}),X(s==="https"||!t.credentials||t.allowInsecureAuthentication,"insecure authorized connections unsupported","UNSUPPORTED_OPERATION",{operation:"request"});let i=null;const o=new AbortController,a=setTimeout(()=>{i=wt("request timeout","TIMEOUT"),o.abort()},t.timeout);r&&r.addListener(()=>{i=wt("request cancelled","CANCELLED"),o.abort()});const l={method:t.method,headers:new Headers(Array.from(t)),body:t.body||void 0,signal:o.signal};let c;try{c=await fetch(t.url,l)}catch(h){throw clearTimeout(a),i||h}clearTimeout(a);const u={};c.headers.forEach((h,p)=>{u[p.toLowerCase()]=h});const f=await c.arrayBuffer(),d=f==null?null:new Uint8Array(f);return{statusCode:c.status,statusMessage:c.statusText,headers:u,body:d}}return e}const Uz=12,Hz=250;let q2=J2();const jz=new RegExp("^data:([^;:]*)?(;base64)?,(.*)$","i"),$z=new RegExp("^ipfs://(ipfs/)?(.*)$","i");let Pw=!1;async function Q2(n,e){try{const t=n.match(jz);if(!t)throw new Error("invalid data");return new io(200,"OK",{"content-type":t[1]||"text/plain"},t[2]?Pz(t[3]):Vz(t[3]))}catch{return new io(599,"BAD REQUEST (invalid data: URI)",{},null,new Tn(n))}}function Y2(n){async function e(t,r){try{const s=t.match($z);if(!s)throw new Error("invalid link");return new Tn(`${n}${s[2]}`)}catch{return new io(599,"BAD REQUEST (invalid IPFS URI)",{},null,new Tn(t))}}return e}const Sm={data:Q2,ipfs:Y2("https://gateway.ipfs.io/ipfs/")},X2=new WeakMap;class zz{constructor(e){W(this,Pa,void 0);W(this,po,void 0);D(this,Pa,[]),D(this,po,!1),X2.set(e,()=>{if(!k(this,po)){D(this,po,!0);for(const t of k(this,Pa))setTimeout(()=>{t()},0);D(this,Pa,[])}})}addListener(e){X(!k(this,po),"singal already cancelled","UNSUPPORTED_OPERATION",{operation:"fetchCancelSignal.addCancelListener"}),k(this,Pa).push(e)}get cancelled(){return k(this,po)}checkSignal(){X(!this.cancelled,"cancelled","CANCELLED",{})}}Pa=new WeakMap,po=new WeakMap;function Tm(n){if(n==null)throw new Error("missing signal; should not happen");return n.checkSignal(),n}const yg=class yg{constructor(e){W(this,La);W(this,Rc,void 0);W(this,Pc,void 0);W(this,Jr,void 0);W(this,di,void 0);W(this,Dc,void 0);W(this,Ic,void 0);W(this,nn,void 0);W(this,ir,void 0);W(this,hi,void 0);W(this,Da,void 0);W(this,Ia,void 0);W(this,_a,void 0);W(this,Ns,void 0);W(this,qr,void 0);W(this,mo,void 0);D(this,Ic,String(e)),D(this,Rc,!1),D(this,Pc,!0),D(this,Jr,{}),D(this,di,""),D(this,Dc,3e5),D(this,qr,{slotInterval:Hz,maxAttempts:Uz}),D(this,mo,null)}get url(){return k(this,Ic)}set url(e){D(this,Ic,String(e))}get body(){return k(this,nn)==null?null:new Uint8Array(k(this,nn))}set body(e){if(e==null)D(this,nn,void 0),D(this,ir,void 0);else if(typeof e=="string")D(this,nn,ri(e)),D(this,ir,"text/plain");else if(e instanceof Uint8Array)D(this,nn,e),D(this,ir,"application/octet-stream");else if(typeof e=="object")D(this,nn,ri(JSON.stringify(e))),D(this,ir,"application/json");else throw new Error("invalid body")}hasBody(){return k(this,nn)!=null}get method(){return k(this,di)?k(this,di):this.hasBody()?"POST":"GET"}set method(e){e==null&&(e=""),D(this,di,String(e).toUpperCase())}get headers(){const e=Object.assign({},k(this,Jr));return k(this,hi)&&(e.authorization=`Basic ${Dz(ri(k(this,hi)))}`),this.allowGzip&&(e["accept-encoding"]="gzip"),e["content-type"]==null&&k(this,ir)&&(e["content-type"]=k(this,ir)),this.body&&(e["content-length"]=String(this.body.length)),e}getHeader(e){return this.headers[e.toLowerCase()]}setHeader(e,t){k(this,Jr)[String(e).toLowerCase()]=String(t)}clearHeaders(){D(this,Jr,{})}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let r=0;return{next:()=>{if(r<t.length){const s=t[r++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}get credentials(){return k(this,hi)||null}setCredentials(e,t){H(!e.match(/:/),"invalid basic authentication username","username","[REDACTED]"),D(this,hi,`${e}:${t}`)}get allowGzip(){return k(this,Pc)}set allowGzip(e){D(this,Pc,!!e)}get allowInsecureAuthentication(){return!!k(this,Rc)}set allowInsecureAuthentication(e){D(this,Rc,!!e)}get timeout(){return k(this,Dc)}set timeout(e){H(e>=0,"timeout must be non-zero","timeout",e),D(this,Dc,e)}get preflightFunc(){return k(this,Da)||null}set preflightFunc(e){D(this,Da,e)}get processFunc(){return k(this,Ia)||null}set processFunc(e){D(this,Ia,e)}get retryFunc(){return k(this,_a)||null}set retryFunc(e){D(this,_a,e)}get getUrlFunc(){return k(this,mo)||q2}set getUrlFunc(e){D(this,mo,e)}toString(){return`<FetchRequest method=${JSON.stringify(this.method)} url=${JSON.stringify(this.url)} headers=${JSON.stringify(this.headers)} body=${k(this,nn)?ce(k(this,nn)):"null"}>`}setThrottleParams(e){e.slotInterval!=null&&(k(this,qr).slotInterval=e.slotInterval),e.maxAttempts!=null&&(k(this,qr).maxAttempts=e.maxAttempts)}send(){return X(k(this,Ns)==null,"request already sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.send"}),D(this,Ns,new zz(this)),ie(this,La,jd).call(this,0,Z2()+this.timeout,0,this,new io(0,"",{},null,this))}cancel(){X(k(this,Ns)!=null,"request has not been sent","UNSUPPORTED_OPERATION",{operation:"fetchRequest.cancel"});const e=X2.get(this);if(!e)throw new Error("missing signal; should not happen");e()}redirect(e){const t=this.url.split(":")[0].toLowerCase(),r=e.split(":")[0].toLowerCase();X(this.method==="GET"&&(t!=="https"||r!=="http")&&e.match(/^https?:/),"unsupported redirect","UNSUPPORTED_OPERATION",{operation:`redirect(${this.method} ${JSON.stringify(this.url)} => ${JSON.stringify(e)})`});const s=new yg(e);return s.method="GET",s.allowGzip=this.allowGzip,s.timeout=this.timeout,D(s,Jr,Object.assign({},k(this,Jr))),k(this,nn)&&D(s,nn,new Uint8Array(k(this,nn))),D(s,ir,k(this,ir)),s}clone(){const e=new yg(this.url);return D(e,di,k(this,di)),k(this,nn)&&D(e,nn,k(this,nn)),D(e,ir,k(this,ir)),D(e,Jr,Object.assign({},k(this,Jr))),D(e,hi,k(this,hi)),this.allowGzip&&(e.allowGzip=!0),e.timeout=this.timeout,this.allowInsecureAuthentication&&(e.allowInsecureAuthentication=!0),D(e,Da,k(this,Da)),D(e,Ia,k(this,Ia)),D(e,_a,k(this,_a)),D(e,qr,Object.assign({},k(this,qr))),D(e,mo,k(this,mo)),e}static lockConfig(){Pw=!0}static getGateway(e){return Sm[e.toLowerCase()]||null}static registerGateway(e,t){if(e=e.toLowerCase(),e==="http"||e==="https")throw new Error(`cannot intercept ${e}; use registerGetUrl`);if(Pw)throw new Error("gateways locked");Sm[e]=t}static registerGetUrl(e){if(Pw)throw new Error("gateways locked");q2=e}static createGetUrlFunc(e){return J2()}static createDataGateway(){return Q2}static createIpfsGatewayFunc(e){return Y2(e)}};Rc=new WeakMap,Pc=new WeakMap,Jr=new WeakMap,di=new WeakMap,Dc=new WeakMap,Ic=new WeakMap,nn=new WeakMap,ir=new WeakMap,hi=new WeakMap,Da=new WeakMap,Ia=new WeakMap,_a=new WeakMap,Ns=new WeakMap,qr=new WeakMap,mo=new WeakMap,La=new WeakSet,jd=async function(e,t,r,s,i){var u,f,d;if(e>=k(this,qr).maxAttempts)return i.makeServerError("exceeded maximum retry limit");X(Z2()<=t,"timeout","TIMEOUT",{operation:"request.send",reason:"timeout",request:s}),r>0&&await Wz(r);let o=this.clone();const a=(o.url.split(":")[0]||"").toLowerCase();if(a in Sm){const h=await Sm[a](o.url,Tm(k(s,Ns)));if(h instanceof io){let p=h;if(this.processFunc){Tm(k(s,Ns));try{p=await this.processFunc(o,p)}catch(g){(g.throttle==null||typeof g.stall!="number")&&p.makeServerError("error in post-processing function",g).assertOk()}}return p}o=h}this.preflightFunc&&(o=await this.preflightFunc(o));const l=await this.getUrlFunc(o,Tm(k(s,Ns)));let c=new io(l.statusCode,l.statusMessage,l.headers,l.body,s);if(c.statusCode===301||c.statusCode===302){try{const h=c.headers.location||"";return ie(u=o.redirect(h),La,jd).call(u,e+1,t,0,s,c)}catch{}return c}else if(c.statusCode===429&&(this.retryFunc==null||await this.retryFunc(o,c,e))){const h=c.headers["retry-after"];let p=k(this,qr).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return typeof h=="string"&&h.match(/^[1-9][0-9]*$/)&&(p=parseInt(h)),ie(f=o.clone(),La,jd).call(f,e+1,t,p,s,c)}if(this.processFunc){Tm(k(s,Ns));try{c=await this.processFunc(o,c)}catch(h){(h.throttle==null||typeof h.stall!="number")&&c.makeServerError("error in post-processing function",h).assertOk();let p=k(this,qr).slotInterval*Math.trunc(Math.random()*Math.pow(2,e));return h.stall>=0&&(p=h.stall),ie(d=o.clone(),La,jd).call(d,e+1,t,p,s,c)}}return c};let Tn=yg;const Wv=class Wv{constructor(e,t,r,s,i){W(this,yd,void 0);W(this,bd,void 0);W(this,wd,void 0);W(this,or,void 0);W(this,_c,void 0);W(this,Ba,void 0);D(this,yd,e),D(this,bd,t),D(this,wd,Object.keys(r).reduce((o,a)=>(o[a.toLowerCase()]=String(r[a]),o),{})),D(this,or,s==null?null:new Uint8Array(s)),D(this,_c,i||null),D(this,Ba,{message:""})}toString(){return`<FetchResponse status=${this.statusCode} body=${k(this,or)?ce(k(this,or)):"null"}>`}get statusCode(){return k(this,yd)}get statusMessage(){return k(this,bd)}get headers(){return Object.assign({},k(this,wd))}get body(){return k(this,or)==null?null:new Uint8Array(k(this,or))}get bodyText(){try{return k(this,or)==null?"":fc(k(this,or))}catch{X(!1,"response body is not valid UTF-8 data","UNSUPPORTED_OPERATION",{operation:"bodyText",info:{response:this}})}}get bodyJson(){try{return JSON.parse(this.bodyText)}catch{X(!1,"response body is not valid JSON","UNSUPPORTED_OPERATION",{operation:"bodyJson",info:{response:this}})}}[Symbol.iterator](){const e=this.headers,t=Object.keys(e);let r=0;return{next:()=>{if(r<t.length){const s=t[r++];return{value:[s,e[s]],done:!1}}return{value:void 0,done:!0}}}}makeServerError(e,t){let r;e?r=`CLIENT ESCALATED SERVER ERROR (${this.statusCode} ${this.statusMessage}; ${e})`:(e=`${this.statusCode} ${this.statusMessage}`,r=`CLIENT ESCALATED SERVER ERROR (${e})`);const s=new Wv(599,r,this.headers,this.body,k(this,_c)||void 0);return D(s,Ba,{message:e,error:t}),s}throwThrottleError(e,t){t==null?t=-1:H(Number.isInteger(t)&&t>=0,"invalid stall timeout","stall",t);const r=new Error(e||"throttling requests");throw be(r,{stall:t,throttle:!0}),r}getHeader(e){return this.headers[e.toLowerCase()]}hasBody(){return k(this,or)!=null}get request(){return k(this,_c)}ok(){return k(this,Ba).message===""&&this.statusCode>=200&&this.statusCode<300}assertOk(){if(this.ok())return;let{message:e,error:t}=k(this,Ba);e===""&&(e=`server response ${this.statusCode} ${this.statusMessage}`);let r=null;this.request&&(r=this.request.url);let s=null;try{k(this,or)&&(s=fc(k(this,or)))}catch{}X(!1,e,"SERVER_ERROR",{request:this.request||"unknown request",response:this,error:t,info:{requestUrl:r,responseBody:s,responseStatus:`${this.statusCode} ${this.statusMessage}`}})}};yd=new WeakMap,bd=new WeakMap,wd=new WeakMap,or=new WeakMap,_c=new WeakMap,Ba=new WeakMap;let io=Wv;function Z2(){return new Date().getTime()}function Vz(n){return ri(n.replace(/%([0-9a-f][0-9a-f])/gi,(e,t)=>String.fromCharCode(parseInt(t,16))))}function Wz(n){return new Promise(e=>setTimeout(e,n))}function Gz(n){let e=n.toString(16);for(;e.length<2;)e="0"+e;return"0x"+e}function eO(n,e,t){let r=0;for(let s=0;s<t;s++)r=r*256+n[e+s];return r}function tO(n,e,t,r){const s=[];for(;t<e+1+r;){const i=nO(n,t);s.push(i.result),t+=i.consumed,X(t<=e+1+r,"child data too short","BUFFER_OVERRUN",{buffer:n,length:r,offset:e})}return{consumed:1+r,result:s}}function nO(n,e){X(n.length!==0,"data too short","BUFFER_OVERRUN",{buffer:n,length:0,offset:1});const t=r=>{X(r<=n.length,"data short segment too short","BUFFER_OVERRUN",{buffer:n,length:n.length,offset:r})};if(n[e]>=248){const r=n[e]-247;t(e+1+r);const s=eO(n,e+1,r);return t(e+1+r+s),tO(n,e,e+1+r,r+s)}else if(n[e]>=192){const r=n[e]-192;return t(e+1+r),tO(n,e,e+1,r)}else if(n[e]>=184){const r=n[e]-183;t(e+1+r);const s=eO(n,e+1,r);t(e+1+r+s);const i=ce(n.slice(e+1+r,e+1+r+s));return{consumed:1+r+s,result:i}}else if(n[e]>=128){const r=n[e]-128;t(e+1+r);const s=ce(n.slice(e+1,e+1+r));return{consumed:1+r,result:s}}return{consumed:1,result:Gz(n[e])}}function Om(n){const e=qe(n,"data"),t=nO(e,0);return H(t.consumed===e.length,"unexpected junk after rlp payload","data",n),t.result}function rO(n){const e=[];for(;n;)e.unshift(n&255),n>>=8;return e}function sO(n){if(Array.isArray(n)){let r=[];if(n.forEach(function(i){r=r.concat(sO(i))}),r.length<=55)return r.unshift(192+r.length),r;const s=rO(r.length);return s.unshift(247+s.length),s.concat(r)}const e=Array.prototype.slice.call(qe(n,"object"));if(e.length===1&&e[0]<=127)return e;if(e.length<=55)return e.unshift(128+e.length),e;const t=rO(e.length);return t.unshift(183+t.length),t.concat(e)}const iO="0123456789abcdef";function wa(n){let e="0x";for(const t of sO(n))e+=iO[t>>4],e+=iO[t&15];return e}const On=32,Dw=new Uint8Array(On),Kz=["then"],Nm={},oO=new WeakMap;function va(n){return oO.get(n)}function aO(n,e){oO.set(n,e)}function Jf(n,e){const t=new Error(`deferred error during ABI decoding triggered accessing ${n}`);throw t.error=e,t}function Iw(n,e,t){return n.indexOf(null)>=0?e.map((r,s)=>r instanceof dc?Iw(va(r),r,t):r):n.reduce((r,s,i)=>{let o=e.getValue(s);return s in r||(t&&o instanceof dc&&(o=Iw(va(o),o,t)),r[s]=o),r},{})}const Bc=class Bc extends Array{constructor(...t){const r=t[0];let s=t[1],i=(t[2]||[]).slice(),o=!0;r!==Nm&&(s=t,i=[],o=!1);super(s.length);W(this,Lc,void 0);s.forEach((c,u)=>{this[u]=c});const a=i.reduce((c,u)=>(typeof u=="string"&&c.set(u,(c.get(u)||0)+1),c),new Map);if(aO(this,Object.freeze(s.map((c,u)=>{const f=i[u];return f!=null&&a.get(f)===1?f:null}))),D(this,Lc,[]),k(this,Lc)==null&&k(this,Lc),!o)return;Object.freeze(this);const l=new Proxy(this,{get:(c,u,f)=>{if(typeof u=="string"){if(u.match(/^[0-9]+$/)){const h=Pe(u,"%index");if(h<0||h>=this.length)throw new RangeError("out of result range");const p=c[h];return p instanceof Error&&Jf(`index ${h}`,p),p}if(Kz.indexOf(u)>=0)return Reflect.get(c,u,f);const d=c[u];if(d instanceof Function)return function(...h){return d.apply(this===f?c:this,h)};if(!(u in c))return c.getValue.apply(this===f?c:this,[u])}return Reflect.get(c,u,f)}});return aO(l,va(this)),l}toArray(t){const r=[];return this.forEach((s,i)=>{s instanceof Error&&Jf(`index ${i}`,s),t&&s instanceof Bc&&(s=s.toArray(t)),r.push(s)}),r}toObject(t){const r=va(this);return r.reduce((s,i,o)=>(X(i!=null,`value at index ${o} unnamed`,"UNSUPPORTED_OPERATION",{operation:"toObject()"}),Iw(r,this,t)),{})}slice(t,r){t==null&&(t=0),t<0&&(t+=this.length,t<0&&(t=0)),r==null&&(r=this.length),r<0&&(r+=this.length,r<0&&(r=0)),r>this.length&&(r=this.length);const s=va(this),i=[],o=[];for(let a=t;a<r;a++)i.push(this[a]),o.push(s[a]);return new Bc(Nm,i,o)}filter(t,r){const s=va(this),i=[],o=[];for(let a=0;a<this.length;a++){const l=this[a];l instanceof Error&&Jf(`index ${a}`,l),t.call(r,l,a,this)&&(i.push(l),o.push(s[a]))}return new Bc(Nm,i,o)}map(t,r){const s=[];for(let i=0;i<this.length;i++){const o=this[i];o instanceof Error&&Jf(`index ${i}`,o),s.push(t.call(r,o,i,this))}return s}getValue(t){const r=va(this).indexOf(t);if(r===-1)return;const s=this[r];return s instanceof Error&&Jf(`property ${JSON.stringify(t)}`,s.error),s}static fromItems(t,r){return new Bc(Nm,t,r)}};Lc=new WeakMap;let dc=Bc;function lO(n){let e=Sn(n);return X(e.length<=On,"value out-of-bounds","BUFFER_OVERRUN",{buffer:e,length:On,offset:e.length}),e.length!==On&&(e=Cn(Rt([Dw.slice(e.length%On),e]))),e}class si{constructor(e,t,r,s){j(this,"name");j(this,"type");j(this,"localName");j(this,"dynamic");be(this,{name:e,type:t,localName:r,dynamic:s},{name:"string",type:"string",localName:"string",dynamic:"boolean"})}_throwError(e,t){H(!1,e,this.localName,t)}}class _w{constructor(){W(this,Fc);W(this,pi,void 0);W(this,Fa,void 0);D(this,pi,[]),D(this,Fa,0)}get data(){return Rt(k(this,pi))}get length(){return k(this,Fa)}appendWriter(e){return ie(this,Fc,Og).call(this,Cn(e.data))}writeBytes(e){let t=Cn(e);const r=t.length%On;return r&&(t=Cn(Rt([t,Dw.slice(r)]))),ie(this,Fc,Og).call(this,t)}writeValue(e){return ie(this,Fc,Og).call(this,lO(e))}writeUpdatableValue(){const e=k(this,pi).length;return k(this,pi).push(Dw),D(this,Fa,k(this,Fa)+On),t=>{k(this,pi)[e]=lO(t)}}}pi=new WeakMap,Fa=new WeakMap,Fc=new WeakSet,Og=function(e){return k(this,pi).push(e),D(this,Fa,k(this,Fa)+e.length),e.length};const Gv=class Gv{constructor(e,t,r){W(this,vd);W(this,bg);j(this,"allowLoose");W(this,Gn,void 0);W(this,ar,void 0);W(this,Ua,void 0);W(this,Ha,void 0);W(this,go,void 0);be(this,{allowLoose:!!t}),D(this,Gn,Cn(e)),D(this,Ua,0),D(this,Ha,null),D(this,go,r??1024),D(this,ar,0)}get data(){return ce(k(this,Gn))}get dataLength(){return k(this,Gn).length}get consumed(){return k(this,ar)}get bytes(){return new Uint8Array(k(this,Gn))}subReader(e){const t=new Gv(k(this,Gn).slice(k(this,ar)+e),this.allowLoose,k(this,go));return D(t,Ha,this),t}readBytes(e,t){let r=ie(this,bg,GM).call(this,0,e,!!t);return ie(this,vd,n1).call(this,e),D(this,ar,k(this,ar)+r.length),r.slice(0,e)}readValue(){return Rw(this.readBytes(On))}readIndex(){return Mz(this.readBytes(On))}};Gn=new WeakMap,ar=new WeakMap,Ua=new WeakMap,Ha=new WeakMap,go=new WeakMap,vd=new WeakSet,n1=function(e){var t;if(k(this,Ha))return ie(t=k(this,Ha),vd,n1).call(t,e);D(this,Ua,k(this,Ua)+e),X(k(this,go)<1||k(this,Ua)<=k(this,go)*this.dataLength,`compressed ABI data exceeds inflation ratio of ${k(this,go)} ( see: https://github.com/ethers-io/ethers.js/issues/4537 )`,"BUFFER_OVERRUN",{buffer:Cn(k(this,Gn)),offset:k(this,ar),length:e,info:{bytesRead:k(this,Ua),dataLength:this.dataLength}})},bg=new WeakSet,GM=function(e,t,r){let s=Math.ceil(t/On)*On;return k(this,ar)+s>k(this,Gn).length&&(this.allowLoose&&r&&k(this,ar)+t<=k(this,Gn).length?s=t:X(!1,"data out-of-bounds","BUFFER_OVERRUN",{buffer:Cn(k(this,Gn)),length:k(this,Gn).length,offset:k(this,ar)+s})),k(this,Gn).slice(k(this,ar),k(this,ar)+s)};let Lw=Gv;function Mm(n){if(!Number.isSafeInteger(n)||n<0)throw new Error(`Wrong positive integer: ${n}`)}function Bw(n,...e){if(!(n instanceof Uint8Array))throw new Error("Expected Uint8Array");if(e.length>0&&!e.includes(n.length))throw new Error(`Expected Uint8Array of length ${e}, not of length=${n.length}`)}function Jz(n){if(typeof n!="function"||typeof n.create!="function")throw new Error("Hash should be wrapped by utils.wrapConstructor");Mm(n.outputLen),Mm(n.blockLen)}function hc(n,e=!0){if(n.destroyed)throw new Error("Hash instance has been destroyed");if(e&&n.finished)throw new Error("Hash#digest() has already been called")}function cO(n,e){Bw(n);const t=e.outputLen;if(n.length<t)throw new Error(`digestInto() expects output buffer of length at least ${t}`)}const Fw=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;/*! noble-hashes - MIT License (c) 2022 Paul Miller (paulmillr.com) */const uO=n=>n instanceof Uint8Array,qz=n=>new Uint32Array(n.buffer,n.byteOffset,Math.floor(n.byteLength/4)),Uw=n=>new DataView(n.buffer,n.byteOffset,n.byteLength),Ss=(n,e)=>n<<32-e|n>>>e;if(!(new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68))throw new Error("Non little-endian hardware is not supported");function Qz(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function Rm(n){if(typeof n=="string"&&(n=Qz(n)),!uO(n))throw new Error(`expected Uint8Array, got ${typeof n}`);return n}function Yz(...n){const e=new Uint8Array(n.reduce((r,s)=>r+s.length,0));let t=0;return n.forEach(r=>{if(!uO(r))throw new Error("Uint8Array expected");e.set(r,t),t+=r.length}),e}class Hw{clone(){return this._cloneInto()}}function jw(n){const e=r=>n().update(Rm(r)).digest(),t=n();return e.outputLen=t.outputLen,e.blockLen=t.blockLen,e.create=()=>n(),e}function Xz(n=32){if(Fw&&typeof Fw.getRandomValues=="function")return Fw.getRandomValues(new Uint8Array(n));throw new Error("crypto.getRandomValues must be defined")}class fO extends Hw{constructor(e,t){super(),this.finished=!1,this.destroyed=!1,Jz(e);const r=Rm(t);if(this.iHash=e.create(),typeof this.iHash.update!="function")throw new Error("Expected instance of class which extends utils.Hash");this.blockLen=this.iHash.blockLen,this.outputLen=this.iHash.outputLen;const s=this.blockLen,i=new Uint8Array(s);i.set(r.length>s?e.create().update(r).digest():r);for(let o=0;o<i.length;o++)i[o]^=54;this.iHash.update(i),this.oHash=e.create();for(let o=0;o<i.length;o++)i[o]^=106;this.oHash.update(i),i.fill(0)}update(e){return hc(this),this.iHash.update(e),this}digestInto(e){hc(this),Bw(e,this.outputLen),this.finished=!0,this.iHash.digestInto(e),this.oHash.update(e),this.oHash.digestInto(e),this.destroy()}digest(){const e=new Uint8Array(this.oHash.outputLen);return this.digestInto(e),e}_cloneInto(e){e||(e=Object.create(Object.getPrototypeOf(this),{}));const{oHash:t,iHash:r,finished:s,destroyed:i,blockLen:o,outputLen:a}=this;return e=e,e.finished=s,e.destroyed=i,e.blockLen=o,e.outputLen=a,e.oHash=t._cloneInto(e.oHash),e.iHash=r._cloneInto(e.iHash),e}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const dO=(n,e,t)=>new fO(n,e).update(t).digest();dO.create=(n,e)=>new fO(n,e);function Zz(n,e,t,r){if(typeof n.setBigUint64=="function")return n.setBigUint64(e,t,r);const s=BigInt(32),i=BigInt(4294967295),o=Number(t>>s&i),a=Number(t&i),l=r?4:0,c=r?0:4;n.setUint32(e+l,o,r),n.setUint32(e+c,a,r)}class hO extends Hw{constructor(e,t,r,s){super(),this.blockLen=e,this.outputLen=t,this.padOffset=r,this.isLE=s,this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.buffer=new Uint8Array(e),this.view=Uw(this.buffer)}update(e){hc(this);const{view:t,buffer:r,blockLen:s}=this;e=Rm(e);const i=e.length;for(let o=0;o<i;){const a=Math.min(s-this.pos,i-o);if(a===s){const l=Uw(e);for(;s<=i-o;o+=s)this.process(l,o);continue}r.set(e.subarray(o,o+a),this.pos),this.pos+=a,o+=a,this.pos===s&&(this.process(t,0),this.pos=0)}return this.length+=e.length,this.roundClean(),this}digestInto(e){hc(this),cO(e,this),this.finished=!0;const{buffer:t,view:r,blockLen:s,isLE:i}=this;let{pos:o}=this;t[o++]=128,this.buffer.subarray(o).fill(0),this.padOffset>s-o&&(this.process(r,0),o=0);for(let f=o;f<s;f++)t[f]=0;Zz(r,s-8,BigInt(this.length*8),i),this.process(r,0);const a=Uw(e),l=this.outputLen;if(l%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const c=l/4,u=this.get();if(c>u.length)throw new Error("_sha2: outputLen bigger than state");for(let f=0;f<c;f++)a.setUint32(4*f,u[f],i)}digest(){const{buffer:e,outputLen:t}=this;this.digestInto(e);const r=e.slice(0,t);return this.destroy(),r}_cloneInto(e){e||(e=new this.constructor),e.set(...this.get());const{blockLen:t,buffer:r,length:s,finished:i,destroyed:o,pos:a}=this;return e.length=s,e.pos=a,e.finished=i,e.destroyed=o,s%t&&e.buffer.set(r),e}}const eV=(n,e,t)=>n&e^~n&t,tV=(n,e,t)=>n&e^n&t^e&t,nV=new Uint32Array([1116352408,1899447441,3049323471,3921009573,961987163,1508970993,2453635748,2870763221,3624381080,310598401,607225278,1426881987,1925078388,2162078206,2614888103,3248222580,3835390401,4022224774,264347078,604807628,770255983,1249150122,1555081692,1996064986,2554220882,2821834349,2952996808,3210313671,3336571891,3584528711,113926993,338241895,666307205,773529912,1294757372,1396182291,1695183700,1986661051,2177026350,2456956037,2730485921,2820302411,3259730800,3345764771,3516065817,3600352804,4094571909,275423344,430227734,506948616,659060556,883997877,958139571,1322822218,1537002063,1747873779,1955562222,2024104815,2227730452,2361852424,2428436474,2756734187,3204031479,3329325298]),oo=new Uint32Array([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),ao=new Uint32Array(64);class rV extends hO{constructor(){super(64,32,8,!1),this.A=oo[0]|0,this.B=oo[1]|0,this.C=oo[2]|0,this.D=oo[3]|0,this.E=oo[4]|0,this.F=oo[5]|0,this.G=oo[6]|0,this.H=oo[7]|0}get(){const{A:e,B:t,C:r,D:s,E:i,F:o,G:a,H:l}=this;return[e,t,r,s,i,o,a,l]}set(e,t,r,s,i,o,a,l){this.A=e|0,this.B=t|0,this.C=r|0,this.D=s|0,this.E=i|0,this.F=o|0,this.G=a|0,this.H=l|0}process(e,t){for(let f=0;f<16;f++,t+=4)ao[f]=e.getUint32(t,!1);for(let f=16;f<64;f++){const d=ao[f-15],h=ao[f-2],p=Ss(d,7)^Ss(d,18)^d>>>3,g=Ss(h,17)^Ss(h,19)^h>>>10;ao[f]=g+ao[f-7]+p+ao[f-16]|0}let{A:r,B:s,C:i,D:o,E:a,F:l,G:c,H:u}=this;for(let f=0;f<64;f++){const d=Ss(a,6)^Ss(a,11)^Ss(a,25),h=u+d+eV(a,l,c)+nV[f]+ao[f]|0,g=(Ss(r,2)^Ss(r,13)^Ss(r,22))+tV(r,s,i)|0;u=c,c=l,l=a,a=o+h|0,o=i,i=s,s=r,r=h+g|0}r=r+this.A|0,s=s+this.B|0,i=i+this.C|0,o=o+this.D|0,a=a+this.E|0,l=l+this.F|0,c=c+this.G|0,u=u+this.H|0,this.set(r,s,i,o,a,l,c,u)}roundClean(){ao.fill(0)}destroy(){this.set(0,0,0,0,0,0,0,0),this.buffer.fill(0)}}const pO=jw(()=>new rV),Pm=BigInt(2**32-1),$w=BigInt(32);function mO(n,e=!1){return e?{h:Number(n&Pm),l:Number(n>>$w&Pm)}:{h:Number(n>>$w&Pm)|0,l:Number(n&Pm)|0}}function gO(n,e=!1){let t=new Uint32Array(n.length),r=new Uint32Array(n.length);for(let s=0;s<n.length;s++){const{h:i,l:o}=mO(n[s],e);[t[s],r[s]]=[i,o]}return[t,r]}const sV=(n,e)=>BigInt(n>>>0)<<$w|BigInt(e>>>0),iV=(n,e,t)=>n>>>t,oV=(n,e,t)=>n<<32-t|e>>>t,aV=(n,e,t)=>n>>>t|e<<32-t,lV=(n,e,t)=>n<<32-t|e>>>t,cV=(n,e,t)=>n<<64-t|e>>>t-32,uV=(n,e,t)=>n>>>t-32|e<<64-t,fV=(n,e)=>e,dV=(n,e)=>n,yO=(n,e,t)=>n<<t|e>>>32-t,bO=(n,e,t)=>e<<t|n>>>32-t,wO=(n,e,t)=>e<<t-32|n>>>64-t,vO=(n,e,t)=>n<<t-32|e>>>64-t;function hV(n,e,t,r){const s=(e>>>0)+(r>>>0);return{h:n+t+(s/2**32|0)|0,l:s|0}}const Fe={fromBig:mO,split:gO,toBig:sV,shrSH:iV,shrSL:oV,rotrSH:aV,rotrSL:lV,rotrBH:cV,rotrBL:uV,rotr32H:fV,rotr32L:dV,rotlSH:yO,rotlSL:bO,rotlBH:wO,rotlBL:vO,add:hV,add3L:(n,e,t)=>(n>>>0)+(e>>>0)+(t>>>0),add3H:(n,e,t,r)=>e+t+r+(n/2**32|0)|0,add4L:(n,e,t,r)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0),add4H:(n,e,t,r,s)=>e+t+r+s+(n/2**32|0)|0,add5H:(n,e,t,r,s,i)=>e+t+r+s+i+(n/2**32|0)|0,add5L:(n,e,t,r,s)=>(n>>>0)+(e>>>0)+(t>>>0)+(r>>>0)+(s>>>0)},[pV,mV]=Fe.split(["0x428a2f98d728ae22","0x7137449123ef65cd","0xb5c0fbcfec4d3b2f","0xe9b5dba58189dbbc","0x3956c25bf348b538","0x59f111f1b605d019","0x923f82a4af194f9b","0xab1c5ed5da6d8118","0xd807aa98a3030242","0x12835b0145706fbe","0x243185be4ee4b28c","0x550c7dc3d5ffb4e2","0x72be5d74f27b896f","0x80deb1fe3b1696b1","0x9bdc06a725c71235","0xc19bf174cf692694","0xe49b69c19ef14ad2","0xefbe4786384f25e3","0x0fc19dc68b8cd5b5","0x240ca1cc77ac9c65","0x2de92c6f592b0275","0x4a7484aa6ea6e483","0x5cb0a9dcbd41fbd4","0x76f988da831153b5","0x983e5152ee66dfab","0xa831c66d2db43210","0xb00327c898fb213f","0xbf597fc7beef0ee4","0xc6e00bf33da88fc2","0xd5a79147930aa725","0x06ca6351e003826f","0x142929670a0e6e70","0x27b70a8546d22ffc","0x2e1b21385c26c926","0x4d2c6dfc5ac42aed","0x53380d139d95b3df","0x650a73548baf63de","0x766a0abb3c77b2a8","0x81c2c92e47edaee6","0x92722c851482353b","0xa2bfe8a14cf10364","0xa81a664bbc423001","0xc24b8b70d0f89791","0xc76c51a30654be30","0xd192e819d6ef5218","0xd69906245565a910","0xf40e35855771202a","0x106aa07032bbd1b8","0x19a4c116b8d2d0c8","0x1e376c085141ab53","0x2748774cdf8eeb99","0x34b0bcb5e19b48a8","0x391c0cb3c5c95a63","0x4ed8aa4ae3418acb","0x5b9cca4f7763e373","0x682e6ff3d6b2b8a3","0x748f82ee5defb2fc","0x78a5636f43172f60","0x84c87814a1f0ab72","0x8cc702081a6439ec","0x90befffa23631e28","0xa4506cebde82bde9","0xbef9a3f7b2c67915","0xc67178f2e372532b","0xca273eceea26619c","0xd186b8c721c0c207","0xeada7dd6cde0eb1e","0xf57d4f7fee6ed178","0x06f067aa72176fba","0x0a637dc5a2c898a6","0x113f9804bef90dae","0x1b710b35131c471b","0x28db77f523047d84","0x32caab7b40c72493","0x3c9ebe0a15c9bebc","0x431d67c49c100d4c","0x4cc5d4becb3e42b6","0x597f299cfc657e2a","0x5fcb6fab3ad6faec","0x6c44198c4a475817"].map(n=>BigInt(n))),lo=new Uint32Array(80),co=new Uint32Array(80);class gV extends hO{constructor(){super(128,64,16,!1),this.Ah=1779033703,this.Al=-205731576,this.Bh=-1150833019,this.Bl=-2067093701,this.Ch=1013904242,this.Cl=-23791573,this.Dh=-1521486534,this.Dl=1595750129,this.Eh=1359893119,this.El=-1377402159,this.Fh=-1694144372,this.Fl=725511199,this.Gh=528734635,this.Gl=-79577749,this.Hh=1541459225,this.Hl=327033209}get(){const{Ah:e,Al:t,Bh:r,Bl:s,Ch:i,Cl:o,Dh:a,Dl:l,Eh:c,El:u,Fh:f,Fl:d,Gh:h,Gl:p,Hh:g,Hl:y}=this;return[e,t,r,s,i,o,a,l,c,u,f,d,h,p,g,y]}set(e,t,r,s,i,o,a,l,c,u,f,d,h,p,g,y){this.Ah=e|0,this.Al=t|0,this.Bh=r|0,this.Bl=s|0,this.Ch=i|0,this.Cl=o|0,this.Dh=a|0,this.Dl=l|0,this.Eh=c|0,this.El=u|0,this.Fh=f|0,this.Fl=d|0,this.Gh=h|0,this.Gl=p|0,this.Hh=g|0,this.Hl=y|0}process(e,t){for(let v=0;v<16;v++,t+=4)lo[v]=e.getUint32(t),co[v]=e.getUint32(t+=4);for(let v=16;v<80;v++){const w=lo[v-15]|0,E=co[v-15]|0,C=Fe.rotrSH(w,E,1)^Fe.rotrSH(w,E,8)^Fe.shrSH(w,E,7),T=Fe.rotrSL(w,E,1)^Fe.rotrSL(w,E,8)^Fe.shrSL(w,E,7),N=lo[v-2]|0,M=co[v-2]|0,O=Fe.rotrSH(N,M,19)^Fe.rotrBH(N,M,61)^Fe.shrSH(N,M,6),I=Fe.rotrSL(N,M,19)^Fe.rotrBL(N,M,61)^Fe.shrSL(N,M,6),L=Fe.add4L(T,I,co[v-7],co[v-16]),$=Fe.add4H(L,C,O,lo[v-7],lo[v-16]);lo[v]=$|0,co[v]=L|0}let{Ah:r,Al:s,Bh:i,Bl:o,Ch:a,Cl:l,Dh:c,Dl:u,Eh:f,El:d,Fh:h,Fl:p,Gh:g,Gl:y,Hh:b,Hl:x}=this;for(let v=0;v<80;v++){const w=Fe.rotrSH(f,d,14)^Fe.rotrSH(f,d,18)^Fe.rotrBH(f,d,41),E=Fe.rotrSL(f,d,14)^Fe.rotrSL(f,d,18)^Fe.rotrBL(f,d,41),C=f&h^~f&g,T=d&p^~d&y,N=Fe.add5L(x,E,T,mV[v],co[v]),M=Fe.add5H(N,b,w,C,pV[v],lo[v]),O=N|0,I=Fe.rotrSH(r,s,28)^Fe.rotrBH(r,s,34)^Fe.rotrBH(r,s,39),L=Fe.rotrSL(r,s,28)^Fe.rotrBL(r,s,34)^Fe.rotrBL(r,s,39),$=r&i^r&a^i&a,J=s&o^s&l^o&l;b=g|0,x=y|0,g=h|0,y=p|0,h=f|0,p=d|0,{h:f,l:d}=Fe.add(c|0,u|0,M|0,O|0),c=a|0,u=l|0,a=i|0,l=o|0,i=r|0,o=s|0;const U=Fe.add3L(O,L,J);r=Fe.add3H(U,M,I,$),s=U|0}({h:r,l:s}=Fe.add(this.Ah|0,this.Al|0,r|0,s|0)),{h:i,l:o}=Fe.add(this.Bh|0,this.Bl|0,i|0,o|0),{h:a,l}=Fe.add(this.Ch|0,this.Cl|0,a|0,l|0),{h:c,l:u}=Fe.add(this.Dh|0,this.Dl|0,c|0,u|0),{h:f,l:d}=Fe.add(this.Eh|0,this.El|0,f|0,d|0),{h,l:p}=Fe.add(this.Fh|0,this.Fl|0,h|0,p|0),{h:g,l:y}=Fe.add(this.Gh|0,this.Gl|0,g|0,y|0),{h:b,l:x}=Fe.add(this.Hh|0,this.Hl|0,b|0,x|0),this.set(r,s,i,o,a,l,c,u,f,d,h,p,g,y,b,x)}roundClean(){lo.fill(0),co.fill(0)}destroy(){this.buffer.fill(0),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}const yV=jw(()=>new gV);function bV(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const AO=bV();AO.crypto||AO.msCrypto;function wV(n){switch(n){case"sha256":return pO.create();case"sha512":return yV.create()}H(!1,"invalid hashing algorithm name","algorithm",n)}const[xO,EO,kO]=[[],[],[]],vV=BigInt(0),qf=BigInt(1),AV=BigInt(2),xV=BigInt(7),EV=BigInt(256),kV=BigInt(113);for(let n=0,e=qf,t=1,r=0;n<24;n++){[t,r]=[r,(2*t+3*r)%5],xO.push(2*(5*r+t)),EO.push((n+1)*(n+2)/2%64);let s=vV;for(let i=0;i<7;i++)e=(e<<qf^(e>>xV)*kV)%EV,e&AV&&(s^=qf<<(qf<<BigInt(i))-qf);kO.push(s)}const[CV,SV]=gO(kO,!0),CO=(n,e,t)=>t>32?wO(n,e,t):yO(n,e,t),SO=(n,e,t)=>t>32?vO(n,e,t):bO(n,e,t);function TV(n,e=24){const t=new Uint32Array(10);for(let r=24-e;r<24;r++){for(let o=0;o<10;o++)t[o]=n[o]^n[o+10]^n[o+20]^n[o+30]^n[o+40];for(let o=0;o<10;o+=2){const a=(o+8)%10,l=(o+2)%10,c=t[l],u=t[l+1],f=CO(c,u,1)^t[a],d=SO(c,u,1)^t[a+1];for(let h=0;h<50;h+=10)n[o+h]^=f,n[o+h+1]^=d}let s=n[2],i=n[3];for(let o=0;o<24;o++){const a=EO[o],l=CO(s,i,a),c=SO(s,i,a),u=xO[o];s=n[u],i=n[u+1],n[u]=l,n[u+1]=c}for(let o=0;o<50;o+=10){for(let a=0;a<10;a++)t[a]=n[o+a];for(let a=0;a<10;a++)n[o+a]^=~t[(a+2)%10]&t[(a+4)%10]}n[0]^=CV[r],n[1]^=SV[r]}t.fill(0)}class zw extends Hw{constructor(e,t,r,s=!1,i=24){if(super(),this.blockLen=e,this.suffix=t,this.outputLen=r,this.enableXOF=s,this.rounds=i,this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,Mm(r),0>=this.blockLen||this.blockLen>=200)throw new Error("Sha3 supports only keccak-f1600 function");this.state=new Uint8Array(200),this.state32=qz(this.state)}keccak(){TV(this.state32,this.rounds),this.posOut=0,this.pos=0}update(e){hc(this);const{blockLen:t,state:r}=this;e=Rm(e);const s=e.length;for(let i=0;i<s;){const o=Math.min(t-this.pos,s-i);for(let a=0;a<o;a++)r[this.pos++]^=e[i++];this.pos===t&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:e,suffix:t,pos:r,blockLen:s}=this;e[r]^=t,t&128&&r===s-1&&this.keccak(),e[s-1]^=128,this.keccak()}writeInto(e){hc(this,!1),Bw(e),this.finish();const t=this.state,{blockLen:r}=this;for(let s=0,i=e.length;s<i;){this.posOut>=r&&this.keccak();const o=Math.min(r-this.posOut,i-s);e.set(t.subarray(this.posOut,this.posOut+o),s),this.posOut+=o,s+=o}return e}xofInto(e){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(e)}xof(e){return Mm(e),this.xofInto(new Uint8Array(e))}digestInto(e){if(cO(e,this),this.finished)throw new 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){const{blockLen:t,suffix:r,outputLen:s,rounds:i,enableXOF:o}=this;return e||(e=new zw(t,r,s,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=s,e.enableXOF=o,e.destroyed=this.destroyed,e}}const OV=((n,e,t)=>jw(()=>new zw(e,n,t)))(1,136,256/8);let TO=!1;const OO=function(n){return OV(n)};let NO=OO;function Ft(n){const e=qe(n,"data");return ce(NO(e))}Ft._=OO,Ft.lock=function(){TO=!0},Ft.register=function(n){if(TO)throw new TypeError("keccak256 is locked");NO=n},Object.freeze(Ft);const MO=function(n){return wV("sha256").update(n).digest()};let RO=MO,PO=!1;function pc(n){const e=qe(n,"data");return ce(RO(e))}pc._=MO,pc.lock=function(){PO=!0},pc.register=function(n){if(PO)throw new Error("sha256 is locked");RO=n},Object.freeze(pc),Object.freeze(pc);/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const DO=BigInt(0),Dm=BigInt(1),NV=BigInt(2),Im=n=>n instanceof Uint8Array,MV=Array.from({length:256},(n,e)=>e.toString(16).padStart(2,"0"));function mc(n){if(!Im(n))throw new Error("Uint8Array expected");let e="";for(let t=0;t<n.length;t++)e+=MV[n[t]];return e}function IO(n){const e=n.toString(16);return e.length&1?`0${e}`:e}function Vw(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);return BigInt(n===""?"0":`0x${n}`)}function gc(n){if(typeof n!="string")throw new Error("hex string expected, got "+typeof n);const e=n.length;if(e%2)throw new Error("padded hex string expected, got unpadded hex of length "+e);const t=new Uint8Array(e/2);for(let r=0;r<t.length;r++){const s=r*2,i=n.slice(s,s+2),o=Number.parseInt(i,16);if(Number.isNaN(o)||o<0)throw new Error("Invalid byte sequence");t[r]=o}return t}function Aa(n){return Vw(mc(n))}function Ww(n){if(!Im(n))throw new Error("Uint8Array expected");return Vw(mc(Uint8Array.from(n).reverse()))}function yc(n,e){return gc(n.toString(16).padStart(e*2,"0"))}function Gw(n,e){return yc(n,e).reverse()}function RV(n){return gc(IO(n))}function Vr(n,e,t){let r;if(typeof e=="string")try{r=gc(e)}catch(i){throw new Error(`${n} must be valid hex string, got "${e}". Cause: ${i}`)}else if(Im(e))r=Uint8Array.from(e);else throw new Error(`${n} must be hex string or Uint8Array`);const s=r.length;if(typeof t=="number"&&s!==t)throw new Error(`${n} expected ${t} bytes, got ${s}`);return r}function Qf(...n){const e=new Uint8Array(n.reduce((r,s)=>r+s.length,0));let t=0;return n.forEach(r=>{if(!Im(r))throw new Error("Uint8Array expected");e.set(r,t),t+=r.length}),e}function PV(n,e){if(n.length!==e.length)return!1;for(let t=0;t<n.length;t++)if(n[t]!==e[t])return!1;return!0}function DV(n){if(typeof n!="string")throw new Error(`utf8ToBytes expected string, got ${typeof n}`);return new Uint8Array(new TextEncoder().encode(n))}function IV(n){let e;for(e=0;n>DO;n>>=Dm,e+=1);return e}function _V(n,e){return n>>BigInt(e)&Dm}const LV=(n,e,t)=>n|(t?Dm:DO)<<BigInt(e),Kw=n=>(NV<<BigInt(n-1))-Dm,Jw=n=>new Uint8Array(n),_O=n=>Uint8Array.from(n);function LO(n,e,t){if(typeof n!="number"||n<2)throw new Error("hashLen must be a number");if(typeof e!="number"||e<2)throw new Error("qByteLen must be a number");if(typeof t!="function")throw new Error("hmacFn must be a function");let r=Jw(n),s=Jw(n),i=0;const o=()=>{r.fill(1),s.fill(0),i=0},a=(...f)=>t(s,r,...f),l=(f=Jw())=>{s=a(_O([0]),f),r=a(),f.length!==0&&(s=a(_O([1]),f),r=a())},c=()=>{if(i++>=1e3)throw new Error("drbg: tried 1000 values");let f=0;const d=[];for(;f<e;){r=a();const h=r.slice();d.push(h),f+=r.length}return Qf(...d)};return(f,d)=>{o(),l(f);let h;for(;!(h=d(c()));)l();return o(),h}}const BV={bigint:n=>typeof n=="bigint",function:n=>typeof n=="function",boolean:n=>typeof n=="boolean",string:n=>typeof n=="string",stringOrUint8Array:n=>typeof n=="string"||n instanceof Uint8Array,isSafeInteger:n=>Number.isSafeInteger(n),array:n=>Array.isArray(n),field:(n,e)=>e.Fp.isValid(n),hash:n=>typeof n=="function"&&Number.isSafeInteger(n.outputLen)};function Yf(n,e,t={}){const r=(s,i,o)=>{const a=BV[i];if(typeof a!="function")throw new Error(`Invalid validator "${i}", expected function`);const l=n[s];if(!(o&&l===void 0)&&!a(l,n))throw new Error(`Invalid param ${String(s)}=${l} (${typeof l}), expected ${i}`)};for(const[s,i]of Object.entries(e))r(s,i,!1);for(const[s,i]of Object.entries(t))r(s,i,!0);return n}const FV=Object.freeze(Object.defineProperty({__proto__:null,bitGet:_V,bitLen:IV,bitMask:Kw,bitSet:LV,bytesToHex:mc,bytesToNumberBE:Aa,bytesToNumberLE:Ww,concatBytes:Qf,createHmacDrbg:LO,ensureBytes:Vr,equalBytes:PV,hexToBytes:gc,hexToNumber:Vw,numberToBytesBE:yc,numberToBytesLE:Gw,numberToHexUnpadded:IO,numberToVarBytesBE:RV,utf8ToBytes:DV,validateObject:Yf},Symbol.toStringTag,{value:"Module"}));/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const en=BigInt(0),Pt=BigInt(1),xa=BigInt(2),UV=BigInt(3),qw=BigInt(4),BO=BigInt(5),FO=BigInt(8);BigInt(9),BigInt(16);function zn(n,e){const t=n%e;return t>=en?t:e+t}function HV(n,e,t){if(t<=en||e<en)throw new Error("Expected power/modulo > 0");if(t===Pt)return en;let r=Pt;for(;e>en;)e&Pt&&(r=r*n%t),n=n*n%t,e>>=Pt;return r}function Er(n,e,t){let r=n;for(;e-- >en;)r*=r,r%=t;return r}function Qw(n,e){if(n===en||e<=en)throw new Error(`invert: expected positive integers, got n=${n} mod=${e}`);let t=zn(n,e),r=e,s=en,i=Pt;for(;t!==en;){const a=r/t,l=r%t,c=s-i*a;r=t,t=l,s=i,i=c}if(r!==Pt)throw new Error("invert: does not exist");return zn(s,e)}function jV(n){const e=(n-Pt)/xa;let t,r,s;for(t=n-Pt,r=0;t%xa===en;t/=xa,r++);for(s=xa;s<n&&HV(s,e,n)!==n-Pt;s++);if(r===1){const o=(n+Pt)/qw;return function(l,c){const u=l.pow(c,o);if(!l.eql(l.sqr(u),c))throw new Error("Cannot find square root");return u}}const i=(t+Pt)/xa;return function(a,l){if(a.pow(l,e)===a.neg(a.ONE))throw new Error("Cannot find square root");let c=r,u=a.pow(a.mul(a.ONE,s),t),f=a.pow(l,i),d=a.pow(l,t);for(;!a.eql(d,a.ONE);){if(a.eql(d,a.ZERO))return a.ZERO;let h=1;for(let g=a.sqr(d);h<c&&!a.eql(g,a.ONE);h++)g=a.sqr(g);const p=a.pow(u,Pt<<BigInt(c-h-1));u=a.sqr(p),f=a.mul(f,p),d=a.mul(d,u),c=h}return f}}function $V(n){if(n%qw===UV){const e=(n+Pt)/qw;return function(r,s){const i=r.pow(s,e);if(!r.eql(r.sqr(i),s))throw new Error("Cannot find square root");return i}}if(n%FO===BO){const e=(n-BO)/FO;return function(r,s){const i=r.mul(s,xa),o=r.pow(i,e),a=r.mul(s,o),l=r.mul(r.mul(a,xa),o),c=r.mul(a,r.sub(l,r.ONE));if(!r.eql(r.sqr(c),s))throw new Error("Cannot find square root");return c}}return jV(n)}const zV=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function VV(n){const e={ORDER:"bigint",MASK:"bigint",BYTES:"isSafeInteger",BITS:"isSafeInteger"},t=zV.reduce((r,s)=>(r[s]="function",r),e);return Yf(n,t)}function WV(n,e,t){if(t<en)throw new Error("Expected power > 0");if(t===en)return n.ONE;if(t===Pt)return e;let r=n.ONE,s=e;for(;t>en;)t&Pt&&(r=n.mul(r,s)),s=n.sqr(s),t>>=Pt;return r}function GV(n,e){const t=new Array(e.length),r=e.reduce((i,o,a)=>n.is0(o)?i:(t[a]=i,n.mul(i,o)),n.ONE),s=n.inv(r);return e.reduceRight((i,o,a)=>n.is0(o)?i:(t[a]=n.mul(i,t[a]),n.mul(i,o)),s),t}function UO(n,e){const t=e!==void 0?e:n.toString(2).length,r=Math.ceil(t/8);return{nBitLength:t,nByteLength:r}}function KV(n,e,t=!1,r={}){if(n<=en)throw new Error(`Expected Field ORDER > 0, got ${n}`);const{nBitLength:s,nByteLength:i}=UO(n,e);if(i>2048)throw new Error("Field lengths over 2048 bytes are not supported");const o=$V(n),a=Object.freeze({ORDER:n,BITS:s,BYTES:i,MASK:Kw(s),ZERO:en,ONE:Pt,create:l=>zn(l,n),isValid:l=>{if(typeof l!="bigint")throw new Error(`Invalid field element: expected bigint, got ${typeof l}`);return en<=l&&l<n},is0:l=>l===en,isOdd:l=>(l&Pt)===Pt,neg:l=>zn(-l,n),eql:(l,c)=>l===c,sqr:l=>zn(l*l,n),add:(l,c)=>zn(l+c,n),sub:(l,c)=>zn(l-c,n),mul:(l,c)=>zn(l*c,n),pow:(l,c)=>WV(a,l,c),div:(l,c)=>zn(l*Qw(c,n),n),sqrN:l=>l*l,addN:(l,c)=>l+c,subN:(l,c)=>l-c,mulN:(l,c)=>l*c,inv:l=>Qw(l,n),sqrt:r.sqrt||(l=>o(a,l)),invertBatch:l=>GV(a,l),cmov:(l,c,u)=>u?c:l,toBytes:l=>t?Gw(l,i):yc(l,i),fromBytes:l=>{if(l.length!==i)throw new Error(`Fp.fromBytes: expected ${i}, got ${l.length}`);return t?Ww(l):Aa(l)}});return Object.freeze(a)}function HO(n){if(typeof n!="bigint")throw new Error("field order must be bigint");const e=n.toString(2).length;return Math.ceil(e/8)}function jO(n){const e=HO(n);return e+Math.ceil(e/2)}function JV(n,e,t=!1){const r=n.length,s=HO(e),i=jO(e);if(r<16||r<i||r>1024)throw new Error(`expected ${i}-1024 bytes of input, got ${r}`);const o=t?Aa(n):Ww(n),a=zn(o,e-Pt)+Pt;return t?Gw(a,s):yc(a,s)}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const qV=BigInt(0),Yw=BigInt(1);function QV(n,e){const t=(s,i)=>{const o=i.negate();return s?o:i},r=s=>{const i=Math.ceil(e/s)+1,o=2**(s-1);return{windows:i,windowSize:o}};return{constTimeNegate:t,unsafeLadder(s,i){let o=n.ZERO,a=s;for(;i>qV;)i&Yw&&(o=o.add(a)),a=a.double(),i>>=Yw;return o},precomputeWindow(s,i){const{windows:o,windowSize:a}=r(i),l=[];let c=s,u=c;for(let f=0;f<o;f++){u=c,l.push(u);for(let d=1;d<a;d++)u=u.add(c),l.push(u);c=u.double()}return l},wNAF(s,i,o){const{windows:a,windowSize:l}=r(s);let c=n.ZERO,u=n.BASE;const f=BigInt(2**s-1),d=2**s,h=BigInt(s);for(let p=0;p<a;p++){const g=p*l;let y=Number(o&f);o>>=h,y>l&&(y-=d,o+=Yw);const b=g,x=g+Math.abs(y)-1,v=p%2!==0,w=y<0;y===0?u=u.add(t(v,i[b])):c=c.add(t(w,i[x]))}return{p:c,f:u}},wNAFCached(s,i,o,a){const l=s._WINDOW_SIZE||1;let c=i.get(s);return c||(c=this.precomputeWindow(s,l),l!==1&&i.set(s,a(c))),this.wNAF(l,c,o)}}}function $O(n){return VV(n.Fp),Yf(n,{n:"bigint",h:"bigint",Gx:"field",Gy:"field"},{nBitLength:"isSafeInteger",nByteLength:"isSafeInteger"}),Object.freeze({...UO(n.n,n.nBitLength),...n,p:n.Fp.ORDER})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function YV(n){const e=$O(n);Yf(e,{a:"field",b:"field"},{allowedPrivateKeyLengths:"array",wrapPrivateKey:"boolean",isTorsionFree:"function",clearCofactor:"function",allowInfinityPoint:"boolean",fromBytes:"function",toBytes:"function"});const{endo:t,Fp:r,a:s}=e;if(t){if(!r.eql(s,r.ZERO))throw new Error("Endomorphism can only be defined for Koblitz curves that have a=0");if(typeof t!="object"||typeof t.beta!="bigint"||typeof t.splitScalar!="function")throw new Error("Expected endomorphism with beta: bigint and splitScalar: function")}return Object.freeze({...e})}const{bytesToNumberBE:XV,hexToBytes:ZV}=FV,Ea={Err:class extends Error{constructor(e=""){super(e)}},_parseInt(n){const{Err:e}=Ea;if(n.length<2||n[0]!==2)throw new e("Invalid signature integer tag");const t=n[1],r=n.subarray(2,t+2);if(!t||r.length!==t)throw new e("Invalid signature integer: wrong length");if(r[0]&128)throw new e("Invalid signature integer: negative");if(r[0]===0&&!(r[1]&128))throw new e("Invalid signature integer: unnecessary leading zero");return{d:XV(r),l:n.subarray(t+2)}},toSig(n){const{Err:e}=Ea,t=typeof n=="string"?ZV(n):n;if(!(t instanceof Uint8Array))throw new Error("ui8a expected");let r=t.length;if(r<2||t[0]!=48)throw new e("Invalid signature tag");if(t[1]!==r-2)throw new e("Invalid signature: incorrect length");const{d:s,l:i}=Ea._parseInt(t.subarray(2)),{d:o,l:a}=Ea._parseInt(i);if(a.length)throw new e("Invalid signature: left bytes after parsing");return{r:s,s:o}},hexFromSig(n){const e=c=>Number.parseInt(c[0],16)&8?"00"+c:c,t=c=>{const u=c.toString(16);return u.length&1?`0${u}`:u},r=e(t(n.s)),s=e(t(n.r)),i=r.length/2,o=s.length/2,a=t(i),l=t(o);return`30${t(o+i+4)}02${l}${s}02${a}${r}`}},ii=BigInt(0),kr=BigInt(1);BigInt(2);const zO=BigInt(3);BigInt(4);function e9(n){const e=YV(n),{Fp:t}=e,r=e.toBytes||((p,g,y)=>{const b=g.toAffine();return Qf(Uint8Array.from([4]),t.toBytes(b.x),t.toBytes(b.y))}),s=e.fromBytes||(p=>{const g=p.subarray(1),y=t.fromBytes(g.subarray(0,t.BYTES)),b=t.fromBytes(g.subarray(t.BYTES,2*t.BYTES));return{x:y,y:b}});function i(p){const{a:g,b:y}=e,b=t.sqr(p),x=t.mul(b,p);return t.add(t.add(x,t.mul(p,g)),y)}if(!t.eql(t.sqr(e.Gy),i(e.Gx)))throw new Error("bad generator point: equation left != right");function o(p){return typeof p=="bigint"&&ii<p&&p<e.n}function a(p){if(!o(p))throw new Error("Expected valid bigint: 0 < bigint < curve.n")}function l(p){const{allowedPrivateKeyLengths:g,nByteLength:y,wrapPrivateKey:b,n:x}=e;if(g&&typeof p!="bigint"){if(p instanceof Uint8Array&&(p=mc(p)),typeof p!="string"||!g.includes(p.length))throw new Error("Invalid key");p=p.padStart(y*2,"0")}let v;try{v=typeof p=="bigint"?p:Aa(Vr("private key",p,y))}catch{throw new Error(`private key must be ${y} bytes, hex or bigint, not ${typeof p}`)}return b&&(v=zn(v,x)),a(v),v}const c=new Map;function u(p){if(!(p instanceof f))throw new Error("ProjectivePoint expected")}class f{constructor(g,y,b){if(this.px=g,this.py=y,this.pz=b,g==null||!t.isValid(g))throw new Error("x required");if(y==null||!t.isValid(y))throw new Error("y required");if(b==null||!t.isValid(b))throw new Error("z required")}static fromAffine(g){const{x:y,y:b}=g||{};if(!g||!t.isValid(y)||!t.isValid(b))throw new Error("invalid affine point");if(g instanceof f)throw new Error("projective point not allowed");const x=v=>t.eql(v,t.ZERO);return x(y)&&x(b)?f.ZERO:new f(y,b,t.ONE)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}static normalizeZ(g){const y=t.invertBatch(g.map(b=>b.pz));return g.map((b,x)=>b.toAffine(y[x])).map(f.fromAffine)}static fromHex(g){const y=f.fromAffine(s(Vr("pointHex",g)));return y.assertValidity(),y}static fromPrivateKey(g){return f.BASE.multiply(l(g))}_setWindowSize(g){this._WINDOW_SIZE=g,c.delete(this)}assertValidity(){if(this.is0()){if(e.allowInfinityPoint&&!t.is0(this.py))return;throw new Error("bad point: ZERO")}const{x:g,y}=this.toAffine();if(!t.isValid(g)||!t.isValid(y))throw new Error("bad point: x or y not FE");const b=t.sqr(y),x=i(g);if(!t.eql(b,x))throw new Error("bad point: equation left != right");if(!this.isTorsionFree())throw new Error("bad point: not in prime-order subgroup")}hasEvenY(){const{y:g}=this.toAffine();if(t.isOdd)return!t.isOdd(g);throw new Error("Field doesn't support isOdd")}equals(g){u(g);const{px:y,py:b,pz:x}=this,{px:v,py:w,pz:E}=g,C=t.eql(t.mul(y,E),t.mul(v,x)),T=t.eql(t.mul(b,E),t.mul(w,x));return C&&T}negate(){return new f(this.px,t.neg(this.py),this.pz)}double(){const{a:g,b:y}=e,b=t.mul(y,zO),{px:x,py:v,pz:w}=this;let E=t.ZERO,C=t.ZERO,T=t.ZERO,N=t.mul(x,x),M=t.mul(v,v),O=t.mul(w,w),I=t.mul(x,v);return I=t.add(I,I),T=t.mul(x,w),T=t.add(T,T),E=t.mul(g,T),C=t.mul(b,O),C=t.add(E,C),E=t.sub(M,C),C=t.add(M,C),C=t.mul(E,C),E=t.mul(I,E),T=t.mul(b,T),O=t.mul(g,O),I=t.sub(N,O),I=t.mul(g,I),I=t.add(I,T),T=t.add(N,N),N=t.add(T,N),N=t.add(N,O),N=t.mul(N,I),C=t.add(C,N),O=t.mul(v,w),O=t.add(O,O),N=t.mul(O,I),E=t.sub(E,N),T=t.mul(O,M),T=t.add(T,T),T=t.add(T,T),new f(E,C,T)}add(g){u(g);const{px:y,py:b,pz:x}=this,{px:v,py:w,pz:E}=g;let C=t.ZERO,T=t.ZERO,N=t.ZERO;const M=e.a,O=t.mul(e.b,zO);let I=t.mul(y,v),L=t.mul(b,w),$=t.mul(x,E),J=t.add(y,b),U=t.add(v,w);J=t.mul(J,U),U=t.add(I,L),J=t.sub(J,U),U=t.add(y,x);let G=t.add(v,E);return U=t.mul(U,G),G=t.add(I,$),U=t.sub(U,G),G=t.add(b,x),C=t.add(w,E),G=t.mul(G,C),C=t.add(L,$),G=t.sub(G,C),N=t.mul(M,U),C=t.mul(O,$),N=t.add(C,N),C=t.sub(L,N),N=t.add(L,N),T=t.mul(C,N),L=t.add(I,I),L=t.add(L,I),$=t.mul(M,$),U=t.mul(O,U),L=t.add(L,$),$=t.sub(I,$),$=t.mul(M,$),U=t.add(U,$),I=t.mul(L,U),T=t.add(T,I),I=t.mul(G,U),C=t.mul(J,C),C=t.sub(C,I),I=t.mul(J,L),N=t.mul(G,N),N=t.add(N,I),new f(C,T,N)}subtract(g){return this.add(g.negate())}is0(){return this.equals(f.ZERO)}wNAF(g){return h.wNAFCached(this,c,g,y=>{const b=t.invertBatch(y.map(x=>x.pz));return y.map((x,v)=>x.toAffine(b[v])).map(f.fromAffine)})}multiplyUnsafe(g){const y=f.ZERO;if(g===ii)return y;if(a(g),g===kr)return this;const{endo:b}=e;if(!b)return h.unsafeLadder(this,g);let{k1neg:x,k1:v,k2neg:w,k2:E}=b.splitScalar(g),C=y,T=y,N=this;for(;v>ii||E>ii;)v&kr&&(C=C.add(N)),E&kr&&(T=T.add(N)),N=N.double(),v>>=kr,E>>=kr;return x&&(C=C.negate()),w&&(T=T.negate()),T=new f(t.mul(T.px,b.beta),T.py,T.pz),C.add(T)}multiply(g){a(g);let y=g,b,x;const{endo:v}=e;if(v){const{k1neg:w,k1:E,k2neg:C,k2:T}=v.splitScalar(y);let{p:N,f:M}=this.wNAF(E),{p:O,f:I}=this.wNAF(T);N=h.constTimeNegate(w,N),O=h.constTimeNegate(C,O),O=new f(t.mul(O.px,v.beta),O.py,O.pz),b=N.add(O),x=M.add(I)}else{const{p:w,f:E}=this.wNAF(y);b=w,x=E}return f.normalizeZ([b,x])[0]}multiplyAndAddUnsafe(g,y,b){const x=f.BASE,v=(E,C)=>C===ii||C===kr||!E.equals(x)?E.multiplyUnsafe(C):E.multiply(C),w=v(this,y).add(v(g,b));return w.is0()?void 0:w}toAffine(g){const{px:y,py:b,pz:x}=this,v=this.is0();g==null&&(g=v?t.ONE:t.inv(x));const w=t.mul(y,g),E=t.mul(b,g),C=t.mul(x,g);if(v)return{x:t.ZERO,y:t.ZERO};if(!t.eql(C,t.ONE))throw new Error("invZ was invalid");return{x:w,y:E}}isTorsionFree(){const{h:g,isTorsionFree:y}=e;if(g===kr)return!0;if(y)return y(f,this);throw new Error("isTorsionFree() has not been declared for the elliptic curve")}clearCofactor(){const{h:g,clearCofactor:y}=e;return g===kr?this:y?y(f,this):this.multiplyUnsafe(e.h)}toRawBytes(g=!0){return this.assertValidity(),r(f,this,g)}toHex(g=!0){return mc(this.toRawBytes(g))}}f.BASE=new f(e.Gx,e.Gy,t.ONE),f.ZERO=new f(t.ZERO,t.ONE,t.ZERO);const d=e.nBitLength,h=QV(f,e.endo?Math.ceil(d/2):d);return{CURVE:e,ProjectivePoint:f,normPrivateKeyToScalar:l,weierstrassEquation:i,isWithinCurveOrder:o}}function t9(n){const e=$O(n);return Yf(e,{hash:"hash",hmac:"function",randomBytes:"function"},{bits2int:"function",bits2int_modN:"function",lowS:"boolean"}),Object.freeze({lowS:!0,...e})}function n9(n){const e=t9(n),{Fp:t,n:r}=e,s=t.BYTES+1,i=2*t.BYTES+1;function o(U){return ii<U&&U<t.ORDER}function a(U){return zn(U,r)}function l(U){return Qw(U,r)}const{ProjectivePoint:c,normPrivateKeyToScalar:u,weierstrassEquation:f,isWithinCurveOrder:d}=e9({...e,toBytes(U,G,Y){const re=G.toAffine(),Z=t.toBytes(re.x),me=Qf;return Y?me(Uint8Array.from([G.hasEvenY()?2:3]),Z):me(Uint8Array.from([4]),Z,t.toBytes(re.y))},fromBytes(U){const G=U.length,Y=U[0],re=U.subarray(1);if(G===s&&(Y===2||Y===3)){const Z=Aa(re);if(!o(Z))throw new Error("Point is not on curve");const me=f(Z);let Me=t.sqrt(me);const De=(Me&kr)===kr;return(Y&1)===1!==De&&(Me=t.neg(Me)),{x:Z,y:Me}}else if(G===i&&Y===4){const Z=t.fromBytes(re.subarray(0,t.BYTES)),me=t.fromBytes(re.subarray(t.BYTES,2*t.BYTES));return{x:Z,y:me}}else throw new Error(`Point of length ${G} was invalid. Expected ${s} compressed bytes or ${i} uncompressed bytes`)}}),h=U=>mc(yc(U,e.nByteLength));function p(U){const G=r>>kr;return U>G}function g(U){return p(U)?a(-U):U}const y=(U,G,Y)=>Aa(U.slice(G,Y));class b{constructor(G,Y,re){this.r=G,this.s=Y,this.recovery=re,this.assertValidity()}static fromCompact(G){const Y=e.nByteLength;return G=Vr("compactSignature",G,Y*2),new b(y(G,0,Y),y(G,Y,2*Y))}static fromDER(G){const{r:Y,s:re}=Ea.toSig(Vr("DER",G));return new b(Y,re)}assertValidity(){if(!d(this.r))throw new Error("r must be 0 < r < CURVE.n");if(!d(this.s))throw new Error("s must be 0 < s < CURVE.n")}addRecoveryBit(G){return new b(this.r,this.s,G)}recoverPublicKey(G){const{r:Y,s:re,recovery:Z}=this,me=T(Vr("msgHash",G));if(Z==null||![0,1,2,3].includes(Z))throw new Error("recovery id invalid");const Me=Z===2||Z===3?Y+e.n:Y;if(Me>=t.ORDER)throw new Error("recovery id 2 or 3 invalid");const De=Z&1?"03":"02",Se=c.fromHex(De+h(Me)),Ee=l(Me),He=a(-me*Ee),Ve=a(re*Ee),Xe=c.BASE.multiplyAndAddUnsafe(Se,He,Ve);if(!Xe)throw new Error("point at infinify");return Xe.assertValidity(),Xe}hasHighS(){return p(this.s)}normalizeS(){return this.hasHighS()?new b(this.r,a(-this.s),this.recovery):this}toDERRawBytes(){return gc(this.toDERHex())}toDERHex(){return Ea.hexFromSig({r:this.r,s:this.s})}toCompactRawBytes(){return gc(this.toCompactHex())}toCompactHex(){return h(this.r)+h(this.s)}}const x={isValidPrivateKey(U){try{return u(U),!0}catch{return!1}},normPrivateKeyToScalar:u,randomPrivateKey:()=>{const U=jO(e.n);return JV(e.randomBytes(U),e.n)},precompute(U=8,G=c.BASE){return G._setWindowSize(U),G.multiply(BigInt(3)),G}};function v(U,G=!0){return c.fromPrivateKey(U).toRawBytes(G)}function w(U){const G=U instanceof Uint8Array,Y=typeof U=="string",re=(G||Y)&&U.length;return G?re===s||re===i:Y?re===2*s||re===2*i:U instanceof c}function E(U,G,Y=!0){if(w(U))throw new Error("first arg must be private key");if(!w(G))throw new Error("second arg must be public key");return c.fromHex(G).multiply(u(U)).toRawBytes(Y)}const C=e.bits2int||function(U){const G=Aa(U),Y=U.length*8-e.nBitLength;return Y>0?G>>BigInt(Y):G},T=e.bits2int_modN||function(U){return a(C(U))},N=Kw(e.nBitLength);function M(U){if(typeof U!="bigint")throw new Error("bigint expected");if(!(ii<=U&&U<N))throw new Error(`bigint expected < 2^${e.nBitLength}`);return yc(U,e.nByteLength)}function O(U,G,Y=I){if(["recovered","canonical"].some(Ze=>Ze in Y))throw new Error("sign() legacy options not supported");const{hash:re,randomBytes:Z}=e;let{lowS:me,prehash:Me,extraEntropy:De}=Y;me==null&&(me=!0),U=Vr("msgHash",U),Me&&(U=Vr("prehashed msgHash",re(U)));const Se=T(U),Ee=u(G),He=[M(Ee),M(Se)];if(De!=null){const Ze=De===!0?Z(t.BYTES):De;He.push(Vr("extraEntropy",Ze))}const Ve=Qf(...He),Xe=Se;function mt(Ze){const nt=C(Ze);if(!d(nt))return;const zt=l(nt),yt=c.BASE.multiply(nt).toAffine(),Qe=a(yt.x);if(Qe===ii)return;const lt=a(zt*a(Xe+Qe*Ee));if(lt===ii)return;let z=(yt.x===Qe?0:2)|Number(yt.y&kr),K=lt;return me&&p(lt)&&(K=g(lt),z^=1),new b(Qe,K,z)}return{seed:Ve,k2sig:mt}}const I={lowS:e.lowS,prehash:!1},L={lowS:e.lowS,prehash:!1};function $(U,G,Y=I){const{seed:re,k2sig:Z}=O(U,G,Y),me=e;return LO(me.hash.outputLen,me.nByteLength,me.hmac)(re,Z)}c.BASE._setWindowSize(8);function J(U,G,Y,re=L){var yt;const Z=U;if(G=Vr("msgHash",G),Y=Vr("publicKey",Y),"strict"in re)throw new Error("options.strict was renamed to lowS");const{lowS:me,prehash:Me}=re;let De,Se;try{if(typeof Z=="string"||Z instanceof Uint8Array)try{De=b.fromDER(Z)}catch(Qe){if(!(Qe instanceof Ea.Err))throw Qe;De=b.fromCompact(Z)}else if(typeof Z=="object"&&typeof Z.r=="bigint"&&typeof Z.s=="bigint"){const{r:Qe,s:lt}=Z;De=new b(Qe,lt)}else throw new Error("PARSE");Se=c.fromHex(Y)}catch(Qe){if(Qe.message==="PARSE")throw new Error("signature must be Signature instance, Uint8Array or hex string");return!1}if(me&&De.hasHighS())return!1;Me&&(G=e.hash(G));const{r:Ee,s:He}=De,Ve=T(G),Xe=l(He),mt=a(Ve*Xe),Ze=a(Ee*Xe),nt=(yt=c.BASE.multiplyAndAddUnsafe(Se,mt,Ze))==null?void 0:yt.toAffine();return nt?a(nt.x)===Ee:!1}return{CURVE:e,getPublicKey:v,getSharedSecret:E,sign:$,verify:J,ProjectivePoint:c,Signature:b,utils:x}}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */function r9(n){return{hash:n,hmac:(e,...t)=>dO(n,e,Yz(...t)),randomBytes:Xz}}function s9(n,e){const t=r=>n9({...n,...r9(r)});return Object.freeze({...t(e),create:t})}/*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) */const VO=BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),WO=BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),i9=BigInt(1),Xw=BigInt(2),GO=(n,e)=>(n+e/Xw)/e;function o9(n){const e=VO,t=BigInt(3),r=BigInt(6),s=BigInt(11),i=BigInt(22),o=BigInt(23),a=BigInt(44),l=BigInt(88),c=n*n*n%e,u=c*c*n%e,f=Er(u,t,e)*u%e,d=Er(f,t,e)*u%e,h=Er(d,Xw,e)*c%e,p=Er(h,s,e)*h%e,g=Er(p,i,e)*p%e,y=Er(g,a,e)*g%e,b=Er(y,l,e)*y%e,x=Er(b,a,e)*g%e,v=Er(x,t,e)*u%e,w=Er(v,o,e)*p%e,E=Er(w,r,e)*c%e,C=Er(E,Xw,e);if(!Zw.eql(Zw.sqr(C),n))throw new Error("Cannot find square root");return C}const Zw=KV(VO,void 0,void 0,{sqrt:o9}),uo=s9({a:BigInt(0),b:BigInt(7),Fp:Zw,n:WO,Gx:BigInt("55066263022277343669578718895168534326250603453777594175500187360389116729240"),Gy:BigInt("32670510020758816978083085130507043184471273380659243275938904335757337482424"),h:BigInt(1),lowS:!0,endo:{beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),splitScalar:n=>{const e=WO,t=BigInt("0x3086d221a7d46bcde86c90e49284eb15"),r=-i9*BigInt("0xe4437ed6010e88286f547fa90abfe4c3"),s=BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),i=t,o=BigInt("0x100000000000000000000000000000000"),a=GO(i*n,e),l=GO(-r*n,e);let c=zn(n-a*t-l*s,e),u=zn(-a*r-l*i,e);const f=c>o,d=u>o;if(f&&(c=e-c),d&&(u=e-u),c>o||u>o)throw new Error("splitScalar: Endomorphism failed, k="+n);return{k1neg:f,k1:c,k2neg:d,k2:u}}}},pO);BigInt(0),uo.ProjectivePoint;const Xf="0x0000000000000000000000000000000000000000",KO="0x0000000000000000000000000000000000000000000000000000000000000000",JO=BigInt(0),qO=BigInt(1),QO=BigInt(2),YO=BigInt(27),XO=BigInt(28),_m=BigInt(35),bc={};function ZO(n){return ya(Sn(n),32)}const Qr=class Qr{constructor(e,t,r,s){W(this,Uc,void 0);W(this,Hc,void 0);W(this,jc,void 0);W(this,ja,void 0);Em(e,bc,"Signature"),D(this,Uc,t),D(this,Hc,r),D(this,jc,s),D(this,ja,null)}get r(){return k(this,Uc)}set r(e){H(cc(e)===32,"invalid r","value",e),D(this,Uc,ce(e))}get s(){return k(this,Hc)}set s(e){H(cc(e)===32,"invalid s","value",e);const t=ce(e);H(parseInt(t.substring(0,3))<8,"non-canonical s","value",t),D(this,Hc,t)}get v(){return k(this,jc)}set v(e){const t=Pe(e,"value");H(t===27||t===28,"invalid v","v",e),D(this,jc,t)}get networkV(){return k(this,ja)}get legacyChainId(){const e=this.networkV;return e==null?null:Qr.getChainId(e)}get yParity(){return this.v===27?0:1}get yParityAndS(){const e=qe(this.s);return this.yParity&&(e[0]|=128),ce(e)}get compactSerialized(){return Rt([this.r,this.yParityAndS])}get serialized(){return Rt([this.r,this.s,this.yParity?"0x1c":"0x1b"])}[Symbol.for("nodejs.util.inspect.custom")](){return`Signature { r: "${this.r}", s: "${this.s}", yParity: ${this.yParity}, networkV: ${this.networkV} }`}clone(){const e=new Qr(bc,this.r,this.s,this.v);return this.networkV&&D(e,ja,this.networkV),e}toJSON(){const e=this.networkV;return{_type:"signature",networkV:e!=null?e.toString():null,r:this.r,s:this.s,v:this.v}}static getChainId(e){const t=pe(e,"v");return t==YO||t==XO?JO:(H(t>=_m,"invalid EIP-155 v","v",e),(t-_m)/QO)}static getChainIdV(e,t){return pe(e)*QO+BigInt(35+t-27)}static getNormalizedV(e){const t=pe(e);return t===JO||t===YO?27:t===qO||t===XO?28:(H(t>=_m,"invalid v","v",e),t&qO?27:28)}static from(e){function t(c,u){H(c,u,"signature",e)}if(e==null)return new Qr(bc,KO,KO,27);if(typeof e=="string"){const c=qe(e,"signature");if(c.length===64){const u=ce(c.slice(0,32)),f=c.slice(32,64),d=f[0]&128?28:27;return f[0]&=127,new Qr(bc,u,ce(f),d)}if(c.length===65){const u=ce(c.slice(0,32)),f=c.slice(32,64);t((f[0]&128)===0,"non-canonical s");const d=Qr.getNormalizedV(c[64]);return new Qr(bc,u,ce(f),d)}t(!1,"invalid raw signature length")}if(e instanceof Qr)return e.clone();const r=e.r;t(r!=null,"missing r");const s=ZO(r),i=function(c,u){if(c!=null)return ZO(c);if(u!=null){t(pt(u,32),"invalid yParityAndS");const f=qe(u);return f[0]&=127,ce(f)}t(!1,"missing s")}(e.s,e.yParityAndS);t((qe(i)[0]&128)==0,"non-canonical s");const{networkV:o,v:a}=function(c,u,f){if(c!=null){const d=pe(c);return{networkV:d>=_m?d:void 0,v:Qr.getNormalizedV(d)}}if(u!=null)return t(pt(u,32),"invalid yParityAndS"),{v:qe(u)[0]&128?28:27};if(f!=null){switch(Pe(f,"sig.yParity")){case 0:return{v:27};case 1:return{v:28}}t(!1,"invalid yParity")}t(!1,"missing v")}(e.v,e.yParityAndS,e.yParity),l=new Qr(bc,s,i,a);return o&&D(l,ja,o),t(e.yParity==null||Pe(e.yParity,"sig.yParity")===l.yParity,"yParity mismatch"),t(e.yParityAndS==null||e.yParityAndS===l.yParityAndS,"yParityAndS mismatch"),l}};Uc=new WeakMap,Hc=new WeakMap,jc=new WeakMap,ja=new WeakMap;let Wr=Qr;const $a=class $a{constructor(e){W(this,mi,void 0);H(cc(e)===32,"invalid private key","privateKey","[REDACTED]"),D(this,mi,ce(e))}get privateKey(){return k(this,mi)}get publicKey(){return $a.computePublicKey(k(this,mi))}get compressedPublicKey(){return $a.computePublicKey(k(this,mi),!0)}sign(e){H(cc(e)===32,"invalid digest length","digest",e);const t=uo.sign(Cn(e),Cn(k(this,mi)),{lowS:!0});return Wr.from({r:so(t.r,32),s:so(t.s,32),v:t.recovery?28:27})}computeSharedSecret(e){const t=$a.computePublicKey(e);return ce(uo.getSharedSecret(Cn(k(this,mi)),qe(t),!1))}static computePublicKey(e,t){let r=qe(e,"key");if(r.length===32){const i=uo.getPublicKey(r,!!t);return ce(i)}if(r.length===64){const i=new Uint8Array(65);i[0]=4,i.set(r,1),r=i}const s=uo.ProjectivePoint.fromHex(r);return ce(s.toRawBytes(t))}static recoverPublicKey(e,t){H(cc(e)===32,"invalid digest length","digest",e);const r=Wr.from(t);let s=uo.Signature.fromCompact(Cn(Rt([r.r,r.s])));s=s.addRecoveryBit(r.yParity);const i=s.recoverPublicKey(Cn(e));return H(i!=null,"invalid signautre for digest","signature",t),"0x"+i.toHex(!1)}static addPoints(e,t,r){const s=uo.ProjectivePoint.fromHex($a.computePublicKey(e).substring(2)),i=uo.ProjectivePoint.fromHex($a.computePublicKey(t).substring(2));return"0x"+s.add(i).toHex(!!r)}};mi=new WeakMap;let Zf=$a;const a9=BigInt(0),l9=BigInt(36);function eN(n){n=n.toLowerCase();const e=n.substring(2).split(""),t=new Uint8Array(40);for(let s=0;s<40;s++)t[s]=e[s].charCodeAt(0);const r=qe(Ft(t));for(let s=0;s<40;s+=2)r[s>>1]>>4>=8&&(e[s]=e[s].toUpperCase()),(r[s>>1]&15)>=8&&(e[s+1]=e[s+1].toUpperCase());return"0x"+e.join("")}const ev={};for(let n=0;n<10;n++)ev[String(n)]=String(n);for(let n=0;n<26;n++)ev[String.fromCharCode(65+n)]=String(10+n);const tN=15;function c9(n){n=n.toUpperCase(),n=n.substring(4)+n.substring(0,2)+"00";let e=n.split("").map(r=>ev[r]).join("");for(;e.length>=tN;){let r=e.substring(0,tN);e=parseInt(r,10)%97+e.substring(r.length)}let t=String(98-parseInt(e,10)%97);for(;t.length<2;)t="0"+t;return t}const u9=function(){const n={};for(let e=0;e<36;e++){const t="0123456789abcdefghijklmnopqrstuvwxyz"[e];n[t]=BigInt(e)}return n}();function f9(n){n=n.toLowerCase();let e=a9;for(let t=0;t<n.length;t++)e=e*l9+u9[n[t]];return e}function st(n){if(H(typeof n=="string","invalid address","address",n),n.match(/^(0x)?[0-9a-fA-F]{40}$/)){n.startsWith("0x")||(n="0x"+n);const e=eN(n);return H(!n.match(/([A-F].*[a-f])|([a-f].*[A-F])/)||e===n,"bad address checksum","address",n),e}if(n.match(/^XE[0-9]{2}[0-9A-Za-z]{30,31}$/)){H(n.substring(2,4)===c9(n),"bad icap checksum","address",n);let e=f9(n.substring(4)).toString(16);for(;e.length<40;)e="0"+e;return eN("0x"+e)}H(!1,"invalid address","address",n)}function d9(n){const e=st(n.from);let r=pe(n.nonce,"tx.nonce").toString(16);return r==="0"?r="0x":r.length%2?r="0x0"+r:r="0x"+r,st(Nt(Ft(wa([e,r])),12))}function nN(n){return n&&typeof n.getAddress=="function"}function h9(n){try{return st(n),!0}catch{}return!1}async function tv(n,e){const t=await e;return(t==null||t==="0x0000000000000000000000000000000000000000")&&(X(typeof n!="string","unconfigured name","UNCONFIGURED_NAME",{value:n}),H(!1,"invalid AddressLike value; did not resolve to a value address","target",n)),st(t)}function Nn(n,e){if(typeof n=="string")return n.match(/^0x[0-9a-f]{40}$/i)?st(n):(X(e!=null,"ENS resolution requires a provider","UNSUPPORTED_OPERATION",{operation:"resolveName"}),tv(n,e.resolveName(n)));if(nN(n))return tv(n,n.getAddress());if(n&&typeof n.then=="function")return tv(n,n);H(!1,"unsupported addressable value","target",n)}const oi={};function ue(n,e){let t=!1;return e<0&&(t=!0,e*=-1),new mn(oi,`${t?"":"u"}int${e}`,n,{signed:t,width:e})}function Ye(n,e){return new mn(oi,`bytes${e||""}`,n,{size:e})}const rN=Symbol.for("_ethers_typed"),gi=class gi{constructor(e,t,r,s){j(this,"type");j(this,"value");W(this,za,void 0);j(this,"_typedSymbol");s==null&&(s=null),Em(oi,e,"Typed"),be(this,{_typedSymbol:rN,type:t,value:r}),D(this,za,s),this.format()}format(){if(this.type==="array")throw new Error("");if(this.type==="dynamicArray")throw new Error("");return this.type==="tuple"?`tuple(${this.value.map(e=>e.format()).join(",")})`:this.type}defaultValue(){return 0}minValue(){return 0}maxValue(){return 0}isBigInt(){return!!this.type.match(/^u?int[0-9]+$/)}isData(){return this.type.startsWith("bytes")}isString(){return this.type==="string"}get tupleName(){if(this.type!=="tuple")throw TypeError("not a tuple");return k(this,za)}get arrayLength(){if(this.type!=="array")throw TypeError("not an array");return k(this,za)===!0?-1:k(this,za)===!1?this.value.length:null}static from(e,t){return new gi(oi,e,t)}static uint8(e){return ue(e,8)}static uint16(e){return ue(e,16)}static uint24(e){return ue(e,24)}static uint32(e){return ue(e,32)}static uint40(e){return ue(e,40)}static uint48(e){return ue(e,48)}static uint56(e){return ue(e,56)}static uint64(e){return ue(e,64)}static uint72(e){return ue(e,72)}static uint80(e){return ue(e,80)}static uint88(e){return ue(e,88)}static uint96(e){return ue(e,96)}static uint104(e){return ue(e,104)}static uint112(e){return ue(e,112)}static uint120(e){return ue(e,120)}static uint128(e){return ue(e,128)}static uint136(e){return ue(e,136)}static uint144(e){return ue(e,144)}static uint152(e){return ue(e,152)}static uint160(e){return ue(e,160)}static uint168(e){return ue(e,168)}static uint176(e){return ue(e,176)}static uint184(e){return ue(e,184)}static uint192(e){return ue(e,192)}static uint200(e){return ue(e,200)}static uint208(e){return ue(e,208)}static uint216(e){return ue(e,216)}static uint224(e){return ue(e,224)}static uint232(e){return ue(e,232)}static uint240(e){return ue(e,240)}static uint248(e){return ue(e,248)}static uint256(e){return ue(e,256)}static uint(e){return ue(e,256)}static int8(e){return ue(e,-8)}static int16(e){return ue(e,-16)}static int24(e){return ue(e,-24)}static int32(e){return ue(e,-32)}static int40(e){return ue(e,-40)}static int48(e){return ue(e,-48)}static int56(e){return ue(e,-56)}static int64(e){return ue(e,-64)}static int72(e){return ue(e,-72)}static int80(e){return ue(e,-80)}static int88(e){return ue(e,-88)}static int96(e){return ue(e,-96)}static int104(e){return ue(e,-104)}static int112(e){return ue(e,-112)}static int120(e){return ue(e,-120)}static int128(e){return ue(e,-128)}static int136(e){return ue(e,-136)}static int144(e){return ue(e,-144)}static int152(e){return ue(e,-152)}static int160(e){return ue(e,-160)}static int168(e){return ue(e,-168)}static int176(e){return ue(e,-176)}static int184(e){return ue(e,-184)}static int192(e){return ue(e,-192)}static int200(e){return ue(e,-200)}static int208(e){return ue(e,-208)}static int216(e){return ue(e,-216)}static int224(e){return ue(e,-224)}static int232(e){return ue(e,-232)}static int240(e){return ue(e,-240)}static int248(e){return ue(e,-248)}static int256(e){return ue(e,-256)}static int(e){return ue(e,-256)}static bytes1(e){return Ye(e,1)}static bytes2(e){return Ye(e,2)}static bytes3(e){return Ye(e,3)}static bytes4(e){return Ye(e,4)}static bytes5(e){return Ye(e,5)}static bytes6(e){return Ye(e,6)}static bytes7(e){return Ye(e,7)}static bytes8(e){return Ye(e,8)}static bytes9(e){return Ye(e,9)}static bytes10(e){return Ye(e,10)}static bytes11(e){return Ye(e,11)}static bytes12(e){return Ye(e,12)}static bytes13(e){return Ye(e,13)}static bytes14(e){return Ye(e,14)}static bytes15(e){return Ye(e,15)}static bytes16(e){return Ye(e,16)}static bytes17(e){return Ye(e,17)}static bytes18(e){return Ye(e,18)}static bytes19(e){return Ye(e,19)}static bytes20(e){return Ye(e,20)}static bytes21(e){return Ye(e,21)}static bytes22(e){return Ye(e,22)}static bytes23(e){return Ye(e,23)}static bytes24(e){return Ye(e,24)}static bytes25(e){return Ye(e,25)}static bytes26(e){return Ye(e,26)}static bytes27(e){return Ye(e,27)}static bytes28(e){return Ye(e,28)}static bytes29(e){return Ye(e,29)}static bytes30(e){return Ye(e,30)}static bytes31(e){return Ye(e,31)}static bytes32(e){return Ye(e,32)}static address(e){return new gi(oi,"address",e)}static bool(e){return new gi(oi,"bool",!!e)}static bytes(e){return new gi(oi,"bytes",e)}static string(e){return new gi(oi,"string",e)}static array(e,t){throw new Error("not implemented yet")}static tuple(e,t){throw new Error("not implemented yet")}static overrides(e){return new gi(oi,"overrides",Object.assign({},e))}static isTyped(e){return e&&typeof e=="object"&&"_typedSymbol"in e&&e._typedSymbol===rN}static dereference(e,t){if(gi.isTyped(e)){if(e.type!==t)throw new Error(`invalid type: expecetd ${t}, got ${e.type}`);return e.value}return e}};za=new WeakMap;let mn=gi;class p9 extends si{constructor(e){super("address","address",e,!1)}defaultValue(){return"0x0000000000000000000000000000000000000000"}encode(e,t){let r=mn.dereference(t,"string");try{r=st(r)}catch(s){return this._throwError(s.message,t)}return e.writeValue(r)}decode(e){return st(so(e.readValue(),20))}}class m9 extends si{constructor(t){super(t.name,t.type,"_",t.dynamic);j(this,"coder");this.coder=t}defaultValue(){return this.coder.defaultValue()}encode(t,r){return this.coder.encode(t,r)}decode(t){return this.coder.decode(t)}}function sN(n,e,t){let r=[];if(Array.isArray(t))r=t;else if(t&&typeof t=="object"){let l={};r=e.map(c=>{const u=c.localName;return X(u,"cannot encode object for signature with missing names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),X(!l[u],"cannot encode object for signature with duplicate names","INVALID_ARGUMENT",{argument:"values",info:{coder:c},value:t}),l[u]=!0,t[u]})}else H(!1,"invalid tuple value","tuple",t);H(e.length===r.length,"types/value length mismatch","tuple",t);let s=new _w,i=new _w,o=[];e.forEach((l,c)=>{let u=r[c];if(l.dynamic){let f=i.length;l.encode(i,u);let d=s.writeUpdatableValue();o.push(h=>{d(h+f)})}else l.encode(s,u)}),o.forEach(l=>{l(s.length)});let a=n.appendWriter(s);return a+=n.appendWriter(i),a}function iN(n,e){let t=[],r=[],s=n.subReader(0);return e.forEach(i=>{let o=null;if(i.dynamic){let a=n.readIndex(),l=s.subReader(a);try{o=i.decode(l)}catch(c){if(Zt(c,"BUFFER_OVERRUN"))throw c;o=c,o.baseType=i.name,o.name=i.localName,o.type=i.type}}else try{o=i.decode(n)}catch(a){if(Zt(a,"BUFFER_OVERRUN"))throw a;o=a,o.baseType=i.name,o.name=i.localName,o.type=i.type}if(o==null)throw new Error("investigate");t.push(o),r.push(i.localName||null)}),dc.fromItems(t,r)}class g9 extends si{constructor(t,r,s){const i=t.type+"["+(r>=0?r:"")+"]",o=r===-1||t.dynamic;super("array",i,s,o);j(this,"coder");j(this,"length");be(this,{coder:t,length:r})}defaultValue(){const t=this.coder.defaultValue(),r=[];for(let s=0;s<this.length;s++)r.push(t);return r}encode(t,r){const s=mn.dereference(r,"array");Array.isArray(s)||this._throwError("expected array value",s);let i=this.length;i===-1&&(i=s.length,t.writeValue(s.length)),F2(s.length,i,"coder array"+(this.localName?" "+this.localName:""));let o=[];for(let a=0;a<s.length;a++)o.push(this.coder);return sN(t,o,s)}decode(t){let r=this.length;r===-1&&(r=t.readIndex(),X(r*On<=t.dataLength,"insufficient data length","BUFFER_OVERRUN",{buffer:t.bytes,offset:r*On,length:t.dataLength}));let s=[];for(let i=0;i<r;i++)s.push(new m9(this.coder));return iN(t,s)}}class y9 extends si{constructor(e){super("bool","bool",e,!1)}defaultValue(){return!1}encode(e,t){const r=mn.dereference(t,"bool");return e.writeValue(r?1:0)}decode(e){return!!e.readValue()}}class oN extends si{constructor(e,t){super(e,e,t,!0)}defaultValue(){return"0x"}encode(e,t){t=Cn(t);let r=e.writeValue(t.length);return r+=e.writeBytes(t),r}decode(e){return e.readBytes(e.readIndex(),!0)}}class b9 extends oN{constructor(e){super("bytes",e)}decode(e){return ce(super.decode(e))}}class w9 extends si{constructor(t,r){let s="bytes"+String(t);super(s,s,r,!1);j(this,"size");be(this,{size:t},{size:"number"})}defaultValue(){return"0x0000000000000000000000000000000000000000000000000000000000000000".substring(0,2+this.size*2)}encode(t,r){let s=Cn(mn.dereference(r,this.type));return s.length!==this.size&&this._throwError("incorrect data length",r),t.writeBytes(s)}decode(t){return ce(t.readBytes(this.size))}}const v9=new Uint8Array([]);class A9 extends si{constructor(e){super("null","",e,!1)}defaultValue(){return null}encode(e,t){return t!=null&&this._throwError("not null",t),e.writeBytes(v9)}decode(e){return e.readBytes(0),null}}const x9=BigInt(0),E9=BigInt(1),k9=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");class C9 extends si{constructor(t,r,s){const i=(r?"int":"uint")+t*8;super(i,i,s,!1);j(this,"size");j(this,"signed");be(this,{size:t,signed:r},{size:"number",signed:"boolean"})}defaultValue(){return 0}encode(t,r){let s=pe(mn.dereference(r,this.type)),i=Kf(k9,On*8);if(this.signed){let o=Kf(i,this.size*8-1);(s>o||s<-(o+E9))&&this._throwError("value out-of-bounds",r),s=$2(s,8*On)}else(s<x9||s>Kf(i,this.size*8))&&this._throwError("value out-of-bounds",r);return t.writeValue(s)}decode(t){let r=Kf(t.readValue(),this.size*8);return this.signed&&(r=Nz(r,this.size*8)),r}}class S9 extends oN{constructor(e){super("string",e)}defaultValue(){return""}encode(e,t){return super.encode(e,ri(mn.dereference(t,"string")))}decode(e){return fc(super.decode(e))}}class Lm extends si{constructor(t,r){let s=!1;const i=[];t.forEach(a=>{a.dynamic&&(s=!0),i.push(a.type)});const o="tuple("+i.join(",")+")";super("tuple",o,r,s);j(this,"coders");be(this,{coders:Object.freeze(t.slice())})}defaultValue(){const t=[];this.coders.forEach(s=>{t.push(s.defaultValue())});const r=this.coders.reduce((s,i)=>{const o=i.localName;return o&&(s[o]||(s[o]=0),s[o]++),s},{});return this.coders.forEach((s,i)=>{let o=s.localName;!o||r[o]!==1||(o==="length"&&(o="_length"),t[o]==null&&(t[o]=t[i]))}),Object.freeze(t)}encode(t,r){const s=mn.dereference(r,"tuple");return sN(t,this.coders,s)}decode(t){return iN(t,this.coders)}}function ka(n){return Ft(ri(n))}var T9="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";const aN=new Map([[8217,"apostrophe"],[8260,"fraction slash"],[12539,"middle dot"]]),lN=4;function O9(n){let e=0;function t(){return n[e++]<<8|n[e++]}let r=t(),s=1,i=[0,1];for(let E=1;E<r;E++)i.push(s+=t());let o=t(),a=e;e+=o;let l=0,c=0;function u(){return l==0&&(c=c<<8|n[e++],l=8),c>>--l&1}const f=31,d=2**f,h=d>>>1,p=h>>1,g=d-1;let y=0;for(let E=0;E<f;E++)y=y<<1|u();let b=[],x=0,v=d;for(;;){let E=Math.floor(((y-x+1)*s-1)/v),C=0,T=r;for(;T-C>1;){let O=C+T>>>1;E<i[O]?T=O:C=O}if(C==0)break;b.push(C);let N=x+Math.floor(v*i[C]/s),M=x+Math.floor(v*i[C+1]/s)-1;for(;!((N^M)&h);)y=y<<1&g|u(),N=N<<1&g,M=M<<1&g|1;for(;N&~M&p;)y=y&h|y<<1&g>>>1|u(),N=N<<1^h,M=(M^h)<<1|h|1;x=N,v=1+M-N}let w=r-4;return b.map(E=>{switch(E-w){case 3:return w+65792+(n[a++]<<16|n[a++]<<8|n[a++]);case 2:return w+256+(n[a++]<<8|n[a++]);case 1:return w+n[a++];default:return E-1}})}function N9(n){let e=0;return()=>n[e++]}function cN(n){return N9(O9(M9(n)))}function M9(n){let e=[];[..."ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"].forEach((s,i)=>e[s.charCodeAt(0)]=i);let t=n.length,r=new Uint8Array(6*t>>3);for(let s=0,i=0,o=0,a=0;s<t;s++)a=a<<6|e[n.charCodeAt(s)],o+=6,o>=8&&(r[i++]=a>>(o-=8));return r}function R9(n){return n&1?~n>>1:n>>1}function P9(n,e){let t=Array(n);for(let r=0,s=0;r<n;r++)t[r]=s+=R9(e());return t}function ed(n,e=0){let t=[];for(;;){let r=n(),s=n();if(!s)break;e+=r;for(let i=0;i<s;i++)t.push(e+i);e+=s+1}return t}function uN(n){return td(()=>{let e=ed(n);if(e.length)return e})}function fN(n){let e=[];for(;;){let t=n();if(t==0)break;e.push(D9(t,n))}for(;;){let t=n()-1;if(t<0)break;e.push(I9(t,n))}return e.flat()}function td(n){let e=[];for(;;){let t=n(e.length);if(!t)break;e.push(t)}return e}function dN(n,e,t){let r=Array(n).fill().map(()=>[]);for(let s=0;s<e;s++)P9(n,t).forEach((i,o)=>r[o].push(i));return r}function D9(n,e){let t=1+e(),r=e(),s=td(e);return dN(s.length,1+n,e).flatMap((o,a)=>{let[l,...c]=o;return Array(s[a]).fill().map((u,f)=>{let d=f*r;return[l+f*t,c.map(h=>h+d)]})})}function I9(n,e){let t=1+e();return dN(t,1+n,e).map(s=>[s[0],s.slice(1)])}function _9(n){let e=[],t=ed(n);return s(r([]),[]),e;function r(i){let o=n(),a=td(()=>{let l=ed(n).map(c=>t[c]);if(l.length)return r(l)});return{S:o,B:a,Q:i}}function s({S:i,B:o},a,l){if(!(i&4&&l===a[a.length-1])){i&2&&(l=a[a.length-1]),i&1&&e.push(a);for(let c of o)for(let u of c.Q)s(c,[...a,u],l)}}}function L9(n){return n.toString(16).toUpperCase().padStart(2,"0")}function hN(n){return`{${L9(n)}}`}function B9(n){let e=[];for(let t=0,r=n.length;t<r;){let s=n.codePointAt(t);t+=s<65536?1:2,e.push(s)}return e}function wc(n){let t=n.length;if(t<4096)return String.fromCodePoint(...n);let r=[];for(let s=0;s<t;)r.push(String.fromCodePoint(...n.slice(s,s+=4096)));return r.join("")}function F9(n,e){let t=n.length,r=t-e.length;for(let s=0;r==0&&s<t;s++)r=n[s]-e[s];return r}var U9="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";const nd=44032,Bm=4352,Fm=4449,Um=4519,pN=19,mN=21,vc=28,Hm=mN*vc,H9=pN*Hm,j9=nd+H9,$9=Bm+pN,z9=Fm+mN,V9=Um+vc;function rd(n){return n>>24&255}function gN(n){return n&16777215}let nv,yN,rv,jm;function W9(){let n=cN(U9);nv=new Map(uN(n).flatMap((e,t)=>e.map(r=>[r,t+1<<24]))),yN=new Set(ed(n)),rv=new Map,jm=new Map;for(let[e,t]of fN(n)){if(!yN.has(e)&&t.length==2){let[r,s]=t,i=jm.get(r);i||(i=new Map,jm.set(r,i)),i.set(s,e)}rv.set(e,t.reverse())}}function bN(n){return n>=nd&&n<j9}function G9(n,e){if(n>=Bm&&n<$9&&e>=Fm&&e<z9)return nd+(n-Bm)*Hm+(e-Fm)*vc;if(bN(n)&&e>Um&&e<V9&&(n-nd)%vc==0)return n+(e-Um);{let t=jm.get(n);return t&&(t=t.get(e),t)?t:-1}}function wN(n){nv||W9();let e=[],t=[],r=!1;function s(i){let o=nv.get(i);o&&(r=!0,i|=o),e.push(i)}for(let i of n)for(;;){if(i<128)e.push(i);else if(bN(i)){let o=i-nd,a=o/Hm|0,l=o%Hm/vc|0,c=o%vc;s(Bm+a),s(Fm+l),c>0&&s(Um+c)}else{let o=rv.get(i);o?t.push(...o):s(i)}if(!t.length)break;i=t.pop()}if(r&&e.length>1){let i=rd(e[0]);for(let o=1;o<e.length;o++){let a=rd(e[o]);if(a==0||i<=a){i=a;continue}let l=o-1;for(;;){let c=e[l+1];if(e[l+1]=e[l],e[l]=c,!l||(i=rd(e[--l]),i<=a))break}i=rd(e[o])}}return e}function K9(n){let e=[],t=[],r=-1,s=0;for(let i of n){let o=rd(i),a=gN(i);if(r==-1)o==0?r=a:e.push(a);else if(s>0&&s>=o)o==0?(e.push(r,...t),t.length=0,r=a):t.push(a),s=o;else{let l=G9(r,a);l>=0?r=l:s==0&&o==0?(e.push(r),r=a):(t.push(a),s=o)}}return r>=0&&e.push(r,...t),e}function vN(n){return wN(n).map(gN)}function J9(n){return K9(wN(n))}const AN=45,xN=".",EN=65039,kN=1,$m=n=>Array.from(n);function sd(n,e){return n.P.has(e)||n.Q.has(e)}class q9 extends Array{get is_emoji(){return!0}}let sv,CN,Ca,iv,SN,Ac,ov,xc,Sa,TN,av;function lv(){if(sv)return;let n=cN(T9);const e=()=>ed(n),t=()=>new Set(e()),r=(u,f)=>f.forEach(d=>u.add(d));sv=new Map(fN(n)),CN=t(),Ca=e(),iv=new Set(e().map(u=>Ca[u])),Ca=new Set(Ca),SN=t(),t();let s=uN(n),i=n();const o=()=>{let u=new Set;return e().forEach(f=>r(u,s[f])),r(u,e()),u};Ac=td(u=>{let f=td(n).map(d=>d+96);if(f.length){let d=u>=i;f[0]-=32,f=wc(f),d&&(f=`Restricted[${f}]`);let h=o(),p=o(),g=!n();return{N:f,P:h,Q:p,M:g,R:d}}}),ov=t(),xc=new Map;let a=e().concat($m(ov)).sort((u,f)=>u-f);a.forEach((u,f)=>{let d=n(),h=a[f]=d?a[f-d]:{V:[],M:new Map};h.V.push(u),ov.has(u)||xc.set(u,h)});for(let{V:u,M:f}of new Set(xc.values())){let d=[];for(let p of u){let g=Ac.filter(b=>sd(b,p)),y=d.find(({G:b})=>g.some(x=>b.has(x)));y||(y={G:new Set,V:[]},d.push(y)),y.V.push(p),r(y.G,g)}let h=d.flatMap(p=>$m(p.G));for(let{G:p,V:g}of d){let y=new Set(h.filter(b=>!p.has(b)));for(let b of g)f.set(b,y)}}Sa=new Set;let l=new Set;const c=u=>Sa.has(u)?l.add(u):Sa.add(u);for(let u of Ac){for(let f of u.P)c(f);for(let f of u.Q)c(f)}for(let u of Sa)!xc.has(u)&&!l.has(u)&&xc.set(u,kN);r(Sa,vN(Sa)),TN=_9(n).map(u=>q9.from(u)).sort(F9),av=new Map;for(let u of TN){let f=[av];for(let d of u){let h=f.map(p=>{let g=p.get(d);return g||(g=new Map,p.set(d,g)),g});d===EN?f.push(...h):f=h}for(let d of f)d.V=u}}function cv(n){return(ON(n)?"":`${uv(zm([n]))} `)+hN(n)}function uv(n){return`"${n}"`}function Q9(n){if(n.length>=4&&n[2]==AN&&n[3]==AN)throw new Error(`invalid label extension: "${wc(n.slice(0,4))}"`)}function Y9(n){for(let t=n.lastIndexOf(95);t>0;)if(n[--t]!==95)throw new Error("underscore allowed only at start")}function X9(n){let e=n[0],t=aN.get(e);if(t)throw id(`leading ${t}`);let r=n.length,s=-1;for(let i=1;i<r;i++){e=n[i];let o=aN.get(e);if(o){if(s==i)throw id(`${t} + ${o}`);s=i+1,t=o}}if(s==r)throw id(`trailing ${t}`)}function zm(n,e=1/0,t=hN){let r=[];Z9(n[0])&&r.push("◌"),n.length>e&&(e>>=1,n=[...n.slice(0,e),8230,...n.slice(-e)]);let s=0,i=n.length;for(let o=0;o<i;o++){let a=n[o];ON(a)&&(r.push(wc(n.slice(s,o))),r.push(t(a)),s=o+1)}return r.push(wc(n.slice(s,i))),r.join("")}function Z9(n){return lv(),Ca.has(n)}function ON(n){return lv(),SN.has(n)}function e7(n){return s7(t7(n,J9,a7))}function t7(n,e,t){if(!n)return[];lv();let r=0;return n.split(xN).map(s=>{let i=B9(s),o={input:i,offset:r};r+=i.length+1;try{let a=o.tokens=o7(i,e,t),l=a.length,c;if(!l)throw new Error("empty label");let u=o.output=a.flat();if(Y9(u),!(o.emoji=l>1||a[0].is_emoji)&&u.every(d=>d<128))Q9(u),c="ASCII";else{let d=a.flatMap(h=>h.is_emoji?[]:h);if(!d.length)c="Emoji";else{if(Ca.has(u[0]))throw id("leading combining mark");for(let g=1;g<l;g++){let y=a[g];if(!y.is_emoji&&Ca.has(y[0]))throw id(`emoji + combining mark: "${wc(a[g-1])} + ${zm([y[0]])}"`)}X9(u);let h=$m(new Set(d)),[p]=r7(h);i7(p,d),n7(p,h),c=p.N}}o.type=c}catch(a){o.error=a}return o})}function n7(n,e){let t,r=[];for(let s of e){let i=xc.get(s);if(i===kN)return;if(i){let o=i.M.get(s);if(t=t?t.filter(a=>o.has(a)):$m(o),!t.length)return}else r.push(s)}if(t){for(let s of t)if(r.every(i=>sd(s,i)))throw new Error(`whole-script confusable: ${n.N}/${s.N}`)}}function r7(n){let e=Ac;for(let t of n){let r=e.filter(s=>sd(s,t));if(!r.length)throw Ac.some(s=>sd(s,t))?MN(e[0],t):NN(t);if(e=r,r.length==1)break}return e}function s7(n){return n.map(({input:e,error:t,output:r})=>{if(t){let s=t.message;throw new Error(n.length==1?s:`Invalid label ${uv(zm(e,63))}: ${s}`)}return wc(r)}).join(xN)}function NN(n){return new Error(`disallowed character: ${cv(n)}`)}function MN(n,e){let t=cv(e),r=Ac.find(s=>s.P.has(e));return r&&(t=`${r.N} ${t}`),new Error(`illegal mixture: ${n.N} + ${t}`)}function id(n){return new Error(`illegal placement: ${n}`)}function i7(n,e){for(let t of e)if(!sd(n,t))throw MN(n,t);if(n.M){let t=vN(e);for(let r=1,s=t.length;r<s;r++)if(iv.has(t[r])){let i=r+1;for(let o;i<s&&iv.has(o=t[i]);i++)for(let a=r;a<i;a++)if(t[a]==o)throw new Error(`duplicate non-spacing marks: ${cv(o)}`);if(i-r>lN)throw new Error(`excessive non-spacing marks: ${uv(zm(t.slice(r-1,i)))} (${i-r}/${lN})`);r=i}}}function o7(n,e,t){let r=[],s=[];for(n=n.slice().reverse();n.length;){let i=l7(n);if(i)s.length&&(r.push(e(s)),s=[]),r.push(t(i));else{let o=n.pop();if(Sa.has(o))s.push(o);else{let a=sv.get(o);if(a)s.push(...a);else if(!CN.has(o))throw NN(o)}}}return s.length&&r.push(e(s)),r}function a7(n){return n.filter(e=>e!=EN)}function l7(n,e){let t=av,r,s=n.length;for(;s&&(t=t.get(n[--s]),!!t);){let{V:i}=t;i&&(r=i,n.length=s)}return r}const RN=new Uint8Array(32);RN.fill(0);function PN(n){return H(n.length!==0,"invalid ENS name; empty component","comp",n),n}function DN(n){const e=ri(c7(n)),t=[];if(n.length===0)return t;let r=0;for(let s=0;s<e.length;s++)e[s]===46&&(t.push(PN(e.slice(r,s))),r=s+1);return H(r<e.length,"invalid ENS name; empty component","name",n),t.push(PN(e.slice(r))),t}function c7(n){try{if(n.length===0)throw new Error("empty label");return e7(n)}catch(e){H(!1,`invalid ENS name (${e.message})`,"name",n)}}function fv(n){H(typeof n=="string","invalid ENS name; not a string","name",n),H(n.length,"invalid ENS name (empty label)","name",n);let e=RN;const t=DN(n);for(;t.length;)e=Ft(Rt([e,Ft(t.pop())]));return ce(e)}function u7(n,e){const t=e;return H(t<=255,"DNS encoded label cannot exceed 255","length",t),ce(Rt(DN(n).map(r=>{H(r.length<=t,`label ${JSON.stringify(n)} exceeds ${t} bytes`,"name",n);const s=new Uint8Array(r.length+1);return s.set(r,1),s[0]=s.length-1,s})))+"00"}function dv(n,e){return{address:st(n),storageKeys:e.map((t,r)=>(H(pt(t,32),"invalid slot",`storageKeys[${r}]`,t),t.toLowerCase()))}}function fo(n){if(Array.isArray(n))return n.map((t,r)=>Array.isArray(t)?(H(t.length===2,"invalid slot set",`value[${r}]`,t),dv(t[0],t[1])):(H(t!=null&&typeof t=="object","invalid address-slot set","value",n),dv(t.address,t.storageKeys)));H(n!=null&&typeof n=="object","invalid access list","value",n);const e=Object.keys(n).map(t=>{const r=n[t].reduce((s,i)=>(s[i]=!0,s),{});return dv(t,Object.keys(r).sort())});return e.sort((t,r)=>t.address.localeCompare(r.address)),e}function f7(n){let e;return typeof n=="string"?e=Zf.computePublicKey(n,!1):e=n.publicKey,st(Ft("0x"+e.substring(4)).substring(26))}function d7(n,e){return f7(Zf.recoverPublicKey(n,e))}const tn=BigInt(0),h7=BigInt(2),p7=BigInt(27),m7=BigInt(28),g7=BigInt(35),y7=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),hv=4096*32;function IN(n,e){let t=n.toString(16);for(;t.length<2;)t="0"+t;return t+=pc(e).substring(4),"0x"+t}function Vm(n){return n==="0x"?null:st(n)}function pv(n,e){try{return fo(n)}catch(t){H(!1,t.message,e,n)}}function od(n,e){return n==="0x"?0:Pe(n,e)}function Dt(n,e){if(n==="0x")return tn;const t=pe(n,e);return H(t<=y7,"value exceeds uint size",e,t),t}function gt(n,e){const t=pe(n,"value"),r=Sn(t);return H(r.length<=32,"value too large",`tx.${e}`,t),r}function mv(n){return fo(n).map(e=>[e.address,e.storageKeys])}function b7(n,e){H(Array.isArray(n),`invalid ${e}`,"value",n);for(let t=0;t<n.length;t++)H(pt(n[t],32),"invalid ${ param } hash",`value[${t}]`,n[t]);return n}function w7(n){const e=Om(n);H(Array.isArray(e)&&(e.length===9||e.length===6),"invalid field count for legacy transaction","data",n);const t={type:0,nonce:od(e[0],"nonce"),gasPrice:Dt(e[1],"gasPrice"),gasLimit:Dt(e[2],"gasLimit"),to:Vm(e[3]),value:Dt(e[4],"value"),data:ce(e[5]),chainId:tn};if(e.length===6)return t;const r=Dt(e[6],"v"),s=Dt(e[7],"r"),i=Dt(e[8],"s");if(s===tn&&i===tn)t.chainId=r;else{let o=(r-g7)/h7;o<tn&&(o=tn),t.chainId=o,H(o!==tn||r===p7||r===m7,"non-canonical legacy v","v",e[6]),t.signature=Wr.from({r:ya(e[7],32),s:ya(e[8],32),v:r})}return t}function v7(n,e){const t=[gt(n.nonce,"nonce"),gt(n.gasPrice||0,"gasPrice"),gt(n.gasLimit,"gasLimit"),n.to||"0x",gt(n.value,"value"),n.data];let r=tn;if(n.chainId!=tn)r=pe(n.chainId,"tx.chainId"),H(!e||e.networkV==null||e.legacyChainId===r,"tx.chainId/sig.v mismatch","sig",e);else if(n.signature){const i=n.signature.legacyChainId;i!=null&&(r=i)}if(!e)return r!==tn&&(t.push(Sn(r)),t.push("0x"),t.push("0x")),wa(t);let s=BigInt(27+e.yParity);return r!==tn?s=Wr.getChainIdV(r,e.v):BigInt(e.v)!==s&&H(!1,"tx.chainId/sig.v mismatch","sig",e),t.push(Sn(s)),t.push(Sn(e.r)),t.push(Sn(e.s)),wa(t)}function gv(n,e){let t;try{if(t=od(e[0],"yParity"),t!==0&&t!==1)throw new Error("bad yParity")}catch{H(!1,"invalid yParity","yParity",e[0])}const r=ya(e[1],32),s=ya(e[2],32),i=Wr.from({r,s,yParity:t});n.signature=i}function A7(n){const e=Om(qe(n).slice(1));H(Array.isArray(e)&&(e.length===9||e.length===12),"invalid field count for transaction type: 2","data",ce(n));const t={type:2,chainId:Dt(e[0],"chainId"),nonce:od(e[1],"nonce"),maxPriorityFeePerGas:Dt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Dt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Dt(e[4],"gasLimit"),to:Vm(e[5]),value:Dt(e[6],"value"),data:ce(e[7]),accessList:pv(e[8],"accessList")};return e.length===9||gv(t,e.slice(9)),t}function x7(n,e){const t=[gt(n.chainId,"chainId"),gt(n.nonce,"nonce"),gt(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gt(n.maxFeePerGas||0,"maxFeePerGas"),gt(n.gasLimit,"gasLimit"),n.to||"0x",gt(n.value,"value"),n.data,mv(n.accessList||[])];return e&&(t.push(gt(e.yParity,"yParity")),t.push(Sn(e.r)),t.push(Sn(e.s))),Rt(["0x02",wa(t)])}function E7(n){const e=Om(qe(n).slice(1));H(Array.isArray(e)&&(e.length===8||e.length===11),"invalid field count for transaction type: 1","data",ce(n));const t={type:1,chainId:Dt(e[0],"chainId"),nonce:od(e[1],"nonce"),gasPrice:Dt(e[2],"gasPrice"),gasLimit:Dt(e[3],"gasLimit"),to:Vm(e[4]),value:Dt(e[5],"value"),data:ce(e[6]),accessList:pv(e[7],"accessList")};return e.length===8||gv(t,e.slice(8)),t}function k7(n,e){const t=[gt(n.chainId,"chainId"),gt(n.nonce,"nonce"),gt(n.gasPrice||0,"gasPrice"),gt(n.gasLimit,"gasLimit"),n.to||"0x",gt(n.value,"value"),n.data,mv(n.accessList||[])];return e&&(t.push(gt(e.yParity,"recoveryParam")),t.push(Sn(e.r)),t.push(Sn(e.s))),Rt(["0x01",wa(t)])}function C7(n){let e=Om(qe(n).slice(1)),t="3",r=null;if(e.length===4&&Array.isArray(e[0])){t="3 (network format)";const i=e[1],o=e[2],a=e[3];H(Array.isArray(i),"invalid network format: blobs not an array","fields[1]",i),H(Array.isArray(o),"invalid network format: commitments not an array","fields[2]",o),H(Array.isArray(a),"invalid network format: proofs not an array","fields[3]",a),H(i.length===o.length,"invalid network format: blobs/commitments length mismatch","fields",e),H(i.length===a.length,"invalid network format: blobs/proofs length mismatch","fields",e),r=[];for(let l=0;l<e[1].length;l++)r.push({data:i[l],commitment:o[l],proof:a[l]});e=e[0]}H(Array.isArray(e)&&(e.length===11||e.length===14),`invalid field count for transaction type: ${t}`,"data",ce(n));const s={type:3,chainId:Dt(e[0],"chainId"),nonce:od(e[1],"nonce"),maxPriorityFeePerGas:Dt(e[2],"maxPriorityFeePerGas"),maxFeePerGas:Dt(e[3],"maxFeePerGas"),gasPrice:null,gasLimit:Dt(e[4],"gasLimit"),to:Vm(e[5]),value:Dt(e[6],"value"),data:ce(e[7]),accessList:pv(e[8],"accessList"),maxFeePerBlobGas:Dt(e[9],"maxFeePerBlobGas"),blobVersionedHashes:e[10]};r&&(s.blobs=r),H(s.to!=null,`invalid address for transaction type: ${t}`,"data",n),H(Array.isArray(s.blobVersionedHashes),"invalid blobVersionedHashes: must be an array","data",n);for(let i=0;i<s.blobVersionedHashes.length;i++)H(pt(s.blobVersionedHashes[i],32),`invalid blobVersionedHash at index ${i}: must be length 32`,"data",n);return e.length===11||gv(s,e.slice(11)),s}function S7(n,e,t){const r=[gt(n.chainId,"chainId"),gt(n.nonce,"nonce"),gt(n.maxPriorityFeePerGas||0,"maxPriorityFeePerGas"),gt(n.maxFeePerGas||0,"maxFeePerGas"),gt(n.gasLimit,"gasLimit"),n.to||Xf,gt(n.value,"value"),n.data,mv(n.accessList||[]),gt(n.maxFeePerBlobGas||0,"maxFeePerBlobGas"),b7(n.blobVersionedHashes||[],"blobVersionedHashes")];return e&&(r.push(gt(e.yParity,"yParity")),r.push(Sn(e.r)),r.push(Sn(e.s)),t)?Rt(["0x03",wa([r,t.map(s=>s.data),t.map(s=>s.commitment),t.map(s=>s.proof)])]):Rt(["0x03",wa(r)])}const bi=class bi{constructor(){W(this,Zc);W(this,Ms,void 0);W(this,$c,void 0);W(this,zc,void 0);W(this,Vc,void 0);W(this,Wc,void 0);W(this,Gc,void 0);W(this,Kc,void 0);W(this,Jc,void 0);W(this,qc,void 0);W(this,Qc,void 0);W(this,Yc,void 0);W(this,Xc,void 0);W(this,Va,void 0);W(this,yo,void 0);W(this,yi,void 0);W(this,bo,void 0);D(this,Ms,null),D(this,$c,null),D(this,Vc,0),D(this,Wc,tn),D(this,Gc,null),D(this,Kc,null),D(this,Jc,null),D(this,zc,"0x"),D(this,qc,tn),D(this,Qc,tn),D(this,Yc,null),D(this,Xc,null),D(this,Va,null),D(this,yo,null),D(this,bo,null),D(this,yi,null)}get type(){return k(this,Ms)}set type(e){switch(e){case null:D(this,Ms,null);break;case 0:case"legacy":D(this,Ms,0);break;case 1:case"berlin":case"eip-2930":D(this,Ms,1);break;case 2:case"london":case"eip-1559":D(this,Ms,2);break;case 3:case"cancun":case"eip-4844":D(this,Ms,3);break;default:H(!1,"unsupported transaction type","type",e)}}get typeName(){switch(this.type){case 0:return"legacy";case 1:return"eip-2930";case 2:return"eip-1559";case 3:return"eip-4844"}return null}get to(){const e=k(this,$c);return e==null&&this.type===3?Xf:e}set to(e){D(this,$c,e==null?null:st(e))}get nonce(){return k(this,Vc)}set nonce(e){D(this,Vc,Pe(e,"value"))}get gasLimit(){return k(this,Wc)}set gasLimit(e){D(this,Wc,pe(e))}get gasPrice(){const e=k(this,Gc);return e==null&&(this.type===0||this.type===1)?tn:e}set gasPrice(e){D(this,Gc,e==null?null:pe(e,"gasPrice"))}get maxPriorityFeePerGas(){const e=k(this,Kc);return e??(this.type===2||this.type===3?tn:null)}set maxPriorityFeePerGas(e){D(this,Kc,e==null?null:pe(e,"maxPriorityFeePerGas"))}get maxFeePerGas(){const e=k(this,Jc);return e??(this.type===2||this.type===3?tn:null)}set maxFeePerGas(e){D(this,Jc,e==null?null:pe(e,"maxFeePerGas"))}get data(){return k(this,zc)}set data(e){D(this,zc,ce(e))}get value(){return k(this,qc)}set value(e){D(this,qc,pe(e,"value"))}get chainId(){return k(this,Qc)}set chainId(e){D(this,Qc,pe(e))}get signature(){return k(this,Yc)||null}set signature(e){D(this,Yc,e==null?null:Wr.from(e))}get accessList(){const e=k(this,Xc)||null;return e??(this.type===1||this.type===2||this.type===3?[]:null)}set accessList(e){D(this,Xc,e==null?null:fo(e))}get maxFeePerBlobGas(){const e=k(this,Va);return e==null&&this.type===3?tn:e}set maxFeePerBlobGas(e){D(this,Va,e==null?null:pe(e,"maxFeePerBlobGas"))}get blobVersionedHashes(){let e=k(this,yo);return e==null&&this.type===3?[]:e}set blobVersionedHashes(e){if(e!=null){H(Array.isArray(e),"blobVersionedHashes must be an Array","value",e),e=e.slice();for(let t=0;t<e.length;t++)H(pt(e[t],32),"invalid blobVersionedHash",`value[${t}]`,e[t])}D(this,yo,e)}get blobs(){return k(this,bo)==null?null:k(this,bo).map(e=>Object.assign({},e))}set blobs(e){if(e==null){D(this,bo,null);return}const t=[],r=[];for(let s=0;s<e.length;s++){const i=e[s];if(Mw(i)){X(k(this,yi),"adding a raw blob requires a KZG library","UNSUPPORTED_OPERATION",{operation:"set blobs()"});let o=qe(i);if(H(o.length<=hv,"blob is too large",`blobs[${s}]`,i),o.length!==hv){const c=new Uint8Array(hv);c.set(o),o=c}const a=k(this,yi).blobToKzgCommitment(o),l=ce(k(this,yi).computeBlobKzgProof(o,a));t.push({data:ce(o),commitment:ce(a),proof:l}),r.push(IN(1,a))}else{const o=ce(i.commitment);t.push({data:ce(i.data),commitment:o,proof:ce(i.proof)}),r.push(IN(1,o))}}D(this,bo,t),D(this,yo,r)}get kzg(){return k(this,yi)}set kzg(e){D(this,yi,e)}get hash(){return this.signature==null?null:Ft(ie(this,Zc,Ng).call(this,!0,!1))}get unsignedHash(){return Ft(this.unsignedSerialized)}get from(){return this.signature==null?null:d7(this.unsignedHash,this.signature)}get fromPublicKey(){return this.signature==null?null:Zf.recoverPublicKey(this.unsignedHash,this.signature)}isSigned(){return this.signature!=null}get serialized(){return ie(this,Zc,Ng).call(this,!0,!0)}get unsignedSerialized(){return ie(this,Zc,Ng).call(this,!1,!1)}inferType(){const e=this.inferTypes();return e.indexOf(2)>=0?2:e.pop()}inferTypes(){const e=this.gasPrice!=null,t=this.maxFeePerGas!=null||this.maxPriorityFeePerGas!=null,r=this.accessList!=null,s=k(this,Va)!=null||k(this,yo);this.maxFeePerGas!=null&&this.maxPriorityFeePerGas!=null&&X(this.maxFeePerGas>=this.maxPriorityFeePerGas,"priorityFee cannot be more than maxFee","BAD_DATA",{value:this}),X(!t||this.type!==0&&this.type!==1,"transaction type cannot have maxFeePerGas or maxPriorityFeePerGas","BAD_DATA",{value:this}),X(this.type!==0||!r,"legacy transaction cannot have accessList","BAD_DATA",{value:this});const i=[];return this.type!=null?i.push(this.type):t?i.push(2):e?(i.push(1),r||i.push(0)):r?(i.push(1),i.push(2)):(s&&this.to||(i.push(0),i.push(1),i.push(2)),i.push(3)),i.sort(),i}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}clone(){return bi.from(this)}toJSON(){const e=t=>t==null?null:t.toString();return{type:this.type,to:this.to,data:this.data,nonce:this.nonce,gasLimit:e(this.gasLimit),gasPrice:e(this.gasPrice),maxPriorityFeePerGas:e(this.maxPriorityFeePerGas),maxFeePerGas:e(this.maxFeePerGas),value:e(this.value),chainId:e(this.chainId),sig:this.signature?this.signature.toJSON():null,accessList:this.accessList}}static from(e){if(e==null)return new bi;if(typeof e=="string"){const r=qe(e);if(r[0]>=127)return bi.from(w7(r));switch(r[0]){case 1:return bi.from(E7(r));case 2:return bi.from(A7(r));case 3:return bi.from(C7(r))}X(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:"from"})}const t=new bi;return e.type!=null&&(t.type=e.type),e.to!=null&&(t.to=e.to),e.nonce!=null&&(t.nonce=e.nonce),e.gasLimit!=null&&(t.gasLimit=e.gasLimit),e.gasPrice!=null&&(t.gasPrice=e.gasPrice),e.maxPriorityFeePerGas!=null&&(t.maxPriorityFeePerGas=e.maxPriorityFeePerGas),e.maxFeePerGas!=null&&(t.maxFeePerGas=e.maxFeePerGas),e.maxFeePerBlobGas!=null&&(t.maxFeePerBlobGas=e.maxFeePerBlobGas),e.data!=null&&(t.data=e.data),e.value!=null&&(t.value=e.value),e.chainId!=null&&(t.chainId=e.chainId),e.signature!=null&&(t.signature=Wr.from(e.signature)),e.accessList!=null&&(t.accessList=e.accessList),e.blobVersionedHashes!=null&&(t.blobVersionedHashes=e.blobVersionedHashes),e.kzg!=null&&(t.kzg=e.kzg),e.blobs!=null&&(t.blobs=e.blobs),e.hash!=null&&(H(t.isSigned(),"unsigned transaction cannot define '.hash'","tx",e),H(t.hash===e.hash,"hash mismatch","tx",e)),e.from!=null&&(H(t.isSigned(),"unsigned transaction cannot define '.from'","tx",e),H(t.from.toLowerCase()===(e.from||"").toLowerCase(),"from mismatch","tx",e)),t}};Ms=new WeakMap,$c=new WeakMap,zc=new WeakMap,Vc=new WeakMap,Wc=new WeakMap,Gc=new WeakMap,Kc=new WeakMap,Jc=new WeakMap,qc=new WeakMap,Qc=new WeakMap,Yc=new WeakMap,Xc=new WeakMap,Va=new WeakMap,yo=new WeakMap,yi=new WeakMap,bo=new WeakMap,Zc=new WeakSet,Ng=function(e,t){X(!e||this.signature!=null,"cannot serialize unsigned transaction; maybe you meant .unsignedSerialized","UNSUPPORTED_OPERATION",{operation:".serialized"});const r=e?this.signature:null;switch(this.inferType()){case 0:return v7(this,r);case 1:return k7(this,r);case 2:return x7(this,r);case 3:return S7(this,r,t?this.blobs:null)}X(!1,"unsupported transaction type","UNSUPPORTED_OPERATION",{operation:".serialized"})};let ad=bi;const _N=new Uint8Array(32);_N.fill(0);const T7=BigInt(-1),LN=BigInt(0),BN=BigInt(1),O7=BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff");function N7(n){const e=qe(n),t=e.length%32;return t?Rt([e,_N.slice(t)]):ce(e)}const M7=so(BN,32),R7=so(LN,32),FN={name:"string",version:"string",chainId:"uint256",verifyingContract:"address",salt:"bytes32"},yv=["name","version","chainId","verifyingContract","salt"];function UN(n){return function(e){return H(typeof e=="string",`invalid domain value for ${JSON.stringify(n)}`,`domain.${n}`,e),e}}const P7={name:UN("name"),version:UN("version"),chainId:function(n){const e=pe(n,"domain.chainId");return H(e>=0,"invalid chain ID","domain.chainId",n),Number.isSafeInteger(e)?Number(e):ba(e)},verifyingContract:function(n){try{return st(n).toLowerCase()}catch{}H(!1,'invalid domain value "verifyingContract"',"domain.verifyingContract",n)},salt:function(n){const e=qe(n,"domain.salt");return H(e.length===32,'invalid domain value "salt"',"domain.salt",n),ce(e)}};function bv(n){{const e=n.match(/^(u?)int(\d+)$/);if(e){const t=e[1]==="",r=parseInt(e[2]);H(r%8===0&&r!==0&&r<=256&&e[2]===String(r),"invalid numeric width","type",n);const s=Kf(O7,t?r-1:r),i=t?(s+BN)*T7:LN;return function(o){const a=pe(o,"value");return H(a>=i&&a<=s,`value out-of-bounds for ${n}`,"value",a),so(t?$2(a,256):a,32)}}}{const e=n.match(/^bytes(\d+)$/);if(e){const t=parseInt(e[1]);return H(t!==0&&t<=32&&e[1]===String(t),"invalid bytes width","type",n),function(r){const s=qe(r);return H(s.length===t,`invalid length for ${n}`,"value",r),N7(r)}}}switch(n){case"address":return function(e){return ya(st(e),32)};case"bool":return function(e){return e?M7:R7};case"bytes":return function(e){return Ft(e)};case"string":return function(e){return ka(e)}}return null}function HN(n,e){return`${n}(${e.map(({name:t,type:r})=>r+" "+t).join(",")})`}function Wm(n){const e=n.match(/^([^\x5b]*)((\x5b\d*\x5d)*)(\x5b(\d*)\x5d)$/);return e?{base:e[1],index:e[2]+e[4],array:{base:e[1],prefix:e[1]+e[2],count:e[5]?parseInt(e[5]):-1}}:{base:n}}const Cr=class Cr{constructor(e){W(this,wg);j(this,"primaryType");W(this,Ad,void 0);W(this,wi,void 0);W(this,eu,void 0);D(this,wi,new Map),D(this,eu,new Map);const t=new Map,r=new Map,s=new Map,i={};Object.keys(e).forEach(l=>{i[l]=e[l].map(({name:c,type:u})=>{let{base:f,index:d}=Wm(u);return f==="int"&&!e.int&&(f="int256"),f==="uint"&&!e.uint&&(f="uint256"),{name:c,type:f+(d||"")}}),t.set(l,new Set),r.set(l,[]),s.set(l,new Set)}),D(this,Ad,JSON.stringify(i));for(const l in i){const c=new Set;for(const u of i[l]){H(!c.has(u.name),`duplicate variable name ${JSON.stringify(u.name)} in ${JSON.stringify(l)}`,"types",e),c.add(u.name);const f=Wm(u.type).base;H(f!==l,`circular type reference to ${JSON.stringify(f)}`,"types",e),!bv(f)&&(H(r.has(f),`unknown type ${JSON.stringify(f)}`,"types",e),r.get(f).push(l),t.get(l).add(f))}}const o=Array.from(r.keys()).filter(l=>r.get(l).length===0);H(o.length!==0,"missing primary type","types",e),H(o.length===1,`ambiguous primary types or unused types: ${o.map(l=>JSON.stringify(l)).join(", ")}`,"types",e),be(this,{primaryType:o[0]});function a(l,c){H(!c.has(l),`circular type reference to ${JSON.stringify(l)}`,"types",e),c.add(l);for(const u of t.get(l))if(r.has(u)){a(u,c);for(const f of c)s.get(f).add(u)}c.delete(l)}a(this.primaryType,new Set);for(const[l,c]of s){const u=Array.from(c);u.sort(),k(this,wi).set(l,HN(l,i[l])+u.map(f=>HN(f,i[f])).join(""))}}get types(){return JSON.parse(k(this,Ad))}getEncoder(e){let t=k(this,eu).get(e);return t||(t=ie(this,wg,KM).call(this,e),k(this,eu).set(e,t)),t}encodeType(e){const t=k(this,wi).get(e);return H(t,`unknown type: ${JSON.stringify(e)}`,"name",e),t}encodeData(e,t){return this.getEncoder(e)(t)}hashStruct(e,t){return Ft(this.encodeData(e,t))}encode(e){return this.encodeData(this.primaryType,e)}hash(e){return this.hashStruct(this.primaryType,e)}_visit(e,t,r){if(bv(e))return r(e,t);const s=Wm(e).array;if(s)return H(s.count===-1||s.count===t.length,`array length mismatch; expected length ${s.count}`,"value",t),t.map(o=>this._visit(s.prefix,o,r));const i=this.types[e];if(i)return i.reduce((o,{name:a,type:l})=>(o[a]=this._visit(l,t[a],r),o),{});H(!1,`unknown type: ${e}`,"type",e)}visit(e,t){return this._visit(this.primaryType,e,t)}static from(e){return new Cr(e)}static getPrimaryType(e){return Cr.from(e).primaryType}static hashStruct(e,t,r){return Cr.from(t).hashStruct(e,r)}static hashDomain(e){const t=[];for(const r in e){if(e[r]==null)continue;const s=FN[r];H(s,`invalid typed-data domain key: ${JSON.stringify(r)}`,"domain",e),t.push({name:r,type:s})}return t.sort((r,s)=>yv.indexOf(r.name)-yv.indexOf(s.name)),Cr.hashStruct("EIP712Domain",{EIP712Domain:t},e)}static encode(e,t,r){return Rt(["0x1901",Cr.hashDomain(e),Cr.from(t).hash(r)])}static hash(e,t,r){return Ft(Cr.encode(e,t,r))}static async resolveNames(e,t,r,s){e=Object.assign({},e);for(const a in e)e[a]==null&&delete e[a];const i={};e.verifyingContract&&!pt(e.verifyingContract,20)&&(i[e.verifyingContract]="0x");const o=Cr.from(t);o.visit(r,(a,l)=>(a==="address"&&!pt(l,20)&&(i[l]="0x"),l));for(const a in i)i[a]=await s(a);return e.verifyingContract&&i[e.verifyingContract]&&(e.verifyingContract=i[e.verifyingContract]),r=o.visit(r,(a,l)=>a==="address"&&i[l]?i[l]:l),{domain:e,value:r}}static getPayload(e,t,r){Cr.hashDomain(e);const s={},i=[];yv.forEach(l=>{const c=e[l];c!=null&&(s[l]=P7[l](c),i.push({name:l,type:FN[l]}))});const o=Cr.from(t);t=o.types;const a=Object.assign({},t);return H(a.EIP712Domain==null,"types must not contain EIP712Domain type","types.EIP712Domain",t),a.EIP712Domain=i,o.encode(r),{types:a,domain:s,primaryType:o.primaryType,message:o.visit(r,(l,c)=>{if(l.match(/^bytes(\d*)/))return ce(qe(c));if(l.match(/^u?int/))return pe(c).toString();switch(l){case"address":return c.toLowerCase();case"bool":return!!c;case"string":return H(typeof c=="string","invalid string","value",c),c}H(!1,"unsupported type","type",l)})}}};Ad=new WeakMap,wi=new WeakMap,eu=new WeakMap,wg=new WeakSet,KM=function(e){{const s=bv(e);if(s)return s}const t=Wm(e).array;if(t){const s=t.prefix,i=this.getEncoder(s);return o=>{H(t.count===-1||t.count===o.length,`array length mismatch; expected length ${t.count}`,"value",o);let a=o.map(i);return k(this,wi).has(s)&&(a=a.map(Ft)),Ft(Rt(a))}}const r=this.types[e];if(r){const s=ka(k(this,wi).get(e));return i=>{const o=r.map(({name:a,type:l})=>{const c=this.getEncoder(l)(i[a]);return k(this,wi).has(l)?Ft(c):c});return o.unshift(s),Rt(o)}}H(!1,`unknown type: ${e}`,"type",e)};let Gm=Cr;function Mn(n){const e=new Set;return n.forEach(t=>e.add(t)),Object.freeze(e)}const D7=Mn("external public payable override".split(" ")),jN="constant external internal payable private public pure view override",I7=Mn(jN.split(" ")),$N="constructor error event fallback function receive struct",zN=Mn($N.split(" ")),VN="calldata memory storage payable indexed",_7=Mn(VN.split(" ")),L7=[$N,VN,"tuple returns",jN].join(" "),B7=Mn(L7.split(" ")),F7={"(":"OPEN_PAREN",")":"CLOSE_PAREN","[":"OPEN_BRACKET","]":"CLOSE_BRACKET",",":"COMMA","@":"AT"},U7=new RegExp("^(\\s*)"),H7=new RegExp("^([0-9]+)"),j7=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)"),WN=new RegExp("^([a-zA-Z$_][a-zA-Z0-9$_]*)$"),GN=new RegExp("^(address|bool|bytes([0-9]*)|string|u?int([0-9]*))$"),vg=class vg{constructor(e){W(this,xd);W(this,un,void 0);W(this,Yr,void 0);D(this,un,0),D(this,Yr,e.slice())}get offset(){return k(this,un)}get length(){return k(this,Yr).length-k(this,un)}clone(){return new vg(k(this,Yr))}reset(){D(this,un,0)}popKeyword(e){const t=this.peek();if(t.type!=="KEYWORD"||!e.has(t.text))throw new Error(`expected keyword ${t.text}`);return this.pop().text}popType(e){if(this.peek().type!==e){const t=this.peek();throw new Error(`expected ${e}; got ${t.type} ${JSON.stringify(t.text)}`)}return this.pop().text}popParen(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=ie(this,xd,r1).call(this,k(this,un)+1,e.match+1);return D(this,un,e.match+1),t}popParams(){const e=this.peek();if(e.type!=="OPEN_PAREN")throw new Error("bad start");const t=[];for(;k(this,un)<e.match-1;){const r=this.peek().linkNext;t.push(ie(this,xd,r1).call(this,k(this,un)+1,r)),D(this,un,r)}return D(this,un,e.match+1),t}peek(){if(k(this,un)>=k(this,Yr).length)throw new Error("out-of-bounds");return k(this,Yr)[k(this,un)]}peekKeyword(e){const t=this.peekType("KEYWORD");return t!=null&&e.has(t)?t:null}peekType(e){if(this.length===0)return null;const t=this.peek();return t.type===e?t.text:null}pop(){const e=this.peek();return Hd(this,un)._++,e}toString(){const e=[];for(let t=k(this,un);t<k(this,Yr).length;t++){const r=k(this,Yr)[t];e.push(`${r.type}:${r.text}`)}return`<TokenString ${e.join(" ")}>`}};un=new WeakMap,Yr=new WeakMap,xd=new WeakSet,r1=function(e=0,t=0){return new vg(k(this,Yr).slice(e,t).map(r=>Object.freeze(Object.assign({},r,{match:r.match-e,linkBack:r.linkBack-e,linkNext:r.linkNext-e}))))};let Gr=vg;function ho(n){const e=[],t=o=>{const a=i<n.length?JSON.stringify(n[i]):"$EOI";throw new Error(`invalid token ${a} at ${i}: ${o}`)};let r=[],s=[],i=0;for(;i<n.length;){let o=n.substring(i),a=o.match(U7);a&&(i+=a[1].length,o=n.substring(i));const l={depth:r.length,linkBack:-1,linkNext:-1,match:-1,type:"",text:"",offset:i,value:-1};e.push(l);let c=F7[o[0]]||"";if(c){if(l.type=c,l.text=o[0],i++,c==="OPEN_PAREN")r.push(e.length-1),s.push(e.length-1);else if(c=="CLOSE_PAREN")r.length===0&&t("no matching open bracket"),l.match=r.pop(),e[l.match].match=e.length-1,l.depth--,l.linkBack=s.pop(),e[l.linkBack].linkNext=e.length-1;else if(c==="COMMA")l.linkBack=s.pop(),e[l.linkBack].linkNext=e.length-1,s.push(e.length-1);else if(c==="OPEN_BRACKET")l.type="BRACKET";else if(c==="CLOSE_BRACKET"){let u=e.pop().text;if(e.length>0&&e[e.length-1].type==="NUMBER"){const f=e.pop().text;u=f+u,e[e.length-1].value=Pe(f)}if(e.length===0||e[e.length-1].type!=="BRACKET")throw new Error("missing opening bracket");e[e.length-1].text+=u}continue}if(a=o.match(j7),a){if(l.text=a[1],i+=l.text.length,B7.has(l.text)){l.type="KEYWORD";continue}if(l.text.match(GN)){l.type="TYPE";continue}l.type="ID";continue}if(a=o.match(H7),a){l.text=a[1],l.type="NUMBER",i+=l.text.length;continue}throw new Error(`unexpected token ${JSON.stringify(o[0])} at position ${i}`)}return new Gr(e.map(o=>Object.freeze(o)))}function KN(n,e){let t=[];for(const r in e.keys())n.has(r)&&t.push(r);if(t.length>1)throw new Error(`conflicting types: ${t.join(", ")}`)}function Km(n,e){if(e.peekKeyword(zN)){const t=e.pop().text;if(t!==n)throw new Error(`expected ${n}, got ${t}`)}return e.popType("ID")}function ai(n,e){const t=new Set;for(;;){const r=n.peekType("KEYWORD");if(r==null||e&&!e.has(r))break;if(n.pop(),t.has(r))throw new Error(`duplicate keywords: ${JSON.stringify(r)}`);t.add(r)}return Object.freeze(t)}function JN(n){let e=ai(n,I7);return KN(e,Mn("constant payable nonpayable".split(" "))),KN(e,Mn("pure view payable nonpayable".split(" "))),e.has("view")?"view":e.has("pure")?"pure":e.has("payable")?"payable":e.has("nonpayable")?"nonpayable":e.has("constant")?"view":"nonpayable"}function li(n,e){return n.popParams().map(t=>ln.from(t,e))}function qN(n){if(n.peekType("AT")){if(n.pop(),n.peekType("NUMBER"))return pe(n.pop().text);throw new Error("invalid gas")}return null}function Ta(n){if(n.length)throw new Error(`unexpected tokens at offset ${n.offset}: ${n.toString()}`)}const $7=new RegExp(/^(.*)\[([0-9]*)\]$/);function QN(n){const e=n.match(GN);if(H(e,"invalid type","type",n),n==="uint")return"uint256";if(n==="int")return"int256";if(e[2]){const t=parseInt(e[2]);H(t!==0&&t<=32,"invalid bytes length","type",n)}else if(e[3]){const t=parseInt(e[3]);H(t!==0&&t<=256&&t%8===0,"invalid numeric width","type",n)}return n}const kt={},Vn=Symbol.for("_ethers_internal"),YN="_ParamTypeInternal",XN="_ErrorInternal",ZN="_EventInternal",eM="_ConstructorInternal",tM="_FallbackInternal",nM="_FunctionInternal",rM="_StructInternal",Sr=class Sr{constructor(e,t,r,s,i,o,a,l){W(this,tu);j(this,"name");j(this,"type");j(this,"baseType");j(this,"indexed");j(this,"components");j(this,"arrayLength");j(this,"arrayChildren");if(Em(e,kt,"ParamType"),Object.defineProperty(this,Vn,{value:YN}),o&&(o=Object.freeze(o.slice())),s==="array"){if(a==null||l==null)throw new Error("")}else if(a!=null||l!=null)throw new Error("");if(s==="tuple"){if(o==null)throw new Error("")}else if(o!=null)throw new Error("");be(this,{name:t,type:r,baseType:s,indexed:i,components:o,arrayLength:a,arrayChildren:l})}format(e){if(e==null&&(e="sighash"),e==="json"){const r=this.name||"";if(this.isArray()){const i=JSON.parse(this.arrayChildren.format("json"));return i.name=r,i.type+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`,JSON.stringify(i)}const s={type:this.baseType==="tuple"?"tuple":this.type,name:r};return typeof this.indexed=="boolean"&&(s.indexed=this.indexed),this.isTuple()&&(s.components=this.components.map(i=>JSON.parse(i.format(e)))),JSON.stringify(s)}let t="";return this.isArray()?(t+=this.arrayChildren.format(e),t+=`[${this.arrayLength<0?"":String(this.arrayLength)}]`):this.isTuple()?t+="("+this.components.map(r=>r.format(e)).join(e==="full"?", ":",")+")":t+=this.type,e!=="sighash"&&(this.indexed===!0&&(t+=" indexed"),e==="full"&&this.name&&(t+=" "+this.name)),t}isArray(){return this.baseType==="array"}isTuple(){return this.baseType==="tuple"}isIndexable(){return this.indexed!=null}walk(e,t){if(this.isArray()){if(!Array.isArray(e))throw new Error("invalid array value");if(this.arrayLength!==-1&&e.length!==this.arrayLength)throw new Error("array is wrong length");const r=this;return e.map(s=>r.arrayChildren.walk(s,t))}if(this.isTuple()){if(!Array.isArray(e))throw new Error("invalid tuple value");if(e.length!==this.components.length)throw new Error("array is wrong length");const r=this;return e.map((s,i)=>r.components[i].walk(s,t))}return t(this.type,e)}async walkAsync(e,t){const r=[],s=[e];return ie(this,tu,Mg).call(this,r,e,t,i=>{s[0]=i}),r.length&&await Promise.all(r),s[0]}static from(e,t){if(Sr.isParamType(e))return e;if(typeof e=="string")try{return Sr.from(ho(e),t)}catch{H(!1,"invalid param type","obj",e)}else if(e instanceof Gr){let a="",l="",c=null;ai(e,Mn(["tuple"])).has("tuple")||e.peekType("OPEN_PAREN")?(l="tuple",c=e.popParams().map(g=>Sr.from(g)),a=`tuple(${c.map(g=>g.format()).join(",")})`):(a=QN(e.popType("TYPE")),l=a);let u=null,f=null;for(;e.length&&e.peekType("BRACKET");){const g=e.pop();u=new Sr(kt,"",a,l,null,c,f,u),f=g.value,a+=g.text,l="array",c=null}let d=null;if(ai(e,_7).has("indexed")){if(!t)throw new Error("");d=!0}const p=e.peekType("ID")?e.pop().text:"";if(e.length)throw new Error("leftover tokens");return new Sr(kt,p,a,l,d,c,f,u)}const r=e.name;H(!r||typeof r=="string"&&r.match(WN),"invalid name","obj.name",r);let s=e.indexed;s!=null&&(H(t,"parameter cannot be indexed","obj.indexed",e.indexed),s=!!s);let i=e.type,o=i.match($7);if(o){const a=parseInt(o[2]||"-1"),l=Sr.from({type:o[1],components:e.components});return new Sr(kt,r||"",i,"array",s,null,a,l)}if(i==="tuple"||i.startsWith("tuple(")||i.startsWith("(")){const a=e.components!=null?e.components.map(c=>Sr.from(c)):null;return new Sr(kt,r||"",i,"tuple",s,a,null,null)}return i=QN(e.type),new Sr(kt,r||"",i,i,s,null,null,null)}static isParamType(e){return e&&e[Vn]===YN}};tu=new WeakSet,Mg=function(e,t,r,s){if(this.isArray()){if(!Array.isArray(t))throw new Error("invalid array value");if(this.arrayLength!==-1&&t.length!==this.arrayLength)throw new Error("array is wrong length");const o=this.arrayChildren,a=t.slice();a.forEach((l,c)=>{var u;ie(u=o,tu,Mg).call(u,e,l,r,f=>{a[c]=f})}),s(a);return}if(this.isTuple()){const o=this.components;let a;if(Array.isArray(t))a=t.slice();else{if(t==null||typeof t!="object")throw new Error("invalid tuple value");a=o.map(l=>{if(!l.name)throw new Error("cannot use object value with unnamed components");if(!(l.name in t))throw new Error(`missing value for component ${l.name}`);return t[l.name]})}if(a.length!==this.components.length)throw new Error("array is wrong length");a.forEach((l,c)=>{var u;ie(u=o[c],tu,Mg).call(u,e,l,r,f=>{a[c]=f})}),s(a);return}const i=r(this.type,t);i.then?e.push(async function(){s(await i)}()):s(i)};let ln=Sr;class Oa{constructor(e,t,r){j(this,"type");j(this,"inputs");Em(e,kt,"Fragment"),r=Object.freeze(r.slice()),be(this,{type:t,inputs:r})}static from(e){if(typeof e=="string"){try{Oa.from(JSON.parse(e))}catch{}return Oa.from(ho(e))}if(e instanceof Gr)switch(e.peekKeyword(zN)){case"constructor":return ci.from(e);case"error":return Wn.from(e);case"event":return Ts.from(e);case"fallback":case"receive":return ui.from(e);case"function":return Os.from(e);case"struct":return Na.from(e)}else if(typeof e=="object"){switch(e.type){case"constructor":return ci.from(e);case"error":return Wn.from(e);case"event":return Ts.from(e);case"fallback":case"receive":return ui.from(e);case"function":return Os.from(e);case"struct":return Na.from(e)}X(!1,`unsupported type: ${e.type}`,"UNSUPPORTED_OPERATION",{operation:"Fragment.from"})}H(!1,"unsupported frgament object","obj",e)}static isConstructor(e){return ci.isFragment(e)}static isError(e){return Wn.isFragment(e)}static isEvent(e){return Ts.isFragment(e)}static isFunction(e){return Os.isFragment(e)}static isStruct(e){return Na.isFragment(e)}}class Jm extends Oa{constructor(t,r,s,i){super(t,r,i);j(this,"name");H(typeof s=="string"&&s.match(WN),"invalid identifier","name",s),i=Object.freeze(i.slice()),be(this,{name:s})}}function ld(n,e){return"("+e.map(t=>t.format(n)).join(n==="full"?", ":",")+")"}class Wn extends Jm{constructor(e,t,r){super(e,"error",t,r),Object.defineProperty(this,Vn,{value:XN})}get selector(){return ka(this.format("sighash")).substring(0,10)}format(e){if(e==null&&(e="sighash"),e==="json")return JSON.stringify({type:"error",name:this.name,inputs:this.inputs.map(r=>JSON.parse(r.format(e)))});const t=[];return e!=="sighash"&&t.push("error"),t.push(this.name+ld(e,this.inputs)),t.join(" ")}static from(e){if(Wn.isFragment(e))return e;if(typeof e=="string")return Wn.from(ho(e));if(e instanceof Gr){const t=Km("error",e),r=li(e);return Ta(e),new Wn(kt,t,r)}return new Wn(kt,e.name,e.inputs?e.inputs.map(ln.from):[])}static isFragment(e){return e&&e[Vn]===XN}}class Ts extends Jm{constructor(t,r,s,i){super(t,"event",r,s);j(this,"anonymous");Object.defineProperty(this,Vn,{value:ZN}),be(this,{anonymous:i})}get topicHash(){return ka(this.format("sighash"))}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"event",anonymous:this.anonymous,name:this.name,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("event"),r.push(this.name+ld(t,this.inputs)),t!=="sighash"&&this.anonymous&&r.push("anonymous"),r.join(" ")}static getTopicHash(t,r){return r=(r||[]).map(i=>ln.from(i)),new Ts(kt,t,r,!1).topicHash}static from(t){if(Ts.isFragment(t))return t;if(typeof t=="string")try{return Ts.from(ho(t))}catch{H(!1,"invalid event fragment","obj",t)}else if(t instanceof Gr){const r=Km("event",t),s=li(t,!0),i=!!ai(t,Mn(["anonymous"])).has("anonymous");return Ta(t),new Ts(kt,r,s,i)}return new Ts(kt,t.name,t.inputs?t.inputs.map(r=>ln.from(r,!0)):[],!!t.anonymous)}static isFragment(t){return t&&t[Vn]===ZN}}class ci extends Oa{constructor(t,r,s,i,o){super(t,r,s);j(this,"payable");j(this,"gas");Object.defineProperty(this,Vn,{value:eM}),be(this,{payable:i,gas:o})}format(t){if(X(t!=null&&t!=="sighash","cannot format a constructor for sighash","UNSUPPORTED_OPERATION",{operation:"format(sighash)"}),t==="json")return JSON.stringify({type:"constructor",stateMutability:this.payable?"payable":"undefined",payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t)))});const r=[`constructor${ld(t,this.inputs)}`];return this.payable&&r.push("payable"),this.gas!=null&&r.push(`@${this.gas.toString()}`),r.join(" ")}static from(t){if(ci.isFragment(t))return t;if(typeof t=="string")try{return ci.from(ho(t))}catch{H(!1,"invalid constuctor fragment","obj",t)}else if(t instanceof Gr){ai(t,Mn(["constructor"]));const r=li(t),s=!!ai(t,D7).has("payable"),i=qN(t);return Ta(t),new ci(kt,"constructor",r,s,i)}return new ci(kt,"constructor",t.inputs?t.inputs.map(ln.from):[],!!t.payable,t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Vn]===eM}}class ui extends Oa{constructor(t,r,s){super(t,"fallback",r);j(this,"payable");Object.defineProperty(this,Vn,{value:tM}),be(this,{payable:s})}format(t){const r=this.inputs.length===0?"receive":"fallback";if(t==="json"){const s=this.payable?"payable":"nonpayable";return JSON.stringify({type:r,stateMutability:s})}return`${r}()${this.payable?" payable":""}`}static from(t){if(ui.isFragment(t))return t;if(typeof t=="string")try{return ui.from(ho(t))}catch{H(!1,"invalid fallback fragment","obj",t)}else if(t instanceof Gr){const r=t.toString(),s=t.peekKeyword(Mn(["fallback","receive"]));if(H(s,"type must be fallback or receive","obj",r),t.popKeyword(Mn(["fallback","receive"]))==="receive"){const l=li(t);return H(l.length===0,"receive cannot have arguments","obj.inputs",l),ai(t,Mn(["payable"])),Ta(t),new ui(kt,[],!0)}let o=li(t);o.length?H(o.length===1&&o[0].type==="bytes","invalid fallback inputs","obj.inputs",o.map(l=>l.format("minimal")).join(", ")):o=[ln.from("bytes")];const a=JN(t);if(H(a==="nonpayable"||a==="payable","fallback cannot be constants","obj.stateMutability",a),ai(t,Mn(["returns"])).has("returns")){const l=li(t);H(l.length===1&&l[0].type==="bytes","invalid fallback outputs","obj.outputs",l.map(c=>c.format("minimal")).join(", "))}return Ta(t),new ui(kt,o,a==="payable")}if(t.type==="receive")return new ui(kt,[],!0);if(t.type==="fallback"){const r=[ln.from("bytes")],s=t.stateMutability==="payable";return new ui(kt,r,s)}H(!1,"invalid fallback description","obj",t)}static isFragment(t){return t&&t[Vn]===tM}}class Os extends Jm{constructor(t,r,s,i,o,a){super(t,"function",r,i);j(this,"constant");j(this,"outputs");j(this,"stateMutability");j(this,"payable");j(this,"gas");Object.defineProperty(this,Vn,{value:nM}),o=Object.freeze(o.slice()),be(this,{constant:s==="view"||s==="pure",gas:a,outputs:o,payable:s==="payable",stateMutability:s})}get selector(){return ka(this.format("sighash")).substring(0,10)}format(t){if(t==null&&(t="sighash"),t==="json")return JSON.stringify({type:"function",name:this.name,constant:this.constant,stateMutability:this.stateMutability!=="nonpayable"?this.stateMutability:void 0,payable:this.payable,gas:this.gas!=null?this.gas:void 0,inputs:this.inputs.map(s=>JSON.parse(s.format(t))),outputs:this.outputs.map(s=>JSON.parse(s.format(t)))});const r=[];return t!=="sighash"&&r.push("function"),r.push(this.name+ld(t,this.inputs)),t!=="sighash"&&(this.stateMutability!=="nonpayable"&&r.push(this.stateMutability),this.outputs&&this.outputs.length&&(r.push("returns"),r.push(ld(t,this.outputs))),this.gas!=null&&r.push(`@${this.gas.toString()}`)),r.join(" ")}static getSelector(t,r){return r=(r||[]).map(i=>ln.from(i)),new Os(kt,t,"view",r,[],null).selector}static from(t){if(Os.isFragment(t))return t;if(typeof t=="string")try{return Os.from(ho(t))}catch{H(!1,"invalid function fragment","obj",t)}else if(t instanceof Gr){const s=Km("function",t),i=li(t),o=JN(t);let a=[];ai(t,Mn(["returns"])).has("returns")&&(a=li(t));const l=qN(t);return Ta(t),new Os(kt,s,o,i,a,l)}let r=t.stateMutability;return r==null&&(r="payable",typeof t.constant=="boolean"?(r="view",t.constant||(r="payable",typeof t.payable=="boolean"&&!t.payable&&(r="nonpayable"))):typeof t.payable=="boolean"&&!t.payable&&(r="nonpayable")),new Os(kt,t.name,r,t.inputs?t.inputs.map(ln.from):[],t.outputs?t.outputs.map(ln.from):[],t.gas!=null?t.gas:null)}static isFragment(t){return t&&t[Vn]===nM}}class Na extends Jm{constructor(e,t,r){super(e,"struct",t,r),Object.defineProperty(this,Vn,{value:rM})}format(){throw new Error("@TODO")}static from(e){if(typeof e=="string")try{return Na.from(ho(e))}catch{H(!1,"invalid struct fragment","obj",e)}else if(e instanceof Gr){const t=Km("struct",e),r=li(e);return Ta(e),new Na(kt,t,r)}return new Na(kt,e.name,e.inputs?e.inputs.map(ln.from):[])}static isFragment(e){return e&&e[Vn]===rM}}const Kr=new Map;Kr.set(0,"GENERIC_PANIC"),Kr.set(1,"ASSERT_FALSE"),Kr.set(17,"OVERFLOW"),Kr.set(18,"DIVIDE_BY_ZERO"),Kr.set(33,"ENUM_RANGE_ERROR"),Kr.set(34,"BAD_STORAGE_DATA"),Kr.set(49,"STACK_UNDERFLOW"),Kr.set(50,"ARRAY_RANGE_ERROR"),Kr.set(65,"OUT_OF_MEMORY"),Kr.set(81,"UNINITIALIZED_FUNCTION_CALL");const z7=new RegExp(/^bytes([0-9]*)$/),V7=new RegExp(/^(u?int)([0-9]*)$/);let wv=null,sM=1024;function W7(n,e,t,r){let s="missing revert data",i=null;const o=null;let a=null;if(t){s="execution reverted";const c=qe(t);if(t=ce(t),c.length===0)s+=" (no data present; likely require(false) occurred",i="require(false)";else if(c.length%32!==4)s+=" (could not decode reason; invalid data length)";else if(ce(c.slice(0,4))==="0x08c379a0")try{i=r.decode(["string"],c.slice(4))[0],a={signature:"Error(string)",name:"Error",args:[i]},s+=`: ${JSON.stringify(i)}`}catch{s+=" (could not decode reason; invalid string data)"}else if(ce(c.slice(0,4))==="0x4e487b71")try{const u=Number(r.decode(["uint256"],c.slice(4))[0]);a={signature:"Panic(uint256)",name:"Panic",args:[u]},i=`Panic due to ${Kr.get(u)||"UNKNOWN"}(${u})`,s+=`: ${i}`}catch{s+=" (could not decode panic code)"}else s+=" (unknown custom error)"}const l={to:e.to?st(e.to):null,data:e.data||"0x"};return e.from&&(l.from=st(e.from)),wt(s,"CALL_EXCEPTION",{action:n,data:t,reason:i,transaction:l,invocation:o,revert:a})}const Ag=class Ag{constructor(){W(this,wo)}getDefaultValue(e){const t=e.map(s=>ie(this,wo,Nu).call(this,ln.from(s)));return new Lm(t,"_").defaultValue()}encode(e,t){F2(t.length,e.length,"types/values length mismatch");const r=e.map(o=>ie(this,wo,Nu).call(this,ln.from(o))),s=new Lm(r,"_"),i=new _w;return s.encode(i,t),i.data}decode(e,t,r){const s=e.map(o=>ie(this,wo,Nu).call(this,ln.from(o)));return new Lm(s,"_").decode(new Lw(t,r,sM))}static _setDefaultMaxInflation(e){H(typeof e=="number"&&Number.isInteger(e),"invalid defaultMaxInflation factor","value",e),sM=e}static defaultAbiCoder(){return wv==null&&(wv=new Ag),wv}static getBuiltinCallException(e,t,r){return W7(e,t,r,Ag.defaultAbiCoder())}};wo=new WeakSet,Nu=function(e){if(e.isArray())return new g9(ie(this,wo,Nu).call(this,e.arrayChildren),e.arrayLength,e.name);if(e.isTuple())return new Lm(e.components.map(r=>ie(this,wo,Nu).call(this,r)),e.name);switch(e.baseType){case"address":return new p9(e.name);case"bool":return new y9(e.name);case"string":return new S9(e.name);case"bytes":return new b9(e.name);case"":return new A9(e.name)}let t=e.type.match(V7);if(t){let r=parseInt(t[2]||"256");return H(r!==0&&r<=256&&r%8===0,"invalid "+t[1]+" bit length","param",e),new C9(r/8,t[1]==="int",e.name)}if(t=e.type.match(z7),t){let r=parseInt(t[1]);return H(r!==0&&r<=32,"invalid bytes length","param",e),new w9(r,e.name)}H(!1,"invalid type","type",e.type)};let Ec=Ag;class G7{constructor(e,t,r){j(this,"fragment");j(this,"name");j(this,"signature");j(this,"topic");j(this,"args");const s=e.name,i=e.format();be(this,{fragment:e,name:s,signature:i,topic:t,args:r})}}class K7{constructor(e,t,r,s){j(this,"fragment");j(this,"name");j(this,"args");j(this,"signature");j(this,"selector");j(this,"value");const i=e.name,o=e.format();be(this,{fragment:e,name:i,args:r,signature:o,selector:t,value:s})}}class J7{constructor(e,t,r){j(this,"fragment");j(this,"name");j(this,"args");j(this,"signature");j(this,"selector");const s=e.name,i=e.format();be(this,{fragment:e,name:s,args:r,signature:i,selector:t})}}class iM{constructor(e){j(this,"hash");j(this,"_isIndexed");be(this,{hash:e,_isIndexed:!0})}static isIndexed(e){return!!(e&&e._isIndexed)}}const oM={0:"generic panic",1:"assert(false)",17:"arithmetic overflow",18:"division or modulo by zero",33:"enum overflow",34:"invalid encoded storage byte array accessed",49:"out-of-bounds array access; popping on an empty array",50:"out-of-bounds access of an array or bytesN",65:"out of memory",81:"uninitialized function"},aM={"0x08c379a0":{signature:"Error(string)",name:"Error",inputs:["string"],reason:n=>`reverted with reason string ${JSON.stringify(n)}`},"0x4e487b71":{signature:"Panic(uint256)",name:"Panic",inputs:["uint256"],reason:n=>{let e="unknown panic code";return n>=0&&n<=255&&oM[n.toString()]&&(e=oM[n.toString()]),`reverted with panic code 0x${n.toString(16)} (${e})`}}},Wa=class Wa{constructor(e){W(this,nu);W(this,ru);j(this,"fragments");j(this,"deploy");j(this,"fallback");j(this,"receive");W(this,Rs,void 0);W(this,Ps,void 0);W(this,Ds,void 0);W(this,gn,void 0);let t=[];typeof e=="string"?t=JSON.parse(e):t=e,D(this,Ds,new Map),D(this,Rs,new Map),D(this,Ps,new Map);const r=[];for(const o of t)try{r.push(Oa.from(o))}catch(a){console.log(`[Warning] Invalid Fragment ${JSON.stringify(o)}:`,a.message)}be(this,{fragments:Object.freeze(r)});let s=null,i=!1;D(this,gn,this.getAbiCoder()),this.fragments.forEach((o,a)=>{let l;switch(o.type){case"constructor":if(this.deploy){console.log("duplicate definition - constructor");return}be(this,{deploy:o});return;case"fallback":o.inputs.length===0?i=!0:(H(!s||o.payable!==s.payable,"conflicting fallback fragments",`fragments[${a}]`,o),s=o,i=s.payable);return;case"function":l=k(this,Ds);break;case"event":l=k(this,Ps);break;case"error":l=k(this,Rs);break;default:return}const c=o.format();l.has(c)||l.set(c,o)}),this.deploy||be(this,{deploy:ci.from("constructor()")}),be(this,{fallback:s,receive:i})}format(e){const t=e?"minimal":"full";return this.fragments.map(s=>s.format(t))}formatJson(){const e=this.fragments.map(t=>t.format("json"));return JSON.stringify(e.map(t=>JSON.parse(t)))}getAbiCoder(){return Ec.defaultAbiCoder()}getFunctionName(e){const t=ie(this,nu,Rg).call(this,e,null,!1);return H(t,"no matching function","key",e),t.name}hasFunction(e){return!!ie(this,nu,Rg).call(this,e,null,!1)}getFunction(e,t){return ie(this,nu,Rg).call(this,e,t||null,!0)}forEachFunction(e){const t=Array.from(k(this,Ds).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(k(this,Ds).get(s),r)}}getEventName(e){const t=ie(this,ru,Pg).call(this,e,null,!1);return H(t,"no matching event","key",e),t.name}hasEvent(e){return!!ie(this,ru,Pg).call(this,e,null,!1)}getEvent(e,t){return ie(this,ru,Pg).call(this,e,t||null,!0)}forEachEvent(e){const t=Array.from(k(this,Ps).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(k(this,Ps).get(s),r)}}getError(e,t){if(pt(e)){const s=e.toLowerCase();if(aM[s])return Wn.from(aM[s].signature);for(const i of k(this,Rs).values())if(s===i.selector)return i;return null}if(e.indexOf("(")===-1){const s=[];for(const[i,o]of k(this,Rs))i.split("(")[0]===e&&s.push(o);if(s.length===0)return e==="Error"?Wn.from("error Error(string)"):e==="Panic"?Wn.from("error Panic(uint256)"):null;if(s.length>1){const i=s.map(o=>JSON.stringify(o.format())).join(", ");H(!1,`ambiguous error description (i.e. ${i})`,"name",e)}return s[0]}if(e=Wn.from(e).format(),e==="Error(string)")return Wn.from("error Error(string)");if(e==="Panic(uint256)")return Wn.from("error Panic(uint256)");const r=k(this,Rs).get(e);return r||null}forEachError(e){const t=Array.from(k(this,Rs).keys());t.sort((r,s)=>r.localeCompare(s));for(let r=0;r<t.length;r++){const s=t[r];e(k(this,Rs).get(s),r)}}_decodeParams(e,t){return k(this,gn).decode(e,t)}_encodeParams(e,t){return k(this,gn).encode(e,t)}encodeDeploy(e){return this._encodeParams(this.deploy.inputs,e||[])}decodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);H(r,"unknown error","fragment",e),e=r}return H(Nt(t,0,4)===e.selector,`data signature does not match error ${e.name}.`,"data",t),this._decodeParams(e.inputs,Nt(t,4))}encodeErrorResult(e,t){if(typeof e=="string"){const r=this.getError(e);H(r,"unknown error","fragment",e),e=r}return Rt([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);H(r,"unknown function","fragment",e),e=r}return H(Nt(t,0,4)===e.selector,`data signature does not match function ${e.name}.`,"data",t),this._decodeParams(e.inputs,Nt(t,4))}encodeFunctionData(e,t){if(typeof e=="string"){const r=this.getFunction(e);H(r,"unknown function","fragment",e),e=r}return Rt([e.selector,this._encodeParams(e.inputs,t||[])])}decodeFunctionResult(e,t){if(typeof e=="string"){const i=this.getFunction(e);H(i,"unknown function","fragment",e),e=i}let r="invalid length for result data";const s=Cn(t);if(s.length%32===0)try{return k(this,gn).decode(e.outputs,s)}catch{r="could not decode result data"}X(!1,r,"BAD_DATA",{value:ce(s),info:{method:e.name,signature:e.format()}})}makeError(e,t){const r=qe(e,"data"),s=Ec.getBuiltinCallException("call",t,r);if(s.message.startsWith("execution reverted (unknown custom error)")){const a=ce(r.slice(0,4)),l=this.getError(a);if(l)try{const c=k(this,gn).decode(l.inputs,r.slice(4));s.revert={name:l.name,signature:l.format(),args:c},s.reason=s.revert.signature,s.message=`execution reverted: ${s.reason}`}catch{s.message="execution reverted (coult not decode custom error)"}}const o=this.parseTransaction(t);return o&&(s.invocation={method:o.name,signature:o.signature,args:o.args}),s}encodeFunctionResult(e,t){if(typeof e=="string"){const r=this.getFunction(e);H(r,"unknown function","fragment",e),e=r}return ce(k(this,gn).encode(e.outputs,t||[]))}encodeFilterTopics(e,t){if(typeof e=="string"){const i=this.getEvent(e);H(i,"unknown event","eventFragment",e),e=i}X(t.length<=e.inputs.length,`too many arguments for ${e.format()}`,"UNEXPECTED_ARGUMENT",{count:t.length,expectedCount:e.inputs.length});const r=[];e.anonymous||r.push(e.topicHash);const s=(i,o)=>i.type==="string"?ka(o):i.type==="bytes"?Ft(ce(o)):(i.type==="bool"&&typeof o=="boolean"?o=o?"0x01":"0x00":i.type.match(/^u?int/)?o=so(o):i.type.match(/^bytes/)?o=Oz(o,32):i.type==="address"&&k(this,gn).encode(["address"],[o]),ya(ce(o),32));for(t.forEach((i,o)=>{const a=e.inputs[o];if(!a.indexed){H(i==null,"cannot filter non-indexed parameters; must be null","contract."+a.name,i);return}i==null?r.push(null):a.baseType==="array"||a.baseType==="tuple"?H(!1,"filtering with tuples or arrays not supported","contract."+a.name,i):Array.isArray(i)?r.push(i.map(l=>s(a,l))):r.push(s(a,i))});r.length&&r[r.length-1]===null;)r.pop();return r}encodeEventLog(e,t){if(typeof e=="string"){const o=this.getEvent(e);H(o,"unknown event","eventFragment",e),e=o}const r=[],s=[],i=[];return e.anonymous||r.push(e.topicHash),H(t.length===e.inputs.length,"event arguments/values mismatch","values",t),e.inputs.forEach((o,a)=>{const l=t[a];if(o.indexed)if(o.type==="string")r.push(ka(l));else if(o.type==="bytes")r.push(Ft(l));else{if(o.baseType==="tuple"||o.baseType==="array")throw new Error("not implemented");r.push(k(this,gn).encode([o.type],[l]))}else s.push(o),i.push(l)}),{data:k(this,gn).encode(s,i),topics:r}}decodeEventLog(e,t,r){if(typeof e=="string"){const h=this.getEvent(e);H(h,"unknown event","eventFragment",e),e=h}if(r!=null&&!e.anonymous){const h=e.topicHash;H(pt(r[0],32)&&r[0].toLowerCase()===h,"fragment/topic mismatch","topics[0]",r[0]),r=r.slice(1)}const s=[],i=[],o=[];e.inputs.forEach((h,p)=>{h.indexed?h.type==="string"||h.type==="bytes"||h.baseType==="tuple"||h.baseType==="array"?(s.push(ln.from({type:"bytes32",name:h.name})),o.push(!0)):(s.push(h),o.push(!1)):(i.push(h),o.push(!1))});const a=r!=null?k(this,gn).decode(s,Rt(r)):null,l=k(this,gn).decode(i,t,!0),c=[],u=[];let f=0,d=0;return e.inputs.forEach((h,p)=>{let g=null;if(h.indexed)if(a==null)g=new iM(null);else if(o[p])g=new iM(a[d++]);else try{g=a[d++]}catch(y){g=y}else try{g=l[f++]}catch(y){g=y}c.push(g),u.push(h.name||null)}),dc.fromItems(c,u)}parseTransaction(e){const t=qe(e.data,"tx.data"),r=pe(e.value!=null?e.value:0,"tx.value"),s=this.getFunction(ce(t.slice(0,4)));if(!s)return null;const i=k(this,gn).decode(s.inputs,t.slice(4));return new K7(s,s.selector,i,r)}parseCallResult(e){throw new Error("@TODO")}parseLog(e){const t=this.getEvent(e.topics[0]);return!t||t.anonymous?null:new G7(t,t.topicHash,this.decodeEventLog(t,e.data,e.topics))}parseError(e){const t=ce(e),r=this.getError(Nt(t,0,4));if(!r)return null;const s=k(this,gn).decode(r.inputs,Nt(t,4));return new J7(r,r.selector,s)}static from(e){return e instanceof Wa?e:typeof e=="string"?new Wa(JSON.parse(e)):typeof e.formatJson=="function"?new Wa(e.formatJson()):typeof e.format=="function"?new Wa(e.format("json")):new Wa(e)}};Rs=new WeakMap,Ps=new WeakMap,Ds=new WeakMap,gn=new WeakMap,nu=new WeakSet,Rg=function(e,t,r){if(pt(e)){const i=e.toLowerCase();for(const o of k(this,Ds).values())if(i===o.selector)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of k(this,Ds))o.split("(")[0]===e&&i.push(a);if(t){const o=t.length>0?t[t.length-1]:null;let a=t.length,l=!0;mn.isTyped(o)&&o.type==="overrides"&&(l=!1,a--);for(let c=i.length-1;c>=0;c--){const u=i[c].inputs.length;u!==a&&(!l||u!==a-1)&&i.splice(c,1)}for(let c=i.length-1;c>=0;c--){const u=i[c].inputs;for(let f=0;f<t.length;f++)if(mn.isTyped(t[f])){if(f>=u.length){if(t[f].type==="overrides")continue;i.splice(c,1);break}if(t[f].type!==u[f].baseType){i.splice(c,1);break}}}}if(i.length===1&&t&&t.length!==i[0].inputs.length){const o=t[t.length-1];(o==null||Array.isArray(o)||typeof o!="object")&&i.splice(0,1)}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");H(!1,`ambiguous function description (i.e. matches ${o})`,"key",e)}return i[0]}const s=k(this,Ds).get(Os.from(e).format());return s||null},ru=new WeakSet,Pg=function(e,t,r){if(pt(e)){const i=e.toLowerCase();for(const o of k(this,Ps).values())if(i===o.topicHash)return o;return null}if(e.indexOf("(")===-1){const i=[];for(const[o,a]of k(this,Ps))o.split("(")[0]===e&&i.push(a);if(t){for(let o=i.length-1;o>=0;o--)i[o].inputs.length<t.length&&i.splice(o,1);for(let o=i.length-1;o>=0;o--){const a=i[o].inputs;for(let l=0;l<t.length;l++)if(mn.isTyped(t[l])&&t[l].type!==a[l].baseType){i.splice(o,1);break}}}if(i.length===0)return null;if(i.length>1&&r){const o=i.map(a=>JSON.stringify(a.format())).join(", ");H(!1,`ambiguous event description (i.e. matches ${o})`,"key",e)}return i[0]}const s=k(this,Ps).get(Ts.from(e).format());return s||null};let vv=Wa;const lM=BigInt(0);function kc(n){return n??null}function It(n){return n==null?null:n.toString()}class cM{constructor(e,t,r){j(this,"gasPrice");j(this,"maxFeePerGas");j(this,"maxPriorityFeePerGas");be(this,{gasPrice:kc(e),maxFeePerGas:kc(t),maxPriorityFeePerGas:kc(r)})}toJSON(){const{gasPrice:e,maxFeePerGas:t,maxPriorityFeePerGas:r}=this;return{_type:"FeeData",gasPrice:It(e),maxFeePerGas:It(t),maxPriorityFeePerGas:It(r)}}}function qm(n){const e={};n.to&&(e.to=n.to),n.from&&(e.from=n.from),n.data&&(e.data=ce(n.data));const t="chainId,gasLimit,gasPrice,maxFeePerBlobGas,maxFeePerGas,maxPriorityFeePerGas,value".split(/,/);for(const s of t)!(s in n)||n[s]==null||(e[s]=pe(n[s],`request.${s}`));const r="type,nonce".split(/,/);for(const s of r)!(s in n)||n[s]==null||(e[s]=Pe(n[s],`request.${s}`));return n.accessList&&(e.accessList=fo(n.accessList)),"blockTag"in n&&(e.blockTag=n.blockTag),"enableCcipRead"in n&&(e.enableCcipRead=!!n.enableCcipRead),"customData"in n&&(e.customData=n.customData),"blobVersionedHashes"in n&&n.blobVersionedHashes&&(e.blobVersionedHashes=n.blobVersionedHashes.slice()),"kzg"in n&&(e.kzg=n.kzg),"blobs"in n&&n.blobs&&(e.blobs=n.blobs.map(s=>Mw(s)?ce(s):Object.assign({},s))),e}class q7{constructor(e,t){j(this,"provider");j(this,"number");j(this,"hash");j(this,"timestamp");j(this,"parentHash");j(this,"parentBeaconBlockRoot");j(this,"nonce");j(this,"difficulty");j(this,"gasLimit");j(this,"gasUsed");j(this,"stateRoot");j(this,"receiptsRoot");j(this,"blobGasUsed");j(this,"excessBlobGas");j(this,"miner");j(this,"prevRandao");j(this,"extraData");j(this,"baseFeePerGas");W(this,vi,void 0);D(this,vi,e.transactions.map(r=>typeof r!="string"?new ud(r,t):r)),be(this,{provider:t,hash:kc(e.hash),number:e.number,timestamp:e.timestamp,parentHash:e.parentHash,parentBeaconBlockRoot:e.parentBeaconBlockRoot,nonce:e.nonce,difficulty:e.difficulty,gasLimit:e.gasLimit,gasUsed:e.gasUsed,blobGasUsed:e.blobGasUsed,excessBlobGas:e.excessBlobGas,miner:e.miner,prevRandao:kc(e.prevRandao),extraData:e.extraData,baseFeePerGas:kc(e.baseFeePerGas),stateRoot:e.stateRoot,receiptsRoot:e.receiptsRoot})}get transactions(){return k(this,vi).map(e=>typeof e=="string"?e:e.hash)}get prefetchedTransactions(){const e=k(this,vi).slice();return e.length===0?[]:(X(typeof e[0]=="object","transactions were not prefetched with block request","UNSUPPORTED_OPERATION",{operation:"transactionResponses()"}),e)}toJSON(){const{baseFeePerGas:e,difficulty:t,extraData:r,gasLimit:s,gasUsed:i,hash:o,miner:a,prevRandao:l,nonce:c,number:u,parentHash:f,parentBeaconBlockRoot:d,stateRoot:h,receiptsRoot:p,timestamp:g,transactions:y}=this;return{_type:"Block",baseFeePerGas:It(e),difficulty:It(t),extraData:r,gasLimit:It(s),gasUsed:It(i),blobGasUsed:It(this.blobGasUsed),excessBlobGas:It(this.excessBlobGas),hash:o,miner:a,prevRandao:l,nonce:c,number:u,parentHash:f,timestamp:g,parentBeaconBlockRoot:d,stateRoot:h,receiptsRoot:p,transactions:y}}[Symbol.iterator](){let e=0;const t=this.transactions;return{next:()=>e<this.length?{value:t[e++],done:!1}:{value:void 0,done:!0}}}get length(){return k(this,vi).length}get date(){return this.timestamp==null?null:new Date(this.timestamp*1e3)}async getTransaction(e){let t;if(typeof e=="number")t=k(this,vi)[e];else{const r=e.toLowerCase();for(const s of k(this,vi))if(typeof s=="string"){if(s!==r)continue;t=s;break}else{if(s.hash===r)continue;t=s;break}}if(t==null)throw new Error("no such tx");return typeof t=="string"?await this.provider.getTransaction(t):t}getPrefetchedTransaction(e){const t=this.prefetchedTransactions;if(typeof e=="number")return t[e];e=e.toLowerCase();for(const r of t)if(r.hash===e)return r;H(!1,"no matching transaction","indexOrHash",e)}isMined(){return!!this.hash}isLondon(){return!!this.baseFeePerGas}orphanedEvent(){if(!this.isMined())throw new Error("");return Q7(this)}}vi=new WeakMap;class cd{constructor(e,t){j(this,"provider");j(this,"transactionHash");j(this,"blockHash");j(this,"blockNumber");j(this,"removed");j(this,"address");j(this,"data");j(this,"topics");j(this,"index");j(this,"transactionIndex");this.provider=t;const r=Object.freeze(e.topics.slice());be(this,{transactionHash:e.transactionHash,blockHash:e.blockHash,blockNumber:e.blockNumber,removed:e.removed,address:e.address,data:e.data,topics:r,index:e.index,transactionIndex:e.transactionIndex})}toJSON(){const{address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:l,transactionIndex:c}=this;return{_type:"log",address:e,blockHash:t,blockNumber:r,data:s,index:i,removed:o,topics:a,transactionHash:l,transactionIndex:c}}async getBlock(){const e=await this.provider.getBlock(this.blockHash);return X(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransaction(){const e=await this.provider.getTransaction(this.transactionHash);return X(!!e,"failed to find transaction","UNKNOWN_ERROR",{}),e}async getTransactionReceipt(){const e=await this.provider.getTransactionReceipt(this.transactionHash);return X(!!e,"failed to find transaction receipt","UNKNOWN_ERROR",{}),e}removedEvent(){return Y7(this)}}class uM{constructor(e,t){j(this,"provider");j(this,"to");j(this,"from");j(this,"contractAddress");j(this,"hash");j(this,"index");j(this,"blockHash");j(this,"blockNumber");j(this,"logsBloom");j(this,"gasUsed");j(this,"blobGasUsed");j(this,"cumulativeGasUsed");j(this,"gasPrice");j(this,"blobGasPrice");j(this,"type");j(this,"status");j(this,"root");W(this,Ed,void 0);D(this,Ed,Object.freeze(e.logs.map(s=>new cd(s,t))));let r=lM;e.effectiveGasPrice!=null?r=e.effectiveGasPrice:e.gasPrice!=null&&(r=e.gasPrice),be(this,{provider:t,to:e.to,from:e.from,contractAddress:e.contractAddress,hash:e.hash,index:e.index,blockHash:e.blockHash,blockNumber:e.blockNumber,logsBloom:e.logsBloom,gasUsed:e.gasUsed,cumulativeGasUsed:e.cumulativeGasUsed,blobGasUsed:e.blobGasUsed,gasPrice:r,blobGasPrice:e.blobGasPrice,type:e.type,status:e.status,root:e.root})}get logs(){return k(this,Ed)}toJSON(){const{to:e,from:t,contractAddress:r,hash:s,index:i,blockHash:o,blockNumber:a,logsBloom:l,logs:c,status:u,root:f}=this;return{_type:"TransactionReceipt",blockHash:o,blockNumber:a,contractAddress:r,cumulativeGasUsed:It(this.cumulativeGasUsed),from:t,gasPrice:It(this.gasPrice),blobGasUsed:It(this.blobGasUsed),blobGasPrice:It(this.blobGasPrice),gasUsed:It(this.gasUsed),hash:s,index:i,logs:c,logsBloom:l,root:f,status:u,to:e}}get length(){return this.logs.length}[Symbol.iterator](){let e=0;return{next:()=>e<this.length?{value:this.logs[e++],done:!1}:{value:void 0,done:!0}}}get fee(){return this.gasUsed*this.gasPrice}async getBlock(){const e=await this.provider.getBlock(this.blockHash);if(e==null)throw new Error("TODO");return e}async getTransaction(){const e=await this.provider.getTransaction(this.hash);if(e==null)throw new Error("TODO");return e}async getResult(){return await this.provider.getTransactionResult(this.hash)}async confirmations(){return await this.provider.getBlockNumber()-this.blockNumber+1}removedEvent(){return dM(this)}reorderedEvent(e){return X(!e||e.isMined(),"unmined 'other' transction cannot be orphaned","UNSUPPORTED_OPERATION",{operation:"reorderedEvent(other)"}),fM(this,e)}}Ed=new WeakMap;const Kv=class Kv{constructor(e,t){j(this,"provider");j(this,"blockNumber");j(this,"blockHash");j(this,"index");j(this,"hash");j(this,"type");j(this,"to");j(this,"from");j(this,"nonce");j(this,"gasLimit");j(this,"gasPrice");j(this,"maxPriorityFeePerGas");j(this,"maxFeePerGas");j(this,"maxFeePerBlobGas");j(this,"data");j(this,"value");j(this,"chainId");j(this,"signature");j(this,"accessList");j(this,"blobVersionedHashes");W(this,vo,void 0);this.provider=t,this.blockNumber=e.blockNumber!=null?e.blockNumber:null,this.blockHash=e.blockHash!=null?e.blockHash:null,this.hash=e.hash,this.index=e.index,this.type=e.type,this.from=e.from,this.to=e.to||null,this.gasLimit=e.gasLimit,this.nonce=e.nonce,this.data=e.data,this.value=e.value,this.gasPrice=e.gasPrice,this.maxPriorityFeePerGas=e.maxPriorityFeePerGas!=null?e.maxPriorityFeePerGas:null,this.maxFeePerGas=e.maxFeePerGas!=null?e.maxFeePerGas:null,this.maxFeePerBlobGas=e.maxFeePerBlobGas!=null?e.maxFeePerBlobGas:null,this.chainId=e.chainId,this.signature=e.signature,this.accessList=e.accessList!=null?e.accessList:null,this.blobVersionedHashes=e.blobVersionedHashes!=null?e.blobVersionedHashes:null,D(this,vo,-1)}toJSON(){const{blockNumber:e,blockHash:t,index:r,hash:s,type:i,to:o,from:a,nonce:l,data:c,signature:u,accessList:f,blobVersionedHashes:d}=this;return{_type:"TransactionResponse",accessList:f,blockNumber:e,blockHash:t,blobVersionedHashes:d,chainId:It(this.chainId),data:c,from:a,gasLimit:It(this.gasLimit),gasPrice:It(this.gasPrice),hash:s,maxFeePerGas:It(this.maxFeePerGas),maxPriorityFeePerGas:It(this.maxPriorityFeePerGas),maxFeePerBlobGas:It(this.maxFeePerBlobGas),nonce:l,signature:u,to:o,index:r,type:i,value:It(this.value)}}async getBlock(){let e=this.blockNumber;if(e==null){const r=await this.getTransaction();r&&(e=r.blockNumber)}if(e==null)return null;const t=this.provider.getBlock(e);if(t==null)throw new Error("TODO");return t}async getTransaction(){return this.provider.getTransaction(this.hash)}async confirmations(){if(this.blockNumber==null){const{tx:t,blockNumber:r}=await pn({tx:this.getTransaction(),blockNumber:this.provider.getBlockNumber()});return t==null||t.blockNumber==null?0:r-t.blockNumber+1}return await this.provider.getBlockNumber()-this.blockNumber+1}async wait(e,t){const r=e??1,s=t??0;let i=k(this,vo),o=-1,a=i===-1;const l=async()=>{if(a)return null;const{blockNumber:d,nonce:h}=await pn({blockNumber:this.provider.getBlockNumber(),nonce:this.provider.getTransactionCount(this.from)});if(h<this.nonce){i=d;return}if(a)return null;const p=await this.getTransaction();if(!(p&&p.blockNumber!=null))for(o===-1&&(o=i-3,o<k(this,vo)&&(o=k(this,vo)));o<=d;){if(a)return null;const g=await this.provider.getBlock(o,!0);if(g==null)return;for(const y of g)if(y===this.hash)return;for(let y=0;y<g.length;y++){const b=await g.getTransaction(y);if(b.from===this.from&&b.nonce===this.nonce){if(a)return null;const x=await this.provider.getTransactionReceipt(b.hash);if(x==null||d-x.blockNumber+1<r)return;let v="replaced";b.data===this.data&&b.to===this.to&&b.value===this.value?v="repriced":b.data==="0x"&&b.from===b.to&&b.value===lM&&(v="cancelled"),X(!1,"transaction was replaced","TRANSACTION_REPLACED",{cancelled:v==="replaced"||v==="cancelled",reason:v,replacement:b.replaceableTransaction(i),hash:b.hash,receipt:x})}}o++}},c=d=>{if(d==null||d.status!==0)return d;X(!1,"transaction execution reverted","CALL_EXCEPTION",{action:"sendTransaction",data:null,reason:null,invocation:null,revert:null,transaction:{to:d.to,from:d.from,data:""},receipt:d})},u=await this.provider.getTransactionReceipt(this.hash);if(r===0)return c(u);if(u){if(await u.confirmations()>=r)return c(u)}else if(await l(),r===0)return null;return await new Promise((d,h)=>{const p=[],g=()=>{p.forEach(b=>b())};if(p.push(()=>{a=!0}),s>0){const b=setTimeout(()=>{g(),h(wt("wait for transaction timeout","TIMEOUT"))},s);p.push(()=>{clearTimeout(b)})}const y=async b=>{if(await b.confirmations()>=r){g();try{d(c(b))}catch(x){h(x)}}};if(p.push(()=>{this.provider.off(this.hash,y)}),this.provider.on(this.hash,y),i>=0){const b=async()=>{try{await l()}catch(x){if(Zt(x,"TRANSACTION_REPLACED")){g(),h(x);return}}a||this.provider.once("block",b)};p.push(()=>{this.provider.off("block",b)}),this.provider.once("block",b)}})}isMined(){return this.blockHash!=null}isLegacy(){return this.type===0}isBerlin(){return this.type===1}isLondon(){return this.type===2}isCancun(){return this.type===3}removedEvent(){return X(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),dM(this)}reorderedEvent(e){return X(this.isMined(),"unmined transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),X(!e||e.isMined(),"unmined 'other' transaction canot be orphaned","UNSUPPORTED_OPERATION",{operation:"removeEvent()"}),fM(this,e)}replaceableTransaction(e){H(Number.isInteger(e)&&e>=0,"invalid startBlock","startBlock",e);const t=new Kv(this,this.provider);return D(t,vo,e),t}};vo=new WeakMap;let ud=Kv;function Q7(n){return{orphan:"drop-block",hash:n.hash,number:n.number}}function fM(n,e){return{orphan:"reorder-transaction",tx:n,other:e}}function dM(n){return{orphan:"drop-transaction",tx:n}}function Y7(n){return{orphan:"drop-log",log:{transactionHash:n.transactionHash,blockHash:n.blockHash,blockNumber:n.blockNumber,address:n.address,data:n.data,topics:Object.freeze(n.topics.slice()),index:n.index}}}class Av extends cd{constructor(t,r,s){super(t,t.provider);j(this,"interface");j(this,"fragment");j(this,"args");const i=r.decodeEventLog(s,t.data,t.topics);be(this,{args:i,fragment:s,interface:r})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}class hM extends cd{constructor(t,r){super(t,t.provider);j(this,"error");be(this,{error:r})}}class X7 extends uM{constructor(t,r,s){super(s,r);W(this,su,void 0);D(this,su,t)}get logs(){return super.logs.map(t=>{const r=t.topics.length?k(this,su).getEvent(t.topics[0]):null;if(r)try{return new Av(t,k(this,su),r)}catch(s){return new hM(t,s)}return t})}}su=new WeakMap;class xv extends ud{constructor(t,r,s){super(s,r);W(this,kd,void 0);D(this,kd,t)}async wait(t,r){const s=await super.wait(t,r);return s==null?null:new X7(k(this,kd),this.provider,s)}}kd=new WeakMap;class pM extends G2{constructor(t,r,s,i){super(t,r,s);j(this,"log");be(this,{log:i})}async getBlock(){return await this.log.getBlock()}async getTransaction(){return await this.log.getTransaction()}async getTransactionReceipt(){return await this.log.getTransactionReceipt()}}class Z7 extends pM{constructor(e,t,r,s,i){super(e,t,r,new Av(i,e.interface,s));const o=e.interface.decodeEventLog(s,this.log.data,this.log.topics);be(this,{args:o,fragment:s})}get eventName(){return this.fragment.name}get eventSignature(){return this.fragment.format()}}const mM=BigInt(0);function gM(n){return n&&typeof n.call=="function"}function yM(n){return n&&typeof n.estimateGas=="function"}function Qm(n){return n&&typeof n.resolveName=="function"}function bM(n){return n&&typeof n.sendTransaction=="function"}function wM(n){if(n!=null){if(Qm(n))return n;if(n.provider)return n.provider}}class eW{constructor(e,t,r){W(this,Cd,void 0);j(this,"fragment");if(be(this,{fragment:t}),t.inputs.length<r.length)throw new Error("too many arguments");const s=Ma(e.runner,"resolveName"),i=Qm(s)?s:null;D(this,Cd,async function(){const o=await Promise.all(t.inputs.map((a,l)=>r[l]==null?null:a.walkAsync(r[l],(u,f)=>u==="address"?Array.isArray(f)?Promise.all(f.map(d=>Nn(d,i))):Nn(f,i):f)));return e.interface.encodeFilterTopics(t,o)}())}getTopicFilter(){return k(this,Cd)}}Cd=new WeakMap;function Ma(n,e){return n==null?null:typeof n[e]=="function"?n:n.provider&&typeof n.provider[e]=="function"?n.provider:null}function Ra(n){return n==null?null:n.provider||null}async function vM(n,e){const t=mn.dereference(n,"overrides");H(typeof t=="object","invalid overrides parameter","overrides",n);const r=qm(t);return H(r.to==null||(e||[]).indexOf("to")>=0,"cannot override to","overrides.to",r.to),H(r.data==null||(e||[]).indexOf("data")>=0,"cannot override data","overrides.data",r.data),r.from&&(r.from=r.from),r}async function tW(n,e,t){const r=Ma(n,"resolveName"),s=Qm(r)?r:null;return await Promise.all(e.map((i,o)=>i.walkAsync(t[o],(a,l)=>(l=mn.dereference(l,a),a==="address"?Nn(l,s):l))))}function nW(n){const e=async function(o){const a=await vM(o,["data"]);a.to=await n.getAddress(),a.from&&(a.from=await Nn(a.from,wM(n.runner)));const l=n.interface,c=pe(a.value||mM,"overrides.value")===mM,u=(a.data||"0x")==="0x";l.fallback&&!l.fallback.payable&&l.receive&&!u&&!c&&H(!1,"cannot send data to receive or send value to non-payable fallback","overrides",o),H(l.fallback||u,"cannot send data to receive-only contract","overrides.data",a.data);const f=l.receive||l.fallback&&l.fallback.payable;return H(f||c,"cannot send value to non-payable fallback","overrides.value",a.value),H(l.fallback||u,"cannot send data to receive-only contract","overrides.data",a.data),a},t=async function(o){const a=Ma(n.runner,"call");X(gM(a),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const l=await e(o);try{return await a.call(l)}catch(c){throw Nw(c)&&c.data?n.interface.makeError(c.data,l):c}},r=async function(o){const a=n.runner;X(bM(a),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const l=await a.sendTransaction(await e(o)),c=Ra(n.runner);return new xv(n.interface,c,l)},s=async function(o){const a=Ma(n.runner,"estimateGas");return X(yM(a),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await a.estimateGas(await e(o))},i=async o=>await r(o);return be(i,{_contract:n,estimateGas:s,populateTransaction:e,send:r,staticCall:t}),i}function rW(n,e){const t=function(...c){const u=n.interface.getFunction(e,c);return X(u,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:c}}),u},r=async function(...c){const u=t(...c);let f={};if(u.inputs.length+1===c.length&&(f=await vM(c.pop()),f.from&&(f.from=await Nn(f.from,wM(n.runner)))),u.inputs.length!==c.length)throw new Error("internal error: fragment inputs doesn't match arguments; should not happen");const d=await tW(n.runner,u.inputs,c);return Object.assign({},f,await pn({to:n.getAddress(),data:n.interface.encodeFunctionData(u,d)}))},s=async function(...c){const u=await a(...c);return u.length===1?u[0]:u},i=async function(...c){const u=n.runner;X(bM(u),"contract runner does not support sending transactions","UNSUPPORTED_OPERATION",{operation:"sendTransaction"});const f=await u.sendTransaction(await r(...c)),d=Ra(n.runner);return new xv(n.interface,d,f)},o=async function(...c){const u=Ma(n.runner,"estimateGas");return X(yM(u),"contract runner does not support gas estimation","UNSUPPORTED_OPERATION",{operation:"estimateGas"}),await u.estimateGas(await r(...c))},a=async function(...c){const u=Ma(n.runner,"call");X(gM(u),"contract runner does not support calling","UNSUPPORTED_OPERATION",{operation:"call"});const f=await r(...c);let d="0x";try{d=await u.call(f)}catch(p){throw Nw(p)&&p.data?n.interface.makeError(p.data,f):p}const h=t(...c);return n.interface.decodeFunctionResult(h,d)},l=async(...c)=>t(...c).constant?await s(...c):await i(...c);return be(l,{name:n.interface.getFunctionName(e),_contract:n,_key:e,getFragment:t,estimateGas:o,populateTransaction:r,send:i,staticCall:s,staticCallResult:a}),Object.defineProperty(l,"fragment",{configurable:!1,enumerable:!0,get:()=>{const c=n.interface.getFunction(e);return X(c,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),c}}),l}function sW(n,e){const t=function(...s){const i=n.interface.getEvent(e,s);return X(i,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e,args:s}}),i},r=function(...s){return new eW(n,t(...s),s)};return be(r,{name:n.interface.getEventName(e),_contract:n,_key:e,getFragment:t}),Object.defineProperty(r,"fragment",{configurable:!1,enumerable:!0,get:()=>{const s=n.interface.getEvent(e);return X(s,"no matching fragment","UNSUPPORTED_OPERATION",{operation:"fragment",info:{key:e}}),s}}),r}const Ym=Symbol.for("_ethersInternal_contract"),AM=new WeakMap;function iW(n,e){AM.set(n[Ym],e)}function sr(n){return AM.get(n[Ym])}function oW(n){return n&&typeof n=="object"&&"getTopicFilter"in n&&typeof n.getTopicFilter=="function"&&n.fragment}async function Ev(n,e){let t,r=null;if(Array.isArray(e)){const i=function(o){if(pt(o,32))return o;const a=n.interface.getEvent(o);return H(a,"unknown fragment","name",o),a.topicHash};t=e.map(o=>o==null?null:Array.isArray(o)?o.map(i):i(o))}else e==="*"?t=[null]:typeof e=="string"?pt(e,32)?t=[e]:(r=n.interface.getEvent(e),H(r,"unknown fragment","event",e),t=[r.topicHash]):oW(e)?t=await e.getTopicFilter():"fragment"in e?(r=e.fragment,t=[r.topicHash]):H(!1,"unknown event name","event",e);t=t.map(i=>{if(i==null)return null;if(Array.isArray(i)){const o=Array.from(new Set(i.map(a=>a.toLowerCase())).values());return o.length===1?o[0]:(o.sort(),o)}return i.toLowerCase()});const s=t.map(i=>i==null?"null":Array.isArray(i)?i.join("|"):i).join("&");return{fragment:r,tag:s,topics:t}}async function fd(n,e){const{subs:t}=sr(n);return t.get((await Ev(n,e)).tag)||null}async function xM(n,e,t){const r=Ra(n.runner);X(r,"contract runner does not support subscribing","UNSUPPORTED_OPERATION",{operation:e});const{fragment:s,tag:i,topics:o}=await Ev(n,t),{addr:a,subs:l}=sr(n);let c=l.get(i);if(!c){const f={address:a||n,topics:o},d=y=>{let b=s;if(b==null)try{b=n.interface.getEvent(y.topics[0])}catch{}if(b){const x=b,v=s?n.interface.decodeEventLog(s,y.data,y.topics):[];Cv(n,t,v,w=>new Z7(n,w,t,x,y))}else Cv(n,t,[],x=>new pM(n,x,t,y))};let h=[];c={tag:i,listeners:[],start:()=>{h.length||h.push(r.on(f,d))},stop:async()=>{if(h.length==0)return;let y=h;h=[],await Promise.all(y),r.off(f,d)}},l.set(i,c)}return c}let kv=Promise.resolve();async function aW(n,e,t,r){await kv;const s=await fd(n,e);if(!s)return!1;const i=s.listeners.length;return s.listeners=s.listeners.filter(({listener:o,once:a})=>{const l=Array.from(t);r&&l.push(r(a?null:o));try{o.call(n,...l)}catch{}return!a}),s.listeners.length===0&&(s.stop(),sr(n).subs.delete(s.tag)),i>0}async function Cv(n,e,t,r){try{await kv}catch{}const s=aW(n,e,t,r);return kv=s,await s}const Xm=["then"],Sd=class Sd{constructor(e,t,r,s){j(this,"target");j(this,"interface");j(this,"runner");j(this,"filters");j(this,xG);j(this,"fallback");H(typeof e=="string"||nN(e),"invalid value for Contract target","target",e),r==null&&(r=null);const i=vv.from(t);be(this,{target:e,runner:r,interface:i}),Object.defineProperty(this,Ym,{value:{}});let o,a=null,l=null;if(s){const f=Ra(r);l=new xv(this.interface,f,s)}let c=new Map;if(typeof e=="string")if(pt(e))a=e,o=Promise.resolve(e);else{const f=Ma(r,"resolveName");if(!Qm(f))throw wt("contract runner does not support name resolution","UNSUPPORTED_OPERATION",{operation:"resolveName"});o=f.resolveName(e).then(d=>{if(d==null)throw wt("an ENS name used for a contract target must be correctly configured","UNCONFIGURED_NAME",{value:e});return sr(this).addr=d,d})}else o=e.getAddress().then(f=>{if(f==null)throw new Error("TODO");return sr(this).addr=f,f});iW(this,{addrPromise:o,addr:a,deployTx:l,subs:c});const u=new Proxy({},{get:(f,d,h)=>{if(typeof d=="symbol"||Xm.indexOf(d)>=0)return Reflect.get(f,d,h);try{return this.getEvent(d)}catch(p){if(!Zt(p,"INVALID_ARGUMENT")||p.argument!=="key")throw p}},has:(f,d)=>Xm.indexOf(d)>=0?Reflect.has(f,d):Reflect.has(f,d)||this.interface.hasEvent(String(d))});return be(this,{filters:u}),be(this,{fallback:i.receive||i.fallback?nW(this):null}),new Proxy(this,{get:(f,d,h)=>{if(typeof d=="symbol"||d in f||Xm.indexOf(d)>=0)return Reflect.get(f,d,h);try{return f.getFunction(d)}catch(p){if(!Zt(p,"INVALID_ARGUMENT")||p.argument!=="key")throw p}},has:(f,d)=>typeof d=="symbol"||d in f||Xm.indexOf(d)>=0?Reflect.has(f,d):f.interface.hasFunction(d)})}connect(e){return new Sd(this.target,this.interface,e)}attach(e){return new Sd(e,this.interface,this.runner)}async getAddress(){return await sr(this).addrPromise}async getDeployedCode(){const e=Ra(this.runner);X(e,"runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"getDeployedCode"});const t=await e.getCode(await this.getAddress());return t==="0x"?null:t}async waitForDeployment(){const e=this.deploymentTransaction();if(e)return await e.wait(),this;if(await this.getDeployedCode()!=null)return this;const r=Ra(this.runner);return X(r!=null,"contract runner does not support .provider","UNSUPPORTED_OPERATION",{operation:"waitForDeployment"}),new Promise((s,i)=>{const o=async()=>{try{if(await this.getDeployedCode()!=null)return s(this);r.once("block",o)}catch(a){i(a)}};o()})}deploymentTransaction(){return sr(this).deployTx}getFunction(e){return typeof e!="string"&&(e=e.format()),rW(this,e)}getEvent(e){return typeof e!="string"&&(e=e.format()),sW(this,e)}async queryTransaction(e){throw new Error("@TODO")}async queryFilter(e,t,r){t==null&&(t=0),r==null&&(r="latest");const{addr:s,addrPromise:i}=sr(this),o=s||await i,{fragment:a,topics:l}=await Ev(this,e),c={address:o,topics:l,fromBlock:t,toBlock:r},u=Ra(this.runner);return X(u,"contract runner does not have a provider","UNSUPPORTED_OPERATION",{operation:"queryFilter"}),(await u.getLogs(c)).map(f=>{let d=a;if(d==null)try{d=this.interface.getEvent(f.topics[0])}catch{}if(d)try{return new Av(f,this.interface,d)}catch(h){return new hM(f,h)}return new cd(f,u)})}async on(e,t){const r=await xM(this,"on",e);return r.listeners.push({listener:t,once:!1}),r.start(),this}async once(e,t){const r=await xM(this,"once",e);return r.listeners.push({listener:t,once:!0}),r.start(),this}async emit(e,...t){return await Cv(this,e,t,null)}async listenerCount(e){if(e){const s=await fd(this,e);return s?s.listeners.length:0}const{subs:t}=sr(this);let r=0;for(const{listeners:s}of t.values())r+=s.length;return r}async listeners(e){if(e){const s=await fd(this,e);return s?s.listeners.map(({listener:i})=>i):[]}const{subs:t}=sr(this);let r=[];for(const{listeners:s}of t.values())r=r.concat(s.map(({listener:i})=>i));return r}async off(e,t){const r=await fd(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(t==null||r.listeners.length===0)&&(r.stop(),sr(this).subs.delete(r.tag)),this}async removeAllListeners(e){if(e){const t=await fd(this,e);if(!t)return this;t.stop(),sr(this).subs.delete(t.tag)}else{const{subs:t}=sr(this);for(const{tag:r,stop:s}of t.values())s(),t.delete(r)}return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return await this.off(e,t)}static buildClass(e){class t extends Sd{constructor(s,i=null){super(s,e,i)}}return t}static from(e,t,r){return r==null&&(r=null),new this(e,t,r)}};xG=Ym;let Sv=Sd;function lW(){return Sv}class Cc extends lW(){}function Tv(n){return n.match(/^ipfs:\/\/ipfs\//i)?n=n.substring(12):n.match(/^ipfs:\/\//i)?n=n.substring(7):H(!1,"unsupported IPFS format","link",n),`https://gateway.ipfs.io/ipfs/${n}`}class cW{constructor(e){j(this,"name");be(this,{name:e})}connect(e){return this}supportsCoinType(e){return!1}async encodeAddress(e,t){throw new Error("unsupported coin")}async decodeAddress(e,t){throw new Error("unsupported coin")}}const EM=new RegExp("^(ipfs)://(.*)$","i"),kM=[new RegExp("^(https)://(.*)$","i"),new RegExp("^(data):(.*)$","i"),EM,new RegExp("^eip155:[0-9]+/(erc[0-9]+):(.*)$","i")],iu=class iu{constructor(e,t,r){W(this,xo);j(this,"provider");j(this,"address");j(this,"name");W(this,Ao,void 0);W(this,Ga,void 0);be(this,{provider:e,address:t,name:r}),D(this,Ao,null),D(this,Ga,new Cc(t,["function supportsInterface(bytes4) view returns (bool)","function resolve(bytes, bytes) view returns (bytes)","function addr(bytes32) view returns (address)","function addr(bytes32, uint) view returns (bytes)","function text(bytes32, string) view returns (string)","function contenthash(bytes32) view returns (bytes)"],e))}async supportsWildcard(){return k(this,Ao)==null&&D(this,Ao,(async()=>{try{return await k(this,Ga).supportsInterface("0x9061b923")}catch(e){if(Zt(e,"CALL_EXCEPTION"))return!1;throw D(this,Ao,null),e}})()),await k(this,Ao)}async getAddress(e){if(e==null&&(e=60),e===60)try{const i=await ie(this,xo,Mu).call(this,"addr(bytes32)");return i==null||i===Xf?null:i}catch(i){if(Zt(i,"CALL_EXCEPTION"))return null;throw i}if(e>=0&&e<2147483648){let i=e+2147483648;const o=await ie(this,xo,Mu).call(this,"addr(bytes32,uint)",[i]);if(pt(o,20))return st(o)}let t=null;for(const i of this.provider.plugins)if(i instanceof cW&&i.supportsCoinType(e)){t=i;break}if(t==null)return null;const r=await ie(this,xo,Mu).call(this,"addr(bytes32,uint)",[e]);if(r==null||r==="0x")return null;const s=await t.decodeAddress(e,r);if(s!=null)return s;X(!1,"invalid coin data","UNSUPPORTED_OPERATION",{operation:`getAddress(${e})`,info:{coinType:e,data:r}})}async getText(e){const t=await ie(this,xo,Mu).call(this,"text(bytes32,string)",[e]);return t==null||t==="0x"?null:t}async getContentHash(){const e=await ie(this,xo,Mu).call(this,"contenthash(bytes32)");if(e==null||e==="0x")return null;const t=e.match(/^0x(e3010170|e5010172)(([0-9a-f][0-9a-f])([0-9a-f][0-9a-f])([0-9a-f]*))$/);if(t){const s=t[1]==="e3010170"?"ipfs":"ipns",i=parseInt(t[4],16);if(t[5].length===i*2)return`${s}://${Rz("0x"+t[2])}`}const r=e.match(/^0xe40101fa011b20([0-9a-f]*)$/);if(r&&r[1].length===64)return`bzz://${r[1]}`;X(!1,"invalid or unsupported content hash data","UNSUPPORTED_OPERATION",{operation:"getContentHash()",info:{data:e}})}async getAvatar(){return(await this._getAvatar()).url}async _getAvatar(){const e=[{type:"name",value:this.name}];try{const t=await this.getText("avatar");if(t==null)return e.push({type:"!avatar",value:""}),{url:null,linkage:e};e.push({type:"avatar",value:t});for(let r=0;r<kM.length;r++){const s=t.match(kM[r]);if(s==null)continue;const i=s[1].toLowerCase();switch(i){case"https":case"data":return e.push({type:"url",value:t}),{linkage:e,url:t};case"ipfs":{const o=Tv(t);return e.push({type:"ipfs",value:t}),e.push({type:"url",value:o}),{linkage:e,url:o}}case"erc721":case"erc1155":{const o=i==="erc721"?"tokenURI(uint256)":"uri(uint256)";e.push({type:i,value:t});const a=await this.getAddress();if(a==null)return e.push({type:"!owner",value:""}),{url:null,linkage:e};const l=(s[2]||"").split("/");if(l.length!==2)return e.push({type:`!${i}caip`,value:s[2]||""}),{url:null,linkage:e};const c=l[1],u=new Cc(l[0],["function tokenURI(uint) view returns (string)","function ownerOf(uint) view returns (address)","function uri(uint) view returns (string)","function balanceOf(address, uint256) view returns (uint)"],this.provider);if(i==="erc721"){const g=await u.ownerOf(c);if(a!==g)return e.push({type:"!owner",value:g}),{url:null,linkage:e};e.push({type:"owner",value:g})}else if(i==="erc1155"){const g=await u.balanceOf(a,c);if(!g)return e.push({type:"!balance",value:"0"}),{url:null,linkage:e};e.push({type:"balance",value:g.toString()})}let f=await u[o](c);if(f==null||f==="0x")return e.push({type:"!metadata-url",value:""}),{url:null,linkage:e};e.push({type:"metadata-url-base",value:f}),i==="erc1155"&&(f=f.replace("{id}",so(c,32).substring(2)),e.push({type:"metadata-url-expanded",value:f})),f.match(/^ipfs:/i)&&(f=Tv(f)),e.push({type:"metadata-url",value:f});let d={};const h=await new Tn(f).send();h.assertOk();try{d=h.bodyJson}catch{try{e.push({type:"!metadata",value:h.bodyText})}catch{const b=h.body;return b&&e.push({type:"!metadata",value:ce(b)}),{url:null,linkage:e}}return{url:null,linkage:e}}if(!d)return e.push({type:"!metadata",value:""}),{url:null,linkage:e};e.push({type:"metadata",value:JSON.stringify(d)});let p=d.image;if(typeof p!="string")return e.push({type:"!imageUrl",value:""}),{url:null,linkage:e};if(!p.match(/^(https:\/\/|data:)/i)){if(p.match(EM)==null)return e.push({type:"!imageUrl-ipfs",value:p}),{url:null,linkage:e};e.push({type:"imageUrl-ipfs",value:p}),p=Tv(p)}return e.push({type:"url",value:p}),{linkage:e,url:p}}}}}catch{}return{linkage:e,url:null}}static async getEnsAddress(e){const t=await e.getNetwork(),r=t.getPlugin("org.ethers.plugins.network.Ens");return X(r,"network does not support ENS","UNSUPPORTED_OPERATION",{operation:"getEnsAddress",info:{network:t}}),r.address}static async fromName(e,t){var s;let r=t;for(;;){if(r===""||r==="."||t!=="eth"&&r==="eth")return null;const i=await ie(s=iu,xg,JM).call(s,e,r);if(i!=null){const o=new iu(e,i,t);return r!==t&&!await o.supportsWildcard()?null:o}r=r.split(".").slice(1).join(".")}}};Ao=new WeakMap,Ga=new WeakMap,xo=new WeakSet,Mu=async function(e,t){t=(t||[]).slice();const r=k(this,Ga).interface;t.unshift(fv(this.name));let s=null;await this.supportsWildcard()&&(s=r.getFunction(e),X(s,"missing fragment","UNKNOWN_ERROR",{info:{funcName:e}}),t=[u7(this.name,255),r.encodeFunctionData(s,t)],e="resolve(bytes,bytes)"),t.push({enableCcipRead:!0});try{const i=await k(this,Ga)[e](...t);return s?r.decodeFunctionResult(s,i)[0]:i}catch(i){if(!Zt(i,"CALL_EXCEPTION"))throw i}return null},xg=new WeakSet,JM=async function(e,t){const r=await iu.getEnsAddress(e);try{const i=await new Cc(r,["function resolver(bytes32) view returns (address)"],e).resolver(fv(t),{enableCcipRead:!0});return i===Xf?null:i}catch(s){throw s}return null},W(iu,xg);let Zm=iu;const CM=BigInt(0);function Ge(n,e){return function(t){return t==null?e:n(t)}}function eg(n,e){return t=>{if(e&&t==null)return null;if(!Array.isArray(t))throw new Error("not an array");return t.map(r=>n(r))}}function dd(n,e){return t=>{const r={};for(const s in n){let i=s;if(e&&s in e&&!(i in t)){for(const o of e[s])if(o in t){i=o;break}}try{const o=n[s](t[i]);o!==void 0&&(r[s]=o)}catch(o){const a=o instanceof Error?o.message:"not-an-error";X(!1,`invalid value for value.${s} (${a})`,"BAD_DATA",{value:t})}}return r}}function uW(n){switch(n){case!0:case"true":return!0;case!1:case"false":return!1}H(!1,`invalid boolean; ${JSON.stringify(n)}`,"value",n)}function Sc(n){return H(pt(n,!0),"invalid data","value",n),n}function cn(n){return H(pt(n,32),"invalid hash","value",n),n}const fW=dd({address:st,blockHash:cn,blockNumber:Pe,data:Sc,index:Pe,removed:Ge(uW,!1),topics:eg(cn),transactionHash:cn,transactionIndex:Pe},{index:["logIndex"]});function dW(n){return fW(n)}const hW=dd({hash:Ge(cn),parentHash:cn,parentBeaconBlockRoot:Ge(cn,null),number:Pe,timestamp:Pe,nonce:Ge(Sc),difficulty:pe,gasLimit:pe,gasUsed:pe,stateRoot:Ge(cn,null),receiptsRoot:Ge(cn,null),blobGasUsed:Ge(pe,null),excessBlobGas:Ge(pe,null),miner:Ge(st),prevRandao:Ge(cn,null),extraData:Sc,baseFeePerGas:Ge(pe)},{prevRandao:["mixHash"]});function pW(n){const e=hW(n);return e.transactions=n.transactions.map(t=>typeof t=="string"?t:SM(t)),e}const mW=dd({transactionIndex:Pe,blockNumber:Pe,transactionHash:cn,address:st,topics:eg(cn),data:Sc,index:Pe,blockHash:cn},{index:["logIndex"]});function gW(n){return mW(n)}const yW=dd({to:Ge(st,null),from:Ge(st,null),contractAddress:Ge(st,null),index:Pe,root:Ge(ce),gasUsed:pe,blobGasUsed:Ge(pe,null),logsBloom:Ge(Sc),blockHash:cn,hash:cn,logs:eg(gW),blockNumber:Pe,cumulativeGasUsed:pe,effectiveGasPrice:Ge(pe),blobGasPrice:Ge(pe,null),status:Ge(Pe),type:Ge(Pe,0)},{effectiveGasPrice:["gasPrice"],hash:["transactionHash"],index:["transactionIndex"]});function bW(n){return yW(n)}function SM(n){n.to&&pe(n.to)===CM&&(n.to="0x0000000000000000000000000000000000000000");const e=dd({hash:cn,index:Ge(Pe,void 0),type:t=>t==="0x"||t==null?0:Pe(t),accessList:Ge(fo,null),blobVersionedHashes:Ge(eg(cn,!0),null),blockHash:Ge(cn,null),blockNumber:Ge(Pe,null),transactionIndex:Ge(Pe,null),from:st,gasPrice:Ge(pe),maxPriorityFeePerGas:Ge(pe),maxFeePerGas:Ge(pe),maxFeePerBlobGas:Ge(pe,null),gasLimit:pe,to:Ge(st,null),value:pe,nonce:Pe,data:Sc,creates:Ge(st,null),chainId:Ge(pe,null)},{data:["input"],gasLimit:["gas"],index:["transactionIndex"]})(n);if(e.to==null&&e.creates==null&&(e.creates=d9(e)),(n.type===1||n.type===2)&&n.accessList==null&&(e.accessList=[]),n.signature?e.signature=Wr.from(n.signature):e.signature=Wr.from(n),e.chainId==null){const t=e.signature.legacyChainId;t!=null&&(e.chainId=t)}return e.blockHash&&pe(e.blockHash)===CM&&(e.blockHash=null),e}const wW="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e";class hd{constructor(e){j(this,"name");be(this,{name:e})}clone(){return new hd(this.name)}}class tg extends hd{constructor(t,r){t==null&&(t=0);super(`org.ethers.network.plugins.GasCost#${t||0}`);j(this,"effectiveBlock");j(this,"txBase");j(this,"txCreate");j(this,"txDataZero");j(this,"txDataNonzero");j(this,"txAccessListStorageKey");j(this,"txAccessListAddress");const s={effectiveBlock:t};function i(o,a){let l=(r||{})[o];l==null&&(l=a),H(typeof l=="number",`invalud value for ${o}`,"costs",r),s[o]=l}i("txBase",21e3),i("txCreate",32e3),i("txDataZero",4),i("txDataNonzero",16),i("txAccessListStorageKey",1900),i("txAccessListAddress",2400),be(this,s)}clone(){return new tg(this.effectiveBlock,this)}}class ng extends hd{constructor(t,r){super("org.ethers.plugins.network.Ens");j(this,"address");j(this,"targetNetwork");be(this,{address:t||wW,targetNetwork:r??1})}clone(){return new ng(this.address,this.targetNetwork)}}class vW extends hd{constructor(t,r){super("org.ethers.plugins.network.FetchUrlFeeDataPlugin");W(this,Td,void 0);W(this,Od,void 0);D(this,Td,t),D(this,Od,r)}get url(){return k(this,Td)}get processFunc(){return k(this,Od)}clone(){return this}}Td=new WeakMap,Od=new WeakMap;const Ov=new Map,lu=class lu{constructor(e,t){W(this,ou,void 0);W(this,au,void 0);W(this,Eo,void 0);D(this,ou,e),D(this,au,pe(t)),D(this,Eo,new Map)}toJSON(){return{name:this.name,chainId:String(this.chainId)}}get name(){return k(this,ou)}set name(e){D(this,ou,e)}get chainId(){return k(this,au)}set chainId(e){D(this,au,pe(e,"chainId"))}matches(e){if(e==null)return!1;if(typeof e=="string"){try{return this.chainId===pe(e)}catch{}return this.name===e}if(typeof e=="number"||typeof e=="bigint"){try{return this.chainId===pe(e)}catch{}return!1}if(typeof e=="object"){if(e.chainId!=null){try{return this.chainId===pe(e.chainId)}catch{}return!1}return e.name!=null?this.name===e.name:!1}return!1}get plugins(){return Array.from(k(this,Eo).values())}attachPlugin(e){if(k(this,Eo).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return k(this,Eo).set(e.name,e.clone()),this}getPlugin(e){return k(this,Eo).get(e)||null}getPlugins(e){return this.plugins.filter(t=>t.name.split("#")[0]===e)}clone(){const e=new lu(this.name,this.chainId);return this.plugins.forEach(t=>{e.attachPlugin(t.clone())}),e}computeIntrinsicGas(e){const t=this.getPlugin("org.ethers.plugins.network.GasCost")||new tg;let r=t.txBase;if(e.to==null&&(r+=t.txCreate),e.data)for(let s=2;s<e.data.length;s+=2)e.data.substring(s,s+2)==="00"?r+=t.txDataZero:r+=t.txDataNonzero;if(e.accessList){const s=fo(e.accessList);for(const i in s)r+=t.txAccessListAddress+t.txAccessListStorageKey*s[i].storageKeys.length}return r}static from(e){if(AW(),e==null)return lu.from("mainnet");if(typeof e=="number"&&(e=BigInt(e)),typeof e=="string"||typeof e=="bigint"){const t=Ov.get(e);if(t)return t();if(typeof e=="bigint")return new lu("unknown",e);H(!1,"unknown network","network",e)}if(typeof e.clone=="function")return e.clone();if(typeof e=="object"){H(typeof e.name=="string"&&typeof e.chainId=="number","invalid network object name or chainId","network",e);const t=new lu(e.name,e.chainId);return(e.ensAddress||e.ensNetwork!=null)&&t.attachPlugin(new ng(e.ensAddress,e.ensNetwork)),t}H(!1,"invalid network","network",e)}static register(e,t){typeof e=="number"&&(e=BigInt(e));const r=Ov.get(e);r&&H(!1,`conflicting network for ${JSON.stringify(r.name)}`,"nameOrChainId",e),Ov.set(e,t)}};ou=new WeakMap,au=new WeakMap,Eo=new WeakMap;let $t=lu;function TM(n,e){const t=String(n);if(!t.match(/^[0-9.]+$/))throw new Error(`invalid gwei value: ${n}`);const r=t.split(".");if(r.length===1&&r.push(""),r.length!==2)throw new Error(`invalid gwei value: ${n}`);for(;r[1].length<e;)r[1]+="0";if(r[1].length>9){let s=BigInt(r[1].substring(0,9));r[1].substring(9).match(/^0+$/)||s++,r[1]=s.toString()}return BigInt(r[0]+r[1])}function OM(n){return new vW(n,async(e,t,r)=>{r.setHeader("User-Agent","ethers");let s;try{const[i,o]=await Promise.all([r.send(),e()]);s=i;const a=s.bodyJson.standard;return{gasPrice:o.gasPrice,maxFeePerGas:TM(a.maxFee,9),maxPriorityFeePerGas:TM(a.maxPriorityFee,9)}}catch(i){X(!1,`error encountered with polygon gas station (${JSON.stringify(r.url)})`,"SERVER_ERROR",{request:r,response:s,error:i})}})}let NM=!1;function AW(){if(NM)return;NM=!0;function n(e,t,r){const s=function(){const i=new $t(e,t);return r.ensNetwork!=null&&i.attachPlugin(new ng(null,r.ensNetwork)),i.attachPlugin(new tg),(r.plugins||[]).forEach(o=>{i.attachPlugin(o)}),i};$t.register(e,s),$t.register(t,s),r.altNames&&r.altNames.forEach(i=>{$t.register(i,s)})}n("mainnet",1,{ensNetwork:1,altNames:["homestead"]}),n("ropsten",3,{ensNetwork:3}),n("rinkeby",4,{ensNetwork:4}),n("goerli",5,{ensNetwork:5}),n("kovan",42,{ensNetwork:42}),n("sepolia",11155111,{ensNetwork:11155111}),n("holesky",17e3,{ensNetwork:17e3}),n("classic",61,{}),n("classicKotti",6,{}),n("arbitrum",42161,{ensNetwork:1}),n("arbitrum-goerli",421613,{}),n("arbitrum-sepolia",421614,{}),n("base",8453,{ensNetwork:1}),n("base-goerli",84531,{}),n("base-sepolia",84532,{}),n("bnb",56,{ensNetwork:1}),n("bnbt",97,{}),n("linea",59144,{ensNetwork:1}),n("linea-goerli",59140,{}),n("linea-sepolia",59141,{}),n("matic",137,{ensNetwork:1,plugins:[OM("https://gasstation.polygon.technology/v2")]}),n("matic-amoy",80002,{}),n("matic-mumbai",80001,{altNames:["maticMumbai","maticmum"],plugins:[OM("https://gasstation-testnet.polygon.technology/v2")]}),n("optimism",10,{ensNetwork:1,plugins:[]}),n("optimism-goerli",420,{}),n("optimism-sepolia",11155420,{}),n("xdai",100,{ensNetwork:1})}function Nv(n){return JSON.parse(JSON.stringify(n))}class xW{constructor(e){W(this,cu);W(this,Ai,void 0);W(this,Tr,void 0);W(this,ko,void 0);W(this,Is,void 0);D(this,Ai,e),D(this,Tr,null),D(this,ko,4e3),D(this,Is,-2)}get pollingInterval(){return k(this,ko)}set pollingInterval(e){D(this,ko,e)}start(){k(this,Tr)||(D(this,Tr,k(this,Ai)._setTimeout(ie(this,cu,Dg).bind(this),k(this,ko))),ie(this,cu,Dg).call(this))}stop(){k(this,Tr)&&(k(this,Ai)._clearTimeout(k(this,Tr)),D(this,Tr,null))}pause(e){this.stop(),e&&D(this,Is,-2)}resume(){this.start()}}Ai=new WeakMap,Tr=new WeakMap,ko=new WeakMap,Is=new WeakMap,cu=new WeakSet,Dg=async function(){try{const e=await k(this,Ai).getBlockNumber();if(k(this,Is)===-2){D(this,Is,e);return}if(e!==k(this,Is)){for(let t=k(this,Is)+1;t<=e;t++){if(k(this,Tr)==null)return;await k(this,Ai).emit("block",t)}D(this,Is,e)}}catch{}k(this,Tr)!=null&&D(this,Tr,k(this,Ai)._setTimeout(ie(this,cu,Dg).bind(this),k(this,ko)))};class Mv{constructor(e){W(this,Ka,void 0);W(this,Ja,void 0);W(this,Co,void 0);D(this,Ka,e),D(this,Co,!1),D(this,Ja,t=>{this._poll(t,k(this,Ka))})}async _poll(e,t){throw new Error("sub-classes must override this")}start(){k(this,Co)||(D(this,Co,!0),k(this,Ja).call(this,-2),k(this,Ka).on("block",k(this,Ja)))}stop(){k(this,Co)&&(D(this,Co,!1),k(this,Ka).off("block",k(this,Ja)))}pause(e){this.stop()}resume(){this.start()}}Ka=new WeakMap,Ja=new WeakMap,Co=new WeakMap;class EW extends Mv{constructor(t,r){super(t);W(this,uu,void 0);W(this,xi,void 0);D(this,uu,r),D(this,xi,-2)}pause(t){t&&D(this,xi,-2),super.pause(t)}async _poll(t,r){const s=await r.getBlock(k(this,uu));s!=null&&(k(this,xi)===-2?D(this,xi,s.number):s.number>k(this,xi)&&(r.emit(k(this,uu),s.number),D(this,xi,s.number)))}}uu=new WeakMap,xi=new WeakMap;class kW extends Mv{constructor(t,r){super(t);W(this,Eg,void 0);D(this,Eg,Nv(r))}async _poll(t,r){throw new Error("@TODO")}}Eg=new WeakMap;class CW extends Mv{constructor(t,r){super(t);W(this,fu,void 0);D(this,fu,r)}async _poll(t,r){const s=await r.getTransactionReceipt(k(this,fu));s&&r.emit(k(this,fu),s)}}fu=new WeakMap;class Rv{constructor(e,t){W(this,kg);W(this,Ei,void 0);W(this,du,void 0);W(this,hu,void 0);W(this,So,void 0);W(this,Or,void 0);D(this,Ei,e),D(this,du,Nv(t)),D(this,hu,ie(this,kg,qM).bind(this)),D(this,So,!1),D(this,Or,-2)}start(){k(this,So)||(D(this,So,!0),k(this,Or)===-2&&k(this,Ei).getBlockNumber().then(e=>{D(this,Or,e)}),k(this,Ei).on("block",k(this,hu)))}stop(){k(this,So)&&(D(this,So,!1),k(this,Ei).off("block",k(this,hu)))}pause(e){this.stop(),e&&D(this,Or,-2)}resume(){this.start()}}Ei=new WeakMap,du=new WeakMap,hu=new WeakMap,So=new WeakMap,Or=new WeakMap,kg=new WeakSet,qM=async function(e){if(k(this,Or)===-2)return;const t=Nv(k(this,du));t.fromBlock=k(this,Or)+1,t.toBlock=e;const r=await k(this,Ei).getLogs(t);if(r.length===0){k(this,Or)<e-60&&D(this,Or,e-60);return}for(const s of r)k(this,Ei).emit(k(this,du),s),D(this,Or,s.blockNumber)};const SW=BigInt(2),TW=10;function rg(n){return n&&typeof n.then=="function"}function sg(n,e){return n+":"+JSON.stringify(e,(t,r)=>{if(r==null)return"null";if(typeof r=="bigint")return`bigint:${r.toString()}`;if(typeof r=="string")return r.toLowerCase();if(typeof r=="object"&&!Array.isArray(r)){const s=Object.keys(r);return s.sort(),s.reduce((i,o)=>(i[o]=r[o],i),{})}return r})}class ig{constructor(e){j(this,"name");be(this,{name:e})}start(){}stop(){}pause(e){}resume(){}}function OW(n){return JSON.parse(JSON.stringify(n))}function Pv(n){return n=Array.from(new Set(n).values()),n.sort(),n}async function Dv(n,e){if(n==null)throw new Error("invalid event");if(Array.isArray(n)&&(n={topics:n}),typeof n=="string")switch(n){case"block":case"debug":case"error":case"finalized":case"network":case"pending":case"safe":return{type:n,tag:n}}if(pt(n,32)){const t=n.toLowerCase();return{type:"transaction",tag:sg("tx",{hash:t}),hash:t}}if(n.orphan){const t=n;return{type:"orphan",tag:sg("orphan",t),filter:OW(t)}}if(n.address||n.topics){const t=n,r={topics:(t.topics||[]).map(s=>s==null?null:Array.isArray(s)?Pv(s.map(i=>i.toLowerCase())):s.toLowerCase())};if(t.address){const s=[],i=[],o=a=>{pt(a)?s.push(a):i.push((async()=>{s.push(await Nn(a,e))})())};Array.isArray(t.address)?t.address.forEach(o):o(t.address),i.length&&await Promise.all(i),r.address=Pv(s.map(a=>a.toLowerCase()))}return{filter:r,tag:sg("event",r),type:"event"}}H(!1,"unknown ProviderEvent","event",n)}function Iv(){return new Date().getTime()}const NW={cacheTimeout:250,pollingInterval:4e3};class og{constructor(e,t){W(this,Rn);W(this,Md);W(this,Rd);W(this,Qa);W(this,Pd);W(this,Ya);W(this,yu);W(this,yn,void 0);W(this,To,void 0);W(this,bn,void 0);W(this,pu,void 0);W(this,lr,void 0);W(this,qa,void 0);W(this,Oo,void 0);W(this,ki,void 0);W(this,Nd,void 0);W(this,Nr,void 0);W(this,mu,void 0);W(this,gu,void 0);if(D(this,gu,Object.assign({},NW,t||{})),e==="any")D(this,qa,!0),D(this,lr,null);else if(e){const r=$t.from(e);D(this,qa,!1),D(this,lr,Promise.resolve(r)),setTimeout(()=>{this.emit("network",r,null)},0)}else D(this,qa,!1),D(this,lr,null);D(this,ki,-1),D(this,Oo,new Map),D(this,yn,new Map),D(this,To,new Map),D(this,bn,null),D(this,pu,!1),D(this,Nd,1),D(this,Nr,new Map),D(this,mu,!1)}get pollingInterval(){return k(this,gu).pollingInterval}get provider(){return this}get plugins(){return Array.from(k(this,To).values())}attachPlugin(e){if(k(this,To).get(e.name))throw new Error(`cannot replace existing plugin: ${e.name} `);return k(this,To).set(e.name,e.connect(this)),this}getPlugin(e){return k(this,To).get(e)||null}get disableCcipRead(){return k(this,mu)}set disableCcipRead(e){D(this,mu,!!e)}async ccipReadFetch(e,t,r){if(this.disableCcipRead||r.length===0||e.to==null)return null;const s=e.to.toLowerCase(),i=t.toLowerCase(),o=[];for(let a=0;a<r.length;a++){const l=r[a],c=l.replace("{sender}",s).replace("{data}",i),u=new Tn(c);l.indexOf("{data}")===-1&&(u.body={data:i,sender:s}),this.emit("debug",{action:"sendCcipReadFetchRequest",request:u,index:a,urls:r});let f="unknown error";const d=await u.send();try{const h=d.bodyJson;if(h.data)return this.emit("debug",{action:"receiveCcipReadFetchResult",request:u,result:h}),h.data;h.message&&(f=h.message),this.emit("debug",{action:"receiveCcipReadFetchError",request:u,result:h})}catch{}X(d.statusCode<400||d.statusCode>=500,`response not found during CCIP fetch: ${f}`,"OFFCHAIN_FAULT",{reason:"404_MISSING_RESOURCE",transaction:e,info:{url:l,errorMessage:f}}),o.push(f)}X(!1,`error encountered during CCIP fetch: ${o.map(a=>JSON.stringify(a)).join(", ")}`,"OFFCHAIN_FAULT",{reason:"500_SERVER_ERROR",transaction:e,info:{urls:r,errorMessages:o}})}_wrapBlock(e,t){return new q7(pW(e),this)}_wrapLog(e,t){return new cd(dW(e),this)}_wrapTransactionReceipt(e,t){return new uM(bW(e),this)}_wrapTransactionResponse(e,t){return new ud(SM(e),this)}_detectNetwork(){X(!1,"sub-classes must implement this","UNSUPPORTED_OPERATION",{operation:"_detectNetwork"})}async _perform(e){X(!1,`unsupported method: ${e.method}`,"UNSUPPORTED_OPERATION",{operation:e.method,info:e})}async getBlockNumber(){const e=Pe(await ie(this,Rn,ur).call(this,{method:"getBlockNumber"}),"%response");return k(this,ki)>=0&&D(this,ki,e),e}_getAddress(e){return Nn(e,this)}_getBlockTag(e){if(e==null)return"latest";switch(e){case"earliest":return"0x0";case"finalized":case"latest":case"pending":case"safe":return e}if(pt(e))return pt(e,32)?e:ba(e);if(typeof e=="bigint"&&(e=Pe(e,"blockTag")),typeof e=="number")return e>=0?ba(e):k(this,ki)>=0?ba(k(this,ki)+e):this.getBlockNumber().then(t=>ba(t+e));H(!1,"invalid blockTag","blockTag",e)}_getFilter(e){const t=(e.topics||[]).map(l=>l==null?null:Array.isArray(l)?Pv(l.map(c=>c.toLowerCase())):l.toLowerCase()),r="blockHash"in e?e.blockHash:void 0,s=(l,c,u)=>{let f;switch(l.length){case 0:break;case 1:f=l[0];break;default:l.sort(),f=l}if(r&&(c!=null||u!=null))throw new Error("invalid filter");const d={};return f&&(d.address=f),t.length&&(d.topics=t),c&&(d.fromBlock=c),u&&(d.toBlock=u),r&&(d.blockHash=r),d};let i=[];if(e.address)if(Array.isArray(e.address))for(const l of e.address)i.push(this._getAddress(l));else i.push(this._getAddress(e.address));let o;"fromBlock"in e&&(o=this._getBlockTag(e.fromBlock));let a;return"toBlock"in e&&(a=this._getBlockTag(e.toBlock)),i.filter(l=>typeof l!="string").length||o!=null&&typeof o!="string"||a!=null&&typeof a!="string"?Promise.all([Promise.all(i),o,a]).then(l=>s(l[0],l[1],l[2])):s(i,o,a)}_getTransactionRequest(e){const t=qm(e),r=[];if(["to","from"].forEach(s=>{if(t[s]==null)return;const i=Nn(t[s],this);rg(i)?r.push(async function(){t[s]=await i}()):t[s]=i}),t.blockTag!=null){const s=this._getBlockTag(t.blockTag);rg(s)?r.push(async function(){t.blockTag=await s}()):t.blockTag=s}return r.length?async function(){return await Promise.all(r),t}():t}async getNetwork(){if(k(this,lr)==null){const s=(async()=>{try{const i=await this._detectNetwork();return this.emit("network",i,null),i}catch(i){throw k(this,lr)===s&&D(this,lr,null),i}})();return D(this,lr,s),(await s).clone()}const e=k(this,lr),[t,r]=await Promise.all([e,this._detectNetwork()]);return t.chainId!==r.chainId&&(k(this,qa)?(this.emit("network",r,t),k(this,lr)===e&&D(this,lr,Promise.resolve(r))):X(!1,`network changed: ${t.chainId} => ${r.chainId} `,"NETWORK_ERROR",{event:"changed"})),t.clone()}async getFeeData(){const e=await this.getNetwork(),t=async()=>{const{_block:s,gasPrice:i,priorityFee:o}=await pn({_block:ie(this,Pd,o1).call(this,"latest",!1),gasPrice:(async()=>{try{const u=await ie(this,Rn,ur).call(this,{method:"getGasPrice"});return pe(u,"%response")}catch{}return null})(),priorityFee:(async()=>{try{const u=await ie(this,Rn,ur).call(this,{method:"getPriorityFee"});return pe(u,"%response")}catch{}return null})()});let a=null,l=null;const c=this._wrapBlock(s,e);return c&&c.baseFeePerGas&&(l=o??BigInt("1000000000"),a=c.baseFeePerGas*SW+l),new cM(i,a,l)},r=e.getPlugin("org.ethers.plugins.network.FetchUrlFeeDataPlugin");if(r){const s=new Tn(r.url),i=await r.processFunc(t,this,s);return new cM(i.gasPrice,i.maxFeePerGas,i.maxPriorityFeePerGas)}return await t()}async estimateGas(e){let t=this._getTransactionRequest(e);return rg(t)&&(t=await t),pe(await ie(this,Rn,ur).call(this,{method:"estimateGas",transaction:t}),"%response")}async call(e){const{tx:t,blockTag:r}=await pn({tx:this._getTransactionRequest(e),blockTag:this._getBlockTag(e.blockTag)});return await ie(this,Rd,i1).call(this,ie(this,Md,s1).call(this,t,r,e.enableCcipRead?0:-1))}async getBalance(e,t){return pe(await ie(this,Qa,$d).call(this,{method:"getBalance"},e,t),"%response")}async getTransactionCount(e,t){return Pe(await ie(this,Qa,$d).call(this,{method:"getTransactionCount"},e,t),"%response")}async getCode(e,t){return ce(await ie(this,Qa,$d).call(this,{method:"getCode"},e,t))}async getStorage(e,t,r){const s=pe(t,"position");return ce(await ie(this,Qa,$d).call(this,{method:"getStorage",position:s},e,r))}async broadcastTransaction(e){const{blockNumber:t,hash:r,network:s}=await pn({blockNumber:this.getBlockNumber(),hash:this._perform({method:"broadcastTransaction",signedTransaction:e}),network:this.getNetwork()}),i=ad.from(e);if(i.hash!==r)throw new Error("@TODO: the returned hash did not match");return this._wrapTransactionResponse(i,s).replaceableTransaction(t)}async getBlock(e,t){const{network:r,params:s}=await pn({network:this.getNetwork(),params:ie(this,Pd,o1).call(this,e,!!t)});return s==null?null:this._wrapBlock(s,r)}async getTransaction(e){const{network:t,params:r}=await pn({network:this.getNetwork(),params:ie(this,Rn,ur).call(this,{method:"getTransaction",hash:e})});return r==null?null:this._wrapTransactionResponse(r,t)}async getTransactionReceipt(e){const{network:t,params:r}=await pn({network:this.getNetwork(),params:ie(this,Rn,ur).call(this,{method:"getTransactionReceipt",hash:e})});if(r==null)return null;if(r.gasPrice==null&&r.effectiveGasPrice==null){const s=await ie(this,Rn,ur).call(this,{method:"getTransaction",hash:e});if(s==null)throw new Error("report this; could not find tx or effectiveGasPrice");r.effectiveGasPrice=s.gasPrice}return this._wrapTransactionReceipt(r,t)}async getTransactionResult(e){const{result:t}=await pn({network:this.getNetwork(),result:ie(this,Rn,ur).call(this,{method:"getTransactionResult",hash:e})});return t==null?null:ce(t)}async getLogs(e){let t=this._getFilter(e);rg(t)&&(t=await t);const{network:r,params:s}=await pn({network:this.getNetwork(),params:ie(this,Rn,ur).call(this,{method:"getLogs",filter:t})});return s.map(i=>this._wrapLog(i,r))}_getProvider(e){X(!1,"provider cannot connect to target network","UNSUPPORTED_OPERATION",{operation:"_getProvider()"})}async getResolver(e){return await Zm.fromName(this,e)}async getAvatar(e){const t=await this.getResolver(e);return t?await t.getAvatar():null}async resolveName(e){const t=await this.getResolver(e);return t?await t.getAddress():null}async lookupAddress(e){e=st(e);const t=fv(e.substring(2).toLowerCase()+".addr.reverse");try{const r=await Zm.getEnsAddress(this),i=await new Cc(r,["function resolver(bytes32) view returns (address)"],this).resolver(t);if(i==null||i===Xf)return null;const a=await new Cc(i,["function name(bytes32) view returns (string)"],this).name(t);return await this.resolveName(a)!==e?null:a}catch(r){if(Zt(r,"BAD_DATA")&&r.value==="0x"||Zt(r,"CALL_EXCEPTION"))return null;throw r}return null}async waitForTransaction(e,t,r){const s=t??1;return s===0?this.getTransactionReceipt(e):new Promise(async(i,o)=>{let a=null;const l=async c=>{try{const u=await this.getTransactionReceipt(e);if(u!=null&&c-u.blockNumber+1>=s){i(u),a&&(clearTimeout(a),a=null);return}}catch(u){console.log("EEE",u)}this.once("block",l)};r!=null&&(a=setTimeout(()=>{a!=null&&(a=null,this.off("block",l),o(wt("timeout","TIMEOUT",{reason:"timeout"})))},r)),l(await this.getBlockNumber())})}async waitForBlock(e){X(!1,"not implemented yet","NOT_IMPLEMENTED",{operation:"waitForBlock"})}_clearTimeout(e){const t=k(this,Nr).get(e);t&&(t.timer&&clearTimeout(t.timer),k(this,Nr).delete(e))}_setTimeout(e,t){t==null&&(t=0);const r=Hd(this,Nd)._++,s=()=>{k(this,Nr).delete(r),e()};if(this.paused)k(this,Nr).set(r,{timer:null,func:s,time:t});else{const i=setTimeout(s,t);k(this,Nr).set(r,{timer:i,func:s,time:Iv()})}return r}_forEachSubscriber(e){for(const t of k(this,yn).values())e(t.subscriber)}_getSubscriber(e){switch(e.type){case"debug":case"error":case"network":return new ig(e.type);case"block":{const t=new xW(this);return t.pollingInterval=this.pollingInterval,t}case"safe":case"finalized":return new EW(this,e.type);case"event":return new Rv(this,e.filter);case"transaction":return new CW(this,e.hash);case"orphan":return new kW(this,e.filter)}throw new Error(`unsupported event: ${e.type}`)}_recoverSubscriber(e,t){for(const r of k(this,yn).values())if(r.subscriber===e){r.started&&r.subscriber.stop(),r.subscriber=t,r.started&&t.start(),k(this,bn)!=null&&t.pause(k(this,bn));break}}async on(e,t){const r=await ie(this,yu,Ig).call(this,e);return r.listeners.push({listener:t,once:!1}),r.started||(r.subscriber.start(),r.started=!0,k(this,bn)!=null&&r.subscriber.pause(k(this,bn))),this}async once(e,t){const r=await ie(this,yu,Ig).call(this,e);return r.listeners.push({listener:t,once:!0}),r.started||(r.subscriber.start(),r.started=!0,k(this,bn)!=null&&r.subscriber.pause(k(this,bn))),this}async emit(e,...t){const r=await ie(this,Ya,zd).call(this,e,t);if(!r||r.listeners.length===0)return!1;const s=r.listeners.length;return r.listeners=r.listeners.filter(({listener:i,once:o})=>{const a=new G2(this,o?null:i,e);try{i.call(this,...t,a)}catch{}return!o}),r.listeners.length===0&&(r.started&&r.subscriber.stop(),k(this,yn).delete(r.tag)),s>0}async listenerCount(e){if(e){const r=await ie(this,Ya,zd).call(this,e);return r?r.listeners.length:0}let t=0;for(const{listeners:r}of k(this,yn).values())t+=r.length;return t}async listeners(e){if(e){const r=await ie(this,Ya,zd).call(this,e);return r?r.listeners.map(({listener:s})=>s):[]}let t=[];for(const{listeners:r}of k(this,yn).values())t=t.concat(r.map(({listener:s})=>s));return t}async off(e,t){const r=await ie(this,Ya,zd).call(this,e);if(!r)return this;if(t){const s=r.listeners.map(({listener:i})=>i).indexOf(t);s>=0&&r.listeners.splice(s,1)}return(!t||r.listeners.length===0)&&(r.started&&r.subscriber.stop(),k(this,yn).delete(r.tag)),this}async removeAllListeners(e){if(e){const{tag:t,started:r,subscriber:s}=await ie(this,yu,Ig).call(this,e);r&&s.stop(),k(this,yn).delete(t)}else for(const[t,{started:r,subscriber:s}]of k(this,yn))r&&s.stop(),k(this,yn).delete(t);return this}async addListener(e,t){return await this.on(e,t)}async removeListener(e,t){return this.off(e,t)}get destroyed(){return k(this,pu)}destroy(){this.removeAllListeners();for(const e of k(this,Nr).keys())this._clearTimeout(e);D(this,pu,!0)}get paused(){return k(this,bn)!=null}set paused(e){!!e!==this.paused&&(this.paused?this.resume():this.pause(!1))}pause(e){if(D(this,ki,-1),k(this,bn)!=null){if(k(this,bn)==!!e)return;X(!1,"cannot change pause type; resume first","UNSUPPORTED_OPERATION",{operation:"pause"})}this._forEachSubscriber(t=>t.pause(e)),D(this,bn,!!e);for(const t of k(this,Nr).values())t.timer&&clearTimeout(t.timer),t.time=Iv()-t.time}resume(){if(k(this,bn)!=null){this._forEachSubscriber(e=>e.resume()),D(this,bn,null);for(const e of k(this,Nr).values()){let t=e.time;t<0&&(t=0),e.time=Iv(),setTimeout(e.func,t)}}}}yn=new WeakMap,To=new WeakMap,bn=new WeakMap,pu=new WeakMap,lr=new WeakMap,qa=new WeakMap,Oo=new WeakMap,ki=new WeakMap,Nd=new WeakMap,Nr=new WeakMap,mu=new WeakMap,gu=new WeakMap,Rn=new WeakSet,ur=async function(e){const t=k(this,gu).cacheTimeout;if(t<0)return await this._perform(e);const r=sg(e.method,e);let s=k(this,Oo).get(r);return s||(s=this._perform(e),k(this,Oo).set(r,s),setTimeout(()=>{k(this,Oo).get(r)===s&&k(this,Oo).delete(r)},t)),await s},Md=new WeakSet,s1=async function(e,t,r){X(r<TW,"CCIP read exceeded maximum redirections","OFFCHAIN_FAULT",{reason:"TOO_MANY_REDIRECTS",transaction:Object.assign({},e,{blockTag:t,enableCcipRead:!0})});const s=qm(e);try{return ce(await this._perform({method:"call",transaction:s,blockTag:t}))}catch(i){if(!this.disableCcipRead&&Nw(i)&&i.data&&r>=0&&t==="latest"&&s.to!=null&&Nt(i.data,0,4)==="0x556f1830"){const o=i.data,a=await Nn(s.to,this);let l;try{l=IW(Nt(i.data,4))}catch(f){X(!1,f.message,"OFFCHAIN_FAULT",{reason:"BAD_DATA",transaction:s,info:{data:o}})}X(l.sender.toLowerCase()===a.toLowerCase(),"CCIP Read sender mismatch","CALL_EXCEPTION",{action:"call",data:o,reason:"OffchainLookup",transaction:s,invocation:null,revert:{signature:"OffchainLookup(address,string[],bytes,bytes4,bytes)",name:"OffchainLookup",args:l.errorArgs}});const c=await this.ccipReadFetch(s,l.calldata,l.urls);X(c!=null,"CCIP Read failed to fetch data","OFFCHAIN_FAULT",{reason:"FETCH_FAILED",transaction:s,info:{data:i.data,errorArgs:l.errorArgs}});const u={to:a,data:Rt([l.selector,DW([c,l.extraData])])};this.emit("debug",{action:"sendCcipReadCall",transaction:u});try{const f=await ie(this,Md,s1).call(this,u,t,r+1);return this.emit("debug",{action:"receiveCcipReadCallResult",transaction:Object.assign({},u),result:f}),f}catch(f){throw this.emit("debug",{action:"receiveCcipReadCallError",transaction:Object.assign({},u),error:f}),f}}throw i}},Rd=new WeakSet,i1=async function(e){const{value:t}=await pn({network:this.getNetwork(),value:e});return t},Qa=new WeakSet,$d=async function(e,t,r){let s=this._getAddress(t),i=this._getBlockTag(r);return(typeof s!="string"||typeof i!="string")&&([s,i]=await Promise.all([s,i])),await ie(this,Rd,i1).call(this,ie(this,Rn,ur).call(this,Object.assign(e,{address:s,blockTag:i})))},Pd=new WeakSet,o1=async function(e,t){if(pt(e,32))return await ie(this,Rn,ur).call(this,{method:"getBlock",blockHash:e,includeTransactions:t});let r=this._getBlockTag(e);return typeof r!="string"&&(r=await r),await ie(this,Rn,ur).call(this,{method:"getBlock",blockTag:r,includeTransactions:t})},Ya=new WeakSet,zd=async function(e,t){let r=await Dv(e,this);return r.type==="event"&&t&&t.length>0&&t[0].removed===!0&&(r=await Dv({orphan:"drop-log",log:t[0]},this)),k(this,yn).get(r.tag)||null},yu=new WeakSet,Ig=async function(e){const t=await Dv(e,this),r=t.tag;let s=k(this,yn).get(r);return s||(s={subscriber:this._getSubscriber(t),tag:r,addressableMap:new WeakMap,nameMap:new Map,started:!1,listeners:[]},k(this,yn).set(r,s)),s};function MW(n,e){try{const t=_v(n,e);if(t)return fc(t)}catch{}return null}function _v(n,e){if(n==="0x")return null;try{const t=Pe(Nt(n,e,e+32)),r=Pe(Nt(n,t,t+32));return Nt(n,t+32,t+32+r)}catch{}return null}function MM(n){const e=Sn(n);if(e.length>32)throw new Error("internal; should not happen");const t=new Uint8Array(32);return t.set(e,32-e.length),t}function RW(n){if(n.length%32===0)return n;const e=new Uint8Array(Math.ceil(n.length/32)*32);return e.set(n),e}const PW=new Uint8Array([]);function DW(n){const e=[];let t=0;for(let r=0;r<n.length;r++)e.push(PW),t+=32;for(let r=0;r<n.length;r++){const s=qe(n[r]);e[r]=MM(t),e.push(MM(s.length)),e.push(RW(s)),t+=32+Math.ceil(s.length/32)*32}return Rt(e)}const RM="0x0000000000000000000000000000000000000000000000000000000000000000";function IW(n){const e={sender:"",urls:[],calldata:"",selector:"",extraData:"",errorArgs:[]};X(cc(n)>=5*32,"insufficient OffchainLookup data","OFFCHAIN_FAULT",{reason:"insufficient OffchainLookup data"});const t=Nt(n,0,32);X(Nt(t,0,12)===Nt(RM,0,12),"corrupt OffchainLookup sender","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup sender"}),e.sender=Nt(t,12);try{const r=[],s=Pe(Nt(n,32,64)),i=Pe(Nt(n,s,s+32)),o=Nt(n,s+32);for(let a=0;a<i;a++){const l=MW(o,a*32);if(l==null)throw new Error("abort");r.push(l)}e.urls=r}catch{X(!1,"corrupt OffchainLookup urls","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup urls"})}try{const r=_v(n,64);if(r==null)throw new Error("abort");e.calldata=r}catch{X(!1,"corrupt OffchainLookup calldata","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup calldata"})}X(Nt(n,100,128)===Nt(RM,0,28),"corrupt OffchainLookup callbaackSelector","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup callbaackSelector"}),e.selector=Nt(n,96,100);try{const r=_v(n,128);if(r==null)throw new Error("abort");e.extraData=r}catch{X(!1,"corrupt OffchainLookup extraData","OFFCHAIN_FAULT",{reason:"corrupt OffchainLookup extraData"})}return e.errorArgs="sender,urls,calldata,selector,extraData".split(/,/).map(r=>e[r]),e}function Tc(n,e){if(n.provider)return n.provider;X(!1,"missing provider","UNSUPPORTED_OPERATION",{operation:e})}async function PM(n,e){let t=qm(e);if(t.to!=null&&(t.to=Nn(t.to,n)),t.from!=null){const r=t.from;t.from=Promise.all([n.getAddress(),Nn(r,n)]).then(([s,i])=>(H(s.toLowerCase()===i.toLowerCase(),"transaction from mismatch","tx.from",i),s))}else t.from=n.getAddress();return await pn(t)}class _W{constructor(e){j(this,"provider");be(this,{provider:e||null})}async getNonce(e){return Tc(this,"getTransactionCount").getTransactionCount(await this.getAddress(),e)}async populateCall(e){return await PM(this,e)}async populateTransaction(e){const t=Tc(this,"populateTransaction"),r=await PM(this,e);r.nonce==null&&(r.nonce=await this.getNonce("pending")),r.gasLimit==null&&(r.gasLimit=await this.estimateGas(r));const s=await this.provider.getNetwork();if(r.chainId!=null){const o=pe(r.chainId);H(o===s.chainId,"transaction chainId mismatch","tx.chainId",e.chainId)}else r.chainId=s.chainId;const i=r.maxFeePerGas!=null||r.maxPriorityFeePerGas!=null;if(r.gasPrice!=null&&(r.type===2||i)?H(!1,"eip-1559 transaction do not support gasPrice","tx",e):(r.type===0||r.type===1)&&i&&H(!1,"pre-eip-1559 transaction do not support maxFeePerGas/maxPriorityFeePerGas","tx",e),(r.type===2||r.type==null)&&r.maxFeePerGas!=null&&r.maxPriorityFeePerGas!=null)r.type=2;else if(r.type===0||r.type===1){const o=await t.getFeeData();X(o.gasPrice!=null,"network does not support gasPrice","UNSUPPORTED_OPERATION",{operation:"getGasPrice"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice)}else{const o=await t.getFeeData();if(r.type==null)if(o.maxFeePerGas!=null&&o.maxPriorityFeePerGas!=null)if(r.type=2,r.gasPrice!=null){const a=r.gasPrice;delete r.gasPrice,r.maxFeePerGas=a,r.maxPriorityFeePerGas=a}else r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas);else o.gasPrice!=null?(X(!i,"network does not support EIP-1559","UNSUPPORTED_OPERATION",{operation:"populateTransaction"}),r.gasPrice==null&&(r.gasPrice=o.gasPrice),r.type=0):X(!1,"failed to get consistent fee data","UNSUPPORTED_OPERATION",{operation:"signer.getFeeData"});else(r.type===2||r.type===3)&&(r.maxFeePerGas==null&&(r.maxFeePerGas=o.maxFeePerGas),r.maxPriorityFeePerGas==null&&(r.maxPriorityFeePerGas=o.maxPriorityFeePerGas))}return await pn(r)}async estimateGas(e){return Tc(this,"estimateGas").estimateGas(await this.populateCall(e))}async call(e){return Tc(this,"call").call(await this.populateCall(e))}async resolveName(e){return await Tc(this,"resolveName").resolveName(e)}async sendTransaction(e){const t=Tc(this,"sendTransaction"),r=await this.populateTransaction(e);delete r.from;const s=ad.from(r);return await t.broadcastTransaction(await this.signTransaction(s))}}const DM=new Set;function Oc(n){DM.has(n)||(DM.add(n),console.log("========= NOTICE ========="),console.log(`Request-Rate Exceeded for ${n} (this message will not be repeated)`),console.log(""),console.log("The default API keys for each service are provided as a highly-throttled,"),console.log("community resource for low-traffic projects and early prototyping."),console.log(""),console.log("While your application will continue to function, we highly recommended"),console.log("signing up for your own API keys to improve performance, increase your"),console.log("request rate/limit and enable other perks, such as metrics and advanced APIs."),console.log(""),console.log("For more details: https://docs.ethers.org/api-keys/"),console.log("=========================="))}function LW(n){return JSON.parse(JSON.stringify(n))}class IM{constructor(e){W(this,Dd);W(this,Id);W(this,Pn,void 0);W(this,_s,void 0);W(this,Xa,void 0);W(this,No,void 0);W(this,Za,void 0);W(this,bu,void 0);D(this,Pn,e),D(this,_s,null),D(this,Xa,ie(this,Dd,a1).bind(this)),D(this,No,!1),D(this,Za,null),D(this,bu,!1)}_subscribe(e){throw new Error("subclasses must override this")}_emitResults(e,t){throw new Error("subclasses must override this")}_recover(e){throw new Error("subclasses must override this")}start(){k(this,No)||(D(this,No,!0),ie(this,Dd,a1).call(this,-2))}stop(){k(this,No)&&(D(this,No,!1),D(this,bu,!0),ie(this,Id,l1).call(this),k(this,Pn).off("block",k(this,Xa)))}pause(e){e&&ie(this,Id,l1).call(this),k(this,Pn).off("block",k(this,Xa))}resume(){this.start()}}Pn=new WeakMap,_s=new WeakMap,Xa=new WeakMap,No=new WeakMap,Za=new WeakMap,bu=new WeakMap,Dd=new WeakSet,a1=async function(e){try{k(this,_s)==null&&D(this,_s,this._subscribe(k(this,Pn)));let t=null;try{t=await k(this,_s)}catch(i){if(!Zt(i,"UNSUPPORTED_OPERATION")||i.operation!=="eth_newFilter")throw i}if(t==null){D(this,_s,null),k(this,Pn)._recoverSubscriber(this,this._recover(k(this,Pn)));return}const r=await k(this,Pn).getNetwork();if(k(this,Za)||D(this,Za,r),k(this,Za).chainId!==r.chainId)throw new Error("chaid changed");if(k(this,bu))return;const s=await k(this,Pn).send("eth_getFilterChanges",[t]);await this._emitResults(k(this,Pn),s)}catch(t){console.log("@TODO",t)}k(this,Pn).once("block",k(this,Xa))},Id=new WeakSet,l1=function(){const e=k(this,_s);e&&(D(this,_s,null),e.then(t=>{k(this,Pn).destroyed||k(this,Pn).send("eth_uninstallFilter",[t])}))};class BW extends IM{constructor(t,r){super(t);W(this,el,void 0);D(this,el,LW(r))}_recover(t){return new Rv(t,k(this,el))}async _subscribe(t){return await t.send("eth_newFilter",[k(this,el)])}async _emitResults(t,r){for(const s of r)t.emit(k(this,el),t._wrapLog(s,t._network))}}el=new WeakMap;class FW extends IM{async _subscribe(e){return await e.send("eth_newPendingTransactionFilter",[])}async _emitResults(e,t){for(const r of t)e.emit("pending",r)}}const UW="bigint,boolean,function,number,string,symbol".split(/,/g);function ag(n){if(n==null||UW.indexOf(typeof n)>=0||typeof n.getAddress=="function")return n;if(Array.isArray(n))return n.map(ag);if(typeof n=="object")return Object.keys(n).reduce((e,t)=>(e[t]=n[t],e),{});throw new Error(`should not happen: ${n} (${typeof n})`)}function HW(n){return new Promise(e=>{setTimeout(e,n)})}function Nc(n){return n&&n.toLowerCase()}function _M(n){return n&&typeof n.pollingInterval=="number"}const LM={polling:!1,staticNetwork:null,batchStallTime:10,batchMaxSize:1<<20,batchMaxCount:100,cacheTimeout:250,pollingInterval:4e3};class Lv extends _W{constructor(t,r){super(t);j(this,"address");r=st(r),be(this,{address:r})}connect(t){X(!1,"cannot reconnect JsonRpcSigner","UNSUPPORTED_OPERATION",{operation:"signer.connect"})}async getAddress(){return this.address}async populateTransaction(t){return await this.populateCall(t)}async sendUncheckedTransaction(t){const r=ag(t),s=[];if(r.from){const o=r.from;s.push((async()=>{const a=await Nn(o,this.provider);H(a!=null&&a.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),r.from=a})())}else r.from=this.address;if(r.gasLimit==null&&s.push((async()=>{r.gasLimit=await this.provider.estimateGas({...r,from:this.address})})()),r.to!=null){const o=r.to;s.push((async()=>{r.to=await Nn(o,this.provider)})())}s.length&&await Promise.all(s);const i=this.provider.getRpcTransaction(r);return this.provider.send("eth_sendTransaction",[i])}async sendTransaction(t){const r=await this.provider.getBlockNumber(),s=await this.sendUncheckedTransaction(t);return await new Promise((i,o)=>{const a=[1e3,100];let l=0;const c=async()=>{try{const u=await this.provider.getTransaction(s);if(u!=null){i(u.replaceableTransaction(r));return}}catch(u){if(Zt(u,"CANCELLED")||Zt(u,"BAD_DATA")||Zt(u,"NETWORK_ERROR")){u.info==null&&(u.info={}),u.info.sendTransactionHash=s,o(u);return}if(Zt(u,"INVALID_ARGUMENT")&&(l++,u.info==null&&(u.info={}),u.info.sendTransactionHash=s,l>10)){o(u);return}this.provider.emit("error",wt("failed to fetch transation after sending (will try again)","UNKNOWN_ERROR",{error:u}))}this.provider._setTimeout(()=>{c()},a.pop()||4e3)};c()})}async signTransaction(t){const r=ag(t);if(r.from){const i=await Nn(r.from,this.provider);H(i!=null&&i.toLowerCase()===this.address.toLowerCase(),"from address mismatch","transaction",t),r.from=i}else r.from=this.address;const s=this.provider.getRpcTransaction(r);return await this.provider.send("eth_signTransaction",[s])}async signMessage(t){const r=typeof t=="string"?ri(t):t;return await this.provider.send("personal_sign",[ce(r),this.address.toLowerCase()])}async signTypedData(t,r,s){const i=ag(s),o=await Gm.resolveNames(t,r,i,async a=>{const l=await Nn(a);return H(l!=null,"TypedData does not support null address","value",a),l});return await this.provider.send("eth_signTypedData_v4",[this.address.toLowerCase(),JSON.stringify(Gm.getPayload(o.domain,r,o.value))])}async unlock(t){return this.provider.send("personal_unlockAccount",[this.address.toLowerCase(),t,null])}async _legacySignMessage(t){const r=typeof t=="string"?ri(t):t;return await this.provider.send("eth_sign",[this.address.toLowerCase(),ce(r)])}}class BM extends og{constructor(t,r){super(t,r);W(this,_d);W(this,tl,void 0);W(this,wu,void 0);W(this,Ci,void 0);W(this,Ls,void 0);W(this,Xr,void 0);W(this,Mr,void 0);W(this,Kn,void 0);D(this,wu,1),D(this,tl,Object.assign({},LM,r||{})),D(this,Ci,[]),D(this,Ls,null),D(this,Mr,null),D(this,Kn,null);{let i=null;const o=new Promise(a=>{i=a});D(this,Xr,{promise:o,resolve:i})}const s=this._getOption("staticNetwork");typeof s=="boolean"?(H(!s||t!=="any","staticNetwork cannot be used on special network 'any'","options",r),s&&t!=null&&D(this,Mr,$t.from(t))):s&&(H(t==null||s.matches(t),"staticNetwork MUST match network object","options",r),D(this,Mr,s))}_getOption(t){return k(this,tl)[t]}get _network(){return X(k(this,Mr),"network is not available yet","NETWORK_ERROR"),k(this,Mr)}async _perform(t){if(t.method==="call"||t.method==="estimateGas"){let s=t.transaction;if(s&&s.type!=null&&pe(s.type)&&s.maxFeePerGas==null&&s.maxPriorityFeePerGas==null){const i=await this.getFeeData();i.maxFeePerGas==null&&i.maxPriorityFeePerGas==null&&(t=Object.assign({},t,{transaction:Object.assign({},s,{type:void 0})}))}}const r=this.getRpcRequest(t);return r!=null?await this.send(r.method,r.args):super._perform(t)}async _detectNetwork(){const t=this._getOption("staticNetwork");if(t)if(t===!0){if(k(this,Mr))return k(this,Mr)}else return t;return k(this,Kn)?await k(this,Kn):this.ready?(D(this,Kn,(async()=>{try{const r=$t.from(pe(await this.send("eth_chainId",[])));return D(this,Kn,null),r}catch(r){throw D(this,Kn,null),r}})()),await k(this,Kn)):(D(this,Kn,(async()=>{const r={id:Hd(this,wu)._++,method:"eth_chainId",params:[],jsonrpc:"2.0"};this.emit("debug",{action:"sendRpcPayload",payload:r});let s;try{s=(await this._send(r))[0],D(this,Kn,null)}catch(i){throw D(this,Kn,null),this.emit("debug",{action:"receiveRpcError",error:i}),i}if(this.emit("debug",{action:"receiveRpcResult",result:s}),"result"in s)return $t.from(pe(s.result));throw this.getRpcError(r,s)})()),await k(this,Kn))}_start(){k(this,Xr)==null||k(this,Xr).resolve==null||(k(this,Xr).resolve(),D(this,Xr,null),(async()=>{for(;k(this,Mr)==null&&!this.destroyed;)try{D(this,Mr,await this._detectNetwork())}catch(t){if(this.destroyed)break;console.log("JsonRpcProvider failed to detect network and cannot start up; retry in 1s (perhaps the URL is wrong or the node is not started)"),this.emit("error",wt("failed to bootstrap network detection","NETWORK_ERROR",{event:"initial-network-discovery",info:{error:t}})),await HW(1e3)}ie(this,_d,c1).call(this)})())}async _waitUntilReady(){if(k(this,Xr)!=null)return await k(this,Xr).promise}_getSubscriber(t){return t.type==="pending"?new FW(this):t.type==="event"?this._getOption("polling")?new Rv(this,t.filter):new BW(this,t.filter):t.type==="orphan"&&t.filter.orphan==="drop-log"?new ig("orphan"):super._getSubscriber(t)}get ready(){return k(this,Xr)==null}getRpcTransaction(t){const r={};return["chainId","gasLimit","gasPrice","type","maxFeePerGas","maxPriorityFeePerGas","nonce","value"].forEach(s=>{if(t[s]==null)return;let i=s;s==="gasLimit"&&(i="gas"),r[i]=ba(pe(t[s],`tx.${s}`))}),["from","to","data"].forEach(s=>{t[s]!=null&&(r[s]=ce(t[s]))}),t.accessList&&(r.accessList=fo(t.accessList)),t.blobVersionedHashes&&(r.blobVersionedHashes=t.blobVersionedHashes.map(s=>s.toLowerCase())),r}getRpcRequest(t){switch(t.method){case"chainId":return{method:"eth_chainId",args:[]};case"getBlockNumber":return{method:"eth_blockNumber",args:[]};case"getGasPrice":return{method:"eth_gasPrice",args:[]};case"getPriorityFee":return{method:"eth_maxPriorityFeePerGas",args:[]};case"getBalance":return{method:"eth_getBalance",args:[Nc(t.address),t.blockTag]};case"getTransactionCount":return{method:"eth_getTransactionCount",args:[Nc(t.address),t.blockTag]};case"getCode":return{method:"eth_getCode",args:[Nc(t.address),t.blockTag]};case"getStorage":return{method:"eth_getStorageAt",args:[Nc(t.address),"0x"+t.position.toString(16),t.blockTag]};case"broadcastTransaction":return{method:"eth_sendRawTransaction",args:[t.signedTransaction]};case"getBlock":if("blockTag"in t)return{method:"eth_getBlockByNumber",args:[t.blockTag,!!t.includeTransactions]};if("blockHash"in t)return{method:"eth_getBlockByHash",args:[t.blockHash,!!t.includeTransactions]};break;case"getTransaction":return{method:"eth_getTransactionByHash",args:[t.hash]};case"getTransactionReceipt":return{method:"eth_getTransactionReceipt",args:[t.hash]};case"call":return{method:"eth_call",args:[this.getRpcTransaction(t.transaction),t.blockTag]};case"estimateGas":return{method:"eth_estimateGas",args:[this.getRpcTransaction(t.transaction)]};case"getLogs":return t.filter&&t.filter.address!=null&&(Array.isArray(t.filter.address)?t.filter.address=t.filter.address.map(Nc):t.filter.address=Nc(t.filter.address)),{method:"eth_getLogs",args:[t.filter]}}return null}getRpcError(t,r){const{method:s}=t,{error:i}=r;if(s==="eth_estimateGas"&&i.message){const l=i.message;if(!l.match(/revert/i)&&l.match(/insufficient funds/i))return wt("insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.params[0],info:{payload:t,error:i}})}if(s==="eth_call"||s==="eth_estimateGas"){const l=Bv(i),c=Ec.getBuiltinCallException(s==="eth_call"?"call":"estimateGas",t.params[0],l?l.data:null);return c.info={error:i,payload:t},c}const o=JSON.stringify($W(i));if(typeof i.message=="string"&&i.message.match(/user denied|ethers-user-denied/i))return wt("user rejected action","ACTION_REJECTED",{action:{eth_sign:"signMessage",personal_sign:"signMessage",eth_signTypedData_v4:"signTypedData",eth_signTransaction:"signTransaction",eth_sendTransaction:"sendTransaction",eth_requestAccounts:"requestAccess",wallet_requestAccounts:"requestAccess"}[s]||"unknown",reason:"rejected",info:{payload:t,error:i}});if(s==="eth_sendRawTransaction"||s==="eth_sendTransaction"){const l=t.params[0];if(o.match(/insufficient funds|base fee exceeds gas limit/i))return wt("insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:l,info:{error:i}});if(o.match(/nonce/i)&&o.match(/too low/i))return wt("nonce has already been used","NONCE_EXPIRED",{transaction:l,info:{error:i}});if(o.match(/replacement transaction/i)&&o.match(/underpriced/i))return wt("replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:l,info:{error:i}});if(o.match(/only replay-protected/i))return wt("legacy pre-eip-155 transactions not supported","UNSUPPORTED_OPERATION",{operation:s,info:{transaction:l,info:{error:i}}})}let a=!!o.match(/the method .* does not exist/i);return a||i&&i.details&&i.details.startsWith("Unauthorized method:")&&(a=!0),a?wt("unsupported operation","UNSUPPORTED_OPERATION",{operation:t.method,info:{error:i,payload:t}}):wt("could not coalesce error","UNKNOWN_ERROR",{error:i,payload:t})}send(t,r){if(this.destroyed)return Promise.reject(wt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t}));const s=Hd(this,wu)._++,i=new Promise((o,a)=>{k(this,Ci).push({resolve:o,reject:a,payload:{method:t,params:r,id:s,jsonrpc:"2.0"}})});return ie(this,_d,c1).call(this),i}async getSigner(t){t==null&&(t=0);const r=this.send("eth_accounts",[]);if(typeof t=="number"){const i=await r;if(t>=i.length)throw new Error("no such account");return new Lv(this,i[t])}const{accounts:s}=await pn({network:this.getNetwork(),accounts:r});t=st(t);for(const i of s)if(st(i)===t)return new Lv(this,t);throw new Error("invalid account")}async listAccounts(){return(await this.send("eth_accounts",[])).map(r=>new Lv(this,r))}destroy(){k(this,Ls)&&(clearTimeout(k(this,Ls)),D(this,Ls,null));for(const{payload:t,reject:r}of k(this,Ci))r(wt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:t.method}));D(this,Ci,[]),super.destroy()}}tl=new WeakMap,wu=new WeakMap,Ci=new WeakMap,Ls=new WeakMap,Xr=new WeakMap,Mr=new WeakMap,Kn=new WeakMap,_d=new WeakSet,c1=function(){if(k(this,Ls))return;const t=this._getOption("batchMaxCount")===1?0:this._getOption("batchStallTime");D(this,Ls,setTimeout(()=>{D(this,Ls,null);const r=k(this,Ci);for(D(this,Ci,[]);r.length;){const s=[r.shift()];for(;r.length&&s.length!==k(this,tl).batchMaxCount;)if(s.push(r.shift()),JSON.stringify(s.map(o=>o.payload)).length>k(this,tl).batchMaxSize){r.unshift(s.pop());break}(async()=>{const i=s.length===1?s[0].payload:s.map(o=>o.payload);this.emit("debug",{action:"sendRpcPayload",payload:i});try{const o=await this._send(i);this.emit("debug",{action:"receiveRpcResult",result:o});for(const{resolve:a,reject:l,payload:c}of s){if(this.destroyed){l(wt("provider destroyed; cancelled request","UNSUPPORTED_OPERATION",{operation:c.method}));continue}const u=o.filter(f=>f.id===c.id)[0];if(u==null){const f=wt("missing response for request","BAD_DATA",{value:o,info:{payload:c}});this.emit("error",f),l(f);continue}if("error"in u){l(this.getRpcError(c,u));continue}a(u.result)}}catch(o){this.emit("debug",{action:"receiveRpcError",error:o});for(const{reject:a}of s)a(o)}})()}},t))};class jW extends BM{constructor(t,r){super(t,r);W(this,Mo,void 0);let s=this._getOption("pollingInterval");s==null&&(s=LM.pollingInterval),D(this,Mo,s)}_getSubscriber(t){const r=super._getSubscriber(t);return _M(r)&&(r.pollingInterval=k(this,Mo)),r}get pollingInterval(){return k(this,Mo)}set pollingInterval(t){if(!Number.isInteger(t)||t<0)throw new Error("invalid interval");D(this,Mo,t),this._forEachSubscriber(r=>{_M(r)&&(r.pollingInterval=k(this,Mo))})}}Mo=new WeakMap;class fi extends jW{constructor(t,r,s){t==null&&(t="http://localhost:8545");super(r,s);W(this,vu,void 0);typeof t=="string"?D(this,vu,new Tn(t)):D(this,vu,t.clone())}_getConnection(){return k(this,vu).clone()}async send(t,r){return await this._start(),await super.send(t,r)}async _send(t){const r=this._getConnection();r.body=JSON.stringify(t),r.setHeader("content-type","application/json");const s=await r.send();s.assertOk();let i=s.bodyJson;return Array.isArray(i)||(i=[i]),i}}vu=new WeakMap;function Bv(n){if(n==null)return null;if(typeof n.message=="string"&&n.message.match(/revert/i)&&pt(n.data))return{message:n.message,data:n.data};if(typeof n=="object"){for(const e in n){const t=Bv(n[e]);if(t)return t}return null}if(typeof n=="string")try{return Bv(JSON.parse(n))}catch{}return null}function Fv(n,e){if(n!=null){if(typeof n.message=="string"&&e.push(n.message),typeof n=="object")for(const t in n)Fv(n[t],e);if(typeof n=="string")try{return Fv(JSON.parse(n),e)}catch{}}}function $W(n){const e=[];return Fv(n,e),e}const lg="9f7d929b018cdffb338517efa06f58359e86ff1ffd350bc889738523659e7972";function zW(n){switch(n){case"mainnet":return"rpc.ankr.com/eth";case"goerli":return"rpc.ankr.com/eth_goerli";case"sepolia":return"rpc.ankr.com/eth_sepolia";case"arbitrum":return"rpc.ankr.com/arbitrum";case"base":return"rpc.ankr.com/base";case"base-goerli":return"rpc.ankr.com/base_goerli";case"base-sepolia":return"rpc.ankr.com/base_sepolia";case"bnb":return"rpc.ankr.com/bsc";case"bnbt":return"rpc.ankr.com/bsc_testnet_chapel";case"matic":return"rpc.ankr.com/polygon";case"matic-mumbai":return"rpc.ankr.com/polygon_mumbai";case"optimism":return"rpc.ankr.com/optimism";case"optimism-goerli":return"rpc.ankr.com/optimism_testnet";case"optimism-sepolia":return"rpc.ankr.com/optimism_sepolia"}H(!1,"unsupported network","network",n)}class cg extends fi{constructor(t,r){t==null&&(t="mainnet");const s=$t.from(t);r==null&&(r=lg);const i={polling:!0,staticNetwork:s},o=cg.getRequest(s,r);super(o,s,i);j(this,"apiKey");be(this,{apiKey:r})}_getProvider(t){try{return new cg(t,this.apiKey)}catch{}return super._getProvider(t)}static getRequest(t,r){r==null&&(r=lg);const s=new Tn(`https://${zW(t.name)}/${r}`);return s.allowGzip=!0,r===lg&&(s.retryFunc=async(i,o,a)=>(Oc("AnkrProvider"),!0)),s}getRpcError(t,r){return t.method==="eth_sendRawTransaction"&&r&&r.error&&r.error.message==="INTERNAL_ERROR: could not replace existing tx"&&(r.error.message="replacement transaction underpriced"),super.getRpcError(t,r)}isCommunityResource(){return this.apiKey===lg}}const ug="_gg7wSSi0KMBsdKnGVfHDueq6xMB9EkC";function VW(n){switch(n){case"mainnet":return"eth-mainnet.alchemyapi.io";case"goerli":return"eth-goerli.g.alchemy.com";case"sepolia":return"eth-sepolia.g.alchemy.com";case"arbitrum":return"arb-mainnet.g.alchemy.com";case"arbitrum-goerli":return"arb-goerli.g.alchemy.com";case"arbitrum-sepolia":return"arb-sepolia.g.alchemy.com";case"base":return"base-mainnet.g.alchemy.com";case"base-goerli":return"base-goerli.g.alchemy.com";case"base-sepolia":return"base-sepolia.g.alchemy.com";case"matic":return"polygon-mainnet.g.alchemy.com";case"matic-amoy":return"polygon-amoy.g.alchemy.com";case"matic-mumbai":return"polygon-mumbai.g.alchemy.com";case"optimism":return"opt-mainnet.g.alchemy.com";case"optimism-goerli":return"opt-goerli.g.alchemy.com";case"optimism-sepolia":return"opt-sepolia.g.alchemy.com"}H(!1,"unsupported network","network",n)}class fg extends fi{constructor(t,r){t==null&&(t="mainnet");const s=$t.from(t);r==null&&(r=ug);const i=fg.getRequest(s,r);super(i,s,{staticNetwork:s});j(this,"apiKey");be(this,{apiKey:r})}_getProvider(t){try{return new fg(t,this.apiKey)}catch{}return super._getProvider(t)}async _perform(t){if(t.method==="getTransactionResult"){const{trace:r,tx:s}=await pn({trace:this.send("trace_transaction",[t.hash]),tx:this.getTransaction(t.hash)});if(r==null||s==null)return null;let i,o=!1;try{i=r[0].result.output,o=r[0].error==="Reverted"}catch{}if(i)return X(!o,"an error occurred during transaction executions","CALL_EXCEPTION",{action:"getTransactionResult",data:i,reason:null,transaction:s,invocation:null,revert:null}),i;X(!1,"could not parse trace result","BAD_DATA",{value:r})}return await super._perform(t)}isCommunityResource(){return this.apiKey===ug}static getRequest(t,r){r==null&&(r=ug);const s=new Tn(`https://${VW(t.name)}/v2/${r}`);return s.allowGzip=!0,r===ug&&(s.retryFunc=async(i,o,a)=>(Oc("alchemy"),!0)),s}}function dg(n){switch(n){case"mainnet":return"39f1d67cedf8b7831010a665328c9197";case"arbitrum":return"0550c209db33c3abf4cc927e1e18cea1";case"bnb":return"98b5a77e531614387366f6fc5da097f8";case"matic":return"cd9d4d70377471aa7c142ec4a4205249"}H(!1,"unsupported network","network",n)}function WW(n){switch(n){case"mainnet":return"ethereum-mainnet.core.chainstack.com";case"arbitrum":return"arbitrum-mainnet.core.chainstack.com";case"bnb":return"bsc-mainnet.core.chainstack.com";case"matic":return"polygon-mainnet.core.chainstack.com"}H(!1,"unsupported network","network",n)}class hg extends fi{constructor(t,r){t==null&&(t="mainnet");const s=$t.from(t);r==null&&(r=dg(s.name));const i=hg.getRequest(s,r);super(i,s,{staticNetwork:s});j(this,"apiKey");be(this,{apiKey:r})}_getProvider(t){try{return new hg(t,this.apiKey)}catch{}return super._getProvider(t)}isCommunityResource(){return this.apiKey===dg(this._network.name)}static getRequest(t,r){r==null&&(r=dg(t.name));const s=new Tn(`https://${WW(t.name)}/${r}`);return s.allowGzip=!0,r===dg(t.name)&&(s.retryFunc=async(i,o,a)=>(Oc("ChainstackProvider"),!0)),s}}class GW extends fi{constructor(e){e==null&&(e="mainnet");const t=$t.from(e);H(t.name==="mainnet","unsupported network","network",e),super("https://cloudflare-eth.com/",t,{staticNetwork:t})}}const FM=2e3;function KW(n){return n&&typeof n.then=="function"}const JW="org.ethers.plugins.provider.Etherscan",qW=["enableCcipRead"];let QW=1;class YW extends og{constructor(t,r){const s=r??null;super();j(this,"network");j(this,"apiKey");W(this,Au,void 0);const i=$t.from(t);D(this,Au,i.getPlugin(JW)),be(this,{apiKey:s,network:i}),this.getBaseUrl()}getBaseUrl(){if(k(this,Au))return k(this,Au).baseUrl;switch(this.network.name){case"mainnet":return"https://api.etherscan.io";case"goerli":return"https://api-goerli.etherscan.io";case"sepolia":return"https://api-sepolia.etherscan.io";case"holesky":return"https://api-holesky.etherscan.io";case"arbitrum":return"https://api.arbiscan.io";case"arbitrum-goerli":return"https://api-goerli.arbiscan.io";case"base":return"https://api.basescan.org";case"base-sepolia":return"https://api-sepolia.basescan.org";case"bnb":return"https://api.bscscan.com";case"bnbt":return"https://api-testnet.bscscan.com";case"matic":return"https://api.polygonscan.com";case"matic-amoy":return"https://api-amoy.polygonscan.com";case"matic-mumbai":return"https://api-testnet.polygonscan.com";case"optimism":return"https://api-optimistic.etherscan.io";case"optimism-goerli":return"https://api-goerli-optimistic.etherscan.io"}H(!1,"unsupported network","network",this.network)}getUrl(t,r){const s=Object.keys(r).reduce((o,a)=>{const l=r[a];return l!=null&&(o+=`&${a}=${l}`),o},""),i=this.apiKey?`&apikey=${this.apiKey}`:"";return`${this.getBaseUrl()}/api?module=${t}${s}${i}`}getPostUrl(){return`${this.getBaseUrl()}/api`}getPostData(t,r){return r.module=t,r.apikey=this.apiKey,r}async detectNetwork(){return this.network}async fetch(t,r,s){const i=QW++,o=s?this.getPostUrl():this.getUrl(t,r),a=s?this.getPostData(t,r):null;this.emit("debug",{action:"sendRequest",id:i,url:o,payload:a});const l=new Tn(o);l.setThrottleParams({slotInterval:1e3}),l.retryFunc=(f,d,h)=>(this.isCommunityResource()&&Oc("Etherscan"),Promise.resolve(!0)),l.processFunc=async(f,d)=>{const h=d.hasBody()?JSON.parse(fc(d.body)):{},p=(typeof h.result=="string"?h.result:"").toLowerCase().indexOf("rate limit")>=0;return t==="proxy"?h&&h.status==0&&h.message=="NOTOK"&&p&&(this.emit("debug",{action:"receiveError",id:i,reason:"proxy-NOTOK",error:h}),d.throwThrottleError(h.result,FM)):p&&(this.emit("debug",{action:"receiveError",id:i,reason:"null result",error:h.result}),d.throwThrottleError(h.result,FM)),d},a&&(l.setHeader("content-type","application/x-www-form-urlencoded; charset=UTF-8"),l.body=Object.keys(a).map(f=>`${f}=${a[f]}`).join("&"));const c=await l.send();try{c.assertOk()}catch(f){this.emit("debug",{action:"receiveError",id:i,error:f,reason:"assertOk"}),X(!1,"response error","SERVER_ERROR",{request:l,response:c})}c.hasBody()||(this.emit("debug",{action:"receiveError",id:i,error:"missing body",reason:"null body"}),X(!1,"missing response","SERVER_ERROR",{request:l,response:c}));const u=JSON.parse(fc(c.body));return t==="proxy"?(u.jsonrpc!="2.0"&&(this.emit("debug",{action:"receiveError",id:i,result:u,reason:"invalid JSON-RPC"}),X(!1,"invalid JSON-RPC response (missing jsonrpc='2.0')","SERVER_ERROR",{request:l,response:c,info:{result:u}})),u.error&&(this.emit("debug",{action:"receiveError",id:i,result:u,reason:"JSON-RPC error"}),X(!1,"error response","SERVER_ERROR",{request:l,response:c,info:{result:u}})),this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result):u.status==0&&(u.message==="No records found"||u.message==="No transactions found")?(this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result):((u.status!=1||typeof u.message=="string"&&!u.message.match(/^OK/))&&(this.emit("debug",{action:"receiveError",id:i,result:u}),X(!1,"error response","SERVER_ERROR",{request:l,response:c,info:{result:u}})),this.emit("debug",{action:"receiveRequest",id:i,result:u}),u.result)}_getTransactionPostData(t){const r={};for(let s in t){if(qW.indexOf(s)>=0||t[s]==null)continue;let i=t[s];if(!(s==="type"&&i===0)&&!(s==="blockTag"&&i==="latest")){if({type:!0,gasLimit:!0,gasPrice:!0,maxFeePerGs:!0,maxPriorityFeePerGas:!0,nonce:!0,value:!0}[s])i=ba(i);else if(s==="accessList")i="["+fo(i).map(o=>`{address:"${o.address}",storageKeys:["${o.storageKeys.join('","')}"]}`).join(",")+"]";else if(s==="blobVersionedHashes"){if(i.length===0)continue;X(!1,"Etherscan API does not support blobVersionedHashes","UNSUPPORTED_OPERATION",{operation:"_getTransactionPostData",info:{transaction:t}})}else i=ce(i);r[s]=i}}return r}_checkError(t,r,s){let i="";if(Zt(r,"SERVER_ERROR")){try{i=r.info.result.error.message}catch{}if(!i)try{i=r.info.message}catch{}}if(t.method==="estimateGas"&&!i.match(/revert/i)&&i.match(/insufficient funds/i)&&X(!1,"insufficient funds","INSUFFICIENT_FUNDS",{transaction:t.transaction}),(t.method==="call"||t.method==="estimateGas")&&i.match(/execution reverted/i)){let o="";try{o=r.info.result.error.data}catch{}const a=Ec.getBuiltinCallException(t.method,t.transaction,o);throw a.info={request:t,error:r},a}if(i&&t.method==="broadcastTransaction"){const o=ad.from(t.signedTransaction);i.match(/replacement/i)&&i.match(/underpriced/i)&&X(!1,"replacement fee too low","REPLACEMENT_UNDERPRICED",{transaction:o}),i.match(/insufficient funds/)&&X(!1,"insufficient funds for intrinsic transaction cost","INSUFFICIENT_FUNDS",{transaction:o}),i.match(/same hash was already imported|transaction nonce is too low|nonce too low/)&&X(!1,"nonce has already been used","NONCE_EXPIRED",{transaction:o})}throw r}async _detectNetwork(){return this.network}async _perform(t){switch(t.method){case"chainId":return this.network.chainId;case"getBlockNumber":return this.fetch("proxy",{action:"eth_blockNumber"});case"getGasPrice":return this.fetch("proxy",{action:"eth_gasPrice"});case"getPriorityFee":if(this.network.name==="mainnet")return"1000000000";if(this.network.name==="optimism")return"1000000";throw new Error("fallback onto the AbstractProvider default");case"getBalance":return this.fetch("account",{action:"balance",address:t.address,tag:t.blockTag});case"getTransactionCount":return this.fetch("proxy",{action:"eth_getTransactionCount",address:t.address,tag:t.blockTag});case"getCode":return this.fetch("proxy",{action:"eth_getCode",address:t.address,tag:t.blockTag});case"getStorage":return this.fetch("proxy",{action:"eth_getStorageAt",address:t.address,position:t.position,tag:t.blockTag});case"broadcastTransaction":return this.fetch("proxy",{action:"eth_sendRawTransaction",hex:t.signedTransaction},!0).catch(r=>this._checkError(t,r,t.signedTransaction));case"getBlock":if("blockTag"in t)return this.fetch("proxy",{action:"eth_getBlockByNumber",tag:t.blockTag,boolean:t.includeTransactions?"true":"false"});X(!1,"getBlock by blockHash not supported by Etherscan","UNSUPPORTED_OPERATION",{operation:"getBlock(blockHash)"});case"getTransaction":return this.fetch("proxy",{action:"eth_getTransactionByHash",txhash:t.hash});case"getTransactionReceipt":return this.fetch("proxy",{action:"eth_getTransactionReceipt",txhash:t.hash});case"call":{if(t.blockTag!=="latest")throw new Error("EtherscanProvider does not support blockTag for call");const r=this._getTransactionPostData(t.transaction);r.module="proxy",r.action="eth_call";try{return await this.fetch("proxy",r,!0)}catch(s){return this._checkError(t,s,t.transaction)}}case"estimateGas":{const r=this._getTransactionPostData(t.transaction);r.module="proxy",r.action="eth_estimateGas";try{return await this.fetch("proxy",r,!0)}catch(s){return this._checkError(t,s,t.transaction)}}}return super._perform(t)}async getNetwork(){return this.network}async getEtherPrice(){return this.network.name!=="mainnet"?0:parseFloat((await this.fetch("stats",{action:"ethprice"})).ethusd)}async getContract(t){let r=this._getAddress(t);KW(r)&&(r=await r);try{const s=await this.fetch("contract",{action:"getabi",address:r}),i=JSON.parse(s);return new Cc(r,i,this)}catch{return null}}isCommunityResource(){return this.apiKey==null}}Au=new WeakMap;function XW(){if(typeof self<"u")return self;if(typeof window<"u")return window;if(typeof global<"u")return global;throw new Error("unable to locate global object")}const ZW=XW().WebSocket;class Uv{constructor(e,t){W(this,Bs,void 0);W(this,Ld,void 0);W(this,Ro,void 0);W(this,nl,void 0);W(this,Po,void 0);D(this,Bs,e),D(this,Ld,JSON.stringify(t)),D(this,Ro,null),D(this,nl,null),D(this,Po,null)}get filter(){return JSON.parse(k(this,Ld))}start(){D(this,Ro,k(this,Bs).send("eth_subscribe",this.filter).then(e=>(k(this,Bs)._register(e,this),e)))}stop(){k(this,Ro).then(e=>{k(this,Bs).destroyed||k(this,Bs).send("eth_unsubscribe",[e])}),D(this,Ro,null)}pause(e){X(e,"preserve logs while paused not supported by SocketSubscriber yet","UNSUPPORTED_OPERATION",{operation:"pause(false)"}),D(this,nl,!!e)}resume(){D(this,nl,null)}_handleMessage(e){if(k(this,Ro)!=null&&k(this,nl)===null){let t=k(this,Po);t==null?t=this._emit(k(this,Bs),e):t=t.then(async()=>{await this._emit(k(this,Bs),e)}),D(this,Po,t.then(()=>{k(this,Po)===t&&D(this,Po,null)}))}}async _emit(e,t){throw new Error("sub-classes must implemente this; _emit")}}Bs=new WeakMap,Ld=new WeakMap,Ro=new WeakMap,nl=new WeakMap,Po=new WeakMap;class eG extends Uv{constructor(e){super(e,["newHeads"])}async _emit(e,t){e.emit("block",parseInt(t.number))}}class tG extends Uv{constructor(e){super(e,["newPendingTransactions"])}async _emit(e,t){e.emit("pending",t)}}class nG extends Uv{constructor(t,r){super(t,["logs",r]);W(this,Bd,void 0);D(this,Bd,JSON.stringify(r))}get logFilter(){return JSON.parse(k(this,Bd))}async _emit(t,r){t.emit(this.logFilter,t._wrapLog(r,t._network))}}Bd=new WeakMap;class rG extends BM{constructor(t,r){const s=Object.assign({},r??{});H(s.batchMaxCount==null||s.batchMaxCount===1,"sockets-based providers do not support batches","options.batchMaxCount",r),s.batchMaxCount=1,s.staticNetwork==null&&(s.staticNetwork=!0);super(t,s);W(this,rl,void 0);W(this,xu,void 0);W(this,Do,void 0);D(this,rl,new Map),D(this,xu,new Map),D(this,Do,new Map)}_getSubscriber(t){switch(t.type){case"close":return new ig("close");case"block":return new eG(this);case"pending":return new tG(this);case"event":return new nG(this,t.filter);case"orphan":if(t.filter.orphan==="drop-log")return new ig("drop-log")}return super._getSubscriber(t)}_register(t,r){k(this,xu).set(t,r);const s=k(this,Do).get(t);if(s){for(const i of s)r._handleMessage(i);k(this,Do).delete(t)}}async _send(t){H(!Array.isArray(t),"WebSocket does not support batch send","payload",t);const r=new Promise((s,i)=>{k(this,rl).set(t.id,{payload:t,resolve:s,reject:i})});return await this._waitUntilReady(),await this._write(JSON.stringify(t)),[await r]}async _processMessage(t){const r=JSON.parse(t);if(r&&typeof r=="object"&&"id"in r){const s=k(this,rl).get(r.id);if(s==null){this.emit("error",wt("received result for unknown id","UNKNOWN_ERROR",{reasonCode:"UNKNOWN_ID",result:r}));return}k(this,rl).delete(r.id),s.resolve(r)}else if(r&&r.method==="eth_subscription"){const s=r.params.subscription,i=k(this,xu).get(s);if(i)i._handleMessage(r.params.result);else{let o=k(this,Do).get(s);o==null&&(o=[],k(this,Do).set(s,o)),o.push(r.params.result)}}else{this.emit("error",wt("received unexpected message","UNKNOWN_ERROR",{reasonCode:"UNEXPECTED_MESSAGE",result:r}));return}}async _write(t){throw new Error("sub-classes must override this")}}rl=new WeakMap,xu=new WeakMap,Do=new WeakMap;class UM extends rG{constructor(t,r,s){super(r,s);W(this,sl,void 0);W(this,Zr,void 0);typeof t=="string"?(D(this,sl,()=>new ZW(t)),D(this,Zr,k(this,sl).call(this))):typeof t=="function"?(D(this,sl,t),D(this,Zr,t())):(D(this,sl,null),D(this,Zr,t)),this.websocket.onopen=async()=>{try{await this._start(),this.resume()}catch(i){console.log("failed to start WebsocketProvider",i)}},this.websocket.onmessage=i=>{this._processMessage(i.data)}}get websocket(){if(k(this,Zr)==null)throw new Error("websocket closed");return k(this,Zr)}async _write(t){this.websocket.send(t)}async destroy(){k(this,Zr)!=null&&(k(this,Zr).close(),D(this,Zr,null)),super.destroy()}}sl=new WeakMap,Zr=new WeakMap;const pd="84842078b09946638c03157f83405213";function sG(n){switch(n){case"mainnet":return"mainnet.infura.io";case"goerli":return"goerli.infura.io";case"sepolia":return"sepolia.infura.io";case"arbitrum":return"arbitrum-mainnet.infura.io";case"arbitrum-goerli":return"arbitrum-goerli.infura.io";case"arbitrum-sepolia":return"arbitrum-sepolia.infura.io";case"base":return"base-mainnet.infura.io";case"base-goerlia":return"base-goerli.infura.io";case"base-sepolia":return"base-sepolia.infura.io";case"bnb":return"bnbsmartchain-mainnet.infura.io";case"bnbt":return"bnbsmartchain-testnet.infura.io";case"linea":return"linea-mainnet.infura.io";case"linea-goerli":return"linea-goerli.infura.io";case"linea-sepolia":return"linea-sepolia.infura.io";case"matic":return"polygon-mainnet.infura.io";case"matic-amoy":return"polygon-amoy.infura.io";case"matic-mumbai":return"polygon-mumbai.infura.io";case"optimism":return"optimism-mainnet.infura.io";case"optimism-goerli":return"optimism-goerli.infura.io";case"optimism-sepolia":return"optimism-sepolia.infura.io"}H(!1,"unsupported network","network",n)}class iG extends UM{constructor(t,r){const s=new md(t,r),i=s._getConnection();X(!i.credentials,"INFURA WebSocket project secrets unsupported","UNSUPPORTED_OPERATION",{operation:"InfuraProvider.getWebSocketProvider()"});const o=i.url.replace(/^http/i,"ws").replace("/v3/","/ws/v3/");super(o,s._network);j(this,"projectId");j(this,"projectSecret");be(this,{projectId:s.projectId,projectSecret:s.projectSecret})}isCommunityResource(){return this.projectId===pd}}class md extends fi{constructor(t,r,s){t==null&&(t="mainnet");const i=$t.from(t);r==null&&(r=pd),s==null&&(s=null);const o=md.getRequest(i,r,s);super(o,i,{staticNetwork:i});j(this,"projectId");j(this,"projectSecret");be(this,{projectId:r,projectSecret:s})}_getProvider(t){try{return new md(t,this.projectId,this.projectSecret)}catch{}return super._getProvider(t)}isCommunityResource(){return this.projectId===pd}static getWebSocketProvider(t,r){return new iG(t,r)}static getRequest(t,r,s){r==null&&(r=pd),s==null&&(s=null);const i=new Tn(`https://${sG(t.name)}/v3/${r}`);return i.allowGzip=!0,s&&i.setCredentials("",s),r===pd&&(i.retryFunc=async(o,a,l)=>(Oc("InfuraProvider"),!0)),i}}const pg="919b412a057b5e9c9b6dce193c5a60242d6efadb";function oG(n){switch(n){case"mainnet":return"ethers.quiknode.pro";case"goerli":return"ethers.ethereum-goerli.quiknode.pro";case"sepolia":return"ethers.ethereum-sepolia.quiknode.pro";case"holesky":return"ethers.ethereum-holesky.quiknode.pro";case"arbitrum":return"ethers.arbitrum-mainnet.quiknode.pro";case"arbitrum-goerli":return"ethers.arbitrum-goerli.quiknode.pro";case"arbitrum-sepolia":return"ethers.arbitrum-sepolia.quiknode.pro";case"base":return"ethers.base-mainnet.quiknode.pro";case"base-goerli":return"ethers.base-goerli.quiknode.pro";case"base-spolia":return"ethers.base-sepolia.quiknode.pro";case"bnb":return"ethers.bsc.quiknode.pro";case"bnbt":return"ethers.bsc-testnet.quiknode.pro";case"matic":return"ethers.matic.quiknode.pro";case"matic-mumbai":return"ethers.matic-testnet.quiknode.pro";case"optimism":return"ethers.optimism.quiknode.pro";case"optimism-goerli":return"ethers.optimism-goerli.quiknode.pro";case"optimism-sepolia":return"ethers.optimism-sepolia.quiknode.pro";case"xdai":return"ethers.xdai.quiknode.pro"}H(!1,"unsupported network","network",n)}class mg extends fi{constructor(t,r){t==null&&(t="mainnet");const s=$t.from(t);r==null&&(r=pg);const i=mg.getRequest(s,r);super(i,s,{staticNetwork:s});j(this,"token");be(this,{token:r})}_getProvider(t){try{return new mg(t,this.token)}catch{}return super._getProvider(t)}isCommunityResource(){return this.token===pg}static getRequest(t,r){r==null&&(r=pg);const s=new Tn(`https://${oG(t.name)}/${r}`);return s.allowGzip=!0,r===pg&&(s.retryFunc=async(i,o,a)=>(Oc("QuickNodeProvider"),!0)),s}}const aG=BigInt("1"),lG=BigInt("2");function cG(n){for(let e=n.length-1;e>0;e--){const t=Math.floor(Math.random()*(e+1)),r=n[e];n[e]=n[t],n[t]=r}}function uG(n){return new Promise(e=>{setTimeout(e,n)})}function Hv(){return new Date().getTime()}function jv(n){return JSON.stringify(n,(e,t)=>typeof t=="bigint"?{type:"bigint",value:t.toString()}:t)}const HM={stallTimeout:400,priority:1,weight:1},jM={blockNumber:-2,requests:0,lateResponses:0,errorResponses:0,outOfSync:-1,unsupportedEvents:0,rollingDuration:0,score:0,_network:null,_updateNumber:null,_totalTime:0,_lastFatalError:null,_lastFatalErrorTimestamp:0};async function fG(n,e){for(;(n.blockNumber<0||n.blockNumber<e)&&(n._updateNumber||(n._updateNumber=(async()=>{try{const t=await n.provider.getBlockNumber();t>n.blockNumber&&(n.blockNumber=t)}catch(t){n.blockNumber=-2,n._lastFatalError=t,n._lastFatalErrorTimestamp=Hv()}n._updateNumber=null})()),await n._updateNumber,n.outOfSync++,!n._lastFatalError););}function gd(n){if(n==null)return"null";if(Array.isArray(n))return"["+n.map(gd).join(",")+"]";if(typeof n=="object"&&typeof n.toJSON=="function")return gd(n.toJSON());switch(typeof n){case"boolean":case"symbol":return n.toString();case"bigint":case"number":return BigInt(n).toString();case"string":return JSON.stringify(n);case"object":{const e=Object.keys(n);return e.sort(),"{"+e.map(t=>`${JSON.stringify(t)}:${gd(n[t])}`).join(",")+"}"}}throw console.log("Could not serialize",n),new Error("Hmm...")}function $v(n){if("error"in n){const t=n.error;return{tag:gd(t),value:t}}const e=n.result;return{tag:gd(e),value:e}}function gg(n,e){const t=new Map;for(const{value:s,tag:i,weight:o}of e){const a=t.get(i)||{value:s,weight:0};a.weight+=o,t.set(i,a)}let r=null;for(const s of t.values())s.weight>=n&&(!r||s.weight>r.weight)&&(r=s);if(r)return r.value}function zv(n,e){let t=0;const r=new Map;let s=null;const i=[];for(const{value:a,tag:l,weight:c}of e)if(a instanceof Error){const u=r.get(l)||{value:a,weight:0};u.weight+=c,r.set(l,u),(s==null||u.weight>s.weight)&&(s=u)}else i.push(BigInt(a)),t+=c;if(t<n)return s&&s.weight>=n?s.value:void 0;i.sort((a,l)=>a<l?-1:l>a?1:0);const o=Math.floor(i.length/2);return i.length%2?i[o]:(i[o-1]+i[o]+aG)/lG}function Vv(n,e){const t=gg(n,e);if(t!==void 0)return t;for(const r of e)if(r.value)return r.value}function dG(n,e){if(n===1)return Pe(zv(n,e),"%internal");const t=new Map,r=(o,a)=>{const l=t.get(o)||{result:o,weight:0};l.weight+=a,t.set(o,l)};for(const{weight:o,value:a}of e){const l=Pe(a);r(l-1,o),r(l,o),r(l+1,o)}let s=0,i;for(const{weight:o,result:a}of t.values())o>=n&&(o>s||i!=null&&o===s&&a>i)&&(s=o,i=a);return i}class hG extends og{constructor(t,r,s){super(r,s);W(this,Cg);W(this,Fd);W(this,Sg);W(this,Tg);W(this,Ud);j(this,"quorum");j(this,"eventQuorum");j(this,"eventWorkers");W(this,Jn,void 0);W(this,Si,void 0);W(this,Eu,void 0);D(this,Jn,t.map(i=>i instanceof og?Object.assign({provider:i},HM,jM):Object.assign({},HM,i,jM))),D(this,Si,-2),D(this,Eu,null),s&&s.quorum!=null?this.quorum=s.quorum:this.quorum=Math.ceil(k(this,Jn).reduce((i,o)=>(i+=o.weight,i),0)/2),this.eventQuorum=1,this.eventWorkers=1,H(this.quorum<=k(this,Jn).reduce((i,o)=>i+o.weight,0),"quorum exceed provider weight","quorum",this.quorum)}get providerConfigs(){return k(this,Jn).map(t=>{const r=Object.assign({},t);for(const s in r)s[0]==="_"&&delete r[s];return r})}async _detectNetwork(){return $t.from(pe(await this._perform({method:"chainId"})))}async _translatePerform(t,r){switch(r.method){case"broadcastTransaction":return await t.broadcastTransaction(r.signedTransaction);case"call":return await t.call(Object.assign({},r.transaction,{blockTag:r.blockTag}));case"chainId":return(await t.getNetwork()).chainId;case"estimateGas":return await t.estimateGas(r.transaction);case"getBalance":return await t.getBalance(r.address,r.blockTag);case"getBlock":{const s="blockHash"in r?r.blockHash:r.blockTag;return await t.getBlock(s,r.includeTransactions)}case"getBlockNumber":return await t.getBlockNumber();case"getCode":return await t.getCode(r.address,r.blockTag);case"getGasPrice":return(await t.getFeeData()).gasPrice;case"getPriorityFee":return(await t.getFeeData()).maxPriorityFeePerGas;case"getLogs":return await t.getLogs(r.filter);case"getStorage":return await t.getStorage(r.address,r.position,r.blockTag);case"getTransaction":return await t.getTransaction(r.hash);case"getTransactionCount":return await t.getTransactionCount(r.address,r.blockTag);case"getTransactionReceipt":return await t.getTransactionReceipt(r.hash);case"getTransactionResult":return await t.getTransactionResult(r.hash)}}async _perform(t){if(t.method==="broadcastTransaction"){const o=k(this,Jn).map(c=>null),a=k(this,Jn).map(async({provider:c,weight:u},f)=>{try{const d=await c._perform(t);o[f]=Object.assign($v({result:d}),{weight:u})}catch(d){o[f]=Object.assign($v({error:d}),{weight:u})}});for(;;){const c=o.filter(d=>d!=null);for(const{value:d}of c)if(!(d instanceof Error))return d;const u=gg(this.quorum,o.filter(d=>d!=null));if(Zt(u,"INSUFFICIENT_FUNDS"))throw u;const f=a.filter((d,h)=>o[h]==null);if(f.length===0)break;await Promise.race(f)}const l=Vv(this.quorum,o);if(X(l!==void 0,"problem multi-broadcasting","SERVER_ERROR",{request:"%sub-requests",info:{request:t,results:o.map(jv)}}),l instanceof Error)throw l;return l}await ie(this,Sg,YM).call(this);const r=new Set;let s=0;for(;;){const o=ie(this,Fd,u1).call(this,r,t);if(o==null||(s+=o.config.weight,s>=this.quorum))break}const i=await ie(this,Ud,f1).call(this,r,t);for(const o of r)o.perform&&o.result==null&&o.config.lateResponses++;return i}async destroy(){for(const{provider:t}of k(this,Jn))t.destroy();super.destroy()}}Jn=new WeakMap,Si=new WeakMap,Eu=new WeakMap,Cg=new WeakSet,QM=function(t){const r=Array.from(t).map(i=>i.config),s=k(this,Jn).slice();cG(s),s.sort((i,o)=>i.priority-o.priority);for(const i of s)if(!i._lastFatalError&&r.indexOf(i)===-1)return i;return null},Fd=new WeakSet,u1=function(t,r){const s=ie(this,Cg,QM).call(this,t);if(s==null)return null;const i={config:s,result:null,didBump:!1,perform:null,staller:null},o=Hv();return i.perform=(async()=>{try{s.requests++;const l=await this._translatePerform(s.provider,r);i.result={result:l}}catch(l){s.errorResponses++,i.result={error:l}}const a=Hv()-o;s._totalTime+=a,s.rollingDuration=.95*s.rollingDuration+.05*a,i.perform=null})(),i.staller=(async()=>{await uG(s.stallTimeout),i.staller=null})(),t.add(i),i},Sg=new WeakSet,YM=async function(){let t=k(this,Eu);if(!t){const r=[];k(this,Jn).forEach(s=>{r.push((async()=>{await fG(s,0),s._lastFatalError||(s._network=await s.provider.getNetwork())})())}),D(this,Eu,t=(async()=>{await Promise.all(r);let s=null;for(const i of k(this,Jn)){if(i._lastFatalError)continue;const o=i._network;s==null?s=o.chainId:o.chainId!==s&&X(!1,"cannot mix providers on different networks","UNSUPPORTED_OPERATION",{operation:"new FallbackProvider"})}})())}await t},Tg=new WeakSet,XM=async function(t,r){const s=[];for(const i of t)if(i.result!=null){const{tag:o,value:a}=$v(i.result);s.push({tag:o,value:a,weight:i.config.weight})}if(!(s.reduce((i,o)=>i+o.weight,0)<this.quorum)){switch(r.method){case"getBlockNumber":{k(this,Si)===-2&&D(this,Si,Math.ceil(Pe(zv(this.quorum,k(this,Jn).filter(o=>!o._lastFatalError).map(o=>({value:o.blockNumber,tag:Pe(o.blockNumber).toString(),weight:o.weight}))))));const i=dG(this.quorum,s);return i===void 0?void 0:(i>k(this,Si)&&D(this,Si,i),k(this,Si))}case"getGasPrice":case"getPriorityFee":case"estimateGas":return zv(this.quorum,s);case"getBlock":return"blockTag"in r&&r.blockTag==="pending"?Vv(this.quorum,s):gg(this.quorum,s);case"call":case"chainId":case"getBalance":case"getTransactionCount":case"getCode":case"getStorage":case"getTransaction":case"getTransactionReceipt":case"getLogs":return gg(this.quorum,s);case"broadcastTransaction":return Vv(this.quorum,s)}X(!1,"unsupported method","UNSUPPORTED_OPERATION",{operation:`_perform(${jv(r.method)})`})}},Ud=new WeakSet,f1=async function(t,r){if(t.size===0)throw new Error("no runners?!");const s=[];let i=0;for(const a of t){if(a.perform&&s.push(a.perform),a.staller){s.push(a.staller);continue}a.didBump||(a.didBump=!0,i++)}const o=await ie(this,Tg,XM).call(this,t,r);if(o!==void 0){if(o instanceof Error)throw o;return o}for(let a=0;a<i;a++)ie(this,Fd,u1).call(this,t,r);return X(s.length>0,"quorum not met","SERVER_ERROR",{request:"%sub-requests",info:{request:r,results:Array.from(t).map(a=>jv(a.result))}}),await Promise.race(s),await ie(this,Ud,f1).call(this,t,r)};function pG(n){return n&&typeof n.send=="function"&&typeof n.close=="function"}const mG="goerli kovan sepolia classicKotti optimism-goerli arbitrum-goerli matic-mumbai bnbt".split(" ");function gG(n,e){e==null&&(e={});const t=o=>e[o]==="-"?!1:typeof e.exclusive=="string"?o===e.exclusive:Array.isArray(e.exclusive)?e.exclusive.indexOf(o)!==-1:!0;if(typeof n=="string"&&n.match(/^https?:/))return new fi(n);if(typeof n=="string"&&n.match(/^wss?:/)||pG(n))return new UM(n);let r=null;try{r=$t.from(n)}catch{}const s=[];if(t("publicPolygon")&&r&&(r.name==="matic"?s.push(new fi("https://polygon-rpc.com/",r,{staticNetwork:r})):r.name==="matic-amoy"&&s.push(new fi("https://rpc-amoy.polygon.technology/",r,{staticNetwork:r}))),t("alchemy"))try{s.push(new fg(n,e.alchemy))}catch{}if(t("ankr")&&e.ankr!=null)try{s.push(new cg(n,e.ankr))}catch{}if(t("chainstack"))try{s.push(new hg(n,e.chainstack))}catch{}if(t("cloudflare"))try{s.push(new GW(n))}catch{}if(t("etherscan"))try{s.push(new YW(n,e.etherscan))}catch{}if(t("infura"))try{let o=e.infura,a;typeof o=="object"&&(a=o.projectSecret,o=o.projectId),s.push(new md(n,o,a))}catch{}if(t("quicknode"))try{let o=e.quicknode;s.push(new mg(n,o))}catch{}if(X(s.length,"unsupported default network","UNSUPPORTED_OPERATION",{operation:"getDefaultProvider"}),s.length===1)return s[0];let i=Math.floor(s.length/2);return i>2&&(i=2),r&&mG.indexOf(r.name)!==-1&&(i=1),e&&e.quorum&&(i=e.quorum),new hG(s,void 0,{quorum:i})}const yG=async(n,e)=>{const t={name:n,isEns:!1};if(!e)throw new Error("cannot fetch ens name without a provider url");if(!h9(n))return t;try{const r=await bG(n,e);r&&(t.name=r,t.isEns=!0)}catch(r){console.log(r)}return t},bG=async(n,e)=>await wG(e).lookupAddress(n),wG=n=>gG(n),$M=["#30bced","#6eeb83","#fa69d1","#ecd444","#ee6352","#db3041","#0ad7f2","#1bff39"],vG=({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r,ensProviderUrl:s,username:i,onAutoSave:o})=>{const[a,l]=R.useState({plugin:{title:"Untitled"}}),[c]=R.useState(new Ll),[u,f]=R.useState(!1),[d,h]=R.useState([...iz]),p=NE({extensions:d,editorProps:hS,autofocus:"start"},[d]),g=NE({extensions:d,editorProps:hS,autofocus:"start"}),y=(C,T=!1)=>{if(!t||!r||!C)throw new Error("docId or username is not provided");f(!0);const N=new k8(r,c,{signaling:["wss://fileverse-signaling-server-0529292ff51c.herokuapp.com/"]});h([...d,Q8.configure({document:c}),Y8.configure({provider:N,user:{name:C,color:$M[Math.floor(Math.random()*$M.length)],isEns:T},render:Cz})]);const M=setTimeout(()=>{f(!1)},100);return()=>{clearTimeout(M),N.destroy(),c.destroy(),f(!1)}};R.useEffect(()=>{r&&new vz(r,c)},[r]);const b=R.useRef(null),x=R.useMemo(()=>t&&r&&p&&!u?p:g,[p,g,u]),v=C=>{var T;(T=b.current)!=null&&T.contains(C.target)||x==null||x.chain().focus().run()};R.useEffect(()=>{x==null||x.chain().focus()},[]),R.useEffect(()=>{x==null||x.setEditable(!n)},[n,x]),R.useEffect(()=>{e&&x&&setTimeout(()=>{x==null||x.commands.setContent(e.editorJSONData),l(e.metaData)})},[e,x]);const w=async()=>{if(!i)return;let C=i,T=!1;if(s){const{name:N,isEns:M}=await yG(i,s);C=N,T=M}y(C,T)};R.useEffect(()=>{t&&i&&w()},[t]);const E=R.useCallback(Kb(()=>{x&&o&&o({metaData:a,editorJSONData:x.getJSON()})},1e3),[x,o,a]);return R.useEffect(()=>{if(x&&o)return E(),x.on("update",()=>{E()}),()=>{x.off("destroy",()=>{E()})}},[x,o,a,E]),{editor:x,pluginMetaData:a,setPluginMetaData:l,focusEditor:v,ref:b,loading:u,connect:y}},AG=({isPreviewMode:n=!1,data:e,enableCollaboration:t,collaborationId:r,username:s,onAutoSave:i,renderToolRightSection:o,ensProviderUrl:a})=>{const{editor:l,pluginMetaData:c,focusEditor:u,setPluginMetaData:f,ref:d,loading:h}=vG({isPreviewMode:n,data:e,enableCollaboration:t,collaborationId:r,ensProviderUrl:a,username:s,onAutoSave:i});return!l||h?_.jsxs("div",{className:"w-screen h-screen flex flex-col gap-4 justify-center items-center",children:[_.jsx(mk,{}),_.jsx("p",{children:"Loading Editor..."})]}):_.jsx("div",{"data-cy":"single-webpage",className:"bg-[#f8f9fa]",children:_.jsx("div",{className:"h-full flex flex-col overflow-scroll no-scrollbar",children:_.jsxs("div",{className:"w-full h-screen",children:[_.jsx("div",{className:"h-fit relative bg-[#f8f9fa]",children:_.jsxs("div",{className:"flex items-center justify-center pl-4 pr-4 gap-2 h-16",children:[_.jsx("div",{className:"grow",children:_.jsx(nR,{isPreviewMode:n,metaData:c,setMetaData:f})}),!n&&_.jsx("div",{className:"grow relative",children:_.jsx(OF,{editor:l})}),o==null?void 0:o({editor:l,pluginMetaData:c})]})}),_.jsx("main",{className:"h-screen lg:h-full w-full rounded-[8px] flex flex-col justify-start items-center gap-2",children:_.jsx("div",{onClick:u,className:"w-full flex justify-center relative",children:_.jsx("div",{className:"p-12 sm:p-[96px] mt-4 min-h-[900px] bg-white overflow-scroll no-scrollbar w-full sm:w-[70%] max-w-[856px]",children:_.jsxs("div",{ref:d,className:"w-full pt-4 h-full",children:[!n&&_.jsxs("div",{children:[_.jsx(wF,{editor:l}),_.jsx(SF,{editor:l,appendTo:d})]}),_.jsx(TF,{isPreviewMode:n,children:_.jsx(DB,{editor:l})})]})})})})]})})})};Je.DdocEditor=AG,Object.defineProperty(Je,Symbol.toStringTag,{value:"Module"})});
|