@powerhousedao/connect 5.1.0-dev.3 → 5.1.0-dev.30
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.env +1 -0
- package/dist/assets/AddDriveModal-D9L-2Lil.js +1 -0
- package/dist/assets/ClearStorageModal-DT3crd2J.js +1 -0
- package/dist/assets/CookiesPolicyModal-Cg-ZIYwQ.js +1 -0
- package/dist/assets/CreateDocumentModal-B5-4x1PL.js +1 -0
- package/dist/assets/DebugSettingsModal-2VROxLa6.js +1 -0
- package/dist/assets/DeleteDriveModal-BqTbD9AA.js +1 -0
- package/dist/assets/DeleteItemModal-BcTkVZ5s.js +1 -0
- package/dist/assets/DisclaimerModal-C8twiB3J.js +1 -0
- package/dist/assets/DriveSettingsModal-DGXi1S_w.js +1 -0
- package/dist/assets/ExportDocumentWithErrorsModal-CnVPh2hg.js +1 -0
- package/dist/assets/SettingsModal-DhLRuwrH.js +1 -0
- package/dist/assets/UpgradeDriveModal-BQmVYoWu.js +1 -0
- package/dist/assets/{design_system-D6ejBLrT.js → design_system-wiExdGSo.js} +1 -1
- package/dist/assets/design_system_connect-C8sP_VL9.js +45 -0
- package/dist/assets/{design_system_ui-CtSAZiBK.js → design_system_ui-CPf6X_7e.js} +1 -1
- package/dist/assets/document_drive-CwJB1Xeu.js +316 -0
- package/dist/assets/{document_engineering-BTWZsN7i.js → document_engineering-CO_nmZuG.js} +1 -1
- package/dist/assets/{document_model-DXcLJEjZ.js → document_model-Dg5TMlFt.js} +11 -11
- package/dist/assets/document_model_editor-BWBEv1yk.js +25 -0
- package/dist/assets/{drive_explorer-B7kE_9_o.js → drive_explorer-Br9HlKVt.js} +2 -2
- package/dist/assets/{graphql-editor-CwDDLZi4.js → graphql-editor-CJvpFT5J.js} +1 -1
- package/dist/assets/{hooks-Cu19Ukp1.js → hooks-CBM25xI9.js} +1 -1
- package/dist/assets/index-C9sx8eSK.js +18 -0
- package/dist/assets/index-CaSdt_en.js +25 -0
- package/dist/assets/index-CdamZauA.css +1 -0
- package/dist/assets/{json-editor-W5vEzMnK.js → json-editor-ROpu8Iji.js} +1 -1
- package/dist/assets/nodefs-Vq2O_c5A.js +1 -0
- package/dist/assets/opfs-ahp-BrSKGNTW.js +3 -0
- package/dist/assets/pg_dump-CW0pN9tG.wasm +0 -0
- package/dist/assets/postgres-CkP7QCDB.data +0 -0
- package/dist/assets/postgres-CyuUVpXN.wasm +0 -0
- package/dist/assets/reactor_browser-C4GeHg-H.js +129 -0
- package/dist/assets/{state-schemas-CE_hoR2g.js → state-schemas--EJ9plhU.js} +2 -2
- package/dist/assets/zod-BpTyxkjy.js +20 -0
- package/dist/index.html +11 -11
- package/heroku/Dockerfile +3 -0
- package/lib/package.copy.json +17 -8
- package/lib/src/components/app.d.ts.map +1 -1
- package/lib/src/components/app.js +11 -0
- package/lib/src/components/app.js.map +1 -1
- package/lib/src/components/drive-editor-container.d.ts.map +1 -1
- package/lib/src/components/drive-editor-container.js +3 -6
- package/lib/src/components/drive-editor-container.js.map +1 -1
- package/lib/src/components/editors.d.ts.map +1 -1
- package/lib/src/components/editors.js +3 -9
- package/lib/src/components/editors.js.map +1 -1
- package/lib/src/components/error-boundary.d.ts +103 -0
- package/lib/src/components/error-boundary.d.ts.map +1 -0
- package/lib/src/components/error-boundary.js +104 -0
- package/lib/src/components/error-boundary.js.map +1 -0
- package/lib/src/components/modal/index.d.ts +0 -1
- package/lib/src/components/modal/index.d.ts.map +1 -1
- package/lib/src/components/modal/index.js +0 -1
- package/lib/src/components/modal/index.js.map +1 -1
- package/lib/src/components/modal/modals/AddDriveModal.d.ts.map +1 -1
- package/lib/src/components/modal/modals/AddDriveModal.js +35 -27
- package/lib/src/components/modal/modals/AddDriveModal.js.map +1 -1
- package/lib/src/components/modal/modals/InspectorModal/InspectorModal.d.ts +2 -0
- package/lib/src/components/modal/modals/InspectorModal/InspectorModal.d.ts.map +1 -0
- package/lib/src/components/modal/modals/InspectorModal/InspectorModal.js +26 -0
- package/lib/src/components/modal/modals/InspectorModal/InspectorModal.js.map +1 -0
- package/lib/src/components/modal/modals/InspectorModal/index.d.ts +2 -0
- package/lib/src/components/modal/modals/InspectorModal/index.d.ts.map +1 -0
- package/lib/src/components/modal/modals/InspectorModal/index.js +2 -0
- package/lib/src/components/modal/modals/InspectorModal/index.js.map +1 -0
- package/lib/src/components/modal/modals/InspectorModal/useDbExplorer.d.ts +32 -0
- package/lib/src/components/modal/modals/InspectorModal/useDbExplorer.d.ts.map +1 -0
- package/lib/src/components/modal/modals/InspectorModal/useDbExplorer.js +108 -0
- package/lib/src/components/modal/modals/InspectorModal/useDbExplorer.js.map +1 -0
- package/lib/src/components/modal/modals/InspectorModal/useRemotesInspector.d.ts +4 -0
- package/lib/src/components/modal/modals/InspectorModal/useRemotesInspector.d.ts.map +1 -0
- package/lib/src/components/modal/modals/InspectorModal/useRemotesInspector.js +12 -0
- package/lib/src/components/modal/modals/InspectorModal/useRemotesInspector.js.map +1 -0
- package/lib/src/components/modal/modals-container.d.ts.map +1 -1
- package/lib/src/components/modal/modals-container.js +6 -2
- package/lib/src/components/modal/modals-container.js.map +1 -1
- package/lib/src/components/sidebar.d.ts.map +1 -1
- package/lib/src/components/sidebar.js +7 -4
- package/lib/src/components/sidebar.js.map +1 -1
- package/lib/src/connect.config.d.ts +2 -0
- package/lib/src/connect.config.d.ts.map +1 -1
- package/lib/src/connect.config.js +1 -0
- package/lib/src/connect.config.js.map +1 -1
- package/lib/src/feature-flags.d.ts +22 -3
- package/lib/src/feature-flags.d.ts.map +1 -1
- package/lib/src/feature-flags.js +48 -3
- package/lib/src/feature-flags.js.map +1 -1
- package/lib/src/hooks/useClientErrorHandler.d.ts.map +1 -1
- package/lib/src/hooks/useClientErrorHandler.js +13 -2
- package/lib/src/hooks/useClientErrorHandler.js.map +1 -1
- package/lib/src/pages/demo/atlas-import.js +2 -2
- package/lib/src/pages/demo/atlas-import.js.map +1 -1
- package/lib/src/store/reactor.d.ts.map +1 -1
- package/lib/src/store/reactor.js +105 -51
- package/lib/src/store/reactor.js.map +1 -1
- package/lib/src/utils/reactor.d.ts +7 -0
- package/lib/src/utils/reactor.d.ts.map +1 -1
- package/lib/src/utils/reactor.js +35 -2
- package/lib/src/utils/reactor.js.map +1 -1
- package/lib/style.css +12451 -0
- package/lib/test/utils/signer.test.d.ts +2 -0
- package/lib/test/utils/signer.test.d.ts.map +1 -0
- package/lib/test/utils/signer.test.js +318 -0
- package/lib/test/utils/signer.test.js.map +1 -0
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/lib/vite.config.d.ts.map +1 -1
- package/lib/vite.config.js +4 -0
- package/lib/vite.config.js.map +1 -1
- package/lib/vitest.config.d.ts +3 -0
- package/lib/vitest.config.d.ts.map +1 -0
- package/lib/vitest.config.js +8 -0
- package/lib/vitest.config.js.map +1 -0
- package/nginx.conf +7 -0
- package/package.copy.json +17 -8
- package/package.json +24 -15
- package/src/index.css +1 -0
- package/dist/assets/AddDriveModal-BogH1qLY.js +0 -1
- package/dist/assets/ClearStorageModal-BGmHb5YI.js +0 -1
- package/dist/assets/CookiesPolicyModal-B_awrKM1.js +0 -1
- package/dist/assets/CreateDocumentModal-DWmVo234.js +0 -1
- package/dist/assets/DebugSettingsModal-CvIx617r.js +0 -1
- package/dist/assets/DeleteDriveModal-DrShfGEm.js +0 -1
- package/dist/assets/DeleteItemModal-DNwthbws.js +0 -1
- package/dist/assets/DisclaimerModal-DbqPTThP.js +0 -1
- package/dist/assets/DriveSettingsModal-DN9qItSq.js +0 -1
- package/dist/assets/ExportDocumentWithErrorsModal-BYdlElQZ.js +0 -1
- package/dist/assets/SettingsModal-xLvRUiBO.js +0 -1
- package/dist/assets/UpgradeDriveModal-C2HItk6V.js +0 -1
- package/dist/assets/design_system_connect-DGRGq4LH.js +0 -45
- package/dist/assets/document_drive-BEIKnuGM.js +0 -305
- package/dist/assets/document_model_editor-DcutbKRX.js +0 -23
- package/dist/assets/index-Br7E7qjt.css +0 -1
- package/dist/assets/index-CweNcjSF.js +0 -18
- package/dist/assets/reactor_browser-CBjOdsN2.js +0 -25
- package/dist/assets/zod-C6yxFxyo.js +0 -1
- package/lib/src/components/modal/modals-error-boundary.d.ts +0 -18
- package/lib/src/components/modal/modals-error-boundary.d.ts.map +0 -1
- package/lib/src/components/modal/modals-error-boundary.js +0 -22
- package/lib/src/components/modal/modals-error-boundary.js.map +0 -1
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import{l as z,d as Oa,a as Ua,i as Xt,b as Na,c as Ma,g as Pa,h as Ha,e as ja,m as La,u as Fa,s as Va,f as Ka,j as za,r as qa,P as Ja,k as Wa,S as Za,D as Ga,n as Ya}from"./document_drive-BEIKnuGM.js";import{Y as Xa,Z as Qa,d as ec,_ as tc,g as Ce,k as Qt,w as nc,e as rc,$ as oc,a0 as sc,a1 as ic,a2 as ac,j as cc,h as dc}from"./document_model-DXcLJEjZ.js";import"./document_model_editor-DcutbKRX.js";import{r as Ne}from"./sentry_react-cODD7zWc.js";import{g as nr,a as en}from"./react-DQSxOgtG.js";async function be(e,t){if(!t){z.error("No actions found");return}const n=Array.isArray(t)?t:[t];if(n.length===0){z.error("No actions found");return}const r=window.ph?.reactor;if(!r)return;if(!e){z.error("No document found");return}const o=await r.queueActions(e.header.id,n);return o.status!=="SUCCESS"&&z.error(o.error),o.document}async function ls(e,t){if(!t){z.error("No operations found");return}const n=Array.isArray(t)?t:[t],r=window.ph?.reactor;if(!r)return;const o=await r.queueOperations(e,n);return o.status!=="SUCCESS"&&z.error(o.error),o.document}async function hs(e,t,n,r){const o=r?.operationsLimit||50,s=r?.onProgress;z.verbose(`uploadDocumentOperations(documentId:${e}, ops: ${Object.keys(t).join(",")}, limit:${o})`);const i=Object.values(t).filter(d=>d!==void 0),c=i.reduce((d,f)=>d+f.length,0);let a=0;for(const d of i)for(let f=0;f<d.length;f+=o){z.verbose(`uploadDocumentOperations:for(i:${f}, ops:${d.length}, limit:${o}): START`);const l=d.slice(f,f+o),u=l.at(-1);if(!u)break;const b=u.action.scope;if(await n(e,l),a+=l.length,s){const h=Math.round(a/c*100);s({stage:"uploading",progress:h,totalOperations:c,uploadedOperations:a})}z.verbose(`uploadDocumentOperations:for:waitForUpdate(${e}:${b} rev ${u.index}): NEXT`)}z.verbose(`uploadDocumentOperations:for:waitForUpdate(${e}): END`)}async function uc(e,t){const n=window.ph?.reactor;if(!n)return e;const o=n.getDocumentModelModules().find(f=>f.documentModel.global.id===t.header.documentType);if(!o)return z.error(`Document model '${t.header.documentType}' not found`),e;const s=o.reducer,i=window.ph?.user,c=window.ph?.connectCrypto;if(!i||!c||!e.context?.signer)return e;const a=e.context.signer;return await Xa(e,s,t,a,c.sign)}function fc(e){const t=window.ph?.user,n=window.ph?.did;return t?{context:{signer:{app:{name:"Connect",key:n||""},user:{address:t.address,networkId:t.networkId,chainId:t.chainId},signatures:[]}},...e}:e}async function lc(e,t){if(!e){z.error("No action found");return}if(!t){z.error("No document found");return}const n=await uc(e,t);return fc(n)}async function hc(e,t){if(!e){z.error("No actions found");return}const n=Array.isArray(e)?e:[e];return(await Promise.all(n.map(o=>lc(o,t)))).filter(o=>o!==void 0)}async function bc(e){try{return await window.ph?.reactor?.getDocument(e)}catch(t){z.debug(`Failed to get document with id ${e}:`,t);return}}async function pc(e,t){const n=typeof t=="string"?await bc(t):t;if(!n){z.error(`Document with id ${JSON.stringify(t)} not found`);return}const r=await hc(e,n);if(!r){z.error("No signed actions with context found");return}return await be(n,r)}class zr extends Error{constructor(t){super(`Document type ${t} is not supported`),this.name="UnsupportedDocumentTypeError"}}class wc extends Error{constructor(t,n,r){super(`Document ${t} is not of type ${n}. Actual type: ${r}`)}}class yc extends Error{constructor(){super("There is no selected document. Call 'setSelectedNode' to select a document.")}}function gc(e,t){return t?.length?t.some(n=>{if(n.endsWith("/*")){const r=n.slice(0,-2);return e.startsWith(r+"/")}if(n.endsWith("*")&&!n.endsWith("/*")){const r=n.slice(0,-1);return e.startsWith(r)}return n===e}):!0}function ue(){const e=window.ph?.user,t=window.ph?.allowList;return t?{isAllowedToCreateDocuments:t.includes(e?.address??""),isAllowedToEditDocuments:t.includes(e?.address??"")}:{isAllowedToCreateDocuments:!0,isAllowedToEditDocuments:!0}}async function mc(e,t,n){const r=window.ph?.reactor;if(!r)return{isDuplicate:!1};try{const o=await r.getDrive(t),s=o.state.global.nodes.find(c=>c.id===e.header.id);if(s&&s.parentFolder===(n??null))return{isDuplicate:!0,duplicateType:"id",nodeId:s.id};const i=o.state.global.nodes.find(c=>Xt(c)&&c.name===e.header.name&&c.documentType===e.header.documentType&&c.parentFolder===(n??null));return i?{isDuplicate:!0,duplicateType:"name",nodeId:i.id}:{isDuplicate:!1}}catch{return{isDuplicate:!1}}}function Ec(e){switch(e.header.documentType){case"powerhouse/document-model":return"document-model";case"powerhouse/app":return"app";case"powerhouse/document-editor":return"editor";case"powerhouse/subgraph":return"subgraph";case"powerhouse/package":return"package";case"powerhouse/processor":{const r=e.state.global?.type;return r==="analytics"?"analytics-processor":r==="relational"?"relational-processor":r==="codegen"?"codegen-processor":void 0}default:return}}function Dc(e,t){tc(e).generateAsync({type:"blob"}).then(r=>{const o=window.document.createElement("a");o.style.display="none",o.href=URL.createObjectURL(r),o.download=t,window.document.body.appendChild(o),o.click(),window.document.body.removeChild(o)}).catch(z.error)}async function xc(e,t){if(!window.ph?.reactor)return;let r="";if(e.header.documentType===Qa){const i=e.state.global.extension.replace(/^\.+|\.+$/g,"");r=i!==""?`.${i}`:""}const o=`${e.header.name||"Untitled"}${r}.phd`;if(!window.showSaveFilePicker)return Dc(e,o);try{const s=await window.showSaveFilePicker({suggestedName:o});return await ec(e,s),s}catch(s){if(!(s instanceof DOMException&&s.name==="AbortError"))throw s}}async function bs(e){const t=window.ph?.reactor;if(!t)return;const n=t.getDocumentModelModules(),r=await rc(e,s=>s,{checkHashes:!0}),o=n.find(s=>s.documentModel.global.id===r.header.documentType);if(!o)throw new Error(`Document "${r.header.documentType}" is not supported`);return o.utils.loadFromInput(e)}async function ps(e,t,n,r,o,s,i){const c=window.ph?.reactor;if(!c)return;const{isAllowedToCreateDocuments:a}=ue();if(!a)throw new Error("User is not allowed to create documents");const d=await c.getDrive(e),f=s??Ce(),u=c.getDocumentModelModules().find(g=>g.documentModel.global.id===n);if(!u)throw new Error(`Document model module for type ${n} not found`);const b=u.utils.createDocument({...o?.state});b.header=Qt(f,n),b.header.name=t;const h=i?{preferredEditor:i}:void 0;await c.addDocument(b,h);const p=Ua({id:f,name:t,documentType:n,parentFolder:r??null}),w=(await be(d,p)).state.global.nodes.find(g=>g.id===f);if(!w||!Xt(w))throw new Error("There was an error adding document");return w}async function vc(e,t,n,r){z.verbose(`addFile(drive: ${t}, name: ${n}, folder: ${r})`);const o=window.ph?.reactor;if(!o)return;const{isAllowedToCreateDocuments:s}=ue();if(!s)throw new Error("User is not allowed to create files");const i=await bs(e);if(!i)throw new Error("No document loaded");if(!o.getDocumentModelModules().find(b=>b.documentModel.global.id===i.header.documentType))throw new Error(`Document model module for type ${i.header.documentType} not found`);let a=!1;try{await o.getDocument(i.header.id),a=!0}catch{}const d=a?Ce():i.header.id,f=Qt(d,i.header.documentType);f.lastModifiedAtUtcIso=i.header.createdAtUtcIso,f.meta=i.header.meta,f.name=n||i.header.name;const l={...i,state:i.initialState,operations:Object.keys(i.operations).reduce((b,h)=>(b[h]=[],b),{})};if(!await ps(t,n||i.header.name,i.header.documentType,r,l,d,i.header.meta?.preferredEditor))throw new Error("There was an error adding file");hs(d,i.operations,ls).catch(b=>{throw b})}async function Sc(e,t,n,r,o,s,i){z.verbose(`addFileWithProgress(drive: ${t}, name: ${n}, folder: ${r})`);const c=window.ph?.reactor;if(!c)return;const{isAllowedToCreateDocuments:a}=ue();if(!a)throw new Error("User is not allowed to create files");try{o?.({stage:"loading",progress:0});const d=await bs(e);if(!d)throw new Error("No document loaded");const f=await mc(d,t,r);if(f.isDuplicate&&!i){o?.({stage:"conflict",progress:0,duplicateType:f.duplicateType});return}f.isDuplicate&&i==="replace"&&f.nodeId&&await kc(t,f.nodeId);const l=Ec(d);if(o?.(l?{stage:"loading",progress:10,documentType:l}:{stage:"loading",progress:10}),!gc(d.header.documentType,s))throw o?.({stage:"unsupported-document-type",progress:100,error:`Document type ${d.header.documentType} is not supported`}),new zr(d.header.documentType);if(!c.getDocumentModelModules().find(g=>g.documentModel.global.id===d.header.documentType))throw new Error(`Document model module for type ${d.header.documentType} not found`);o?.({stage:"initializing",progress:10});let b=!1;try{await c.getDocument(d.header.id),b=!0}catch{}const h=b?Ce():d.header.id,p=Qt(h,d.header.documentType);p.lastModifiedAtUtcIso=d.header.createdAtUtcIso,p.meta=d.header.meta,p.name=n||d.header.name;const D={...d,header:p,state:d.initialState,operations:Object.keys(d.operations).reduce((g,y)=>(g[y]=[],g),{})},w=await ps(t,n||d.header.name,d.header.documentType,r,D,h,d.header.meta?.preferredEditor);if(!w)throw new Error("There was an error adding file");return o?.({stage:"initializing",progress:20}),await hs(h,d.operations,ls,{onProgress:g=>{if(g.totalOperations&&g.uploadedOperations!==void 0){const y=g.totalOperations>0?g.uploadedOperations/g.totalOperations:0,S=20+Math.round(y*80);o?.({stage:"uploading",progress:S,totalOperations:g.totalOperations,uploadedOperations:g.uploadedOperations})}}}),o?.({stage:"complete",progress:100}),w}catch(d){if(!(d instanceof zr)){const f=d instanceof Error?d.message:"Unknown error occurred";o?.({stage:"failed",progress:100,error:f})}throw d}}async function Ac(e,t,n){const r=window.ph?.reactor;if(!r)return;const{isAllowedToCreateDocuments:o}=ue();if(!o)throw new Error("User is not allowed to create folders");const s=Ce(),i=await r.getDrive(e),a=(await be(i,Na({id:s,name:t,parentFolder:n}))).state.global.nodes.find(d=>d.id===s);if(!a||!Ma(a))throw new Error("There was an error adding folder");return a}async function kc(e,t){const n=window.ph?.reactor;if(!n)return;const{isAllowedToCreateDocuments:r}=ue();if(!r)throw new Error("User is not allowed to delete documents");const o=await n.getDrive(e);await be(o,Oa({id:t}))}async function Tc(e,t,n){const r=window.ph?.reactor;if(!r)return;const{isAllowedToCreateDocuments:o}=ue();if(!o)throw new Error("User is not allowed to rename documents");const s=await r.getDrive(e),c=(await be(s,Fa({id:t,name:n}))).state.global.nodes.find(a=>a.id===t);if(!c)throw new Error("There was an error renaming node");return c}async function Ic(e,t,n){const r=window.ph?.reactor;if(!r)return;const{isAllowedToCreateDocuments:o}=ue();if(!o)throw new Error("User is not allowed to move documents");const s=await r.getDrive(e);return await be(s,La({srcFolder:t.id,targetParentFolder:n?.id}))}function Cc(e,t,n=Ce()){const r=e.getDocumentModelModules().find(o=>o.documentModel.global.id===t.header.documentType);if(!r)throw new Error(`Document model module for type ${t.header.documentType} not found`);return nc(t.initialState,t.operations,r.reducer,void 0,Qt(n,t.header.documentType))}async function qr(e,t,n){const r=window.ph?.reactor;if(!r)return;const{isAllowedToCreateDocuments:o}=ue();if(!o)throw new Error("User is not allowed to copy documents");const s=await r.getDrive(e),i=Pa({srcId:t.id,targetParentFolder:n?.id,targetName:t.name},()=>Ce(),s.state.global.nodes),c=new Map;for(const f of i){const l=s.state.global.nodes.find(u=>u.id===f.srcId);if(l){const u=Ha({nodes:s.state.global.nodes,srcName:f.targetName||l.name,targetParentFolder:f.targetParentFolder||null});c.set(f.targetId,u)}}const a=i.filter(f=>{const l=s.state.global.nodes.find(u=>u.id===f.srcId);return l!==void 0&&Xt(l)});for(const f of a)try{const l=await r.getDocument(f.srcId),u=Cc(r,l,f.targetId),b=c.get(f.targetId);b&&(u.header.name=b),await r.addDocument(u)}catch(l){z.error(`Error copying document ${f.srcId}: ${String(l)}`)}const d=i.map(f=>ja(f));return await be(s,d)}async function q1(e,t){const n=window.ph?.reactor;if(!n)return;const{isAllowedToCreateDocuments:r}=ue();if(!r)throw new Error("User is not allowed to create drives");const o=Ce();return await n.addDrive({global:e.global,local:e.local,id:o},t)}async function J1(e,t){const n=window.ph?.reactor;return n?await n.addRemoteDrive(e,t):void 0}async function W1(e){const t=window.ph?.reactor;if(!t)return;const{isAllowedToCreateDocuments:n}=ue();if(!n)throw new Error("User is not allowed to delete drives");await t.deleteDrive(e)}async function Z1(e,t){const n=window.ph?.reactor;if(!n)return;const{isAllowedToCreateDocuments:r}=ue();if(!r)throw new Error("User is not allowed to rename drives");const o=await n.getDrive(e);return await be(o,za({name:t}))}async function G1(e,t){const n=window.ph?.reactor;if(!n)return;const{isAllowedToCreateDocuments:r}=ue();if(!r)throw new Error("User is not allowed to change drive availability");const o=await n.getDrive(e);return await be(o,Ka({availableOffline:t}))}async function Y1(e,t){const n=window.ph?.reactor;if(!n)return;const{isAllowedToCreateDocuments:r}=ue();if(!r)throw new Error("User is not allowed to change drive availability");const o=await n.getDrive(e);return await be(o,Va({type:t}))}async function X1(e,t){const n=window.ph?.reactor;if(!n)return;const r=await n.getDrive(e);if((await be(r,qa({triggerId:t}))).state.local.triggers.find(i=>i.id===t))throw new Error(`There was an error removing trigger ${t}`)}async function Q1(e,t,n){const r=window.ph?.reactor;if(!r)return;const o=Ce(),s={driveId:e,listenerId:o,block:!1,filter:{branch:n.pullFilter?.branch??[],documentId:n.pullFilter?.documentId??[],documentType:n.pullFilter?.documentType??[],scope:n.pullFilter?.scope??[]},system:!1,label:`Pullresponder #${o}`,callInfo:{data:"",name:"PullResponder",transmitterType:"PullResponder"}},i=r.listeners;s.transmitter=new Ja(s,i);try{await i.setListener(e,s)}catch(c){throw new Error(`Listener couldn't be registered: ${c}`)}return{driveId:e,filter:s.filter,data:{interval:`${n.pullInterval}`||"1000",listenerId:o,url:t},id:o,type:"PullResponder"}}async function ew(e,t){const n=window.ph?.reactor;if(!n)return;const r=await n.getDrive(e);if(!(await be(r,Wa({trigger:t}))).state.local.triggers.find(i=>i.id===i.id))throw new Error(`There was an error adding the trigger ${t.id}`)}const _c="powerhouse/generic-drive-explorer",tw="powerhouse/common";function _(e){const t=`ph:set${oc(e)}`,n=`ph:${e}Updated`;function r(f){const l=new CustomEvent(t,{detail:{[e]:f}});window.dispatchEvent(l)}function o(){const f=new CustomEvent(n);window.dispatchEvent(f)}function s(f){const l=f.detail[e];if(!window.ph)throw new Error("ph global store is not defined");window.ph[e]=l,o()}function i(){window.addEventListener(t,s)}function c(f){return window.addEventListener(n,f),()=>{window.removeEventListener(n,f)}}function a(){if(!window.ph)throw new Error("ph global store is not defined");return window.ph[e]}function d(){return Ne.useSyncExternalStore(c,a)}return{useValue:d,setValue:r,addEventHandler:i}}const ws=_("isExternalControlsEnabled"),Bc=ws.setValue,$c=ws.addEventHandler,rr=_("isDragAndDropEnabled"),Rc=rr.setValue,nw=rr.useValue,Oc=rr.addEventHandler,or=_("allowedDocumentTypes"),Uc=or.setValue;function Nc(){return or.useValue()}const Mc=or.addEventHandler,Pc={allowedDocumentTypes:Uc,isDragAndDropEnabled:Rc},Hc={isExternalControlsEnabled:Bc},sr=_("vetraPackages"),ir=sr.useValue,jc=sr.addEventHandler;function rw(e){sr.setValue(e);const t=e?.flatMap(n=>n.modules.documentModelModules).filter(n=>n!==void 0);window.ph?.reactor?.setDocumentModelModules(t)}function ys(){return ir()?.flatMap(t=>t.modules.documentModelModules||[])}function Lc(e){return ys()?.find(n=>n.id===e)}function Jr(e){return e.toSorted((t,n)=>t.name.localeCompare(n.name))}function ow(e){return e?e.kind.toUpperCase()==="FILE":!1}function gs(e){return e?e.kind.toUpperCase()==="FOLDER":!1}function ar(e){function t(n){pc(n,e).catch(z.error)}return[e,t]}function cr(e){return globalThis.Buffer!=null?new Uint8Array(e.buffer,e.byteOffset,e.byteLength):e}function ms(e=0){return globalThis.Buffer!=null&&globalThis.Buffer.allocUnsafe!=null?cr(globalThis.Buffer.allocUnsafe(e)):new Uint8Array(e)}function Es(e,t){t||(t=e.reduce((o,s)=>o+s.length,0));const n=ms(t);let r=0;for(const o of e)n.set(o,r),r+=o.length;return cr(n)}const Fc=Object.freeze(Object.defineProperty({__proto__:null,concat:Es},Symbol.toStringTag,{value:"Module"}));function Vc(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(n[i]!==255)throw new TypeError(s+" is ambiguous");n[i]=o}var c=e.length,a=e.charAt(0),d=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var p=0,D=0,w=0,g=h.length;w!==g&&h[w]===0;)w++,p++;for(var y=(g-w)*f+1>>>0,S=new Uint8Array(y);w!==g;){for(var E=h[w],m=0,k=y-1;(E!==0||m<D)&&k!==-1;k--,m++)E+=256*S[k]>>>0,S[k]=E%c>>>0,E=E/c>>>0;if(E!==0)throw new Error("Non-zero carry");D=m,w++}for(var A=y-D;A!==y&&S[A]===0;)A++;for(var T=a.repeat(p);A<y;++A)T+=e.charAt(S[A]);return T}function u(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var p=0;if(h[p]!==" "){for(var D=0,w=0;h[p]===a;)D++,p++;for(var g=(h.length-p)*d+1>>>0,y=new Uint8Array(g);h[p];){var S=n[h.charCodeAt(p)];if(S===255)return;for(var E=0,m=g-1;(S!==0||E<w)&&m!==-1;m--,E++)S+=c*y[m]>>>0,y[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=E,p++}if(h[p]!==" "){for(var k=g-w;k!==g&&y[k]===0;)k++;for(var A=new Uint8Array(D+(g-k)),T=D;k!==g;)A[T++]=y[k++];return A}}}function b(h){var p=u(h);if(p)return p;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:u,decode:b}}var Kc=Vc,zc=Kc;const Ds=new Uint8Array(0),qc=e=>e.reduce((t,n)=>t+n.toString(16).padStart(2,"0"),""),Jc=e=>{const t=e.match(/../g);return t?new Uint8Array(t.map(n=>parseInt(n,16))):Ds},xs=(e,t)=>{if(e===t)return!0;if(e.byteLength!==t.byteLength)return!1;for(let n=0;n<e.byteLength;n++)if(e[n]!==t[n])return!1;return!0},Ve=e=>{if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")},Wc=e=>e instanceof ArrayBuffer||ArrayBuffer.isView(e),vs=e=>new TextEncoder().encode(e),Ss=e=>new TextDecoder().decode(e),Zc=Object.freeze(Object.defineProperty({__proto__:null,coerce:Ve,empty:Ds,equals:xs,fromHex:Jc,fromString:vs,isBinary:Wc,toHex:qc,toString:Ss},Symbol.toStringTag,{value:"Module"}));let Gc=class{constructor(t,n,r){this.name=t,this.prefix=n,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}},Yc=class{constructor(t,n,r){if(this.name=t,this.prefix=n,n.codePointAt(0)===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=n.codePointAt(0),this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return As(this,t)}},Xc=class{constructor(t){this.decoders=t}or(t){return As(this,t)}decode(t){const n=t[0],r=this.decoders[n];if(r)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}};const As=(e,t)=>new Xc({...e.decoders||{[e.prefix]:e},...t.decoders||{[t.prefix]:t}});let Qc=class{constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new Gc(t,n,r),this.decoder=new Yc(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}};const tn=({name:e,prefix:t,encode:n,decode:r})=>new Qc(e,t,n,r),Et=({prefix:e,name:t,alphabet:n})=>{const{encode:r,decode:o}=zc(n,t);return tn({prefix:e,name:t,encode:r,decode:s=>Ve(o(s))})},ed=(e,t,n,r)=>{const o={};for(let f=0;f<t.length;++f)o[t[f]]=f;let s=e.length;for(;e[s-1]==="=";)--s;const i=new Uint8Array(s*n/8|0);let c=0,a=0,d=0;for(let f=0;f<s;++f){const l=o[e[f]];if(l===void 0)throw new SyntaxError(`Non-${r} character`);a=a<<n|l,c+=n,c>=8&&(c-=8,i[d++]=255&a>>c)}if(c>=n||255&a<<8-c)throw new SyntaxError("Unexpected end of data");return i},td=(e,t,n)=>{const r=t[t.length-1]==="=",o=(1<<n)-1;let s="",i=0,c=0;for(let a=0;a<e.length;++a)for(c=c<<8|e[a],i+=8;i>n;)i-=n,s+=t[o&c>>i];if(i&&(s+=t[o&c<<n-i]),r)for(;s.length*n&7;)s+="=";return s},ee=({name:e,prefix:t,bitsPerChar:n,alphabet:r})=>tn({prefix:t,name:e,encode(o){return td(o,r,n)},decode(o){return ed(o,r,n,e)}}),nd=tn({prefix:"\0",name:"identity",encode:e=>Ss(e),decode:e=>vs(e)}),rd=Object.freeze(Object.defineProperty({__proto__:null,identity:nd},Symbol.toStringTag,{value:"Module"})),od=ee({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),sd=Object.freeze(Object.defineProperty({__proto__:null,base2:od},Symbol.toStringTag,{value:"Module"})),id=ee({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),ad=Object.freeze(Object.defineProperty({__proto__:null,base8:id},Symbol.toStringTag,{value:"Module"})),cd=Et({prefix:"9",name:"base10",alphabet:"0123456789"}),dd=Object.freeze(Object.defineProperty({__proto__:null,base10:cd},Symbol.toStringTag,{value:"Module"})),ud=ee({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),fd=ee({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),ld=Object.freeze(Object.defineProperty({__proto__:null,base16:ud,base16upper:fd},Symbol.toStringTag,{value:"Module"})),it=ee({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),hd=ee({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),bd=ee({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),pd=ee({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),wd=ee({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),yd=ee({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),gd=ee({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),md=ee({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),Ed=ee({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),Dd=Object.freeze(Object.defineProperty({__proto__:null,base32:it,base32hex:wd,base32hexpad:gd,base32hexpadupper:md,base32hexupper:yd,base32pad:bd,base32padupper:pd,base32upper:hd,base32z:Ed},Symbol.toStringTag,{value:"Module"})),xd=Et({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),vd=Et({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),Sd=Object.freeze(Object.defineProperty({__proto__:null,base36:xd,base36upper:vd},Symbol.toStringTag,{value:"Module"})),me=Et({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),Ad=Et({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),kd=Object.freeze(Object.defineProperty({__proto__:null,base58btc:me,base58flickr:Ad},Symbol.toStringTag,{value:"Module"})),Td=ee({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),Id=ee({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),Cd=ee({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),_d=ee({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),Bd=Object.freeze(Object.defineProperty({__proto__:null,base64:Td,base64pad:Id,base64url:Cd,base64urlpad:_d},Symbol.toStringTag,{value:"Module"})),ks=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),$d=ks.reduce((e,t,n)=>(e[n]=t,e),[]),Rd=ks.reduce((e,t,n)=>(e[t.codePointAt(0)]=n,e),[]);function Od(e){return e.reduce((t,n)=>(t+=$d[n],t),"")}function Ud(e){const t=[];for(const n of e){const r=Rd[n.codePointAt(0)];if(r===void 0)throw new Error(`Non-base256emoji character: ${n}`);t.push(r)}return new Uint8Array(t)}const Nd=tn({prefix:"🚀",name:"base256emoji",encode:Od,decode:Ud}),Md=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:Nd},Symbol.toStringTag,{value:"Module"}));var Pd=Ts,Wr=128,Hd=-128,jd=Math.pow(2,31);function Ts(e,t,n){t=t||[],n=n||0;for(var r=n;e>=jd;)t[n++]=e&255|Wr,e/=128;for(;e&Hd;)t[n++]=e&255|Wr,e>>>=7;return t[n]=e|0,Ts.bytes=n-r+1,t}var Ld=Kn,Fd=128,Zr=127;function Kn(e,r){var n=0,r=r||0,o=0,s=r,i,c=e.length;do{if(s>=c)throw Kn.bytes=0,new RangeError("Could not decode varint");i=e[s++],n+=o<28?(i&Zr)<<o:(i&Zr)*Math.pow(2,o),o+=7}while(i>=Fd);return Kn.bytes=s-r,n}var Vd=Math.pow(2,7),Kd=Math.pow(2,14),zd=Math.pow(2,21),qd=Math.pow(2,28),Jd=Math.pow(2,35),Wd=Math.pow(2,42),Zd=Math.pow(2,49),Gd=Math.pow(2,56),Yd=Math.pow(2,63),Xd=function(e){return e<Vd?1:e<Kd?2:e<zd?3:e<qd?4:e<Jd?5:e<Wd?6:e<Zd?7:e<Gd?8:e<Yd?9:10},Qd={encode:Pd,decode:Ld,encodingLength:Xd},Kt=Qd;const at=(e,t=0)=>[Kt.decode(e,t),Kt.decode.bytes],ct=(e,t,n=0)=>(Kt.encode(e,t,n),t),dt=e=>Kt.encodingLength(e),eu=Object.freeze(Object.defineProperty({__proto__:null,decode:at,encodeTo:ct,encodingLength:dt},Symbol.toStringTag,{value:"Module"})),ut=(e,t)=>{const n=t.byteLength,r=dt(e),o=r+dt(n),s=new Uint8Array(o+n);return ct(e,s,0),ct(n,s,r),s.set(t,o),new nn(e,n,t,s)},Is=e=>{const t=Ve(e),[n,r]=at(t),[o,s]=at(t.subarray(r)),i=t.subarray(r+s);if(i.byteLength!==o)throw new Error("Incorrect length");return new nn(n,o,i,t)},Cs=(e,t)=>e===t?!0:e.code===t.code&&e.size===t.size&&xs(e.bytes,t.bytes);class nn{constructor(t,n,r,o){this.code=t,this.size=n,this.digest=r,this.bytes=o}}const tu=Object.freeze(Object.defineProperty({__proto__:null,Digest:nn,create:ut,decode:Is,equals:Cs},Symbol.toStringTag,{value:"Module"})),dr=({name:e,code:t,encode:n})=>new _s(e,t,n);class _s{constructor(t,n,r){this.name=t,this.code=n,this.encode=r}digest(t){if(t instanceof Uint8Array){const n=this.encode(t);return n instanceof Uint8Array?ut(this.code,n):n.then(r=>ut(this.code,r))}else throw Error("Unknown type, must be binary type")}}const nu=Object.freeze(Object.defineProperty({__proto__:null,Hasher:_s,from:dr},Symbol.toStringTag,{value:"Module"})),Bs=e=>async t=>new Uint8Array(await crypto.subtle.digest(e,t)),ru=dr({name:"sha2-256",code:18,encode:Bs("SHA-256")}),ou=dr({name:"sha2-512",code:19,encode:Bs("SHA-512")}),su=Object.freeze(Object.defineProperty({__proto__:null,sha256:ru,sha512:ou},Symbol.toStringTag,{value:"Module"})),$s=0,iu="identity",Rs=Ve,au=e=>ut($s,Rs(e)),cu={code:$s,name:iu,encode:Rs,digest:au},du=Object.freeze(Object.defineProperty({__proto__:null,identity:cu},Symbol.toStringTag,{value:"Module"})),uu="raw",fu=85,lu=e=>Ve(e),hu=e=>Ve(e),bu=Object.freeze(Object.defineProperty({__proto__:null,code:fu,decode:hu,encode:lu,name:uu},Symbol.toStringTag,{value:"Module"})),pu=new TextEncoder,wu=new TextDecoder,yu="json",gu=512,mu=e=>pu.encode(JSON.stringify(e)),Eu=e=>JSON.parse(wu.decode(e)),Du=Object.freeze(Object.defineProperty({__proto__:null,code:gu,decode:Eu,encode:mu,name:yu},Symbol.toStringTag,{value:"Module"}));class se{constructor(t,n,r,o){this.code=n,this.version=t,this.multihash=r,this.bytes=o,this.byteOffset=o.byteOffset,this.byteLength=o.byteLength,this.asCID=this,this._baseCache=new Map,Object.defineProperties(this,{byteOffset:_t,byteLength:_t,code:Ct,version:Ct,multihash:Ct,bytes:Ct,_baseCache:_t,asCID:_t})}toV0(){switch(this.version){case 0:return this;default:{const{code:t,multihash:n}=this;if(t!==tt)throw new Error("Cannot convert a non dag-pb CID to CIDv0");if(n.code!==Au)throw new Error("Cannot convert non sha2-256 multihash CID to CIDv0");return se.createV0(n)}}}toV1(){switch(this.version){case 0:{const{code:t,digest:n}=this.multihash,r=ut(t,n);return se.createV1(this.code,r)}case 1:return this;default:throw Error(`Can not convert CID version ${this.version} to version 0. This is a bug please report`)}}equals(t){return t&&this.code===t.code&&this.version===t.version&&Cs(this.multihash,t.multihash)}toString(t){const{bytes:n,version:r,_baseCache:o}=this;switch(r){case 0:return vu(n,o,t||me.encoder);default:return Su(n,o,t||it.encoder)}}toJSON(){return{code:this.code,version:this.version,hash:this.multihash.bytes}}get[Symbol.toStringTag](){return"CID"}[Symbol.for("nodejs.util.inspect.custom")](){return"CID("+this.toString()+")"}static isCID(t){return Tu(/^0\.0/,Iu),!!(t&&(t[Yr]||t.asCID===t))}get toBaseEncodedString(){throw new Error("Deprecated, use .toString()")}get codec(){throw new Error('"codec" property is deprecated, use integer "code" property instead')}get buffer(){throw new Error("Deprecated .buffer property, use .bytes to get Uint8Array instead")}get multibaseName(){throw new Error('"multibaseName" property is deprecated')}get prefix(){throw new Error('"prefix" property is deprecated')}static asCID(t){if(t instanceof se)return t;if(t!=null&&t.asCID===t){const{version:n,code:r,multihash:o,bytes:s}=t;return new se(n,r,o,s||Gr(n,r,o.bytes))}else if(t!=null&&t[Yr]===!0){const{version:n,multihash:r,code:o}=t,s=Is(r);return se.create(n,o,s)}else return null}static create(t,n,r){if(typeof n!="number")throw new Error("String codecs are no longer supported");switch(t){case 0:{if(n!==tt)throw new Error(`Version 0 CID must use dag-pb (code: ${tt}) block encoding`);return new se(t,n,r,r.bytes)}case 1:{const o=Gr(t,n,r.bytes);return new se(t,n,r,o)}default:throw new Error("Invalid version")}}static createV0(t){return se.create(0,tt,t)}static createV1(t,n){return se.create(1,t,n)}static decode(t){const[n,r]=se.decodeFirst(t);if(r.length)throw new Error("Incorrect length");return n}static decodeFirst(t){const n=se.inspectBytes(t),r=n.size-n.multihashSize,o=Ve(t.subarray(r,r+n.multihashSize));if(o.byteLength!==n.multihashSize)throw new Error("Incorrect length");const s=o.subarray(n.multihashSize-n.digestSize),i=new nn(n.multihashCode,n.digestSize,s,o);return[n.version===0?se.createV0(i):se.createV1(n.codec,i),t.subarray(n.size)]}static inspectBytes(t){let n=0;const r=()=>{const[l,u]=at(t.subarray(n));return n+=u,l};let o=r(),s=tt;if(o===18?(o=0,n=0):o===1&&(s=r()),o!==0&&o!==1)throw new RangeError(`Invalid CID version ${o}`);const i=n,c=r(),a=r(),d=n+a,f=d-i;return{version:o,codec:s,multihashCode:c,digestSize:a,multihashSize:f,size:d}}static parse(t,n){const[r,o]=xu(t,n),s=se.decode(o);return s._baseCache.set(r,t),s}}const xu=(e,t)=>{switch(e[0]){case"Q":{const n=t||me;return[me.prefix,n.decode(`${me.prefix}${e}`)]}case me.prefix:{const n=t||me;return[me.prefix,n.decode(e)]}case it.prefix:{const n=t||it;return[it.prefix,n.decode(e)]}default:{if(t==null)throw Error("To parse non base32 or base58btc encoded CID multibase decoder must be provided");return[e[0],t.decode(e)]}}},vu=(e,t,n)=>{const{prefix:r}=n;if(r!==me.prefix)throw Error(`Cannot string encode V0 in ${n.name} encoding`);const o=t.get(r);if(o==null){const s=n.encode(e).slice(1);return t.set(r,s),s}else return o},Su=(e,t,n)=>{const{prefix:r}=n,o=t.get(r);if(o==null){const s=n.encode(e);return t.set(r,s),s}else return o},tt=112,Au=18,Gr=(e,t,n)=>{const r=dt(e),o=r+dt(t),s=new Uint8Array(o+n.byteLength);return ct(e,s,0),ct(t,s,r),s.set(n,o),s},Yr=Symbol.for("@ipld/js-cid/CID"),Ct={writable:!1,configurable:!1,enumerable:!0},_t={writable:!1,enumerable:!1,configurable:!1},ku="0.0.0-dev",Tu=(e,t)=>{if(e.test(ku))console.warn(t);else throw new Error(t)},Iu=`CID.isCID(v) is deprecated and will be removed in the next major release.
|
|
2
|
-
Following code pattern:
|
|
3
|
-
|
|
4
|
-
if (CID.isCID(value)) {
|
|
5
|
-
doSomethingWithCID(value)
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
Is replaced with:
|
|
9
|
-
|
|
10
|
-
const cid = CID.asCID(value)
|
|
11
|
-
if (cid) {
|
|
12
|
-
// Make sure to use cid instead of value
|
|
13
|
-
doSomethingWithCID(cid)
|
|
14
|
-
}
|
|
15
|
-
`,zn={...rd,...sd,...ad,...dd,...ld,...Dd,...Sd,...kd,...Bd,...Md},Cu={...su,...du},_u={raw:bu,json:Du},Bu=Object.freeze(Object.defineProperty({__proto__:null,CID:se,bases:zn,bytes:Zc,codecs:_u,digest:tu,hasher:nu,hashes:Cu,varint:eu},Symbol.toStringTag,{value:"Module"}));function Os(e,t,n,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:n},decoder:{decode:r}}}const Xr=Os("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),ln=Os("ascii","a",e=>{let t="a";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t},e=>{e=e.substring(1);const t=ms(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}),Us={utf8:Xr,"utf-8":Xr,hex:zn.base16,latin1:ln,ascii:ln,binary:ln,...zn};function rn(e,t="utf8"){const n=Us[t];if(!n)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?cr(globalThis.Buffer.from(e,"utf-8")):n.decoder.decode(`${n.prefix}${e}`)}const $u=Object.freeze(Object.defineProperty({__proto__:null,fromString:rn},Symbol.toStringTag,{value:"Module"}));function ur(e,t="utf8"){const n=Us[t];if(!n)throw new Error(`Unsupported encoding "${t}"`);return(t==="utf8"||t==="utf-8")&&globalThis.Buffer!=null&&globalThis.Buffer.from!=null?globalThis.Buffer.from(e.buffer,e.byteOffset,e.byteLength).toString("utf8"):n.encoder.encode(e).substring(1)}const Ru=Object.freeze(Object.defineProperty({__proto__:null,toString:ur},Symbol.toStringTag,{value:"Module"})),Ke=typeof globalThis=="object"&&"crypto"in globalThis?globalThis.crypto:void 0;function Dt(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function ft(e){if(!Number.isSafeInteger(e)||e<0)throw new Error("positive integer expected, got "+e)}function Ie(e,...t){if(!Dt(e))throw new Error("Uint8Array expected");if(t.length>0&&!t.includes(e.length))throw new Error("Uint8Array expected of length "+t+", got length="+e.length)}function Ns(e){if(typeof e!="function"||typeof e.create!="function")throw new Error("Hash should be wrapped by utils.createHasher");ft(e.outputLen),ft(e.blockLen)}function Ye(e,t=!0){if(e.destroyed)throw new Error("Hash instance has been destroyed");if(t&&e.finished)throw new Error("Hash#digest() has already been called")}function Ms(e,t){Ie(e);const n=t.outputLen;if(e.length<n)throw new Error("digestInto() expects output buffer of length at least "+n)}function Ou(e){return new Uint32Array(e.buffer,e.byteOffset,Math.floor(e.byteLength/4))}function De(...e){for(let t=0;t<e.length;t++)e[t].fill(0)}function hn(e){return new DataView(e.buffer,e.byteOffset,e.byteLength)}function ye(e,t){return e<<32-t|e>>>t}function Bt(e,t){return e<<t|e>>>32-t>>>0}const Uu=new Uint8Array(new Uint32Array([287454020]).buffer)[0]===68;function Nu(e){return e<<24&4278190080|e<<8&16711680|e>>>8&65280|e>>>24&255}function Mu(e){for(let t=0;t<e.length;t++)e[t]=Nu(e[t]);return e}const Qr=Uu?e=>e:Mu,Ps=typeof Uint8Array.from([]).toHex=="function"&&typeof Uint8Array.fromHex=="function",Pu=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function je(e){if(Ie(e),Ps)return e.toHex();let t="";for(let n=0;n<e.length;n++)t+=Pu[e[n]];return t}const Se={_0:48,_9:57,A:65,F:70,a:97,f:102};function eo(e){if(e>=Se._0&&e<=Se._9)return e-Se._0;if(e>=Se.A&&e<=Se.F)return e-(Se.A-10);if(e>=Se.a&&e<=Se.f)return e-(Se.a-10)}function lt(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);if(Ps)return Uint8Array.fromHex(e);const t=e.length,n=t/2;if(t%2)throw new Error("hex string expected, got unpadded hex of length "+t);const r=new Uint8Array(n);for(let o=0,s=0;o<n;o++,s+=2){const i=eo(e.charCodeAt(s)),c=eo(e.charCodeAt(s+1));if(i===void 0||c===void 0){const a=e[s]+e[s+1];throw new Error('hex string expected, got non-hex character "'+a+'" at index '+s)}r[o]=i*16+c}return r}function Hu(e){if(typeof e!="string")throw new Error("string expected");return new Uint8Array(new TextEncoder().encode(e))}function on(e){return typeof e=="string"&&(e=Hu(e)),Ie(e),e}function Ee(...e){let t=0;for(let r=0;r<e.length;r++){const o=e[r];Ie(o),t+=o.length}const n=new Uint8Array(t);for(let r=0,o=0;r<e.length;r++){const s=e[r];n.set(s,o),o+=s.length}return n}class fr{}function xt(e){const t=r=>e().update(on(r)).digest(),n=e();return t.outputLen=n.outputLen,t.blockLen=n.blockLen,t.create=()=>e(),t}function lr(e=32){if(Ke&&typeof Ke.getRandomValues=="function")return Ke.getRandomValues(new Uint8Array(e));if(Ke&&typeof Ke.randomBytes=="function")return Uint8Array.from(Ke.randomBytes(e));throw new Error("crypto.getRandomValues must be defined")}function ju(e,t,n,r){if(typeof e.setBigUint64=="function")return e.setBigUint64(t,n,r);const o=BigInt(32),s=BigInt(4294967295),i=Number(n>>o&s),c=Number(n&s),a=r?4:0,d=r?0:4;e.setUint32(t+a,i,r),e.setUint32(t+d,c,r)}function Lu(e,t,n){return e&t^~e&n}function Fu(e,t,n){return e&t^e&n^t&n}class hr extends fr{constructor(t,n,r,o){super(),this.finished=!1,this.length=0,this.pos=0,this.destroyed=!1,this.blockLen=t,this.outputLen=n,this.padOffset=r,this.isLE=o,this.buffer=new Uint8Array(t),this.view=hn(this.buffer)}update(t){Ye(this),t=on(t),Ie(t);const{view:n,buffer:r,blockLen:o}=this,s=t.length;for(let i=0;i<s;){const c=Math.min(o-this.pos,s-i);if(c===o){const a=hn(t);for(;o<=s-i;i+=o)this.process(a,i);continue}r.set(t.subarray(i,i+c),this.pos),this.pos+=c,i+=c,this.pos===o&&(this.process(n,0),this.pos=0)}return this.length+=t.length,this.roundClean(),this}digestInto(t){Ye(this),Ms(t,this),this.finished=!0;const{buffer:n,view:r,blockLen:o,isLE:s}=this;let{pos:i}=this;n[i++]=128,De(this.buffer.subarray(i)),this.padOffset>o-i&&(this.process(r,0),i=0);for(let l=i;l<o;l++)n[l]=0;ju(r,o-8,BigInt(this.length*8),s),this.process(r,0);const c=hn(t),a=this.outputLen;if(a%4)throw new Error("_sha2: outputLen should be aligned to 32bit");const d=a/4,f=this.get();if(d>f.length)throw new Error("_sha2: outputLen bigger than state");for(let l=0;l<d;l++)c.setUint32(4*l,f[l],s)}digest(){const{buffer:t,outputLen:n}=this;this.digestInto(t);const r=t.slice(0,n);return this.destroy(),r}_cloneInto(t){t||(t=new this.constructor),t.set(...this.get());const{blockLen:n,buffer:r,length:o,finished:s,destroyed:i,pos:c}=this;return t.destroyed=i,t.finished=s,t.length=o,t.pos=c,o%n&&t.buffer.set(r),t}clone(){return this._cloneInto()}}const _e=Uint32Array.from([1779033703,3144134277,1013904242,2773480762,1359893119,2600822924,528734635,1541459225]),re=Uint32Array.from([3418070365,3238371032,1654270250,914150663,2438529370,812702999,355462360,4144912697,1731405415,4290775857,2394180231,1750603025,3675008525,1694076839,1203062813,3204075428]),oe=Uint32Array.from([1779033703,4089235720,3144134277,2227873595,1013904242,4271175723,2773480762,1595750129,1359893119,2917565137,2600822924,725511199,528734635,4215389547,1541459225,327033209]),$t=BigInt(2**32-1),to=BigInt(32);function Vu(e,t=!1){return t?{h:Number(e&$t),l:Number(e>>to&$t)}:{h:Number(e>>to&$t)|0,l:Number(e&$t)|0}}function Hs(e,t=!1){const n=e.length;let r=new Uint32Array(n),o=new Uint32Array(n);for(let s=0;s<n;s++){const{h:i,l:c}=Vu(e[s],t);[r[s],o[s]]=[i,c]}return[r,o]}const no=(e,t,n)=>e>>>n,ro=(e,t,n)=>e<<32-n|t>>>n,ze=(e,t,n)=>e>>>n|t<<32-n,qe=(e,t,n)=>e<<32-n|t>>>n,Rt=(e,t,n)=>e<<64-n|t>>>n-32,Ot=(e,t,n)=>e>>>n-32|t<<64-n,Ku=(e,t,n)=>e<<n|t>>>32-n,zu=(e,t,n)=>t<<n|e>>>32-n,qu=(e,t,n)=>t<<n-32|e>>>64-n,Ju=(e,t,n)=>e<<n-32|t>>>64-n;function Ae(e,t,n,r){const o=(t>>>0)+(r>>>0);return{h:e+n+(o/2**32|0)|0,l:o|0}}const Wu=(e,t,n)=>(e>>>0)+(t>>>0)+(n>>>0),Zu=(e,t,n,r)=>t+n+r+(e/2**32|0)|0,Gu=(e,t,n,r)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0),Yu=(e,t,n,r,o)=>t+n+r+o+(e/2**32|0)|0,Xu=(e,t,n,r,o)=>(e>>>0)+(t>>>0)+(n>>>0)+(r>>>0)+(o>>>0),Qu=(e,t,n,r,o,s)=>t+n+r+o+s+(e/2**32|0)|0,ef=Uint32Array.from([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]),Be=new Uint32Array(64);class tf extends hr{constructor(t=32){super(64,t,8,!1),this.A=_e[0]|0,this.B=_e[1]|0,this.C=_e[2]|0,this.D=_e[3]|0,this.E=_e[4]|0,this.F=_e[5]|0,this.G=_e[6]|0,this.H=_e[7]|0}get(){const{A:t,B:n,C:r,D:o,E:s,F:i,G:c,H:a}=this;return[t,n,r,o,s,i,c,a]}set(t,n,r,o,s,i,c,a){this.A=t|0,this.B=n|0,this.C=r|0,this.D=o|0,this.E=s|0,this.F=i|0,this.G=c|0,this.H=a|0}process(t,n){for(let l=0;l<16;l++,n+=4)Be[l]=t.getUint32(n,!1);for(let l=16;l<64;l++){const u=Be[l-15],b=Be[l-2],h=ye(u,7)^ye(u,18)^u>>>3,p=ye(b,17)^ye(b,19)^b>>>10;Be[l]=p+Be[l-7]+h+Be[l-16]|0}let{A:r,B:o,C:s,D:i,E:c,F:a,G:d,H:f}=this;for(let l=0;l<64;l++){const u=ye(c,6)^ye(c,11)^ye(c,25),b=f+u+Lu(c,a,d)+ef[l]+Be[l]|0,p=(ye(r,2)^ye(r,13)^ye(r,22))+Fu(r,o,s)|0;f=d,d=a,a=c,c=i+b|0,i=s,s=o,o=r,r=b+p|0}r=r+this.A|0,o=o+this.B|0,s=s+this.C|0,i=i+this.D|0,c=c+this.E|0,a=a+this.F|0,d=d+this.G|0,f=f+this.H|0,this.set(r,o,s,i,c,a,d,f)}roundClean(){De(Be)}destroy(){this.set(0,0,0,0,0,0,0,0),De(this.buffer)}}const js=Hs(["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(e=>BigInt(e))),nf=js[0],rf=js[1],$e=new Uint32Array(80),Re=new Uint32Array(80);class Ls extends hr{constructor(t=64){super(128,t,16,!1),this.Ah=oe[0]|0,this.Al=oe[1]|0,this.Bh=oe[2]|0,this.Bl=oe[3]|0,this.Ch=oe[4]|0,this.Cl=oe[5]|0,this.Dh=oe[6]|0,this.Dl=oe[7]|0,this.Eh=oe[8]|0,this.El=oe[9]|0,this.Fh=oe[10]|0,this.Fl=oe[11]|0,this.Gh=oe[12]|0,this.Gl=oe[13]|0,this.Hh=oe[14]|0,this.Hl=oe[15]|0}get(){const{Ah:t,Al:n,Bh:r,Bl:o,Ch:s,Cl:i,Dh:c,Dl:a,Eh:d,El:f,Fh:l,Fl:u,Gh:b,Gl:h,Hh:p,Hl:D}=this;return[t,n,r,o,s,i,c,a,d,f,l,u,b,h,p,D]}set(t,n,r,o,s,i,c,a,d,f,l,u,b,h,p,D){this.Ah=t|0,this.Al=n|0,this.Bh=r|0,this.Bl=o|0,this.Ch=s|0,this.Cl=i|0,this.Dh=c|0,this.Dl=a|0,this.Eh=d|0,this.El=f|0,this.Fh=l|0,this.Fl=u|0,this.Gh=b|0,this.Gl=h|0,this.Hh=p|0,this.Hl=D|0}process(t,n){for(let y=0;y<16;y++,n+=4)$e[y]=t.getUint32(n),Re[y]=t.getUint32(n+=4);for(let y=16;y<80;y++){const S=$e[y-15]|0,E=Re[y-15]|0,m=ze(S,E,1)^ze(S,E,8)^no(S,E,7),k=qe(S,E,1)^qe(S,E,8)^ro(S,E,7),A=$e[y-2]|0,T=Re[y-2]|0,O=ze(A,T,19)^Rt(A,T,61)^no(A,T,6),P=qe(A,T,19)^Ot(A,T,61)^ro(A,T,6),U=Gu(k,P,Re[y-7],Re[y-16]),I=Yu(U,m,O,$e[y-7],$e[y-16]);$e[y]=I|0,Re[y]=U|0}let{Ah:r,Al:o,Bh:s,Bl:i,Ch:c,Cl:a,Dh:d,Dl:f,Eh:l,El:u,Fh:b,Fl:h,Gh:p,Gl:D,Hh:w,Hl:g}=this;for(let y=0;y<80;y++){const S=ze(l,u,14)^ze(l,u,18)^Rt(l,u,41),E=qe(l,u,14)^qe(l,u,18)^Ot(l,u,41),m=l&b^~l&p,k=u&h^~u&D,A=Xu(g,E,k,rf[y],Re[y]),T=Qu(A,w,S,m,nf[y],$e[y]),O=A|0,P=ze(r,o,28)^Rt(r,o,34)^Rt(r,o,39),U=qe(r,o,28)^Ot(r,o,34)^Ot(r,o,39),I=r&s^r&c^s&c,x=o&i^o&a^i&a;w=p|0,g=D|0,p=b|0,D=h|0,b=l|0,h=u|0,{h:l,l:u}=Ae(d|0,f|0,T|0,O|0),d=c|0,f=a|0,c=s|0,a=i|0,s=r|0,i=o|0;const v=Wu(O,U,x);r=Zu(v,T,P,I),o=v|0}({h:r,l:o}=Ae(this.Ah|0,this.Al|0,r|0,o|0)),{h:s,l:i}=Ae(this.Bh|0,this.Bl|0,s|0,i|0),{h:c,l:a}=Ae(this.Ch|0,this.Cl|0,c|0,a|0),{h:d,l:f}=Ae(this.Dh|0,this.Dl|0,d|0,f|0),{h:l,l:u}=Ae(this.Eh|0,this.El|0,l|0,u|0),{h:b,l:h}=Ae(this.Fh|0,this.Fl|0,b|0,h|0),{h:p,l:D}=Ae(this.Gh|0,this.Gl|0,p|0,D|0),{h:w,l:g}=Ae(this.Hh|0,this.Hl|0,w|0,g|0),this.set(r,o,s,i,c,a,d,f,l,u,b,h,p,D,w,g)}roundClean(){De($e,Re)}destroy(){De(this.buffer),this.set(0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0)}}class of extends Ls{constructor(){super(48),this.Ah=re[0]|0,this.Al=re[1]|0,this.Bh=re[2]|0,this.Bl=re[3]|0,this.Ch=re[4]|0,this.Cl=re[5]|0,this.Dh=re[6]|0,this.Dl=re[7]|0,this.Eh=re[8]|0,this.El=re[9]|0,this.Fh=re[10]|0,this.Fl=re[11]|0,this.Gh=re[12]|0,this.Gl=re[13]|0,this.Hh=re[14]|0,this.Hl=re[15]|0}}const br=xt(()=>new tf),Fs=xt(()=>new Ls),sf=xt(()=>new of);const pr=BigInt(0),qn=BigInt(1);function Fe(e,t=""){if(typeof e!="boolean"){const n=t&&`"${t}"`;throw new Error(n+"expected boolean, got type="+typeof e)}return e}function we(e,t,n=""){const r=Dt(e),o=e?.length,s=t!==void 0;if(!r||s&&o!==t){const i=n&&`"${n}" `,c=s?` of length ${t}`:"",a=r?`length=${o}`:`type=${typeof e}`;throw new Error(i+"expected Uint8Array"+c+", got "+a)}return e}function ot(e){const t=e.toString(16);return t.length&1?"0"+t:t}function Vs(e){if(typeof e!="string")throw new Error("hex string expected, got "+typeof e);return e===""?pr:BigInt("0x"+e)}function sn(e){return Vs(je(e))}function ht(e){return Ie(e),Vs(je(Uint8Array.from(e).reverse()))}function wr(e,t){return lt(e.toString(16).padStart(t*2,"0"))}function Ks(e,t){return wr(e,t).reverse()}function af(e){return lt(ot(e))}function K(e,t,n){let r;if(typeof t=="string")try{r=lt(t)}catch(s){throw new Error(e+" must be hex string or Uint8Array, cause: "+s)}else if(Dt(t))r=Uint8Array.from(t);else throw new Error(e+" must be hex string or Uint8Array");const o=r.length;if(typeof n=="number"&&o!==n)throw new Error(e+" of length "+n+" expected, got "+o);return r}function oo(e){return Uint8Array.from(e)}const bn=e=>typeof e=="bigint"&&pr<=e;function cf(e,t,n){return bn(e)&&bn(t)&&bn(n)&&t<=e&&e<n}function Jn(e,t,n,r){if(!cf(t,n,r))throw new Error("expected valid "+e+": "+n+" <= n < "+r+", got "+t)}function zs(e){let t;for(t=0;e>pr;e>>=qn,t+=1);return t}const vt=e=>(qn<<BigInt(e))-qn;function df(e,t,n){if(typeof e!="number"||e<2)throw new Error("hashLen must be a number");if(typeof t!="number"||t<2)throw new Error("qByteLen must be a number");if(typeof n!="function")throw new Error("hmacFn must be a function");const r=b=>new Uint8Array(b),o=b=>Uint8Array.of(b);let s=r(e),i=r(e),c=0;const a=()=>{s.fill(1),i.fill(0),c=0},d=(...b)=>n(i,s,...b),f=(b=r(0))=>{i=d(o(0),b),s=d(),b.length!==0&&(i=d(o(1),b),s=d())},l=()=>{if(c++>=1e3)throw new Error("drbg: tried 1000 values");let b=0;const h=[];for(;b<t;){s=d();const p=s.slice();h.push(p),b+=s.length}return Ee(...h)};return(b,h)=>{a(),f(b);let p;for(;!(p=h(l()));)f();return a(),p}}function St(e,t,n={}){if(!e||typeof e!="object")throw new Error("expected valid options object");function r(o,s,i){const c=e[o];if(i&&c===void 0)return;const a=typeof c;if(a!==s||c===null)throw new Error(`param "${o}" is invalid: expected ${s}, got ${a}`)}Object.entries(t).forEach(([o,s])=>r(o,s,!1)),Object.entries(n).forEach(([o,s])=>r(o,s,!0))}function zt(e){const t=new WeakMap;return(n,...r)=>{const o=t.get(n);if(o!==void 0)return o;const s=e(n,...r);return t.set(n,s),s}}const de=BigInt(0),Q=BigInt(1),Me=BigInt(2),qs=BigInt(3),Js=BigInt(4),Ws=BigInt(5),uf=BigInt(7),Zs=BigInt(8),ff=BigInt(9),Gs=BigInt(16);function G(e,t){const n=e%t;return n>=de?n:t+n}function Z(e,t,n){let r=e;for(;t-- >de;)r*=r,r%=n;return r}function so(e,t){if(e===de)throw new Error("invert: expected non-zero number");if(t<=de)throw new Error("invert: expected positive modulus, got "+t);let n=G(e,t),r=t,o=de,s=Q;for(;n!==de;){const c=r/n,a=r%n,d=o-s*c;r=n,n=a,o=s,s=d}if(r!==Q)throw new Error("invert: does not exist");return G(o,t)}function yr(e,t,n){if(!e.eql(e.sqr(t),n))throw new Error("Cannot find square root")}function Ys(e,t){const n=(e.ORDER+Q)/Js,r=e.pow(t,n);return yr(e,r,t),r}function lf(e,t){const n=(e.ORDER-Ws)/Zs,r=e.mul(t,Me),o=e.pow(r,n),s=e.mul(t,o),i=e.mul(e.mul(s,Me),o),c=e.mul(s,e.sub(i,e.ONE));return yr(e,c,t),c}function hf(e){const t=ve(e),n=Xs(e),r=n(t,t.neg(t.ONE)),o=n(t,r),s=n(t,t.neg(r)),i=(e+uf)/Gs;return(c,a)=>{let d=c.pow(a,i),f=c.mul(d,r);const l=c.mul(d,o),u=c.mul(d,s),b=c.eql(c.sqr(f),a),h=c.eql(c.sqr(l),a);d=c.cmov(d,f,b),f=c.cmov(u,l,h);const p=c.eql(c.sqr(f),a),D=c.cmov(d,f,p);return yr(c,D,a),D}}function Xs(e){if(e<qs)throw new Error("sqrt is not defined for small field");let t=e-Q,n=0;for(;t%Me===de;)t/=Me,n++;let r=Me;const o=ve(e);for(;io(o,r)===1;)if(r++>1e3)throw new Error("Cannot find square root: probably non-prime P");if(n===1)return Ys;let s=o.pow(r,t);const i=(t+Q)/Me;return function(a,d){if(a.is0(d))return d;if(io(a,d)!==1)throw new Error("Cannot find square root");let f=n,l=a.mul(a.ONE,s),u=a.pow(d,t),b=a.pow(d,i);for(;!a.eql(u,a.ONE);){if(a.is0(u))return a.ZERO;let h=1,p=a.sqr(u);for(;!a.eql(p,a.ONE);)if(h++,p=a.sqr(p),h===f)throw new Error("Cannot find square root");const D=Q<<BigInt(f-h-1),w=a.pow(l,D);f=h,l=a.sqr(w),u=a.mul(u,l),b=a.mul(b,w)}return b}}function bf(e){return e%Js===qs?Ys:e%Zs===Ws?lf:e%Gs===ff?hf(e):Xs(e)}const pf=(e,t)=>(G(e,t)&Q)===Q,wf=["create","isValid","is0","neg","inv","sqrt","sqr","eql","add","sub","mul","pow","div","addN","subN","mulN","sqrN"];function yf(e){const t={ORDER:"bigint",MASK:"bigint",BYTES:"number",BITS:"number"},n=wf.reduce((r,o)=>(r[o]="function",r),t);return St(e,n),e}function gf(e,t,n){if(n<de)throw new Error("invalid exponent, negatives unsupported");if(n===de)return e.ONE;if(n===Q)return t;let r=e.ONE,o=t;for(;n>de;)n&Q&&(r=e.mul(r,o)),o=e.sqr(o),n>>=Q;return r}function Qs(e,t,n=!1){const r=new Array(t.length).fill(n?e.ZERO:void 0),o=t.reduce((i,c,a)=>e.is0(c)?i:(r[a]=i,e.mul(i,c)),e.ONE),s=e.inv(o);return t.reduceRight((i,c,a)=>e.is0(c)?i:(r[a]=e.mul(i,r[a]),e.mul(i,c)),s),r}function io(e,t){const n=(e.ORDER-Q)/Me,r=e.pow(t,n),o=e.eql(r,e.ONE),s=e.eql(r,e.ZERO),i=e.eql(r,e.neg(e.ONE));if(!o&&!s&&!i)throw new Error("invalid Legendre symbol result");return o?1:s?0:-1}function ei(e,t){t!==void 0&&ft(t);const n=t!==void 0?t:e.toString(2).length,r=Math.ceil(n/8);return{nBitLength:n,nByteLength:r}}function ve(e,t,n=!1,r={}){if(e<=de)throw new Error("invalid field: expected ORDER > 0, got "+e);let o,s,i=!1,c;if(typeof t=="object"&&t!=null){if(r.sqrt||n)throw new Error("cannot specify opts in two arguments");const u=t;u.BITS&&(o=u.BITS),u.sqrt&&(s=u.sqrt),typeof u.isLE=="boolean"&&(n=u.isLE),typeof u.modFromBytes=="boolean"&&(i=u.modFromBytes),c=u.allowedLengths}else typeof t=="number"&&(o=t),r.sqrt&&(s=r.sqrt);const{nBitLength:a,nByteLength:d}=ei(e,o);if(d>2048)throw new Error("invalid field: expected ORDER of <= 2048 bytes");let f;const l=Object.freeze({ORDER:e,isLE:n,BITS:a,BYTES:d,MASK:vt(a),ZERO:de,ONE:Q,allowedLengths:c,create:u=>G(u,e),isValid:u=>{if(typeof u!="bigint")throw new Error("invalid field element: expected bigint, got "+typeof u);return de<=u&&u<e},is0:u=>u===de,isValidNot0:u=>!l.is0(u)&&l.isValid(u),isOdd:u=>(u&Q)===Q,neg:u=>G(-u,e),eql:(u,b)=>u===b,sqr:u=>G(u*u,e),add:(u,b)=>G(u+b,e),sub:(u,b)=>G(u-b,e),mul:(u,b)=>G(u*b,e),pow:(u,b)=>gf(l,u,b),div:(u,b)=>G(u*so(b,e),e),sqrN:u=>u*u,addN:(u,b)=>u+b,subN:(u,b)=>u-b,mulN:(u,b)=>u*b,inv:u=>so(u,e),sqrt:s||(u=>(f||(f=bf(e)),f(l,u))),toBytes:u=>n?Ks(u,d):wr(u,d),fromBytes:(u,b=!0)=>{if(c){if(!c.includes(u.length)||u.length>d)throw new Error("Field.fromBytes: expected "+c+" bytes, got "+u.length);const p=new Uint8Array(d);p.set(u,n?0:p.length-u.length),u=p}if(u.length!==d)throw new Error("Field.fromBytes: expected "+d+" bytes, got "+u.length);let h=n?ht(u):sn(u);if(i&&(h=G(h,e)),!b&&!l.isValid(h))throw new Error("invalid field element: outside of range 0..ORDER");return h},invertBatch:u=>Qs(l,u),cmov:(u,b,h)=>h?b:u});return Object.freeze(l)}function ti(e){if(typeof e!="bigint")throw new Error("field order must be bigint");const t=e.toString(2).length;return Math.ceil(t/8)}function ni(e){const t=ti(e);return t+Math.ceil(t/2)}function mf(e,t,n=!1){const r=e.length,o=ti(t),s=ni(t);if(r<16||r<s||r>1024)throw new Error("expected "+s+"-1024 bytes of input, got "+r);const i=n?ht(e):sn(e),c=G(i,t-Q)+Q;return n?Ks(c,o):wr(c,o)}const Xe=BigInt(0),Pe=BigInt(1);function qt(e,t){const n=t.negate();return e?n:t}function He(e,t){const n=Qs(e.Fp,t.map(r=>r.Z));return t.map((r,o)=>e.fromAffine(r.toAffine(n[o])))}function ri(e,t){if(!Number.isSafeInteger(e)||e<=0||e>t)throw new Error("invalid window size, expected [1.."+t+"], got W="+e)}function pn(e,t){ri(e,t);const n=Math.ceil(t/e)+1,r=2**(e-1),o=2**e,s=vt(e),i=BigInt(e);return{windows:n,windowSize:r,mask:s,maxNumber:o,shiftBy:i}}function ao(e,t,n){const{windowSize:r,mask:o,maxNumber:s,shiftBy:i}=n;let c=Number(e&o),a=e>>i;c>r&&(c-=s,a+=Pe);const d=t*r,f=d+Math.abs(c)-1,l=c===0,u=c<0,b=t%2!==0;return{nextN:a,offset:f,isZero:l,isNeg:u,isNegF:b,offsetF:d}}function Ef(e,t){if(!Array.isArray(e))throw new Error("array expected");e.forEach((n,r)=>{if(!(n instanceof t))throw new Error("invalid point at index "+r)})}function Df(e,t){if(!Array.isArray(e))throw new Error("array of scalars expected");e.forEach((n,r)=>{if(!t.isValid(n))throw new Error("invalid scalar at index "+r)})}const wn=new WeakMap,oi=new WeakMap;function yn(e){return oi.get(e)||1}function co(e){if(e!==Xe)throw new Error("invalid wNAF")}class si{constructor(t,n){this.BASE=t.BASE,this.ZERO=t.ZERO,this.Fn=t.Fn,this.bits=n}_unsafeLadder(t,n,r=this.ZERO){let o=t;for(;n>Xe;)n&Pe&&(r=r.add(o)),o=o.double(),n>>=Pe;return r}precomputeWindow(t,n){const{windows:r,windowSize:o}=pn(n,this.bits),s=[];let i=t,c=i;for(let a=0;a<r;a++){c=i,s.push(c);for(let d=1;d<o;d++)c=c.add(i),s.push(c);i=c.double()}return s}wNAF(t,n,r){if(!this.Fn.isValid(r))throw new Error("invalid scalar");let o=this.ZERO,s=this.BASE;const i=pn(t,this.bits);for(let c=0;c<i.windows;c++){const{nextN:a,offset:d,isZero:f,isNeg:l,isNegF:u,offsetF:b}=ao(r,c,i);r=a,f?s=s.add(qt(u,n[b])):o=o.add(qt(l,n[d]))}return co(r),{p:o,f:s}}wNAFUnsafe(t,n,r,o=this.ZERO){const s=pn(t,this.bits);for(let i=0;i<s.windows&&r!==Xe;i++){const{nextN:c,offset:a,isZero:d,isNeg:f}=ao(r,i,s);if(r=c,!d){const l=n[a];o=o.add(f?l.negate():l)}}return co(r),o}getPrecomputes(t,n,r){let o=wn.get(n);return o||(o=this.precomputeWindow(n,t),t!==1&&(typeof r=="function"&&(o=r(o)),wn.set(n,o))),o}cached(t,n,r){const o=yn(t);return this.wNAF(o,this.getPrecomputes(o,t,r),n)}unsafe(t,n,r,o){const s=yn(t);return s===1?this._unsafeLadder(t,n,o):this.wNAFUnsafe(s,this.getPrecomputes(s,t,r),n,o)}createCache(t,n){ri(n,this.bits),oi.set(t,n),wn.delete(t)}hasCache(t){return yn(t)!==1}}function xf(e,t,n,r){let o=t,s=e.ZERO,i=e.ZERO;for(;n>Xe||r>Xe;)n&Pe&&(s=s.add(o)),r&Pe&&(i=i.add(o)),o=o.double(),n>>=Pe,r>>=Pe;return{p1:s,p2:i}}function ii(e,t,n,r){Ef(n,e),Df(r,t);const o=n.length,s=r.length;if(o!==s)throw new Error("arrays of points and scalars must have equal length");const i=e.ZERO,c=zs(BigInt(o));let a=1;c>12?a=c-3:c>4?a=c-2:c>0&&(a=2);const d=vt(a),f=new Array(Number(d)+1).fill(i),l=Math.floor((t.BITS-1)/a)*a;let u=i;for(let b=l;b>=0;b-=a){f.fill(i);for(let p=0;p<s;p++){const D=r[p],w=Number(D>>BigInt(b)&d);f[w]=f[w].add(n[p])}let h=i;for(let p=f.length-1,D=i;p>0;p--)D=D.add(f[p]),h=h.add(D);if(u=u.add(h),b!==0)for(let p=0;p<a;p++)u=u.double()}return u}function uo(e,t,n){if(t){if(t.ORDER!==e)throw new Error("Field.ORDER must match order: Fp == p, Fn == n");return yf(t),t}else return ve(e,{isLE:n})}function ai(e,t,n={},r){if(r===void 0&&(r=e==="edwards"),!t||typeof t!="object")throw new Error(`expected valid ${e} CURVE object`);for(const a of["p","n","h"]){const d=t[a];if(!(typeof d=="bigint"&&d>Xe))throw new Error(`CURVE.${a} must be positive bigint`)}const o=uo(t.p,n.Fp,r),s=uo(t.n,n.Fn,r),c=["Gx","Gy","a",e==="weierstrass"?"b":"d"];for(const a of c)if(!o.isValid(t[a]))throw new Error(`CURVE.${a} must be valid field element of CURVE.Fp`);return t=Object.freeze(Object.assign({},t)),{CURVE:t,Fp:o,Fn:s}}const Oe=BigInt(0),X=BigInt(1),gn=BigInt(2),vf=BigInt(8);function Sf(e,t,n,r){const o=e.sqr(n),s=e.sqr(r),i=e.add(e.mul(t.a,o),s),c=e.add(e.ONE,e.mul(t.d,e.mul(o,s)));return e.eql(i,c)}function Af(e,t={}){const n=ai("edwards",e,t,t.FpFnLE),{Fp:r,Fn:o}=n;let s=n.CURVE;const{h:i}=s;St(t,{},{uvRatio:"function"});const c=gn<<BigInt(o.BYTES*8)-X,a=D=>r.create(D),d=t.uvRatio||((D,w)=>{try{return{isValid:!0,value:r.sqrt(r.div(D,w))}}catch{return{isValid:!1,value:Oe}}});if(!Sf(r,s,s.Gx,s.Gy))throw new Error("bad curve params: generator point");function f(D,w,g=!1){const y=g?X:Oe;return Jn("coordinate "+D,w,y,c),w}function l(D){if(!(D instanceof h))throw new Error("ExtendedPoint expected")}const u=zt((D,w)=>{const{X:g,Y:y,Z:S}=D,E=D.is0();w==null&&(w=E?vf:r.inv(S));const m=a(g*w),k=a(y*w),A=r.mul(S,w);if(E)return{x:Oe,y:X};if(A!==X)throw new Error("invZ was invalid");return{x:m,y:k}}),b=zt(D=>{const{a:w,d:g}=s;if(D.is0())throw new Error("bad point: ZERO");const{X:y,Y:S,Z:E,T:m}=D,k=a(y*y),A=a(S*S),T=a(E*E),O=a(T*T),P=a(k*w),U=a(T*a(P+A)),I=a(O+a(g*a(k*A)));if(U!==I)throw new Error("bad point: equation left != right (1)");const x=a(y*S),v=a(E*m);if(x!==v)throw new Error("bad point: equation left != right (2)");return!0});class h{constructor(w,g,y,S){this.X=f("x",w),this.Y=f("y",g),this.Z=f("z",y,!0),this.T=f("t",S),Object.freeze(this)}static CURVE(){return s}static fromAffine(w){if(w instanceof h)throw new Error("extended point not allowed");const{x:g,y}=w||{};return f("x",g),f("y",y),new h(g,y,X,a(g*y))}static fromBytes(w,g=!1){const y=r.BYTES,{a:S,d:E}=s;w=oo(we(w,y,"point")),Fe(g,"zip215");const m=oo(w),k=w[y-1];m[y-1]=k&-129;const A=ht(m),T=g?c:r.ORDER;Jn("point.y",A,Oe,T);const O=a(A*A),P=a(O-X),U=a(E*O-S);let{isValid:I,value:x}=d(P,U);if(!I)throw new Error("bad point: invalid y coordinate");const v=(x&X)===X,C=(k&128)!==0;if(!g&&x===Oe&&C)throw new Error("bad point: x=0 and x_0=1");return C!==v&&(x=a(-x)),h.fromAffine({x,y:A})}static fromHex(w,g=!1){return h.fromBytes(K("point",w),g)}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(w=8,g=!0){return p.createCache(this,w),g||this.multiply(gn),this}assertValidity(){b(this)}equals(w){l(w);const{X:g,Y:y,Z:S}=this,{X:E,Y:m,Z:k}=w,A=a(g*k),T=a(E*S),O=a(y*k),P=a(m*S);return A===T&&O===P}is0(){return this.equals(h.ZERO)}negate(){return new h(a(-this.X),this.Y,this.Z,a(-this.T))}double(){const{a:w}=s,{X:g,Y:y,Z:S}=this,E=a(g*g),m=a(y*y),k=a(gn*a(S*S)),A=a(w*E),T=g+y,O=a(a(T*T)-E-m),P=A+m,U=P-k,I=A-m,x=a(O*U),v=a(P*I),C=a(O*I),B=a(U*P);return new h(x,v,B,C)}add(w){l(w);const{a:g,d:y}=s,{X:S,Y:E,Z:m,T:k}=this,{X:A,Y:T,Z:O,T:P}=w,U=a(S*A),I=a(E*T),x=a(k*y*P),v=a(m*O),C=a((S+E)*(A+T)-U-I),B=v-x,N=v+x,$=a(I-g*U),R=a(C*B),M=a(N*$),H=a(C*$),q=a(B*N);return new h(R,M,q,H)}subtract(w){return this.add(w.negate())}multiply(w){if(!o.isValidNot0(w))throw new Error("invalid scalar: expected 1 <= sc < curve.n");const{p:g,f:y}=p.cached(this,w,S=>He(h,S));return He(h,[g,y])[0]}multiplyUnsafe(w,g=h.ZERO){if(!o.isValid(w))throw new Error("invalid scalar: expected 0 <= sc < curve.n");return w===Oe?h.ZERO:this.is0()||w===X?this:p.unsafe(this,w,y=>He(h,y),g)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}isTorsionFree(){return p.unsafe(this,s.n).is0()}toAffine(w){return u(this,w)}clearCofactor(){return i===X?this:this.multiplyUnsafe(i)}toBytes(){const{x:w,y:g}=this.toAffine(),y=r.toBytes(g);return y[y.length-1]|=w&X?128:0,y}toHex(){return je(this.toBytes())}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get ex(){return this.X}get ey(){return this.Y}get ez(){return this.Z}get et(){return this.T}static normalizeZ(w){return He(h,w)}static msm(w,g){return ii(h,o,w,g)}_setWindowSize(w){this.precompute(w)}toRawBytes(){return this.toBytes()}}h.BASE=new h(s.Gx,s.Gy,X,a(s.Gx*s.Gy)),h.ZERO=new h(Oe,X,X,Oe),h.Fp=r,h.Fn=o;const p=new si(h,o.BITS);return h.BASE.precompute(8),h}function kf(e,t,n={}){if(typeof t!="function")throw new Error('"hash" function param is required');St(n,{},{adjustScalarBytes:"function",randomBytes:"function",domain:"function",prehash:"function",mapToCurve:"function"});const{prehash:r}=n,{BASE:o,Fp:s,Fn:i}=e,c=n.randomBytes||lr,a=n.adjustScalarBytes||(T=>T),d=n.domain||((T,O,P)=>{if(Fe(P,"phflag"),O.length||P)throw new Error("Contexts/pre-hash are not supported");return T});function f(T){return i.create(ht(T))}function l(T){const O=y.secretKey;T=K("private key",T,O);const P=K("hashed private key",t(T),2*O),U=a(P.slice(0,O)),I=P.slice(O,2*O),x=f(U);return{head:U,prefix:I,scalar:x}}function u(T){const{head:O,prefix:P,scalar:U}=l(T),I=o.multiply(U),x=I.toBytes();return{head:O,prefix:P,scalar:U,point:I,pointBytes:x}}function b(T){return u(T).pointBytes}function h(T=Uint8Array.of(),...O){const P=Ee(...O);return f(t(d(P,K("context",T),!!r)))}function p(T,O,P={}){T=K("message",T),r&&(T=r(T));const{prefix:U,scalar:I,pointBytes:x}=u(O),v=h(P.context,U,T),C=o.multiply(v).toBytes(),B=h(P.context,C,x,T),N=i.create(v+B*I);if(!i.isValid(N))throw new Error("sign failed: invalid s");const $=Ee(C,i.toBytes(N));return we($,y.signature,"result")}const D={zip215:!0};function w(T,O,P,U=D){const{context:I,zip215:x}=U,v=y.signature;T=K("signature",T,v),O=K("message",O),P=K("publicKey",P,y.publicKey),x!==void 0&&Fe(x,"zip215"),r&&(O=r(O));const C=v/2,B=T.subarray(0,C),N=ht(T.subarray(C,v));let $,R,M;try{$=e.fromBytes(P,x),R=e.fromBytes(B,x),M=o.multiplyUnsafe(N)}catch{return!1}if(!x&&$.isSmallOrder())return!1;const H=h(I,R.toBytes(),$.toBytes(),O);return R.add($.multiplyUnsafe(H)).subtract(M).clearCofactor().is0()}const g=s.BYTES,y={secretKey:g,publicKey:g,signature:2*g,seed:g};function S(T=c(y.seed)){return we(T,y.seed,"seed")}function E(T){const O=A.randomSecretKey(T);return{secretKey:O,publicKey:b(O)}}function m(T){return Dt(T)&&T.length===i.BYTES}function k(T,O){try{return!!e.fromBytes(T,O)}catch{return!1}}const A={getExtendedPublicKey:u,randomSecretKey:S,isValidSecretKey:m,isValidPublicKey:k,toMontgomery(T){const{y:O}=e.fromBytes(T),P=y.publicKey,U=P===32;if(!U&&P!==57)throw new Error("only defined for 25519 and 448");const I=U?s.div(X+O,X-O):s.div(O-X,O+X);return s.toBytes(I)},toMontgomerySecret(T){const O=y.secretKey;we(T,O);const P=t(T.subarray(0,O));return a(P).subarray(0,O)},randomPrivateKey:S,precompute(T=8,O=e.BASE){return O.precompute(T,!1)}};return Object.freeze({keygen:E,getPublicKey:b,sign:p,verify:w,utils:A,Point:e,lengths:y})}function Tf(e){const t={a:e.a,d:e.d,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp,r=ve(t.n,e.nBitLength,!0),o={Fp:n,Fn:r,uvRatio:e.uvRatio},s={randomBytes:e.randomBytes,adjustScalarBytes:e.adjustScalarBytes,domain:e.domain,prehash:e.prehash,mapToCurve:e.mapToCurve};return{CURVE:t,curveOpts:o,hash:e.hash,eddsaOpts:s}}function If(e,t){const n=t.Point;return Object.assign({},t,{ExtendedPoint:n,CURVE:e,nBitLength:n.Fn.BITS,nByteLength:n.Fn.BYTES})}function Cf(e){const{CURVE:t,curveOpts:n,hash:r,eddsaOpts:o}=Tf(e),s=Af(t,n),i=kf(s,r,o);return If(e,i)}const _f=BigInt(1),fo=BigInt(2);BigInt(3);const Bf=BigInt(5),$f=BigInt(8),gr=BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffed"),ci={p:gr,n:BigInt("0x1000000000000000000000000000000014def9dea2f79cd65812631a5cf5d3ed"),h:$f,a:BigInt("0x7fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffec"),d:BigInt("0x52036cee2b6ffe738cc740797779e89800700a4d4141d8ab75eb4dca135978a3"),Gx:BigInt("0x216936d3cd6e53fec0a4e231fdd6dc5c692cc7609525a7b2c9562d608f25d51a"),Gy:BigInt("0x6666666666666666666666666666666666666666666666666666666666666658")};function Rf(e){const t=BigInt(10),n=BigInt(20),r=BigInt(40),o=BigInt(80),s=gr,c=e*e%s*e%s,a=Z(c,fo,s)*c%s,d=Z(a,_f,s)*e%s,f=Z(d,Bf,s)*d%s,l=Z(f,t,s)*f%s,u=Z(l,n,s)*l%s,b=Z(u,r,s)*u%s,h=Z(b,o,s)*b%s,p=Z(h,o,s)*b%s,D=Z(p,t,s)*f%s;return{pow_p_5_8:Z(D,fo,s)*e%s,b2:c}}function Of(e){return e[0]&=248,e[31]&=127,e[31]|=64,e}const lo=BigInt("19681161376707505956807079304988542015446066515923890162744021073123829784752");function Uf(e,t){const n=gr,r=G(t*t*t,n),o=G(r*r*t,n),s=Rf(e*o).pow_p_5_8;let i=G(e*r*s,n);const c=G(t*i*i,n),a=i,d=G(i*lo,n),f=c===e,l=c===G(-e,n),u=c===G(-e*lo,n);return f&&(i=a),(l||u)&&(i=d),pf(i,n)&&(i=G(-i,n)),{isValid:f||l,value:i}}const Nf=ve(ci.p,{isLE:!0}),Mf={...ci,Fp:Nf,hash:Fs,adjustScalarBytes:Of,uvRatio:Uf},di=Cf(Mf);function Pf(e){return di.utils.toMontgomery(K("pub",e))}var Ut={exports:{}},mn,ho;function Hf(){if(ho)return mn;ho=1;function e(t){if(t.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<t.length;o++){var s=t.charAt(o),i=s.charCodeAt(0);if(n[i]!==255)throw new TypeError(s+" is ambiguous");n[i]=o}var c=t.length,a=t.charAt(0),d=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var p=0,D=0,w=0,g=h.length;w!==g&&h[w]===0;)w++,p++;for(var y=(g-w)*f+1>>>0,S=new Uint8Array(y);w!==g;){for(var E=h[w],m=0,k=y-1;(E!==0||m<D)&&k!==-1;k--,m++)E+=256*S[k]>>>0,S[k]=E%c>>>0,E=E/c>>>0;if(E!==0)throw new Error("Non-zero carry");D=m,w++}for(var A=y-D;A!==y&&S[A]===0;)A++;for(var T=a.repeat(p);A<y;++A)T+=t.charAt(S[A]);return T}function u(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var p=0;if(h[p]!==" "){for(var D=0,w=0;h[p]===a;)D++,p++;for(var g=(h.length-p)*d+1>>>0,y=new Uint8Array(g);h[p];){var S=n[h.charCodeAt(p)];if(S===255)return;for(var E=0,m=g-1;(S!==0||E<w)&&m!==-1;m--,E++)S+=c*y[m]>>>0,y[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=E,p++}if(h[p]!==" "){for(var k=g-w;k!==g&&y[k]===0;)k++;for(var A=new Uint8Array(D+(g-k)),T=D;k!==g;)A[T++]=y[k++];return A}}}function b(h){var p=u(h);if(p)return p;throw new Error("Non-base"+c+" character")}return{encode:l,decodeUnsafe:u,decode:b}}return mn=e,mn}var En,bo;function mr(){if(bo)return En;bo=1;const e=new TextDecoder,t=s=>e.decode(s),n=new TextEncoder,r=s=>n.encode(s);function o(s,i){const c=new Uint8Array(i);let a=0;for(const d of s)c.set(d,a),a+=d.length;return c}return En={decodeText:t,encodeText:r,concat:o},En}var Dn,po;function jf(){if(po)return Dn;po=1;const{encodeText:e}=mr();class t{constructor(r,o,s,i){this.name=r,this.code=o,this.codeBuf=e(this.code),this.alphabet=i,this.codec=s(i)}encode(r){return this.codec.encode(r)}decode(r){for(const o of r)if(this.alphabet&&this.alphabet.indexOf(o)<0)throw new Error(`invalid character '${o}' in '${r}'`);return this.codec.decode(r)}}return Dn=t,Dn}var xn,wo;function Lf(){if(wo)return xn;wo=1;const e=(r,o,s)=>{const i={};for(let u=0;u<o.length;++u)i[o[u]]=u;let c=r.length;for(;r[c-1]==="=";)--c;const a=new Uint8Array(c*s/8|0);let d=0,f=0,l=0;for(let u=0;u<c;++u){const b=i[r[u]];if(b===void 0)throw new SyntaxError("Invalid character "+r[u]);f=f<<s|b,d+=s,d>=8&&(d-=8,a[l++]=255&f>>d)}if(d>=s||255&f<<8-d)throw new SyntaxError("Unexpected end of data");return a},t=(r,o,s)=>{const i=o[o.length-1]==="=",c=(1<<s)-1;let a="",d=0,f=0;for(let l=0;l<r.length;++l)for(f=f<<8|r[l],d+=8;d>s;)d-=s,a+=o[c&f>>d];if(d&&(a+=o[c&f<<s-d]),i)for(;a.length*s&7;)a+="=";return a};return xn={rfc4648:r=>o=>({encode(s){return t(s,o,r)},decode(s){return e(s,o,r)}})},xn}var vn,yo;function Ff(){if(yo)return vn;yo=1;const e=Hf(),t=jf(),{rfc4648:n}=Lf(),{decodeText:r,encodeText:o}=mr(),i=[["identity","\0",()=>({encode:r,decode:o}),""],["base2","0",n(1),"01"],["base8","7",n(3),"01234567"],["base10","9",e,"0123456789"],["base16","f",n(4),"0123456789abcdef"],["base16upper","F",n(4),"0123456789ABCDEF"],["base32hex","v",n(5),"0123456789abcdefghijklmnopqrstuv"],["base32hexupper","V",n(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV"],["base32hexpad","t",n(5),"0123456789abcdefghijklmnopqrstuv="],["base32hexpadupper","T",n(5),"0123456789ABCDEFGHIJKLMNOPQRSTUV="],["base32","b",n(5),"abcdefghijklmnopqrstuvwxyz234567"],["base32upper","B",n(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"],["base32pad","c",n(5),"abcdefghijklmnopqrstuvwxyz234567="],["base32padupper","C",n(5),"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="],["base32z","h",n(5),"ybndrfg8ejkmcpqxot1uwisza345h769"],["base36","k",e,"0123456789abcdefghijklmnopqrstuvwxyz"],["base36upper","K",e,"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"],["base58btc","z",e,"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"],["base58flickr","Z",e,"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"],["base64","m",n(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"],["base64pad","M",n(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="],["base64url","u",n(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"],["base64urlpad","U",n(6),"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="]],c=i.reduce((d,f)=>(d[f[0]]=new t(f[0],f[1],f[2],f[3]),d),{}),a=i.reduce((d,f)=>(d[f[1]]=c[f[0]],d),{});return vn={names:c,codes:a},vn}var go;function Vf(){return go||(go=1,(function(e,t){const n=Ff(),{encodeText:r,decodeText:o,concat:s}=mr();function i(p,D){if(!D)throw new Error("requires an encoded Uint8Array");const{name:w,codeBuf:g}=l(p);return f(w,D),s([g,D],g.length+D.length)}function c(p,D){const w=l(p),g=r(w.encode(D));return s([w.codeBuf,g],w.codeBuf.length+g.length)}function a(p){p instanceof Uint8Array&&(p=o(p));const D=p[0];return["f","F","v","V","t","T","b","B","c","C","h","k","K"].includes(D)&&(p=p.toLowerCase()),l(p[0]).decode(p.substring(1))}function d(p){if(p instanceof Uint8Array&&(p=o(p)),Object.prototype.toString.call(p)!=="[object String]")return!1;try{return l(p[0]).name}catch{return!1}}function f(p,D){l(p).decode(o(D))}function l(p){if(Object.prototype.hasOwnProperty.call(n.names,p))return n.names[p];if(Object.prototype.hasOwnProperty.call(n.codes,p))return n.codes[p];throw new Error(`Unsupported encoding: ${p}`)}function u(p){return p instanceof Uint8Array&&(p=o(p)),l(p[0])}t=e.exports=i,t.encode=c,t.decode=a,t.isEncoded=d,t.encoding=l,t.encodingFromData=u;const b=Object.freeze(n.names),h=Object.freeze(n.codes);t.names=b,t.codes=h})(Ut,Ut.exports)),Ut.exports}var Kf=Vf();class ui extends fr{constructor(t,n){super(),this.finished=!1,this.destroyed=!1,Ns(t);const r=on(n);if(this.iHash=t.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 o=this.blockLen,s=new Uint8Array(o);s.set(r.length>o?t.create().update(r).digest():r);for(let i=0;i<s.length;i++)s[i]^=54;this.iHash.update(s),this.oHash=t.create();for(let i=0;i<s.length;i++)s[i]^=106;this.oHash.update(s),De(s)}update(t){return Ye(this),this.iHash.update(t),this}digestInto(t){Ye(this),Ie(t,this.outputLen),this.finished=!0,this.iHash.digestInto(t),this.oHash.update(t),this.oHash.digestInto(t),this.destroy()}digest(){const t=new Uint8Array(this.oHash.outputLen);return this.digestInto(t),t}_cloneInto(t){t||(t=Object.create(Object.getPrototypeOf(this),{}));const{oHash:n,iHash:r,finished:o,destroyed:s,blockLen:i,outputLen:c}=this;return t=t,t.finished=o,t.destroyed=s,t.blockLen=i,t.outputLen=c,t.oHash=n._cloneInto(t.oHash),t.iHash=r._cloneInto(t.iHash),t}clone(){return this._cloneInto()}destroy(){this.destroyed=!0,this.oHash.destroy(),this.iHash.destroy()}}const fi=(e,t,n)=>new ui(e,t).update(n).digest();fi.create=(e,t)=>new ui(e,t);const mo=(e,t)=>(e+(e>=0?t:-t)/li)/t;function zf(e,t,n){const[[r,o],[s,i]]=t,c=mo(i*e,n),a=mo(-o*e,n);let d=e-c*r-a*s,f=-c*o-a*i;const l=d<Te,u=f<Te;l&&(d=-d),u&&(f=-f);const b=vt(Math.ceil(zs(n)/2))+Ge;if(d<Te||d>=b||f<Te||f>=b)throw new Error("splitScalar (endomorphism): failed, k="+e);return{k1neg:l,k1:d,k2neg:u,k2:f}}function Wn(e){if(!["compact","recovered","der"].includes(e))throw new Error('Signature format must be "compact", "recovered", or "der"');return e}function Sn(e,t){const n={};for(let r of Object.keys(t))n[r]=e[r]===void 0?t[r]:e[r];return Fe(n.lowS,"lowS"),Fe(n.prehash,"prehash"),n.format!==void 0&&Wn(n.format),n}class qf extends Error{constructor(t=""){super(t)}}const ke={Err:qf,_tlv:{encode:(e,t)=>{const{Err:n}=ke;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length&1)throw new n("tlv.encode: unpadded data");const r=t.length/2,o=ot(r);if(o.length/2&128)throw new n("tlv.encode: long form length too big");const s=r>127?ot(o.length/2|128):"";return ot(e)+s+o+t},decode(e,t){const{Err:n}=ke;let r=0;if(e<0||e>256)throw new n("tlv.encode: wrong tag");if(t.length<2||t[r++]!==e)throw new n("tlv.decode: wrong tlv");const o=t[r++],s=!!(o&128);let i=0;if(!s)i=o;else{const a=o&127;if(!a)throw new n("tlv.decode(long): indefinite length not supported");if(a>4)throw new n("tlv.decode(long): byte length is too big");const d=t.subarray(r,r+a);if(d.length!==a)throw new n("tlv.decode: length bytes not complete");if(d[0]===0)throw new n("tlv.decode(long): zero leftmost byte");for(const f of d)i=i<<8|f;if(r+=a,i<128)throw new n("tlv.decode(long): not minimal encoding")}const c=t.subarray(r,r+i);if(c.length!==i)throw new n("tlv.decode: wrong value length");return{v:c,l:t.subarray(r+i)}}},_int:{encode(e){const{Err:t}=ke;if(e<Te)throw new t("integer: negative integers are not allowed");let n=ot(e);if(Number.parseInt(n[0],16)&8&&(n="00"+n),n.length&1)throw new t("unexpected DER parsing assertion: unpadded hex");return n},decode(e){const{Err:t}=ke;if(e[0]&128)throw new t("invalid signature integer: negative");if(e[0]===0&&!(e[1]&128))throw new t("invalid signature integer: unnecessary leading zero");return sn(e)}},toSig(e){const{Err:t,_int:n,_tlv:r}=ke,o=K("signature",e),{v:s,l:i}=r.decode(48,o);if(i.length)throw new t("invalid signature: left bytes after parsing");const{v:c,l:a}=r.decode(2,s),{v:d,l:f}=r.decode(2,a);if(f.length)throw new t("invalid signature: left bytes after parsing");return{r:n.decode(c),s:n.decode(d)}},hexFromSig(e){const{_tlv:t,_int:n}=ke,r=t.encode(2,n.encode(e.r)),o=t.encode(2,n.encode(e.s)),s=r+o;return t.encode(48,s)}},Te=BigInt(0),Ge=BigInt(1),li=BigInt(2),Nt=BigInt(3),Jf=BigInt(4);function We(e,t){const{BYTES:n}=e;let r;if(typeof t=="bigint")r=t;else{let o=K("private key",t);try{r=e.fromBytes(o)}catch{throw new Error(`invalid private key: expected ui8a of size ${n}, got ${typeof t}`)}}if(!e.isValidNot0(r))throw new Error("invalid private key: out of range [1..N-1]");return r}function Wf(e,t={}){const n=ai("weierstrass",e,t),{Fp:r,Fn:o}=n;let s=n.CURVE;const{h:i,n:c}=s;St(t,{},{allowInfinityPoint:"boolean",clearCofactor:"function",isTorsionFree:"function",fromBytes:"function",toBytes:"function",endo:"object",wrapPrivateKey:"boolean"});const{endo:a}=t;if(a&&(!r.is0(s.a)||typeof a.beta!="bigint"||!Array.isArray(a.basises)))throw new Error('invalid endo: expected "beta": bigint and "basises": array');const d=bi(r,o);function f(){if(!r.isOdd)throw new Error("compression is not supported: Field does not have .isOdd()")}function l(U,I,x){const{x:v,y:C}=I.toAffine(),B=r.toBytes(v);if(Fe(x,"isCompressed"),x){f();const N=!r.isOdd(C);return Ee(hi(N),B)}else return Ee(Uint8Array.of(4),B,r.toBytes(C))}function u(U){we(U,void 0,"Point");const{publicKey:I,publicKeyUncompressed:x}=d,v=U.length,C=U[0],B=U.subarray(1);if(v===I&&(C===2||C===3)){const N=r.fromBytes(B);if(!r.isValid(N))throw new Error("bad point: is not on curve, wrong x");const $=p(N);let R;try{R=r.sqrt($)}catch(q){const V=q instanceof Error?": "+q.message:"";throw new Error("bad point: is not on curve, sqrt error"+V)}f();const M=r.isOdd(R);return(C&1)===1!==M&&(R=r.neg(R)),{x:N,y:R}}else if(v===x&&C===4){const N=r.BYTES,$=r.fromBytes(B.subarray(0,N)),R=r.fromBytes(B.subarray(N,N*2));if(!D($,R))throw new Error("bad point: is not on curve");return{x:$,y:R}}else throw new Error(`bad point: got length ${v}, expected compressed=${I} or uncompressed=${x}`)}const b=t.toBytes||l,h=t.fromBytes||u;function p(U){const I=r.sqr(U),x=r.mul(I,U);return r.add(r.add(x,r.mul(U,s.a)),s.b)}function D(U,I){const x=r.sqr(I),v=p(U);return r.eql(x,v)}if(!D(s.Gx,s.Gy))throw new Error("bad curve params: generator point");const w=r.mul(r.pow(s.a,Nt),Jf),g=r.mul(r.sqr(s.b),BigInt(27));if(r.is0(r.add(w,g)))throw new Error("bad curve params: a or b");function y(U,I,x=!1){if(!r.isValid(I)||x&&r.is0(I))throw new Error(`bad point coordinate ${U}`);return I}function S(U){if(!(U instanceof T))throw new Error("ProjectivePoint expected")}function E(U){if(!a||!a.basises)throw new Error("no endo");return zf(U,a.basises,o.ORDER)}const m=zt((U,I)=>{const{X:x,Y:v,Z:C}=U;if(r.eql(C,r.ONE))return{x,y:v};const B=U.is0();I==null&&(I=B?r.ONE:r.inv(C));const N=r.mul(x,I),$=r.mul(v,I),R=r.mul(C,I);if(B)return{x:r.ZERO,y:r.ZERO};if(!r.eql(R,r.ONE))throw new Error("invZ was invalid");return{x:N,y:$}}),k=zt(U=>{if(U.is0()){if(t.allowInfinityPoint&&!r.is0(U.Y))return;throw new Error("bad point: ZERO")}const{x:I,y:x}=U.toAffine();if(!r.isValid(I)||!r.isValid(x))throw new Error("bad point: x or y not field elements");if(!D(I,x))throw new Error("bad point: equation left != right");if(!U.isTorsionFree())throw new Error("bad point: not in prime-order subgroup");return!0});function A(U,I,x,v,C){return x=new T(r.mul(x.X,U),x.Y,x.Z),I=qt(v,I),x=qt(C,x),I.add(x)}class T{constructor(I,x,v){this.X=y("x",I),this.Y=y("y",x,!0),this.Z=y("z",v),Object.freeze(this)}static CURVE(){return s}static fromAffine(I){const{x,y:v}=I||{};if(!I||!r.isValid(x)||!r.isValid(v))throw new Error("invalid affine point");if(I instanceof T)throw new Error("projective point not allowed");return r.is0(x)&&r.is0(v)?T.ZERO:new T(x,v,r.ONE)}static fromBytes(I){const x=T.fromAffine(h(we(I,void 0,"point")));return x.assertValidity(),x}static fromHex(I){return T.fromBytes(K("pointHex",I))}get x(){return this.toAffine().x}get y(){return this.toAffine().y}precompute(I=8,x=!0){return P.createCache(this,I),x||this.multiply(Nt),this}assertValidity(){k(this)}hasEvenY(){const{y:I}=this.toAffine();if(!r.isOdd)throw new Error("Field doesn't support isOdd");return!r.isOdd(I)}equals(I){S(I);const{X:x,Y:v,Z:C}=this,{X:B,Y:N,Z:$}=I,R=r.eql(r.mul(x,$),r.mul(B,C)),M=r.eql(r.mul(v,$),r.mul(N,C));return R&&M}negate(){return new T(this.X,r.neg(this.Y),this.Z)}double(){const{a:I,b:x}=s,v=r.mul(x,Nt),{X:C,Y:B,Z:N}=this;let $=r.ZERO,R=r.ZERO,M=r.ZERO,H=r.mul(C,C),q=r.mul(B,B),V=r.mul(N,N),j=r.mul(C,B);return j=r.add(j,j),M=r.mul(C,N),M=r.add(M,M),$=r.mul(I,M),R=r.mul(v,V),R=r.add($,R),$=r.sub(q,R),R=r.add(q,R),R=r.mul($,R),$=r.mul(j,$),M=r.mul(v,M),V=r.mul(I,V),j=r.sub(H,V),j=r.mul(I,j),j=r.add(j,M),M=r.add(H,H),H=r.add(M,H),H=r.add(H,V),H=r.mul(H,j),R=r.add(R,H),V=r.mul(B,N),V=r.add(V,V),H=r.mul(V,j),$=r.sub($,H),M=r.mul(V,q),M=r.add(M,M),M=r.add(M,M),new T($,R,M)}add(I){S(I);const{X:x,Y:v,Z:C}=this,{X:B,Y:N,Z:$}=I;let R=r.ZERO,M=r.ZERO,H=r.ZERO;const q=s.a,V=r.mul(s.b,Nt);let j=r.mul(x,B),J=r.mul(v,N),Y=r.mul(C,$),ce=r.add(x,v),W=r.add(B,N);ce=r.mul(ce,W),W=r.add(j,J),ce=r.sub(ce,W),W=r.add(x,C);let ne=r.add(B,$);return W=r.mul(W,ne),ne=r.add(j,Y),W=r.sub(W,ne),ne=r.add(v,C),R=r.add(N,$),ne=r.mul(ne,R),R=r.add(J,Y),ne=r.sub(ne,R),H=r.mul(q,W),R=r.mul(V,Y),H=r.add(R,H),R=r.sub(J,H),H=r.add(J,H),M=r.mul(R,H),J=r.add(j,j),J=r.add(J,j),Y=r.mul(q,Y),W=r.mul(V,W),J=r.add(J,Y),Y=r.sub(j,Y),Y=r.mul(q,Y),W=r.add(W,Y),j=r.mul(J,W),M=r.add(M,j),j=r.mul(ne,W),R=r.mul(ce,R),R=r.sub(R,j),j=r.mul(ce,J),H=r.mul(ne,H),H=r.add(H,j),new T(R,M,H)}subtract(I){return this.add(I.negate())}is0(){return this.equals(T.ZERO)}multiply(I){const{endo:x}=t;if(!o.isValidNot0(I))throw new Error("invalid scalar: out of range");let v,C;const B=N=>P.cached(this,N,$=>He(T,$));if(x){const{k1neg:N,k1:$,k2neg:R,k2:M}=E(I),{p:H,f:q}=B($),{p:V,f:j}=B(M);C=q.add(j),v=A(x.beta,H,V,N,R)}else{const{p:N,f:$}=B(I);v=N,C=$}return He(T,[v,C])[0]}multiplyUnsafe(I){const{endo:x}=t,v=this;if(!o.isValid(I))throw new Error("invalid scalar: out of range");if(I===Te||v.is0())return T.ZERO;if(I===Ge)return v;if(P.hasCache(this))return this.multiply(I);if(x){const{k1neg:C,k1:B,k2neg:N,k2:$}=E(I),{p1:R,p2:M}=xf(T,v,B,$);return A(x.beta,R,M,C,N)}else return P.unsafe(v,I)}multiplyAndAddUnsafe(I,x,v){const C=this.multiplyUnsafe(x).add(I.multiplyUnsafe(v));return C.is0()?void 0:C}toAffine(I){return m(this,I)}isTorsionFree(){const{isTorsionFree:I}=t;return i===Ge?!0:I?I(T,this):P.unsafe(this,c).is0()}clearCofactor(){const{clearCofactor:I}=t;return i===Ge?this:I?I(T,this):this.multiplyUnsafe(i)}isSmallOrder(){return this.multiplyUnsafe(i).is0()}toBytes(I=!0){return Fe(I,"isCompressed"),this.assertValidity(),b(T,this,I)}toHex(I=!0){return je(this.toBytes(I))}toString(){return`<Point ${this.is0()?"ZERO":this.toHex()}>`}get px(){return this.X}get py(){return this.X}get pz(){return this.Z}toRawBytes(I=!0){return this.toBytes(I)}_setWindowSize(I){this.precompute(I)}static normalizeZ(I){return He(T,I)}static msm(I,x){return ii(T,o,I,x)}static fromPrivateKey(I){return T.BASE.multiply(We(o,I))}}T.BASE=new T(s.Gx,s.Gy,r.ONE),T.ZERO=new T(r.ZERO,r.ONE,r.ZERO),T.Fp=r,T.Fn=o;const O=o.BITS,P=new si(T,t.endo?Math.ceil(O/2):O);return T.BASE.precompute(8),T}function hi(e){return Uint8Array.of(e?2:3)}function bi(e,t){return{secretKey:t.BYTES,publicKey:1+e.BYTES,publicKeyUncompressed:1+2*e.BYTES,publicKeyHasPrefix:!0,signature:2*t.BYTES}}function Zf(e,t={}){const{Fn:n}=e,r=t.randomBytes||lr,o=Object.assign(bi(e.Fp,n),{seed:ni(n.ORDER)});function s(b){try{return!!We(n,b)}catch{return!1}}function i(b,h){const{publicKey:p,publicKeyUncompressed:D}=o;try{const w=b.length;return h===!0&&w!==p||h===!1&&w!==D?!1:!!e.fromBytes(b)}catch{return!1}}function c(b=r(o.seed)){return mf(we(b,o.seed,"seed"),n.ORDER)}function a(b,h=!0){return e.BASE.multiply(We(n,b)).toBytes(h)}function d(b){const h=c(b);return{secretKey:h,publicKey:a(h)}}function f(b){if(typeof b=="bigint")return!1;if(b instanceof e)return!0;const{secretKey:h,publicKey:p,publicKeyUncompressed:D}=o;if(n.allowedLengths||h===p)return;const w=K("key",b).length;return w===p||w===D}function l(b,h,p=!0){if(f(b)===!0)throw new Error("first arg must be private key");if(f(h)===!1)throw new Error("second arg must be public key");const D=We(n,b);return e.fromHex(h).multiply(D).toBytes(p)}return Object.freeze({getPublicKey:a,getSharedSecret:l,keygen:d,Point:e,utils:{isValidSecretKey:s,isValidPublicKey:i,randomSecretKey:c,isValidPrivateKey:s,randomPrivateKey:c,normPrivateKeyToScalar:b=>We(n,b),precompute(b=8,h=e.BASE){return h.precompute(b,!1)}},lengths:o})}function Gf(e,t,n={}){Ns(t),St(n,{},{hmac:"function",lowS:"boolean",randomBytes:"function",bits2int:"function",bits2int_modN:"function"});const r=n.randomBytes||lr,o=n.hmac||((x,...v)=>fi(t,x,Ee(...v))),{Fp:s,Fn:i}=e,{ORDER:c,BITS:a}=i,{keygen:d,getPublicKey:f,getSharedSecret:l,utils:u,lengths:b}=Zf(e,n),h={prehash:!1,lowS:typeof n.lowS=="boolean"?n.lowS:!1,format:void 0,extraEntropy:!1},p="compact";function D(x){const v=c>>Ge;return x>v}function w(x,v){if(!i.isValidNot0(v))throw new Error(`invalid signature ${x}: out of range 1..Point.Fn.ORDER`);return v}function g(x,v){Wn(v);const C=b.signature,B=v==="compact"?C:v==="recovered"?C+1:void 0;return we(x,B,`${v} signature`)}class y{constructor(v,C,B){this.r=w("r",v),this.s=w("s",C),B!=null&&(this.recovery=B),Object.freeze(this)}static fromBytes(v,C=p){g(v,C);let B;if(C==="der"){const{r:M,s:H}=ke.toSig(we(v));return new y(M,H)}C==="recovered"&&(B=v[0],C="compact",v=v.subarray(1));const N=i.BYTES,$=v.subarray(0,N),R=v.subarray(N,N*2);return new y(i.fromBytes($),i.fromBytes(R),B)}static fromHex(v,C){return this.fromBytes(lt(v),C)}addRecoveryBit(v){return new y(this.r,this.s,v)}recoverPublicKey(v){const C=s.ORDER,{r:B,s:N,recovery:$}=this;if($==null||![0,1,2,3].includes($))throw new Error("recovery id invalid");if(c*li<C&&$>1)throw new Error("recovery id is ambiguous for h>1 curve");const M=$===2||$===3?B+c:B;if(!s.isValid(M))throw new Error("recovery id 2 or 3 invalid");const H=s.toBytes(M),q=e.fromBytes(Ee(hi(($&1)===0),H)),V=i.inv(M),j=E(K("msgHash",v)),J=i.create(-j*V),Y=i.create(N*V),ce=e.BASE.multiplyUnsafe(J).add(q.multiplyUnsafe(Y));if(ce.is0())throw new Error("point at infinify");return ce.assertValidity(),ce}hasHighS(){return D(this.s)}toBytes(v=p){if(Wn(v),v==="der")return lt(ke.hexFromSig(this));const C=i.toBytes(this.r),B=i.toBytes(this.s);if(v==="recovered"){if(this.recovery==null)throw new Error("recovery bit must be present");return Ee(Uint8Array.of(this.recovery),C,B)}return Ee(C,B)}toHex(v){return je(this.toBytes(v))}assertValidity(){}static fromCompact(v){return y.fromBytes(K("sig",v),"compact")}static fromDER(v){return y.fromBytes(K("sig",v),"der")}normalizeS(){return this.hasHighS()?new y(this.r,i.neg(this.s),this.recovery):this}toDERRawBytes(){return this.toBytes("der")}toDERHex(){return je(this.toBytes("der"))}toCompactRawBytes(){return this.toBytes("compact")}toCompactHex(){return je(this.toBytes("compact"))}}const S=n.bits2int||function(v){if(v.length>8192)throw new Error("input is too large");const C=sn(v),B=v.length*8-a;return B>0?C>>BigInt(B):C},E=n.bits2int_modN||function(v){return i.create(S(v))},m=vt(a);function k(x){return Jn("num < 2^"+a,x,Te,m),i.toBytes(x)}function A(x,v){return we(x,void 0,"message"),v?we(t(x),void 0,"prehashed message"):x}function T(x,v,C){if(["recovered","canonical"].some(J=>J in C))throw new Error("sign() legacy options not supported");const{lowS:B,prehash:N,extraEntropy:$}=Sn(C,h);x=A(x,N);const R=E(x),M=We(i,v),H=[k(M),k(R)];if($!=null&&$!==!1){const J=$===!0?r(b.secretKey):$;H.push(K("extraEntropy",J))}const q=Ee(...H),V=R;function j(J){const Y=S(J);if(!i.isValidNot0(Y))return;const ce=i.inv(Y),W=e.BASE.multiply(Y).toAffine(),ne=i.create(W.x);if(ne===Te)return;const It=i.create(ce*i.create(V+ne*M));if(It===Te)return;let Vr=(W.x===ne?0:2)|Number(W.y&Ge),Kr=It;return B&&D(It)&&(Kr=i.neg(It),Vr^=1),new y(ne,Kr,Vr)}return{seed:q,k2sig:j}}function O(x,v,C={}){x=K("message",x);const{seed:B,k2sig:N}=T(x,v,C);return df(t.outputLen,i.BYTES,o)(B,N)}function P(x){let v;const C=typeof x=="string"||Dt(x),B=!C&&x!==null&&typeof x=="object"&&typeof x.r=="bigint"&&typeof x.s=="bigint";if(!C&&!B)throw new Error("invalid signature, expected Uint8Array, hex string or Signature instance");if(B)v=new y(x.r,x.s);else if(C){try{v=y.fromBytes(K("sig",x),"der")}catch(N){if(!(N instanceof ke.Err))throw N}if(!v)try{v=y.fromBytes(K("sig",x),"compact")}catch{return!1}}return v||!1}function U(x,v,C,B={}){const{lowS:N,prehash:$,format:R}=Sn(B,h);if(C=K("publicKey",C),v=A(K("message",v),$),"strict"in B)throw new Error("options.strict was renamed to lowS");const M=R===void 0?P(x):y.fromBytes(K("sig",x),R);if(M===!1)return!1;try{const H=e.fromBytes(C);if(N&&M.hasHighS())return!1;const{r:q,s:V}=M,j=E(v),J=i.inv(V),Y=i.create(j*J),ce=i.create(q*J),W=e.BASE.multiplyUnsafe(Y).add(H.multiplyUnsafe(ce));return W.is0()?!1:i.create(W.x)===q}catch{return!1}}function I(x,v,C={}){const{prehash:B}=Sn(C,h);return v=A(v,B),y.fromBytes(x,"recovered").recoverPublicKey(v).toBytes()}return Object.freeze({keygen:d,getPublicKey:f,getSharedSecret:l,utils:u,lengths:b,Point:e,sign:O,verify:U,recoverPublicKey:I,Signature:y,hash:t})}function Yf(e){const t={a:e.a,b:e.b,p:e.Fp.ORDER,n:e.n,h:e.h,Gx:e.Gx,Gy:e.Gy},n=e.Fp;let r=e.allowedPrivateKeyLengths?Array.from(new Set(e.allowedPrivateKeyLengths.map(i=>Math.ceil(i/2)))):void 0;const o=ve(t.n,{BITS:e.nBitLength,allowedLengths:r,modFromBytes:e.wrapPrivateKey}),s={Fp:n,Fn:o,allowInfinityPoint:e.allowInfinityPoint,endo:e.endo,isTorsionFree:e.isTorsionFree,clearCofactor:e.clearCofactor,fromBytes:e.fromBytes,toBytes:e.toBytes};return{CURVE:t,curveOpts:s}}function Xf(e){const{CURVE:t,curveOpts:n}=Yf(e),r={hmac:e.hmac,randomBytes:e.randomBytes,lowS:e.lowS,bits2int:e.bits2int,bits2int_modN:e.bits2int_modN};return{CURVE:t,curveOpts:n,hash:e.hash,ecdsaOpts:r}}function Qf(e,t){const n=t.Point;return Object.assign({},t,{ProjectivePoint:n,CURVE:Object.assign({},e,ei(n.Fn.ORDER,n.Fn.BITS))})}function el(e){const{CURVE:t,curveOpts:n,hash:r,ecdsaOpts:o}=Xf(e),s=Wf(t,n),i=Gf(s,r,o);return Qf(e,i)}function an(e,t){const n=r=>el({...e,hash:r});return{...n(t),create:n}}const Er={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffefffffc2f"),n:BigInt("0xfffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141"),h:BigInt(1),a:BigInt(0),b:BigInt(7),Gx:BigInt("0x79be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798"),Gy:BigInt("0x483ada7726a3c4655da4fbfc0e1108a8fd17b448a68554199c47d08ffb10d4b8")},tl={beta:BigInt("0x7ae96a2b657c07106e64479eac3434e99cf0497512f58995c1396c28719501ee"),basises:[[BigInt("0x3086d221a7d46bcde86c90e49284eb15"),-BigInt("0xe4437ed6010e88286f547fa90abfe4c3")],[BigInt("0x114ca50f7a8e2f3f657c1108d9d44cfd8"),BigInt("0x3086d221a7d46bcde86c90e49284eb15")]]},Eo=BigInt(2);function nl(e){const t=Er.p,n=BigInt(3),r=BigInt(6),o=BigInt(11),s=BigInt(22),i=BigInt(23),c=BigInt(44),a=BigInt(88),d=e*e*e%t,f=d*d*e%t,l=Z(f,n,t)*f%t,u=Z(l,n,t)*f%t,b=Z(u,Eo,t)*d%t,h=Z(b,o,t)*b%t,p=Z(h,s,t)*h%t,D=Z(p,c,t)*p%t,w=Z(D,a,t)*D%t,g=Z(w,c,t)*p%t,y=Z(g,n,t)*f%t,S=Z(y,i,t)*h%t,E=Z(S,r,t)*d%t,m=Z(E,Eo,t);if(!Zn.eql(Zn.sqr(m),e))throw new Error("Cannot find square root");return m}const Zn=ve(Er.p,{sqrt:nl}),bt=an({...Er,Fp:Zn,lowS:!0,endo:tl},br);const pi={p:BigInt("0xffffffff00000001000000000000000000000000ffffffffffffffffffffffff"),n:BigInt("0xffffffff00000000ffffffffffffffffbce6faada7179e84f3b9cac2fc632551"),h:BigInt(1),a:BigInt("0xffffffff00000001000000000000000000000000fffffffffffffffffffffffc"),b:BigInt("0x5ac635d8aa3a93e7b3ebbd55769886bc651d06b0cc53b0f63bce3c3e27d2604b"),Gx:BigInt("0x6b17d1f2e12c4247f8bce6e563a440f277037d812deb33a0f4a13945d898c296"),Gy:BigInt("0x4fe342e2fe1a7f9b8ee7eb4a7c0f9e162bce33576b315ececbb6406837bf51f5")},wi={p:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000ffffffff"),n:BigInt("0xffffffffffffffffffffffffffffffffffffffffffffffffc7634d81f4372ddf581a0db248b0a77aecec196accc52973"),h:BigInt(1),a:BigInt("0xfffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffeffffffff0000000000000000fffffffc"),b:BigInt("0xb3312fa7e23ee7e4988e056be3f82d19181d9c6efe8141120314088f5013875ac656398d8a2ed19d2a85c8edd3ec2aef"),Gx:BigInt("0xaa87ca22be8b05378eb1c71ef320ad746e1d3b628ba79b9859f741e082542a385502f25dbf55296c3a545e3872760ab7"),Gy:BigInt("0x3617de4a96262c6f5d9e98bf9292dc29f8f41dbd289a147ce9da3113b5f0b8c00a60b1ce1d7e819d7a431d7c90ea0e5f")},yi={p:BigInt("0x1ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),n:BigInt("0x01fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffa51868783bf2f966b7fcc0148f709a5d03bb5c9b8899c47aebb6fb71e91386409"),h:BigInt(1),a:BigInt("0x1fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffc"),b:BigInt("0x0051953eb9618e1c9a1f929a21a0b68540eea2da725b99b315f3b8b489918ef109e156193951ec7e937b1652c0bd3bb1bf073573df883d2c34f1ef451fd46b503f00"),Gx:BigInt("0x00c6858e06b70404e9cd9e3ecb662395b4429c648139053fb521f828af606b4d3dbaa14b5e77efe75928fe1dc127a2ffa8de3348b3c1856a429bf97e7e31c2e5bd66"),Gy:BigInt("0x011839296a789a3bc0045c8a5fb42c7d1bd998f54449579b446817afbd17273e662c97ee72995ef42640c550b9013fad0761353c7086a272c24088be94769fd16650")},rl=ve(pi.p),ol=ve(wi.p),sl=ve(yi.p),il=an({...pi,Fp:rl,lowS:!1},br),al=an({...wi,Fp:ol,lowS:!1},sf),cl=an({...yi,Fp:sl,lowS:!1,allowedPrivateKeyLengths:[130,131,132]},Fs);const Jt=il,dl=br,ul=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),gi=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),fl=gi.map(e=>(9*e+5)%16),mi=(()=>{const n=[[gi],[fl]];for(let r=0;r<4;r++)for(let o of n)o.push(o[r].map(s=>ul[s]));return n})(),Ei=mi[0],Di=mi[1],xi=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),ll=Ei.map((e,t)=>e.map(n=>xi[t][n])),hl=Di.map((e,t)=>e.map(n=>xi[t][n])),bl=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),pl=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function Do(e,t,n,r){return e===0?t^n^r:e===1?t&n|~t&r:e===2?(t|~n)^r:e===3?t&r|n&~r:t^(n|~r)}const Mt=new Uint32Array(16);class wl extends hr{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){const{h0:t,h1:n,h2:r,h3:o,h4:s}=this;return[t,n,r,o,s]}set(t,n,r,o,s){this.h0=t|0,this.h1=n|0,this.h2=r|0,this.h3=o|0,this.h4=s|0}process(t,n){for(let b=0;b<16;b++,n+=4)Mt[b]=t.getUint32(n,!0);let r=this.h0|0,o=r,s=this.h1|0,i=s,c=this.h2|0,a=c,d=this.h3|0,f=d,l=this.h4|0,u=l;for(let b=0;b<5;b++){const h=4-b,p=bl[b],D=pl[b],w=Ei[b],g=Di[b],y=ll[b],S=hl[b];for(let E=0;E<16;E++){const m=Bt(r+Do(b,s,c,d)+Mt[w[E]]+p,y[E])+l|0;r=l,l=d,d=Bt(c,10)|0,c=s,s=m}for(let E=0;E<16;E++){const m=Bt(o+Do(h,i,a,f)+Mt[g[E]]+D,S[E])+u|0;o=u,u=f,f=Bt(a,10)|0,a=i,i=m}}this.set(this.h1+c+f|0,this.h2+d+u|0,this.h3+l+o|0,this.h4+r+i|0,this.h0+s+a|0)}roundClean(){De(Mt)}destroy(){this.destroyed=!0,De(this.buffer),this.set(0,0,0,0,0)}}const yl=xt(()=>new wl),vi=yl,gl=BigInt(0),nt=BigInt(1),ml=BigInt(2),El=BigInt(7),Dl=BigInt(256),xl=BigInt(113),Si=[],Ai=[],ki=[];for(let e=0,t=nt,n=1,r=0;e<24;e++){[n,r]=[r,(2*n+3*r)%5],Si.push(2*(5*r+n)),Ai.push((e+1)*(e+2)/2%64);let o=gl;for(let s=0;s<7;s++)t=(t<<nt^(t>>El)*xl)%Dl,t&ml&&(o^=nt<<(nt<<BigInt(s))-nt);ki.push(o)}const Ti=Hs(ki,!0),vl=Ti[0],Sl=Ti[1],xo=(e,t,n)=>n>32?qu(e,t,n):Ku(e,t,n),vo=(e,t,n)=>n>32?Ju(e,t,n):zu(e,t,n);function Al(e,t=24){const n=new Uint32Array(10);for(let r=24-t;r<24;r++){for(let i=0;i<10;i++)n[i]=e[i]^e[i+10]^e[i+20]^e[i+30]^e[i+40];for(let i=0;i<10;i+=2){const c=(i+8)%10,a=(i+2)%10,d=n[a],f=n[a+1],l=xo(d,f,1)^n[c],u=vo(d,f,1)^n[c+1];for(let b=0;b<50;b+=10)e[i+b]^=l,e[i+b+1]^=u}let o=e[2],s=e[3];for(let i=0;i<24;i++){const c=Ai[i],a=xo(o,s,c),d=vo(o,s,c),f=Si[i];o=e[f],s=e[f+1],e[f]=a,e[f+1]=d}for(let i=0;i<50;i+=10){for(let c=0;c<10;c++)n[c]=e[i+c];for(let c=0;c<10;c++)e[i+c]^=~n[(c+2)%10]&n[(c+4)%10]}e[0]^=vl[r],e[1]^=Sl[r]}De(n)}class Dr extends fr{constructor(t,n,r,o=!1,s=24){if(super(),this.pos=0,this.posOut=0,this.finished=!1,this.destroyed=!1,this.enableXOF=!1,this.blockLen=t,this.suffix=n,this.outputLen=r,this.enableXOF=o,this.rounds=s,ft(r),!(0<t&&t<200))throw new Error("only keccak-f1600 function is supported");this.state=new Uint8Array(200),this.state32=Ou(this.state)}clone(){return this._cloneInto()}keccak(){Qr(this.state32),Al(this.state32,this.rounds),Qr(this.state32),this.posOut=0,this.pos=0}update(t){Ye(this),t=on(t),Ie(t);const{blockLen:n,state:r}=this,o=t.length;for(let s=0;s<o;){const i=Math.min(n-this.pos,o-s);for(let c=0;c<i;c++)r[this.pos++]^=t[s++];this.pos===n&&this.keccak()}return this}finish(){if(this.finished)return;this.finished=!0;const{state:t,suffix:n,pos:r,blockLen:o}=this;t[r]^=n,(n&128)!==0&&r===o-1&&this.keccak(),t[o-1]^=128,this.keccak()}writeInto(t){Ye(this,!1),Ie(t),this.finish();const n=this.state,{blockLen:r}=this;for(let o=0,s=t.length;o<s;){this.posOut>=r&&this.keccak();const i=Math.min(r-this.posOut,s-o);t.set(n.subarray(this.posOut,this.posOut+i),o),this.posOut+=i,o+=i}return t}xofInto(t){if(!this.enableXOF)throw new Error("XOF is not possible for this instance");return this.writeInto(t)}xof(t){return ft(t),this.xofInto(new Uint8Array(t))}digestInto(t){if(Ms(t,this),this.finished)throw new Error("digest() was already called");return this.writeInto(t),this.destroy(),t}digest(){return this.digestInto(new Uint8Array(this.outputLen))}destroy(){this.destroyed=!0,De(this.state)}_cloneInto(t){const{blockLen:n,suffix:r,outputLen:o,rounds:s,enableXOF:i}=this;return t||(t=new Dr(n,r,o,i,s)),t.state32.set(this.state32),t.pos=this.pos,t.posOut=this.posOut,t.finished=this.finished,t.rounds=s,t.suffix=r,t.outputLen=o,t.enableXOF=i,t.destroyed=this.destroyed,t}}const kl=(e,t,n)=>xt(()=>new Dr(t,e,n)),Tl=kl(1,136,256/8);var An,So;function Il(){return So||(So=1,An=function e(t){if(typeof t=="number"&&isNaN(t))throw new Error("NaN is not allowed");if(typeof t=="number"&&!isFinite(t))throw new Error("Infinity is not allowed");return t===null||typeof t!="object"?JSON.stringify(t):t.toJSON instanceof Function?e(t.toJSON()):Array.isArray(t)?`[${t.reduce((o,s,i)=>`${o}${i===0?"":","}${e(s===void 0||typeof s=="symbol"?null:s)}`,"")}]`:`{${Object.keys(t).sort().reduce((r,o)=>{if(t[o]===void 0||typeof t[o]=="symbol")return r;const s=r.length===0?"":",";return`${r}${s}${e(o)}:${e(t[o])}`},"")}}`}),An}var Cl=Il();const _l=nr(Cl);function Bl(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function $l(){const e=new Map;return function(t,n){try{let o=function(i){if(r)return i;const c=e.get(t.didUrl);return c!==void 0?c:Promise.resolve(n()).then(function(a){var d;return((d=a.didResolutionMetadata)==null?void 0:d.error)!=="notFound"&&e.set(t.didUrl,a),a})},r;const s=(function(){if(t.params&&t.params["no-cache"]==="true")return Promise.resolve(n()).then(function(i){return r=1,i})})();return Promise.resolve(s&&s.then?s.then(o):o(s))}catch(r){return Promise.reject(r)}}}function Rl(e,t){return t()}const Ol="(?:%[0-9a-fA-F]{2})",Ao=`(?:[a-zA-Z0-9._-]|${Ol})`,Ul="([a-z0-9]+)",Nl=`((?:${Ao}*:)*(${Ao}+))`,ko="[a-zA-Z0-9_.:%-]",Ml=`;${ko}+=${ko}*`,Pl=`((${Ml})*)`,Hl="(/[^#?]*)?",jl="([?][^#]*)?",Ll="(#.*)?",Fl=new RegExp(`^did:${Ul}:${Nl}${Pl}${Hl}${jl}${Ll}$`);function Ii(e){if(e===""||!e)return null;const t=e.match(Fl);if(t){const n={did:`did:${t[1]}:${t[2]}`,method:t[1],id:t[2],didUrl:e};if(t[4]){const r=t[4].slice(1).split(";");n.params={};for(const o of r){const s=o.split("=");n.params[s[0]]=s[1]}}return t[6]&&(n.path=t[6]),t[7]&&(n.query=t[7].slice(1)),t[8]&&(n.fragment=t[8].slice(1)),n}return null}const Wt={didResolutionMetadata:{},didDocument:null,didDocumentMetadata:{}};function Vl(e){return function(t,n,r){try{return Promise.resolve(Bl(function(){return Promise.resolve(e(t,n,r)).then(function(o){return{...Wt,didResolutionMetadata:{contentType:"application/did+ld+json"},didDocument:o}})},function(o){return{...Wt,didResolutionMetadata:{error:"notFound",message:o.toString()}}}))}catch(o){return Promise.reject(o)}}}class Kl{constructor(t={},n={}){this.registry=void 0,this.cache=void 0,this.registry=t,this.cache=n.cache===!0?$l():n.cache||Rl,n.legacyResolvers&&Object.keys(n.legacyResolvers).map(r=>{this.registry[r]||(this.registry[r]=Vl(n.legacyResolvers[r]))})}resolve(t,n={}){try{const r=this,o=Ii(t);if(o===null)return Promise.resolve({...Wt,didResolutionMetadata:{error:"invalidDid"}});const s=r.registry[o.method];return s?Promise.resolve(r.cache(o,()=>s(o.did,o,r,n))):Promise.resolve({...Wt,didResolutionMetadata:{error:"unsupportedDidMethod"}})}catch(r){return Promise.reject(r)}}}function Ci(e){return e instanceof Uint8Array||ArrayBuffer.isView(e)&&e.constructor.name==="Uint8Array"}function _i(e,t){return Array.isArray(t)?t.length===0?!0:e?t.every(n=>typeof n=="string"):t.every(n=>Number.isSafeInteger(n)):!1}function zl(e){if(typeof e!="function")throw new Error("function expected");return!0}function pt(e,t){if(typeof t!="string")throw new Error(`${e}: string expected`);return!0}function Bi(e){if(!Number.isSafeInteger(e))throw new Error(`invalid integer: ${e}`)}function Gn(e){if(!Array.isArray(e))throw new Error("array expected")}function $i(e,t){if(!_i(!0,t))throw new Error(`${e}: array of strings expected`)}function Ri(e,t){if(!_i(!1,t))throw new Error(`${e}: array of numbers expected`)}function ql(...e){const t=s=>s,n=(s,i)=>c=>s(i(c)),r=e.map(s=>s.encode).reduceRight(n,t),o=e.map(s=>s.decode).reduce(n,t);return{encode:r,decode:o}}function Jl(e){const t=typeof e=="string"?e.split(""):e,n=t.length;$i("alphabet",t);const r=new Map(t.map((o,s)=>[o,s]));return{encode:o=>(Gn(o),o.map(s=>{if(!Number.isSafeInteger(s)||s<0||s>=n)throw new Error(`alphabet.encode: digit index outside alphabet "${s}". Allowed: ${e}`);return t[s]})),decode:o=>(Gn(o),o.map(s=>{pt("alphabet.decode",s);const i=r.get(s);if(i===void 0)throw new Error(`Unknown letter: "${s}". Allowed: ${e}`);return i}))}}function Wl(e=""){return pt("join",e),{encode:t=>($i("join.decode",t),t.join(e)),decode:t=>(pt("join.decode",t),t.split(e))}}const Oi=(e,t)=>t===0?e:Oi(t,e%t),Zt=(e,t)=>e+(t-Oi(e,t)),jt=(()=>{let e=[];for(let t=0;t<40;t++)e.push(2**t);return e})();function Yn(e,t,n,r){if(Gn(e),t<=0||t>32)throw new Error(`convertRadix2: wrong from=${t}`);if(n<=0||n>32)throw new Error(`convertRadix2: wrong to=${n}`);if(Zt(t,n)>32)throw new Error(`convertRadix2: carry overflow from=${t} to=${n} carryBits=${Zt(t,n)}`);let o=0,s=0;const i=jt[t],c=jt[n]-1,a=[];for(const d of e){if(Bi(d),d>=i)throw new Error(`convertRadix2: invalid data word=${d} from=${t}`);if(o=o<<t|d,s+t>32)throw new Error(`convertRadix2: carry overflow pos=${s} from=${t}`);for(s+=t;s>=n;s-=n)a.push((o>>s-n&c)>>>0);const f=jt[s];if(f===void 0)throw new Error("invalid carry");o&=f-1}if(o=o<<n-s&c,!r&&s>=t)throw new Error("Excess padding");if(!r&&o>0)throw new Error(`Non-zero padding: ${o}`);return r&&s>0&&a.push(o>>>0),a}function Zl(e,t=!1){if(Bi(e),e<=0||e>32)throw new Error("radix2: bits should be in (0..32]");if(Zt(8,e)>32||Zt(e,8)>32)throw new Error("radix2: carry overflow");return{encode:n=>{if(!Ci(n))throw new Error("radix2.encode input should be Uint8Array");return Yn(Array.from(n),8,e,!t)},decode:n=>(Ri("radix2.decode",n),Uint8Array.from(Yn(n,e,8,t)))}}function To(e){return zl(e),function(...t){try{return e.apply(null,t)}catch{}}}const Xn=ql(Jl("qpzry9x8gf2tvdw0s3jn54khce6mua7l"),Wl("")),Io=[996825010,642813549,513874426,1027748829,705979059];function rt(e){const t=e>>25;let n=(e&33554431)<<5;for(let r=0;r<Io.length;r++)(t>>r&1)===1&&(n^=Io[r]);return n}function Co(e,t,n=1){const r=e.length;let o=1;for(let s=0;s<r;s++){const i=e.charCodeAt(s);if(i<33||i>126)throw new Error(`Invalid prefix (${e})`);o=rt(o)^i>>5}o=rt(o);for(let s=0;s<r;s++)o=rt(o)^e.charCodeAt(s)&31;for(let s of t)o=rt(o)^s;for(let s=0;s<6;s++)o=rt(o);return o^=n,Xn.encode(Yn([o%jt[30]],30,5,!1))}function Gl(e){const t=e==="bech32"?1:734539939,n=Zl(5),r=n.decode,o=n.encode,s=To(r);function i(l,u,b=90){pt("bech32.encode prefix",l),Ci(u)&&(u=Array.from(u)),Ri("bech32.encode",u);const h=l.length;if(h===0)throw new TypeError(`Invalid prefix length ${h}`);const p=h+7+u.length;if(b!==!1&&p>b)throw new TypeError(`Length ${p} exceeds limit ${b}`);const D=l.toLowerCase(),w=Co(D,u,t);return`${D}1${Xn.encode(u)}${w}`}function c(l,u=90){pt("bech32.decode input",l);const b=l.length;if(b<8||u!==!1&&b>u)throw new TypeError(`invalid string length: ${b} (${l}). Expected (8..${u})`);const h=l.toLowerCase();if(l!==h&&l!==l.toUpperCase())throw new Error("String must be lowercase or uppercase");const p=h.lastIndexOf("1");if(p===0||p===-1)throw new Error('Letter "1" must be present between prefix and data only');const D=h.slice(0,p),w=h.slice(p+1);if(w.length<6)throw new Error("Data must be at least 6 characters long");const g=Xn.decode(w).slice(0,-6),y=Co(D,g,t);if(!w.endsWith(y))throw new Error(`Invalid checksum in ${l}: expected "${y}"`);return{prefix:D,words:g}}const a=To(c);function d(l){const{prefix:u,words:b}=c(l,!1);return{prefix:u,words:b,bytes:r(b)}}function f(l,u){return i(l,o(u))}return{encode:i,decode:c,encodeFromBytes:f,decodeToBytes:d,decodeUnsafe:a,fromWords:r,fromWordsUnsafe:s,toWords:o}}const _o=Gl("bech32"),he={toString:ur,fromString:rn,concat:Es};function xr(e){return he.toString(e,"base64url")}function fe(e){const t=e.replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"");return he.fromString(t,"base64url")}function Ui(e){return he.fromString(e,"base58btc")}function Yl(e){return he.toString(e,"base58btc")}const Xl={ES256:["JsonWebKey2020","Multikey","EcdsaSecp256r1VerificationKey2019"],ES256K:["EcdsaSecp256k1VerificationKey2019","EcdsaSecp256k1RecoveryMethod2020","Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1","JsonWebKey2020","Multikey"],"ES256K-R":["EcdsaSecp256k1VerificationKey2019","EcdsaSecp256k1RecoveryMethod2020","Secp256k1VerificationKey2018","Secp256k1SignatureVerificationKey2018","EcdsaPublicKeySecp256k1","ConditionalProof2022","JsonWebKey2020","Multikey"],Ed25519:["ED25519SignatureVerification","Ed25519VerificationKey2018","Ed25519VerificationKey2020","JsonWebKey2020","Multikey"],EdDSA:["ED25519SignatureVerification","Ed25519VerificationKey2018","Ed25519VerificationKey2020","JsonWebKey2020","Multikey"]},Pt={Secp256k1SignatureVerificationKey2018:"Secp256k1",Secp256k1VerificationKey2018:"Secp256k1",EcdsaSecp256k1VerificationKey2019:"Secp256k1",EcdsaPublicKeySecp256k1:"Secp256k1",EcdsaSecp256k1RecoveryMethod2020:"Secp256k1",EcdsaSecp256r1VerificationKey2019:"P-256",Ed25519VerificationKey2018:"Ed25519",Ed25519VerificationKey2020:"Ed25519",ED25519SignatureVerification:"Ed25519",X25519KeyAgreementKey2019:"X25519",X25519KeyAgreementKey2020:"X25519",ConditionalProof2022:void 0,JsonWebKey2020:void 0,Multikey:void 0},Ql={"ed25519-pub":237,"x25519-pub":236,"secp256k1-pub":231,"bls12_381-g1-pub":234,"bls12_381-g2-pub":235,"p256-pub":4608},eh={"bls12_381-g1-pub":"Bls12381G1","bls12_381-g2-pub":"Bls12381G2","ed25519-pub":"Ed25519","p256-pub":"P-256","secp256k1-pub":"Secp256k1","x25519-pub":"X25519"};function cn(e){if(e.publicKeyBase58)return{keyBytes:Ui(e.publicKeyBase58),keyType:Pt[e.type]};if(e.publicKeyBase64)return{keyBytes:fe(e.publicKeyBase64),keyType:Pt[e.type]};if(e.publicKeyHex)return{keyBytes:Lt(e.publicKeyHex),keyType:Pt[e.type]};if(e.publicKeyJwk&&e.publicKeyJwk.crv==="secp256k1"&&e.publicKeyJwk.x&&e.publicKeyJwk.y)return{keyBytes:bt.ProjectivePoint.fromAffine({x:Ht(fe(e.publicKeyJwk.x)),y:Ht(fe(e.publicKeyJwk.y))}).toRawBytes(!1),keyType:"Secp256k1"};if(e.publicKeyJwk&&e.publicKeyJwk.crv==="P-256"&&e.publicKeyJwk.x&&e.publicKeyJwk.y)return{keyBytes:Jt.ProjectivePoint.fromAffine({x:Ht(fe(e.publicKeyJwk.x)),y:Ht(fe(e.publicKeyJwk.y))}).toRawBytes(!1),keyType:"P-256"};if(e.publicKeyJwk&&e.publicKeyJwk.kty==="OKP"&&["Ed25519","X25519"].includes(e.publicKeyJwk.crv??"")&&e.publicKeyJwk.x)return{keyBytes:fe(e.publicKeyJwk.x),keyType:e.publicKeyJwk.crv};if(e.publicKeyMultibase){const{keyBytes:t,keyType:n}=th(e.publicKeyMultibase);return{keyBytes:t,keyType:n??Pt[e.type]}}return{keyBytes:new Uint8Array}}function th(e){const t=Kf.decode(e);if([32,33,48,64,65,96].includes(t.length))return{keyBytes:t};try{const[n,r]=at(t),o=Object.entries(Ql).filter(([,s])=>s===n)?.[0][0]??"";return{keyBytes:t.slice(r),keyType:eh[o]}}catch{return{keyBytes:t}}}function Lt(e,t){let n=e.startsWith("0x")?e.substring(2):e;return n.length%2!==0&&(n=`0${n}`),he.fromString(n.toLowerCase(),"base16")}function Bo(e){return xr(he.fromString(e))}function Ni(e){return he.toString(fe(e))}function Ue(e){return he.toString(e,"base16")}function Ht(e){return BigInt("0x"+he.toString(e,"base16"))}function nh(e){return he.fromString(e,"utf-8")}function Mi({r:e,s:t,recoveryParam:n},r){const o=new Uint8Array(r?65:64);if(o.set(he.fromString(e,"base16"),0),o.set(he.fromString(t,"base16"),32),r){if(typeof n>"u")throw new Error("Signer did not return a recoveryParam");o[64]=n}return xr(o)}function rh(e){const t=fe(e);if(t.length<64||t.length>65)throw new TypeError(`Wrong size for signature. Expected 64 or 65 bytes, but got ${t.length}`);const n=Ue(t.slice(0,32)),r=Ue(t.slice(32,64)),o=t.length===65?t[64]:void 0;return{r:n,s:r,recoveryParam:o}}function Le(e){const t=typeof e=="string"?rn(e):e;return dl(t)}const oh=Tl;function Pi(e){const t=rn(e.slice(2),"base16");return`0x${ur(oh(t).slice(-20),"base16")}`}function vr(e){return typeof e=="object"&&"r"in e&&"s"in e}function sh(){return function(t,n){try{return Promise.resolve(n(t)).then(function(r){return vr(r)?Mi(r):r})}catch(r){return Promise.reject(r)}}}function $o(e){return function(n,r){try{return Promise.resolve(r(n)).then(function(o){if(vr(o))return Mi(o,e);if(e&&typeof rh(o).recoveryParam>"u")throw new Error("not_supported: ES256K-R not supported when signer doesn't provide a recovery param");return o})}catch(o){return Promise.reject(o)}}}function Ro(){return function(t,n){try{return Promise.resolve(n(t)).then(function(r){if(vr(r))throw new Error("invalid_config: expected a signer function that returns a string instead of signature object");return r})}catch(r){return Promise.reject(r)}}}const ih={ES256:sh(),ES256K:$o(),"ES256K-R":$o(!0),Ed25519:Ro(),EdDSA:Ro()};function ah(e){const t=ih[e];if(!t)throw new Error(`not_supported: Unsupported algorithm ${e}`);return t}function ch(e,t){const n=Ue(Ui(t).slice(0,1)),r=Lt(e),o=vi(Le(r)),s=n+Ue(o),i=Le(Lt(s)),c=Le(i),a=Ue(c).substring(0,8),d=s+a;return Yl(Lt(d))}function dh(e,t){const n=bt.ProjectivePoint.fromHex(e).toRawBytes(),r=vi(Le(n)),o=_o.toWords(r);return _o.encode(t,o).replace(t,"")}function uh(e,t){if(t){const n=t.split(":");switch(n[0]){case"bip122":n[n.length-1]=ch(e,n[n.length-1]);break;case"cosmos":n[n.length-1]=dh(e,n[1]);break;case"eip155":n[n.length-1]=Pi(e);break;default:return!1}return n.join(":").toLowerCase()===t.toLowerCase()}return!1}function fh(e,t=!1){const n=fe(e);if(n.length!==(t?65:64))throw new Error("wrong signature length");const r=Ue(n.slice(0,32)),o=Ue(n.slice(32,64)),s={r,s:o};return t&&(s.recoveryParam=n[64]),s}function Qn(e,t=!1){const n=fe(e);if(n.length!==(t?65:64))throw new Error("wrong signature length");return{compact:n.slice(0,64),recovery:n[64]}}function lh(e,t,n){const r=Le(e),o=Jt.Signature.fromCompact(Qn(t).compact),i=n.filter(c=>!c.ethereumAddress&&!c.blockchainAccountId).find(c=>{try{const{keyBytes:a}=cn(c);return Jt.verify(o,r,a)}catch{return!1}});if(!i)throw new Error("invalid_signature: Signature invalid for JWT");return i}function hh(e,t,n){const r=Le(e),o=bt.Signature.fromCompact(fe(t)).normalizeS(),s=n.filter(a=>!a.ethereumAddress&&!a.blockchainAccountId),i=n.filter(a=>a.ethereumAddress||a.blockchainAccountId);let c=s.find(a=>{try{const{keyBytes:d}=cn(a);return bt.verify(o,r,d)}catch{return!1}});if(!c&&i.length>0&&(c=Hi(e,t,i)),!c)throw new Error("invalid_signature: Signature invalid for JWT");return c}function Hi(e,t,n){const r=[];if(t.length>86)r.push(Qn(t,!0));else{const i=Qn(t,!1);r.push({...i,recovery:0}),r.push({...i,recovery:1})}const o=Le(e),s=i=>{const a=bt.Signature.fromCompact(i.compact).addRecoveryBit(i.recovery||0).recoverPublicKey(o),d=Pi(a.toHex(!1)).toLowerCase(),f=a.toHex(!1),l=a.toHex(!0);return n.find(u=>{const{keyBytes:b}=cn(u),h=Ue(b);return h===f||h===l||u.ethereumAddress?.toLowerCase()===d||u.blockchainAccountId?.split("@eip155")?.[0].toLowerCase()===d||uh(f,u.blockchainAccountId)})};for(const i of r){const c=s(i);if(c)return c}throw new Error("invalid_signature: Signature invalid for JWT")}function Oo(e,t,n){const r=nh(e),o=fe(t),s=n.find(i=>{const{keyBytes:c,keyType:a}=cn(i);return a==="Ed25519"?di.verify(o,r,c):!1});if(!s)throw new Error("invalid_signature: Signature invalid for JWT");return s}const bh={ES256:lh,ES256K:hh,"ES256K-R":Hi,Ed25519:Oo,EdDSA:Oo};function ji(e){const t=bh[e];if(!t)throw new Error(`not_supported: Unsupported algorithm ${e}`);return t}ji.toSignatureObject=fh;const L={INVALID_JWT:"invalid_jwt",INVALID_AUDIENCE:"invalid_config",INVALID_SIGNATURE:"invalid_signature",NO_SUITABLE_KEYS:"no_suitable_keys",NOT_SUPPORTED:"not_supported",RESOLVER_ERROR:"resolver_error"};function ph(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}const wh=function(e,{header:t,payload:n,data:r,signature:o},s,i){try{if(!s.conditionDelegated)throw new Error("Expected conditionDelegated");if(!i.resolver)throw new Error("Expected resolver");let c;const a=s.conditionDelegated;return Promise.resolve(Fi(i.resolver,t.alg,a,i.proofPurpose)).then(function(d){let f;function l(p){if(c)return s;throw new Error(`${L.INVALID_SIGNATURE}: condition for authenticator ${s.id} is not met.`)}const u=d.didResolutionResult;if(!u?.didDocument)throw new Error(`${L.RESOLVER_ERROR}: Could not resolve delegated DID ${a}.`);const b=d.authenticators.find(p=>p.id===a);if(!b)throw new Error(`${L.NO_SUITABLE_KEYS}: Could not find delegated authenticator ${a} in it's DID Document`);const h=(function(){if(b.type===Sr)return Promise.resolve(Ar(e,{...i,didAuthenticator:{didResolutionResult:u,authenticators:[b],issuer:b.id}})).then(function({verified:p}){p&&(c=b)});try{c=kr({header:t,payload:n,data:r,signature:o},b)}catch(p){if(!p.message.startsWith("invalid_signature:"))throw p}})();return h&&h.then?h.then(l):l(h)})}catch(c){return Promise.reject(c)}},Uo=typeof Symbol<"u"?Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")):"@@iterator";function ae(e,t,n){if(!e.s){if(n instanceof Qe)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=ae.bind(null,e,t);return}if(n&&n.then){n.then(ae.bind(null,e,t),ae.bind(null,e,2));return}e.s=t,e.v=n;const r=e.o;r&&r(e)}}const Qe=(function(){function e(){}return e.prototype.then=function(t,n){const r=new e,o=this.s;if(o){const s=o&1?t:n;if(s){try{ae(r,1,s(this.v))}catch(i){ae(r,2,i)}return r}else return this}return this.o=function(s){try{const i=s.v;s.s&1?ae(r,1,t?t(i):i):n?ae(r,1,n(i)):ae(r,2,i)}catch(i){ae(r,2,i)}},r},e})();function Li(e){return e instanceof Qe&&e.s&1}function yh(e,t,n){var r=-1,o,s;function i(c){try{for(;++r<e.length&&(!n||!n());)if(c=t(r),c&&c.then)if(Li(c))c=c.v;else{c.then(i,s||(s=ae.bind(null,o=new Qe,2)));return}o?ae(o,1,c):o=c}catch(a){ae(o||(o=new Qe),2,a)}}return i(),o}const gh=function(e,{header:t,payload:n,data:r,signature:o},s,i){try{let c=function(b){if(a)return b;throw new Error(`${L.INVALID_SIGNATURE}: condition for authenticator ${s.id} is not met.`)},a;if(!s.conditionWeightedThreshold||!s.threshold)throw new Error("Expected conditionWeightedThreshold and threshold");const d=[],f=s.threshold;let l=0;const u=mh(s.conditionWeightedThreshold,function(b){function h(g){if(a)return g;if(D&&!d.includes(D.id)&&(d.push(D.id),l+=b.weight,l>=f))return a=1,s}const p=b.condition;let D;const w=ph(function(){if(p.type===Sr){if(!i.didAuthenticator)throw new Error("Expected didAuthenticator");const g={...i,didAuthenticator:{didResolutionResult:i.didAuthenticator?.didResolutionResult,authenticators:[p],issuer:p.id}};return Promise.resolve(Ar(e,g)).then(function({verified:y}){y&&(D=p)})}else return Promise.resolve(kr({header:t,payload:n,data:r,signature:o},p)).then(function(g){D=g})},function(g){if(!g.message.startsWith(L.INVALID_SIGNATURE))throw g});return w&&w.then?w.then(h):h(w)},function(){return a});return Promise.resolve(u&&u.then?u.then(c):c(u))}catch(c){return Promise.reject(c)}};function mh(e,t,n){if(typeof e[Uo]=="function"){let f=function(l){try{for(;!(o=r.next()).done&&(!n||!n());)if(l=t(o.value),l&&l.then)if(Li(l))l=l.v;else{l.then(f,i||(i=ae.bind(null,s=new Qe,2)));return}s?ae(s,1,l):s=l}catch(u){ae(s||(s=new Qe),2,u)}};var r=e[Uo](),o,s,i;if(f(),r.return){var c=function(l){try{o.done||r.return()}catch{}return l};if(s&&s.then)return s.then(c,function(l){throw c(l)});c()}return s}if(!("length"in e))throw new TypeError("Object is not iterable");for(var a=[],d=0;d<e.length;d++)a.push(e[d]);return yh(a,function(f){return t(a[f])},n)}const Eh=function(e,{header:t,payload:n,signature:r,data:o},s,i){try{if(s.conditionWeightedThreshold)return gh(e,{header:t,payload:n,data:o,signature:r},s,i);if(s.conditionDelegated)return wh(e,{header:t,payload:n,data:o,signature:r},s,i);throw new Error(`${L.INVALID_JWT}: conditional proof type did not find condition for authenticator ${s.id}.`)}catch(c){return Promise.reject(c)}},No=function(e,{header:t,payload:n,signature:r,data:o},s,i){try{return s.type===Sr?Eh(e,{payload:n,header:t,signature:r,data:o},s,i):Promise.resolve(kr({header:t,payload:n,data:o,signature:r},[s]))}catch(c){return Promise.reject(c)}},Sr="ConditionalProof2022";function ie(e,t,n){if(!e.s){if(n instanceof wt)if(n.s)t&1&&(t=n.s),n=n.v;else{n.o=ie.bind(null,e,t);return}if(n&&n.then){n.then(ie.bind(null,e,t),ie.bind(null,e,2));return}e.s=t,e.v=n;const r=e.o;r&&r(e)}}const wt=(function(){function e(){}return e.prototype.then=function(t,n){const r=new e,o=this.s;if(o){const s=o&1?t:n;if(s){try{ie(r,1,s(this.v))}catch(i){ie(r,2,i)}return r}else return this}return this.o=function(s){try{const i=s.v;s.s&1?ie(r,1,t?t(i):i):n?ie(r,1,n(i)):ie(r,2,i)}catch(i){ie(r,2,i)}},r},e})();function st(e){return e instanceof wt&&e.s&1}function Dh(e,t,n){var r=-1,o,s;function i(c){try{for(;++r<e.length&&(!n||!n());)if(c=t(r),c&&c.then)if(st(c))c=c.v;else{c.then(i,s||(s=ie.bind(null,o=new wt,2)));return}o?ie(o,1,c):o=c}catch(a){ie(o||(o=new wt),2,a)}}return i(),o}function xh(e,t){try{var n=e()}catch(r){return t(r)}return n&&n.then?n.then(void 0,t):n}function vh(e,t,n){for(var r;;){var o=e();if(st(o)&&(o=o.v),!o)return s;if(o.then){r=0;break}var s=n();if(s&&s.then)if(st(s))s=s.s;else{r=1;break}var i}var c=new wt,a=ie.bind(null,c,2);return(r===0?o.then(f):r===1?s.then(d):i.then(l)).then(void 0,a),c;function d(u){s=u;do{if(o=e(),!o||st(o)&&!o.v){ie(c,1,s);return}if(o.then){o.then(f).then(void 0,a);return}s=n(),st(s)&&(s=s.v)}while(!s||!s.then);s.then(d).then(void 0,a)}function f(u){u?(s=n(),s&&s.then?s.then(d).then(void 0,a):d(s)):ie(c,1,s)}function l(){(o=e())?o.then?o.then(f).then(void 0,a):f(o):ie(c,1,s)}}const Fi=function(e,t,n,r){try{const o=Xl[t];if(!o||o.length===0)throw new Error(`${L.NOT_SUPPORTED}: No supported signature types for algorithm ${t}`);let s;return Promise.resolve(e.resolve(n,{accept:Mo})).then(function(i){if(Object.getOwnPropertyNames(i).indexOf("didDocument")===-1?s={didDocument:i,didDocumentMetadata:{},didResolutionMetadata:{contentType:Mo}}:s=i,s.didResolutionMetadata?.error||s.didDocument==null){const{error:f,message:l}=s.didResolutionMetadata;throw new Error(`${L.RESOLVER_ERROR}: Unable to resolve DID document for ${n}: ${f}, ${l||""}`)}const c=(f,l)=>{const u=f.filter(({id:b})=>l===b);return u.length>0?u[0]:null};let a=[...s?.didDocument?.verificationMethod||[],...s?.didDocument?.publicKey||[]];typeof r=="string"&&(r.startsWith("assertion")&&!Object.getOwnPropertyNames(s?.didDocument).includes("assertionMethod")&&(s.didDocument={...s.didDocument},s.didDocument.assertionMethod=[...a.map(f=>f.id)]),a=(s.didDocument[r]||[]).map(f=>typeof f=="string"?c(a,f):typeof f.publicKey=="string"?c(a,f.publicKey):f).filter(f=>f!=null));const d=a.filter(({type:f})=>o.find(l=>l===f));if(typeof r=="string"&&(!d||d.length===0))throw new Error(`${L.NO_SUITABLE_KEYS}: DID document for ${n} does not have public keys suitable for ${t} with ${r} purpose`);if(!d||d.length===0)throw new Error(`${L.NO_SUITABLE_KEYS}: DID document for ${n} does not have public keys for ${t}`);return{authenticators:d,issuer:n,didResolutionResult:s}})}catch(o){return Promise.reject(o)}},Ar=function(e,t={resolver:void 0,auth:void 0,audience:void 0,callbackUrl:void 0,skewTime:void 0,proofPurpose:void 0,policies:{},didAuthenticator:void 0}){try{let n=function(){let b;function h(g){if(D){const y=typeof t.policies?.now=="number"?t.policies.now:Math.floor(Date.now()/1e3),S=typeof t.skewTime<"u"&&t.skewTime>=0?t.skewTime:_h,E=y+S;if(t.policies?.nbf!==!1&&r.nbf){if(r.nbf>E)throw new Error(`${L.INVALID_JWT}: JWT not valid before nbf: ${r.nbf}`)}else if(t.policies?.iat!==!1&&r.iat&&r.iat>E)throw new Error(`${L.INVALID_JWT}: JWT not valid yet (issued in the future) iat: ${r.iat}`);if(t.policies?.exp!==!1&&r.exp&&r.exp<=y-S)throw new Error(`${L.INVALID_JWT}: JWT has expired: exp: ${r.exp} < now: ${y}`);if(t.policies?.aud!==!1&&r.aud){if(!t.audience&&!t.callbackUrl)throw new Error(`${L.INVALID_AUDIENCE}: JWT audience is required but your app address has not been configured`);if(typeof(Array.isArray(r.aud)?r.aud:[r.aud]).find(A=>t.audience===A||t.callbackUrl===A)>"u")throw new Error(`${L.INVALID_AUDIENCE}: JWT audience does not match your DID or callback url`)}return{verified:!0,payload:r,didResolutionResult:l,issuer:f,signer:D,jwt:e,policies:t.policies}}throw new Error(`${L.INVALID_SIGNATURE}: JWT not valid. issuer DID document does not contain a verificationMethod that matches the signature.`)}const{did:p}=Ii(a);let D=null;const w=(function(){if(p!==a){const g=d.find(y=>y.id===a);if(!g)throw new Error(`${L.INVALID_JWT}: No authenticator found for did URL ${a}`);return Promise.resolve(No(e,{payload:r,header:o,signature:s,data:i},g,t)).then(function(y){D=y})}else{let g=0;return vh(function(){return!b&&!D&&g<d.length},void 0,function(){function y(m){g++}const S=d[g],E=xh(function(){return Promise.resolve(No(e,{payload:r,header:o,signature:s,data:i},S,t)).then(function(m){D=m})},function(m){if(!m.message.includes(L.INVALID_SIGNATURE)||g===d.length-1)throw m});return E&&E.then?E.then(y):y(E)})}})();return w&&w.then?w.then(h):h(w)};if(!t.resolver)throw new Error("missing_resolver: No DID resolver has been configured");const{payload:r,header:o,signature:s,data:i}=dn(e,!1),c=Object.prototype.hasOwnProperty.call(t,"auth")?t.auth?"authentication":void 0:t.proofPurpose;let a;if(!r.iss&&!r.client_id)throw new Error(`${L.INVALID_JWT}: JWT iss or client_id are required`);if(t.didAuthenticator)a=t.didAuthenticator.issuer;else if(r.iss===kh||r.iss===Th){if(!r.sub)throw new Error(`${L.INVALID_JWT}: JWT sub is required`);typeof r.sub_jwk>"u"?a=r.sub:a=(o.kid||"").split("#")[0]}else if(r.iss===Ih){if(!r.did)throw new Error(`${L.INVALID_JWT}: JWT did is required`);a=r.did}else if(!r.iss&&r.scope==="openid"&&r.redirect_uri){if(!r.client_id)throw new Error(`${L.INVALID_JWT}: JWT client_id is required`);a=r.client_id}else a=r.iss;if(!a)throw new Error(`${L.INVALID_JWT}: No DID has been found in the JWT`);let d,f,l;const u=(function(){if(t.didAuthenticator)({didResolutionResult:l,authenticators:d,issuer:f}=t.didAuthenticator);else return Promise.resolve(Fi(t.resolver,o.alg,a,c)).then(function(b){({didResolutionResult:l,authenticators:d,issuer:f}=b),t.didAuthenticator={didResolutionResult:l,authenticators:d,issuer:f}})})();return Promise.resolve(u&&u.then?u.then(n):n(u))}catch(n){return Promise.reject(n)}},Sh=function(e,{expiresIn:t,canonicalize:n},r){try{if(r.length===0)throw new Error("invalid_argument: must provide one or more issuers");let o=e,s="";const i=Dh(r,function(c){const a=r[c],d={typ:"JWT",alg:a.alg};return c!==0&&(d.cty="JWT"),Promise.resolve(Vi(o,{...a,canonicalize:n,expiresIn:t},d)).then(function(f){s=f,o={jwt:s}})});return Promise.resolve(i&&i.then?i.then(function(){return s}):s)}catch(o){return Promise.reject(o)}},Vi=function(e,{issuer:t,signer:n,alg:r,expiresIn:o,canonicalize:s},i={}){try{if(!n)throw new Error("missing_signer: No Signer functionality has been configured");if(!t)throw new Error("missing_issuer: No issuing DID has been configured");i.typ||(i.typ="JWT"),i.alg||(i.alg=r);const c={iat:Math.floor(Date.now()/1e3),exp:void 0};if(o)if(typeof o=="number")c.exp=(e.nbf||c.iat)+Math.floor(o);else throw new Error("invalid_argument: JWT expiresIn is not a number");const a={...c,...e,iss:t};return Ah(a,n,i,{canonicalize:s})}catch(c){return Promise.reject(c)}},Ah=function(e,t,n={},r={}){try{n.alg||(n.alg=Ch);const o=typeof e=="string"?e:Po(e,r.canonicalize),s=[Po(n,r.canonicalize),o].join("."),i=ah(n.alg);return Promise.resolve(i(s,t)).then(function(c){return[s,c].join(".")})}catch(o){return Promise.reject(o)}},kh="https://self-issued.me/v2",Th="https://self-issued.me/v2/openid-vc",Ih="https://self-issued.me",Ch="ES256K",Mo="application/did+json";function Po(e,t=!1){return Bo(t?_l(e):JSON.stringify(e))}const _h=300;function Bh(e){const t=e.match(/^([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)\.([a-zA-Z0-9_-]+)$/);if(t)return{header:JSON.parse(Ni(t[1])),payload:t[2],signature:t[3],data:`${t[1]}.${t[2]}`};throw new Error("invalid_argument: Incorrect format JWS")}function dn(e,t=!0){if(!e)throw new Error("invalid_argument: no JWT passed into decodeJWT");try{const n=Bh(e),r=Object.assign(n,{payload:JSON.parse(Ni(n.payload))}),o=r.payload.iss;if(r.header.cty==="JWT"&&t){const s=dn(r.payload.jwt);if(s.payload.iss!==o)throw new Error(`${L.INVALID_JWT}: multiple issuers`);return s}return r}catch(n){throw new Error(`invalid_argument: ${L.INVALID_JWT}: ${n}`)}}function kr({header:e,payload:t,data:n,signature:r},o){Array.isArray(o)||(o=[o]);const s=t.iss;let i=!0;do{if(s!==t.iss)throw new Error(`${L.INVALID_JWT}: multiple issuers`);try{return ji(e.alg)(n,r,o)}catch(c){if(!c.message.startsWith(L.INVALID_SIGNATURE))throw c}e.cty!=="JWT"?i=!1:{payload:t,header:e,signature:r,data:n}=dn(t.jwt,!1)}while(i);throw new Error(`${L.INVALID_SIGNATURE}: no matching public key found`)}typeof Symbol<"u"&&(Symbol.iterator||(Symbol.iterator=Symbol("Symbol.iterator")));var kn,Ho;function $h(){if(Ho)return kn;Ho=1;function e(t,n){for(let r=0;r<t.byteLength;r++){if(t[r]<n[r])return-1;if(t[r]>n[r])return 1}return t.byteLength>n.byteLength?1:t.byteLength<n.byteLength?-1:0}return kn=e,kn}var Tn,jo;function Rh(){if(jo)return Tn;jo=1;function e(t,n){n||(n=t.reduce((s,i)=>s+i.length,0));const r=new Uint8Array(n);let o=0;for(const s of t)r.set(s,o),o+=s.length;return r}return Tn=e,Tn}var In,Lo;function Oh(){if(Lo)return In;Lo=1;function e(t,n){if(t===n)return!0;if(t.byteLength!==n.byteLength)return!1;for(let r=0;r<t.byteLength;r++)if(t[r]!==n[r])return!1;return!0}return In=e,In}const Uh=en(Bu);var Cn,Fo;function Ki(){if(Fo)return Cn;Fo=1;const{bases:e}=Uh;function t(s,i,c,a){return{name:s,prefix:i,encoder:{name:s,prefix:i,encode:c},decoder:{decode:a}}}const n=t("utf8","u",s=>"u"+new TextDecoder("utf8").decode(s),s=>new TextEncoder().encode(s.substring(1))),r=t("ascii","a",s=>{let i="a";for(let c=0;c<s.length;c++)i+=String.fromCharCode(s[c]);return i},s=>{s=s.substring(1);const i=new Uint8Array(s.length);for(let c=0;c<s.length;c++)i[c]=s.charCodeAt(c);return i});return Cn={utf8:n,"utf-8":n,hex:e.base16,latin1:r,ascii:r,binary:r,...e},Cn}var _n,Vo;function Nh(){if(Vo)return _n;Vo=1;const e=Ki();function t(n,r="utf8"){const o=e[r];if(!o)throw new Error(`Unsupported encoding "${r}"`);return o.decoder.decode(`${o.prefix}${n}`)}return _n=t,_n}var Bn,Ko;function Mh(){if(Ko)return Bn;Ko=1;const e=Ki();function t(n,r="utf8"){const o=e[r];if(!o)throw new Error(`Unsupported encoding "${r}"`);return o.encoder.encode(n).substring(1)}return Bn=t,Bn}var $n,zo;function Ph(){if(zo)return $n;zo=1;function e(t,n){if(t.length!==n.length)throw new Error("Inputs should have the same length");const r=new Uint8Array(t.length);for(let o=0;o<t.length;o++)r[o]=t[o]^n[o];return r}return $n=e,$n}var Rn,qo;function Hh(){if(qo)return Rn;qo=1;const e=$h(),t=Rh(),n=Oh(),r=Nh(),o=Mh(),s=Ph();return Rn={compare:e,concat:t,equals:n,fromString:r,toString:o,xor:s},Rn}var Ft=Hh(),On,Jo;function jh(){if(Jo)return On;Jo=1,On=r;var e=128,t=-128,n=Math.pow(2,31);function r(o,s,i){if(Number.MAX_SAFE_INTEGER&&o>Number.MAX_SAFE_INTEGER)throw r.bytes=0,new RangeError("Could not encode varint");s=s||[],i=i||0;for(var c=i;o>=n;)s[i++]=o&255|e,o/=128;for(;o&t;)s[i++]=o&255|e,o>>>=7;return s[i]=o|0,r.bytes=i-c+1,s}return On}var Un,Wo;function Lh(){if(Wo)return Un;Wo=1,Un=n;var e=128,t=127;function n(r,i){var s=0,i=i||0,c=0,a=i,d,f=r.length;do{if(a>=f||c>49)throw n.bytes=0,new RangeError("Could not decode varint");d=r[a++],s+=c<28?(d&t)<<c:(d&t)*Math.pow(2,c),c+=7}while(d>=e);return n.bytes=a-i,s}return Un}var Nn,Zo;function Fh(){if(Zo)return Nn;Zo=1;var e=Math.pow(2,7),t=Math.pow(2,14),n=Math.pow(2,21),r=Math.pow(2,28),o=Math.pow(2,35),s=Math.pow(2,42),i=Math.pow(2,49),c=Math.pow(2,56),a=Math.pow(2,63);return Nn=function(d){return d<e?1:d<t?2:d<n?3:d<r?4:d<o?5:d<s?6:d<i?7:d<c?8:d<a?9:10},Nn}var Mn,Go;function Tr(){return Go||(Go=1,Mn={encode:jh(),decode:Lh(),encodingLength:Fh()}),Mn}const Vh=en(Fc),Kh=en(Ru),zh=en($u);var Pn,Yo;function zi(){if(Yo)return Pn;Yo=1;const e=Tr(),{toString:t}=Kh,{fromString:n}=zh;Pn={numberToUint8Array:o,uint8ArrayToNumber:r,varintUint8ArrayEncode:s,varintEncode:i};function r(c){return parseInt(t(c,"base16"),16)}function o(c){let a=c.toString(16);return a.length%2===1&&(a="0"+a),n(a,"base16")}function s(c){return Uint8Array.from(e.encode(r(c)))}function i(c){return Uint8Array.from(e.encode(c))}return Pn}var Hn,Xo;function qh(){return Xo||(Xo=1,Hn={baseTable:Object.freeze({identity:0,cidv1:1,cidv2:2,cidv3:3,ip4:4,tcp:6,sha1:17,"sha2-256":18,"sha2-512":19,"sha3-512":20,"sha3-384":21,"sha3-256":22,"sha3-224":23,"shake-128":24,"shake-256":25,"keccak-224":26,"keccak-256":27,"keccak-384":28,"keccak-512":29,blake3:30,dccp:33,"murmur3-128":34,"murmur3-32":35,ip6:41,ip6zone:42,path:47,multicodec:48,multihash:49,multiaddr:50,multibase:51,dns:53,dns4:54,dns6:55,dnsaddr:56,protobuf:80,cbor:81,raw:85,"dbl-sha2-256":86,rlp:96,bencode:99,"dag-pb":112,"dag-cbor":113,"libp2p-key":114,"git-raw":120,"torrent-info":123,"torrent-file":124,"leofcoin-block":129,"leofcoin-tx":130,"leofcoin-pr":131,sctp:132,"dag-jose":133,"dag-cose":134,"eth-block":144,"eth-block-list":145,"eth-tx-trie":146,"eth-tx":147,"eth-tx-receipt-trie":148,"eth-tx-receipt":149,"eth-state-trie":150,"eth-account-snapshot":151,"eth-storage-trie":152,"eth-receipt-log-trie":153,"eth-reciept-log":154,"bitcoin-block":176,"bitcoin-tx":177,"bitcoin-witness-commitment":178,"zcash-block":192,"zcash-tx":193,"caip-50":202,streamid:206,"stellar-block":208,"stellar-tx":209,md4:212,md5:213,bmt:214,"decred-block":224,"decred-tx":225,"ipld-ns":226,"ipfs-ns":227,"swarm-ns":228,"ipns-ns":229,zeronet:230,"secp256k1-pub":231,"bls12_381-g1-pub":234,"bls12_381-g2-pub":235,"x25519-pub":236,"ed25519-pub":237,"bls12_381-g1g2-pub":238,"dash-block":240,"dash-tx":241,"swarm-manifest":250,"swarm-feed":251,udp:273,"p2p-webrtc-star":275,"p2p-webrtc-direct":276,"p2p-stardust":277,"p2p-circuit":290,"dag-json":297,udt:301,utp:302,unix:400,thread:406,p2p:421,ipfs:421,https:443,onion:444,onion3:445,garlic64:446,garlic32:447,tls:448,noise:454,quic:460,ws:477,wss:478,"p2p-websocket-star":479,http:480,"swhid-1-snp":496,json:512,messagepack:513,"libp2p-peer-record":769,"libp2p-relay-rsvp":770,"car-index-sorted":1024,"sha2-256-trunc254-padded":4114,"ripemd-128":4178,"ripemd-160":4179,"ripemd-256":4180,"ripemd-320":4181,x11:4352,"p256-pub":4608,"p384-pub":4609,"p521-pub":4610,"ed448-pub":4611,"x448-pub":4612,"ed25519-priv":4864,"secp256k1-priv":4865,"x25519-priv":4866,kangarootwelve:7425,"sm3-256":21325,"blake2b-8":45569,"blake2b-16":45570,"blake2b-24":45571,"blake2b-32":45572,"blake2b-40":45573,"blake2b-48":45574,"blake2b-56":45575,"blake2b-64":45576,"blake2b-72":45577,"blake2b-80":45578,"blake2b-88":45579,"blake2b-96":45580,"blake2b-104":45581,"blake2b-112":45582,"blake2b-120":45583,"blake2b-128":45584,"blake2b-136":45585,"blake2b-144":45586,"blake2b-152":45587,"blake2b-160":45588,"blake2b-168":45589,"blake2b-176":45590,"blake2b-184":45591,"blake2b-192":45592,"blake2b-200":45593,"blake2b-208":45594,"blake2b-216":45595,"blake2b-224":45596,"blake2b-232":45597,"blake2b-240":45598,"blake2b-248":45599,"blake2b-256":45600,"blake2b-264":45601,"blake2b-272":45602,"blake2b-280":45603,"blake2b-288":45604,"blake2b-296":45605,"blake2b-304":45606,"blake2b-312":45607,"blake2b-320":45608,"blake2b-328":45609,"blake2b-336":45610,"blake2b-344":45611,"blake2b-352":45612,"blake2b-360":45613,"blake2b-368":45614,"blake2b-376":45615,"blake2b-384":45616,"blake2b-392":45617,"blake2b-400":45618,"blake2b-408":45619,"blake2b-416":45620,"blake2b-424":45621,"blake2b-432":45622,"blake2b-440":45623,"blake2b-448":45624,"blake2b-456":45625,"blake2b-464":45626,"blake2b-472":45627,"blake2b-480":45628,"blake2b-488":45629,"blake2b-496":45630,"blake2b-504":45631,"blake2b-512":45632,"blake2s-8":45633,"blake2s-16":45634,"blake2s-24":45635,"blake2s-32":45636,"blake2s-40":45637,"blake2s-48":45638,"blake2s-56":45639,"blake2s-64":45640,"blake2s-72":45641,"blake2s-80":45642,"blake2s-88":45643,"blake2s-96":45644,"blake2s-104":45645,"blake2s-112":45646,"blake2s-120":45647,"blake2s-128":45648,"blake2s-136":45649,"blake2s-144":45650,"blake2s-152":45651,"blake2s-160":45652,"blake2s-168":45653,"blake2s-176":45654,"blake2s-184":45655,"blake2s-192":45656,"blake2s-200":45657,"blake2s-208":45658,"blake2s-216":45659,"blake2s-224":45660,"blake2s-232":45661,"blake2s-240":45662,"blake2s-248":45663,"blake2s-256":45664,"skein256-8":45825,"skein256-16":45826,"skein256-24":45827,"skein256-32":45828,"skein256-40":45829,"skein256-48":45830,"skein256-56":45831,"skein256-64":45832,"skein256-72":45833,"skein256-80":45834,"skein256-88":45835,"skein256-96":45836,"skein256-104":45837,"skein256-112":45838,"skein256-120":45839,"skein256-128":45840,"skein256-136":45841,"skein256-144":45842,"skein256-152":45843,"skein256-160":45844,"skein256-168":45845,"skein256-176":45846,"skein256-184":45847,"skein256-192":45848,"skein256-200":45849,"skein256-208":45850,"skein256-216":45851,"skein256-224":45852,"skein256-232":45853,"skein256-240":45854,"skein256-248":45855,"skein256-256":45856,"skein512-8":45857,"skein512-16":45858,"skein512-24":45859,"skein512-32":45860,"skein512-40":45861,"skein512-48":45862,"skein512-56":45863,"skein512-64":45864,"skein512-72":45865,"skein512-80":45866,"skein512-88":45867,"skein512-96":45868,"skein512-104":45869,"skein512-112":45870,"skein512-120":45871,"skein512-128":45872,"skein512-136":45873,"skein512-144":45874,"skein512-152":45875,"skein512-160":45876,"skein512-168":45877,"skein512-176":45878,"skein512-184":45879,"skein512-192":45880,"skein512-200":45881,"skein512-208":45882,"skein512-216":45883,"skein512-224":45884,"skein512-232":45885,"skein512-240":45886,"skein512-248":45887,"skein512-256":45888,"skein512-264":45889,"skein512-272":45890,"skein512-280":45891,"skein512-288":45892,"skein512-296":45893,"skein512-304":45894,"skein512-312":45895,"skein512-320":45896,"skein512-328":45897,"skein512-336":45898,"skein512-344":45899,"skein512-352":45900,"skein512-360":45901,"skein512-368":45902,"skein512-376":45903,"skein512-384":45904,"skein512-392":45905,"skein512-400":45906,"skein512-408":45907,"skein512-416":45908,"skein512-424":45909,"skein512-432":45910,"skein512-440":45911,"skein512-448":45912,"skein512-456":45913,"skein512-464":45914,"skein512-472":45915,"skein512-480":45916,"skein512-488":45917,"skein512-496":45918,"skein512-504":45919,"skein512-512":45920,"skein1024-8":45921,"skein1024-16":45922,"skein1024-24":45923,"skein1024-32":45924,"skein1024-40":45925,"skein1024-48":45926,"skein1024-56":45927,"skein1024-64":45928,"skein1024-72":45929,"skein1024-80":45930,"skein1024-88":45931,"skein1024-96":45932,"skein1024-104":45933,"skein1024-112":45934,"skein1024-120":45935,"skein1024-128":45936,"skein1024-136":45937,"skein1024-144":45938,"skein1024-152":45939,"skein1024-160":45940,"skein1024-168":45941,"skein1024-176":45942,"skein1024-184":45943,"skein1024-192":45944,"skein1024-200":45945,"skein1024-208":45946,"skein1024-216":45947,"skein1024-224":45948,"skein1024-232":45949,"skein1024-240":45950,"skein1024-248":45951,"skein1024-256":45952,"skein1024-264":45953,"skein1024-272":45954,"skein1024-280":45955,"skein1024-288":45956,"skein1024-296":45957,"skein1024-304":45958,"skein1024-312":45959,"skein1024-320":45960,"skein1024-328":45961,"skein1024-336":45962,"skein1024-344":45963,"skein1024-352":45964,"skein1024-360":45965,"skein1024-368":45966,"skein1024-376":45967,"skein1024-384":45968,"skein1024-392":45969,"skein1024-400":45970,"skein1024-408":45971,"skein1024-416":45972,"skein1024-424":45973,"skein1024-432":45974,"skein1024-440":45975,"skein1024-448":45976,"skein1024-456":45977,"skein1024-464":45978,"skein1024-472":45979,"skein1024-480":45980,"skein1024-488":45981,"skein1024-496":45982,"skein1024-504":45983,"skein1024-512":45984,"skein1024-520":45985,"skein1024-528":45986,"skein1024-536":45987,"skein1024-544":45988,"skein1024-552":45989,"skein1024-560":45990,"skein1024-568":45991,"skein1024-576":45992,"skein1024-584":45993,"skein1024-592":45994,"skein1024-600":45995,"skein1024-608":45996,"skein1024-616":45997,"skein1024-624":45998,"skein1024-632":45999,"skein1024-640":46e3,"skein1024-648":46001,"skein1024-656":46002,"skein1024-664":46003,"skein1024-672":46004,"skein1024-680":46005,"skein1024-688":46006,"skein1024-696":46007,"skein1024-704":46008,"skein1024-712":46009,"skein1024-720":46010,"skein1024-728":46011,"skein1024-736":46012,"skein1024-744":46013,"skein1024-752":46014,"skein1024-760":46015,"skein1024-768":46016,"skein1024-776":46017,"skein1024-784":46018,"skein1024-792":46019,"skein1024-800":46020,"skein1024-808":46021,"skein1024-816":46022,"skein1024-824":46023,"skein1024-832":46024,"skein1024-840":46025,"skein1024-848":46026,"skein1024-856":46027,"skein1024-864":46028,"skein1024-872":46029,"skein1024-880":46030,"skein1024-888":46031,"skein1024-896":46032,"skein1024-904":46033,"skein1024-912":46034,"skein1024-920":46035,"skein1024-928":46036,"skein1024-936":46037,"skein1024-944":46038,"skein1024-952":46039,"skein1024-960":46040,"skein1024-968":46041,"skein1024-976":46042,"skein1024-984":46043,"skein1024-992":46044,"skein1024-1000":46045,"skein1024-1008":46046,"skein1024-1016":46047,"skein1024-1024":46048,"poseidon-bls12_381-a2-fc1":46081,"poseidon-bls12_381-a2-fc1-sc":46082,"zeroxcert-imprint-256":52753,"fil-commitment-unsealed":61697,"fil-commitment-sealed":61698,"holochain-adr-v0":8417572,"holochain-adr-v1":8483108,"holochain-key-v0":9728292,"holochain-key-v1":9793828,"holochain-sig-v0":10645796,"holochain-sig-v1":10711332,"skynet-ns":11639056,"arweave-ns":11704592})}),Hn}var jn,Qo;function Jh(){if(Qo)return jn;Qo=1;const{baseTable:e}=qh(),t=zi().varintEncode,n={},r={},o={};for(const i in e){const c=i,a=e[c];n[c]=t(a);const d=c.toUpperCase().replace(/-/g,"_");r[d]=a,o[a]||(o[a]=c)}Object.freeze(n),Object.freeze(r),Object.freeze(o);const s=Object.freeze(e);return jn={nameToVarint:n,constantToCode:r,nameToCode:s,codeToName:o},jn}var Ln,es;function Wh(){if(es)return Ln;es=1;const e=Tr(),{concat:t}=Vh,n=zi(),{nameToVarint:r,constantToCode:o,nameToCode:s,codeToName:i}=Jh();function c(E,m){let k;if(E instanceof Uint8Array)k=n.varintUint8ArrayEncode(E);else if(r[E])k=r[E];else throw new Error("multicodec not recognized");return t([k,m],k.length+m.length)}function a(E){return e.decode(E),E.slice(e.decode.bytes)}function d(E){const m=e.decode(E),k=i[m];if(k===void 0)throw new Error(`Code "${m}" not found`);return k}function f(E){return i[E]}function l(E){const m=s[E];if(m===void 0)throw new Error(`Codec "${E}" not found`);return m}function u(E){return e.decode(E)}function b(E){const m=r[E];if(m===void 0)throw new Error(`Codec "${E}" not found`);return m}function h(E){return n.varintEncode(E)}function p(E){return d(E)}function D(E){return f(E)}function w(E){return l(E)}function g(E){return u(E)}function y(E){return b(E)}function S(E){return Array.from(h(E))}return Ln={addPrefix:c,rmPrefix:a,getNameFromData:d,getNameFromCode:f,getCodeFromName:l,getCodeFromData:u,getVarintFromName:b,getVarintFromCode:h,getCodec:p,getName:D,getNumber:w,getCode:g,getCodeVarint:y,getVarint:S,...o,nameToVarint:r,nameToCode:s,codeToName:i},Ln}var Zh=Wh();const Gh=nr(Zh);function Yh(e,t){const n=new Uint8Array(e.length+1);return n[0]=2+(t[t.length-1]&1),n.set(e,1),n}function Xh(e){const t=e.slice(0,e.length/2),n=e.slice(e.length/2,e.length),r=Ft.fromString(t,"base16"),o=Ft.fromString(n,"base16"),s=Yh(r,o);return Ft.toString(s,"base16")}function Qh(e){return e.slice(2)}function e0(e,t){const n=Ft.fromString(t,"base16");return t0(e,n)}function t0(e,t){const n=Gh.addPrefix(e,t);return`did:key:${me.encode(n)}`}function qi(e=0){return new Uint8Array(e)}function Ji(e,t){t==null&&(t=e.reduce((o,s)=>o+s.length,0));const n=qi(t);let r=0;for(const o of e)n.set(o,r),r+=o.length;return n}function n0(e){if(e instanceof Uint8Array&&e.constructor.name==="Uint8Array")return e;if(e instanceof ArrayBuffer)return new Uint8Array(e);if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);throw new Error("Unknown type, must be binary type")}function r0(e){return new TextEncoder().encode(e)}function o0(e){return new TextDecoder().decode(e)}function s0(e,t){if(e.length>=255)throw new TypeError("Alphabet too long");for(var n=new Uint8Array(256),r=0;r<n.length;r++)n[r]=255;for(var o=0;o<e.length;o++){var s=e.charAt(o),i=s.charCodeAt(0);if(n[i]!==255)throw new TypeError(s+" is ambiguous");n[i]=o}var c=e.length,a=e.charAt(0),d=Math.log(c)/Math.log(256),f=Math.log(256)/Math.log(c);function l(h){if(h instanceof Uint8Array||(ArrayBuffer.isView(h)?h=new Uint8Array(h.buffer,h.byteOffset,h.byteLength):Array.isArray(h)&&(h=Uint8Array.from(h))),!(h instanceof Uint8Array))throw new TypeError("Expected Uint8Array");if(h.length===0)return"";for(var p=0,D=0,w=0,g=h.length;w!==g&&h[w]===0;)w++,p++;for(var y=(g-w)*f+1>>>0,S=new Uint8Array(y);w!==g;){for(var E=h[w],m=0,k=y-1;(E!==0||m<D)&&k!==-1;k--,m++)E+=256*S[k]>>>0,S[k]=E%c>>>0,E=E/c>>>0;if(E!==0)throw new Error("Non-zero carry");D=m,w++}for(var A=y-D;A!==y&&S[A]===0;)A++;for(var T=a.repeat(p);A<y;++A)T+=e.charAt(S[A]);return T}function u(h){if(typeof h!="string")throw new TypeError("Expected String");if(h.length===0)return new Uint8Array;var p=0;if(h[p]!==" "){for(var D=0,w=0;h[p]===a;)D++,p++;for(var g=(h.length-p)*d+1>>>0,y=new Uint8Array(g);h[p];){var S=n[h.charCodeAt(p)];if(S===255)return;for(var E=0,m=g-1;(S!==0||E<w)&&m!==-1;m--,E++)S+=c*y[m]>>>0,y[m]=S%256>>>0,S=S/256>>>0;if(S!==0)throw new Error("Non-zero carry");w=E,p++}if(h[p]!==" "){for(var k=g-w;k!==g&&y[k]===0;)k++;for(var A=new Uint8Array(D+(g-k)),T=D;k!==g;)A[T++]=y[k++];return A}}}function b(h){var p=u(h);if(p)return p;throw new Error(`Non-${t} character`)}return{encode:l,decodeUnsafe:u,decode:b}}var i0=s0,a0=i0;class c0{name;prefix;baseEncode;constructor(t,n,r){this.name=t,this.prefix=n,this.baseEncode=r}encode(t){if(t instanceof Uint8Array)return`${this.prefix}${this.baseEncode(t)}`;throw Error("Unknown type, must be binary type")}}class d0{name;prefix;baseDecode;prefixCodePoint;constructor(t,n,r){this.name=t,this.prefix=n;const o=n.codePointAt(0);if(o===void 0)throw new Error("Invalid prefix character");this.prefixCodePoint=o,this.baseDecode=r}decode(t){if(typeof t=="string"){if(t.codePointAt(0)!==this.prefixCodePoint)throw Error(`Unable to decode multibase string ${JSON.stringify(t)}, ${this.name} decoder only supports inputs prefixed with ${this.prefix}`);return this.baseDecode(t.slice(this.prefix.length))}else throw Error("Can only multibase decode strings")}or(t){return Wi(this,t)}}class u0{decoders;constructor(t){this.decoders=t}or(t){return Wi(this,t)}decode(t){const n=t[0],r=this.decoders[n];if(r!=null)return r.decode(t);throw RangeError(`Unable to decode multibase string ${JSON.stringify(t)}, only inputs prefixed with ${Object.keys(this.decoders)} are supported`)}}function Wi(e,t){return new u0({...e.decoders??{[e.prefix]:e},...t.decoders??{[t.prefix]:t}})}class f0{name;prefix;baseEncode;baseDecode;encoder;decoder;constructor(t,n,r,o){this.name=t,this.prefix=n,this.baseEncode=r,this.baseDecode=o,this.encoder=new c0(t,n,r),this.decoder=new d0(t,n,o)}encode(t){return this.encoder.encode(t)}decode(t){return this.decoder.decode(t)}}function un({name:e,prefix:t,encode:n,decode:r}){return new f0(e,t,n,r)}function At({name:e,prefix:t,alphabet:n}){const{encode:r,decode:o}=a0(n,e);return un({prefix:t,name:e,encode:r,decode:s=>n0(o(s))})}function l0(e,t,n,r){let o=e.length;for(;e[o-1]==="=";)--o;const s=new Uint8Array(o*n/8|0);let i=0,c=0,a=0;for(let d=0;d<o;++d){const f=t[e[d]];if(f===void 0)throw new SyntaxError(`Non-${r} character`);c=c<<n|f,i+=n,i>=8&&(i-=8,s[a++]=255&c>>i)}if(i>=n||(255&c<<8-i)!==0)throw new SyntaxError("Unexpected end of data");return s}function h0(e,t,n){const r=t[t.length-1]==="=",o=(1<<n)-1;let s="",i=0,c=0;for(let a=0;a<e.length;++a)for(c=c<<8|e[a],i+=8;i>n;)i-=n,s+=t[o&c>>i];if(i!==0&&(s+=t[o&c<<n-i]),r)for(;(s.length*n&7)!==0;)s+="=";return s}function b0(e){const t={};for(let n=0;n<e.length;++n)t[e[n]]=n;return t}function te({name:e,prefix:t,bitsPerChar:n,alphabet:r}){const o=b0(r);return un({prefix:t,name:e,encode(s){return h0(s,r,n)},decode(s){return l0(s,o,n,e)}})}const p0=At({prefix:"9",name:"base10",alphabet:"0123456789"}),w0=Object.freeze(Object.defineProperty({__proto__:null,base10:p0},Symbol.toStringTag,{value:"Module"})),y0=te({prefix:"f",name:"base16",alphabet:"0123456789abcdef",bitsPerChar:4}),g0=te({prefix:"F",name:"base16upper",alphabet:"0123456789ABCDEF",bitsPerChar:4}),m0=Object.freeze(Object.defineProperty({__proto__:null,base16:y0,base16upper:g0},Symbol.toStringTag,{value:"Module"})),E0=te({prefix:"0",name:"base2",alphabet:"01",bitsPerChar:1}),D0=Object.freeze(Object.defineProperty({__proto__:null,base2:E0},Symbol.toStringTag,{value:"Module"})),Zi=Array.from("🚀🪐☄🛰🌌🌑🌒🌓🌔🌕🌖🌗🌘🌍🌏🌎🐉☀💻🖥💾💿😂❤😍🤣😊🙏💕😭😘👍😅👏😁🔥🥰💔💖💙😢🤔😆🙄💪😉☺👌🤗💜😔😎😇🌹🤦🎉💞✌✨🤷😱😌🌸🙌😋💗💚😏💛🙂💓🤩😄😀🖤😃💯🙈👇🎶😒🤭❣😜💋👀😪😑💥🙋😞😩😡🤪👊🥳😥🤤👉💃😳✋😚😝😴🌟😬🙃🍀🌷😻😓⭐✅🥺🌈😈🤘💦✔😣🏃💐☹🎊💘😠☝😕🌺🎂🌻😐🖕💝🙊😹🗣💫💀👑🎵🤞😛🔴😤🌼😫⚽🤙☕🏆🤫👈😮🙆🍻🍃🐶💁😲🌿🧡🎁⚡🌞🎈❌✊👋😰🤨😶🤝🚶💰🍓💢🤟🙁🚨💨🤬✈🎀🍺🤓😙💟🌱😖👶🥴▶➡❓💎💸⬇😨🌚🦋😷🕺⚠🙅😟😵👎🤲🤠🤧📌🔵💅🧐🐾🍒😗🤑🌊🤯🐷☎💧😯💆👆🎤🙇🍑❄🌴💣🐸💌📍🥀🤢👅💡💩👐📸👻🤐🤮🎼🥵🚩🍎🍊👼💍📣🥂"),x0=Zi.reduce((e,t,n)=>(e[n]=t,e),[]),v0=Zi.reduce((e,t,n)=>{const r=t.codePointAt(0);if(r==null)throw new Error(`Invalid character: ${t}`);return e[r]=n,e},[]);function S0(e){return e.reduce((t,n)=>(t+=x0[n],t),"")}function A0(e){const t=[];for(const n of e){const r=n.codePointAt(0);if(r==null)throw new Error(`Invalid character: ${n}`);const o=v0[r];if(o==null)throw new Error(`Non-base256emoji character: ${n}`);t.push(o)}return new Uint8Array(t)}const k0=un({prefix:"🚀",name:"base256emoji",encode:S0,decode:A0}),T0=Object.freeze(Object.defineProperty({__proto__:null,base256emoji:k0},Symbol.toStringTag,{value:"Module"})),I0=te({prefix:"b",name:"base32",alphabet:"abcdefghijklmnopqrstuvwxyz234567",bitsPerChar:5}),C0=te({prefix:"B",name:"base32upper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567",bitsPerChar:5}),_0=te({prefix:"c",name:"base32pad",alphabet:"abcdefghijklmnopqrstuvwxyz234567=",bitsPerChar:5}),B0=te({prefix:"C",name:"base32padupper",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=",bitsPerChar:5}),$0=te({prefix:"v",name:"base32hex",alphabet:"0123456789abcdefghijklmnopqrstuv",bitsPerChar:5}),R0=te({prefix:"V",name:"base32hexupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV",bitsPerChar:5}),O0=te({prefix:"t",name:"base32hexpad",alphabet:"0123456789abcdefghijklmnopqrstuv=",bitsPerChar:5}),U0=te({prefix:"T",name:"base32hexpadupper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUV=",bitsPerChar:5}),N0=te({prefix:"h",name:"base32z",alphabet:"ybndrfg8ejkmcpqxot1uwisza345h769",bitsPerChar:5}),M0=Object.freeze(Object.defineProperty({__proto__:null,base32:I0,base32hex:$0,base32hexpad:O0,base32hexpadupper:U0,base32hexupper:R0,base32pad:_0,base32padupper:B0,base32upper:C0,base32z:N0},Symbol.toStringTag,{value:"Module"})),P0=At({prefix:"k",name:"base36",alphabet:"0123456789abcdefghijklmnopqrstuvwxyz"}),H0=At({prefix:"K",name:"base36upper",alphabet:"0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"}),j0=Object.freeze(Object.defineProperty({__proto__:null,base36:P0,base36upper:H0},Symbol.toStringTag,{value:"Module"})),Gi=At({name:"base58btc",prefix:"z",alphabet:"123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"}),L0=At({name:"base58flickr",prefix:"Z",alphabet:"123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"}),F0=Object.freeze(Object.defineProperty({__proto__:null,base58btc:Gi,base58flickr:L0},Symbol.toStringTag,{value:"Module"})),V0=te({prefix:"m",name:"base64",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",bitsPerChar:6}),K0=te({prefix:"M",name:"base64pad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",bitsPerChar:6}),z0=te({prefix:"u",name:"base64url",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_",bitsPerChar:6}),q0=te({prefix:"U",name:"base64urlpad",alphabet:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=",bitsPerChar:6}),J0=Object.freeze(Object.defineProperty({__proto__:null,base64:V0,base64pad:K0,base64url:z0,base64urlpad:q0},Symbol.toStringTag,{value:"Module"})),W0=te({prefix:"7",name:"base8",alphabet:"01234567",bitsPerChar:3}),Z0=Object.freeze(Object.defineProperty({__proto__:null,base8:W0},Symbol.toStringTag,{value:"Module"})),G0=un({prefix:"\0",name:"identity",encode:e=>o0(e),decode:e=>r0(e)}),Y0=Object.freeze(Object.defineProperty({__proto__:null,identity:G0},Symbol.toStringTag,{value:"Module"}));new TextEncoder;new TextDecoder;const ts={...Y0,...D0,...Z0,...w0,...m0,...M0,...j0,...F0,...J0,...T0};function Yi(e,t,n,r){return{name:e,prefix:t,encoder:{name:e,prefix:t,encode:n},decoder:{decode:r}}}const ns=Yi("utf8","u",e=>"u"+new TextDecoder("utf8").decode(e),e=>new TextEncoder().encode(e.substring(1))),Fn=Yi("ascii","a",e=>{let t="a";for(let n=0;n<e.length;n++)t+=String.fromCharCode(e[n]);return t},e=>{e=e.substring(1);const t=qi(e.length);for(let n=0;n<e.length;n++)t[n]=e.charCodeAt(n);return t}),Xi={utf8:ns,"utf-8":ns,hex:ts.base16,latin1:Fn,ascii:Fn,binary:Fn,...ts};function X0(e,t="utf8"){const n=Xi[t];if(n==null)throw new Error(`Unsupported encoding "${t}"`);return n.decoder.decode(`${n.prefix}${e}`)}function xe(e,t="utf8"){const n=Xi[t];if(n==null)throw new Error(`Unsupported encoding "${t}"`);return n.encoder.encode(e).substring(1)}var Q0=Tr();const rs=nr(Q0);function eb(e,t){const n=`did:key:${t}`,r=`${n}#${t}`;return{id:n,verificationMethod:[{id:r,type:"Secp256k1VerificationKey2018",controller:n,publicKeyBase58:xe(e,"base58btc")}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r]}}const tb=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:eb},Symbol.toStringTag,{value:"Module"}));function nb(e){const t=new Uint8Array(e.length+2);return t[0]=236,t[1]=1,t.set(e,2),`z${xe(t,"base58btc")}`}function rb(e,t){const n=`did:key:${t}`,r=`${n}#${t}`,o=Pf(e),s=`${n}#${nb(o)}`;return{id:n,verificationMethod:[{id:r,type:"Ed25519VerificationKey2018",controller:n,publicKeyBase58:xe(e,"base58btc")}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r],keyAgreement:[{id:s,type:"X25519KeyAgreementKey2019",controller:n,publicKeyBase58:xe(o,"base58btc")}]}}const ob=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:rb},Symbol.toStringTag,{value:"Module"})),et=af;function sb(e,t){const n=`did:key:${t}`,r=`${n}#${t}`,o=Jt.ProjectivePoint.fromHex(ib(e));return{id:n,verificationMethod:[{id:r,type:"JsonWebKey2020",controller:n,publicKeyJwk:{kty:"EC",crv:"P-256",x:xe(et(o.x),"base64url"),y:xe(et(o.y),"base64url")}}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r]}}function ib(e){return e.length===64?Ji([new Uint8Array([4]),e]):e}const ab=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:sb},Symbol.toStringTag,{value:"Module"}));const cb=al;function db(e,t){const n=`did:key:${t}`,r=`${n}#${t}`,o=cb.ProjectivePoint.fromHex(ub(e));return{id:n,verificationMethod:[{id:r,type:"JsonWebKey2020",controller:n,publicKeyJwk:{kty:"EC",crv:"P-384",x:xe(et(o.x),"base64url"),y:xe(et(o.y),"base64url")}}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r]}}function ub(e){return e.length===96?Ji([new Uint8Array([4]),e]):e}const fb=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:db},Symbol.toStringTag,{value:"Module"}));const lb=cl;function hb(e,t){const n=`did:key:${t}`,r=`${n}#${t}`,o=lb.ProjectivePoint.fromHex(e);return{id:n,verificationMethod:[{id:r,type:"JsonWebKey2020",controller:n,publicKeyJwk:{kty:"EC",crv:"P-521",x:xe(et(o.x),"base64url"),y:xe(et(o.y),"base64url")}}],authentication:[r],assertionMethod:[r],capabilityDelegation:[r],capabilityInvocation:[r]}}const bb=Object.freeze(Object.defineProperty({__proto__:null,keyToDidDoc:hb},Symbol.toStringTag,{value:"Module"})),pb="application/did+ld+json",os="application/did+json",wb={231:tb,237:ob,4608:ab,4609:fb,4610:bb};function yb(){return{key:async(e,t,n,r)=>{const o=r.accept||os,s={didResolutionMetadata:{contentType:o},didDocument:null,didDocumentMetadata:{}};try{const i=Gi.decode(t.id),c=rs.decode(i),a=i.slice(rs.decode.bytes),d=await wb[c].keyToDidDoc(a,t.id);o===pb?(d["@context"]="https://w3id.org/did/v1",s.didDocument=d):o===os?s.didDocument=d:(delete s.didResolutionMetadata.contentType,s.didResolutionMetadata.error="representationNotSupported")}catch(i){s.didResolutionMetadata.error="invalidDid",s.didResolutionMetadata.message=i.toString()}return s}}}const ss="ES256K",gb=/^[A-Za-z0-9-_=]+\.[A-Za-z0-9-_=]+\.?[A-Za-z0-9-_.+/=]*$/,er="https://www.w3.org/2018/credentials/v1",tr="VerifiableCredential",mb="JwtProof2020",Qi=["evidence","termsOfUse","refreshService","credentialSchema","credentialStatus"];function le(e){return Array.isArray(e)?e:[e]}function yt(e){return Array.isArray(e)?e.map(t=>yt(t)):e instanceof Date?new Date(e.getTime()):e&&typeof e=="object"?Object.getOwnPropertyNames(e).reduce((t,n)=>(Object.defineProperty(t,n,Object.getOwnPropertyDescriptor(e,n)),t[n]=yt(e[n]),t),Object.create(Object.getPrototypeOf(e))):e}function Gt(e){return e!=null}function Eb(e){if(typeof e!="object"||e===null)return e;const t={...e};return Object.keys(t).forEach(n=>t[n]===void 0&&delete t[n]),t}function Db(e){return typeof e=="object"&&e.sub&&e.iss&&e.claim&&e.iat}function xb(e){const{iat:t,nbf:n,claim:r,vc:o,...s}=e,i={...s,nbf:n||t,vc:{"@context":[er],type:[tr],credentialSubject:r}};return o&&(e.issVc=o),i}function ea(e,t=!0){let n=yt(e);Db(e)&&(n=xb(e)),n.credentialSubject={...e.credentialSubject,...e.vc?.credentialSubject},e.sub&&!e.credentialSubject?.id&&n.credentialSubject&&(n.credentialSubject.id=e.sub,t&&delete n.sub),t&&delete n.vc?.credentialSubject,(typeof e.issuer>"u"||typeof e.issuer=="object")&&(n.issuer=Eb({id:e.iss,...e.issuer}),t&&!e.issuer?.id&&delete n.iss),!e.id&&e.jti&&(n.id=n.id||n.jti,t&&delete n.jti);const r=[...le(n.type),...le(n.vc?.type)].filter(Gt);n.type=[...new Set(r)],t&&delete n.vc?.type;for(const s of Qi)e.vc&&e.vc[s]&&(n[s]||(n[s]=e.vc[s]),t&&delete n.vc[s]);const o=[...le(e.context),...le(e["@context"]),...le(e.vc?.["@context"])].filter(Gt);return n["@context"]=[...new Set(o)],t&&(delete n.context,delete n.vc?.["@context"]),!e.issuanceDate&&(e.iat||e.nbf)&&(n.issuanceDate=new Date((e.nbf||e.iat)*1e3).toISOString(),t&&(e.nbf?delete n.nbf:delete n.iat)),!e.expirationDate&&e.exp&&(n.expirationDate=new Date(e.exp*1e3).toISOString(),t&&delete n.exp),t&&n.vc&&Object.keys(n.vc).length===0&&delete n.vc,n}function is(e,t=!0){let n;try{n=dn(e)}catch{throw new TypeError("unknown credential format")}return{...ea(n.payload,t),proof:{type:mb,jwt:e}}}function ta(e,t=!0){if(typeof e=="string"){if(gb.test(e))return is(e,t);{let n;try{n=JSON.parse(e)}catch{throw new TypeError("unknown credential format")}return ta(n,t)}}else return e.proof?.jwt?yt({...is(e.proof.jwt,t),proof:e.proof}):{proof:{},...ea(e,t)}}function vb(e,t=!0){if(Array.isArray(e.credentialSubject))throw Error("credentialSubject of type array not supported");const n=yt({vc:{...e.vc},...e});n.vc=n.vc;const r={...e.credentialSubject,...e.vc?.credentialSubject};e.sub||(n.sub=e.credentialSubject?.id,t&&delete r.id);const o=[...le(e.context),...le(e["@context"]),...le(e.vc?.["@context"])].filter(Gt);n.vc["@context"]=[...new Set(o)],t&&(delete n.context,delete n["@context"]);const s=[...le(e.type),...le(e.vc?.type)].filter(Gt);if(n.vc.type=[...new Set(s)],t&&delete n.type,e.id&&Object.getOwnPropertyNames(e).indexOf("jti")===-1&&(n.jti=e.id,t&&delete n.id),e.issuanceDate&&Object.getOwnPropertyNames(e).indexOf("nbf")===-1){const i=Date.parse(e.issuanceDate);isNaN(i)||(n.nbf=Math.floor(i/1e3),t&&delete n.issuanceDate)}if(e.expirationDate&&Object.getOwnPropertyNames(e).indexOf("exp")===-1){const i=Date.parse(e.expirationDate);isNaN(i)||(n.exp=Math.floor(i/1e3),t&&delete n.expirationDate)}e.issuer&&Object.getOwnPropertyNames(e).indexOf("iss")===-1&&(typeof e.issuer=="object"?(n.iss=e.issuer?.id,t&&(delete n.issuer.id,Object.keys(n.issuer).length===0&&delete n.issuer)):typeof e.issuer=="string"&&(n.iss=e.iss||""+e.issuer,t&&delete n.issuer)),n.vc.credentialSubject=r,t&&delete n.credentialSubject;for(const i of Qi)e[i]&&(n.vc[i]||(n.vc[i]=e[i]),t&&delete n[i]);return n}const gt={SCHEMA_ERROR:"schema_error"};function Sb(e){return e&&!isNaN(e)&&Object.prototype.toString.call(e)==="[object Date]"}function mt(e){if(typeof e=="number"){if(!(Number.isInteger(e)&&e<1e11))throw new TypeError(`${gt.SCHEMA_ERROR}: "${e}" is not a unix timestamp in seconds`)}else if(typeof e=="string")mt(Math.floor(new Date(e).valueOf()/1e3));else if(!Sb(e))throw new TypeError(`${gt.SCHEMA_ERROR}: "${e}" is not a valid time`)}function na(e){const t=le(e);if(t.length<1||t.indexOf(er)===-1)throw new TypeError(`${gt.SCHEMA_ERROR}: @context is missing default context "${er}"`)}function ra(e){const t=le(e);if(t.length<1||t.indexOf(tr)===-1)throw new TypeError(`${gt.SCHEMA_ERROR}: type is missing default "${tr}"`)}function oa(e){if(Object.keys(e).length===0)throw new TypeError(`${gt.SCHEMA_ERROR}: credentialSubject must not be empty`)}const Ab=function(e,t,n={}){try{const r=n?.policies?.issuanceDate===!1?!1:void 0,o=n?.policies?.expirationDate===!1?!1:void 0;return n={...n,policies:{...n?.policies,nbf:r,exp:o,iat:r}},Promise.resolve(Ar(e,{resolver:t,...n})).then(function(s){return s.verifiableCredential=ta(s.jwt,n?.removeOriginalFields),n?.policies?.format!==!1&&Ib(s.verifiableCredential),s})}catch(r){return Promise.reject(r)}},kb=function(e,t,n={}){try{const r={iat:void 0,...vb(e,n.removeOriginalFields)};if(Tb(r),Array.isArray(t)){const o=t[0].did,s=[];for(const i of t){if(i.did!==o)throw new Error("All issuers must be the same did to comply with the Verifiable Conditions spec");s.push({issuer:i.did||r.iss||"",signer:i.signer,alg:i.alg||n.header?.alg||ss})}return Promise.resolve(Sh(r,{...n},s))}else return Promise.resolve(Vi(r,{...n,issuer:t.did||r.iss||"",signer:t.signer},{...n.header,alg:t.alg||n.header?.alg||ss}))}catch(r){return Promise.reject(r)}};function Tb(e){na(e.vc["@context"]),ra(e.vc.type),oa(e.vc.credentialSubject),e.nbf&&mt(e.nbf),e.exp&&mt(e.exp)}function Ib(e){na(e["@context"]),ra(e.type),oa(e.credentialSubject),e.issuanceDate&&mt(e.issuanceDate),e.expirationDate&&mt(e.expirationDate)}function Cb(e){const t=e.split(":");if(!e.startsWith("did:pkh:")||t.length!==5)throw new Error("Invalid pkh did");const[,,n,r,o]=t;if(!o.startsWith("0x"))throw new Error(`Invalid address: ${o}`);const s=Number(r);if(isNaN(s))throw new Error(`Invalid chain id: ${r}`);return{chainId:s,networkId:n,address:o}}async function _b(e){try{const t=parseInt(String(Date.now()/1e3)),n=await Ab(e,Bb(),{policies:{now:parseInt(String(Date.now()/1e3)),expirationDate:!0,issuanceDate:!0}});return n.payload.exp&&n.payload.exp<t?!1:n}catch(t){return console.error(t),!1}}async function sa(e,t,n,r,o){const s={sub:r.did,vc:{"@context":["https://www.w3.org/2018/credentials/v1"],type:["VerifiableCredential"],credentialSubject:{chainId:e,networkId:t,address:n}},aud:o?.aud};return await kb(s,r,{expiresIn:o?.expiresIn})}const Bb=()=>{const e=yb();if(!e)throw new Error("Failed to get key resolver");return new Kl(e)};class pe{static#e="browserKeyDB";static#t="keyPairs";static#n="keyPair";#o;constructor(){this.#o=this.#r()}#r(){return new Promise((t,n)=>{const r=indexedDB.open(pe.#e);r.onupgradeneeded=this.#s,r.onsuccess=()=>this.#c(r.result,t,n),r.onerror=()=>n(r.error)})}#s=t=>{const n=t.target.result;this.#a(n)};#c=(t,n,r)=>{if(t.objectStoreNames.contains(pe.#t))n(t);else{const o=t.version;t.close();const s=indexedDB.open(pe.#e,o+1);s.onupgradeneeded=this.#s,s.onsuccess=()=>n(s.result),s.onerror=()=>r(s.error)}};#a(t){t.objectStoreNames.contains(pe.#t)||t.createObjectStore(pe.#t)}async#i(t="readwrite"){return(await this.#o).transaction(pe.#t,t).objectStore(pe.#t)}async saveKeyPair(t){const r=(await this.#i()).put(t,pe.#n);return new Promise((o,s)=>{r.onsuccess=()=>{o()},r.onerror=()=>{s(new Error("Failed to save key pair"))}})}async loadKeyPair(){const n=(await this.#i("readonly")).get(pe.#n);return new Promise((r,o)=>{n.onsuccess=()=>{const s=n.result;r(s)},n.onerror=()=>{o(new Error("Failed to load key pair"))}})}}const $b="eip155",Rb=1;function Ob(e){return Array.prototype.map.call(new Uint8Array(e),t=>("00"+t.toString(16)).slice(-2)).join("")}class Ze{#e;#t;#n;#o;#r;static algorithm={name:"ECDSA",namedCurve:"P-256"};static signAlgorithm={name:"ECDSA",namedCurve:"P-256",hash:"SHA-256"};constructor(t,n=globalThis.crypto.subtle){this.#n=t,this.#e=n,this.#o=this.#s()}async#s(){const t=await this.#n.loadKeyPair();return t?this.#t=await this.#d(t):(this.#t=await this.#a(),await this.#n.saveKeyPair(await this.#i())),await this.#c()}async getBearerToken(t,n,r=!1,o){const s=await this.getIssuer();if((r||!this.#r)&&(this.#r=await sa(Number(Rb),$b,n||await this.#o,s,o)),!this.#r)throw new Error("Could not create bearer token");return this.#r}did(){return this.#o}async regenerateDid(){this.#t=await this.#a(),await this.#n.saveKeyPair(await this.#i())}async#c(){if(!this.#t)throw new Error("No key pair available");const t=await this.#e.exportKey("raw",this.#t.publicKey),n="p256-pub",r=Qh(Ob(t)),o=Xh(r);return e0(n,o)}async#a(){return await this.#e.generateKey(Ze.algorithm,!0,["sign","verify"])}async#i(){if(!this.#t)throw new Error("No key pair available");return{publicKey:await this.#e.exportKey("jwk",this.#t.publicKey),privateKey:await this.#e.exportKey("jwk",this.#t.privateKey)}}async#d(t){return{publicKey:await this.#e.importKey("jwk",t.publicKey,Ze.algorithm,!0,["verify"]),privateKey:await this.#e.importKey("jwk",t.privateKey,Ze.algorithm,!0,["sign"])}}#f=async(...t)=>await this.#e.sign(...t);#l=async(...t)=>await this.#e.verify(...t);#u(t){return X0(t,"utf-8")}async sign(t){if(this.#t?.privateKey){const n=typeof t=="string"?this.#u(t):t,r=await this.#e.sign(Ze.signAlgorithm,this.#t.privateKey,n.buffer);return new Uint8Array(r)}else throw new Error("No private key available")}async getIssuer(){if(!this.#t?.privateKey)throw new Error("No private key available");return{did:await this.#o,signer:async t=>{const n=await this.sign(typeof t=="string"?new TextEncoder().encode(t):t);return xr(n)},alg:"ES256"}}}const Ub="https://www.renown.id";class Nb{#e;#t;#n;#o;constructor(t,n,r,o=Ub){this.#t=t,this.#o=n,this.#n=r,this.#e=o,this.user&&this.login(this.user.did).catch(()=>{})}get user(){return this.#t.get("user")}#r(t){t?this.#t.set("user",t):this.#t.delete("user"),this.#o.emit("user",t)}set connectId(t){this.#n=t;const n=this.user;this.#r(void 0),n&&this.login(n.did).catch(r=>{console.log("User no longer authenticated:",r)})}async login(t){try{const n=Cb(t),r=await this.#s(n.address,n.chainId,this.#n);if(!r)throw this.#r(void 0),new Error("Credential not found");const o={...n,did:t,credential:r};return this.#r(o),o}catch(n){throw this.#r(void 0),n}}logout(){return this.#r(void 0),Promise.resolve()}on(t,n){return this.#o.on(t,n)}async#s(t,n,r){if(!this.#e)throw new Error("RENOWN_URL is not set");const o=new URL(`/api/auth/credential?address=${encodeURIComponent(t)}&chainId=${encodeURIComponent(n)}&connectId=${encodeURIComponent(r)}`,this.#e),s=await fetch(o,{method:"GET"});if(s.ok)return(await s.json()).credential;throw new Error("Failed to get credential")}async verifyBearerToken(t){return _b(t)}async createBearerToken(t,n,r,o){if(!this.user)throw new Error("User not found");return sa(n,this.#n,t,r,o)}}class as extends CustomEvent{constructor(t,n){super(t,{detail:n})}}class Mb{#e=new EventTarget;on(t,n){const r=o=>{o instanceof as&&n(o.detail)};return this.#e.addEventListener(t.toString(),r),()=>{this.#e.removeEventListener(t.toString(),r)}}emit(t,n){const r=new as(t.toString(),n);this.#e.dispatchEvent(r)}}class Pb{namespace;constructor(t){this.namespace=t}}class Hb extends Pb{constructor(t,n){super(`${n}:${t}`)}#e(t){return`${this.namespace}:${t.toString()}`}get(t){const n=localStorage.getItem(this.#e(t));if(n)return JSON.parse(n)}set(t,n){return n?localStorage.setItem(this.#e(t),JSON.stringify(n)):localStorage.removeItem(this.#e(t))}delete(t){return localStorage.removeItem(this.#e(t))}}function dw(e,t,n){return new Nb(new Hb("renown",t),new Mb,e,n)}const Ir=_("drives"),ia=Ir.useValue,jb=Ir.setValue,Lb=Ir.addEventHandler;function Fb(e){return e.reduce((t,n)=>(n.status==="fulfilled"?t.push(n.value):console.warn(n.reason),t),[])}function uw(e){if(!e)return"PUBLIC";const t="readContext"in e,{sharingType:n}=t?{sharingType:"PUBLIC"}:e.state.local,r=n?.toUpperCase();return r==="PRIVATE"?"LOCAL":r}function fw(e){if(!e)return!1;const t="readContext"in e,{availableOffline:n}=t?{availableOffline:!1}:e.state.local;return n??!1}async function Vb(e){if(!e)return[];const t=await e.getDrives(),n=await Promise.allSettled(t.map(r=>e.getDrive(r)));return Fb(n)}function lw(e,t){if(t==="LOCAL")return;const n=window.ph?.reactor;if(n)try{const r=n.getSyncStatus(e);return r instanceof Za?"INITIAL_SYNC":r}catch(r){return console.error(r),"ERROR"}}function Kb(e){return e?.state.local.triggers.find(t=>t.type==="PullResponder")}function aa(e){return Kb(e)?.data?.url}function ca(e){if(!e)return;const t=aa(e);if("remoteUrl"in e.state.global){const n=e.state.global.remoteUrl;if(typeof n=="string")return n}return t}function zb(e){const t=ca(e),n=aa(e);return t!==void 0||n!==void 0}const hw=(e={})=>{const t=e.defaultDrivesUrl||[];return{defaultDrives:{remoteDrives:t.map(r=>({url:r,options:{sharingType:"PUBLIC",availableOffline:!0,listeners:[{block:!0,callInfo:{data:r,name:"switchboard-push",transmitterType:"SwitchboardPush"},filter:{branch:["main"],documentId:["*"],documentType:["*"],scope:["global"]},label:"Switchboard Sync",listenerId:"1",system:!0}],triggers:[]}})),removeOldRemoteDrives:t.length>0?{strategy:"preserve-by-url-and-detach",urls:t}:{strategy:"preserve-all"}}}},qb=200,Jb=1e3;async function cs(e){if(!e)return;const t=await Vb(e);jb(t)}function Wb(e=qb,t=Jb){let n=null,r=0;return(o,s=!1)=>{const i=Date.now(),c=i-r;return n!==null&&clearTimeout(n),s||c>=t?(r=i,cs(o)):new Promise(a=>{n=setTimeout(()=>{r=Date.now(),cs(o).then(a)},e)})}}const bw=Wb();async function pw(e,t,n){await Zb(e,t,n);const o=(await e.initialize())?.at(0);if(o)throw o}async function Zb(e,t,n){let r=t?.user;r instanceof Function&&(r=await r()),!(!n||!r)&&e.setGenerateJwtHandler(async o=>n.getBearerToken(o,r.address,!0,{expiresIn:10}))}async function ww(){const e=new Ze(new pe);return await e.did(),e}function da(e){switch(e.status){case"pending":return{status:"pending"};case"fulfilled":return{status:"fulfilled",value:e.value};case"rejected":return{status:"rejected",reason:e.reason};default:return e.status="pending",e.then(t=>{e.status="fulfilled",e.value=t}),e.catch(t=>{e.status="rejected",e.reason=t}),da(e)}}function yw(e){const t=new Map;return e.on("documentDeleted",n=>{t.delete(n)}),{get(n,r){const o=t.get(n);if(o&&(da(o).status==="pending"||!r))return o;const s=e.getDocument(n);return t.set(n,s),s},subscribe(n,r){const o=Array.isArray(n)?n:[n];return e.on("operationsAdded",s=>{o.includes(s)&&this.get(s,!0).then(()=>r()).catch(()=>{console.warn("Failed to refetch document",s)})})}}}const Cr=_("documentCache"),Gb=Cr.useValue,gw=Cr.setValue,Yb=Cr.addEventHandler;function Xb(e){const t=Gb(),n=Ne.useSyncExternalStore(r=>e&&t?t.subscribe(e,r):()=>{},()=>e?t?.get(e):void 0);return n?Ne.use(n):void 0}function ua(e){const t=Xb(e),[,n]=ar(t);return[t,n]}let Vt;typeof window<"u"?window.btoa?Vt=function(e){return btoa(unescape(encodeURIComponent(e)))}:Vt=function(e){const t=unescape(encodeURIComponent(e+""));let n="";for(let r,o,s=0,i="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";t.charAt(s|0)||(i="=",s%1);n+=i.charAt(63&r>>8-s%1*8)){if(o=t.charCodeAt(s+=3/4),o>255)throw new Error("'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.");r=r<<8|o}return n}:Vt=function(e){return Buffer.from(e).toString("base64")};function F(e,t){let n=ds(e,t);return(t&&t.fallback!==void 0?t.fallback:F.defaults.fallback)===!0&&n===""&&(n=ds(Vt(e),t)),n}const fa={bg:{Й:"Y",й:"y",X:"H",x:"h",Ц:"Ts",ц:"ts",Щ:"Sht",щ:"sht",Ъ:"A",ъ:"a",Ь:"Y",ь:"y"},de:{Ä:"AE",ä:"ae",Ö:"OE",ö:"oe",Ü:"UE",ü:"ue"},sr:{đ:"dj",Đ:"DJ"},uk:{И:"Y",и:"y",Й:"Y",й:"y",Ц:"Ts",ц:"ts",Х:"Kh",х:"kh",Щ:"Shch",щ:"shch",Г:"H",г:"h"}};let _r={};function ds(e,t){if(typeof e!="string")throw new Error("slug() requires a string argument, received "+typeof e);if(!e.isWellFormed())throw new Error("slug() received a malformed string with lone surrogates");typeof t=="string"&&(t={replacement:t}),t=t?Object.assign({},t):{},t.mode=t.mode||F.defaults.mode;const n=F.defaults.modes[t.mode],r=["replacement","multicharmap","charmap","remove","lower","trim"];for(let a,d=0,f=r.length;d<f;d++)a=r[d],t[a]=a in t?t[a]:n[a];const o=fa[t.locale]||_r;let s=[];for(const a in t.multicharmap){if(!Object.prototype.hasOwnProperty.call(t.multicharmap,a))continue;const d=a.length;s.indexOf(d)===-1&&s.push(d)}s=s.sort(function(a,d){return d-a});const i=t.mode==="rfc3986"?/[^\w\s\-.~]/:/[^A-Za-z0-9\s]/;let c="";for(let a,d=0,f=e.length;d<f;d++){a=e[d];let l=!1;for(let u=0;u<s.length;u++){const b=s[u],h=e.substr(d,b);if(t.multicharmap[h]){d+=b-1,a=t.multicharmap[h],l=!0;break}}l||(o[a]?a=o[a]:t.charmap[a]?a=t.charmap[a].replace(t.replacement," "):a.includes(t.replacement)?a=a.replace(t.replacement," "):a=a.replace(i,"")),c+=a}return t.remove&&(c=c.replace(t.remove,"")),t.trim&&(c=c.trim()),c=c.replace(/\s+/g,t.replacement),t.lower&&(c=c.toLowerCase()),c}const la={फ़:"Fi",ग़:"Ghi",ख़:"Khi",क़:"Qi",ड़:"ugDha",ढ़:"ugDhha",य़:"Yi",ज़:"Za",בִי:"i",בֵ:"e",בֵי:"e",בֶ:"e",בַ:"a",בָ:"a",בֹ:"o",וֹ:"o",בֻ:"u",וּ:"u",בּ:"b",כּ:"k",ךּ:"k",פּ:"p",שׁ:"sh",שׂ:"s",בְ:"e",חֱ:"e",חֲ:"a",חֳ:"o",בִ:"i"},ha={À:"A",Á:"A",Â:"A",Ã:"A",Ä:"A",Å:"A",Æ:"AE",Ç:"C",È:"E",É:"E",Ê:"E",Ë:"E",Ì:"I",Í:"I",Î:"I",Ï:"I",Ð:"D",Ñ:"N",Ò:"O",Ó:"O",Ô:"O",Õ:"O",Ö:"O",Ő:"O",Ø:"O",Ō:"O",Ù:"U",Ú:"U",Û:"U",Ü:"U",Ű:"U",Ý:"Y",Þ:"TH",ß:"ss",à:"a",á:"a",â:"a",ã:"a",ä:"a",å:"a",æ:"ae",ç:"c",è:"e",é:"e",ê:"e",ë:"e",ì:"i",í:"i",î:"i",ï:"i",ð:"d",ñ:"n",ò:"o",ó:"o",ô:"o",õ:"o",ö:"o",ő:"o",ø:"o",ō:"o",Œ:"OE",œ:"oe",ù:"u",ú:"u",û:"u",ü:"u",ű:"u",ý:"y",þ:"th",ÿ:"y","ẞ":"SS",α:"a",β:"b",γ:"g",δ:"d",ε:"e",ζ:"z",η:"h",θ:"th",ι:"i",κ:"k",λ:"l",μ:"m",ν:"n",ξ:"3",ο:"o",π:"p",ρ:"r",σ:"s",τ:"t",υ:"y",φ:"f",χ:"x",ψ:"ps",ω:"w",ά:"a",έ:"e",ί:"i",ό:"o",ύ:"y",ή:"h",ώ:"w",ς:"s",ϊ:"i",ΰ:"y",ϋ:"y",ΐ:"i",Α:"A",Β:"B",Γ:"G",Δ:"D",Ε:"E",Ζ:"Z",Η:"H",Θ:"Th",Ι:"I",Κ:"K",Λ:"L",Μ:"M",Ν:"N",Ξ:"3",Ο:"O",Π:"P",Ρ:"R",Σ:"S",Τ:"T",Υ:"Y",Φ:"F",Χ:"X",Ψ:"PS",Ω:"W",Ά:"A",Έ:"E",Ί:"I",Ό:"O",Ύ:"Y",Ή:"H",Ώ:"W",Ϊ:"I",Ϋ:"Y",ş:"s",Ş:"S",ı:"i",İ:"I",ğ:"g",Ğ:"G",а:"a",б:"b",в:"v",г:"g",д:"d",е:"e",ё:"yo",ж:"zh",з:"z",и:"i",й:"j",к:"k",л:"l",м:"m",н:"n",о:"o",п:"p",р:"r",с:"s",т:"t",у:"u",ф:"f",х:"h",ц:"c",ч:"ch",ш:"sh",щ:"sh",ъ:"u",ы:"y",ь:"",э:"e",ю:"yu",я:"ya",А:"A",Б:"B",В:"V",Г:"G",Д:"D",Е:"E",Ё:"Yo",Ж:"Zh",З:"Z",И:"I",Й:"J",К:"K",Л:"L",М:"M",Н:"N",О:"O",П:"P",Р:"R",С:"S",Т:"T",У:"U",Ф:"F",Х:"H",Ц:"C",Ч:"Ch",Ш:"Sh",Щ:"Sh",Ъ:"U",Ы:"Y",Ь:"",Э:"E",Ю:"Yu",Я:"Ya",Є:"Ye",І:"I",Ї:"Yi",Ґ:"G",є:"ye",і:"i",ї:"yi",ґ:"g",č:"c",ď:"d",ě:"e",ň:"n",ř:"r",š:"s",ť:"t",ů:"u",ž:"z",Č:"C",Ď:"D",Ě:"E",Ň:"N",Ř:"R",Š:"S",Ť:"T",Ů:"U",Ž:"Z",ľ:"l",ĺ:"l",ŕ:"r",Ľ:"L",Ĺ:"L",Ŕ:"R",ą:"a",ć:"c",ę:"e",ł:"l",ń:"n",ś:"s",ź:"z",ż:"z",Ą:"A",Ć:"C",Ę:"E",Ł:"L",Ń:"N",Ś:"S",Ź:"Z",Ż:"Z",ā:"a",ē:"e",ģ:"g",ī:"i",ķ:"k",ļ:"l",ņ:"n",ū:"u",Ā:"A",Ē:"E",Ģ:"G",Ī:"I",Ķ:"K",Ļ:"L",Ņ:"N",Ū:"U",أ:"a",إ:"i",ب:"b",ت:"t",ث:"th",ج:"g",ح:"h",خ:"kh",د:"d",ذ:"th",ر:"r",ز:"z",س:"s",ش:"sh",ص:"s",ض:"d",ط:"t",ظ:"th",ع:"aa",غ:"gh",ف:"f",ق:"k",ك:"k",ل:"l",م:"m",ن:"n",ه:"h",و:"o",ي:"y",ء:"aa",ة:"a",آ:"a",ا:"a",پ:"p",ژ:"zh",گ:"g",چ:"ch",ک:"k",ی:"i",ė:"e",į:"i",ų:"u",Ė:"E",Į:"I",Ų:"U",ț:"t",Ț:"T",ţ:"t",Ţ:"T",ș:"s",Ș:"S",ă:"a",Ă:"A",Ạ:"A",Ả:"A",Ầ:"A",Ấ:"A",Ậ:"A",Ẩ:"A",Ẫ:"A",Ằ:"A",Ắ:"A",Ặ:"A",Ẳ:"A",Ẵ:"A",Ẹ:"E",Ẻ:"E",Ẽ:"E",Ề:"E",Ế:"E",Ệ:"E",Ể:"E",Ễ:"E",Ị:"I",Ỉ:"I",Ĩ:"I",Ọ:"O",Ỏ:"O",Ồ:"O",Ố:"O",Ộ:"O",Ổ:"O",Ỗ:"O",Ơ:"O",Ờ:"O",Ớ:"O",Ợ:"O",Ở:"O",Ỡ:"O",Ụ:"U",Ủ:"U",Ũ:"U",Ư:"U",Ừ:"U",Ứ:"U",Ự:"U",Ử:"U",Ữ:"U",Ỳ:"Y",Ỵ:"Y",Ỷ:"Y",Ỹ:"Y",Đ:"D",ạ:"a",ả:"a",ầ:"a",ấ:"a",ậ:"a",ẩ:"a",ẫ:"a",ằ:"a",ắ:"a",ặ:"a",ẳ:"a",ẵ:"a",ẹ:"e",ẻ:"e",ẽ:"e",ề:"e",ế:"e",ệ:"e",ể:"e",ễ:"e",ị:"i",ỉ:"i",ĩ:"i",ọ:"o",ỏ:"o",ồ:"o",ố:"o",ộ:"o",ổ:"o",ỗ:"o",ơ:"o",ờ:"o",ớ:"o",ợ:"o",ở:"o",ỡ:"o",ụ:"u",ủ:"u",ũ:"u",ư:"u",ừ:"u",ứ:"u",ự:"u",ử:"u",ữ:"u",ỳ:"y",ỵ:"y",ỷ:"y",ỹ:"y",đ:"d",Ә:"AE",ә:"ae",Ғ:"GH",ғ:"gh",Қ:"KH",қ:"kh",Ң:"NG",ң:"ng",Ү:"UE",ү:"ue",Ұ:"U",ұ:"u",Һ:"H",һ:"h",Ө:"OE",ө:"oe",ђ:"dj",ј:"j",љ:"lj",њ:"nj",ћ:"c",џ:"dz",Ђ:"Dj",Ј:"j",Љ:"Lj",Њ:"Nj",Ћ:"C",Џ:"Dz",nj:"nj",lj:"lj",Nj:"NJ",Lj:"LJ",अ:"a",आ:"aa",ए:"e",ई:"ii",ऍ:"ei",ऎ:"ae",ऐ:"ai",इ:"i",ओ:"o",ऑ:"oi",ऒ:"oii",ऊ:"uu",औ:"ou",उ:"u",ब:"B",भ:"Bha",च:"Ca",छ:"Chha",ड:"Da",ढ:"Dha",फ:"Fa",ग:"Ga",घ:"Gha",ग़:"Ghi",ह:"Ha",ज:"Ja",झ:"Jha",क:"Ka",ख:"Kha",ख़:"Khi",ल:"L",ळ:"Li",ऌ:"Li",ऴ:"Lii",ॡ:"Lii",म:"Ma",न:"Na",ङ:"Na",ञ:"Nia",ण:"Nae",ऩ:"Ni",ॐ:"oms",प:"Pa",क़:"Qi",र:"Ra",ऋ:"Ri",ॠ:"Ri",ऱ:"Ri",स:"Sa",श:"Sha",ष:"Shha",ट:"Ta",त:"Ta",ठ:"Tha",द:"Tha",थ:"Tha",ध:"Thha",ड़:"ugDha",ढ़:"ugDhha",व:"Va",य:"Ya",य़:"Yi",ज़:"Za",ə:"e",Ə:"E",ა:"a",ბ:"b",გ:"g",დ:"d",ე:"e",ვ:"v",ზ:"z",თ:"t",ი:"i",კ:"k",ლ:"l",მ:"m",ნ:"n",ო:"o",პ:"p",ჟ:"zh",რ:"r",ს:"s",ტ:"t",უ:"u",ფ:"p",ქ:"k",ღ:"gh",ყ:"q",შ:"sh",ჩ:"ch",ც:"ts",ძ:"dz",წ:"ts",ჭ:"ch",ხ:"kh",ჯ:"j",ჰ:"h",ב:"v",גּ:"g",ג:"g",ד:"d",דּ:"d",ה:"h",ו:"v",ז:"z",ח:"h",ט:"t",י:"y",כ:"kh",ך:"kh",ל:"l",מ:"m",ם:"m",נ:"n",ן:"n",ס:"s",פ:"f",ף:"f",ץ:"ts",צ:"ts",ק:"k",ר:"r",תּ:"t",ת:"t"};F.charmap=Object.assign({},ha);F.multicharmap=Object.assign({},la);F.defaults={charmap:F.charmap,mode:"pretty",modes:{rfc3986:{replacement:"-",remove:null,lower:!0,charmap:F.charmap,multicharmap:F.multicharmap,trim:!0},pretty:{replacement:"-",remove:null,lower:!0,charmap:F.charmap,multicharmap:F.multicharmap,trim:!0}},multicharmap:F.multicharmap,fallback:!0};F.reset=function(){F.defaults.modes.rfc3986.charmap=F.defaults.modes.pretty.charmap=F.charmap=F.defaults.charmap=Object.assign({},ha),F.defaults.modes.rfc3986.multicharmap=F.defaults.modes.pretty.multicharmap=F.multicharmap=F.defaults.multicharmap=Object.assign({},la),_r=""};F.extend=function(e){const t=Object.keys(e),n={},r={};for(let o=0;o<t.length;o++)t[o].length>1?n[t[o]]=e[t[o]]:r[t[o]]=e[t[o]];Object.assign(F.charmap,r),Object.assign(F.multicharmap,n)};F.setLocale=function(e){_r=fa[e]||{}};function Yt(e){return new URL(e.replace(/^\/+/,""),window.location.origin+(window.ph?.basePath??"/")).pathname}function ba(e){const t=window.ph?.basePath??"/";return e.replace(t,t.endsWith("/")?"/":"")}function Qb(e){if(!e)return"";const t=e.name;return F(t?`${t}-${e.id}`:e.id)}function e2(e){const t=ba(e);return/^\/d\/[^/]+\/([^/]+)$/.exec(t)?.[1]}function pa(e){return e?/\b[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}\b/.exec(e)?.[0]:void 0}function t2(e){return pa(e)}function wa(e){const t=ba(e);return/^\/d\/([^/]+)/.exec(t)?.[1]??""}function n2(e){return pa(e)}function r2(e){const t=wa(e);return n2(t)}const Br=_("selectedDriveId"),ya=Br.useValue,o2=Br.setValue,s2=Br.addEventHandler;function i2(){const e=$r();if(!e[0])throw new Error("There is no drive selected. Did you mean to call 'useSelectedDriveSafe'?");return e}function $r(){const e=ya(),n=ia()?.find(s=>s.header.id===e),[r,o]=ar(n);return n?[r,o]:[void 0,void 0]}function a2(e){const t=typeof e=="string"?e:e?.header.slug,r=window.ph?.drives?.find(s=>s.header.slug===t)?.header.id;if(o2(r),!r){const s=Yt("/");if(s===window.location.pathname)return;window.history.pushState(null,"",s);return}const o=Yt(`/d/${t}`);o!==window.location.pathname&&window.history.pushState(null,"",o)}function c2(){window.addEventListener("popstate",()=>{const e=window.location.pathname,t=r2(e),n=window.ph?.selectedDriveId;t!==n&&a2(t)})}function kt(){const[e]=$r();return e?.state.global.nodes}function d2(){return kt()?.filter(t=>gs(t))}const Rr=_("selectedNodeId"),u2=Rr.useValue,ga=Rr.setValue,f2=Rr.addEventHandler;function Tt(){const e=u2();return kt()?.find(n=>n.id===e)}function ma(e){const t=typeof e=="string"?e:Qb(e),n=t2(t);ga(n);const r=wa(window.location.pathname);if(!r)return;if(!t){const s=Yt(`/d/${r}`);if(s===window.location.pathname)return;window.history.pushState(null,"",s);return}const o=Yt(`/d/${r}/${t}`);o!==window.location.pathname&&window.history.pushState(null,"",o)}function l2(){window.addEventListener("ph:selectedDriveIdUpdated",()=>{ga(void 0)})}function h2(){window.addEventListener("popstate",()=>{const e=window.location.pathname,t=e2(e),n=window.ph?.selectedNodeId;t!==n&&ma(t)})}function Or(){const e=Tt();if(gs(e))return e}function mw(){const e=kt(),n=Or()?.id;return e?Jr(n?e.filter(r=>r.parentFolder===n):e.filter(r=>!r.parentFolder)):[]}const{setValue:b2,addEventHandler:p2}=_("routerBasename"),{setValue:w2,addEventHandler:y2}=_("version"),{setValue:g2,addEventHandler:m2}=_("requiresHardRefresh"),{setValue:E2,addEventHandler:D2}=_("warnOutdatedApp"),{setValue:x2,addEventHandler:v2}=_("studioMode"),{setValue:S2,addEventHandler:A2}=_("basePath"),{setValue:k2,addEventHandler:T2}=_("versionCheckInterval"),{setValue:I2,addEventHandler:C2}=_("cliVersion"),{setValue:_2,addEventHandler:B2}=_("fileUploadOperationsChunkSize"),{setValue:$2,addEventHandler:R2}=_("isDocumentModelSelectionSettingsEnabled"),{setValue:O2,addEventHandler:U2}=_("gaTrackingId"),{setValue:N2,addEventHandler:M2}=_("defaultDrivesUrl"),{setValue:P2,addEventHandler:H2}=_("drivesPreserveStrategy"),{setValue:j2,addEventHandler:L2}=_("isLocalDrivesEnabled"),{setValue:F2,addEventHandler:V2}=_("isAddDriveEnabled"),{setValue:K2,addEventHandler:z2}=_("isPublicDrivesEnabled"),{setValue:q2,addEventHandler:J2}=_("isAddPublicDrivesEnabled"),{setValue:W2,addEventHandler:Z2}=_("isDeletePublicDrivesEnabled"),{setValue:G2,addEventHandler:Y2}=_("isCloudDrivesEnabled"),{setValue:X2,addEventHandler:Q2}=_("isAddCloudDrivesEnabled"),{setValue:ep,addEventHandler:tp}=_("isDeleteCloudDrivesEnabled");_("isLocalDrivesEnabled");const{setValue:np,addEventHandler:rp}=_("isAddLocalDrivesEnabled"),{setValue:op,addEventHandler:sp}=_("isDeleteLocalDrivesEnabled"),{setValue:ip,addEventHandler:ap}=_("isEditorDebugModeEnabled"),{setValue:cp,addEventHandler:dp}=_("isEditorReadModeEnabled"),{setValue:up,addEventHandler:fp}=_("isAnalyticsDatabaseWorkerEnabled"),{setValue:lp,addEventHandler:hp}=_("isDiffAnalyticsEnabled"),{setValue:bp,addEventHandler:pp}=_("isDriveAnalyticsEnabled"),{setValue:wp,addEventHandler:yp}=_("renownUrl"),{setValue:gp,addEventHandler:mp}=_("renownNetworkId"),{setValue:Ep,addEventHandler:Dp}=_("renownChainId"),{setValue:xp,addEventHandler:vp}=_("sentryRelease"),{setValue:Sp,addEventHandler:Ap}=_("sentryDsn"),{setValue:kp,addEventHandler:Tp}=_("sentryEnv"),{setValue:Ip,addEventHandler:Cp}=_("isSentryTracingEnabled"),{setValue:_p,addEventHandler:Bp}=_("isExternalProcessorsEnabled"),{setValue:$p,addEventHandler:Rp}=_("isExternalPackagesEnabled"),Ea=_("enabledEditors"),Op=Ea.setValue,Up=Ea.addEventHandler,Da=_("disabledEditors"),Np=Da.setValue,Mp=Da.addEventHandler,xa=_("isRelationalProcessorsEnabled"),Pp=xa.setValue,Hp=xa.addEventHandler,va=_("isExternalRelationalProcessorsEnabled"),jp=va.setValue,Lp=va.addEventHandler,Sa=_("isAnalyticsEnabled"),Fp=Sa.setValue,Vp=Sa.addEventHandler,Aa=_("isAnalyticsExternalProcessorsEnabled"),Kp=Aa.setValue,zp=Aa.addEventHandler,ka=_("analyticsDatabaseName"),qp=ka.setValue,Jp=ka.addEventHandler,Ta=_("logLevel"),Wp=Ta.setValue,Zp=Ta.addEventHandler,Ur=_("allowList"),Gp=Ur.setValue,Yp=Ur.useValue,Xp=Ur.addEventHandler,Qp={routerBasename:b2,version:w2,requiresHardRefresh:g2,warnOutdatedApp:E2,studioMode:x2,basePath:S2,versionCheckInterval:k2,cliVersion:I2,fileUploadOperationsChunkSize:_2,isDocumentModelSelectionSettingsEnabled:$2,gaTrackingId:O2,defaultDrivesUrl:N2,drivesPreserveStrategy:P2,isLocalDrivesEnabled:j2,isAddDriveEnabled:F2,isPublicDrivesEnabled:K2,isAddPublicDrivesEnabled:q2,isDeletePublicDrivesEnabled:W2,isCloudDrivesEnabled:G2,isAddCloudDrivesEnabled:X2,isDeleteCloudDrivesEnabled:ep,isAddLocalDrivesEnabled:np,isDeleteLocalDrivesEnabled:op,isEditorDebugModeEnabled:ip,isEditorReadModeEnabled:cp,isRelationalProcessorsEnabled:Pp,isExternalRelationalProcessorsEnabled:jp,isAnalyticsEnabled:Fp,analyticsDatabaseName:qp,isAnalyticsExternalProcessorsEnabled:Kp,isAnalyticsDatabaseWorkerEnabled:up,isDiffAnalyticsEnabled:lp,isDriveAnalyticsEnabled:bp,renownUrl:wp,renownNetworkId:gp,renownChainId:Ep,sentryRelease:xp,sentryDsn:Sp,sentryEnv:kp,isSentryTracingEnabled:Ip,isExternalProcessorsEnabled:_p,isExternalPackagesEnabled:$p,allowList:Gp,logLevel:Wp,disabledEditors:Np,enabledEditors:Op},e1={...Pc,...Hc,...Qp};function Nr(e,t){const n=e1[e];n(t)}function Ew(e){for(const t of Object.keys(e))Nr(t,e[t])}function t1(e){for(const t of Object.keys(e))Nr(t,e[t])}function n1(e){for(const t of Object.keys(e))Nr(t,e[t])}function Dw(e){const[t,n]=Ne.useState(!1);Ne.useEffect(()=>{t||(t1(e),n(!0))},[e,t])}function xw(e){const[t,n]=Ne.useState(!1);Ne.useEffect(()=>{t||(n1(e),n(!0))},[e,t])}function r1(e,t){const[n,r]=ua(e),o=Lc(t);if(!e||!t)return[];if(!n)throw new Ga(e);if(!o)throw new Ya(t);if(n.header.documentType!==t)throw new wc(e,t,n.header.documentType);return[n,r]}function o1(){return ys()?.map(t=>t.documentModel.global.id)}function s1(){const e=Nc(),t=o1();return e??t}function vw(e){const n=ia()?.find(s=>s.header.id===e),[r,o]=ar(n);if(!n)throw new Error(`Drive with id ${e} not found`);return[r,o]}function Ia(){return ir()?.flatMap(t=>t.modules.editorModules||[]).filter(t=>!t.documentTypes.includes("powerhouse/document-drive"))}function i1(){return ir()?.flatMap(t=>t.modules.editorModules||[]).filter(t=>t.documentTypes.includes("powerhouse/document-drive"))}function Sw(e){const t=Ia();return!e||t?.length===0?void 0:t?.filter(r=>r.documentTypes.includes(e))?.[0]}function a1(e){return i1()?.find(n=>n.id===e)}function Aw(){return a1(_c)}function kw(e){return Ia()?.find(n=>n.id===e)}function Ca(e){return d2()?.find(n=>n.id===e)}const Mr=_("modal"),Tw=Mr.useValue,fn=Mr.setValue,c1=Mr.addEventHandler;function d1(e){fn(e)}function Iw(){fn(void 0)}function Cw(e){fn({type:"createDocument",documentType:e})}function _w(e){const t=typeof e=="string"?e:e.id;fn({type:"deleteItem",id:t})}function ge(e,t){return t?.id!==e?t:void 0}function Bw(){const[e]=$r(),t=Or(),n=Tt(),r=Ca(n?.parentFolder),o=e?.header.id;async function s(u,b){if(!o)return;const h=u.name.replace(/\..+/gim,"");return vc(u,o,h,ge(o,b)?.id)}async function i(u,b){if(o)return Ac(o,u,ge(o,b)?.id)}async function c(u,b){if(!o)return;if(!ge(o,b)){console.error(`Node ${b.id} not found`);return}return await Tc(o,b.id,u)}async function a(u,b){if(!o)return;const h=ge(o,u);if(!h){console.error(`Node ${u.id} not found`);return}const p=ge(o,b);await qr(o,h,p)}async function d(u,b){if(!o)return;const h=ge(o,u);if(!h){console.error(`Node ${u.id} not found`);return}const p=ge(o,b);!p?.id&&!u.parentFolder||p?.id===u.parentFolder||await Ic(o,h,p)}async function f(u){if(!o)return;const b=ge(o,u);if(!b){console.error(`Node ${u.id} not found`);return}const h=ge(o,t??r);await qr(o,b,h)}async function l(u){if(!u||!o)return;const b=ge(o,t??r);if(!b)return;const h=await i(u,b);h&&ma(h)}return{onAddFile:s,onAddFolder:i,onRenameNode:c,onCopyNode:a,onMoveNode:d,onDuplicateNode:f,onAddAndSelectNewFolder:l}}function u1(e){return kt()?.find(n=>n.id===e)}function f1(e){const t=kt();if(!t)return[];const n=[];let r=t.find(o=>o.id===e);for(;r&&(n.push(r),!!r.parentFolder);)r=t.find(o=>o.id===r?.parentFolder);return n.reverse()}function $w(){const e=Tt();return f1(e?.id)}function l1(e){const t=u1(e);return Ca(t?.parentFolder)}function Rw(){const e=Tt();return l1(e?.id)}const Pr=_("revisionHistoryVisible"),Ow=Pr.useValue,h1=Pr.setValue,b1=Pr.addEventHandler;function Uw(){h1(!0)}function _a(){const e=Tt();return e&&Xt(e)?e.id:void 0}function Nw(){const e=_a();return ua(e)}function Mw(e){const t=_a();if(!t)throw new yc;return r1(t,e)}const Hr=_("selectedTimelineItem"),Pw=Hr.useValue,Hw=Hr.setValue,p1=Hr.addEventHandler,w1=_("selectedTimelineRevision"),y1=w1.addEventHandler,g1=e=>{const t=[];if(e.header.documentType!=="powerhouse/document-model")return t;const n=e,r=n.state.global.specifications[0],o=Object.keys(r.state).reduce((c,a)=>{const d=a;return[...c,...sc(r.state[d].initialValue,d!=="global").map(f=>({...f,message:`${f.message}. Scope: ${d}`,details:{...f.details,scope:d}}))]},[]),s=Object.keys(r.state).reduce((c,a)=>{const d=a,f=d==="global";return[...c,...ic(r.state[d].schema,n.state.global?.name||n.header.name||"",f?"":d,!f).map(l=>({...l,message:`${l.message}. Scope: ${d}`,details:{...l.details,scope:d}}))]},[]),i=ac(r.modules);return[...o,...s,...i]},jw=e=>{if(!e)return;if(g1(e).length)d1({type:"exportDocumentWithErrors",documentId:e.header.id});else return xc(e)},Lw=(e,t,n=[])=>{if(!e||!t)return 0;const r=n.find(o=>{const s=new Date(o.timestampUtcMs);return s>=e&&s<=t});return r?r.index:0};var Vn={exports:{}},us;function m1(){return us||(us=1,(function(e){var t=(function(){var n=String.fromCharCode,r="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+-$",s={};function i(a,d){if(!s[a]){s[a]={};for(var f=0;f<a.length;f++)s[a][a.charAt(f)]=f}return s[a][d]}var c={compressToBase64:function(a){if(a==null)return"";var d=c._compress(a,6,function(f){return r.charAt(f)});switch(d.length%4){default:case 0:return d;case 1:return d+"===";case 2:return d+"==";case 3:return d+"="}},decompressFromBase64:function(a){return a==null?"":a==""?null:c._decompress(a.length,32,function(d){return i(r,a.charAt(d))})},compressToUTF16:function(a){return a==null?"":c._compress(a,15,function(d){return n(d+32)})+" "},decompressFromUTF16:function(a){return a==null?"":a==""?null:c._decompress(a.length,16384,function(d){return a.charCodeAt(d)-32})},compressToUint8Array:function(a){for(var d=c.compress(a),f=new Uint8Array(d.length*2),l=0,u=d.length;l<u;l++){var b=d.charCodeAt(l);f[l*2]=b>>>8,f[l*2+1]=b%256}return f},decompressFromUint8Array:function(a){if(a==null)return c.decompress(a);for(var d=new Array(a.length/2),f=0,l=d.length;f<l;f++)d[f]=a[f*2]*256+a[f*2+1];var u=[];return d.forEach(function(b){u.push(n(b))}),c.decompress(u.join(""))},compressToEncodedURIComponent:function(a){return a==null?"":c._compress(a,6,function(d){return o.charAt(d)})},decompressFromEncodedURIComponent:function(a){return a==null?"":a==""?null:(a=a.replace(/ /g,"+"),c._decompress(a.length,32,function(d){return i(o,a.charAt(d))}))},compress:function(a){return c._compress(a,16,function(d){return n(d)})},_compress:function(a,d,f){if(a==null)return"";var l,u,b={},h={},p="",D="",w="",g=2,y=3,S=2,E=[],m=0,k=0,A;for(A=0;A<a.length;A+=1)if(p=a.charAt(A),Object.prototype.hasOwnProperty.call(b,p)||(b[p]=y++,h[p]=!0),D=w+p,Object.prototype.hasOwnProperty.call(b,D))w=D;else{if(Object.prototype.hasOwnProperty.call(h,w)){if(w.charCodeAt(0)<256){for(l=0;l<S;l++)m=m<<1,k==d-1?(k=0,E.push(f(m)),m=0):k++;for(u=w.charCodeAt(0),l=0;l<8;l++)m=m<<1|u&1,k==d-1?(k=0,E.push(f(m)),m=0):k++,u=u>>1}else{for(u=1,l=0;l<S;l++)m=m<<1|u,k==d-1?(k=0,E.push(f(m)),m=0):k++,u=0;for(u=w.charCodeAt(0),l=0;l<16;l++)m=m<<1|u&1,k==d-1?(k=0,E.push(f(m)),m=0):k++,u=u>>1}g--,g==0&&(g=Math.pow(2,S),S++),delete h[w]}else for(u=b[w],l=0;l<S;l++)m=m<<1|u&1,k==d-1?(k=0,E.push(f(m)),m=0):k++,u=u>>1;g--,g==0&&(g=Math.pow(2,S),S++),b[D]=y++,w=String(p)}if(w!==""){if(Object.prototype.hasOwnProperty.call(h,w)){if(w.charCodeAt(0)<256){for(l=0;l<S;l++)m=m<<1,k==d-1?(k=0,E.push(f(m)),m=0):k++;for(u=w.charCodeAt(0),l=0;l<8;l++)m=m<<1|u&1,k==d-1?(k=0,E.push(f(m)),m=0):k++,u=u>>1}else{for(u=1,l=0;l<S;l++)m=m<<1|u,k==d-1?(k=0,E.push(f(m)),m=0):k++,u=0;for(u=w.charCodeAt(0),l=0;l<16;l++)m=m<<1|u&1,k==d-1?(k=0,E.push(f(m)),m=0):k++,u=u>>1}g--,g==0&&(g=Math.pow(2,S),S++),delete h[w]}else for(u=b[w],l=0;l<S;l++)m=m<<1|u&1,k==d-1?(k=0,E.push(f(m)),m=0):k++,u=u>>1;g--,g==0&&(g=Math.pow(2,S),S++)}for(u=2,l=0;l<S;l++)m=m<<1|u&1,k==d-1?(k=0,E.push(f(m)),m=0):k++,u=u>>1;for(;;)if(m=m<<1,k==d-1){E.push(f(m));break}else k++;return E.join("")},decompress:function(a){return a==null?"":a==""?null:c._decompress(a.length,32768,function(d){return a.charCodeAt(d)})},_decompress:function(a,d,f){var l=[],u=4,b=4,h=3,p="",D=[],w,g,y,S,E,m,k,A={val:f(0),position:d,index:1};for(w=0;w<3;w+=1)l[w]=w;for(y=0,E=Math.pow(2,2),m=1;m!=E;)S=A.val&A.position,A.position>>=1,A.position==0&&(A.position=d,A.val=f(A.index++)),y|=(S>0?1:0)*m,m<<=1;switch(y){case 0:for(y=0,E=Math.pow(2,8),m=1;m!=E;)S=A.val&A.position,A.position>>=1,A.position==0&&(A.position=d,A.val=f(A.index++)),y|=(S>0?1:0)*m,m<<=1;k=n(y);break;case 1:for(y=0,E=Math.pow(2,16),m=1;m!=E;)S=A.val&A.position,A.position>>=1,A.position==0&&(A.position=d,A.val=f(A.index++)),y|=(S>0?1:0)*m,m<<=1;k=n(y);break;case 2:return""}for(l[3]=k,g=k,D.push(k);;){if(A.index>a)return"";for(y=0,E=Math.pow(2,h),m=1;m!=E;)S=A.val&A.position,A.position>>=1,A.position==0&&(A.position=d,A.val=f(A.index++)),y|=(S>0?1:0)*m,m<<=1;switch(k=y){case 0:for(y=0,E=Math.pow(2,8),m=1;m!=E;)S=A.val&A.position,A.position>>=1,A.position==0&&(A.position=d,A.val=f(A.index++)),y|=(S>0?1:0)*m,m<<=1;l[b++]=n(y),k=b-1,u--;break;case 1:for(y=0,E=Math.pow(2,16),m=1;m!=E;)S=A.val&A.position,A.position>>=1,A.position==0&&(A.position=d,A.val=f(A.index++)),y|=(S>0?1:0)*m,m<<=1;l[b++]=n(y),k=b-1,u--;break;case 2:return D.join("")}if(u==0&&(u=Math.pow(2,h),h++),l[k])p=l[k];else if(k===b)p=g+g.charAt(0);else return null;D.push(p),l[b++]=g+p.charAt(0),u--,g=p,u==0&&(u=Math.pow(2,h),h++)}}};return c})();e!=null?e.exports=t:typeof angular<"u"&&angular!=null&&angular.module("LZString",[]).factory("LZString",function(){return t})})(Vn)),Vn.exports}var E1=m1();function D1(e){return e.split("/").pop()}function x1(){return`query getDocument($documentId: String!) {
|
|
16
|
-
document(id: $documentId) {
|
|
17
|
-
id
|
|
18
|
-
documentType
|
|
19
|
-
createdAtUtcIso
|
|
20
|
-
lastModifiedAtUtcIso
|
|
21
|
-
name
|
|
22
|
-
revision
|
|
23
|
-
stateJSON
|
|
24
|
-
}
|
|
25
|
-
}`}function v1(e,t,n){const r=D1(e),o=x1(),s={documentId:t,driveId:r},i=n?{Authorization:`Bearer ${n}`}:void 0,c={document:o.trim(),variables:JSON.stringify(s,null,2)};return i&&(c.headers=JSON.stringify(i)),E1.compressToEncodedURIComponent(JSON.stringify(c))}function S1(e,t,n){const r=v1(e,t,n);return`${e}?explorerURLState=${r}`}function Fw(e){return{id:Ce(),name:e.manifest.name,description:e.manifest.description,category:e.manifest.category,author:{name:"Powerhouse",website:"https://powerhousedao.com"},modules:{documentModelModules:e.documentModels.map(A1),editorModules:e.editors.map(r=>k1(r,e.manifest))}}}function A1(e){const t=e.documentModel.global,n=t.name,r=t.id,o=r,s=t.extension,i=t.specifications,c=e.reducer,a=e.actions,d=e.utils;return{id:o,name:n,documentType:r,extension:s,documentModel:cc(dc(),t),specifications:i,reducer:c,actions:a,utils:d}}function k1(e,t){const n=t?.apps?.find(d=>d.driveEditor===e.config.id)?.name,r=e.config.id,o=r.split("-").map(d=>d.charAt(0).toUpperCase()+d.slice(1)).join(" "),s=n||e.config.name||o,i=e.documentTypes,c=e.Component;return{id:r,name:s,documentTypes:i,Component:c}}function Vw(e){const{id:t,name:n,description:r,category:o,author:s,modules:i}=e;return{id:t,name:n,description:r,category:o,author:s,modules:T1(i)}}function T1(e){return Object.entries(e).reduce((t,[n,r])=>(t[n]=r.map(o=>({id:o.id,name:o.name})),t),{})}const jr=_("connectCrypto"),I1=jr.useValue,Kw=jr.setValue,C1=jr.addEventHandler,{setValue:zw,addEventHandler:_1}=_("did"),{addEventHandler:B1}=_("loading"),{setValue:Je,addEventHandler:$1}=_("loginStatus"),Ba=_("processorManager"),qw=Ba.setValue,R1=Ba.addEventHandler,Lr=_("reactor"),Jw=Lr.useValue,Ww=Lr.setValue,O1=Lr.addEventHandler,$a=_("renown"),Zw=$a.setValue,U1=$a.addEventHandler,Fr=_("user"),Ra=Fr.useValue,fs=Fr.setValue,N1=Fr.addEventHandler,M1={loading:B1,reactor:O1,modal:c1,connectCrypto:C1,did:_1,renown:U1,loginStatus:$1,user:N1,processorManager:R1,drives:Lb,documentCache:Yb,selectedDriveId:()=>{s2(),c2(),l2()},selectedNodeId:()=>{f2(),h2()},vetraPackages:jc,selectedTimelineRevision:y1,revisionHistoryVisible:b1,selectedTimelineItem:p1,routerBasename:p2,version:y2,logLevel:Zp,requiresHardRefresh:m2,warnOutdatedApp:D2,studioMode:v2,basePath:A2,versionCheckInterval:T2,cliVersion:C2,fileUploadOperationsChunkSize:B2,isDocumentModelSelectionSettingsEnabled:R2,gaTrackingId:U2,allowList:Xp,defaultDrivesUrl:M2,drivesPreserveStrategy:H2,allowedDocumentTypes:Mc,enabledEditors:Up,disabledEditors:Mp,isAddDriveEnabled:V2,isLocalDrivesEnabled:L2,isPublicDrivesEnabled:z2,isAddPublicDrivesEnabled:J2,isDeletePublicDrivesEnabled:Z2,isCloudDrivesEnabled:Y2,isAddCloudDrivesEnabled:Q2,isDeleteCloudDrivesEnabled:tp,isAddLocalDrivesEnabled:rp,isDeleteLocalDrivesEnabled:sp,isDragAndDropEnabled:Oc,isExternalControlsEnabled:$c,isEditorDebugModeEnabled:ap,isEditorReadModeEnabled:dp,isRelationalProcessorsEnabled:Hp,isExternalRelationalProcessorsEnabled:Lp,isAnalyticsEnabled:Vp,isAnalyticsExternalProcessorsEnabled:zp,analyticsDatabaseName:Jp,isAnalyticsDatabaseWorkerEnabled:fp,isDiffAnalyticsEnabled:hp,isDriveAnalyticsEnabled:pp,renownUrl:yp,renownNetworkId:mp,renownChainId:Dp,sentryRelease:vp,sentryDsn:Ap,sentryEnv:Tp,isSentryTracingEnabled:Cp,isExternalProcessorsEnabled:Bp,isExternalPackagesEnabled:Rp};function Gw(){for(const e of Object.values(M1))e()}function Yw(e){const[t]=i2(),n=zb(t),r=ca(t),o=I1(),s=Ra();return Ne.useMemo(()=>!n||!e?.header.id||!r?null:async()=>{const i=s?.address?await o?.getBearerToken(r,s.address,!1,{expiresIn:600}):void 0;return S1(r,e.header.id,i)},[n,r,e,s,o])}const Xw=e=>{const t=ya(),n=Or(),r=s1();return async(s,i,c)=>{if(!t){console.warn("No selected drive - upload skipped");return}const a=s.name.replace(/\..+/gim,""),d=n?.id;return await Sc(s,t,a,d,i,r,c)}};function Qw(){const e=Ra(),t=Yp();return t?{isAllowedToCreateDocuments:t.includes(e?.address??""),isAllowedToEditDocuments:t.includes(e?.address??"")}:{isAllowedToCreateDocuments:!0,isAllowedToEditDocuments:!0}}const P1="https://www.renown.id",H1="eip155",j1="1";function ey(){const e=new URL(P1);e.searchParams.set("connect",window.ph?.did??""),e.searchParams.set("network",H1),e.searchParams.set("chain",j1);const t=new URL(window.location.pathname,window.location.origin);e.searchParams.set("returnUrl",t.toJSON()),window.open(e,"_self")?.focus()}async function ty(e,t,n,r){if(!(!n||!r||!t))try{Je("checking");let o=n.user instanceof Function?n.user():n.user;if(o=o instanceof Promise?await o:o,o?.did&&(o.did===e||!e))return Je("authorized"),fs(o),t.setGenerateJwtHandler(async i=>r.getBearerToken(i,o.address,!0,{expiresIn:10})),o;if(!e)return;const s=await n.login(e??"");s?(Je("authorized"),fs(s),t.setGenerateJwtHandler(async i=>r.getBearerToken(i,s.address,!0,{expiresIn:10}))):Je("not-authorized")}catch(o){Je("not-authorized"),z.error(o)}}async function ny(){const e=window.ph?.renown,t=window.ph?.reactor;Je("initial"),await e?.logout(),t?.removeJwtHandler()}export{Gw as $,zb as A,ca as B,I1 as C,Ra as D,S1 as E,g1 as F,xc as G,a1 as H,Aw as I,uw as J,Pw as K,Ow as L,Lc as M,kw as N,Sw as O,h1 as P,Lw as Q,Tw as R,ys as S,Cw as T,mw as U,ow as V,Or as W,gs as X,Dw as Y,_c as Z,tw as _,xw as a,ww as a0,dw as a1,hw as a2,pw as a3,yw as a4,Vb as a5,wa as a6,e2 as a7,ty as a8,Ew as a9,kc as aA,fw as aB,Y1 as aC,G1 as aD,Z1 as aE,ir as aF,Vw as aG,Ww as aa,gw as ab,Kw as ac,zw as ad,Zw as ae,qw as af,jb as ag,bw as ah,n1 as ai,t1 as aj,ia as ak,Jw as al,J1 as am,ny as an,ey as ao,i1 as ap,Iw as aq,q1 as ar,Rw as as,ps as at,X1 as au,Q1 as av,ew as aw,vw as ax,W1 as ay,u1 as az,Qw as b,$r as c,ya as d,$w as e,ma as f,Ac as g,ua as h,Nw as i,l1 as j,Yw as k,Uw as l,Hw as m,jw as n,Bw as o,nw as p,Xw as q,Tl as r,a2 as s,lw as t,Mw as u,_w as v,d1 as w,Fw as x,rw as y,i2 as z};
|