@hashgraphonline/standards-agent-kit 0.2.157 → 0.2.159
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/dist/cjs/standards-agent-kit.cjs +1 -1
- package/dist/cjs/standards-agent-kit.cjs.map +1 -1
- package/dist/es/standards-agent-kit.es8.js +21 -17
- package/dist/es/standards-agent-kit.es8.js.map +1 -1
- package/dist/umd/standards-agent-kit.umd.js +1 -1
- package/dist/umd/standards-agent-kit.umd.js.map +1 -1
- package/package.json +26 -34
- package/src/builders/inscriber/inscriber-builder.ts +23 -19
|
@@ -154,7 +154,7 @@ read:function(e,t,n,i,a){var r,o,s=8*a-i-1,c=(1<<s)-1,p=c>>1,l=-7,u=n?a-1:0,d=n?
|
|
|
154
154
|
* Copyright(c) 2014 Jonathan Ong
|
|
155
155
|
* Copyright(c) 2015 Douglas Christopher Wilson
|
|
156
156
|
* MIT Licensed
|
|
157
|
-
*/().extname,o=/^\s*([^;\s]*)(?:;|\s|$)/,s=/^text\//i;function c(e){if(!e||"string"!=typeof e)return!1;var t=o.exec(e),n=t&&a[t[1].toLowerCase()];return n&&n.charset?n.charset:!(!t||!s.test(t[1]))&&"UTF-8"}e.charset=c,e.charsets={lookup:c},e.contentType=function(t){if(!t||"string"!=typeof t)return!1;var n=-1===t.indexOf("/")?e.lookup(t):t;if(!n)return!1;if(-1===n.indexOf("charset")){var i=e.charset(n);i&&(n+="; charset="+i.toLowerCase())}return n},e.extension=function(t){if(!t||"string"!=typeof t)return!1;var n=o.exec(t),i=n&&e.extensions[n[1].toLowerCase()];return!(!i||!i.length)&&i[0]},e.extensions=Object.create(null),e.lookup=function(t){if(!t||"string"!=typeof t)return!1;var n=r("x."+t).toLowerCase().substr(1);return n&&e.types[n]||!1},e.types=Object.create(null),t=e.extensions,n=e.types,i=["nginx","apache",void 0,"iana"],Object.keys(a).forEach(function(e){var r=a[e],o=r.extensions;if(o&&o.length){t[e]=o;for(var s=0;s<o.length;s++){var c=o[s];if(n[c]){var p=i.indexOf(a[n[c]].source),l=i.indexOf(r.source);if("application/octet-stream"!==n[c]&&(p>l||p===l&&"application/"===n[c].substr(0,12)))continue}n[c]=e}}})}(D0));var V0=(e=>(e[e.PERSONAL=0]="PERSONAL",e[e.AI_AGENT=1]="AI_AGENT",e[e.MCP_SERVER=2]="MCP_SERVER",e))(V0||{}),H0=(e=>(e[e.MANUAL=0]="MANUAL",e[e.AUTONOMOUS=1]="AUTONOMOUS",e))(H0||{}),G0=(e=>(e[e.TEXT_GENERATION=0]="TEXT_GENERATION",e[e.IMAGE_GENERATION=1]="IMAGE_GENERATION",e[e.AUDIO_GENERATION=2]="AUDIO_GENERATION",e[e.VIDEO_GENERATION=3]="VIDEO_GENERATION",e[e.CODE_GENERATION=4]="CODE_GENERATION",e[e.LANGUAGE_TRANSLATION=5]="LANGUAGE_TRANSLATION",e[e.SUMMARIZATION_EXTRACTION=6]="SUMMARIZATION_EXTRACTION",e[e.KNOWLEDGE_RETRIEVAL=7]="KNOWLEDGE_RETRIEVAL",e[e.DATA_INTEGRATION=8]="DATA_INTEGRATION",e[e.MARKET_INTELLIGENCE=9]="MARKET_INTELLIGENCE",e[e.TRANSACTION_ANALYTICS=10]="TRANSACTION_ANALYTICS",e[e.SMART_CONTRACT_AUDIT=11]="SMART_CONTRACT_AUDIT",e[e.GOVERNANCE_FACILITATION=12]="GOVERNANCE_FACILITATION",e[e.SECURITY_MONITORING=13]="SECURITY_MONITORING",e[e.COMPLIANCE_ANALYSIS=14]="COMPLIANCE_ANALYSIS",e[e.FRAUD_DETECTION=15]="FRAUD_DETECTION",e[e.MULTI_AGENT_COORDINATION=16]="MULTI_AGENT_COORDINATION",e[e.API_INTEGRATION=17]="API_INTEGRATION",e[e.WORKFLOW_AUTOMATION=18]="WORKFLOW_AUTOMATION",e))(G0||{}),J0=(e=>(e[e.RESOURCE_PROVIDER=0]="RESOURCE_PROVIDER",e[e.TOOL_PROVIDER=1]="TOOL_PROVIDER",e[e.PROMPT_TEMPLATE_PROVIDER=2]="PROMPT_TEMPLATE_PROVIDER",e[e.LOCAL_FILE_ACCESS=3]="LOCAL_FILE_ACCESS",e[e.DATABASE_INTEGRATION=4]="DATABASE_INTEGRATION",e[e.API_INTEGRATION=5]="API_INTEGRATION",e[e.WEB_ACCESS=6]="WEB_ACCESS",e[e.KNOWLEDGE_BASE=7]="KNOWLEDGE_BASE",e[e.MEMORY_PERSISTENCE=8]="MEMORY_PERSISTENCE",e[e.CODE_ANALYSIS=9]="CODE_ANALYSIS",e[e.CONTENT_GENERATION=10]="CONTENT_GENERATION",e[e.COMMUNICATION=11]="COMMUNICATION",e[e.DOCUMENT_PROCESSING=12]="DOCUMENT_PROCESSING",e[e.CALENDAR_SCHEDULE=13]="CALENDAR_SCHEDULE",e[e.SEARCH=14]="SEARCH",e[e.ASSISTANT_ORCHESTRATION=15]="ASSISTANT_ORCHESTRATION",e))(J0||{}),Y0=(e=>(e.DNS="dns",e.SIGNATURE="signature",e.CHALLENGE="challenge",e))(Y0||{});const X0=el({platform:Gp().min(1),handle:Gp().min(1)}),Q0=el({type:sl(H0),capabilities:Qp(sl(G0)).min(1),model:Gp().min(1),creator:Gp().optional()}),e1=el({url:Gp().min(1),transport:ol(["stdio","sse"])}),t1=el({type:sl(Y0),value:Gp(),dns_field:Gp().optional(),challenge_path:Gp().optional()}),n1=el({minVersion:Gp().optional()}),i1=el({name:Gp().min(1),description:Gp().min(1)}),a1=el({name:Gp().min(1),description:Gp().min(1)}),r1=el({version:Gp().min(1),connectionInfo:e1,services:Qp(sl(J0)).min(1),description:Gp().min(1),verification:t1.optional(),host:n1.optional(),capabilities:Qp(Gp()).optional(),resources:Qp(i1).optional(),tools:Qp(a1).optional(),maintainer:Gp().optional(),repository:Gp().optional(),docs:Gp().optional()}),o1=el({version:Gp().min(1),type:sl(V0),display_name:Gp().min(1),alias:Gp().optional(),bio:Gp().optional(),socials:Qp(X0).optional(),profileImage:Gp().optional(),properties:il(Xp()).optional(),inboundTopicId:Gp().optional(),outboundTopicId:Gp().optional()}),s1=o1.extend({type:rl(V0.PERSONAL),language:Gp().optional(),timezone:Gp().optional()}),c1=o1.extend({type:rl(V0.AI_AGENT),aiAgent:Q0}),p1=o1.extend({type:rl(V0.MCP_SERVER),mcpServer:r1});tl([s1,c1,p1]);const l1=el({p:rl("hcs-12")}),u1=Gp().regex(/^\d+\.\d+\.\d+$/,"Invalid Hedera address format"),d1=Gp().regex(/^[a-f0-9]{64}$/,"Invalid SHA-256 hash format"),f1=el({format:ol(["tar.gz","zip","car"]),root_manifest:Gp(),includes_lockfile:Yp(),workspace_members:Qp(Gp()).optional()}),m1=el({source_t_id:u1,source_hash:d1,compiler_version:Gp(),cargo_version:Gp(),target:rl("wasm32-unknown-unknown"),profile:Gp(),build_flags:Qp(Gp()),lockfile_hash:d1,source_structure:f1}),h1=al(()=>el({type:Gp().optional(),required:Qp(Gp()).optional(),properties:il(h1).optional(),pattern:Gp().optional(),minimum:Jp().optional(),maximum:Jp().optional(),regex:Gp().optional(),min:Jp().optional(),max:Jp().optional(),length:Jp().optional(),email:Yp().optional(),url:Yp().optional(),uuid:Yp().optional(),cuid:Yp().optional(),cuid2:Yp().optional(),ulid:Yp().optional(),datetime:Yp().optional(),ip:Yp().optional(),startsWith:Gp().optional(),endsWith:Gp().optional(),includes:Gp().optional(),gt:Jp().optional(),gte:Jp().optional(),lt:Jp().optional(),lte:Jp().optional(),int:Yp().optional(),positive:Yp().optional(),nonnegative:Yp().optional(),negative:Yp().optional(),nonpositive:Yp().optional(),multipleOf:Jp().optional(),finite:Yp().optional(),safe:Yp().optional(),nonempty:Yp().optional(),literal:tl([Gp(),Jp(),Yp()]).optional(),enum:Qp(Gp()).optional(),nullable:Yp().optional(),nullish:Yp().optional(),optional:Yp().optional(),element:Xp().optional(),shape:il(Xp()).optional(),strict:Yp().optional(),passthrough:Yp().optional(),catchall:Xp().optional()}));el({p:rl("hcs-12"),op:rl("register"),t_id:u1,hash:d1,wasm_hash:d1,js_t_id:u1.optional(),js_hash:d1.optional(),interface_version:Gp().regex(/^\d+\.\d+\.\d+$/,"Invalid version format").optional(),info_t_id:u1.optional(),source_verification:m1.optional(),previous_version:Gp().optional(),migration_notes:Gp().optional(),validation_rules:il(h1).optional(),m:Gp().optional()}),el({p:rl("hcs-12"),op:ol(["register","template"]),name:Gp(),version:Gp().regex(/^\d+\.\d+\.\d+$/,"Invalid semver format"),data:tl([Xp(),Gp()]).optional(),t_id:u1.optional()}),ol(["register","add-action","add-block","update"]);const g1=l1.extend({op:rl("register"),name:Gp(),version:Gp().regex(/^\d+\.\d+\.\d+$/,"Invalid semver format"),description:Gp().optional(),tags:Qp(Gp()).optional(),author:Gp().optional()}),v1=l1.extend({op:rl("add-action"),t_id:u1,alias:Gp(),config:Xp().optional(),data:u1.optional()}),y1=l1.extend({op:rl("add-block"),block_t_id:u1,actions:il(Gp(),u1).optional(),attributes:il(Xp()).optional(),children:Qp(Gp()).optional(),data:u1.optional()}),b1=l1.extend({op:rl("update"),description:Gp().optional(),tags:Qp(Gp()).optional()});el({type:ol(["vertical","horizontal","grid"]),responsive:Yp().optional(),containerClass:Gp().optional()}),el({source_t_id:u1,source_hash:d1,description:Gp().optional()}),nl("op",[g1,v1,y1,b1]),l1.extend({op:rl("register"),t_id:u1,name:Gp().max(100,"Name must be 100 characters or less"),description:Gp().max(500,"Description must be 500 characters or less").optional(),tags:Qp(Gp()).max(10,"Maximum 10 tags allowed").optional(),category:Gp().optional(),featured:Yp().optional(),icon:Gp().optional(),author:Gp().optional(),website:Gp().url().optional()});const x1=Gp().regex(/^\d+\.\d+\.\d+$/,{message:"Topic ID must be in Hedera format (e.g., '0.0.123456')"}),w1=el({p:Gp().regex(/^hcs-\d+$/,{message:"Protocol must be in format 'hcs-N' where N is a number"}),op:ol(["register","update","delete","migrate"]),m:Gp().max(500,"Memo must not exceed 500 characters").optional(),ttl:Jp().int().positive().optional()});nl("op",[w1.extend({op:rl("register"),t_id:x1,metadata:Gp().optional()}),w1.extend({op:rl("update"),uid:Gp(),t_id:x1,metadata:Gp().optional()}),w1.extend({op:rl("delete"),uid:Gp()}),w1.extend({op:rl("migrate"),t_id:x1,metadata:Gp().optional()})]);const _1=18,k1=100,E1=100,S1=/^(0|(?:[1-9]\d*))\.(0|(?:[1-9]\d*))\.(0|(?:[1-9]\d*))$/,A1=Gp().regex(S1,"Invalid Hedera account ID format"),T1=Gp().regex(/^\d+$/,"Must be a valid number").max(_1,`Max ${_1} digits`),O1=Gp().min(1,"Tick cannot be empty").transform(e=>e.toLowerCase().trim()),R1=el({p:rl("hcs-20"),m:Gp().optional()});nl("op",[R1.extend({op:rl("deploy"),name:Gp().min(1).max(k1),tick:O1,max:T1,lim:T1.optional(),metadata:Gp().max(E1).optional()}),R1.extend({op:rl("mint"),tick:O1,amt:T1,to:A1}),R1.extend({op:rl("burn"),tick:O1,amt:T1,from:A1}),R1.extend({op:rl("transfer"),tick:O1,amt:T1,from:A1,to:A1}),R1.extend({op:rl("register"),name:Gp().min(1).max(k1),metadata:Gp().max(E1).optional(),private:Yp(),t_id:A1})]);class j1{constructor(){this.resolver=null,this.onUnavailableCallbacks=[],this.logger=gc.getInstance({module:"ContentResolverRegistry"})}static getInstance(){return j1._instance||(j1._instance=new j1),j1._instance}register(e){this.resolver&&this.logger.warn("Resolver already registered, replacing existing"),this.resolver=e,this.logger.info("Content resolver registered")}getResolver(){return this.resolver}isAvailable(){return null!==this.resolver}unregister(){this.resolver&&(this.resolver=null,this.logger.info("Content resolver unregistered"),this.onUnavailableCallbacks.forEach(e=>{try{e()}catch(t){this.logger.error("Error in unavailable callback:",t)}}))}onUnavailable(e){this.onUnavailableCallbacks.push(e)}offUnavailable(e){const t=this.onUnavailableCallbacks.indexOf(e);-1!==t&&this.onUnavailableCallbacks.splice(t,1)}async withResolver(e,t){if(!this.resolver)return this.logger.warn("No resolver available, using fallback"),await t();try{return await e(this.resolver)}catch(n){return this.logger.warn("Resolver operation failed, using fallback:",n),await t()}}}j1.getInstance();class I1{constructor(){this.contentStore=null,this.logger=gc.getInstance({module:"ContentStoreService"})}static getInstance(){return I1._instance||(I1._instance=new I1),I1._instance}async setInstance(e){this.contentStore&&this.logger.warn("Content store already set, replacing"),this.contentStore=e,this.logger.info("Content store instance set")}getInstance(){return this.contentStore}dispose(){this.contentStore=null,this.logger.info("Content store disposed")}isAvailable(){return null!==this.contentStore}}I1.getInstance();class C1{constructor(e){if(lr(this,"accountId"),lr(this,"privateKey"),lr(this,"baseUrl"),lr(this,"network"),this.accountId=e.accountId,"string"==typeof e.privateKey){const t=dl(e.privateKey);this.privateKey=t.privateKey}else this.privateKey=e.privateKey;this.network=e.network||"mainnet",this.baseUrl=e.baseUrl||"https://kiloscribe.com"}async authenticate(){var e,t,n;const i=await qs.get(`${this.baseUrl}/api/auth/request-signature`,{headers:{"x-session":this.accountId}});if(!(null==(e=i.data)?void 0:e.message))throw new Error("Failed to get signature message");const a=i.data.message,r=await this.signMessage(a),o=await qs.post(`${this.baseUrl}/api/auth/authenticate`,{authData:{id:this.accountId,signature:r,data:a,network:this.network},include:"apiKey"});if(!(null==(n=null==(t=o.data)?void 0:t.user)?void 0:n.sessionToken))throw new Error("Authentication failed");return{apiKey:o.data.apiKey}}async signMessage(e){const t=(new TextEncoder).encode(e),n=await this.privateKey.sign(t);return kr.from(n).toString("hex")}}class N1{constructor(e){lr(this,"accountId"),lr(this,"signer"),lr(this,"baseUrl"),lr(this,"network"),lr(this,"logger"),this.accountId=e.accountId,this.signer=e.signer,this.network=e.network||"mainnet",this.baseUrl=e.baseUrl||"https://kiloscribe.com",this.logger=e.logger}async authenticate(){var e,t,n;const i=await qs.get(`${this.baseUrl}/api/auth/request-signature`,{headers:{"x-session":this.accountId}});if(!(null==(e=i.data)?void 0:e.message))throw new Error("Failed to get signature message");const a=i.data.message,r=await this.signMessage(JSON.stringify(a)),o=await qs.post(`${this.baseUrl}/api/auth/authenticate`,{authData:{id:this.accountId,signature:r,data:a,network:this.network},include:"apiKey"});if(!(null==(n=null==(t=o.data)?void 0:t.user)?void 0:n.sessionToken))throw new Error("Authentication failed");return{apiKey:o.data.apiKey}}async signMessage(e){try{const t=(new TextEncoder).encode(e);this.logger.debug("signing message");const n=await this.signer.sign([t],{encoding:"utf-8"});return kr.from(null==n?void 0:n[0].signature).toString("hex")}catch(Owe){throw this.logger.error("Failed to sign message",Owe),new Error("Failed to sign message")}}}const B1={get:(e,t)=>127&e[t+3]|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4},P1=4100;function L1(e){switch(e=e.toLowerCase()){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:e};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:e};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:e};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:e};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:e};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function U1(e,t,n){n={offset:0,...n};for(const[i,a]of t.entries())if(n.mask){if(a!==(n.mask[i]&e[i+n.offset]))return!1}else if(a!==e[i+n.offset])return!1;return!0}class M1{constructor(e){lr(this,"detectConfident",async e=>{if(this.buffer=new Uint8Array(P1),void 0===e.fileInfo.size&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,await e.peekBuffer(this.buffer,{length:12,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.detectConfident(e);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await e.ignore(6);const t=await e.readToken(B1);return e.position+t>e.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await e.ignore(t),this.fromTokenizer(e))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((67===this.buffer[0]||70===this.buffer[0])&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let n;return await new L0(e).unzip(e=>{switch(e.filename){case"META-INF/mozilla.rsa":return n={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return n={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(e){const t=new TextDecoder("utf-8").decode(e).trim();n=L1(t)},stop:!0};case"[Content_Types].xml":return{async handler(e){let t=new TextDecoder("utf-8").decode(e);const i=t.indexOf('.main+xml"');if(-1===i){const e="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";t.includes(`ContentType="${e}"`)&&(n=L1(e))}else{t=t.slice(0,Math.max(0,i));const e=t.lastIndexOf('"'),a=t.slice(Math.max(0,e+1));n=L1(a)}},stop:!0};default:return/classes\d*\.dex/.test(e.filename)?(n={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}),n??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);const i=new Uint8Array(8);return await e.readBuffer(i),U1(i,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:U1(i,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:U1(i,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:U1(i,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:U1(i,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:U1(i,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(3===this.buffer[2]||5===this.buffer[2]||7===this.buffer[2])&&(4===this.buffer[3]||6===this.buffer[3]||8===this.buffer[3]))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){const a=await this.readTiffHeader(!1);if(a)return a}if(this.check([77,77])){const r=await this.readTiffHeader(!0);if(r)return r}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function o(){const t=await e.peekNumber(xQ);let n=128,i=0;for(;0===(t&n)&&0!==n;)++i,n>>=1;const a=new Uint8Array(i+1);return await e.readBuffer(a),a}async function s(){const e=await o(),t=await o();t[0]^=128>>t.length-1;const n=Math.min(6,t.length),i=new DataView(e.buffer),a=new DataView(t.buffer,t.length-n,n);return{id:F0(i),len:F0(a)}}async function c(t){for(;t>0;){const n=await s();if(17026===n.id){return(await e.readToken(new TQ(n.len))).replaceAll(/\00.*$/g,"")}await e.ignore(n.len),--t}}const p=await s();switch(await c(p.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(0===this.buffer[6]||1===this.buffer[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){const l=new TQ(4,"latin1").get(this.buffer,2);if(l.match("^d*")&&l>=1e3&&l<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>")){await e.ignore(8);return"debian-binary"===await e.readToken(new TQ(13,"ascii"))?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"}}if(this.checkString("WEBVTT")&&["\n","\r","\t"," ","\0"].some(e=>this.checkString(e,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){async function u(){return{length:await e.readToken(SQ),type:await e.readToken(new TQ(4,"latin1"))}}await e.ignore(8);do{const d=await u();if(d.length<0)return;switch(d.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await e.ignore(d.length+4)}}while(e.position+8<e.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&96&this.buffer[8]){const f=new TQ(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(f){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return f.startsWith("3g")?f.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function m(){const t=new Uint8Array(16);return await e.readBuffer(t),{id:t,size:Number(await e.readToken(AQ))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){const h=await m();let g=h.size-24;if(U1(h.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){const v=new Uint8Array(16);if(g-=await e.readBuffer(v),U1(v,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(U1(v,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await e.ignore(g)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10])){await e.ignore(20);switch(await e.readToken(new TQ(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.check([0,60,0,63,0,120,0,109,0,108],{offset:2})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){const y=new DataView(this.buffer.buffer).getUint32(12,!0);if(y>12&&this.buffer.length>=y+16)try{const b=(new TextDecoder).decode(this.buffer.subarray(16,y+16));if(JSON.parse(b).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}return this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2])?{ext:"mxf",mime:"application/mxf"}:this.checkString("SCRM",{offset:44})?{ext:"s3m",mime:"audio/x-s3m"}:this.check([71])&&this.check([71],{offset:188})||this.check([71],{offset:4})&&this.check([71],{offset:196})?{ext:"mts",mime:"video/mp2t"}:this.check([66,79,79,75,77,79,66,73],{offset:60})?{ext:"mobi",mime:"application/x-mobipocket-ebook"}:this.check([68,73,67,77],{offset:128})?{ext:"dcm",mime:"application/dicom"}:this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70])?{ext:"lnk",mime:"application/x.ms.shortcut"}:this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0])?{ext:"alias",mime:"application/x.apple.alias"}:this.checkString("Kaydara FBX Binary \0")?{ext:"fbx",mime:"application/x.autodesk.fbx"}:this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8}))?{ext:"eot",mime:"application/vnd.ms-fontobject"}:this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29])?{ext:"indd",mime:"application/x-indesign"}:(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&function(e,t=0){const n=Number.parseInt(new TQ(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(n))return!1;let i=256;for(let a=t;a<t+148;a++)i+=e[a];for(let a=t+156;a<t+512;a++)i+=e[a];return n===i}(this.buffer)?{ext:"tar",mime:"application/x-tar"}:this.check([255,254])?this.check([60,0,63,0,120,0,109,0,108,0],{offset:2})?{ext:"xml",mime:"application/xml"}:this.check([255,14,83,0,107,0,101,0,116,0,99,0,104,0,85,0,112,0,32,0,77,0,111,0,100,0,101,0,108,0],{offset:2})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:void 0:this.checkString("-----BEGIN PGP MESSAGE-----")?{ext:"pgp",mime:"application/pgp-encrypted"}:void 0)}),lr(this,"detectImprecise",async e=>{if(this.buffer=new Uint8Array(P1),await e.peekBuffer(this.buffer,{length:Math.min(8,e.fileInfo.size),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,e.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let t=0;t<=this.options.mpegOffsetTolerance;++t){const e=this.scanMpeg(t);if(e)return e}}),this.options={mpegOffsetTolerance:0,...e},this.detectors=[...(null==e?void 0:e.customDetectors)??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:null==e?void 0:e.signal}}async fromTokenizer(e){const t=e.position;for(const n of this.detectors){const i=await n.detect(e);if(i)return i;if(t!==e.position)return}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);const t=e instanceof Uint8Array?e:new Uint8Array(e);var n,i;if((null==t?void 0:t.length)>1)return this.fromTokenizer((n=t,i=this.tokenizerOptions,new LQ(n,i)))}async fromBlob(e){return this.fromStream(e.stream())}async fromStream(e){const t=await UQ(e,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(e,t){const{sampleSize:n=P1}=t;let i,a;const r=e.getReader({mode:"byob"});try{const{value:e,done:t}=await r.read(new Uint8Array(n));if(a=e,!t&&e)try{i=await this.fromBuffer(e.subarray(0,n))}catch(c){if(!(c instanceof OQ))throw c;i=void 0}a=e}finally{r.releaseLock()}const o=new TransformStream({async start(e){e.enqueue(a)},transform(e,t){t.enqueue(e)}}),s=e.pipeThrough(o);return s.fileType=i,s}check(e,t){return U1(this.buffer,e,t)}checkString(e,t){return this.check((n=e,[...n].map(e=>e.charCodeAt(0))),t);var n}async readTiffTag(e){const t=await this.tokenizer.readToken(e?_Q:wQ);switch(this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(e){const t=await this.tokenizer.readToken(e?_Q:wQ);for(let n=0;n<t;++n){const t=await this.readTiffTag(e);if(t)return t}}async readTiffHeader(e){const t=(e?_Q:wQ).get(this.buffer,2),n=(e?EQ:kQ).get(this.buffer,4);if(42===t){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=8){const t=(e?_Q:wQ).get(this.buffer,8),n=(e?_Q:wQ).get(this.buffer,10);if(28===t&&254===n||31===t&&11===n)return{ext:"nef",mime:"image/x-nikon-nef"}}}await this.tokenizer.ignore(n);return await this.readTiffIFD(e)??{ext:"tif",mime:"image/tiff"}}if(43===t)return{ext:"tif",mime:"image/tiff"}}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]}),{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}}new Set(["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","rm","ppsm","ppsx"]),new Set(["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia"]);const F1=Object.create(null);F1.open="0",F1.close="1",F1.ping="2",F1.pong="3",F1.message="4",F1.upgrade="5",F1.noop="6";const D1=Object.create(null);Object.keys(F1).forEach(e=>{D1[F1[e]]=e});const z1={type:"error",data:"parser error"},$1="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),q1="function"==typeof ArrayBuffer,W1=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,K1=({type:e,data:t},n,i)=>$1&&t instanceof Blob?n?i(t):Z1(t,i):q1&&(t instanceof ArrayBuffer||W1(t))?n?i(t):Z1(new Blob([t]),i):i(F1[e]+(t||"")),Z1=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function V1(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let H1;const G1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J1="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let Rwe=0;Rwe<64;Rwe++)J1[G1.charCodeAt(Rwe)]=Rwe;const Y1="function"==typeof ArrayBuffer,X1=(e,t)=>{if("string"!=typeof e)return{type:"message",data:e2(e,t)};const n=e.charAt(0);if("b"===n)return{type:"message",data:Q1(e.substring(1),t)};return D1[n]?e.length>1?{type:D1[n],data:e.substring(1)}:{type:D1[n]}:z1},Q1=(e,t)=>{if(Y1){const n=(e=>{let t,n,i,a,r,o=.75*e.length,s=e.length,c=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);const p=new ArrayBuffer(o),l=new Uint8Array(p);for(t=0;t<s;t+=4)n=J1[e.charCodeAt(t)],i=J1[e.charCodeAt(t+1)],a=J1[e.charCodeAt(t+2)],r=J1[e.charCodeAt(t+3)],l[c++]=n<<2|i>>4,l[c++]=(15&i)<<4|a>>2,l[c++]=(3&a)<<6|63&r;return p})(e);return e2(n,t)}return{base64:!0,data:e}},e2=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,t2=String.fromCharCode(30);function n2(){return new TransformStream({transform(e,t){!function(e,t){$1&&e.data instanceof Blob?e.data.arrayBuffer().then(V1).then(t):q1&&(e.data instanceof ArrayBuffer||W1(e.data))?t(V1(e.data)):K1(e,!1,e=>{H1||(H1=new TextEncoder),t(H1.encode(e))})}(e,n=>{const i=n.length;let a;if(i<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,i);else if(i<65536){a=new Uint8Array(3);const e=new DataView(a.buffer);e.setUint8(0,126),e.setUint16(1,i)}else{a=new Uint8Array(9);const e=new DataView(a.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(i))}e.data&&"string"!=typeof e.data&&(a[0]|=128),t.enqueue(a),t.enqueue(n)})}})}let i2;function a2(e){return e.reduce((e,t)=>e+t.length,0)}function r2(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let i=0;for(let a=0;a<t;a++)n[a]=e[0][i++],i===e[0].length&&(e.shift(),i=0);return e.length&&i<e[0].length&&(e[0]=e[0].slice(i)),n}function o2(e){if(e)return function(e){for(var t in o2.prototype)e[t]=o2.prototype[t];return e}(e)}o2.prototype.on=o2.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},o2.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},o2.prototype.off=o2.prototype.removeListener=o2.prototype.removeAllListeners=o2.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,i=this._callbacks["$"+e];if(!i)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var a=0;a<i.length;a++)if((n=i[a])===t||n.fn===t){i.splice(a,1);break}return 0===i.length&&delete this._callbacks["$"+e],this},o2.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(n){i=0;for(var a=(n=n.slice(0)).length;i<a;++i)n[i].apply(this,t)}return this},o2.prototype.emitReserved=o2.prototype.emit,o2.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},o2.prototype.hasListeners=function(e){return!!this.listeners(e).length};const s2="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),c2="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function p2(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}const l2=c2.setTimeout,u2=c2.clearTimeout;function d2(e,t){t.useNativeTimers?(e.setTimeoutFn=l2.bind(c2),e.clearTimeoutFn=u2.bind(c2)):(e.setTimeoutFn=c2.setTimeout.bind(c2),e.clearTimeoutFn=c2.clearTimeout.bind(c2))}function f2(e){return"string"==typeof e?function(e){let t=0,n=0;for(let i=0,a=e.length;i<a;i++)t=e.charCodeAt(i),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(i++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))}function m2(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}class h2 extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class g2 extends o2{constructor(e){super(),this.writable=!1,d2(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved("error",new h2(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=X1(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}class v2 extends g2{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once("pollComplete",function(){--e||t()})),this.writable||(e++,this.once("drain",function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const n=e.split(t2),i=[];for(let a=0;a<n.length;a++){const e=X1(n[a],t);if(i.push(e),"error"===e.type)break}return i})(e,this.socket.binaryType).forEach(e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)}),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const n=e.length,i=new Array(n);let a=0;e.forEach((e,r)=>{K1(e,!1,e=>{i[r]=e,++a===n&&t(i.join(t2))})})})(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=m2()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}let y2=!1;try{y2="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(Twe){}const b2=y2;function x2(){}class w2 extends v2{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(e,t)=>{this.onError("xhr post error",e,t)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(e,t)=>{this.onError("xhr poll error",e,t)}),this.pollXhr=e}}let _2=class e extends o2{constructor(e,t,n){super(),this.createRequest=e,d2(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=void 0!==n.data?n.data:null,this._create()}_create(){var t;const n=p2(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(n);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&i.setRequestHeader(e,this._opts.extraHeaders[e])}}catch(Owe){}if("POST"===this._method)try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(Owe){}try{i.setRequestHeader("Accept","*/*")}catch(Owe){}null===(t=this._opts.cookieJar)||void 0===t||t.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var e;3===i.readyState&&(null===(e=this._opts.cookieJar)||void 0===e||e.parseCookies(i.getResponseHeader("set-cookie"))),4===i.readyState&&(200===i.status||1223===i.status?this._onLoad():this.setTimeoutFn(()=>{this._onError("number"==typeof i.status?i.status:0)},0))},i.send(this._data)}catch(Owe){return void this.setTimeoutFn(()=>{this._onError(Owe)},0)}"undefined"!=typeof document&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(t){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=x2,t)try{this._xhr.abort()}catch(Owe){}"undefined"!=typeof document&&delete e.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};if(_2.requestsCount=0,_2.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",k2);else if("function"==typeof addEventListener){addEventListener("onpagehide"in c2?"pagehide":"unload",k2,!1)}function k2(){for(let e in _2.requests)_2.requests.hasOwnProperty(e)&&_2.requests[e].abort()}const E2=function(){const e=S2({xdomain:!1});return e&&null!==e.responseType}();function S2(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||b2))return new XMLHttpRequest}catch(Owe){}if(!t)try{return new(c2[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(Owe){}}const A2="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class T2 extends g2{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,n=A2?{}:p2(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(Twe){return this.emitReserved("error",Twe)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],i=t===e.length-1;K1(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch(Owe){}i&&s2(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=m2()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const O2=c2.WebSocket||c2.MozWebSocket;const R2={websocket:class extends T2{createSocket(e,t,n){return A2?new O2(e,t,n):t?new O2(e,t):new O2(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends g2{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(Twe){return this.emitReserved("error",Twe)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=function(e,t){i2||(i2=new TextDecoder);const n=[];let i=0,a=-1,r=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(0===i){if(a2(n)<1)break;const e=r2(n,1);r=!(128&~e[0]),a=127&e[0],i=a<126?3:126===a?1:2}else if(1===i){if(a2(n)<2)break;const e=r2(n,2);a=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),i=3}else if(2===i){if(a2(n)<8)break;const e=r2(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),r=t.getUint32(0);if(r>Math.pow(2,21)-1){s.enqueue(z1);break}a=r*Math.pow(2,32)+t.getUint32(4),i=3}else{if(a2(n)<a)break;const e=r2(n,a);s.enqueue(X1(r?e:i2.decode(e),t)),i=0}if(0===a||a>e){s.enqueue(z1);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),i=n2();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const a=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),a())}).catch(e=>{})};a();const r={type:"open"};this.query.sid&&(r.data=`{"sid":"${this.query.sid}"}`),this._writer.write(r).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],i=t===e.length-1;this._writer.write(n).then(()=>{i&&s2(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}},polling:class extends w2{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=E2&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new _2(S2,this.uri(),e)}}},j2=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,I2=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function C2(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),i=e.indexOf("]");-1!=n&&-1!=i&&(e=e.substring(0,n)+e.substring(n,i).replace(/:/g,";")+e.substring(i,e.length));let a=j2.exec(e||""),r={},o=14;for(;o--;)r[I2[o]]=a[o]||"";return-1!=n&&-1!=i&&(r.source=t,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=function(e,t){const n=/\/{2,9}/g,i=t.replace(n,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||i.splice(0,1);"/"==t.slice(-1)&&i.splice(i.length-1,1);return i}(0,r.path),r.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,i){t&&(n[t]=i)}),n}(0,r.query),r}const N2="function"==typeof addEventListener&&"function"==typeof removeEventListener,B2=[];N2&&addEventListener("offline",()=>{B2.forEach(e=>e())},!1);class P2 extends o2{constructor(e,t){if(super(),this.binaryType="arraybuffer",this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const n=C2(e);t.hostname=n.host,t.secure="https"===n.protocol||"wss"===n.protocol,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=C2(t.host).host);d2(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{const t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},n=e.split("&");for(let i=0,a=n.length;i<a;i++){let e=n[i].split("=");t[decodeURIComponent(e[0])]=decodeURIComponent(e[1])}return t}(this.opts.query)),N2&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},B2.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);const e=this.opts.rememberUpgrade&&P2.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){this.readyState="open",P2.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const n=this.writeBuffer[t].data;if(n&&(e+=f2(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,s2(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,i){if("function"==typeof t&&(i=t,t=void 0),"function"==typeof n&&(i=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const a={type:e,data:t,options:n};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(P2.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),N2&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=B2.indexOf(this._offlineEventListener);-1!==e&&B2.splice(e,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}P2.protocol=4;class L2 extends P2{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;P2.priorWebsocketSuccess=!1;const i=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",e=>{if(!n)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;P2.priorWebsocketSuccess="websocket"===t.name,this.transport.pause(()=>{n||"closed"!==this.readyState&&(p(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}}))};function a(){n||(n=!0,p(),t.close(),t=null)}const r=e=>{const n=new Error("probe error: "+e);n.transport=t.name,a(),this.emitReserved("upgradeError",n)};function o(){r("transport closed")}function s(){r("socket closed")}function c(e){t&&e.name!==t.name&&a()}const p=()=>{t.removeListener("open",i),t.removeListener("error",r),t.removeListener("close",o),this.off("close",s),this.off("upgrading",c)};t.once("open",i),t.once("error",r),t.once("close",o),this.once("close",s),this.once("upgrading",c),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}let U2=class extends L2{constructor(e,t={}){const n="object"==typeof e?e:t;(!n.transports||n.transports&&"string"==typeof n.transports[0])&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(e=>R2[e]).filter(e=>!!e)),super(e,n)}};const M2="function"==typeof ArrayBuffer,F2=Object.prototype.toString,D2="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===F2.call(Blob),z2="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===F2.call(File);function $2(e){return M2&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||D2&&e instanceof Blob||z2&&e instanceof File}function q2(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(q2(e[t]))return!0;return!1}if($2(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return q2(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&q2(e[n]))return!0;return!1}function W2(e){const t=[],n=e.data,i=e;return i.data=K2(n,t),i.attachments=t.length,{packet:i,buffers:t}}function K2(e,t){if(!e)return e;if($2(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let i=0;i<e.length;i++)n[i]=K2(e[i],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=K2(e[i],t));return n}return e}function Z2(e,t){return e.data=V2(e.data,t),delete e.attachments,e}function V2(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=V2(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=V2(e[n],t));return e}const H2=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var G2;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(G2||(G2={}));function J2(e){return"[object Object]"===Object.prototype.toString.call(e)}class Y2 extends o2{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===G2.BINARY_EVENT;n||t.type===G2.BINARY_ACK?(t.type=n?G2.EVENT:G2.ACK,this.reconstructor=new X2(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!$2(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===G2[n.type])throw new Error("unknown packet type "+n.type);if(n.type===G2.BINARY_EVENT||n.type===G2.BINARY_ACK){const i=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const a=e.substring(i,t);if(a!=Number(a)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(a)}if("/"===e.charAt(t+1)){const i=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(i,t)}else n.nsp="/";const i=e.charAt(t+1);if(""!==i&&Number(i)==i){const i=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(!Y2.isPayloadValid(n.type,i))throw new Error("invalid payload");n.data=i}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(Owe){return!1}}static isPayloadValid(e,t){switch(e){case G2.CONNECT:return J2(t);case G2.DISCONNECT:return void 0===t;case G2.CONNECT_ERROR:return"string"==typeof t||J2(t);case G2.EVENT:case G2.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===H2.indexOf(t[0]));case G2.ACK:case G2.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class X2{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=Z2(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Q2=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Y2,Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==G2.EVENT&&e.type!==G2.ACK||!q2(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===G2.EVENT?G2.BINARY_EVENT:G2.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==G2.BINARY_EVENT&&e.type!==G2.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=W2(e),n=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(n),i}},get PacketType(){return G2},protocol:5},Symbol.toStringTag,{value:"Module"}));function e4(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const t4=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class n4 extends o2{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[e4(e,"open",this.onopen.bind(this)),e4(e,"packet",this.onpacket.bind(this)),e4(e,"error",this.onerror.bind(this)),e4(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var n,i,a;if(t4.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const r={type:G2.EVENT,data:t,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,n=t.pop();this._registerAckCallback(e,n),r.id=e}const o=null===(i=null===(n=this.io.engine)||void 0===n?void 0:n.transport)||void 0===i?void 0:i.writable,s=this.connected&&!(null===(a=this.io.engine)||void 0===a?void 0:a._hasPingExpired());return this.flags.volatile&&!o||(s?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,t){var n;const i=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===i)return void(this.acks[e]=t);const a=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))},i),r=(...e)=>{this.io.clearTimeoutFn(a),t.apply(this,e)};r.withError=!0,this.acks[e]=r}emitWithAck(e,...t){return new Promise((n,i)=>{const a=(e,t)=>e?i(e):n(t);a.withError=!0,t.push(a),this.emit(e,...t)})}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...i)=>{if(n!==this._queue[0])return;return null!==e?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...i)),n.pending=!1,this._drainQueue()}),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:G2.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case G2.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case G2.EVENT:case G2.BINARY_EVENT:this.onevent(e);break;case G2.ACK:case G2.BINARY_ACK:this.onack(e);break;case G2.DISCONNECT:this.ondisconnect();break;case G2.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...i){n||(n=!0,t.packet({type:G2.ACK,id:e,data:i}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:G2.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}function i4(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}i4.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+n:e-n}return 0|Math.min(e,this.max)},i4.prototype.reset=function(){this.attempts=0},i4.prototype.setMin=function(e){this.ms=e},i4.prototype.setMax=function(e){this.max=e},i4.prototype.setJitter=function(e){this.jitter=e};class a4 extends o2{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,d2(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new i4({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||Q2;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new U2(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=e4(t,"open",function(){n.onopen(),e&&e()}),a=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},r=e4(t,"error",a);if(!1!==this._timeout){const e=this._timeout,n=this.setTimeoutFn(()=>{i(),a(new Error("timeout")),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(i),this.subs.push(r),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(e4(e,"ping",this.onping.bind(this)),e4(e,"data",this.ondata.bind(this)),e4(e,"error",this.onerror.bind(this)),e4(e,"close",this.onclose.bind(this)),e4(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(Owe){this.onclose("parse error",Owe)}}ondecoded(e){s2(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new n4(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const n of t){if(this.nsps[n].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),null===(n=this.engine)||void 0===n||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const r4={};function o4(e,t){"object"==typeof e&&(t=e,e=void 0);const n=function(e,t="",n){let i=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),i=C2(e)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const a=-1!==i.host.indexOf(":")?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+a+":"+i.port+t,i.href=i.protocol+"://"+a+(n&&n.port===i.port?"":":"+i.port),i}(e,(t=t||{}).path||"/socket.io"),i=n.source,a=n.id,r=n.path,o=r4[a]&&r in r4[a].nsps;let s;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?s=new a4(i,t):(r4[a]||(r4[a]=new a4(i,t)),s=r4[a]),n.query&&!t.query&&(t.query=n.queryKey),s.socket(n.path,t)}Object.assign(o4,{Manager:a4,Socket:n4,io:o4,connect:o4});const s4=class e{constructor(e){if(lr(this,"client"),lr(this,"config"),lr(this,"logger",oc.getInstance()),lr(this,"socket",null),lr(this,"socketConnected",!1),lr(this,"connectionMode","auto"),lr(this,"wsBaseUrl",null),this.config=e,!e.apiKey)throw new sc("API key is required");if(!e.network)throw new sc("Network is required");const t={"x-api-key":e.apiKey,"Content-Type":"application/json"};this.client=qs.create({baseURL:"https://v2-api.tier.bot/api",headers:t}),this.logger=oc.getInstance(),e.wsBaseUrl&&(this.wsBaseUrl=e.wsBaseUrl),this.connectionMode=e.connectionMode||"websocket",this.wsBaseUrl||"http"===this.connectionMode||this.fetchWebSocketServers().catch(e=>this.logger.warn("Failed to fetch WebSocket servers:",e))}async getFileMetadata(e){try{const t=await qs.get(e),n=t.headers["content-type"]||"";return{size:parseInt(t.headers["content-length"]||"0",10),mimeType:n}}catch(t){throw this.logger.error("Error fetching file metadata:",t),new sc("Unable to fetch file metadata")}}getMimeType(t){const n=t.toLowerCase().split(".").pop();if(!n)throw new sc("File must have an extension");const i=e.VALID_MIME_TYPES[n];if(!i)throw new sc(`Unsupported file type: ${n}`);return i}validateRequest(t){if(this.logger.debug("Validating request:",t),!t.holderId||""===t.holderId.trim())throw this.logger.warn("holderId is missing or empty"),new sc("holderId is required");if(!e.VALID_MODES.includes(t.mode))throw new sc(`Invalid mode: ${t.mode}. Must be one of: ${e.VALID_MODES.join(", ")}`);if("hashinal"===t.mode&&!t.jsonFileURL&&!t.metadataObject)throw new sc("Hashinal mode requires either jsonFileURL or metadataObject");if(t.onlyJSONCollection&&"hashinal-collection"!==t.mode)throw new sc("onlyJSONCollection can only be used with hashinal-collection mode");this.validateFileInput(t.file)}normalizeMimeType(e){return"image/vnd.microsoft.icon"===e?(this.logger.debug("Normalizing MIME type from image/vnd.microsoft.icon to image/x-icon"),"image/x-icon"):e}validateMimeType(t){return!!Object.values(e.VALID_MIME_TYPES).includes(t)||"image/vnd.microsoft.icon"===t&&(this.logger.debug("Accepting alternative MIME type for ICO: image/vnd.microsoft.icon"),!0)}validateFileInput(t){if("base64"===t.type){if(!t.base64)throw new sc("Base64 data is required");const n=t.base64.replace(/^data:.*?;base64,/,"");if(Math.ceil(.75*n.length)>e.MAX_BASE64_SIZE)throw new sc(`File size exceeds maximum limit of ${e.MAX_BASE64_SIZE/1024/1024}MB`);const i=t.mimeType||this.getMimeType(t.fileName);if(!this.validateMimeType(i))throw new sc("File must have one of the supported MIME types");"image/vnd.microsoft.icon"===t.mimeType&&(t.mimeType=this.normalizeMimeType(t.mimeType))}else if("url"===t.type&&!t.url)throw new sc("URL is required")}async detectMimeTypeFromBase64(e){if(e.startsWith("data:")){const t=e.match(/^data:([^;]+);base64,/);if(t&&t.length>1)return t[1]}try{const t=e.replace(/\s/g,""),n=_r.from(t,"base64"),i=await async function(e,t){return new M1(t).fromBuffer(e)}(n);return(null==i?void 0:i.mime)||"application/octet-stream"}catch(Twe){return this.logger.warn("Failed to detect MIME type from buffer"),"application/octet-stream"}}async startInscription(t){var n,i;try{this.validateRequest(t);let n=t.file.mimeType;if("url"===t.file.type){const i=await this.getFileMetadata(t.file.url);if(n=i.mimeType||n,i.size>e.MAX_URL_FILE_SIZE)throw new sc(`File size exceeds maximum URL file limit of ${e.MAX_URL_FILE_SIZE/1024/1024}MB`)}else"base64"===t.file.type&&(n=await this.detectMimeTypeFromBase64(t.file.base64));if("image/vnd.microsoft.icon"===n&&(n=this.normalizeMimeType(n)),t.jsonFileURL){if("application/json"!==(await this.getFileMetadata(t.jsonFileURL)).mimeType)throw new sc("JSON file must be of type application/json")}const i={holderId:t.holderId,mode:t.mode,network:this.config.network,onlyJSONCollection:t.onlyJSONCollection?1:0,creator:t.creator,description:t.description,fileStandard:t.fileStandard,metadataObject:t.metadataObject,jsonFileURL:t.jsonFileURL};let a;return a="url"===t.file.type?await this.client.post("/inscriptions/start-inscription",{...i,fileURL:t.file.url}):await this.client.post("/inscriptions/start-inscription",{...i,fileBase64:t.file.base64,fileName:t.file.fileName,fileMimeType:n||this.getMimeType(t.file.fileName)}),a.data}catch(a){if(a instanceof sc)throw a;if(qs.isAxiosError(a))throw new Error((null==(i=null==(n=a.response)?void 0:n.data)?void 0:i.message)||"Failed to start inscription");throw a}}async executeTransaction(e,t){var n,a;try{const r="mainnet"===t.network?i.Client.forMainnet():i.Client.forTestnet(),o=new pl(t.network),s=await o.requestAccount(t.accountId),c=null==(n=null==s?void 0:s.key)?void 0:n._type,p="string"==typeof t.privateKey;let l;if(c&&p)l=(null==(a=null==c?void 0:c.toLowerCase())?void 0:a.includes("ecdsa"))?i.PrivateKey.fromStringECDSA(t.privateKey):i.PrivateKey.fromStringED25519(t.privateKey);else if(!c&&p){const e=p?dl(t.privateKey):void 0;l="ed25519"===(null==e?void 0:e.detectedType)?i.PrivateKey.fromStringED25519(t.privateKey):i.PrivateKey.fromStringECDSA(t.privateKey)}else l=t.privateKey;r.setOperator(t.accountId,l);const u=i.TransferTransaction.fromBytes(_r.from(e,"base64")),d=await u.sign(l),f=await d.execute(r),m=(await f.getReceipt(r)).status.toString();if("SUCCESS"!==m)throw new Error(`Transaction failed with status: ${m}`);return f.transactionId.toString()}catch(r){throw new Error(`Failed to execute transaction: ${r instanceof Error?r.message:"Unknown error"}`)}}async executeTransactionWithSigner(e,t){try{const n=i.TransferTransaction.fromBytes(_r.from(e,"base64")),a=await n.executeWithSigner(t),r=(await a.getReceiptWithSigner(t)).status.toString();if("SUCCESS"!==r)throw new Error(`Transaction failed with status: ${r}`);return a.transactionId.toString()}catch(n){throw new Error(`Failed to execute transaction: ${n instanceof Error?n.message:"Unknown error"}`)}}async inscribeAndExecute(e,t,n,i){const a=(null==i?void 0:i.waitForCompletion)??!0,r=(null==i?void 0:i.maxWaitTime)??12e4,o=(null==i?void 0:i.checkInterval)??2e3;if(this.logger.debug("inscribeAndExecute called",{hasProgressCallback:!!n,connectionMode:this.connectionMode,wsBaseUrl:this.wsBaseUrl}),"http"!==this.connectionMode){const i="websocket"===this.connectionMode||"auto"===this.connectionMode&&await this.detectBestConnection();if(i)try{return await this.inscribeViaWebSocket(e,t,n)}catch(l){throw this.logger.error("WebSocket inscription failed, falling back to HTTP:",l),l}else this.logger.info(`Not using WebSocket: useWebSocket=${i}, wsBaseUrl=${this.wsBaseUrl}`)}else this.logger.info(`Not using WebSocket: hasCallback=${!!n}, connectionMode=${this.connectionMode}`);const s=await this.startInscription(e);if(!s.transactionBytes)throw this.logger.error("No transaction bytes returned from inscription request",s),new Error("No transaction bytes returned from inscription request");this.logger.info("executing transaction");const c=await this.executeTransaction(s.transactionBytes,t),p={jobId:s.tx_id,transactionId:c};if(a){n&&n({stage:"confirming",message:"Transaction executed, waiting for inscription to complete",progressPercent:5});const e=Math.floor(r/o),t=await this.waitForInscription(c,e,o,!0,n);return{...p,topicId:t.topic_id,status:t.status,completed:t.completed}}return p}async fetchWebSocketServers(){try{const e=await this.client.get("/inscriptions/websocket-servers"),{servers:t,recommended:n}=e.data;if(n)this.wsBaseUrl=n;else if(t&&t.length>0){const e=t.filter(e=>"active"===e.status);if(e.length>0){const t=e[0];this.wsBaseUrl=t.url}}}catch(e){this.logger.debug("Could not fetch WebSocket servers, will use HTTP only")}}async detectBestConnection(){if(!this.wsBaseUrl)return!1;try{const e=o4(this.wsBaseUrl,{auth:{apiKey:this.config.apiKey},transports:["websocket"],timeout:3e3});return new Promise(t=>{const n=setTimeout(()=>{e.disconnect(),t(!1)},3e3);e.on("connect",()=>{clearTimeout(n),e.disconnect(),t(!0)}),e.on("connect_error",()=>{clearTimeout(n),e.disconnect(),t(!1)})})}catch(Owe){return!1}}async inscribeViaWebSocket(e,t,n){if(!this.wsBaseUrl){const e=(await this.client.get("/inscriptions/websocket-servers")).data.recommended;if(!e)throw new Error("No WebSocket servers available");this.wsBaseUrl=e}return await this.connectWebSocket(),new Promise((i,a)=>{if(!this.socket)return a(new Error("WebSocket not connected"));let r,o,s,c;const p=()=>{var e,t,n;c&&clearTimeout(c),null==(e=this.socket)||e.off("inscription-progress",d),null==(t=this.socket)||t.off("inscription-complete",l),null==(n=this.socket)||n.off("inscription-error",u)};c=setTimeout(()=>{this.logger.error("WebSocket inscription timeout after 60 seconds",{jobId:r,transactionId:o,lastTopicId:s}),p(),i({jobId:r,transactionId:o,topicId:s,topic_id:s,status:"timeout",completed:!1})},6e4);const l=e=>{p(),i({jobId:r,transactionId:o,topicId:e.topicId||e.topic_id,topic_id:e.topicId||e.topic_id,status:"completed",completed:!0})},u=e=>{p(),a(new Error(e.error||"Inscription failed"))},d=e=>{this.logger.debug("Progress event received:",{jobId:e.jobId,status:e.status,progress:e.progress,topicId:e.topicId||e.topic_id,topic_id:e.topicId||e.topic_id}),(e.topicId||e.topic_id)&&(s=e.topicId||e.topic_id),n&&n({stage:"completed"===e.status?"completed":"confirming",message:`Processing inscription: ${e.status}`,progressPercent:e.progress||0,details:e}),"completed"!==e.status&&100!==e.progress||(this.logger.info("Inscription completed via progress handler",{status:e.status,progress:e.progress,topicId:e.topicId||e.topic_id||s,topic_id:e.topicId||e.topic_id||s}),p(),i({jobId:r,transactionId:o,topicId:e.topicId||e.topic_id||s,topic_id:e.topicId||e.topic_id||s,status:"completed",completed:!0}))};this.socket.on("inscription-progress",d),this.socket.on("inscription-complete",l),this.socket.on("inscription-error",u),this.socket.emit("start-inscription",{...e,network:this.config.network},async e=>{if(!e.success)return p(),a(new Error(e.error||"Inscription failed"));try{if(!e.transactionBytes)throw new Error("No transaction bytes returned from WebSocket inscription");if(o=await this.executeTransaction(e.transactionBytes,t),r=e.jobId||e.tx_id,!r)throw new Error("No job ID returned from WebSocket inscription");n&&n({stage:"confirming",message:"Transaction executed, inscribing to HCS...",progressPercent:5}),this.logger.info("Transaction executed, waiting for inscription completion...",{jobId:r,transactionId:o})}catch(i){p(),a(i)}})})}async connectWebSocket(){if(!this.socketConnected||!this.socket){if(!this.wsBaseUrl)throw new Error("WebSocket URL not configured");return new Promise((e,t)=>{this.socket=o4(this.wsBaseUrl,{auth:{apiKey:this.config.apiKey},transports:["websocket","polling"]});const n=setTimeout(()=>{t(new Error("WebSocket connection timeout"))},1e4);this.socket.on("connect",()=>{clearTimeout(n),this.socketConnected=!0,this.logger.info("WebSocket connected"),e()}),this.socket.on("connect_error",e=>{clearTimeout(n),this.socketConnected=!1,t(new Error(`WebSocket connection failed: ${e.message}`))}),this.socket.on("disconnect",()=>{this.socketConnected=!1,this.logger.info("WebSocket disconnected")})})}}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null,this.socketConnected=!1)}async inscribe(e,t){const n=await this.startInscription(e);if(!n.transactionBytes)throw this.logger.error("No transaction bytes returned from inscription request",n),new Error("No transaction bytes returned from inscription request");this.logger.info("executing transaction");const i=await this.executeTransactionWithSigner(n.transactionBytes,t);return{jobId:n.tx_id,transactionId:i}}async retryWithBackoff(e,t=3,n=1e3){for(let a=0;a<t;a++)try{return await e()}catch(i){if(a===t-1)throw i;const e=n*Math.pow(2,a);await new Promise(t=>setTimeout(t,e)),this.logger.debug(`Retry attempt ${a+1}/${t} after ${e}ms delay`)}throw new Error("Retry operation failed")}async retrieveInscription(e){if(!e)throw new sc("Transaction ID is required");try{return await this.retryWithBackoff(async()=>{const t=(await this.client.get(`/inscriptions/retrieve-inscription?id=${e}`)).data;return{...t,jobId:t.id}})}catch(t){throw this.logger.error("Failed to retrieve inscription:",t),t}}async getInscriptionNumbers(e={}){try{return(await this.client.get("/inscriptions/numbers",{params:e})).data}catch(t){throw this.logger.error("Failed to fetch inscription numbers:",t),t}}static async authenticate(e){return new C1(e).authenticate()}static async createWithAuth(t){const n="client"===t.type?new N1({...t,logger:oc.getInstance()}):new C1(t),{apiKey:i}=await n.authenticate();return new e({apiKey:i,network:t.network||"mainnet",wsBaseUrl:t.wsBaseUrl,connectionMode:t.connectionMode||"websocket"})}async waitForInscription(e,t=30,n=4e3,i=!1,a){var r;let o=0,s=0;const c=(n,i,r,c)=>{if(a)try{s=Math.max(s,r),a({stage:n,message:i,progressPercent:s,details:{...c,txId:e,currentAttempt:o,maxAttempts:t}})}catch(Twe){this.logger.warn(`Error in progress callback: ${Twe}`)}};for(c("confirming","Starting inscription verification",0);o<t;){c("confirming",`Verifying inscription status (attempt ${o+1}/${t})`,5,{attempt:o+1});const a=await this.retrieveInscription(e);if(a.error)throw c("verifying",`Error: ${a.error}`,100,{error:a.error}),new Error(a.error);let s=5;void 0!==a.messages&&void 0!==a.maxMessages&&a.maxMessages>0?(s=Math.min(95,5+a.messages/a.maxMessages*90),a.completed&&(s=100)):"processing"===a.status?s=10:a.completed&&(s=100),c(a.completed?"completed":"confirming",a.completed?"Inscription completed successfully":`Processing inscription (${a.status})`,s,{status:a.status,messagesProcessed:a.messages,maxMessages:a.maxMessages,messageCount:a.messages,completed:a.completed,confirmedMessages:a.confirmedMessages,result:a});const p="hashinal"===a.mode,l="6"===(null==(r=a.fileStandard)?void 0:r.toString());if(p&&a.topic_id&&a.jsonTopicId&&(!i||a.completed))return c("completed","Inscription verification complete",100,{result:a}),a;if(!p&&!l&&a.topic_id&&(!i||a.completed))return c("completed","Inscription verification complete",100,{result:a}),a;if(l&&a.topic_id&&a.jsonTopicId&&a.registryTopicId&&(!i||a.completed))return c("completed","Inscription verification complete",100,{result:a}),a;await new Promise(e=>setTimeout(e,n)),o++}throw c("verifying",`Inscription ${e} did not complete within ${t} attempts`,100,{timedOut:!0}),new Error(`Inscription ${e} did not complete within ${t} attempts`)}async getHolderInscriptions(e){var t,n;if(!e.holderId)throw new sc("Holder ID is required");try{const t={holderId:e.holderId};e.includeCollections&&(t.includeCollections="1");return(await this.client.get("/inscriptions/holder-inscriptions",{params:t})).data}catch(i){if(this.logger.error("Failed to fetch holder inscriptions:",i),qs.isAxiosError(i))throw new Error((null==(n=null==(t=i.response)?void 0:t.data)?void 0:n.message)||"Failed to fetch holder inscriptions");throw i}}};lr(s4,"VALID_MODES",["file","upload","hashinal","hashinal-collection"]),lr(s4,"MAX_BASE64_SIZE",2097152),lr(s4,"MAX_URL_FILE_SIZE",104857600),lr(s4,"VALID_MIME_TYPES",{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",ico:"image/x-icon",heic:"image/heic",heif:"image/heif",bmp:"image/bmp",webp:"image/webp",tiff:"image/tiff",tif:"image/tiff",svg:"image/svg+xml",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",html:"text/html",htm:"text/html",css:"text/css",php:"application/x-httpd-php",java:"text/x-java-source",js:"application/javascript",mjs:"application/javascript",csv:"text/csv",json:"application/json",txt:"text/plain",glb:"model/gltf-binary",wav:"audio/wav",ogg:"audio/ogg",oga:"audio/ogg",flac:"audio/flac",aac:"audio/aac",m4a:"audio/mp4",avi:"video/x-msvideo",mov:"video/quicktime",mkv:"video/x-matroska",m4v:"video/mp4",mpg:"video/mpeg",mpeg:"video/mpeg",ts:"application/typescript",zip:"application/zip",rar:"application/vnd.rar",tar:"application/x-tar",gz:"application/gzip","7z":"application/x-7z-compressed",xml:"application/xml",yaml:"application/yaml",yml:"application/yaml",md:"text/markdown",markdown:"text/markdown",rtf:"application/rtf",gltf:"model/gltf+json",usdz:"model/vnd.usdz+zip",obj:"model/obj",stl:"model/stl",fbx:"application/octet-stream",ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2",eot:"application/vnd.ms-fontobject",psd:"application/vnd.adobe.photoshop",ai:"application/postscript",eps:"application/postscript",ps:"application/postscript",sqlite:"application/x-sqlite3",db:"application/x-sqlite3",apk:"application/vnd.android.package-archive",ics:"text/calendar",vcf:"text/vcard",py:"text/x-python",rb:"text/x-ruby",go:"text/x-go",rs:"text/x-rust",typescript:"application/typescript",jsx:"text/jsx",tsx:"text/tsx",sql:"application/sql",toml:"application/toml",avif:"image/avif",jxl:"image/jxl",weba:"audio/webm",wasm:"application/wasm"});let c4=s4;const p4=class e extends r.BaseServiceBuilder{constructor(e){super(e)}getOperationalMode(){return this.hederaKit.operationalMode}static setSignerProvider(t){e.signerProvider=t}static setWalletInfoResolver(t){e.walletInfoResolver=t}static setStartInscriptionDelegate(t){e.startInscriptionDelegate=t}static setWalletExecutor(t){e.walletExecutor=t}static setPreferWalletOnly(t){e.preferWalletOnly=!!t}async getSigner(){const t=e.signerProvider;if(!t)return null;try{const e=t();return e&&"function"==typeof e.then?await e:e}catch{return null}}async getInscriptionSDK(e){if(this.inscriptionSDK)return this.inscriptionSDK;const t=this.hederaKit.client.network.toString().includes("mainnet")?"mainnet":"testnet",n=await this.getSigner(),i=this.hederaKit.signer.getAccountId().toString();if(n)this.inscriptionSDK=await c4.createWithAuth({type:"client",accountId:i,signer:n,network:t});else{const e=this.hederaKit.signer?.getOperatorPrivateKey();e&&(this.inscriptionSDK=await c4.createWithAuth({type:"server",accountId:i,privateKey:e.toStringRaw(),network:t}))}return this.inscriptionSDK}async inscribe(e,t){const n={accountId:this.hederaKit.signer.getAccountId().toString(),privateKey:this.hederaKit.signer?.getOperatorPrivateKey()?this.hederaKit.signer.getOperatorPrivateKey().toStringRaw():"",network:this.hederaKit.client.network.toString().includes("mainnet")?"mainnet":"testnet"};return await a.inscribe(e,n,t)}async inscribeWithSigner(e,t,n){return await a.inscribeWithSigner(e,t,n)}async inscribeAuto(t,i){const r=await this.getSigner();if(r)return this.inscribeWithSigner(t,r,i);const o=e.walletInfoResolver?await e.walletInfoResolver():null;if(e.preferWalletOnly&&!o){const e=new Error("Wallet unavailable: connect a wallet or switch to autonomous mode");throw e.code="wallet_unavailable",e}if(o&&e.startInscriptionDelegate&&e.walletExecutor){const r=o.accountId,s=o.network,c=i,p={holderId:r,metadata:c.metadata||{},tags:i.tags||[],mode:i.mode||"file"};void 0!==c.fileStandard&&(p.fileStandard=c.fileStandard),void 0!==c.chunkSize&&(p.chunkSize=c.chunkSize);let l={...p};switch(t.type){case"url":l={...p,file:{type:"url",url:t.url}};break;case"file":l={...p,file:{type:"path",path:t.path}};break;case"buffer":l={...p,file:{type:"base64",base64:n.Buffer.from(t.buffer).toString("base64"),fileName:t.fileName,mimeType:t.mimeType}}}"hashinal"===i.mode&&(l.metadataObject=c.metadata,l.creator=c.metadata?.creator||r,l.description=c.metadata?.description,"string"==typeof c.jsonFileURL&&c.jsonFileURL.length>0&&(l.jsonFileURL=c.jsonFileURL));const u=await e.startInscriptionDelegate(l,s),d=u;if(Boolean(d?.inscription)&&d?.confirmed){const e=u;return this.logger.info("inscription already completed, short circuiting",u),{quote:!1,confirmed:!0===e.confirmed,result:e.result,inscription:e.inscription}}const f=u;if(!f||!f.transactionBytes)throw new Error("Failed to start inscription (no transaction bytes)");const m=await e.walletExecutor(f.transactionBytes,s),h=m?.transactionId||"";if(!i.quoteOnly&&(i.waitForConfirmation??!0)){this.logger.debug("Will be retrieving inscription");const e=i.waitMaxAttempts??60,t=i.waitIntervalMs??5e3,n=await this.getInscriptionSDK(i);if(n){const i=await n.waitForInscription(h,e,t,!0),r=a.getTopicId(i)??f.topic_id,o={quote:!1,confirmed:!0,result:{jobId:f.tx_id||"",transactionId:h,topicId:r},inscription:i};return this.logger.debug("retrieved inscription",o,i),o}}return{quote:!1,confirmed:!1,result:{jobId:f.tx_id||"",transactionId:h,status:f.status,completed:f.completed},inscription:f.topic_id?{topic_id:f.topic_id}:void 0}}if(e.preferWalletOnly){const e=new Error("Wallet unavailable: connect a wallet or switch to autonomous mode");throw e.code="wallet_unavailable",e}return this.inscribe(t,i)}async retrieveInscription(e,t){const n=this.hederaKit.signer.getAccountId().toString(),i=this.hederaKit.signer?.getOperatorPrivateKey()?this.hederaKit.signer.getOperatorPrivateKey().toStringRaw():"";return await a.retrieveInscription(e,{...t,accountId:n,privateKey:i})}async close(){this.inscriptionSDK=void 0}};p4.preferWalletOnly=!1;let l4=p4;const u4=new class{constructor(){this.handlers=new Map}register(e,t){this.handlers.set(e,t)}has(e){return this.handlers.has(e)}async build(e,t,n){const i=this.handlers.get(e);return i?await i({hederaKit:t,request:n}):null}};async function d4(e,t){const a="mainnet"===(e.client.network.toString().includes("mainnet")?"mainnet":"testnet")?i.Client.forMainnet():i.Client.forTestnet(),r=e.signer.getAccountId().toString(),o=i.AccountId.fromString(r);if("function"==typeof t.setTransactionId&&t.setTransactionId(i.TransactionId.generate(o)),"function"==typeof t.setAutoRenewAccountId)try{t.setAutoRenewAccountId(r)}catch{}const s=await t.freezeWith(a);return{transactionBytes:n.Buffer.from(s.toBytes()).toString("base64")}}async function f4(e,t,a,r){const o="mainnet"===(e.client.network.toString().includes("mainnet")?"mainnet":"testnet")?i.Client.forMainnet():i.Client.forTestnet(),s=e.signer.getAccountId().toString(),c=i.AccountId.fromString(s),p=(new i.TopicMessageSubmitTransaction).setTopicId(i.TopicId.fromString(t)).setTransactionId(i.TransactionId.generate(c)).setMessage(a),l=await p.freezeWith(o);return{transactionBytes:n.Buffer.from(l.toBytes()).toString("base64")}}function m4(e){return"object"==typeof e&&null!==e}function h4(e,t){const n=e[t];return"string"==typeof n?n:void 0}function g4(e,t){const n=e[t];return"number"==typeof n&&Number.isFinite(n)?n:void 0}function v4(e,t){const n=e[t];return m4(n)?n:void 0}u4.register("hcs2.createRegistry",async({hederaKit:e,request:t})=>{const n=t?.options||{};let i;try{const t=e?.signer?.getOperatorPrivateKey?.();i=t?.publicKey}catch{}const r=a.buildHcs2CreateRegistryTx({registryType:n.registryType??a.HCS2RegistryType.INDEXED,ttl:n.ttl??86400,adminKey:n.adminKey,submitKey:n.submitKey,operatorPublicKey:i});return await d4(e,r)}),u4.register("hcs2.migrateRegistry",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs2.migrateRegistry: invalid request payload");const n=h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs2.migrateRegistry: registryTopicId is required");const i=v4(t,"options")||{},r=h4(i,"targetTopicId")||"",o=h4(i,"metadata"),s=h4(i,"memo"),c=a.buildHcs2MigrateTx({registryTopicId:n,targetTopicId:r,metadata:o,memo:s});return await d4(e,c)}),u4.register("hcs2.submitMessage",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs2.submitMessage: invalid request payload");const n=h4(t,"topicId")||h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs2.submitMessage: topicId is required");const i=t.payload,a="string"==typeof i?i:JSON.stringify(i??{});return await f4(e,n,a)}),u4.register("hcs2.registerEntry",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs2.registerEntry: invalid request payload");const n=h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs2.registerEntry: registryTopicId is required");const i=v4(t,"options")||{},r=h4(i,"targetTopicId")||"",o=h4(i,"metadata"),s=h4(i,"memo"),c=a.buildHcs2RegisterTx({registryTopicId:n,targetTopicId:r,metadata:o,memo:s});return await d4(e,c)}),u4.register("hcs2.updateEntry",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs2.updateEntry: invalid request payload");const n=h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs2.updateEntry: registryTopicId is required");const i=v4(t,"options")||{},r=h4(i,"targetTopicId")||"",o=h4(i,"uid")||"",s=h4(i,"metadata"),c=h4(i,"memo"),p=a.buildHcs2UpdateTx({registryTopicId:n,uid:o,targetTopicId:r,metadata:s,memo:c});return await d4(e,p)}),u4.register("hcs2.deleteEntry",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs2.deleteEntry: invalid request payload");const n=h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs2.deleteEntry: registryTopicId is required");const i=v4(t,"options")||{},r=h4(i,"uid")||"",o=h4(i,"memo"),s=a.buildHcs2DeleteTx({registryTopicId:n,uid:r,memo:o});return await d4(e,s)}),u4.register("hcs6.createRegistry",async({hederaKit:e,request:t})=>{const n=m4(t)?v4(t,"options"):void 0,i=n?g4(n,"ttl"):void 0;let r;try{const t=e?.signer?.getOperatorPrivateKey?.();r=t?.publicKey}catch{}const o=a.buildHcs6CreateRegistryTx({ttl:i??86400,operatorPublicKey:r});return await d4(e,o)}),u4.register("hcs6.registerEntry",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs6.registerEntry: invalid request payload");const n=h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs6.registerEntry: registryTopicId is required");const i=v4(t,"options")||{},r=h4(i,"targetTopicId")||"",o=h4(i,"memo"),s=a.buildHcs6RegisterEntryTx({registryTopicId:n,targetTopicId:r,memo:o});return await d4(e,s)}),u4.register("hcs6.submitMessage",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs6.submitMessage: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs6.submitMessage: topicId is required");const i=t.payload,a="string"==typeof i?i:JSON.stringify(i??{});return await f4(e,n,a)}),u4.register("sendMessage",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("sendMessage: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("sendMessage: topicId is required");const i=t.data,r=h4(t,"memo")||"",o=e.signer.getAccountId().toString(),s="string"==typeof i?i:JSON.stringify(i??{}),c=a.buildHcs10SendMessageTx({connectionTopicId:n,operatorId:o,data:s,memo:r});return await d4(e,c)}),u4.register("submitConnectionRequest",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("submitConnectionRequest: invalid request payload");const n=h4(t,"inboundTopicId")||"";if(!n)throw new Error("submitConnectionRequest: inboundTopicId is required");const i=h4(t,"memo")||"",r=e.signer.getAccountId().toString(),o=a.buildHcs10SubmitConnectionRequestTx({inboundTopicId:n,operatorId:r,memo:i});return await d4(e,o)}),u4.register("hcs20.deploy",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs20.deploy: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs20.deploy: topicId is required");const i=h4(t,"name")||"",r=h4(t,"tick")||"",o=h4(t,"max")||"",s=h4(t,"lim"),c=h4(t,"metadata"),p=h4(t,"memo"),l=a.buildHcs20DeployTx({topicId:n,name:i,tick:r,max:o,lim:s,metadata:c,memo:p});return await d4(e,l)}),u4.register("hcs20.mint",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs20.mint: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs20.mint: topicId is required");const i=h4(t,"tick")||"",r=h4(t,"amt")||"",o=h4(t,"to")||"",s=h4(t,"memo"),c=a.buildHcs20MintTx({topicId:n,tick:i,amt:r,to:o,memo:s});return await d4(e,c)}),u4.register("hcs20.transfer",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs20.transfer: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs20.transfer: topicId is required");const i=h4(t,"tick")||"",r=h4(t,"amt")||"",o=h4(t,"from")||"",s=h4(t,"to")||"",c=h4(t,"memo"),p=a.buildHcs20TransferTx({topicId:n,tick:i,amt:r,from:o,to:s,memo:c});return await d4(e,p)}),u4.register("hcs20.burn",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs20.burn: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs20.burn: topicId is required");const i=h4(t,"tick")||"",r=h4(t,"amt")||"",o=h4(t,"from")||"",s=h4(t,"memo"),c=a.buildHcs20BurnTx({topicId:n,tick:i,amt:r,from:o,memo:s});return await d4(e,c)}),u4.register("hcs20.register",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs20.register: invalid request payload");const n=h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs20.register: registryTopicId is required");const i=h4(t,"topicId")||"",r=h4(t,"name")||"",o=t.isPrivate,s="boolean"==typeof o&&o,c=h4(t,"metadata"),p=h4(t,"memo"),l=a.buildHcs20RegisterTx({registryTopicId:n,name:r,topicId:i,isPrivate:s,metadata:c,memo:p});return await d4(e,l)}),u4.register("hcs12.createRegistry",async({hederaKit:e,request:t})=>{const n=m4(t)?v4(t,"options"):void 0,i=(n?g4(n,"ttl"):void 0)??60,r=n&&h4(n,"registry")||"hashlinks";let o;try{const t=e?.signer?.getOperatorPrivateKey?.();o=t?.publicKey}catch{}const s=a.buildHcs12CreateRegistryTopicTx({registry:r,ttl:i,operatorPublicKey:o});return await d4(e,s)}),u4.register("hcs12.submitMessage",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs12.submitMessage: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs12.submitMessage: topicId is required");const i=t.payload,r=a.buildHcs12SubmitMessageTx({topicId:n,payload:i});return await d4(e,r)}),u4.register("hcs12.registerAssembly",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs12.registerAssembly: invalid request payload");const n=h4(t,"assemblyTopicId")||"";if(!n)throw new Error("hcs12.registerAssembly: assemblyTopicId is required");const i=v4(t,"registration")||{},r=a.buildHcs12RegisterAssemblyTx({assemblyTopicId:n,registration:i});return await d4(e,r)}),u4.register("hcs12.addBlock",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs12.addBlock: invalid request payload");const n=h4(t,"assemblyTopicId")||"";if(!n)throw new Error("hcs12.addBlock: assemblyTopicId is required");const i=v4(t,"operation")||{},r=a.buildHcs12AddBlockToAssemblyTx({assemblyTopicId:n,operation:i});return await d4(e,r)}),u4.register("hcs12.addAction",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs12.addAction: invalid request payload");const n=h4(t,"assemblyTopicId")||"";if(!n)throw new Error("hcs12.addAction: assemblyTopicId is required");const i=v4(t,"operation")||{},r=a.buildHcs12AddActionToAssemblyTx({assemblyTopicId:n,operation:i});return await d4(e,r)}),u4.register("hcs12.updateAssembly",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs12.updateAssembly: invalid request payload");const n=h4(t,"assemblyTopicId")||"";if(!n)throw new Error("hcs12.updateAssembly: assemblyTopicId is required");const i=v4(t,"operation")||{},r=a.buildHcs12UpdateAssemblyTx({assemblyTopicId:n,operation:i});return await d4(e,r)}),u4.register("hcs7.submitMessage",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs7.submitMessage: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs7.submitMessage: topicId is required");const i=v4(t,"message")||{},r=a.buildHcs7SubmitMessageTx({topicId:n,message:i});return await d4(e,r)}),u4.register("hcs7.evm",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs7.evm: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs7.evm: topicId is required");const i=v4(t,"config")||{},r=a.buildHcs7EvmMessageTx({topicId:n,config:i});return await d4(e,r)}),u4.register("hcs7.wasm",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs7.wasm: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs7.wasm: topicId is required");const i=v4(t,"config")||{},r=a.buildHcs7WasmMessageTx({topicId:n,config:i});return await d4(e,r)});const y4=Object.freeze(Object.defineProperty({__proto__:null,ByteBuildRegistry:u4},Symbol.toStringTag,{value:"Module"}));var b4="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==jS?jS:"undefined"!=typeof self?self:{};function x4(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var w4,_4={};function k4(){return w4||(w4=1,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var t={},n={byteLength:function(e){var t=c(e),n=t[0],i=t[1];return 3*(n+i)/4-i},toByteArray:function(e){var t,n,i=c(e),o=i[0],s=i[1],p=new r(function(e,t,n){return 3*(t+n)/4-n}(0,o,s)),l=0,u=s>0?o-4:o;for(n=0;n<u;n+=4)t=a[e.charCodeAt(n)]<<18|a[e.charCodeAt(n+1)]<<12|a[e.charCodeAt(n+2)]<<6|a[e.charCodeAt(n+3)],p[l++]=t>>16&255,p[l++]=t>>8&255,p[l++]=255&t;2===s&&(t=a[e.charCodeAt(n)]<<2|a[e.charCodeAt(n+1)]>>4,p[l++]=255&t);1===s&&(t=a[e.charCodeAt(n)]<<10|a[e.charCodeAt(n+1)]<<4|a[e.charCodeAt(n+2)]>>2,p[l++]=t>>8&255,p[l++]=255&t);return p},fromByteArray:function(e){for(var t,n=e.length,a=n%3,r=[],o=16383,s=0,c=n-a;s<c;s+=o)r.push(l(e,s,s+o>c?c:s+o));1===a?(t=e[n-1],r.push(i[t>>2]+i[t<<4&63]+"==")):2===a&&(t=(e[n-2]<<8)+e[n-1],r.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return r.join("")}},i=[],a=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)i[s]=o[s],a[o.charCodeAt(s)]=s;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function p(e){return i[e>>18&63]+i[e>>12&63]+i[e>>6&63]+i[63&e]}function l(e,t,n){for(var i,a=[],r=t;r<n;r+=3)i=(e[r]<<16&16711680)+(e[r+1]<<8&65280)+(255&e[r+2]),a.push(p(i));return a.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63;var u={
|
|
157
|
+
*/().extname,o=/^\s*([^;\s]*)(?:;|\s|$)/,s=/^text\//i;function c(e){if(!e||"string"!=typeof e)return!1;var t=o.exec(e),n=t&&a[t[1].toLowerCase()];return n&&n.charset?n.charset:!(!t||!s.test(t[1]))&&"UTF-8"}e.charset=c,e.charsets={lookup:c},e.contentType=function(t){if(!t||"string"!=typeof t)return!1;var n=-1===t.indexOf("/")?e.lookup(t):t;if(!n)return!1;if(-1===n.indexOf("charset")){var i=e.charset(n);i&&(n+="; charset="+i.toLowerCase())}return n},e.extension=function(t){if(!t||"string"!=typeof t)return!1;var n=o.exec(t),i=n&&e.extensions[n[1].toLowerCase()];return!(!i||!i.length)&&i[0]},e.extensions=Object.create(null),e.lookup=function(t){if(!t||"string"!=typeof t)return!1;var n=r("x."+t).toLowerCase().substr(1);return n&&e.types[n]||!1},e.types=Object.create(null),t=e.extensions,n=e.types,i=["nginx","apache",void 0,"iana"],Object.keys(a).forEach(function(e){var r=a[e],o=r.extensions;if(o&&o.length){t[e]=o;for(var s=0;s<o.length;s++){var c=o[s];if(n[c]){var p=i.indexOf(a[n[c]].source),l=i.indexOf(r.source);if("application/octet-stream"!==n[c]&&(p>l||p===l&&"application/"===n[c].substr(0,12)))continue}n[c]=e}}})}(D0));var V0=(e=>(e[e.PERSONAL=0]="PERSONAL",e[e.AI_AGENT=1]="AI_AGENT",e[e.MCP_SERVER=2]="MCP_SERVER",e))(V0||{}),H0=(e=>(e[e.MANUAL=0]="MANUAL",e[e.AUTONOMOUS=1]="AUTONOMOUS",e))(H0||{}),G0=(e=>(e[e.TEXT_GENERATION=0]="TEXT_GENERATION",e[e.IMAGE_GENERATION=1]="IMAGE_GENERATION",e[e.AUDIO_GENERATION=2]="AUDIO_GENERATION",e[e.VIDEO_GENERATION=3]="VIDEO_GENERATION",e[e.CODE_GENERATION=4]="CODE_GENERATION",e[e.LANGUAGE_TRANSLATION=5]="LANGUAGE_TRANSLATION",e[e.SUMMARIZATION_EXTRACTION=6]="SUMMARIZATION_EXTRACTION",e[e.KNOWLEDGE_RETRIEVAL=7]="KNOWLEDGE_RETRIEVAL",e[e.DATA_INTEGRATION=8]="DATA_INTEGRATION",e[e.MARKET_INTELLIGENCE=9]="MARKET_INTELLIGENCE",e[e.TRANSACTION_ANALYTICS=10]="TRANSACTION_ANALYTICS",e[e.SMART_CONTRACT_AUDIT=11]="SMART_CONTRACT_AUDIT",e[e.GOVERNANCE_FACILITATION=12]="GOVERNANCE_FACILITATION",e[e.SECURITY_MONITORING=13]="SECURITY_MONITORING",e[e.COMPLIANCE_ANALYSIS=14]="COMPLIANCE_ANALYSIS",e[e.FRAUD_DETECTION=15]="FRAUD_DETECTION",e[e.MULTI_AGENT_COORDINATION=16]="MULTI_AGENT_COORDINATION",e[e.API_INTEGRATION=17]="API_INTEGRATION",e[e.WORKFLOW_AUTOMATION=18]="WORKFLOW_AUTOMATION",e))(G0||{}),J0=(e=>(e[e.RESOURCE_PROVIDER=0]="RESOURCE_PROVIDER",e[e.TOOL_PROVIDER=1]="TOOL_PROVIDER",e[e.PROMPT_TEMPLATE_PROVIDER=2]="PROMPT_TEMPLATE_PROVIDER",e[e.LOCAL_FILE_ACCESS=3]="LOCAL_FILE_ACCESS",e[e.DATABASE_INTEGRATION=4]="DATABASE_INTEGRATION",e[e.API_INTEGRATION=5]="API_INTEGRATION",e[e.WEB_ACCESS=6]="WEB_ACCESS",e[e.KNOWLEDGE_BASE=7]="KNOWLEDGE_BASE",e[e.MEMORY_PERSISTENCE=8]="MEMORY_PERSISTENCE",e[e.CODE_ANALYSIS=9]="CODE_ANALYSIS",e[e.CONTENT_GENERATION=10]="CONTENT_GENERATION",e[e.COMMUNICATION=11]="COMMUNICATION",e[e.DOCUMENT_PROCESSING=12]="DOCUMENT_PROCESSING",e[e.CALENDAR_SCHEDULE=13]="CALENDAR_SCHEDULE",e[e.SEARCH=14]="SEARCH",e[e.ASSISTANT_ORCHESTRATION=15]="ASSISTANT_ORCHESTRATION",e))(J0||{}),Y0=(e=>(e.DNS="dns",e.SIGNATURE="signature",e.CHALLENGE="challenge",e))(Y0||{});const X0=el({platform:Gp().min(1),handle:Gp().min(1)}),Q0=el({type:sl(H0),capabilities:Qp(sl(G0)).min(1),model:Gp().min(1),creator:Gp().optional()}),e1=el({url:Gp().min(1),transport:ol(["stdio","sse"])}),t1=el({type:sl(Y0),value:Gp(),dns_field:Gp().optional(),challenge_path:Gp().optional()}),n1=el({minVersion:Gp().optional()}),i1=el({name:Gp().min(1),description:Gp().min(1)}),a1=el({name:Gp().min(1),description:Gp().min(1)}),r1=el({version:Gp().min(1),connectionInfo:e1,services:Qp(sl(J0)).min(1),description:Gp().min(1),verification:t1.optional(),host:n1.optional(),capabilities:Qp(Gp()).optional(),resources:Qp(i1).optional(),tools:Qp(a1).optional(),maintainer:Gp().optional(),repository:Gp().optional(),docs:Gp().optional()}),o1=el({version:Gp().min(1),type:sl(V0),display_name:Gp().min(1),alias:Gp().optional(),bio:Gp().optional(),socials:Qp(X0).optional(),profileImage:Gp().optional(),properties:il(Xp()).optional(),inboundTopicId:Gp().optional(),outboundTopicId:Gp().optional()}),s1=o1.extend({type:rl(V0.PERSONAL),language:Gp().optional(),timezone:Gp().optional()}),c1=o1.extend({type:rl(V0.AI_AGENT),aiAgent:Q0}),p1=o1.extend({type:rl(V0.MCP_SERVER),mcpServer:r1});tl([s1,c1,p1]);const l1=el({p:rl("hcs-12")}),u1=Gp().regex(/^\d+\.\d+\.\d+$/,"Invalid Hedera address format"),d1=Gp().regex(/^[a-f0-9]{64}$/,"Invalid SHA-256 hash format"),f1=el({format:ol(["tar.gz","zip","car"]),root_manifest:Gp(),includes_lockfile:Yp(),workspace_members:Qp(Gp()).optional()}),m1=el({source_t_id:u1,source_hash:d1,compiler_version:Gp(),cargo_version:Gp(),target:rl("wasm32-unknown-unknown"),profile:Gp(),build_flags:Qp(Gp()),lockfile_hash:d1,source_structure:f1}),h1=al(()=>el({type:Gp().optional(),required:Qp(Gp()).optional(),properties:il(h1).optional(),pattern:Gp().optional(),minimum:Jp().optional(),maximum:Jp().optional(),regex:Gp().optional(),min:Jp().optional(),max:Jp().optional(),length:Jp().optional(),email:Yp().optional(),url:Yp().optional(),uuid:Yp().optional(),cuid:Yp().optional(),cuid2:Yp().optional(),ulid:Yp().optional(),datetime:Yp().optional(),ip:Yp().optional(),startsWith:Gp().optional(),endsWith:Gp().optional(),includes:Gp().optional(),gt:Jp().optional(),gte:Jp().optional(),lt:Jp().optional(),lte:Jp().optional(),int:Yp().optional(),positive:Yp().optional(),nonnegative:Yp().optional(),negative:Yp().optional(),nonpositive:Yp().optional(),multipleOf:Jp().optional(),finite:Yp().optional(),safe:Yp().optional(),nonempty:Yp().optional(),literal:tl([Gp(),Jp(),Yp()]).optional(),enum:Qp(Gp()).optional(),nullable:Yp().optional(),nullish:Yp().optional(),optional:Yp().optional(),element:Xp().optional(),shape:il(Xp()).optional(),strict:Yp().optional(),passthrough:Yp().optional(),catchall:Xp().optional()}));el({p:rl("hcs-12"),op:rl("register"),t_id:u1,hash:d1,wasm_hash:d1,js_t_id:u1.optional(),js_hash:d1.optional(),interface_version:Gp().regex(/^\d+\.\d+\.\d+$/,"Invalid version format").optional(),info_t_id:u1.optional(),source_verification:m1.optional(),previous_version:Gp().optional(),migration_notes:Gp().optional(),validation_rules:il(h1).optional(),m:Gp().optional()}),el({p:rl("hcs-12"),op:ol(["register","template"]),name:Gp(),version:Gp().regex(/^\d+\.\d+\.\d+$/,"Invalid semver format"),data:tl([Xp(),Gp()]).optional(),t_id:u1.optional()}),ol(["register","add-action","add-block","update"]);const g1=l1.extend({op:rl("register"),name:Gp(),version:Gp().regex(/^\d+\.\d+\.\d+$/,"Invalid semver format"),description:Gp().optional(),tags:Qp(Gp()).optional(),author:Gp().optional()}),v1=l1.extend({op:rl("add-action"),t_id:u1,alias:Gp(),config:Xp().optional(),data:u1.optional()}),y1=l1.extend({op:rl("add-block"),block_t_id:u1,actions:il(Gp(),u1).optional(),attributes:il(Xp()).optional(),children:Qp(Gp()).optional(),data:u1.optional()}),b1=l1.extend({op:rl("update"),description:Gp().optional(),tags:Qp(Gp()).optional()});el({type:ol(["vertical","horizontal","grid"]),responsive:Yp().optional(),containerClass:Gp().optional()}),el({source_t_id:u1,source_hash:d1,description:Gp().optional()}),nl("op",[g1,v1,y1,b1]),l1.extend({op:rl("register"),t_id:u1,name:Gp().max(100,"Name must be 100 characters or less"),description:Gp().max(500,"Description must be 500 characters or less").optional(),tags:Qp(Gp()).max(10,"Maximum 10 tags allowed").optional(),category:Gp().optional(),featured:Yp().optional(),icon:Gp().optional(),author:Gp().optional(),website:Gp().url().optional()});const x1=Gp().regex(/^\d+\.\d+\.\d+$/,{message:"Topic ID must be in Hedera format (e.g., '0.0.123456')"}),w1=el({p:Gp().regex(/^hcs-\d+$/,{message:"Protocol must be in format 'hcs-N' where N is a number"}),op:ol(["register","update","delete","migrate"]),m:Gp().max(500,"Memo must not exceed 500 characters").optional(),ttl:Jp().int().positive().optional()});nl("op",[w1.extend({op:rl("register"),t_id:x1,metadata:Gp().optional()}),w1.extend({op:rl("update"),uid:Gp(),t_id:x1,metadata:Gp().optional()}),w1.extend({op:rl("delete"),uid:Gp()}),w1.extend({op:rl("migrate"),t_id:x1,metadata:Gp().optional()})]);const _1=18,k1=100,E1=100,S1=/^(0|(?:[1-9]\d*))\.(0|(?:[1-9]\d*))\.(0|(?:[1-9]\d*))$/,A1=Gp().regex(S1,"Invalid Hedera account ID format"),T1=Gp().regex(/^\d+$/,"Must be a valid number").max(_1,`Max ${_1} digits`),O1=Gp().min(1,"Tick cannot be empty").transform(e=>e.toLowerCase().trim()),R1=el({p:rl("hcs-20"),m:Gp().optional()});nl("op",[R1.extend({op:rl("deploy"),name:Gp().min(1).max(k1),tick:O1,max:T1,lim:T1.optional(),metadata:Gp().max(E1).optional()}),R1.extend({op:rl("mint"),tick:O1,amt:T1,to:A1}),R1.extend({op:rl("burn"),tick:O1,amt:T1,from:A1}),R1.extend({op:rl("transfer"),tick:O1,amt:T1,from:A1,to:A1}),R1.extend({op:rl("register"),name:Gp().min(1).max(k1),metadata:Gp().max(E1).optional(),private:Yp(),t_id:A1})]);class j1{constructor(){this.resolver=null,this.onUnavailableCallbacks=[],this.logger=gc.getInstance({module:"ContentResolverRegistry"})}static getInstance(){return j1._instance||(j1._instance=new j1),j1._instance}register(e){this.resolver&&this.logger.warn("Resolver already registered, replacing existing"),this.resolver=e,this.logger.info("Content resolver registered")}getResolver(){return this.resolver}isAvailable(){return null!==this.resolver}unregister(){this.resolver&&(this.resolver=null,this.logger.info("Content resolver unregistered"),this.onUnavailableCallbacks.forEach(e=>{try{e()}catch(t){this.logger.error("Error in unavailable callback:",t)}}))}onUnavailable(e){this.onUnavailableCallbacks.push(e)}offUnavailable(e){const t=this.onUnavailableCallbacks.indexOf(e);-1!==t&&this.onUnavailableCallbacks.splice(t,1)}async withResolver(e,t){if(!this.resolver)return this.logger.warn("No resolver available, using fallback"),await t();try{return await e(this.resolver)}catch(n){return this.logger.warn("Resolver operation failed, using fallback:",n),await t()}}}j1.getInstance();class I1{constructor(){this.contentStore=null,this.logger=gc.getInstance({module:"ContentStoreService"})}static getInstance(){return I1._instance||(I1._instance=new I1),I1._instance}async setInstance(e){this.contentStore&&this.logger.warn("Content store already set, replacing"),this.contentStore=e,this.logger.info("Content store instance set")}getInstance(){return this.contentStore}dispose(){this.contentStore=null,this.logger.info("Content store disposed")}isAvailable(){return null!==this.contentStore}}I1.getInstance();class C1{constructor(e){if(lr(this,"accountId"),lr(this,"privateKey"),lr(this,"baseUrl"),lr(this,"network"),this.accountId=e.accountId,"string"==typeof e.privateKey){const t=dl(e.privateKey);this.privateKey=t.privateKey}else this.privateKey=e.privateKey;this.network=e.network||"mainnet",this.baseUrl=e.baseUrl||"https://kiloscribe.com"}async authenticate(){var e,t,n;const i=await qs.get(`${this.baseUrl}/api/auth/request-signature`,{headers:{"x-session":this.accountId}});if(!(null==(e=i.data)?void 0:e.message))throw new Error("Failed to get signature message");const a=i.data.message,r=await this.signMessage(a),o=await qs.post(`${this.baseUrl}/api/auth/authenticate`,{authData:{id:this.accountId,signature:r,data:a,network:this.network},include:"apiKey"});if(!(null==(n=null==(t=o.data)?void 0:t.user)?void 0:n.sessionToken))throw new Error("Authentication failed");return{apiKey:o.data.apiKey}}async signMessage(e){const t=(new TextEncoder).encode(e),n=await this.privateKey.sign(t);return kr.from(n).toString("hex")}}class N1{constructor(e){lr(this,"accountId"),lr(this,"signer"),lr(this,"baseUrl"),lr(this,"network"),lr(this,"logger"),this.accountId=e.accountId,this.signer=e.signer,this.network=e.network||"mainnet",this.baseUrl=e.baseUrl||"https://kiloscribe.com",this.logger=e.logger}async authenticate(){var e,t,n;const i=await qs.get(`${this.baseUrl}/api/auth/request-signature`,{headers:{"x-session":this.accountId}});if(!(null==(e=i.data)?void 0:e.message))throw new Error("Failed to get signature message");const a=i.data.message,r=await this.signMessage(JSON.stringify(a)),o=await qs.post(`${this.baseUrl}/api/auth/authenticate`,{authData:{id:this.accountId,signature:r,data:a,network:this.network},include:"apiKey"});if(!(null==(n=null==(t=o.data)?void 0:t.user)?void 0:n.sessionToken))throw new Error("Authentication failed");return{apiKey:o.data.apiKey}}async signMessage(e){try{const t=(new TextEncoder).encode(e);this.logger.debug("signing message");const n=await this.signer.sign([t],{encoding:"utf-8"});return kr.from(null==n?void 0:n[0].signature).toString("hex")}catch(Owe){throw this.logger.error("Failed to sign message",Owe),new Error("Failed to sign message")}}}const B1={get:(e,t)=>127&e[t+3]|e[t+2]<<7|e[t+1]<<14|e[t]<<21,len:4},P1=4100;function L1(e){switch(e=e.toLowerCase()){case"application/epub+zip":return{ext:"epub",mime:e};case"application/vnd.oasis.opendocument.text":return{ext:"odt",mime:e};case"application/vnd.oasis.opendocument.text-template":return{ext:"ott",mime:e};case"application/vnd.oasis.opendocument.spreadsheet":return{ext:"ods",mime:e};case"application/vnd.oasis.opendocument.spreadsheet-template":return{ext:"ots",mime:e};case"application/vnd.oasis.opendocument.presentation":return{ext:"odp",mime:e};case"application/vnd.oasis.opendocument.presentation-template":return{ext:"otp",mime:e};case"application/vnd.oasis.opendocument.graphics":return{ext:"odg",mime:e};case"application/vnd.oasis.opendocument.graphics-template":return{ext:"otg",mime:e};case"application/vnd.openxmlformats-officedocument.presentationml.slideshow":return{ext:"ppsx",mime:e};case"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":return{ext:"xlsx",mime:e};case"application/vnd.ms-excel.sheet.macroenabled":return{ext:"xlsm",mime:"application/vnd.ms-excel.sheet.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.spreadsheetml.template":return{ext:"xltx",mime:e};case"application/vnd.ms-excel.template.macroenabled":return{ext:"xltm",mime:"application/vnd.ms-excel.template.macroenabled.12"};case"application/vnd.ms-powerpoint.slideshow.macroenabled":return{ext:"ppsm",mime:"application/vnd.ms-powerpoint.slideshow.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.document":return{ext:"docx",mime:e};case"application/vnd.ms-word.document.macroenabled":return{ext:"docm",mime:"application/vnd.ms-word.document.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.wordprocessingml.template":return{ext:"dotx",mime:e};case"application/vnd.ms-word.template.macroenabledtemplate":return{ext:"dotm",mime:"application/vnd.ms-word.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.template":return{ext:"potx",mime:e};case"application/vnd.ms-powerpoint.template.macroenabled":return{ext:"potm",mime:"application/vnd.ms-powerpoint.template.macroenabled.12"};case"application/vnd.openxmlformats-officedocument.presentationml.presentation":return{ext:"pptx",mime:e};case"application/vnd.ms-powerpoint.presentation.macroenabled":return{ext:"pptm",mime:"application/vnd.ms-powerpoint.presentation.macroenabled.12"};case"application/vnd.ms-visio.drawing":return{ext:"vsdx",mime:"application/vnd.visio"};case"application/vnd.ms-package.3dmanufacturing-3dmodel+xml":return{ext:"3mf",mime:"model/3mf"}}}function U1(e,t,n){n={offset:0,...n};for(const[i,a]of t.entries())if(n.mask){if(a!==(n.mask[i]&e[i+n.offset]))return!1}else if(a!==e[i+n.offset])return!1;return!0}class M1{constructor(e){lr(this,"detectConfident",async e=>{if(this.buffer=new Uint8Array(P1),void 0===e.fileInfo.size&&(e.fileInfo.size=Number.MAX_SAFE_INTEGER),this.tokenizer=e,await e.peekBuffer(this.buffer,{length:12,mayBeLess:!0}),this.check([66,77]))return{ext:"bmp",mime:"image/bmp"};if(this.check([11,119]))return{ext:"ac3",mime:"audio/vnd.dolby.dd-raw"};if(this.check([120,1]))return{ext:"dmg",mime:"application/x-apple-diskimage"};if(this.check([77,90]))return{ext:"exe",mime:"application/x-msdownload"};if(this.check([37,33]))return await e.peekBuffer(this.buffer,{length:24,mayBeLess:!0}),this.checkString("PS-Adobe-",{offset:2})&&this.checkString(" EPSF-",{offset:14})?{ext:"eps",mime:"application/eps"}:{ext:"ps",mime:"application/postscript"};if(this.check([31,160])||this.check([31,157]))return{ext:"Z",mime:"application/x-compress"};if(this.check([199,113]))return{ext:"cpio",mime:"application/x-cpio"};if(this.check([96,234]))return{ext:"arj",mime:"application/x-arj"};if(this.check([239,187,191]))return this.tokenizer.ignore(3),this.detectConfident(e);if(this.check([71,73,70]))return{ext:"gif",mime:"image/gif"};if(this.check([73,73,188]))return{ext:"jxr",mime:"image/vnd.ms-photo"};if(this.check([31,139,8]))return{ext:"gz",mime:"application/gzip"};if(this.check([66,90,104]))return{ext:"bz2",mime:"application/x-bzip2"};if(this.checkString("ID3")){await e.ignore(6);const t=await e.readToken(B1);return e.position+t>e.fileInfo.size?{ext:"mp3",mime:"audio/mpeg"}:(await e.ignore(t),this.fromTokenizer(e))}if(this.checkString("MP+"))return{ext:"mpc",mime:"audio/x-musepack"};if((67===this.buffer[0]||70===this.buffer[0])&&this.check([87,83],{offset:1}))return{ext:"swf",mime:"application/x-shockwave-flash"};if(this.check([255,216,255]))return this.check([247],{offset:3})?{ext:"jls",mime:"image/jls"}:{ext:"jpg",mime:"image/jpeg"};if(this.check([79,98,106,1]))return{ext:"avro",mime:"application/avro"};if(this.checkString("FLIF"))return{ext:"flif",mime:"image/flif"};if(this.checkString("8BPS"))return{ext:"psd",mime:"image/vnd.adobe.photoshop"};if(this.checkString("MPCK"))return{ext:"mpc",mime:"audio/x-musepack"};if(this.checkString("FORM"))return{ext:"aif",mime:"audio/aiff"};if(this.checkString("icns",{offset:0}))return{ext:"icns",mime:"image/icns"};if(this.check([80,75,3,4])){let n;return await new L0(e).unzip(e=>{switch(e.filename){case"META-INF/mozilla.rsa":return n={ext:"xpi",mime:"application/x-xpinstall"},{stop:!0};case"META-INF/MANIFEST.MF":return n={ext:"jar",mime:"application/java-archive"},{stop:!0};case"mimetype":return{async handler(e){const t=new TextDecoder("utf-8").decode(e).trim();n=L1(t)},stop:!0};case"[Content_Types].xml":return{async handler(e){let t=new TextDecoder("utf-8").decode(e);const i=t.indexOf('.main+xml"');if(-1===i){const e="application/vnd.ms-package.3dmanufacturing-3dmodel+xml";t.includes(`ContentType="${e}"`)&&(n=L1(e))}else{t=t.slice(0,Math.max(0,i));const e=t.lastIndexOf('"'),a=t.slice(Math.max(0,e+1));n=L1(a)}},stop:!0};default:return/classes\d*\.dex/.test(e.filename)?(n={ext:"apk",mime:"application/vnd.android.package-archive"},{stop:!0}):{}}}),n??{ext:"zip",mime:"application/zip"}}if(this.checkString("OggS")){await e.ignore(28);const i=new Uint8Array(8);return await e.readBuffer(i),U1(i,[79,112,117,115,72,101,97,100])?{ext:"opus",mime:"audio/ogg; codecs=opus"}:U1(i,[128,116,104,101,111,114,97])?{ext:"ogv",mime:"video/ogg"}:U1(i,[1,118,105,100,101,111,0])?{ext:"ogm",mime:"video/ogg"}:U1(i,[127,70,76,65,67])?{ext:"oga",mime:"audio/ogg"}:U1(i,[83,112,101,101,120,32,32])?{ext:"spx",mime:"audio/ogg"}:U1(i,[1,118,111,114,98,105,115])?{ext:"ogg",mime:"audio/ogg"}:{ext:"ogx",mime:"application/ogg"}}if(this.check([80,75])&&(3===this.buffer[2]||5===this.buffer[2]||7===this.buffer[2])&&(4===this.buffer[3]||6===this.buffer[3]||8===this.buffer[3]))return{ext:"zip",mime:"application/zip"};if(this.checkString("MThd"))return{ext:"mid",mime:"audio/midi"};if(this.checkString("wOFF")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff",mime:"font/woff"};if(this.checkString("wOF2")&&(this.check([0,1,0,0],{offset:4})||this.checkString("OTTO",{offset:4})))return{ext:"woff2",mime:"font/woff2"};if(this.check([212,195,178,161])||this.check([161,178,195,212]))return{ext:"pcap",mime:"application/vnd.tcpdump.pcap"};if(this.checkString("DSD "))return{ext:"dsf",mime:"audio/x-dsf"};if(this.checkString("LZIP"))return{ext:"lz",mime:"application/x-lzip"};if(this.checkString("fLaC"))return{ext:"flac",mime:"audio/flac"};if(this.check([66,80,71,251]))return{ext:"bpg",mime:"image/bpg"};if(this.checkString("wvpk"))return{ext:"wv",mime:"audio/wavpack"};if(this.checkString("%PDF"))return{ext:"pdf",mime:"application/pdf"};if(this.check([0,97,115,109]))return{ext:"wasm",mime:"application/wasm"};if(this.check([73,73])){const a=await this.readTiffHeader(!1);if(a)return a}if(this.check([77,77])){const r=await this.readTiffHeader(!0);if(r)return r}if(this.checkString("MAC "))return{ext:"ape",mime:"audio/ape"};if(this.check([26,69,223,163])){async function o(){const t=await e.peekNumber(xQ);let n=128,i=0;for(;0===(t&n)&&0!==n;)++i,n>>=1;const a=new Uint8Array(i+1);return await e.readBuffer(a),a}async function s(){const e=await o(),t=await o();t[0]^=128>>t.length-1;const n=Math.min(6,t.length),i=new DataView(e.buffer),a=new DataView(t.buffer,t.length-n,n);return{id:F0(i),len:F0(a)}}async function c(t){for(;t>0;){const n=await s();if(17026===n.id){return(await e.readToken(new TQ(n.len))).replaceAll(/\00.*$/g,"")}await e.ignore(n.len),--t}}const p=await s();switch(await c(p.len)){case"webm":return{ext:"webm",mime:"video/webm"};case"matroska":return{ext:"mkv",mime:"video/matroska"};default:return}}if(this.checkString("SQLi"))return{ext:"sqlite",mime:"application/x-sqlite3"};if(this.check([78,69,83,26]))return{ext:"nes",mime:"application/x-nintendo-nes-rom"};if(this.checkString("Cr24"))return{ext:"crx",mime:"application/x-google-chrome-extension"};if(this.checkString("MSCF")||this.checkString("ISc("))return{ext:"cab",mime:"application/vnd.ms-cab-compressed"};if(this.check([237,171,238,219]))return{ext:"rpm",mime:"application/x-rpm"};if(this.check([197,208,211,198]))return{ext:"eps",mime:"application/eps"};if(this.check([40,181,47,253]))return{ext:"zst",mime:"application/zstd"};if(this.check([127,69,76,70]))return{ext:"elf",mime:"application/x-elf"};if(this.check([33,66,68,78]))return{ext:"pst",mime:"application/vnd.ms-outlook"};if(this.checkString("PAR1")||this.checkString("PARE"))return{ext:"parquet",mime:"application/vnd.apache.parquet"};if(this.checkString("ttcf"))return{ext:"ttc",mime:"font/collection"};if(this.check([207,250,237,254]))return{ext:"macho",mime:"application/x-mach-binary"};if(this.check([4,34,77,24]))return{ext:"lz4",mime:"application/x-lz4"};if(this.check([79,84,84,79,0]))return{ext:"otf",mime:"font/otf"};if(this.checkString("#!AMR"))return{ext:"amr",mime:"audio/amr"};if(this.checkString("{\\rtf"))return{ext:"rtf",mime:"application/rtf"};if(this.check([70,76,86,1]))return{ext:"flv",mime:"video/x-flv"};if(this.checkString("IMPM"))return{ext:"it",mime:"audio/x-it"};if(this.checkString("-lh0-",{offset:2})||this.checkString("-lh1-",{offset:2})||this.checkString("-lh2-",{offset:2})||this.checkString("-lh3-",{offset:2})||this.checkString("-lh4-",{offset:2})||this.checkString("-lh5-",{offset:2})||this.checkString("-lh6-",{offset:2})||this.checkString("-lh7-",{offset:2})||this.checkString("-lzs-",{offset:2})||this.checkString("-lz4-",{offset:2})||this.checkString("-lz5-",{offset:2})||this.checkString("-lhd-",{offset:2}))return{ext:"lzh",mime:"application/x-lzh-compressed"};if(this.check([0,0,1,186])){if(this.check([33],{offset:4,mask:[241]}))return{ext:"mpg",mime:"video/MP1S"};if(this.check([68],{offset:4,mask:[196]}))return{ext:"mpg",mime:"video/MP2P"}}if(this.checkString("ITSF"))return{ext:"chm",mime:"application/vnd.ms-htmlhelp"};if(this.check([202,254,186,190]))return{ext:"class",mime:"application/java-vm"};if(this.checkString(".RMF"))return{ext:"rm",mime:"application/vnd.rn-realmedia"};if(this.checkString("DRACO"))return{ext:"drc",mime:"application/vnd.google.draco"};if(this.check([253,55,122,88,90,0]))return{ext:"xz",mime:"application/x-xz"};if(this.checkString("<?xml "))return{ext:"xml",mime:"application/xml"};if(this.check([55,122,188,175,39,28]))return{ext:"7z",mime:"application/x-7z-compressed"};if(this.check([82,97,114,33,26,7])&&(0===this.buffer[6]||1===this.buffer[6]))return{ext:"rar",mime:"application/x-rar-compressed"};if(this.checkString("solid "))return{ext:"stl",mime:"model/stl"};if(this.checkString("AC")){const l=new TQ(4,"latin1").get(this.buffer,2);if(l.match("^d*")&&l>=1e3&&l<=1050)return{ext:"dwg",mime:"image/vnd.dwg"}}if(this.checkString("070707"))return{ext:"cpio",mime:"application/x-cpio"};if(this.checkString("BLENDER"))return{ext:"blend",mime:"application/x-blender"};if(this.checkString("!<arch>")){await e.ignore(8);return"debian-binary"===await e.readToken(new TQ(13,"ascii"))?{ext:"deb",mime:"application/x-deb"}:{ext:"ar",mime:"application/x-unix-archive"}}if(this.checkString("WEBVTT")&&["\n","\r","\t"," ","\0"].some(e=>this.checkString(e,{offset:6})))return{ext:"vtt",mime:"text/vtt"};if(this.check([137,80,78,71,13,10,26,10])){async function u(){return{length:await e.readToken(SQ),type:await e.readToken(new TQ(4,"latin1"))}}await e.ignore(8);do{const d=await u();if(d.length<0)return;switch(d.type){case"IDAT":return{ext:"png",mime:"image/png"};case"acTL":return{ext:"apng",mime:"image/apng"};default:await e.ignore(d.length+4)}}while(e.position+8<e.fileInfo.size);return{ext:"png",mime:"image/png"}}if(this.check([65,82,82,79,87,49,0,0]))return{ext:"arrow",mime:"application/vnd.apache.arrow.file"};if(this.check([103,108,84,70,2,0,0,0]))return{ext:"glb",mime:"model/gltf-binary"};if(this.check([102,114,101,101],{offset:4})||this.check([109,100,97,116],{offset:4})||this.check([109,111,111,118],{offset:4})||this.check([119,105,100,101],{offset:4}))return{ext:"mov",mime:"video/quicktime"};if(this.check([73,73,82,79,8,0,0,0,24]))return{ext:"orf",mime:"image/x-olympus-orf"};if(this.checkString("gimp xcf "))return{ext:"xcf",mime:"image/x-xcf"};if(this.checkString("ftyp",{offset:4})&&96&this.buffer[8]){const f=new TQ(4,"latin1").get(this.buffer,8).replace("\0"," ").trim();switch(f){case"avif":case"avis":return{ext:"avif",mime:"image/avif"};case"mif1":return{ext:"heic",mime:"image/heif"};case"msf1":return{ext:"heic",mime:"image/heif-sequence"};case"heic":case"heix":return{ext:"heic",mime:"image/heic"};case"hevc":case"hevx":return{ext:"heic",mime:"image/heic-sequence"};case"qt":return{ext:"mov",mime:"video/quicktime"};case"M4V":case"M4VH":case"M4VP":return{ext:"m4v",mime:"video/x-m4v"};case"M4P":return{ext:"m4p",mime:"video/mp4"};case"M4B":return{ext:"m4b",mime:"audio/mp4"};case"M4A":return{ext:"m4a",mime:"audio/x-m4a"};case"F4V":return{ext:"f4v",mime:"video/mp4"};case"F4P":return{ext:"f4p",mime:"video/mp4"};case"F4A":return{ext:"f4a",mime:"audio/mp4"};case"F4B":return{ext:"f4b",mime:"audio/mp4"};case"crx":return{ext:"cr3",mime:"image/x-canon-cr3"};default:return f.startsWith("3g")?f.startsWith("3g2")?{ext:"3g2",mime:"video/3gpp2"}:{ext:"3gp",mime:"video/3gpp"}:{ext:"mp4",mime:"video/mp4"}}}if(this.check([82,73,70,70])){if(this.checkString("WEBP",{offset:8}))return{ext:"webp",mime:"image/webp"};if(this.check([65,86,73],{offset:8}))return{ext:"avi",mime:"video/vnd.avi"};if(this.check([87,65,86,69],{offset:8}))return{ext:"wav",mime:"audio/wav"};if(this.check([81,76,67,77],{offset:8}))return{ext:"qcp",mime:"audio/qcelp"}}if(this.check([73,73,85,0,24,0,0,0,136,231,116,216]))return{ext:"rw2",mime:"image/x-panasonic-rw2"};if(this.check([48,38,178,117,142,102,207,17,166,217])){async function m(){const t=new Uint8Array(16);return await e.readBuffer(t),{id:t,size:Number(await e.readToken(AQ))}}for(await e.ignore(30);e.position+24<e.fileInfo.size;){const h=await m();let g=h.size-24;if(U1(h.id,[145,7,220,183,183,169,207,17,142,230,0,192,12,32,83,101])){const v=new Uint8Array(16);if(g-=await e.readBuffer(v),U1(v,[64,158,105,248,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"audio/x-ms-asf"};if(U1(v,[192,239,25,188,77,91,207,17,168,253,0,128,95,92,68,43]))return{ext:"asf",mime:"video/x-ms-asf"};break}await e.ignore(g)}return{ext:"asf",mime:"application/vnd.ms-asf"}}if(this.check([171,75,84,88,32,49,49,187,13,10,26,10]))return{ext:"ktx",mime:"image/ktx"};if((this.check([126,16,4])||this.check([126,24,4]))&&this.check([48,77,73,69],{offset:4}))return{ext:"mie",mime:"application/x-mie"};if(this.check([39,10,0,0,0,0,0,0,0,0,0,0],{offset:2}))return{ext:"shp",mime:"application/x-esri-shape"};if(this.check([255,79,255,81]))return{ext:"j2c",mime:"image/j2c"};if(this.check([0,0,0,12,106,80,32,32,13,10,135,10])){await e.ignore(20);switch(await e.readToken(new TQ(4,"ascii"))){case"jp2 ":return{ext:"jp2",mime:"image/jp2"};case"jpx ":return{ext:"jpx",mime:"image/jpx"};case"jpm ":return{ext:"jpm",mime:"image/jpm"};case"mjp2":return{ext:"mj2",mime:"image/mj2"};default:return}}if(this.check([255,10])||this.check([0,0,0,12,74,88,76,32,13,10,135,10]))return{ext:"jxl",mime:"image/jxl"};if(this.check([254,255]))return this.check([0,60,0,63,0,120,0,109,0,108],{offset:2})?{ext:"xml",mime:"application/xml"}:void 0;if(this.check([208,207,17,224,161,177,26,225]))return{ext:"cfb",mime:"application/x-cfb"};if(await e.peekBuffer(this.buffer,{length:Math.min(256,e.fileInfo.size),mayBeLess:!0}),this.check([97,99,115,112],{offset:36}))return{ext:"icc",mime:"application/vnd.iccprofile"};if(this.checkString("**ACE",{offset:7})&&this.checkString("**",{offset:12}))return{ext:"ace",mime:"application/x-ace-compressed"};if(this.checkString("BEGIN:")){if(this.checkString("VCARD",{offset:6}))return{ext:"vcf",mime:"text/vcard"};if(this.checkString("VCALENDAR",{offset:6}))return{ext:"ics",mime:"text/calendar"}}if(this.checkString("FUJIFILMCCD-RAW"))return{ext:"raf",mime:"image/x-fujifilm-raf"};if(this.checkString("Extended Module:"))return{ext:"xm",mime:"audio/x-xm"};if(this.checkString("Creative Voice File"))return{ext:"voc",mime:"audio/x-voc"};if(this.check([4,0,0,0])&&this.buffer.length>=16){const y=new DataView(this.buffer.buffer).getUint32(12,!0);if(y>12&&this.buffer.length>=y+16)try{const b=(new TextDecoder).decode(this.buffer.subarray(16,y+16));if(JSON.parse(b).files)return{ext:"asar",mime:"application/x-asar"}}catch{}}return this.check([6,14,43,52,2,5,1,1,13,1,2,1,1,2])?{ext:"mxf",mime:"application/mxf"}:this.checkString("SCRM",{offset:44})?{ext:"s3m",mime:"audio/x-s3m"}:this.check([71])&&this.check([71],{offset:188})||this.check([71],{offset:4})&&this.check([71],{offset:196})?{ext:"mts",mime:"video/mp2t"}:this.check([66,79,79,75,77,79,66,73],{offset:60})?{ext:"mobi",mime:"application/x-mobipocket-ebook"}:this.check([68,73,67,77],{offset:128})?{ext:"dcm",mime:"application/dicom"}:this.check([76,0,0,0,1,20,2,0,0,0,0,0,192,0,0,0,0,0,0,70])?{ext:"lnk",mime:"application/x.ms.shortcut"}:this.check([98,111,111,107,0,0,0,0,109,97,114,107,0,0,0,0])?{ext:"alias",mime:"application/x.apple.alias"}:this.checkString("Kaydara FBX Binary \0")?{ext:"fbx",mime:"application/x.autodesk.fbx"}:this.check([76,80],{offset:34})&&(this.check([0,0,1],{offset:8})||this.check([1,0,2],{offset:8})||this.check([2,0,2],{offset:8}))?{ext:"eot",mime:"application/vnd.ms-fontobject"}:this.check([6,6,237,245,216,29,70,229,189,49,239,231,254,116,183,29])?{ext:"indd",mime:"application/x-indesign"}:(await e.peekBuffer(this.buffer,{length:Math.min(512,e.fileInfo.size),mayBeLess:!0}),this.checkString("ustar",{offset:257})&&(this.checkString("\0",{offset:262})||this.checkString(" ",{offset:262}))||this.check([0,0,0,0,0,0],{offset:257})&&function(e,t=0){const n=Number.parseInt(new TQ(6).get(e,148).replace(/\0.*$/,"").trim(),8);if(Number.isNaN(n))return!1;let i=256;for(let a=t;a<t+148;a++)i+=e[a];for(let a=t+156;a<t+512;a++)i+=e[a];return n===i}(this.buffer)?{ext:"tar",mime:"application/x-tar"}:this.check([255,254])?this.check([60,0,63,0,120,0,109,0,108,0],{offset:2})?{ext:"xml",mime:"application/xml"}:this.check([255,14,83,0,107,0,101,0,116,0,99,0,104,0,85,0,112,0,32,0,77,0,111,0,100,0,101,0,108,0],{offset:2})?{ext:"skp",mime:"application/vnd.sketchup.skp"}:void 0:this.checkString("-----BEGIN PGP MESSAGE-----")?{ext:"pgp",mime:"application/pgp-encrypted"}:void 0)}),lr(this,"detectImprecise",async e=>{if(this.buffer=new Uint8Array(P1),await e.peekBuffer(this.buffer,{length:Math.min(8,e.fileInfo.size),mayBeLess:!0}),this.check([0,0,1,186])||this.check([0,0,1,179]))return{ext:"mpg",mime:"video/mpeg"};if(this.check([0,1,0,0,0]))return{ext:"ttf",mime:"font/ttf"};if(this.check([0,0,1,0]))return{ext:"ico",mime:"image/x-icon"};if(this.check([0,0,2,0]))return{ext:"cur",mime:"image/x-icon"};if(await e.peekBuffer(this.buffer,{length:Math.min(2+this.options.mpegOffsetTolerance,e.fileInfo.size),mayBeLess:!0}),this.buffer.length>=2+this.options.mpegOffsetTolerance)for(let t=0;t<=this.options.mpegOffsetTolerance;++t){const e=this.scanMpeg(t);if(e)return e}}),this.options={mpegOffsetTolerance:0,...e},this.detectors=[...(null==e?void 0:e.customDetectors)??[],{id:"core",detect:this.detectConfident},{id:"core.imprecise",detect:this.detectImprecise}],this.tokenizerOptions={abortSignal:null==e?void 0:e.signal}}async fromTokenizer(e){const t=e.position;for(const n of this.detectors){const i=await n.detect(e);if(i)return i;if(t!==e.position)return}}async fromBuffer(e){if(!(e instanceof Uint8Array||e instanceof ArrayBuffer))throw new TypeError(`Expected the \`input\` argument to be of type \`Uint8Array\` or \`ArrayBuffer\`, got \`${typeof e}\``);const t=e instanceof Uint8Array?e:new Uint8Array(e);var n,i;if((null==t?void 0:t.length)>1)return this.fromTokenizer((n=t,i=this.tokenizerOptions,new LQ(n,i)))}async fromBlob(e){return this.fromStream(e.stream())}async fromStream(e){const t=await UQ(e,this.tokenizerOptions);try{return await this.fromTokenizer(t)}finally{await t.close()}}async toDetectionStream(e,t){const{sampleSize:n=P1}=t;let i,a;const r=e.getReader({mode:"byob"});try{const{value:e,done:t}=await r.read(new Uint8Array(n));if(a=e,!t&&e)try{i=await this.fromBuffer(e.subarray(0,n))}catch(c){if(!(c instanceof OQ))throw c;i=void 0}a=e}finally{r.releaseLock()}const o=new TransformStream({async start(e){e.enqueue(a)},transform(e,t){t.enqueue(e)}}),s=e.pipeThrough(o);return s.fileType=i,s}check(e,t){return U1(this.buffer,e,t)}checkString(e,t){return this.check((n=e,[...n].map(e=>e.charCodeAt(0))),t);var n}async readTiffTag(e){const t=await this.tokenizer.readToken(e?_Q:wQ);switch(this.tokenizer.ignore(10),t){case 50341:return{ext:"arw",mime:"image/x-sony-arw"};case 50706:return{ext:"dng",mime:"image/x-adobe-dng"}}}async readTiffIFD(e){const t=await this.tokenizer.readToken(e?_Q:wQ);for(let n=0;n<t;++n){const t=await this.readTiffTag(e);if(t)return t}}async readTiffHeader(e){const t=(e?_Q:wQ).get(this.buffer,2),n=(e?EQ:kQ).get(this.buffer,4);if(42===t){if(n>=6){if(this.checkString("CR",{offset:8}))return{ext:"cr2",mime:"image/x-canon-cr2"};if(n>=8){const t=(e?_Q:wQ).get(this.buffer,8),n=(e?_Q:wQ).get(this.buffer,10);if(28===t&&254===n||31===t&&11===n)return{ext:"nef",mime:"image/x-nikon-nef"}}}await this.tokenizer.ignore(n);return await this.readTiffIFD(e)??{ext:"tif",mime:"image/tiff"}}if(43===t)return{ext:"tif",mime:"image/tiff"}}scanMpeg(e){if(this.check([255,224],{offset:e,mask:[255,224]})){if(this.check([16],{offset:e+1,mask:[22]}))return this.check([8],{offset:e+1,mask:[8]}),{ext:"aac",mime:"audio/aac"};if(this.check([2],{offset:e+1,mask:[6]}))return{ext:"mp3",mime:"audio/mpeg"};if(this.check([4],{offset:e+1,mask:[6]}))return{ext:"mp2",mime:"audio/mpeg"};if(this.check([6],{offset:e+1,mask:[6]}))return{ext:"mp1",mime:"audio/mpeg"}}}}new Set(["jpg","png","apng","gif","webp","flif","xcf","cr2","cr3","orf","arw","dng","nef","rw2","raf","tif","bmp","icns","jxr","psd","indd","zip","tar","rar","gz","bz2","7z","dmg","mp4","mid","mkv","webm","mov","avi","mpg","mp2","mp3","m4a","oga","ogg","ogv","opus","flac","wav","spx","amr","pdf","epub","elf","macho","exe","swf","rtf","wasm","woff","woff2","eot","ttf","otf","ttc","ico","flv","ps","xz","sqlite","nes","crx","xpi","cab","deb","ar","rpm","Z","lz","cfb","mxf","mts","blend","bpg","docx","pptx","xlsx","3gp","3g2","j2c","jp2","jpm","jpx","mj2","aif","qcp","odt","ods","odp","xml","mobi","heic","cur","ktx","ape","wv","dcm","ics","glb","pcap","dsf","lnk","alias","voc","ac3","m4v","m4p","m4b","f4v","f4p","f4b","f4a","mie","asf","ogm","ogx","mpc","arrow","shp","aac","mp1","it","s3m","xm","skp","avif","eps","lzh","pgp","asar","stl","chm","3mf","zst","jxl","vcf","jls","pst","dwg","parquet","class","arj","cpio","ace","avro","icc","fbx","vsdx","vtt","apk","drc","lz4","potx","xltx","dotx","xltm","ott","ots","otp","odg","otg","xlsm","docm","dotm","potm","pptm","jar","rm","ppsm","ppsx"]),new Set(["image/jpeg","image/png","image/gif","image/webp","image/flif","image/x-xcf","image/x-canon-cr2","image/x-canon-cr3","image/tiff","image/bmp","image/vnd.ms-photo","image/vnd.adobe.photoshop","application/x-indesign","application/epub+zip","application/x-xpinstall","application/vnd.ms-powerpoint.slideshow.macroenabled.12","application/vnd.oasis.opendocument.text","application/vnd.oasis.opendocument.spreadsheet","application/vnd.oasis.opendocument.presentation","application/vnd.openxmlformats-officedocument.wordprocessingml.document","application/vnd.openxmlformats-officedocument.presentationml.presentation","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet","application/vnd.openxmlformats-officedocument.presentationml.slideshow","application/zip","application/x-tar","application/x-rar-compressed","application/gzip","application/x-bzip2","application/x-7z-compressed","application/x-apple-diskimage","application/vnd.apache.arrow.file","video/mp4","audio/midi","video/matroska","video/webm","video/quicktime","video/vnd.avi","audio/wav","audio/qcelp","audio/x-ms-asf","video/x-ms-asf","application/vnd.ms-asf","video/mpeg","video/3gpp","audio/mpeg","audio/mp4","video/ogg","audio/ogg","audio/ogg; codecs=opus","application/ogg","audio/flac","audio/ape","audio/wavpack","audio/amr","application/pdf","application/x-elf","application/x-mach-binary","application/x-msdownload","application/x-shockwave-flash","application/rtf","application/wasm","font/woff","font/woff2","application/vnd.ms-fontobject","font/ttf","font/otf","font/collection","image/x-icon","video/x-flv","application/postscript","application/eps","application/x-xz","application/x-sqlite3","application/x-nintendo-nes-rom","application/x-google-chrome-extension","application/vnd.ms-cab-compressed","application/x-deb","application/x-unix-archive","application/x-rpm","application/x-compress","application/x-lzip","application/x-cfb","application/x-mie","application/mxf","video/mp2t","application/x-blender","image/bpg","image/j2c","image/jp2","image/jpx","image/jpm","image/mj2","audio/aiff","application/xml","application/x-mobipocket-ebook","image/heif","image/heif-sequence","image/heic","image/heic-sequence","image/icns","image/ktx","application/dicom","audio/x-musepack","text/calendar","text/vcard","text/vtt","model/gltf-binary","application/vnd.tcpdump.pcap","audio/x-dsf","application/x.ms.shortcut","application/x.apple.alias","audio/x-voc","audio/vnd.dolby.dd-raw","audio/x-m4a","image/apng","image/x-olympus-orf","image/x-sony-arw","image/x-adobe-dng","image/x-nikon-nef","image/x-panasonic-rw2","image/x-fujifilm-raf","video/x-m4v","video/3gpp2","application/x-esri-shape","audio/aac","audio/x-it","audio/x-s3m","audio/x-xm","video/MP1S","video/MP2P","application/vnd.sketchup.skp","image/avif","application/x-lzh-compressed","application/pgp-encrypted","application/x-asar","model/stl","application/vnd.ms-htmlhelp","model/3mf","image/jxl","application/zstd","image/jls","application/vnd.ms-outlook","image/vnd.dwg","application/vnd.apache.parquet","application/java-vm","application/x-arj","application/x-cpio","application/x-ace-compressed","application/avro","application/vnd.iccprofile","application/x.autodesk.fbx","application/vnd.visio","application/vnd.android.package-archive","application/vnd.google.draco","application/x-lz4","application/vnd.openxmlformats-officedocument.presentationml.template","application/vnd.openxmlformats-officedocument.spreadsheetml.template","application/vnd.openxmlformats-officedocument.wordprocessingml.template","application/vnd.ms-excel.template.macroenabled.12","application/vnd.oasis.opendocument.text-template","application/vnd.oasis.opendocument.spreadsheet-template","application/vnd.oasis.opendocument.presentation-template","application/vnd.oasis.opendocument.graphics","application/vnd.oasis.opendocument.graphics-template","application/vnd.ms-excel.sheet.macroenabled.12","application/vnd.ms-word.document.macroenabled.12","application/vnd.ms-word.template.macroenabled.12","application/vnd.ms-powerpoint.template.macroenabled.12","application/vnd.ms-powerpoint.presentation.macroenabled.12","application/java-archive","application/vnd.rn-realmedia"]);const F1=Object.create(null);F1.open="0",F1.close="1",F1.ping="2",F1.pong="3",F1.message="4",F1.upgrade="5",F1.noop="6";const D1=Object.create(null);Object.keys(F1).forEach(e=>{D1[F1[e]]=e});const z1={type:"error",data:"parser error"},$1="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===Object.prototype.toString.call(Blob),q1="function"==typeof ArrayBuffer,W1=e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer instanceof ArrayBuffer,K1=({type:e,data:t},n,i)=>$1&&t instanceof Blob?n?i(t):Z1(t,i):q1&&(t instanceof ArrayBuffer||W1(t))?n?i(t):Z1(new Blob([t]),i):i(F1[e]+(t||"")),Z1=(e,t)=>{const n=new FileReader;return n.onload=function(){const e=n.result.split(",")[1];t("b"+(e||""))},n.readAsDataURL(e)};function V1(e){return e instanceof Uint8Array?e:e instanceof ArrayBuffer?new Uint8Array(e):new Uint8Array(e.buffer,e.byteOffset,e.byteLength)}let H1;const G1="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",J1="undefined"==typeof Uint8Array?[]:new Uint8Array(256);for(let Rwe=0;Rwe<64;Rwe++)J1[G1.charCodeAt(Rwe)]=Rwe;const Y1="function"==typeof ArrayBuffer,X1=(e,t)=>{if("string"!=typeof e)return{type:"message",data:e2(e,t)};const n=e.charAt(0);if("b"===n)return{type:"message",data:Q1(e.substring(1),t)};return D1[n]?e.length>1?{type:D1[n],data:e.substring(1)}:{type:D1[n]}:z1},Q1=(e,t)=>{if(Y1){const n=(e=>{let t,n,i,a,r,o=.75*e.length,s=e.length,c=0;"="===e[e.length-1]&&(o--,"="===e[e.length-2]&&o--);const p=new ArrayBuffer(o),l=new Uint8Array(p);for(t=0;t<s;t+=4)n=J1[e.charCodeAt(t)],i=J1[e.charCodeAt(t+1)],a=J1[e.charCodeAt(t+2)],r=J1[e.charCodeAt(t+3)],l[c++]=n<<2|i>>4,l[c++]=(15&i)<<4|a>>2,l[c++]=(3&a)<<6|63&r;return p})(e);return e2(n,t)}return{base64:!0,data:e}},e2=(e,t)=>"blob"===t?e instanceof Blob?e:new Blob([e]):e instanceof ArrayBuffer?e:e.buffer,t2=String.fromCharCode(30);function n2(){return new TransformStream({transform(e,t){!function(e,t){$1&&e.data instanceof Blob?e.data.arrayBuffer().then(V1).then(t):q1&&(e.data instanceof ArrayBuffer||W1(e.data))?t(V1(e.data)):K1(e,!1,e=>{H1||(H1=new TextEncoder),t(H1.encode(e))})}(e,n=>{const i=n.length;let a;if(i<126)a=new Uint8Array(1),new DataView(a.buffer).setUint8(0,i);else if(i<65536){a=new Uint8Array(3);const e=new DataView(a.buffer);e.setUint8(0,126),e.setUint16(1,i)}else{a=new Uint8Array(9);const e=new DataView(a.buffer);e.setUint8(0,127),e.setBigUint64(1,BigInt(i))}e.data&&"string"!=typeof e.data&&(a[0]|=128),t.enqueue(a),t.enqueue(n)})}})}let i2;function a2(e){return e.reduce((e,t)=>e+t.length,0)}function r2(e,t){if(e[0].length===t)return e.shift();const n=new Uint8Array(t);let i=0;for(let a=0;a<t;a++)n[a]=e[0][i++],i===e[0].length&&(e.shift(),i=0);return e.length&&i<e[0].length&&(e[0]=e[0].slice(i)),n}function o2(e){if(e)return function(e){for(var t in o2.prototype)e[t]=o2.prototype[t];return e}(e)}o2.prototype.on=o2.prototype.addEventListener=function(e,t){return this._callbacks=this._callbacks||{},(this._callbacks["$"+e]=this._callbacks["$"+e]||[]).push(t),this},o2.prototype.once=function(e,t){function n(){this.off(e,n),t.apply(this,arguments)}return n.fn=t,this.on(e,n),this},o2.prototype.off=o2.prototype.removeListener=o2.prototype.removeAllListeners=o2.prototype.removeEventListener=function(e,t){if(this._callbacks=this._callbacks||{},0==arguments.length)return this._callbacks={},this;var n,i=this._callbacks["$"+e];if(!i)return this;if(1==arguments.length)return delete this._callbacks["$"+e],this;for(var a=0;a<i.length;a++)if((n=i[a])===t||n.fn===t){i.splice(a,1);break}return 0===i.length&&delete this._callbacks["$"+e],this},o2.prototype.emit=function(e){this._callbacks=this._callbacks||{};for(var t=new Array(arguments.length-1),n=this._callbacks["$"+e],i=1;i<arguments.length;i++)t[i-1]=arguments[i];if(n){i=0;for(var a=(n=n.slice(0)).length;i<a;++i)n[i].apply(this,t)}return this},o2.prototype.emitReserved=o2.prototype.emit,o2.prototype.listeners=function(e){return this._callbacks=this._callbacks||{},this._callbacks["$"+e]||[]},o2.prototype.hasListeners=function(e){return!!this.listeners(e).length};const s2="function"==typeof Promise&&"function"==typeof Promise.resolve?e=>Promise.resolve().then(e):(e,t)=>t(e,0),c2="undefined"!=typeof self?self:"undefined"!=typeof window?window:Function("return this")();function p2(e,...t){return t.reduce((t,n)=>(e.hasOwnProperty(n)&&(t[n]=e[n]),t),{})}const l2=c2.setTimeout,u2=c2.clearTimeout;function d2(e,t){t.useNativeTimers?(e.setTimeoutFn=l2.bind(c2),e.clearTimeoutFn=u2.bind(c2)):(e.setTimeoutFn=c2.setTimeout.bind(c2),e.clearTimeoutFn=c2.clearTimeout.bind(c2))}function f2(e){return"string"==typeof e?function(e){let t=0,n=0;for(let i=0,a=e.length;i<a;i++)t=e.charCodeAt(i),t<128?n+=1:t<2048?n+=2:t<55296||t>=57344?n+=3:(i++,n+=4);return n}(e):Math.ceil(1.33*(e.byteLength||e.size))}function m2(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}class h2 extends Error{constructor(e,t,n){super(e),this.description=t,this.context=n,this.type="TransportError"}}class g2 extends o2{constructor(e){super(),this.writable=!1,d2(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,n){return super.emitReserved("error",new h2(e,t,n)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return"opening"!==this.readyState&&"open"!==this.readyState||(this.doClose(),this.onClose()),this}send(e){"open"===this.readyState&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=X1(e,this.socket.binaryType);this.onPacket(t)}onPacket(e){super.emitReserved("packet",e)}onClose(e){this.readyState="closed",super.emitReserved("close",e)}pause(e){}createUri(e,t={}){return e+"://"+this._hostname()+this._port()+this.opts.path+this._query(t)}_hostname(){const e=this.opts.hostname;return-1===e.indexOf(":")?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(443!==this.opts.port)||!this.opts.secure&&80!==Number(this.opts.port))?":"+this.opts.port:""}_query(e){const t=function(e){let t="";for(let n in e)e.hasOwnProperty(n)&&(t.length&&(t+="&"),t+=encodeURIComponent(n)+"="+encodeURIComponent(e[n]));return t}(e);return t.length?"?"+t:""}}class v2 extends g2{constructor(){super(...arguments),this._polling=!1}get name(){return"polling"}doOpen(){this._poll()}pause(e){this.readyState="pausing";const t=()=>{this.readyState="paused",e()};if(this._polling||!this.writable){let e=0;this._polling&&(e++,this.once("pollComplete",function(){--e||t()})),this.writable||(e++,this.once("drain",function(){--e||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){((e,t)=>{const n=e.split(t2),i=[];for(let a=0;a<n.length;a++){const e=X1(n[a],t);if(i.push(e),"error"===e.type)break}return i})(e,this.socket.binaryType).forEach(e=>{if("opening"===this.readyState&&"open"===e.type&&this.onOpen(),"close"===e.type)return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(e)}),"closed"!==this.readyState&&(this._polling=!1,this.emitReserved("pollComplete"),"open"===this.readyState&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};"open"===this.readyState?e():this.once("open",e)}write(e){this.writable=!1,((e,t)=>{const n=e.length,i=new Array(n);let a=0;e.forEach((e,r)=>{K1(e,!1,e=>{i[r]=e,++a===n&&t(i.join(t2))})})})(e,e=>{this.doWrite(e,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return!1!==this.opts.timestampRequests&&(t[this.opts.timestampParam]=m2()),this.supportsBinary||t.sid||(t.b64=1),this.createUri(e,t)}}let y2=!1;try{y2="undefined"!=typeof XMLHttpRequest&&"withCredentials"in new XMLHttpRequest}catch(Twe){}const b2=y2;function x2(){}class w2 extends v2{constructor(e){if(super(e),"undefined"!=typeof location){const t="https:"===location.protocol;let n=location.port;n||(n=t?"443":"80"),this.xd="undefined"!=typeof location&&e.hostname!==location.hostname||n!==e.port}}doWrite(e,t){const n=this.request({method:"POST",data:e});n.on("success",t),n.on("error",(e,t)=>{this.onError("xhr post error",e,t)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(e,t)=>{this.onError("xhr poll error",e,t)}),this.pollXhr=e}}let _2=class e extends o2{constructor(e,t,n){super(),this.createRequest=e,d2(this,n),this._opts=n,this._method=n.method||"GET",this._uri=t,this._data=void 0!==n.data?n.data:null,this._create()}_create(){var t;const n=p2(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");n.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(n);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let e in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(e)&&i.setRequestHeader(e,this._opts.extraHeaders[e])}}catch(Owe){}if("POST"===this._method)try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch(Owe){}try{i.setRequestHeader("Accept","*/*")}catch(Owe){}null===(t=this._opts.cookieJar)||void 0===t||t.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var e;3===i.readyState&&(null===(e=this._opts.cookieJar)||void 0===e||e.parseCookies(i.getResponseHeader("set-cookie"))),4===i.readyState&&(200===i.status||1223===i.status?this._onLoad():this.setTimeoutFn(()=>{this._onError("number"==typeof i.status?i.status:0)},0))},i.send(this._data)}catch(Owe){return void this.setTimeoutFn(()=>{this._onError(Owe)},0)}"undefined"!=typeof document&&(this._index=e.requestsCount++,e.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(t){if(void 0!==this._xhr&&null!==this._xhr){if(this._xhr.onreadystatechange=x2,t)try{this._xhr.abort()}catch(Owe){}"undefined"!=typeof document&&delete e.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;null!==e&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}};if(_2.requestsCount=0,_2.requests={},"undefined"!=typeof document)if("function"==typeof attachEvent)attachEvent("onunload",k2);else if("function"==typeof addEventListener){addEventListener("onpagehide"in c2?"pagehide":"unload",k2,!1)}function k2(){for(let e in _2.requests)_2.requests.hasOwnProperty(e)&&_2.requests[e].abort()}const E2=function(){const e=S2({xdomain:!1});return e&&null!==e.responseType}();function S2(e){const t=e.xdomain;try{if("undefined"!=typeof XMLHttpRequest&&(!t||b2))return new XMLHttpRequest}catch(Owe){}if(!t)try{return new(c2[["Active"].concat("Object").join("X")])("Microsoft.XMLHTTP")}catch(Owe){}}const A2="undefined"!=typeof navigator&&"string"==typeof navigator.product&&"reactnative"===navigator.product.toLowerCase();class T2 extends g2{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,n=A2?{}:p2(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(n.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,n)}catch(Twe){return this.emitReserved("error",Twe)}this.ws.binaryType=this.socket.binaryType,this.addEventListeners()}addEventListeners(){this.ws.onopen=()=>{this.opts.autoUnref&&this.ws._socket.unref(),this.onOpen()},this.ws.onclose=e=>this.onClose({description:"websocket connection closed",context:e}),this.ws.onmessage=e=>this.onData(e.data),this.ws.onerror=e=>this.onError("websocket error",e)}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],i=t===e.length-1;K1(n,this.supportsBinary,e=>{try{this.doWrite(n,e)}catch(Owe){}i&&s2(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){void 0!==this.ws&&(this.ws.onerror=()=>{},this.ws.close(),this.ws=null)}uri(){const e=this.opts.secure?"wss":"ws",t=this.query||{};return this.opts.timestampRequests&&(t[this.opts.timestampParam]=m2()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const O2=c2.WebSocket||c2.MozWebSocket;const R2={websocket:class extends T2{createSocket(e,t,n){return A2?new O2(e,t,n):t?new O2(e,t):new O2(e)}doWrite(e,t){this.ws.send(t)}},webtransport:class extends g2{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(Twe){return this.emitReserved("error",Twe)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=function(e,t){i2||(i2=new TextDecoder);const n=[];let i=0,a=-1,r=!1;return new TransformStream({transform(o,s){for(n.push(o);;){if(0===i){if(a2(n)<1)break;const e=r2(n,1);r=!(128&~e[0]),a=127&e[0],i=a<126?3:126===a?1:2}else if(1===i){if(a2(n)<2)break;const e=r2(n,2);a=new DataView(e.buffer,e.byteOffset,e.length).getUint16(0),i=3}else if(2===i){if(a2(n)<8)break;const e=r2(n,8),t=new DataView(e.buffer,e.byteOffset,e.length),r=t.getUint32(0);if(r>Math.pow(2,21)-1){s.enqueue(z1);break}a=r*Math.pow(2,32)+t.getUint32(4),i=3}else{if(a2(n)<a)break;const e=r2(n,a);s.enqueue(X1(r?e:i2.decode(e),t)),i=0}if(0===a||a>e){s.enqueue(z1);break}}}})}(Number.MAX_SAFE_INTEGER,this.socket.binaryType),n=e.readable.pipeThrough(t).getReader(),i=n2();i.readable.pipeTo(e.writable),this._writer=i.writable.getWriter();const a=()=>{n.read().then(({done:e,value:t})=>{e||(this.onPacket(t),a())}).catch(e=>{})};a();const r={type:"open"};this.query.sid&&(r.data=`{"sid":"${this.query.sid}"}`),this._writer.write(r).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const n=e[t],i=t===e.length-1;this._writer.write(n).then(()=>{i&&s2(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;null===(e=this._transport)||void 0===e||e.close()}},polling:class extends w2{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=E2&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new _2(S2,this.uri(),e)}}},j2=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,I2=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function C2(e){if(e.length>8e3)throw"URI too long";const t=e,n=e.indexOf("["),i=e.indexOf("]");-1!=n&&-1!=i&&(e=e.substring(0,n)+e.substring(n,i).replace(/:/g,";")+e.substring(i,e.length));let a=j2.exec(e||""),r={},o=14;for(;o--;)r[I2[o]]=a[o]||"";return-1!=n&&-1!=i&&(r.source=t,r.host=r.host.substring(1,r.host.length-1).replace(/;/g,":"),r.authority=r.authority.replace("[","").replace("]","").replace(/;/g,":"),r.ipv6uri=!0),r.pathNames=function(e,t){const n=/\/{2,9}/g,i=t.replace(n,"/").split("/");"/"!=t.slice(0,1)&&0!==t.length||i.splice(0,1);"/"==t.slice(-1)&&i.splice(i.length-1,1);return i}(0,r.path),r.queryKey=function(e,t){const n={};return t.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(e,t,i){t&&(n[t]=i)}),n}(0,r.query),r}const N2="function"==typeof addEventListener&&"function"==typeof removeEventListener,B2=[];N2&&addEventListener("offline",()=>{B2.forEach(e=>e())},!1);class P2 extends o2{constructor(e,t){if(super(),this.binaryType="arraybuffer",this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&"object"==typeof e&&(t=e,e=null),e){const n=C2(e);t.hostname=n.host,t.secure="https"===n.protocol||"wss"===n.protocol,t.port=n.port,n.query&&(t.query=n.query)}else t.host&&(t.hostname=C2(t.host).host);d2(this,t),this.secure=null!=t.secure?t.secure:"undefined"!=typeof location&&"https:"===location.protocol,t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||("undefined"!=typeof location?location.hostname:"localhost"),this.port=t.port||("undefined"!=typeof location&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(e=>{const t=e.prototype.name;this.transports.push(t),this._transportsByName[t]=e}),this.opts=Object.assign({path:"/engine.io",agent:!1,withCredentials:!1,upgrade:!0,timestampParam:"t",rememberUpgrade:!1,addTrailingSlash:!0,rejectUnauthorized:!0,perMessageDeflate:{threshold:1024},transportOptions:{},closeOnBeforeunload:!1},t),this.opts.path=this.opts.path.replace(/\/$/,"")+(this.opts.addTrailingSlash?"/":""),"string"==typeof this.opts.query&&(this.opts.query=function(e){let t={},n=e.split("&");for(let i=0,a=n.length;i<a;i++){let e=n[i].split("=");t[decodeURIComponent(e[0])]=decodeURIComponent(e[1])}return t}(this.opts.query)),N2&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),"localhost"!==this.hostname&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},B2.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=4,t.transport=e,this.id&&(t.sid=this.id);const n=Object.assign({},this.opts,{query:t,socket:this,hostname:this.hostname,secure:this.secure,port:this.port},this.opts.transportOptions[e]);return new this._transportsByName[e](n)}_open(){if(0===this.transports.length)return void this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);const e=this.opts.rememberUpgrade&&P2.priorWebsocketSuccess&&-1!==this.transports.indexOf("websocket")?"websocket":this.transports[0];this.readyState="opening";const t=this.createTransport(e);t.open(),this.setTransport(t)}setTransport(e){this.transport&&this.transport.removeAllListeners(),this.transport=e,e.on("drain",this._onDrain.bind(this)).on("packet",this._onPacket.bind(this)).on("error",this._onError.bind(this)).on("close",e=>this._onClose("transport close",e))}onOpen(){this.readyState="open",P2.priorWebsocketSuccess="websocket"===this.transport.name,this.emitReserved("open"),this.flush()}_onPacket(e){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState)switch(this.emitReserved("packet",e),this.emitReserved("heartbeat"),e.type){case"open":this.onHandshake(JSON.parse(e.data));break;case"ping":this._sendPacket("pong"),this.emitReserved("ping"),this.emitReserved("pong"),this._resetPingTimeout();break;case"error":const t=new Error("server error");t.code=e.data,this._onError(t);break;case"message":this.emitReserved("data",e.data),this.emitReserved("message",e.data)}}onHandshake(e){this.emitReserved("handshake",e),this.id=e.sid,this.transport.query.sid=e.sid,this._pingInterval=e.pingInterval,this._pingTimeout=e.pingTimeout,this._maxPayload=e.maxPayload,this.onOpen(),"closed"!==this.readyState&&this._resetPingTimeout()}_resetPingTimeout(){this.clearTimeoutFn(this._pingTimeoutTimer);const e=this._pingInterval+this._pingTimeout;this._pingTimeoutTime=Date.now()+e,this._pingTimeoutTimer=this.setTimeoutFn(()=>{this._onClose("ping timeout")},e),this.opts.autoUnref&&this._pingTimeoutTimer.unref()}_onDrain(){this.writeBuffer.splice(0,this._prevBufferLen),this._prevBufferLen=0,0===this.writeBuffer.length?this.emitReserved("drain"):this.flush()}flush(){if("closed"!==this.readyState&&this.transport.writable&&!this.upgrading&&this.writeBuffer.length){const e=this._getWritablePackets();this.transport.send(e),this._prevBufferLen=e.length,this.emitReserved("flush")}}_getWritablePackets(){if(!(this._maxPayload&&"polling"===this.transport.name&&this.writeBuffer.length>1))return this.writeBuffer;let e=1;for(let t=0;t<this.writeBuffer.length;t++){const n=this.writeBuffer[t].data;if(n&&(e+=f2(n)),t>0&&e>this._maxPayload)return this.writeBuffer.slice(0,t);e+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,s2(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,n){return this._sendPacket("message",e,t,n),this}send(e,t,n){return this._sendPacket("message",e,t,n),this}_sendPacket(e,t,n,i){if("function"==typeof t&&(i=t,t=void 0),"function"==typeof n&&(i=n,n=null),"closing"===this.readyState||"closed"===this.readyState)return;(n=n||{}).compress=!1!==n.compress;const a={type:e,data:t,options:n};this.emitReserved("packetCreate",a),this.writeBuffer.push(a),i&&this.once("flush",i),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},n=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return"opening"!==this.readyState&&"open"!==this.readyState||(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?n():e()}):this.upgrading?n():e()),this}_onError(e){if(P2.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&"opening"===this.readyState)return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if("opening"===this.readyState||"open"===this.readyState||"closing"===this.readyState){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.close(),this.transport.removeAllListeners(),N2&&(this._beforeunloadEventListener&&removeEventListener("beforeunload",this._beforeunloadEventListener,!1),this._offlineEventListener)){const e=B2.indexOf(this._offlineEventListener);-1!==e&&B2.splice(e,1)}this.readyState="closed",this.id=null,this.emitReserved("close",e,t),this.writeBuffer=[],this._prevBufferLen=0}}}P2.protocol=4;class L2 extends P2{constructor(){super(...arguments),this._upgrades=[]}onOpen(){if(super.onOpen(),"open"===this.readyState&&this.opts.upgrade)for(let e=0;e<this._upgrades.length;e++)this._probe(this._upgrades[e])}_probe(e){let t=this.createTransport(e),n=!1;P2.priorWebsocketSuccess=!1;const i=()=>{n||(t.send([{type:"ping",data:"probe"}]),t.once("packet",e=>{if(!n)if("pong"===e.type&&"probe"===e.data){if(this.upgrading=!0,this.emitReserved("upgrading",t),!t)return;P2.priorWebsocketSuccess="websocket"===t.name,this.transport.pause(()=>{n||"closed"!==this.readyState&&(p(),this.setTransport(t),t.send([{type:"upgrade"}]),this.emitReserved("upgrade",t),t=null,this.upgrading=!1,this.flush())})}else{const e=new Error("probe error");e.transport=t.name,this.emitReserved("upgradeError",e)}}))};function a(){n||(n=!0,p(),t.close(),t=null)}const r=e=>{const n=new Error("probe error: "+e);n.transport=t.name,a(),this.emitReserved("upgradeError",n)};function o(){r("transport closed")}function s(){r("socket closed")}function c(e){t&&e.name!==t.name&&a()}const p=()=>{t.removeListener("open",i),t.removeListener("error",r),t.removeListener("close",o),this.off("close",s),this.off("upgrading",c)};t.once("open",i),t.once("error",r),t.once("close",o),this.once("close",s),this.once("upgrading",c),-1!==this._upgrades.indexOf("webtransport")&&"webtransport"!==e?this.setTimeoutFn(()=>{n||t.open()},200):t.open()}onHandshake(e){this._upgrades=this._filterUpgrades(e.upgrades),super.onHandshake(e)}_filterUpgrades(e){const t=[];for(let n=0;n<e.length;n++)~this.transports.indexOf(e[n])&&t.push(e[n]);return t}}let U2=class extends L2{constructor(e,t={}){const n="object"==typeof e?e:t;(!n.transports||n.transports&&"string"==typeof n.transports[0])&&(n.transports=(n.transports||["polling","websocket","webtransport"]).map(e=>R2[e]).filter(e=>!!e)),super(e,n)}};const M2="function"==typeof ArrayBuffer,F2=Object.prototype.toString,D2="function"==typeof Blob||"undefined"!=typeof Blob&&"[object BlobConstructor]"===F2.call(Blob),z2="function"==typeof File||"undefined"!=typeof File&&"[object FileConstructor]"===F2.call(File);function $2(e){return M2&&(e instanceof ArrayBuffer||(e=>"function"==typeof ArrayBuffer.isView?ArrayBuffer.isView(e):e.buffer instanceof ArrayBuffer)(e))||D2&&e instanceof Blob||z2&&e instanceof File}function q2(e,t){if(!e||"object"!=typeof e)return!1;if(Array.isArray(e)){for(let t=0,n=e.length;t<n;t++)if(q2(e[t]))return!0;return!1}if($2(e))return!0;if(e.toJSON&&"function"==typeof e.toJSON&&1===arguments.length)return q2(e.toJSON(),!0);for(const n in e)if(Object.prototype.hasOwnProperty.call(e,n)&&q2(e[n]))return!0;return!1}function W2(e){const t=[],n=e.data,i=e;return i.data=K2(n,t),i.attachments=t.length,{packet:i,buffers:t}}function K2(e,t){if(!e)return e;if($2(e)){const n={_placeholder:!0,num:t.length};return t.push(e),n}if(Array.isArray(e)){const n=new Array(e.length);for(let i=0;i<e.length;i++)n[i]=K2(e[i],t);return n}if("object"==typeof e&&!(e instanceof Date)){const n={};for(const i in e)Object.prototype.hasOwnProperty.call(e,i)&&(n[i]=K2(e[i],t));return n}return e}function Z2(e,t){return e.data=V2(e.data,t),delete e.attachments,e}function V2(e,t){if(!e)return e;if(e&&!0===e._placeholder){if("number"==typeof e.num&&e.num>=0&&e.num<t.length)return t[e.num];throw new Error("illegal attachments")}if(Array.isArray(e))for(let n=0;n<e.length;n++)e[n]=V2(e[n],t);else if("object"==typeof e)for(const n in e)Object.prototype.hasOwnProperty.call(e,n)&&(e[n]=V2(e[n],t));return e}const H2=["connect","connect_error","disconnect","disconnecting","newListener","removeListener"];var G2;!function(e){e[e.CONNECT=0]="CONNECT",e[e.DISCONNECT=1]="DISCONNECT",e[e.EVENT=2]="EVENT",e[e.ACK=3]="ACK",e[e.CONNECT_ERROR=4]="CONNECT_ERROR",e[e.BINARY_EVENT=5]="BINARY_EVENT",e[e.BINARY_ACK=6]="BINARY_ACK"}(G2||(G2={}));function J2(e){return"[object Object]"===Object.prototype.toString.call(e)}class Y2 extends o2{constructor(e){super(),this.reviver=e}add(e){let t;if("string"==typeof e){if(this.reconstructor)throw new Error("got plaintext data when reconstructing a packet");t=this.decodeString(e);const n=t.type===G2.BINARY_EVENT;n||t.type===G2.BINARY_ACK?(t.type=n?G2.EVENT:G2.ACK,this.reconstructor=new X2(t),0===t.attachments&&super.emitReserved("decoded",t)):super.emitReserved("decoded",t)}else{if(!$2(e)&&!e.base64)throw new Error("Unknown type: "+e);if(!this.reconstructor)throw new Error("got binary data when not reconstructing a packet");t=this.reconstructor.takeBinaryData(e),t&&(this.reconstructor=null,super.emitReserved("decoded",t))}}decodeString(e){let t=0;const n={type:Number(e.charAt(0))};if(void 0===G2[n.type])throw new Error("unknown packet type "+n.type);if(n.type===G2.BINARY_EVENT||n.type===G2.BINARY_ACK){const i=t+1;for(;"-"!==e.charAt(++t)&&t!=e.length;);const a=e.substring(i,t);if(a!=Number(a)||"-"!==e.charAt(t))throw new Error("Illegal attachments");n.attachments=Number(a)}if("/"===e.charAt(t+1)){const i=t+1;for(;++t;){if(","===e.charAt(t))break;if(t===e.length)break}n.nsp=e.substring(i,t)}else n.nsp="/";const i=e.charAt(t+1);if(""!==i&&Number(i)==i){const i=t+1;for(;++t;){const n=e.charAt(t);if(null==n||Number(n)!=n){--t;break}if(t===e.length)break}n.id=Number(e.substring(i,t+1))}if(e.charAt(++t)){const i=this.tryParse(e.substr(t));if(!Y2.isPayloadValid(n.type,i))throw new Error("invalid payload");n.data=i}return n}tryParse(e){try{return JSON.parse(e,this.reviver)}catch(Owe){return!1}}static isPayloadValid(e,t){switch(e){case G2.CONNECT:return J2(t);case G2.DISCONNECT:return void 0===t;case G2.CONNECT_ERROR:return"string"==typeof t||J2(t);case G2.EVENT:case G2.BINARY_EVENT:return Array.isArray(t)&&("number"==typeof t[0]||"string"==typeof t[0]&&-1===H2.indexOf(t[0]));case G2.ACK:case G2.BINARY_ACK:return Array.isArray(t)}}destroy(){this.reconstructor&&(this.reconstructor.finishedReconstruction(),this.reconstructor=null)}}class X2{constructor(e){this.packet=e,this.buffers=[],this.reconPack=e}takeBinaryData(e){if(this.buffers.push(e),this.buffers.length===this.reconPack.attachments){const e=Z2(this.reconPack,this.buffers);return this.finishedReconstruction(),e}return null}finishedReconstruction(){this.reconPack=null,this.buffers=[]}}const Q2=Object.freeze(Object.defineProperty({__proto__:null,Decoder:Y2,Encoder:class{constructor(e){this.replacer=e}encode(e){return e.type!==G2.EVENT&&e.type!==G2.ACK||!q2(e)?[this.encodeAsString(e)]:this.encodeAsBinary({type:e.type===G2.EVENT?G2.BINARY_EVENT:G2.BINARY_ACK,nsp:e.nsp,data:e.data,id:e.id})}encodeAsString(e){let t=""+e.type;return e.type!==G2.BINARY_EVENT&&e.type!==G2.BINARY_ACK||(t+=e.attachments+"-"),e.nsp&&"/"!==e.nsp&&(t+=e.nsp+","),null!=e.id&&(t+=e.id),null!=e.data&&(t+=JSON.stringify(e.data,this.replacer)),t}encodeAsBinary(e){const t=W2(e),n=this.encodeAsString(t.packet),i=t.buffers;return i.unshift(n),i}},get PacketType(){return G2},protocol:5},Symbol.toStringTag,{value:"Module"}));function e4(e,t,n){return e.on(t,n),function(){e.off(t,n)}}const t4=Object.freeze({connect:1,connect_error:1,disconnect:1,disconnecting:1,newListener:1,removeListener:1});class n4 extends o2{constructor(e,t,n){super(),this.connected=!1,this.recovered=!1,this.receiveBuffer=[],this.sendBuffer=[],this._queue=[],this._queueSeq=0,this.ids=0,this.acks={},this.flags={},this.io=e,this.nsp=t,n&&n.auth&&(this.auth=n.auth),this._opts=Object.assign({},n),this.io._autoConnect&&this.open()}get disconnected(){return!this.connected}subEvents(){if(this.subs)return;const e=this.io;this.subs=[e4(e,"open",this.onopen.bind(this)),e4(e,"packet",this.onpacket.bind(this)),e4(e,"error",this.onerror.bind(this)),e4(e,"close",this.onclose.bind(this))]}get active(){return!!this.subs}connect(){return this.connected||(this.subEvents(),this.io._reconnecting||this.io.open(),"open"===this.io._readyState&&this.onopen()),this}open(){return this.connect()}send(...e){return e.unshift("message"),this.emit.apply(this,e),this}emit(e,...t){var n,i,a;if(t4.hasOwnProperty(e))throw new Error('"'+e.toString()+'" is a reserved event name');if(t.unshift(e),this._opts.retries&&!this.flags.fromQueue&&!this.flags.volatile)return this._addToQueue(t),this;const r={type:G2.EVENT,data:t,options:{}};if(r.options.compress=!1!==this.flags.compress,"function"==typeof t[t.length-1]){const e=this.ids++,n=t.pop();this._registerAckCallback(e,n),r.id=e}const o=null===(i=null===(n=this.io.engine)||void 0===n?void 0:n.transport)||void 0===i?void 0:i.writable,s=this.connected&&!(null===(a=this.io.engine)||void 0===a?void 0:a._hasPingExpired());return this.flags.volatile&&!o||(s?(this.notifyOutgoingListeners(r),this.packet(r)):this.sendBuffer.push(r)),this.flags={},this}_registerAckCallback(e,t){var n;const i=null!==(n=this.flags.timeout)&&void 0!==n?n:this._opts.ackTimeout;if(void 0===i)return void(this.acks[e]=t);const a=this.io.setTimeoutFn(()=>{delete this.acks[e];for(let t=0;t<this.sendBuffer.length;t++)this.sendBuffer[t].id===e&&this.sendBuffer.splice(t,1);t.call(this,new Error("operation has timed out"))},i),r=(...e)=>{this.io.clearTimeoutFn(a),t.apply(this,e)};r.withError=!0,this.acks[e]=r}emitWithAck(e,...t){return new Promise((n,i)=>{const a=(e,t)=>e?i(e):n(t);a.withError=!0,t.push(a),this.emit(e,...t)})}_addToQueue(e){let t;"function"==typeof e[e.length-1]&&(t=e.pop());const n={id:this._queueSeq++,tryCount:0,pending:!1,args:e,flags:Object.assign({fromQueue:!0},this.flags)};e.push((e,...i)=>{if(n!==this._queue[0])return;return null!==e?n.tryCount>this._opts.retries&&(this._queue.shift(),t&&t(e)):(this._queue.shift(),t&&t(null,...i)),n.pending=!1,this._drainQueue()}),this._queue.push(n),this._drainQueue()}_drainQueue(e=!1){if(!this.connected||0===this._queue.length)return;const t=this._queue[0];t.pending&&!e||(t.pending=!0,t.tryCount++,this.flags=t.flags,this.emit.apply(this,t.args))}packet(e){e.nsp=this.nsp,this.io._packet(e)}onopen(){"function"==typeof this.auth?this.auth(e=>{this._sendConnectPacket(e)}):this._sendConnectPacket(this.auth)}_sendConnectPacket(e){this.packet({type:G2.CONNECT,data:this._pid?Object.assign({pid:this._pid,offset:this._lastOffset},e):e})}onerror(e){this.connected||this.emitReserved("connect_error",e)}onclose(e,t){this.connected=!1,delete this.id,this.emitReserved("disconnect",e,t),this._clearAcks()}_clearAcks(){Object.keys(this.acks).forEach(e=>{if(!this.sendBuffer.some(t=>String(t.id)===e)){const t=this.acks[e];delete this.acks[e],t.withError&&t.call(this,new Error("socket has been disconnected"))}})}onpacket(e){if(e.nsp===this.nsp)switch(e.type){case G2.CONNECT:e.data&&e.data.sid?this.onconnect(e.data.sid,e.data.pid):this.emitReserved("connect_error",new Error("It seems you are trying to reach a Socket.IO server in v2.x with a v3.x client, but they are not compatible (more information here: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/)"));break;case G2.EVENT:case G2.BINARY_EVENT:this.onevent(e);break;case G2.ACK:case G2.BINARY_ACK:this.onack(e);break;case G2.DISCONNECT:this.ondisconnect();break;case G2.CONNECT_ERROR:this.destroy();const t=new Error(e.data.message);t.data=e.data.data,this.emitReserved("connect_error",t)}}onevent(e){const t=e.data||[];null!=e.id&&t.push(this.ack(e.id)),this.connected?this.emitEvent(t):this.receiveBuffer.push(Object.freeze(t))}emitEvent(e){if(this._anyListeners&&this._anyListeners.length){const t=this._anyListeners.slice();for(const n of t)n.apply(this,e)}super.emit.apply(this,e),this._pid&&e.length&&"string"==typeof e[e.length-1]&&(this._lastOffset=e[e.length-1])}ack(e){const t=this;let n=!1;return function(...i){n||(n=!0,t.packet({type:G2.ACK,id:e,data:i}))}}onack(e){const t=this.acks[e.id];"function"==typeof t&&(delete this.acks[e.id],t.withError&&e.data.unshift(null),t.apply(this,e.data))}onconnect(e,t){this.id=e,this.recovered=t&&this._pid===t,this._pid=t,this.connected=!0,this.emitBuffered(),this.emitReserved("connect"),this._drainQueue(!0)}emitBuffered(){this.receiveBuffer.forEach(e=>this.emitEvent(e)),this.receiveBuffer=[],this.sendBuffer.forEach(e=>{this.notifyOutgoingListeners(e),this.packet(e)}),this.sendBuffer=[]}ondisconnect(){this.destroy(),this.onclose("io server disconnect")}destroy(){this.subs&&(this.subs.forEach(e=>e()),this.subs=void 0),this.io._destroy(this)}disconnect(){return this.connected&&this.packet({type:G2.DISCONNECT}),this.destroy(),this.connected&&this.onclose("io client disconnect"),this}close(){return this.disconnect()}compress(e){return this.flags.compress=e,this}get volatile(){return this.flags.volatile=!0,this}timeout(e){return this.flags.timeout=e,this}onAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.push(e),this}prependAny(e){return this._anyListeners=this._anyListeners||[],this._anyListeners.unshift(e),this}offAny(e){if(!this._anyListeners)return this;if(e){const t=this._anyListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyListeners=[];return this}listenersAny(){return this._anyListeners||[]}onAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.push(e),this}prependAnyOutgoing(e){return this._anyOutgoingListeners=this._anyOutgoingListeners||[],this._anyOutgoingListeners.unshift(e),this}offAnyOutgoing(e){if(!this._anyOutgoingListeners)return this;if(e){const t=this._anyOutgoingListeners;for(let n=0;n<t.length;n++)if(e===t[n])return t.splice(n,1),this}else this._anyOutgoingListeners=[];return this}listenersAnyOutgoing(){return this._anyOutgoingListeners||[]}notifyOutgoingListeners(e){if(this._anyOutgoingListeners&&this._anyOutgoingListeners.length){const t=this._anyOutgoingListeners.slice();for(const n of t)n.apply(this,e.data)}}}function i4(e){e=e||{},this.ms=e.min||100,this.max=e.max||1e4,this.factor=e.factor||2,this.jitter=e.jitter>0&&e.jitter<=1?e.jitter:0,this.attempts=0}i4.prototype.duration=function(){var e=this.ms*Math.pow(this.factor,this.attempts++);if(this.jitter){var t=Math.random(),n=Math.floor(t*this.jitter*e);e=1&Math.floor(10*t)?e+n:e-n}return 0|Math.min(e,this.max)},i4.prototype.reset=function(){this.attempts=0},i4.prototype.setMin=function(e){this.ms=e},i4.prototype.setMax=function(e){this.max=e},i4.prototype.setJitter=function(e){this.jitter=e};class a4 extends o2{constructor(e,t){var n;super(),this.nsps={},this.subs=[],e&&"object"==typeof e&&(t=e,e=void 0),(t=t||{}).path=t.path||"/socket.io",this.opts=t,d2(this,t),this.reconnection(!1!==t.reconnection),this.reconnectionAttempts(t.reconnectionAttempts||1/0),this.reconnectionDelay(t.reconnectionDelay||1e3),this.reconnectionDelayMax(t.reconnectionDelayMax||5e3),this.randomizationFactor(null!==(n=t.randomizationFactor)&&void 0!==n?n:.5),this.backoff=new i4({min:this.reconnectionDelay(),max:this.reconnectionDelayMax(),jitter:this.randomizationFactor()}),this.timeout(null==t.timeout?2e4:t.timeout),this._readyState="closed",this.uri=e;const i=t.parser||Q2;this.encoder=new i.Encoder,this.decoder=new i.Decoder,this._autoConnect=!1!==t.autoConnect,this._autoConnect&&this.open()}reconnection(e){return arguments.length?(this._reconnection=!!e,e||(this.skipReconnect=!0),this):this._reconnection}reconnectionAttempts(e){return void 0===e?this._reconnectionAttempts:(this._reconnectionAttempts=e,this)}reconnectionDelay(e){var t;return void 0===e?this._reconnectionDelay:(this._reconnectionDelay=e,null===(t=this.backoff)||void 0===t||t.setMin(e),this)}randomizationFactor(e){var t;return void 0===e?this._randomizationFactor:(this._randomizationFactor=e,null===(t=this.backoff)||void 0===t||t.setJitter(e),this)}reconnectionDelayMax(e){var t;return void 0===e?this._reconnectionDelayMax:(this._reconnectionDelayMax=e,null===(t=this.backoff)||void 0===t||t.setMax(e),this)}timeout(e){return arguments.length?(this._timeout=e,this):this._timeout}maybeReconnectOnOpen(){!this._reconnecting&&this._reconnection&&0===this.backoff.attempts&&this.reconnect()}open(e){if(~this._readyState.indexOf("open"))return this;this.engine=new U2(this.uri,this.opts);const t=this.engine,n=this;this._readyState="opening",this.skipReconnect=!1;const i=e4(t,"open",function(){n.onopen(),e&&e()}),a=t=>{this.cleanup(),this._readyState="closed",this.emitReserved("error",t),e?e(t):this.maybeReconnectOnOpen()},r=e4(t,"error",a);if(!1!==this._timeout){const e=this._timeout,n=this.setTimeoutFn(()=>{i(),a(new Error("timeout")),t.close()},e);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}return this.subs.push(i),this.subs.push(r),this}connect(e){return this.open(e)}onopen(){this.cleanup(),this._readyState="open",this.emitReserved("open");const e=this.engine;this.subs.push(e4(e,"ping",this.onping.bind(this)),e4(e,"data",this.ondata.bind(this)),e4(e,"error",this.onerror.bind(this)),e4(e,"close",this.onclose.bind(this)),e4(this.decoder,"decoded",this.ondecoded.bind(this)))}onping(){this.emitReserved("ping")}ondata(e){try{this.decoder.add(e)}catch(Owe){this.onclose("parse error",Owe)}}ondecoded(e){s2(()=>{this.emitReserved("packet",e)},this.setTimeoutFn)}onerror(e){this.emitReserved("error",e)}socket(e,t){let n=this.nsps[e];return n?this._autoConnect&&!n.active&&n.connect():(n=new n4(this,e,t),this.nsps[e]=n),n}_destroy(e){const t=Object.keys(this.nsps);for(const n of t){if(this.nsps[n].active)return}this._close()}_packet(e){const t=this.encoder.encode(e);for(let n=0;n<t.length;n++)this.engine.write(t[n],e.options)}cleanup(){this.subs.forEach(e=>e()),this.subs.length=0,this.decoder.destroy()}_close(){this.skipReconnect=!0,this._reconnecting=!1,this.onclose("forced close")}disconnect(){return this._close()}onclose(e,t){var n;this.cleanup(),null===(n=this.engine)||void 0===n||n.close(),this.backoff.reset(),this._readyState="closed",this.emitReserved("close",e,t),this._reconnection&&!this.skipReconnect&&this.reconnect()}reconnect(){if(this._reconnecting||this.skipReconnect)return this;const e=this;if(this.backoff.attempts>=this._reconnectionAttempts)this.backoff.reset(),this.emitReserved("reconnect_failed"),this._reconnecting=!1;else{const t=this.backoff.duration();this._reconnecting=!0;const n=this.setTimeoutFn(()=>{e.skipReconnect||(this.emitReserved("reconnect_attempt",e.backoff.attempts),e.skipReconnect||e.open(t=>{t?(e._reconnecting=!1,e.reconnect(),this.emitReserved("reconnect_error",t)):e.onreconnect()}))},t);this.opts.autoUnref&&n.unref(),this.subs.push(()=>{this.clearTimeoutFn(n)})}}onreconnect(){const e=this.backoff.attempts;this._reconnecting=!1,this.backoff.reset(),this.emitReserved("reconnect",e)}}const r4={};function o4(e,t){"object"==typeof e&&(t=e,e=void 0);const n=function(e,t="",n){let i=e;n=n||"undefined"!=typeof location&&location,null==e&&(e=n.protocol+"//"+n.host),"string"==typeof e&&("/"===e.charAt(0)&&(e="/"===e.charAt(1)?n.protocol+e:n.host+e),/^(https?|wss?):\/\//.test(e)||(e=void 0!==n?n.protocol+"//"+e:"https://"+e),i=C2(e)),i.port||(/^(http|ws)$/.test(i.protocol)?i.port="80":/^(http|ws)s$/.test(i.protocol)&&(i.port="443")),i.path=i.path||"/";const a=-1!==i.host.indexOf(":")?"["+i.host+"]":i.host;return i.id=i.protocol+"://"+a+":"+i.port+t,i.href=i.protocol+"://"+a+(n&&n.port===i.port?"":":"+i.port),i}(e,(t=t||{}).path||"/socket.io"),i=n.source,a=n.id,r=n.path,o=r4[a]&&r in r4[a].nsps;let s;return t.forceNew||t["force new connection"]||!1===t.multiplex||o?s=new a4(i,t):(r4[a]||(r4[a]=new a4(i,t)),s=r4[a]),n.query&&!t.query&&(t.query=n.queryKey),s.socket(n.path,t)}Object.assign(o4,{Manager:a4,Socket:n4,io:o4,connect:o4});const s4=class e{constructor(e){if(lr(this,"client"),lr(this,"config"),lr(this,"logger",oc.getInstance()),lr(this,"socket",null),lr(this,"socketConnected",!1),lr(this,"connectionMode","auto"),lr(this,"wsBaseUrl",null),this.config=e,!e.apiKey)throw new sc("API key is required");if(!e.network)throw new sc("Network is required");const t={"x-api-key":e.apiKey,"Content-Type":"application/json"};this.client=qs.create({baseURL:"https://v2-api.tier.bot/api",headers:t}),this.logger=oc.getInstance(),e.wsBaseUrl&&(this.wsBaseUrl=e.wsBaseUrl),this.connectionMode=e.connectionMode||"websocket",this.wsBaseUrl||"http"===this.connectionMode||this.fetchWebSocketServers().catch(e=>this.logger.warn("Failed to fetch WebSocket servers:",e))}async getFileMetadata(e){try{const t=await qs.get(e),n=t.headers["content-type"]||"";return{size:parseInt(t.headers["content-length"]||"0",10),mimeType:n}}catch(t){throw this.logger.error("Error fetching file metadata:",t),new sc("Unable to fetch file metadata")}}getMimeType(t){const n=t.toLowerCase().split(".").pop();if(!n)throw new sc("File must have an extension");const i=e.VALID_MIME_TYPES[n];if(!i)throw new sc(`Unsupported file type: ${n}`);return i}validateRequest(t){if(this.logger.debug("Validating request:",t),!t.holderId||""===t.holderId.trim())throw this.logger.warn("holderId is missing or empty"),new sc("holderId is required");if(!e.VALID_MODES.includes(t.mode))throw new sc(`Invalid mode: ${t.mode}. Must be one of: ${e.VALID_MODES.join(", ")}`);if("hashinal"===t.mode&&!t.jsonFileURL&&!t.metadataObject)throw new sc("Hashinal mode requires either jsonFileURL or metadataObject");if(t.onlyJSONCollection&&"hashinal-collection"!==t.mode)throw new sc("onlyJSONCollection can only be used with hashinal-collection mode");this.validateFileInput(t.file)}normalizeMimeType(e){return"image/vnd.microsoft.icon"===e?(this.logger.debug("Normalizing MIME type from image/vnd.microsoft.icon to image/x-icon"),"image/x-icon"):e}validateMimeType(t){return!!Object.values(e.VALID_MIME_TYPES).includes(t)||"image/vnd.microsoft.icon"===t&&(this.logger.debug("Accepting alternative MIME type for ICO: image/vnd.microsoft.icon"),!0)}validateFileInput(t){if("base64"===t.type){if(!t.base64)throw new sc("Base64 data is required");const n=t.base64.replace(/^data:.*?;base64,/,"");if(Math.ceil(.75*n.length)>e.MAX_BASE64_SIZE)throw new sc(`File size exceeds maximum limit of ${e.MAX_BASE64_SIZE/1024/1024}MB`);const i=t.mimeType||this.getMimeType(t.fileName);if(!this.validateMimeType(i))throw new sc("File must have one of the supported MIME types");"image/vnd.microsoft.icon"===t.mimeType&&(t.mimeType=this.normalizeMimeType(t.mimeType))}else if("url"===t.type&&!t.url)throw new sc("URL is required")}async detectMimeTypeFromBase64(e){if(e.startsWith("data:")){const t=e.match(/^data:([^;]+);base64,/);if(t&&t.length>1)return t[1]}try{const t=e.replace(/\s/g,""),n=_r.from(t,"base64"),i=await async function(e,t){return new M1(t).fromBuffer(e)}(n);return(null==i?void 0:i.mime)||"application/octet-stream"}catch(Twe){return this.logger.warn("Failed to detect MIME type from buffer"),"application/octet-stream"}}async startInscription(t){var n,i;try{this.validateRequest(t);let n=t.file.mimeType;if("url"===t.file.type){const i=await this.getFileMetadata(t.file.url);if(n=i.mimeType||n,i.size>e.MAX_URL_FILE_SIZE)throw new sc(`File size exceeds maximum URL file limit of ${e.MAX_URL_FILE_SIZE/1024/1024}MB`)}else"base64"===t.file.type&&(n=await this.detectMimeTypeFromBase64(t.file.base64));if("image/vnd.microsoft.icon"===n&&(n=this.normalizeMimeType(n)),t.jsonFileURL){if("application/json"!==(await this.getFileMetadata(t.jsonFileURL)).mimeType)throw new sc("JSON file must be of type application/json")}const i={holderId:t.holderId,mode:t.mode,network:this.config.network,onlyJSONCollection:t.onlyJSONCollection?1:0,creator:t.creator,description:t.description,fileStandard:t.fileStandard,metadataObject:t.metadataObject,jsonFileURL:t.jsonFileURL};let a;return a="url"===t.file.type?await this.client.post("/inscriptions/start-inscription",{...i,fileURL:t.file.url}):await this.client.post("/inscriptions/start-inscription",{...i,fileBase64:t.file.base64,fileName:t.file.fileName,fileMimeType:n||this.getMimeType(t.file.fileName)}),a.data}catch(a){if(a instanceof sc)throw a;if(qs.isAxiosError(a))throw new Error((null==(i=null==(n=a.response)?void 0:n.data)?void 0:i.message)||"Failed to start inscription");throw a}}async executeTransaction(e,t){var n,a;try{const r="mainnet"===t.network?i.Client.forMainnet():i.Client.forTestnet(),o=new pl(t.network),s=await o.requestAccount(t.accountId),c=null==(n=null==s?void 0:s.key)?void 0:n._type,p="string"==typeof t.privateKey;let l;if(c&&p)l=(null==(a=null==c?void 0:c.toLowerCase())?void 0:a.includes("ecdsa"))?i.PrivateKey.fromStringECDSA(t.privateKey):i.PrivateKey.fromStringED25519(t.privateKey);else if(!c&&p){const e=p?dl(t.privateKey):void 0;l="ed25519"===(null==e?void 0:e.detectedType)?i.PrivateKey.fromStringED25519(t.privateKey):i.PrivateKey.fromStringECDSA(t.privateKey)}else l=t.privateKey;r.setOperator(t.accountId,l);const u=i.TransferTransaction.fromBytes(_r.from(e,"base64")),d=await u.sign(l),f=await d.execute(r),m=(await f.getReceipt(r)).status.toString();if("SUCCESS"!==m)throw new Error(`Transaction failed with status: ${m}`);return f.transactionId.toString()}catch(r){throw new Error(`Failed to execute transaction: ${r instanceof Error?r.message:"Unknown error"}`)}}async executeTransactionWithSigner(e,t){try{const n=i.TransferTransaction.fromBytes(_r.from(e,"base64")),a=await n.executeWithSigner(t),r=(await a.getReceiptWithSigner(t)).status.toString();if("SUCCESS"!==r)throw new Error(`Transaction failed with status: ${r}`);return a.transactionId.toString()}catch(n){throw new Error(`Failed to execute transaction: ${n instanceof Error?n.message:"Unknown error"}`)}}async inscribeAndExecute(e,t,n,i){const a=(null==i?void 0:i.waitForCompletion)??!0,r=(null==i?void 0:i.maxWaitTime)??12e4,o=(null==i?void 0:i.checkInterval)??2e3;if(this.logger.debug("inscribeAndExecute called",{hasProgressCallback:!!n,connectionMode:this.connectionMode,wsBaseUrl:this.wsBaseUrl}),"http"!==this.connectionMode){const i="websocket"===this.connectionMode||"auto"===this.connectionMode&&await this.detectBestConnection();if(i)try{return await this.inscribeViaWebSocket(e,t,n)}catch(l){throw this.logger.error("WebSocket inscription failed, falling back to HTTP:",l),l}else this.logger.info(`Not using WebSocket: useWebSocket=${i}, wsBaseUrl=${this.wsBaseUrl}`)}else this.logger.info(`Not using WebSocket: hasCallback=${!!n}, connectionMode=${this.connectionMode}`);const s=await this.startInscription(e);if(!s.transactionBytes)throw this.logger.error("No transaction bytes returned from inscription request",s),new Error("No transaction bytes returned from inscription request");this.logger.info("executing transaction");const c=await this.executeTransaction(s.transactionBytes,t),p={jobId:s.tx_id,transactionId:c};if(a){n&&n({stage:"confirming",message:"Transaction executed, waiting for inscription to complete",progressPercent:5});const e=Math.floor(r/o),t=await this.waitForInscription(c,e,o,!0,n);return{...p,topicId:t.topic_id,status:t.status,completed:t.completed}}return p}async fetchWebSocketServers(){try{const e=await this.client.get("/inscriptions/websocket-servers"),{servers:t,recommended:n}=e.data;if(n)this.wsBaseUrl=n;else if(t&&t.length>0){const e=t.filter(e=>"active"===e.status);if(e.length>0){const t=e[0];this.wsBaseUrl=t.url}}}catch(e){this.logger.debug("Could not fetch WebSocket servers, will use HTTP only")}}async detectBestConnection(){if(!this.wsBaseUrl)return!1;try{const e=o4(this.wsBaseUrl,{auth:{apiKey:this.config.apiKey},transports:["websocket"],timeout:3e3});return new Promise(t=>{const n=setTimeout(()=>{e.disconnect(),t(!1)},3e3);e.on("connect",()=>{clearTimeout(n),e.disconnect(),t(!0)}),e.on("connect_error",()=>{clearTimeout(n),e.disconnect(),t(!1)})})}catch(Owe){return!1}}async inscribeViaWebSocket(e,t,n){if(!this.wsBaseUrl){const e=(await this.client.get("/inscriptions/websocket-servers")).data.recommended;if(!e)throw new Error("No WebSocket servers available");this.wsBaseUrl=e}return await this.connectWebSocket(),new Promise((i,a)=>{if(!this.socket)return a(new Error("WebSocket not connected"));let r,o,s,c;const p=()=>{var e,t,n;c&&clearTimeout(c),null==(e=this.socket)||e.off("inscription-progress",d),null==(t=this.socket)||t.off("inscription-complete",l),null==(n=this.socket)||n.off("inscription-error",u)};c=setTimeout(()=>{this.logger.error("WebSocket inscription timeout after 60 seconds",{jobId:r,transactionId:o,lastTopicId:s}),p(),i({jobId:r,transactionId:o,topicId:s,topic_id:s,status:"timeout",completed:!1})},6e4);const l=e=>{p(),i({jobId:r,transactionId:o,topicId:e.topicId||e.topic_id,topic_id:e.topicId||e.topic_id,status:"completed",completed:!0})},u=e=>{p(),a(new Error(e.error||"Inscription failed"))},d=e=>{this.logger.debug("Progress event received:",{jobId:e.jobId,status:e.status,progress:e.progress,topicId:e.topicId||e.topic_id,topic_id:e.topicId||e.topic_id}),(e.topicId||e.topic_id)&&(s=e.topicId||e.topic_id),n&&n({stage:"completed"===e.status?"completed":"confirming",message:`Processing inscription: ${e.status}`,progressPercent:e.progress||0,details:e}),"completed"!==e.status&&100!==e.progress||(this.logger.info("Inscription completed via progress handler",{status:e.status,progress:e.progress,topicId:e.topicId||e.topic_id||s,topic_id:e.topicId||e.topic_id||s}),p(),i({jobId:r,transactionId:o,topicId:e.topicId||e.topic_id||s,topic_id:e.topicId||e.topic_id||s,status:"completed",completed:!0}))};this.socket.on("inscription-progress",d),this.socket.on("inscription-complete",l),this.socket.on("inscription-error",u),this.socket.emit("start-inscription",{...e,network:this.config.network},async e=>{if(!e.success)return p(),a(new Error(e.error||"Inscription failed"));try{if(!e.transactionBytes)throw new Error("No transaction bytes returned from WebSocket inscription");if(o=await this.executeTransaction(e.transactionBytes,t),r=e.jobId||e.tx_id,!r)throw new Error("No job ID returned from WebSocket inscription");n&&n({stage:"confirming",message:"Transaction executed, inscribing to HCS...",progressPercent:5}),this.logger.info("Transaction executed, waiting for inscription completion...",{jobId:r,transactionId:o})}catch(i){p(),a(i)}})})}async connectWebSocket(){if(!this.socketConnected||!this.socket){if(!this.wsBaseUrl)throw new Error("WebSocket URL not configured");return new Promise((e,t)=>{this.socket=o4(this.wsBaseUrl,{auth:{apiKey:this.config.apiKey},transports:["websocket","polling"]});const n=setTimeout(()=>{t(new Error("WebSocket connection timeout"))},1e4);this.socket.on("connect",()=>{clearTimeout(n),this.socketConnected=!0,this.logger.info("WebSocket connected"),e()}),this.socket.on("connect_error",e=>{clearTimeout(n),this.socketConnected=!1,t(new Error(`WebSocket connection failed: ${e.message}`))}),this.socket.on("disconnect",()=>{this.socketConnected=!1,this.logger.info("WebSocket disconnected")})})}}disconnect(){this.socket&&(this.socket.disconnect(),this.socket=null,this.socketConnected=!1)}async inscribe(e,t){const n=await this.startInscription(e);if(!n.transactionBytes)throw this.logger.error("No transaction bytes returned from inscription request",n),new Error("No transaction bytes returned from inscription request");this.logger.info("executing transaction");const i=await this.executeTransactionWithSigner(n.transactionBytes,t);return{jobId:n.tx_id,transactionId:i}}async retryWithBackoff(e,t=3,n=1e3){for(let a=0;a<t;a++)try{return await e()}catch(i){if(a===t-1)throw i;const e=n*Math.pow(2,a);await new Promise(t=>setTimeout(t,e)),this.logger.debug(`Retry attempt ${a+1}/${t} after ${e}ms delay`)}throw new Error("Retry operation failed")}async retrieveInscription(e){if(!e)throw new sc("Transaction ID is required");try{return await this.retryWithBackoff(async()=>{const t=(await this.client.get(`/inscriptions/retrieve-inscription?id=${e}`)).data;return{...t,jobId:t.id}})}catch(t){throw this.logger.error("Failed to retrieve inscription:",t),t}}async getInscriptionNumbers(e={}){try{return(await this.client.get("/inscriptions/numbers",{params:e})).data}catch(t){throw this.logger.error("Failed to fetch inscription numbers:",t),t}}static async authenticate(e){return new C1(e).authenticate()}static async createWithAuth(t){const n="client"===t.type?new N1({...t,logger:oc.getInstance()}):new C1(t),{apiKey:i}=await n.authenticate();return new e({apiKey:i,network:t.network||"mainnet",wsBaseUrl:t.wsBaseUrl,connectionMode:t.connectionMode||"websocket"})}async waitForInscription(e,t=30,n=4e3,i=!1,a){var r;let o=0,s=0;const c=(n,i,r,c)=>{if(a)try{s=Math.max(s,r),a({stage:n,message:i,progressPercent:s,details:{...c,txId:e,currentAttempt:o,maxAttempts:t}})}catch(Twe){this.logger.warn(`Error in progress callback: ${Twe}`)}};for(c("confirming","Starting inscription verification",0);o<t;){c("confirming",`Verifying inscription status (attempt ${o+1}/${t})`,5,{attempt:o+1});const a=await this.retrieveInscription(e);if(a.error)throw c("verifying",`Error: ${a.error}`,100,{error:a.error}),new Error(a.error);let s=5;void 0!==a.messages&&void 0!==a.maxMessages&&a.maxMessages>0?(s=Math.min(95,5+a.messages/a.maxMessages*90),a.completed&&(s=100)):"processing"===a.status?s=10:a.completed&&(s=100),c(a.completed?"completed":"confirming",a.completed?"Inscription completed successfully":`Processing inscription (${a.status})`,s,{status:a.status,messagesProcessed:a.messages,maxMessages:a.maxMessages,messageCount:a.messages,completed:a.completed,confirmedMessages:a.confirmedMessages,result:a});const p="hashinal"===a.mode,l="6"===(null==(r=a.fileStandard)?void 0:r.toString());if(p&&a.topic_id&&a.jsonTopicId&&(!i||a.completed))return c("completed","Inscription verification complete",100,{result:a}),a;if(!p&&!l&&a.topic_id&&(!i||a.completed))return c("completed","Inscription verification complete",100,{result:a}),a;if(l&&a.topic_id&&a.jsonTopicId&&a.registryTopicId&&(!i||a.completed))return c("completed","Inscription verification complete",100,{result:a}),a;await new Promise(e=>setTimeout(e,n)),o++}throw c("verifying",`Inscription ${e} did not complete within ${t} attempts`,100,{timedOut:!0}),new Error(`Inscription ${e} did not complete within ${t} attempts`)}async getHolderInscriptions(e){var t,n;if(!e.holderId)throw new sc("Holder ID is required");try{const t={holderId:e.holderId};e.includeCollections&&(t.includeCollections="1");return(await this.client.get("/inscriptions/holder-inscriptions",{params:t})).data}catch(i){if(this.logger.error("Failed to fetch holder inscriptions:",i),qs.isAxiosError(i))throw new Error((null==(n=null==(t=i.response)?void 0:t.data)?void 0:n.message)||"Failed to fetch holder inscriptions");throw i}}};lr(s4,"VALID_MODES",["file","upload","hashinal","hashinal-collection"]),lr(s4,"MAX_BASE64_SIZE",2097152),lr(s4,"MAX_URL_FILE_SIZE",104857600),lr(s4,"VALID_MIME_TYPES",{jpg:"image/jpeg",jpeg:"image/jpeg",png:"image/png",gif:"image/gif",ico:"image/x-icon",heic:"image/heic",heif:"image/heif",bmp:"image/bmp",webp:"image/webp",tiff:"image/tiff",tif:"image/tiff",svg:"image/svg+xml",mp4:"video/mp4",webm:"video/webm",mp3:"audio/mpeg",pdf:"application/pdf",doc:"application/msword",docx:"application/vnd.openxmlformats-officedocument.wordprocessingml.document",xls:"application/vnd.ms-excel",xlsx:"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",ppt:"application/vnd.ms-powerpoint",pptx:"application/vnd.openxmlformats-officedocument.presentationml.presentation",html:"text/html",htm:"text/html",css:"text/css",php:"application/x-httpd-php",java:"text/x-java-source",js:"application/javascript",mjs:"application/javascript",csv:"text/csv",json:"application/json",txt:"text/plain",glb:"model/gltf-binary",wav:"audio/wav",ogg:"audio/ogg",oga:"audio/ogg",flac:"audio/flac",aac:"audio/aac",m4a:"audio/mp4",avi:"video/x-msvideo",mov:"video/quicktime",mkv:"video/x-matroska",m4v:"video/mp4",mpg:"video/mpeg",mpeg:"video/mpeg",ts:"application/typescript",zip:"application/zip",rar:"application/vnd.rar",tar:"application/x-tar",gz:"application/gzip","7z":"application/x-7z-compressed",xml:"application/xml",yaml:"application/yaml",yml:"application/yaml",md:"text/markdown",markdown:"text/markdown",rtf:"application/rtf",gltf:"model/gltf+json",usdz:"model/vnd.usdz+zip",obj:"model/obj",stl:"model/stl",fbx:"application/octet-stream",ttf:"font/ttf",otf:"font/otf",woff:"font/woff",woff2:"font/woff2",eot:"application/vnd.ms-fontobject",psd:"application/vnd.adobe.photoshop",ai:"application/postscript",eps:"application/postscript",ps:"application/postscript",sqlite:"application/x-sqlite3",db:"application/x-sqlite3",apk:"application/vnd.android.package-archive",ics:"text/calendar",vcf:"text/vcard",py:"text/x-python",rb:"text/x-ruby",go:"text/x-go",rs:"text/x-rust",typescript:"application/typescript",jsx:"text/jsx",tsx:"text/tsx",sql:"application/sql",toml:"application/toml",avif:"image/avif",jxl:"image/jxl",weba:"audio/webm",wasm:"application/wasm"});let c4=s4;const p4=class e extends r.BaseServiceBuilder{constructor(e){super(e)}getOperationalMode(){return this.hederaKit.operationalMode}static setSignerProvider(t){e.signerProvider=t}static setWalletInfoResolver(t){e.walletInfoResolver=t}static setStartInscriptionDelegate(t){e.startInscriptionDelegate=t}static setWalletExecutor(t){e.walletExecutor=t}static setPreferWalletOnly(t){e.preferWalletOnly=!!t}async getSigner(){const t=e.signerProvider;if(!t)return null;try{const e=t();return e&&"function"==typeof e.then?await e:e}catch{return null}}async getInscriptionSDK(e){if(this.inscriptionSDK)return this.inscriptionSDK;try{const e=this.hederaKit.client.network.toString().includes("mainnet")?"mainnet":"testnet",t=await this.getSigner(),n=this.hederaKit.signer.getAccountId().toString();if(t)this.inscriptionSDK=await c4.createWithAuth({type:"client",accountId:n,signer:t,network:e});else{const t=this.hederaKit.signer?.getOperatorPrivateKey();t&&(this.inscriptionSDK=await c4.createWithAuth({type:"server",accountId:n,privateKey:t.toStringRaw(),network:e}))}}catch(t){this.logger.warn("Failed to create InscriptionSDK with auth",t)}return this.inscriptionSDK||null}async inscribe(e,t){const n={accountId:this.hederaKit.signer.getAccountId().toString(),privateKey:this.hederaKit.signer?.getOperatorPrivateKey()?this.hederaKit.signer.getOperatorPrivateKey().toStringRaw():"",network:this.hederaKit.client.network.toString().includes("mainnet")?"mainnet":"testnet"};return await a.inscribe(e,n,t)}async inscribeWithSigner(e,t,n){return await a.inscribeWithSigner(e,t,n)}async inscribeAuto(t,i){const r=await this.getSigner();if(r)return this.inscribeWithSigner(t,r,i);const o=e.walletInfoResolver?await e.walletInfoResolver():null;if(e.preferWalletOnly&&!o){const e=new Error("Wallet unavailable: connect a wallet or switch to autonomous mode");throw e.code="wallet_unavailable",e}if(o&&e.startInscriptionDelegate&&e.walletExecutor){const r=o.accountId,s=o.network,c=i,p={holderId:r,metadata:c.metadata||{},tags:i.tags||[],mode:i.mode||"file"};void 0!==c.fileStandard&&(p.fileStandard=c.fileStandard),void 0!==c.chunkSize&&(p.chunkSize=c.chunkSize);let l={...p};switch(t.type){case"url":l={...p,file:{type:"url",url:t.url}};break;case"file":l={...p,file:{type:"path",path:t.path}};break;case"buffer":l={...p,file:{type:"base64",base64:n.Buffer.from(t.buffer).toString("base64"),fileName:t.fileName,mimeType:t.mimeType}}}"hashinal"===i.mode&&(l.metadataObject=c.metadata,l.creator=c.metadata?.creator||r,l.description=c.metadata?.description,"string"==typeof c.jsonFileURL&&c.jsonFileURL.length>0&&(l.jsonFileURL=c.jsonFileURL));const u=await e.startInscriptionDelegate(l,s),d=u;if(Boolean(d?.inscription)&&d?.confirmed){const e=u;return this.logger.info("inscription already completed, short circuiting",u),{quote:!1,confirmed:!0===e.confirmed,result:e.result,inscription:e.inscription}}const f=u;if(!f||!f.transactionBytes)throw new Error("Failed to start inscription (no transaction bytes)");const m=await e.walletExecutor(f.transactionBytes,s),h=m?.transactionId||"";if(!i.quoteOnly&&(i.waitForConfirmation??!0)){this.logger.debug("Will be retrieving inscription");const e=i.waitMaxAttempts??60,t=i.waitIntervalMs??5e3,n=await this.getInscriptionSDK(i);if(n){const i=await n.waitForInscription(h,e,t,!0),r=a.getTopicId(i)??f.topic_id,o={quote:!1,confirmed:!0,result:{jobId:f.tx_id||"",transactionId:h,topicId:r},inscription:i};return this.logger.debug("retrieved inscription",o,i),o}}return{quote:!1,confirmed:!1,result:{jobId:f.tx_id||"",transactionId:h,status:f.status,completed:f.completed},inscription:f.topic_id?{topic_id:f.topic_id}:void 0}}if(e.preferWalletOnly){const e=new Error("Wallet unavailable: connect a wallet or switch to autonomous mode");throw e.code="wallet_unavailable",e}return this.inscribe(t,i)}async retrieveInscription(e,t){const n=this.hederaKit.signer.getAccountId().toString(),i=this.hederaKit.signer?.getOperatorPrivateKey()?this.hederaKit.signer.getOperatorPrivateKey().toStringRaw():"";return await a.retrieveInscription(e,{...t,accountId:n,privateKey:i})}async close(){this.inscriptionSDK=void 0}};p4.preferWalletOnly=!1;let l4=p4;const u4=new class{constructor(){this.handlers=new Map}register(e,t){this.handlers.set(e,t)}has(e){return this.handlers.has(e)}async build(e,t,n){const i=this.handlers.get(e);return i?await i({hederaKit:t,request:n}):null}};async function d4(e,t){const a="mainnet"===(e.client.network.toString().includes("mainnet")?"mainnet":"testnet")?i.Client.forMainnet():i.Client.forTestnet(),r=e.signer.getAccountId().toString(),o=i.AccountId.fromString(r);if("function"==typeof t.setTransactionId&&t.setTransactionId(i.TransactionId.generate(o)),"function"==typeof t.setAutoRenewAccountId)try{t.setAutoRenewAccountId(r)}catch{}const s=await t.freezeWith(a);return{transactionBytes:n.Buffer.from(s.toBytes()).toString("base64")}}async function f4(e,t,a,r){const o="mainnet"===(e.client.network.toString().includes("mainnet")?"mainnet":"testnet")?i.Client.forMainnet():i.Client.forTestnet(),s=e.signer.getAccountId().toString(),c=i.AccountId.fromString(s),p=(new i.TopicMessageSubmitTransaction).setTopicId(i.TopicId.fromString(t)).setTransactionId(i.TransactionId.generate(c)).setMessage(a),l=await p.freezeWith(o);return{transactionBytes:n.Buffer.from(l.toBytes()).toString("base64")}}function m4(e){return"object"==typeof e&&null!==e}function h4(e,t){const n=e[t];return"string"==typeof n?n:void 0}function g4(e,t){const n=e[t];return"number"==typeof n&&Number.isFinite(n)?n:void 0}function v4(e,t){const n=e[t];return m4(n)?n:void 0}u4.register("hcs2.createRegistry",async({hederaKit:e,request:t})=>{const n=t?.options||{};let i;try{const t=e?.signer?.getOperatorPrivateKey?.();i=t?.publicKey}catch{}const r=a.buildHcs2CreateRegistryTx({registryType:n.registryType??a.HCS2RegistryType.INDEXED,ttl:n.ttl??86400,adminKey:n.adminKey,submitKey:n.submitKey,operatorPublicKey:i});return await d4(e,r)}),u4.register("hcs2.migrateRegistry",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs2.migrateRegistry: invalid request payload");const n=h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs2.migrateRegistry: registryTopicId is required");const i=v4(t,"options")||{},r=h4(i,"targetTopicId")||"",o=h4(i,"metadata"),s=h4(i,"memo"),c=a.buildHcs2MigrateTx({registryTopicId:n,targetTopicId:r,metadata:o,memo:s});return await d4(e,c)}),u4.register("hcs2.submitMessage",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs2.submitMessage: invalid request payload");const n=h4(t,"topicId")||h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs2.submitMessage: topicId is required");const i=t.payload,a="string"==typeof i?i:JSON.stringify(i??{});return await f4(e,n,a)}),u4.register("hcs2.registerEntry",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs2.registerEntry: invalid request payload");const n=h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs2.registerEntry: registryTopicId is required");const i=v4(t,"options")||{},r=h4(i,"targetTopicId")||"",o=h4(i,"metadata"),s=h4(i,"memo"),c=a.buildHcs2RegisterTx({registryTopicId:n,targetTopicId:r,metadata:o,memo:s});return await d4(e,c)}),u4.register("hcs2.updateEntry",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs2.updateEntry: invalid request payload");const n=h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs2.updateEntry: registryTopicId is required");const i=v4(t,"options")||{},r=h4(i,"targetTopicId")||"",o=h4(i,"uid")||"",s=h4(i,"metadata"),c=h4(i,"memo"),p=a.buildHcs2UpdateTx({registryTopicId:n,uid:o,targetTopicId:r,metadata:s,memo:c});return await d4(e,p)}),u4.register("hcs2.deleteEntry",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs2.deleteEntry: invalid request payload");const n=h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs2.deleteEntry: registryTopicId is required");const i=v4(t,"options")||{},r=h4(i,"uid")||"",o=h4(i,"memo"),s=a.buildHcs2DeleteTx({registryTopicId:n,uid:r,memo:o});return await d4(e,s)}),u4.register("hcs6.createRegistry",async({hederaKit:e,request:t})=>{const n=m4(t)?v4(t,"options"):void 0,i=n?g4(n,"ttl"):void 0;let r;try{const t=e?.signer?.getOperatorPrivateKey?.();r=t?.publicKey}catch{}const o=a.buildHcs6CreateRegistryTx({ttl:i??86400,operatorPublicKey:r});return await d4(e,o)}),u4.register("hcs6.registerEntry",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs6.registerEntry: invalid request payload");const n=h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs6.registerEntry: registryTopicId is required");const i=v4(t,"options")||{},r=h4(i,"targetTopicId")||"",o=h4(i,"memo"),s=a.buildHcs6RegisterEntryTx({registryTopicId:n,targetTopicId:r,memo:o});return await d4(e,s)}),u4.register("hcs6.submitMessage",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs6.submitMessage: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs6.submitMessage: topicId is required");const i=t.payload,a="string"==typeof i?i:JSON.stringify(i??{});return await f4(e,n,a)}),u4.register("sendMessage",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("sendMessage: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("sendMessage: topicId is required");const i=t.data,r=h4(t,"memo")||"",o=e.signer.getAccountId().toString(),s="string"==typeof i?i:JSON.stringify(i??{}),c=a.buildHcs10SendMessageTx({connectionTopicId:n,operatorId:o,data:s,memo:r});return await d4(e,c)}),u4.register("submitConnectionRequest",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("submitConnectionRequest: invalid request payload");const n=h4(t,"inboundTopicId")||"";if(!n)throw new Error("submitConnectionRequest: inboundTopicId is required");const i=h4(t,"memo")||"",r=e.signer.getAccountId().toString(),o=a.buildHcs10SubmitConnectionRequestTx({inboundTopicId:n,operatorId:r,memo:i});return await d4(e,o)}),u4.register("hcs20.deploy",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs20.deploy: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs20.deploy: topicId is required");const i=h4(t,"name")||"",r=h4(t,"tick")||"",o=h4(t,"max")||"",s=h4(t,"lim"),c=h4(t,"metadata"),p=h4(t,"memo"),l=a.buildHcs20DeployTx({topicId:n,name:i,tick:r,max:o,lim:s,metadata:c,memo:p});return await d4(e,l)}),u4.register("hcs20.mint",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs20.mint: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs20.mint: topicId is required");const i=h4(t,"tick")||"",r=h4(t,"amt")||"",o=h4(t,"to")||"",s=h4(t,"memo"),c=a.buildHcs20MintTx({topicId:n,tick:i,amt:r,to:o,memo:s});return await d4(e,c)}),u4.register("hcs20.transfer",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs20.transfer: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs20.transfer: topicId is required");const i=h4(t,"tick")||"",r=h4(t,"amt")||"",o=h4(t,"from")||"",s=h4(t,"to")||"",c=h4(t,"memo"),p=a.buildHcs20TransferTx({topicId:n,tick:i,amt:r,from:o,to:s,memo:c});return await d4(e,p)}),u4.register("hcs20.burn",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs20.burn: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs20.burn: topicId is required");const i=h4(t,"tick")||"",r=h4(t,"amt")||"",o=h4(t,"from")||"",s=h4(t,"memo"),c=a.buildHcs20BurnTx({topicId:n,tick:i,amt:r,from:o,memo:s});return await d4(e,c)}),u4.register("hcs20.register",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs20.register: invalid request payload");const n=h4(t,"registryTopicId")||"";if(!n)throw new Error("hcs20.register: registryTopicId is required");const i=h4(t,"topicId")||"",r=h4(t,"name")||"",o=t.isPrivate,s="boolean"==typeof o&&o,c=h4(t,"metadata"),p=h4(t,"memo"),l=a.buildHcs20RegisterTx({registryTopicId:n,name:r,topicId:i,isPrivate:s,metadata:c,memo:p});return await d4(e,l)}),u4.register("hcs12.createRegistry",async({hederaKit:e,request:t})=>{const n=m4(t)?v4(t,"options"):void 0,i=(n?g4(n,"ttl"):void 0)??60,r=n&&h4(n,"registry")||"hashlinks";let o;try{const t=e?.signer?.getOperatorPrivateKey?.();o=t?.publicKey}catch{}const s=a.buildHcs12CreateRegistryTopicTx({registry:r,ttl:i,operatorPublicKey:o});return await d4(e,s)}),u4.register("hcs12.submitMessage",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs12.submitMessage: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs12.submitMessage: topicId is required");const i=t.payload,r=a.buildHcs12SubmitMessageTx({topicId:n,payload:i});return await d4(e,r)}),u4.register("hcs12.registerAssembly",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs12.registerAssembly: invalid request payload");const n=h4(t,"assemblyTopicId")||"";if(!n)throw new Error("hcs12.registerAssembly: assemblyTopicId is required");const i=v4(t,"registration")||{},r=a.buildHcs12RegisterAssemblyTx({assemblyTopicId:n,registration:i});return await d4(e,r)}),u4.register("hcs12.addBlock",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs12.addBlock: invalid request payload");const n=h4(t,"assemblyTopicId")||"";if(!n)throw new Error("hcs12.addBlock: assemblyTopicId is required");const i=v4(t,"operation")||{},r=a.buildHcs12AddBlockToAssemblyTx({assemblyTopicId:n,operation:i});return await d4(e,r)}),u4.register("hcs12.addAction",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs12.addAction: invalid request payload");const n=h4(t,"assemblyTopicId")||"";if(!n)throw new Error("hcs12.addAction: assemblyTopicId is required");const i=v4(t,"operation")||{},r=a.buildHcs12AddActionToAssemblyTx({assemblyTopicId:n,operation:i});return await d4(e,r)}),u4.register("hcs12.updateAssembly",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs12.updateAssembly: invalid request payload");const n=h4(t,"assemblyTopicId")||"";if(!n)throw new Error("hcs12.updateAssembly: assemblyTopicId is required");const i=v4(t,"operation")||{},r=a.buildHcs12UpdateAssemblyTx({assemblyTopicId:n,operation:i});return await d4(e,r)}),u4.register("hcs7.submitMessage",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs7.submitMessage: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs7.submitMessage: topicId is required");const i=v4(t,"message")||{},r=a.buildHcs7SubmitMessageTx({topicId:n,message:i});return await d4(e,r)}),u4.register("hcs7.evm",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs7.evm: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs7.evm: topicId is required");const i=v4(t,"config")||{},r=a.buildHcs7EvmMessageTx({topicId:n,config:i});return await d4(e,r)}),u4.register("hcs7.wasm",async({hederaKit:e,request:t})=>{if(!m4(t))throw new Error("hcs7.wasm: invalid request payload");const n=h4(t,"topicId")||"";if(!n)throw new Error("hcs7.wasm: topicId is required");const i=v4(t,"config")||{},r=a.buildHcs7WasmMessageTx({topicId:n,config:i});return await d4(e,r)});const y4=Object.freeze(Object.defineProperty({__proto__:null,ByteBuildRegistry:u4},Symbol.toStringTag,{value:"Module"}));var b4="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:void 0!==jS?jS:"undefined"!=typeof self?self:{};function x4(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var w4,_4={};function k4(){return w4||(w4=1,function(e){Object.defineProperties(e,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});for(var t={},n={byteLength:function(e){var t=c(e),n=t[0],i=t[1];return 3*(n+i)/4-i},toByteArray:function(e){var t,n,i=c(e),o=i[0],s=i[1],p=new r(function(e,t,n){return 3*(t+n)/4-n}(0,o,s)),l=0,u=s>0?o-4:o;for(n=0;n<u;n+=4)t=a[e.charCodeAt(n)]<<18|a[e.charCodeAt(n+1)]<<12|a[e.charCodeAt(n+2)]<<6|a[e.charCodeAt(n+3)],p[l++]=t>>16&255,p[l++]=t>>8&255,p[l++]=255&t;2===s&&(t=a[e.charCodeAt(n)]<<2|a[e.charCodeAt(n+1)]>>4,p[l++]=255&t);1===s&&(t=a[e.charCodeAt(n)]<<10|a[e.charCodeAt(n+1)]<<4|a[e.charCodeAt(n+2)]>>2,p[l++]=t>>8&255,p[l++]=255&t);return p},fromByteArray:function(e){for(var t,n=e.length,a=n%3,r=[],o=16383,s=0,c=n-a;s<c;s+=o)r.push(l(e,s,s+o>c?c:s+o));1===a?(t=e[n-1],r.push(i[t>>2]+i[t<<4&63]+"==")):2===a&&(t=(e[n-2]<<8)+e[n-1],r.push(i[t>>10]+i[t>>4&63]+i[t<<2&63]+"="));return r.join("")}},i=[],a=[],r="undefined"!=typeof Uint8Array?Uint8Array:Array,o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",s=0;s<64;++s)i[s]=o[s],a[o.charCodeAt(s)]=s;function c(e){var t=e.length;if(t%4>0)throw new Error("Invalid string. Length must be a multiple of 4");var n=e.indexOf("=");return-1===n&&(n=t),[n,n===t?0:4-n%4]}function p(e){return i[e>>18&63]+i[e>>12&63]+i[e>>6&63]+i[63&e]}function l(e,t,n){for(var i,a=[],r=t;r<n;r+=3)i=(e[r]<<16&16711680)+(e[r+1]<<8&65280)+(255&e[r+2]),a.push(p(i));return a.join("")}a["-".charCodeAt(0)]=62,a["_".charCodeAt(0)]=63;var u={
|
|
158
158
|
/*! ieee754. BSD-3-Clause License. Feross Aboukhadijeh <https://feross.org/opensource> */
|
|
159
159
|
read:function(e,t,n,i,a){var r,o,s=8*a-i-1,c=(1<<s)-1,p=c>>1,l=-7,u=n?a-1:0,d=n?-1:1,f=e[t+u];for(u+=d,r=f&(1<<-l)-1,f>>=-l,l+=s;l>0;r=256*r+e[t+u],u+=d,l-=8);for(o=r&(1<<-l)-1,r>>=-l,l+=i;l>0;o=256*o+e[t+u],u+=d,l-=8);if(0===r)r=1-p;else{if(r===c)return o?NaN:1/0*(f?-1:1);o+=Math.pow(2,i),r-=p}return(f?-1:1)*o*Math.pow(2,r-i)},write:function(e,t,n,i,a,r){var o,s,c,p=8*r-a-1,l=(1<<p)-1,u=l>>1,d=23===a?Math.pow(2,-24)-Math.pow(2,-77):0,f=i?0:r-1,m=i?1:-1,h=t<0||0===t&&1/t<0?1:0;for(t=Math.abs(t),isNaN(t)||t===1/0?(s=isNaN(t)?1:0,o=l):(o=Math.floor(Math.log(t)/Math.LN2),t*(c=Math.pow(2,-o))<1&&(o--,c*=2),(t+=o+u>=1?d/c:d*Math.pow(2,1-u))*c>=2&&(o++,c/=2),o+u>=l?(s=0,o=l):o+u>=1?(s=(t*c-1)*Math.pow(2,a),o+=u):(s=t*Math.pow(2,u-1)*Math.pow(2,a),o=0));a>=8;e[n+f]=255&s,f+=m,s/=256,a-=8);for(o=o<<a|s,p+=a;p>0;e[n+f]=255&o,f+=m,o/=256,p-=8);e[n+f-m]|=128*h}};
|
|
160
160
|
/*!
|