UNPKG

@scandit/web-barcode-link

Version:

The Scandit Web Barcode Link package

8 lines 100 kB
(function(O,x){typeof exports=="object"&&typeof module<"u"?x(exports):typeof define=="function"&&define.amd?define(["exports"],x):(O=typeof globalThis<"u"?globalThis:O||self,x(O.ScanditBarcodeLink={}))})(this,function(O){"use strict";var Br=Object.defineProperty;var Rr=(O,x,$)=>x in O?Br(O,x,{enumerable:!0,configurable:!0,writable:!0,value:$}):O[x]=$;var R=(O,x,$)=>Rr(O,typeof x!="symbol"?x+"":x,$);class x{constructor(e){this.barcodeLink=e}getConfiguration(){return{...this.barcodeLink.configuration}}onCancel(){this.barcodeLink.dispose(),this.barcodeLink.listeners.forEach(e=>{var t;(t=e.onCancel)==null||t.call(e)})}onCapture(e,t){this.barcodeLink.listeners.forEach(i=>{var r;(r=i.onCapture)==null||r.call(i,e,t)})}onConnectionStateChanged(e){this.barcodeLink.listeners.forEach(t=>{var i;(i=t.onConnectionStateChanged)==null||i.call(t,e)})}}var $=(n=>(n.Unique="unique",n.Count="count",n))($||{}),Je=(n=>(n.SingleScanning="singleScanning",n.ContinuousScanning="continuousScanning",n.SingleListBuilding="singleListBuilding",n.ContinuousListBuilding="continuousListBuilding",n))(Je||{}),j=(n=>(n.Express="express",n.Web="web",n))(j||{});class je{constructor(e){R(this,"configuration",{barcodeLinkMode:Je.SingleScanning,licenseKey:"",listBehavior:$.Unique,symbologies:{}});R(this,"flow");R(this,"flowDelegate",new x(this));R(this,"listeners",new Set);this.configuration.licenseKey=e}static forLicenseKey(e){return new je(e)}setSymbologies(e){return this.configuration.symbologies=e,this}setBarcodeLinkMode(e){return this.configuration.barcodeLinkMode=e,this}setBarcodeRegexValidation(e){return this.configuration.barcodeRegexValidation=String(e).slice(1,-1),this}setBarcodeTransformations(e){return this.configuration.barcodeTransformations=e,this}setPlatform(e){switch(e){case j.Express:return delete this.configuration.platform,this;case j.Web:return this.configuration.platform=e,this}}setListBehavior(e){return this.configuration.listBehavior=e,this}addListener(e){return this.listeners.add(e),this}removeListener(e){return this.listeners.delete(e),this}async initialize(e){return this.flow=e,this.flow.setDelegate(this.flowDelegate),await this.flow.initialize()}dispose(){var e;(e=this.flow)==null||e.dispose()}}var te=(n=>(n.MainDeviceReconnected="mainDeviceReconnected",n.MainDeviceDisconnected="mainDeviceDisconnected",n.MainDeviceConnectionFailed="mainDeviceConnectionFailed",n.RemoteDeviceConnected="remoteDeviceConnected",n.RemoteDeviceDisconnected="remoteDeviceDisconnected",n))(te||{});const Rn={SCANDIT_BARCODE_LINK_URL:"https://barcode-link.scandit.com",SCANDIT_BARCODE_LINK_WS_URL:"https://ws.barcode-link.scandit.com"};function Ge(n){const e=n||Rn;return{production:{barcodeLinkUrl:e.SCANDIT_BARCODE_LINK_URL||"https://barcode-link.scandit.com",barcodeLinkWsUrl:e.SCANDIT_BARCODE_LINK_WS_URL||"https://barcode-link-ws.scandit.com"},staging:{barcodeLinkUrl:e.SCANDIT_BARCODE_LINK_STAGING_URL||"https://barcode-link.staging.scandit.io",barcodeLinkWsUrl:e.SCANDIT_BARCODE_LINK_WS_STAGING_URL||"https://barcode-link-ws.staging.scandit.io"},development:{barcodeLinkUrl:e.SCANDIT_BARCODE_LINK_LOCAL_URL||"https://barcode-link.dev.localhost",barcodeLinkWsUrl:e.SCANDIT_BARCODE_LINK_WS_LOCAL_URL||"https://ws.barcode-link.dev.localhost"}}}class le{static setEnvironmentVars(e){this.envMap=Ge(e)}static resetEnvironmentVars(){this.envMap=Ge()}static getCurrentEnvironment(){if(typeof window>"u")return"production";const e=new URLSearchParams(window.location.search).get("__barcodeLinkForceEnvironment");return e&&this.envMap[e]?(console.warn(`Using environment from query parameter: ${e}`),e):"production"}static get barcodeLinkUrl(){return this.envMap[this.getCurrentEnvironment()].barcodeLinkUrl}static get barcodeLinkWsUrl(){return this.envMap[this.getCurrentEnvironment()].barcodeLinkWsUrl}}R(le,"envMap",Ge());var Nn=typeof globalThis<"u"?globalThis:typeof window<"u"?window:typeof global<"u"?global:typeof self<"u"?self:{},ue={},Ln=function(){return typeof Promise=="function"&&Promise.prototype&&Promise.prototype.then},Ot={},U={};let $e;const On=[0,26,44,70,100,134,172,196,242,292,346,404,466,532,581,655,733,815,901,991,1085,1156,1258,1364,1474,1588,1706,1828,1921,2051,2185,2323,2465,2611,2761,2876,3034,3196,3362,3532,3706];U.getSymbolSize=function(e){if(!e)throw new Error('"version" cannot be null or undefined');if(e<1||e>40)throw new Error('"version" should be in range from 1 to 40');return e*4+17},U.getSymbolTotalCodewords=function(e){return On[e]},U.getBCHDigit=function(n){let e=0;for(;n!==0;)e++,n>>>=1;return e},U.setToSJISFunction=function(e){if(typeof e!="function")throw new Error('"toSJISFunc" is not a valid function.');$e=e},U.isKanjiModeEnabled=function(){return typeof $e<"u"},U.toSJIS=function(e){return $e(e)};var Ce={};(function(n){n.L={bit:1},n.M={bit:0},n.Q={bit:3},n.H={bit:2};function e(t){if(typeof t!="string")throw new Error("Param is not a string");switch(t.toLowerCase()){case"l":case"low":return n.L;case"m":case"medium":return n.M;case"q":case"quartile":return n.Q;case"h":case"high":return n.H;default:throw new Error("Unknown EC Level: "+t)}}n.isValid=function(i){return i&&typeof i.bit<"u"&&i.bit>=0&&i.bit<4},n.from=function(i,r){if(n.isValid(i))return i;try{return e(i)}catch{return r}}})(Ce);function Mt(){this.buffer=[],this.length=0}Mt.prototype={get:function(n){const e=Math.floor(n/8);return(this.buffer[e]>>>7-n%8&1)===1},put:function(n,e){for(let t=0;t<e;t++)this.putBit((n>>>e-t-1&1)===1)},getLengthInBits:function(){return this.length},putBit:function(n){const e=Math.floor(this.length/8);this.buffer.length<=e&&this.buffer.push(0),n&&(this.buffer[e]|=128>>>this.length%8),this.length++}};var Mn=Mt;function de(n){if(!n||n<1)throw new Error("BitMatrix size must be defined and greater than 0");this.size=n,this.data=new Uint8Array(n*n),this.reservedBit=new Uint8Array(n*n)}de.prototype.set=function(n,e,t,i){const r=n*this.size+e;this.data[r]=t,i&&(this.reservedBit[r]=!0)},de.prototype.get=function(n,e){return this.data[n*this.size+e]},de.prototype.xor=function(n,e,t){this.data[n*this.size+e]^=t},de.prototype.isReserved=function(n,e){return this.reservedBit[n*this.size+e]};var In=de,It={};(function(n){const e=U.getSymbolSize;n.getRowColCoords=function(i){if(i===1)return[];const r=Math.floor(i/7)+2,s=e(i),o=s===145?26:Math.ceil((s-13)/(2*r-2))*2,a=[s-7];for(let c=1;c<r-1;c++)a[c]=a[c-1]-o;return a.push(6),a.reverse()},n.getPositions=function(i){const r=[],s=n.getRowColCoords(i),o=s.length;for(let a=0;a<o;a++)for(let c=0;c<o;c++)a===0&&c===0||a===0&&c===o-1||a===o-1&&c===0||r.push([s[a],s[c]]);return r}})(It);var Pt={};const Pn=U.getSymbolSize,Dt=7;Pt.getPositions=function(e){const t=Pn(e);return[[0,0],[t-Dt,0],[0,t-Dt]]};var xt={};(function(n){n.Patterns={PATTERN000:0,PATTERN001:1,PATTERN010:2,PATTERN011:3,PATTERN100:4,PATTERN101:5,PATTERN110:6,PATTERN111:7};const e={N1:3,N2:3,N3:40,N4:10};n.isValid=function(r){return r!=null&&r!==""&&!isNaN(r)&&r>=0&&r<=7},n.from=function(r){return n.isValid(r)?parseInt(r,10):void 0},n.getPenaltyN1=function(r){const s=r.size;let o=0,a=0,c=0,w=null,m=null;for(let k=0;k<s;k++){a=c=0,w=m=null;for(let h=0;h<s;h++){let d=r.get(k,h);d===w?a++:(a>=5&&(o+=e.N1+(a-5)),w=d,a=1),d=r.get(h,k),d===m?c++:(c>=5&&(o+=e.N1+(c-5)),m=d,c=1)}a>=5&&(o+=e.N1+(a-5)),c>=5&&(o+=e.N1+(c-5))}return o},n.getPenaltyN2=function(r){const s=r.size;let o=0;for(let a=0;a<s-1;a++)for(let c=0;c<s-1;c++){const w=r.get(a,c)+r.get(a,c+1)+r.get(a+1,c)+r.get(a+1,c+1);(w===4||w===0)&&o++}return o*e.N2},n.getPenaltyN3=function(r){const s=r.size;let o=0,a=0,c=0;for(let w=0;w<s;w++){a=c=0;for(let m=0;m<s;m++)a=a<<1&2047|r.get(w,m),m>=10&&(a===1488||a===93)&&o++,c=c<<1&2047|r.get(m,w),m>=10&&(c===1488||c===93)&&o++}return o*e.N3},n.getPenaltyN4=function(r){let s=0;const o=r.data.length;for(let c=0;c<o;c++)s+=r.data[c];return Math.abs(Math.ceil(s*100/o/5)-10)*e.N4};function t(i,r,s){switch(i){case n.Patterns.PATTERN000:return(r+s)%2===0;case n.Patterns.PATTERN001:return r%2===0;case n.Patterns.PATTERN010:return s%3===0;case n.Patterns.PATTERN011:return(r+s)%3===0;case n.Patterns.PATTERN100:return(Math.floor(r/2)+Math.floor(s/3))%2===0;case n.Patterns.PATTERN101:return r*s%2+r*s%3===0;case n.Patterns.PATTERN110:return(r*s%2+r*s%3)%2===0;case n.Patterns.PATTERN111:return(r*s%3+(r+s)%2)%2===0;default:throw new Error("bad maskPattern:"+i)}}n.applyMask=function(r,s){const o=s.size;for(let a=0;a<o;a++)for(let c=0;c<o;c++)s.isReserved(c,a)||s.xor(c,a,t(r,c,a))},n.getBestMask=function(r,s){const o=Object.keys(n.Patterns).length;let a=0,c=1/0;for(let w=0;w<o;w++){s(w),n.applyMask(w,r);const m=n.getPenaltyN1(r)+n.getPenaltyN2(r)+n.getPenaltyN3(r)+n.getPenaltyN4(r);n.applyMask(w,r),m<c&&(c=m,a=w)}return a}})(xt);var ke={};const Q=Ce,Ae=[1,1,1,1,1,1,1,1,1,1,2,2,1,2,2,4,1,2,4,4,2,4,4,4,2,4,6,5,2,4,6,6,2,5,8,8,4,5,8,8,4,5,8,11,4,8,10,11,4,9,12,16,4,9,16,16,6,10,12,18,6,10,17,16,6,11,16,19,6,13,18,21,7,14,21,25,8,16,20,25,8,17,23,25,9,17,23,34,9,18,25,30,10,20,27,32,12,21,29,35,12,23,34,37,12,25,34,40,13,26,35,42,14,28,38,45,15,29,40,48,16,31,43,51,17,33,45,54,18,35,48,57,19,37,51,60,19,38,53,63,20,40,56,66,21,43,59,70,22,45,62,74,24,47,65,77,25,49,68,81],Te=[7,10,13,17,10,16,22,28,15,26,36,44,20,36,52,64,26,48,72,88,36,64,96,112,40,72,108,130,48,88,132,156,60,110,160,192,72,130,192,224,80,150,224,264,96,176,260,308,104,198,288,352,120,216,320,384,132,240,360,432,144,280,408,480,168,308,448,532,180,338,504,588,196,364,546,650,224,416,600,700,224,442,644,750,252,476,690,816,270,504,750,900,300,560,810,960,312,588,870,1050,336,644,952,1110,360,700,1020,1200,390,728,1050,1260,420,784,1140,1350,450,812,1200,1440,480,868,1290,1530,510,924,1350,1620,540,980,1440,1710,570,1036,1530,1800,570,1064,1590,1890,600,1120,1680,1980,630,1204,1770,2100,660,1260,1860,2220,720,1316,1950,2310,750,1372,2040,2430];ke.getBlocksCount=function(e,t){switch(t){case Q.L:return Ae[(e-1)*4+0];case Q.M:return Ae[(e-1)*4+1];case Q.Q:return Ae[(e-1)*4+2];case Q.H:return Ae[(e-1)*4+3];default:return}},ke.getTotalCodewordsCount=function(e,t){switch(t){case Q.L:return Te[(e-1)*4+0];case Q.M:return Te[(e-1)*4+1];case Q.Q:return Te[(e-1)*4+2];case Q.H:return Te[(e-1)*4+3];default:return}};var Ut={},Se={};const fe=new Uint8Array(512),Be=new Uint8Array(256);(function(){let e=1;for(let t=0;t<255;t++)fe[t]=e,Be[e]=t,e<<=1,e&256&&(e^=285);for(let t=255;t<512;t++)fe[t]=fe[t-255]})(),Se.log=function(e){if(e<1)throw new Error("log("+e+")");return Be[e]},Se.exp=function(e){return fe[e]},Se.mul=function(e,t){return e===0||t===0?0:fe[Be[e]+Be[t]]},function(n){const e=Se;n.mul=function(i,r){const s=new Uint8Array(i.length+r.length-1);for(let o=0;o<i.length;o++)for(let a=0;a<r.length;a++)s[o+a]^=e.mul(i[o],r[a]);return s},n.mod=function(i,r){let s=new Uint8Array(i);for(;s.length-r.length>=0;){const o=s[0];for(let c=0;c<r.length;c++)s[c]^=e.mul(r[c],o);let a=0;for(;a<s.length&&s[a]===0;)a++;s=s.slice(a)}return s},n.generateECPolynomial=function(i){let r=new Uint8Array([1]);for(let s=0;s<i;s++)r=n.mul(r,new Uint8Array([1,e.exp(s)]));return r}}(Ut);const Ft=Ut;function Qe(n){this.genPoly=void 0,this.degree=n,this.degree&&this.initialize(this.degree)}Qe.prototype.initialize=function(e){this.degree=e,this.genPoly=Ft.generateECPolynomial(this.degree)},Qe.prototype.encode=function(e){if(!this.genPoly)throw new Error("Encoder not initialized");const t=new Uint8Array(e.length+this.degree);t.set(e);const i=Ft.mod(t,this.genPoly),r=this.degree-i.length;if(r>0){const s=new Uint8Array(this.degree);return s.set(i,r),s}return i};var Dn=Qe,qt={},X={},Xe={};Xe.isValid=function(e){return!isNaN(e)&&e>=1&&e<=40};var K={};const Vt="[0-9]+",xn="[A-Z $%*+\\-./:]+";let pe="(?:[u3000-u303F]|[u3040-u309F]|[u30A0-u30FF]|[uFF00-uFFEF]|[u4E00-u9FAF]|[u2605-u2606]|[u2190-u2195]|u203B|[u2010u2015u2018u2019u2025u2026u201Cu201Du2225u2260]|[u0391-u0451]|[u00A7u00A8u00B1u00B4u00D7u00F7])+";pe=pe.replace(/u/g,"\\u");const Un="(?:(?![A-Z0-9 $%*+\\-./:]|"+pe+`)(?:.|[\r ]))+`;K.KANJI=new RegExp(pe,"g"),K.BYTE_KANJI=new RegExp("[^A-Z0-9 $%*+\\-./:]+","g"),K.BYTE=new RegExp(Un,"g"),K.NUMERIC=new RegExp(Vt,"g"),K.ALPHANUMERIC=new RegExp(xn,"g");const Fn=new RegExp("^"+pe+"$"),qn=new RegExp("^"+Vt+"$"),Vn=new RegExp("^[A-Z0-9 $%*+\\-./:]+$");K.testKanji=function(e){return Fn.test(e)},K.testNumeric=function(e){return qn.test(e)},K.testAlphanumeric=function(e){return Vn.test(e)},function(n){const e=Xe,t=K;n.NUMERIC={id:"Numeric",bit:1,ccBits:[10,12,14]},n.ALPHANUMERIC={id:"Alphanumeric",bit:2,ccBits:[9,11,13]},n.BYTE={id:"Byte",bit:4,ccBits:[8,16,16]},n.KANJI={id:"Kanji",bit:8,ccBits:[8,10,12]},n.MIXED={bit:-1},n.getCharCountIndicator=function(s,o){if(!s.ccBits)throw new Error("Invalid mode: "+s);if(!e.isValid(o))throw new Error("Invalid version: "+o);return o>=1&&o<10?s.ccBits[0]:o<27?s.ccBits[1]:s.ccBits[2]},n.getBestModeForData=function(s){return t.testNumeric(s)?n.NUMERIC:t.testAlphanumeric(s)?n.ALPHANUMERIC:t.testKanji(s)?n.KANJI:n.BYTE},n.toString=function(s){if(s&&s.id)return s.id;throw new Error("Invalid mode")},n.isValid=function(s){return s&&s.bit&&s.ccBits};function i(r){if(typeof r!="string")throw new Error("Param is not a string");switch(r.toLowerCase()){case"numeric":return n.NUMERIC;case"alphanumeric":return n.ALPHANUMERIC;case"kanji":return n.KANJI;case"byte":return n.BYTE;default:throw new Error("Unknown mode: "+r)}}n.from=function(s,o){if(n.isValid(s))return s;try{return i(s)}catch{return o}}}(X),function(n){const e=U,t=ke,i=Ce,r=X,s=Xe,o=7973,a=e.getBCHDigit(o);function c(h,d,l){for(let u=1;u<=40;u++)if(d<=n.getCapacity(u,l,h))return u}function w(h,d){return r.getCharCountIndicator(h,d)+4}function m(h,d){let l=0;return h.forEach(function(u){const f=w(u.mode,d);l+=f+u.getBitsLength()}),l}function k(h,d){for(let l=1;l<=40;l++)if(m(h,l)<=n.getCapacity(l,d,r.MIXED))return l}n.from=function(d,l){return s.isValid(d)?parseInt(d,10):l},n.getCapacity=function(d,l,u){if(!s.isValid(d))throw new Error("Invalid QR Code version");typeof u>"u"&&(u=r.BYTE);const f=e.getSymbolTotalCodewords(d),b=t.getTotalCodewordsCount(d,l),E=(f-b)*8;if(u===r.MIXED)return E;const p=E-w(u,d);switch(u){case r.NUMERIC:return Math.floor(p/10*3);case r.ALPHANUMERIC:return Math.floor(p/11*2);case r.KANJI:return Math.floor(p/13);case r.BYTE:default:return Math.floor(p/8)}},n.getBestVersionForData=function(d,l){let u;const f=i.from(l,i.M);if(Array.isArray(d)){if(d.length>1)return k(d,f);if(d.length===0)return 1;u=d[0]}else u=d;return c(u.mode,u.getLength(),f)},n.getEncodedBits=function(d){if(!s.isValid(d)||d<7)throw new Error("Invalid QR Code version");let l=d<<12;for(;e.getBCHDigit(l)-a>=0;)l^=o<<e.getBCHDigit(l)-a;return d<<12|l}}(qt);var zt={};const Ze=U,Kt=1335,zn=21522,Ht=Ze.getBCHDigit(Kt);zt.getEncodedBits=function(e,t){const i=e.bit<<3|t;let r=i<<10;for(;Ze.getBCHDigit(r)-Ht>=0;)r^=Kt<<Ze.getBCHDigit(r)-Ht;return(i<<10|r)^zn};var Wt={};const Kn=X;function ne(n){this.mode=Kn.NUMERIC,this.data=n.toString()}ne.getBitsLength=function(e){return 10*Math.floor(e/3)+(e%3?e%3*3+1:0)},ne.prototype.getLength=function(){return this.data.length},ne.prototype.getBitsLength=function(){return ne.getBitsLength(this.data.length)},ne.prototype.write=function(e){let t,i,r;for(t=0;t+3<=this.data.length;t+=3)i=this.data.substr(t,3),r=parseInt(i,10),e.put(r,10);const s=this.data.length-t;s>0&&(i=this.data.substr(t),r=parseInt(i,10),e.put(r,s*3+1))};var Hn=ne;const Wn=X,et=["0","1","2","3","4","5","6","7","8","9","A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"," ","$","%","*","+","-",".","/",":"];function ie(n){this.mode=Wn.ALPHANUMERIC,this.data=n}ie.getBitsLength=function(e){return 11*Math.floor(e/2)+6*(e%2)},ie.prototype.getLength=function(){return this.data.length},ie.prototype.getBitsLength=function(){return ie.getBitsLength(this.data.length)},ie.prototype.write=function(e){let t;for(t=0;t+2<=this.data.length;t+=2){let i=et.indexOf(this.data[t])*45;i+=et.indexOf(this.data[t+1]),e.put(i,11)}this.data.length%2&&e.put(et.indexOf(this.data[t]),6)};var Yn=ie;const Jn=X;function re(n){this.mode=Jn.BYTE,typeof n=="string"?this.data=new TextEncoder().encode(n):this.data=new Uint8Array(n)}re.getBitsLength=function(e){return e*8},re.prototype.getLength=function(){return this.data.length},re.prototype.getBitsLength=function(){return re.getBitsLength(this.data.length)},re.prototype.write=function(n){for(let e=0,t=this.data.length;e<t;e++)n.put(this.data[e],8)};var jn=re;const Gn=X,$n=U;function se(n){this.mode=Gn.KANJI,this.data=n}se.getBitsLength=function(e){return e*13},se.prototype.getLength=function(){return this.data.length},se.prototype.getBitsLength=function(){return se.getBitsLength(this.data.length)},se.prototype.write=function(n){let e;for(e=0;e<this.data.length;e++){let t=$n.toSJIS(this.data[e]);if(t>=33088&&t<=40956)t-=33088;else if(t>=57408&&t<=60351)t-=49472;else throw new Error("Invalid SJIS character: "+this.data[e]+` Make sure your charset is UTF-8`);t=(t>>>8&255)*192+(t&255),n.put(t,13)}};var Qn=se,Yt={exports:{}};(function(n){var e={single_source_shortest_paths:function(t,i,r){var s={},o={};o[i]=0;var a=e.PriorityQueue.make();a.push(i,0);for(var c,w,m,k,h,d,l,u,f;!a.empty();){c=a.pop(),w=c.value,k=c.cost,h=t[w]||{};for(m in h)h.hasOwnProperty(m)&&(d=h[m],l=k+d,u=o[m],f=typeof o[m]>"u",(f||u>l)&&(o[m]=l,a.push(m,l),s[m]=w))}if(typeof r<"u"&&typeof o[r]>"u"){var b=["Could not find a path from ",i," to ",r,"."].join("");throw new Error(b)}return s},extract_shortest_path_from_predecessor_list:function(t,i){for(var r=[],s=i;s;)r.push(s),t[s],s=t[s];return r.reverse(),r},find_path:function(t,i,r){var s=e.single_source_shortest_paths(t,i,r);return e.extract_shortest_path_from_predecessor_list(s,r)},PriorityQueue:{make:function(t){var i=e.PriorityQueue,r={},s;t=t||{};for(s in i)i.hasOwnProperty(s)&&(r[s]=i[s]);return r.queue=[],r.sorter=t.sorter||i.default_sorter,r},default_sorter:function(t,i){return t.cost-i.cost},push:function(t,i){var r={value:t,cost:i};this.queue.push(r),this.queue.sort(this.sorter)},pop:function(){return this.queue.shift()},empty:function(){return this.queue.length===0}}};n.exports=e})(Yt);var Xn=Yt.exports;(function(n){const e=X,t=Hn,i=Yn,r=jn,s=Qn,o=K,a=U,c=Xn;function w(b){return unescape(encodeURIComponent(b)).length}function m(b,E,p){const g=[];let C;for(;(C=b.exec(p))!==null;)g.push({data:C[0],index:C.index,mode:E,length:C[0].length});return g}function k(b){const E=m(o.NUMERIC,e.NUMERIC,b),p=m(o.ALPHANUMERIC,e.ALPHANUMERIC,b);let g,C;return a.isKanjiModeEnabled()?(g=m(o.BYTE,e.BYTE,b),C=m(o.KANJI,e.KANJI,b)):(g=m(o.BYTE_KANJI,e.BYTE,b),C=[]),E.concat(p,g,C).sort(function(L,P){return L.index-P.index}).map(function(L){return{data:L.data,mode:L.mode,length:L.length}})}function h(b,E){switch(E){case e.NUMERIC:return t.getBitsLength(b);case e.ALPHANUMERIC:return i.getBitsLength(b);case e.KANJI:return s.getBitsLength(b);case e.BYTE:return r.getBitsLength(b)}}function d(b){return b.reduce(function(E,p){const g=E.length-1>=0?E[E.length-1]:null;return g&&g.mode===p.mode?(E[E.length-1].data+=p.data,E):(E.push(p),E)},[])}function l(b){const E=[];for(let p=0;p<b.length;p++){const g=b[p];switch(g.mode){case e.NUMERIC:E.push([g,{data:g.data,mode:e.ALPHANUMERIC,length:g.length},{data:g.data,mode:e.BYTE,length:g.length}]);break;case e.ALPHANUMERIC:E.push([g,{data:g.data,mode:e.BYTE,length:g.length}]);break;case e.KANJI:E.push([g,{data:g.data,mode:e.BYTE,length:w(g.data)}]);break;case e.BYTE:E.push([{data:g.data,mode:e.BYTE,length:w(g.data)}])}}return E}function u(b,E){const p={},g={start:{}};let C=["start"];for(let T=0;T<b.length;T++){const L=b[T],P=[];for(let F=0;F<L.length;F++){const I=L[F],ee=""+T+F;P.push(ee),p[ee]={node:I,lastCount:0},g[ee]={};for(let ae=0;ae<C.length;ae++){const D=C[ae];p[D]&&p[D].node.mode===I.mode?(g[D][ee]=h(p[D].lastCount+I.length,I.mode)-h(p[D].lastCount,I.mode),p[D].lastCount+=I.length):(p[D]&&(p[D].lastCount=I.length),g[D][ee]=h(I.length,I.mode)+4+e.getCharCountIndicator(I.mode,E))}}C=P}for(let T=0;T<C.length;T++)g[C[T]].end=0;return{map:g,table:p}}function f(b,E){let p;const g=e.getBestModeForData(b);if(p=e.from(E,g),p!==e.BYTE&&p.bit<g.bit)throw new Error('"'+b+'" cannot be encoded with mode '+e.toString(p)+`. Suggested mode is: `+e.toString(g));switch(p===e.KANJI&&!a.isKanjiModeEnabled()&&(p=e.BYTE),p){case e.NUMERIC:return new t(b);case e.ALPHANUMERIC:return new i(b);case e.KANJI:return new s(b);case e.BYTE:return new r(b)}}n.fromArray=function(E){return E.reduce(function(p,g){return typeof g=="string"?p.push(f(g,null)):g.data&&p.push(f(g.data,g.mode)),p},[])},n.fromString=function(E,p){const g=k(E,a.isKanjiModeEnabled()),C=l(g),T=u(C,p),L=c.find_path(T.map,"start","end"),P=[];for(let F=1;F<L.length-1;F++)P.push(T.table[L[F]].node);return n.fromArray(d(P))},n.rawSplit=function(E){return n.fromArray(k(E,a.isKanjiModeEnabled()))}})(Wt);const Re=U,tt=Ce,Zn=Mn,ei=In,ti=It,ni=Pt,nt=xt,it=ke,ii=Dn,Ne=qt,ri=zt,si=X,rt=Wt;function oi(n,e){const t=n.size,i=ni.getPositions(e);for(let r=0;r<i.length;r++){const s=i[r][0],o=i[r][1];for(let a=-1;a<=7;a++)if(!(s+a<=-1||t<=s+a))for(let c=-1;c<=7;c++)o+c<=-1||t<=o+c||(a>=0&&a<=6&&(c===0||c===6)||c>=0&&c<=6&&(a===0||a===6)||a>=2&&a<=4&&c>=2&&c<=4?n.set(s+a,o+c,!0,!0):n.set(s+a,o+c,!1,!0))}}function ai(n){const e=n.size;for(let t=8;t<e-8;t++){const i=t%2===0;n.set(t,6,i,!0),n.set(6,t,i,!0)}}function ci(n,e){const t=ti.getPositions(e);for(let i=0;i<t.length;i++){const r=t[i][0],s=t[i][1];for(let o=-2;o<=2;o++)for(let a=-2;a<=2;a++)o===-2||o===2||a===-2||a===2||o===0&&a===0?n.set(r+o,s+a,!0,!0):n.set(r+o,s+a,!1,!0)}}function hi(n,e){const t=n.size,i=Ne.getEncodedBits(e);let r,s,o;for(let a=0;a<18;a++)r=Math.floor(a/3),s=a%3+t-8-3,o=(i>>a&1)===1,n.set(r,s,o,!0),n.set(s,r,o,!0)}function st(n,e,t){const i=n.size,r=ri.getEncodedBits(e,t);let s,o;for(s=0;s<15;s++)o=(r>>s&1)===1,s<6?n.set(s,8,o,!0):s<8?n.set(s+1,8,o,!0):n.set(i-15+s,8,o,!0),s<8?n.set(8,i-s-1,o,!0):s<9?n.set(8,15-s-1+1,o,!0):n.set(8,15-s-1,o,!0);n.set(i-8,8,1,!0)}function li(n,e){const t=n.size;let i=-1,r=t-1,s=7,o=0;for(let a=t-1;a>0;a-=2)for(a===6&&a--;;){for(let c=0;c<2;c++)if(!n.isReserved(r,a-c)){let w=!1;o<e.length&&(w=(e[o]>>>s&1)===1),n.set(r,a-c,w),s--,s===-1&&(o++,s=7)}if(r+=i,r<0||t<=r){r-=i,i=-i;break}}}function ui(n,e,t){const i=new Zn;t.forEach(function(c){i.put(c.mode.bit,4),i.put(c.getLength(),si.getCharCountIndicator(c.mode,n)),c.write(i)});const r=Re.getSymbolTotalCodewords(n),s=it.getTotalCodewordsCount(n,e),o=(r-s)*8;for(i.getLengthInBits()+4<=o&&i.put(0,4);i.getLengthInBits()%8!==0;)i.putBit(0);const a=(o-i.getLengthInBits())/8;for(let c=0;c<a;c++)i.put(c%2?17:236,8);return di(i,n,e)}function di(n,e,t){const i=Re.getSymbolTotalCodewords(e),r=it.getTotalCodewordsCount(e,t),s=i-r,o=it.getBlocksCount(e,t),a=i%o,c=o-a,w=Math.floor(i/o),m=Math.floor(s/o),k=m+1,h=w-m,d=new ii(h);let l=0;const u=new Array(o),f=new Array(o);let b=0;const E=new Uint8Array(n.buffer);for(let L=0;L<o;L++){const P=L<c?m:k;u[L]=E.slice(l,l+P),f[L]=d.encode(u[L]),l+=P,b=Math.max(b,P)}const p=new Uint8Array(i);let g=0,C,T;for(C=0;C<b;C++)for(T=0;T<o;T++)C<u[T].length&&(p[g++]=u[T][C]);for(C=0;C<h;C++)for(T=0;T<o;T++)p[g++]=f[T][C];return p}function fi(n,e,t,i){let r;if(Array.isArray(n))r=rt.fromArray(n);else if(typeof n=="string"){let w=e;if(!w){const m=rt.rawSplit(n);w=Ne.getBestVersionForData(m,t)}r=rt.fromString(n,w||40)}else throw new Error("Invalid data");const s=Ne.getBestVersionForData(r,t);if(!s)throw new Error("The amount of data is too big to be stored in a QR Code");if(!e)e=s;else if(e<s)throw new Error(` The chosen QR Code version cannot contain this amount of data. Minimum version required to store current data is: `+s+`. `);const o=ui(e,t,r),a=Re.getSymbolSize(e),c=new ei(a);return oi(c,e),ai(c),ci(c,e),st(c,t,0),e>=7&&hi(c,e),li(c,o),isNaN(i)&&(i=nt.getBestMask(c,st.bind(null,c,t))),nt.applyMask(i,c),st(c,t,i),{modules:c,version:e,errorCorrectionLevel:t,maskPattern:i,segments:r}}Ot.create=function(e,t){if(typeof e>"u"||e==="")throw new Error("No input text");let i=tt.M,r,s;return typeof t<"u"&&(i=tt.from(t.errorCorrectionLevel,tt.M),r=Ne.from(t.version),s=nt.from(t.maskPattern),t.toSJISFunc&&Re.setToSJISFunction(t.toSJISFunc)),fi(e,r,i,s)};var Jt={},ot={};(function(n){function e(t){if(typeof t=="number"&&(t=t.toString()),typeof t!="string")throw new Error("Color should be defined as hex string");let i=t.slice().replace("#","").split("");if(i.length<3||i.length===5||i.length>8)throw new Error("Invalid hex color: "+t);(i.length===3||i.length===4)&&(i=Array.prototype.concat.apply([],i.map(function(s){return[s,s]}))),i.length===6&&i.push("F","F");const r=parseInt(i.join(""),16);return{r:r>>24&255,g:r>>16&255,b:r>>8&255,a:r&255,hex:"#"+i.slice(0,6).join("")}}n.getOptions=function(i){i||(i={}),i.color||(i.color={});const r=typeof i.margin>"u"||i.margin===null||i.margin<0?4:i.margin,s=i.width&&i.width>=21?i.width:void 0,o=i.scale||4;return{width:s,scale:s?4:o,margin:r,color:{dark:e(i.color.dark||"#000000ff"),light:e(i.color.light||"#ffffffff")},type:i.type,rendererOpts:i.rendererOpts||{}}},n.getScale=function(i,r){return r.width&&r.width>=i+r.margin*2?r.width/(i+r.margin*2):r.scale},n.getImageWidth=function(i,r){const s=n.getScale(i,r);return Math.floor((i+r.margin*2)*s)},n.qrToImageData=function(i,r,s){const o=r.modules.size,a=r.modules.data,c=n.getScale(o,s),w=Math.floor((o+s.margin*2)*c),m=s.margin*c,k=[s.color.light,s.color.dark];for(let h=0;h<w;h++)for(let d=0;d<w;d++){let l=(h*w+d)*4,u=s.color.light;if(h>=m&&d>=m&&h<w-m&&d<w-m){const f=Math.floor((h-m)/c),b=Math.floor((d-m)/c);u=k[a[f*o+b]?1:0]}i[l++]=u.r,i[l++]=u.g,i[l++]=u.b,i[l]=u.a}}})(ot),function(n){const e=ot;function t(r,s,o){r.clearRect(0,0,s.width,s.height),s.style||(s.style={}),s.height=o,s.width=o,s.style.height=o+"px",s.style.width=o+"px"}function i(){try{return document.createElement("canvas")}catch{throw new Error("You need to specify a canvas element")}}n.render=function(s,o,a){let c=a,w=o;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),o||(w=i()),c=e.getOptions(c);const m=e.getImageWidth(s.modules.size,c),k=w.getContext("2d"),h=k.createImageData(m,m);return e.qrToImageData(h.data,s,c),t(k,w,m),k.putImageData(h,0,0),w},n.renderToDataURL=function(s,o,a){let c=a;typeof c>"u"&&(!o||!o.getContext)&&(c=o,o=void 0),c||(c={});const w=n.render(s,o,c),m=c.type||"image/png",k=c.rendererOpts||{};return w.toDataURL(m,k.quality)}}(Jt);var jt={};const pi=ot;function Gt(n,e){const t=n.a/255,i=e+'="'+n.hex+'"';return t<1?i+" "+e+'-opacity="'+t.toFixed(2).slice(1)+'"':i}function at(n,e,t){let i=n+e;return typeof t<"u"&&(i+=" "+t),i}function gi(n,e,t){let i="",r=0,s=!1,o=0;for(let a=0;a<n.length;a++){const c=Math.floor(a%e),w=Math.floor(a/e);!c&&!s&&(s=!0),n[a]?(o++,a>0&&c>0&&n[a-1]||(i+=s?at("M",c+t,.5+w+t):at("m",r,0),r=0,s=!1),c+1<e&&n[a+1]||(i+=at("h",o),o=0)):r++}return i}jt.render=function(e,t,i){const r=pi.getOptions(t),s=e.modules.size,o=e.modules.data,a=s+r.margin*2,c=r.color.light.a?"<path "+Gt(r.color.light,"fill")+' d="M0 0h'+a+"v"+a+'H0z"/>':"",w="<path "+Gt(r.color.dark,"stroke")+' d="'+gi(o,s,r.margin)+'"/>',m='viewBox="0 0 '+a+" "+a+'"',h='<svg xmlns="http://www.w3.org/2000/svg" '+(r.width?'width="'+r.width+'" height="'+r.width+'" ':"")+m+' shape-rendering="crispEdges">'+c+w+`</svg> `;return typeof i=="function"&&i(null,h),h};const mi=Ln,ct=Ot,$t=Jt,wi=jt;function ht(n,e,t,i,r){const s=[].slice.call(arguments,1),o=s.length,a=typeof s[o-1]=="function";if(!a&&!mi())throw new Error("Callback required as last argument");if(a){if(o<2)throw new Error("Too few arguments provided");o===2?(r=t,t=e,e=i=void 0):o===3&&(e.getContext&&typeof r>"u"?(r=i,i=void 0):(r=i,i=t,t=e,e=void 0))}else{if(o<1)throw new Error("Too few arguments provided");return o===1?(t=e,e=i=void 0):o===2&&!e.getContext&&(i=t,t=e,e=void 0),new Promise(function(c,w){try{const m=ct.create(t,i);c(n(m,e,i))}catch(m){w(m)}})}try{const c=ct.create(t,i);r(null,n(c,e,i))}catch(c){r(c)}}ue.create=ct.create,ue.toCanvas=ht.bind(null,$t.render),ue.toDataURL=ht.bind(null,$t.renderToDataURL),ue.toString=ht.bind(null,function(n,e,t){return wi.render(n,t)});var ge=(n=>(n.AllOthersDisconnected="allOthersDisconnected",n.Capture="capture",n.Configuration="configuration",n.RemoteScanStarted="remoteScanStarted",n.AllOthersReconnected="allOthersReconnected",n))(ge||{});const H=Object.create(null);H.open="0",H.close="1",H.ping="2",H.pong="3",H.message="4",H.upgrade="5",H.noop="6";const Le=Object.create(null);Object.keys(H).forEach(n=>{Le[H[n]]=n});const lt={type:"error",data:"parser error"},Qt=typeof Blob=="function"||typeof Blob<"u"&&Object.prototype.toString.call(Blob)==="[object BlobConstructor]",Xt=typeof ArrayBuffer=="function",Zt=n=>typeof ArrayBuffer.isView=="function"?ArrayBuffer.isView(n):n&&n.buffer instanceof ArrayBuffer,ut=({type:n,data:e},t,i)=>Qt&&e instanceof Blob?t?i(e):en(e,i):Xt&&(e instanceof ArrayBuffer||Zt(e))?t?i(e):en(new Blob([e]),i):i(H[n]+(e||"")),en=(n,e)=>{const t=new FileReader;return t.onload=function(){const i=t.result.split(",")[1];e("b"+(i||""))},t.readAsDataURL(n)};function tn(n){return n instanceof Uint8Array?n:n instanceof ArrayBuffer?new Uint8Array(n):new Uint8Array(n.buffer,n.byteOffset,n.byteLength)}let dt;function bi(n,e){if(Qt&&n.data instanceof Blob)return n.data.arrayBuffer().then(tn).then(e);if(Xt&&(n.data instanceof ArrayBuffer||Zt(n.data)))return e(tn(n.data));ut(n,!1,t=>{dt||(dt=new TextEncoder),e(dt.encode(t))})}const nn="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",me=typeof Uint8Array>"u"?[]:new Uint8Array(256);for(let n=0;n<nn.length;n++)me[nn.charCodeAt(n)]=n;const yi=n=>{let e=n.length*.75,t=n.length,i,r=0,s,o,a,c;n[n.length-1]==="="&&(e--,n[n.length-2]==="="&&e--);const w=new ArrayBuffer(e),m=new Uint8Array(w);for(i=0;i<t;i+=4)s=me[n.charCodeAt(i)],o=me[n.charCodeAt(i+1)],a=me[n.charCodeAt(i+2)],c=me[n.charCodeAt(i+3)],m[r++]=s<<2|o>>4,m[r++]=(o&15)<<4|a>>2,m[r++]=(a&3)<<6|c&63;return w},_i=typeof ArrayBuffer=="function",ft=(n,e)=>{if(typeof n!="string")return{type:"message",data:rn(n,e)};const t=n.charAt(0);return t==="b"?{type:"message",data:Ei(n.substring(1),e)}:Le[t]?n.length>1?{type:Le[t],data:n.substring(1)}:{type:Le[t]}:lt},Ei=(n,e)=>{if(_i){const t=yi(n);return rn(t,e)}else return{base64:!0,data:n}},rn=(n,e)=>{switch(e){case"blob":return n instanceof Blob?n:new Blob([n]);case"arraybuffer":default:return n instanceof ArrayBuffer?n:n.buffer}},sn="",vi=(n,e)=>{const t=n.length,i=new Array(t);let r=0;n.forEach((s,o)=>{ut(s,!1,a=>{i[o]=a,++r===t&&e(i.join(sn))})})},Ci=(n,e)=>{const t=n.split(sn),i=[];for(let r=0;r<t.length;r++){const s=ft(t[r],e);if(i.push(s),s.type==="error")break}return i};function ki(){return new TransformStream({transform(n,e){bi(n,t=>{const i=t.length;let r;if(i<126)r=new Uint8Array(1),new DataView(r.buffer).setUint8(0,i);else if(i<65536){r=new Uint8Array(3);const s=new DataView(r.buffer);s.setUint8(0,126),s.setUint16(1,i)}else{r=new Uint8Array(9);const s=new DataView(r.buffer);s.setUint8(0,127),s.setBigUint64(1,BigInt(i))}n.data&&typeof n.data!="string"&&(r[0]|=128),e.enqueue(r),e.enqueue(t)})}})}let pt;function Oe(n){return n.reduce((e,t)=>e+t.length,0)}function Me(n,e){if(n[0].length===e)return n.shift();const t=new Uint8Array(e);let i=0;for(let r=0;r<e;r++)t[r]=n[0][i++],i===n[0].length&&(n.shift(),i=0);return n.length&&i<n[0].length&&(n[0]=n[0].slice(i)),t}function Ai(n,e){pt||(pt=new TextDecoder);const t=[];let i=0,r=-1,s=!1;return new TransformStream({transform(o,a){for(t.push(o);;){if(i===0){if(Oe(t)<1)break;const c=Me(t,1);s=(c[0]&128)===128,r=c[0]&127,r<126?i=3:r===126?i=1:i=2}else if(i===1){if(Oe(t)<2)break;const c=Me(t,2);r=new DataView(c.buffer,c.byteOffset,c.length).getUint16(0),i=3}else if(i===2){if(Oe(t)<8)break;const c=Me(t,8),w=new DataView(c.buffer,c.byteOffset,c.length),m=w.getUint32(0);if(m>Math.pow(2,21)-1){a.enqueue(lt);break}r=m*Math.pow(2,32)+w.getUint32(4),i=3}else{if(Oe(t)<r)break;const c=Me(t,r);a.enqueue(ft(s?c:pt.decode(c),e)),i=0}if(r===0||r>n){a.enqueue(lt);break}}}})}const on=4;function M(n){if(n)return Ti(n)}function Ti(n){for(var e in M.prototype)n[e]=M.prototype[e];return n}M.prototype.on=M.prototype.addEventListener=function(n,e){return this._callbacks=this._callbacks||{},(this._callbacks["$"+n]=this._callbacks["$"+n]||[]).push(e),this},M.prototype.once=function(n,e){function t(){this.off(n,t),e.apply(this,arguments)}return t.fn=e,this.on(n,t),this},M.prototype.off=M.prototype.removeListener=M.prototype.removeAllListeners=M.prototype.removeEventListener=function(n,e){if(this._callbacks=this._callbacks||{},arguments.length==0)return this._callbacks={},this;var t=this._callbacks["$"+n];if(!t)return this;if(arguments.length==1)return delete this._callbacks["$"+n],this;for(var i,r=0;r<t.length;r++)if(i=t[r],i===e||i.fn===e){t.splice(r,1);break}return t.length===0&&delete this._callbacks["$"+n],this},M.prototype.emit=function(n){this._callbacks=this._callbacks||{};for(var e=new Array(arguments.length-1),t=this._callbacks["$"+n],i=1;i<arguments.length;i++)e[i-1]=arguments[i];if(t){t=t.slice(0);for(var i=0,r=t.length;i<r;++i)t[i].apply(this,e)}return this},M.prototype.emitReserved=M.prototype.emit,M.prototype.listeners=function(n){return this._callbacks=this._callbacks||{},this._callbacks["$"+n]||[]},M.prototype.hasListeners=function(n){return!!this.listeners(n).length};const Ie=typeof Promise=="function"&&typeof Promise.resolve=="function"?e=>Promise.resolve().then(e):(e,t)=>t(e,0),q=typeof self<"u"?self:typeof window<"u"?window:Function("return this")(),Si="arraybuffer";function Nr(){}function an(n,...e){return e.reduce((t,i)=>(n.hasOwnProperty(i)&&(t[i]=n[i]),t),{})}const Bi=q.setTimeout,Ri=q.clearTimeout;function Pe(n,e){e.useNativeTimers?(n.setTimeoutFn=Bi.bind(q),n.clearTimeoutFn=Ri.bind(q)):(n.setTimeoutFn=q.setTimeout.bind(q),n.clearTimeoutFn=q.clearTimeout.bind(q))}const Ni=1.33;function Li(n){return typeof n=="string"?Oi(n):Math.ceil((n.byteLength||n.size)*Ni)}function Oi(n){let e=0,t=0;for(let i=0,r=n.length;i<r;i++)e=n.charCodeAt(i),e<128?t+=1:e<2048?t+=2:e<55296||e>=57344?t+=3:(i++,t+=4);return t}function cn(){return Date.now().toString(36).substring(3)+Math.random().toString(36).substring(2,5)}function Mi(n){let e="";for(let t in n)n.hasOwnProperty(t)&&(e.length&&(e+="&"),e+=encodeURIComponent(t)+"="+encodeURIComponent(n[t]));return e}function Ii(n){let e={},t=n.split("&");for(let i=0,r=t.length;i<r;i++){let s=t[i].split("=");e[decodeURIComponent(s[0])]=decodeURIComponent(s[1])}return e}class Pi extends Error{constructor(e,t,i){super(e),this.description=t,this.context=i,this.type="TransportError"}}class gt extends M{constructor(e){super(),this.writable=!1,Pe(this,e),this.opts=e,this.query=e.query,this.socket=e.socket,this.supportsBinary=!e.forceBase64}onError(e,t,i){return super.emitReserved("error",new Pi(e,t,i)),this}open(){return this.readyState="opening",this.doOpen(),this}close(){return(this.readyState==="opening"||this.readyState==="open")&&(this.doClose(),this.onClose()),this}send(e){this.readyState==="open"&&this.write(e)}onOpen(){this.readyState="open",this.writable=!0,super.emitReserved("open")}onData(e){const t=ft(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 e.indexOf(":")===-1?e:"["+e+"]"}_port(){return this.opts.port&&(this.opts.secure&&Number(this.opts.port)!==443||!this.opts.secure&&Number(this.opts.port)!==80)?":"+this.opts.port:""}_query(e){const t=Mi(e);return t.length?"?"+t:""}}class Di extends gt{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 i=0;this._polling&&(i++,this.once("pollComplete",function(){--i||t()})),this.writable||(i++,this.once("drain",function(){--i||t()}))}else t()}_poll(){this._polling=!0,this.doPoll(),this.emitReserved("poll")}onData(e){const t=i=>{if(this.readyState==="opening"&&i.type==="open"&&this.onOpen(),i.type==="close")return this.onClose({description:"transport closed by the server"}),!1;this.onPacket(i)};Ci(e,this.socket.binaryType).forEach(t),this.readyState!=="closed"&&(this._polling=!1,this.emitReserved("pollComplete"),this.readyState==="open"&&this._poll())}doClose(){const e=()=>{this.write([{type:"close"}])};this.readyState==="open"?e():this.once("open",e)}write(e){this.writable=!1,vi(e,t=>{this.doWrite(t,()=>{this.writable=!0,this.emitReserved("drain")})})}uri(){const e=this.opts.secure?"https":"http",t=this.query||{};return this.opts.timestampRequests!==!1&&(t[this.opts.timestampParam]=cn()),!this.supportsBinary&&!t.sid&&(t.b64=1),this.createUri(e,t)}}let hn=!1;try{hn=typeof XMLHttpRequest<"u"&&"withCredentials"in new XMLHttpRequest}catch{}const xi=hn;function Ui(){}class Fi extends Di{constructor(e){if(super(e),typeof location<"u"){const t=location.protocol==="https:";let i=location.port;i||(i=t?"443":"80"),this.xd=typeof location<"u"&&e.hostname!==location.hostname||i!==e.port}}doWrite(e,t){const i=this.request({method:"POST",data:e});i.on("success",t),i.on("error",(r,s)=>{this.onError("xhr post error",r,s)})}doPoll(){const e=this.request();e.on("data",this.onData.bind(this)),e.on("error",(t,i)=>{this.onError("xhr poll error",t,i)}),this.pollXhr=e}}class W extends M{constructor(e,t,i){super(),this.createRequest=e,Pe(this,i),this._opts=i,this._method=i.method||"GET",this._uri=t,this._data=i.data!==void 0?i.data:null,this._create()}_create(){var e;const t=an(this._opts,"agent","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","autoUnref");t.xdomain=!!this._opts.xd;const i=this._xhr=this.createRequest(t);try{i.open(this._method,this._uri,!0);try{if(this._opts.extraHeaders){i.setDisableHeaderCheck&&i.setDisableHeaderCheck(!0);for(let r in this._opts.extraHeaders)this._opts.extraHeaders.hasOwnProperty(r)&&i.setRequestHeader(r,this._opts.extraHeaders[r])}}catch{}if(this._method==="POST")try{i.setRequestHeader("Content-type","text/plain;charset=UTF-8")}catch{}try{i.setRequestHeader("Accept","*/*")}catch{}(e=this._opts.cookieJar)===null||e===void 0||e.addCookies(i),"withCredentials"in i&&(i.withCredentials=this._opts.withCredentials),this._opts.requestTimeout&&(i.timeout=this._opts.requestTimeout),i.onreadystatechange=()=>{var r;i.readyState===3&&((r=this._opts.cookieJar)===null||r===void 0||r.parseCookies(i.getResponseHeader("set-cookie"))),i.readyState===4&&(i.status===200||i.status===1223?this._onLoad():this.setTimeoutFn(()=>{this._onError(typeof i.status=="number"?i.status:0)},0))},i.send(this._data)}catch(r){this.setTimeoutFn(()=>{this._onError(r)},0);return}typeof document<"u"&&(this._index=W.requestsCount++,W.requests[this._index]=this)}_onError(e){this.emitReserved("error",e,this._xhr),this._cleanup(!0)}_cleanup(e){if(!(typeof this._xhr>"u"||this._xhr===null)){if(this._xhr.onreadystatechange=Ui,e)try{this._xhr.abort()}catch{}typeof document<"u"&&delete W.requests[this._index],this._xhr=null}}_onLoad(){const e=this._xhr.responseText;e!==null&&(this.emitReserved("data",e),this.emitReserved("success"),this._cleanup())}abort(){this._cleanup()}}if(W.requestsCount=0,W.requests={},typeof document<"u"){if(typeof attachEvent=="function")attachEvent("onunload",ln);else if(typeof addEventListener=="function"){const n="onpagehide"in q?"pagehide":"unload";addEventListener(n,ln,!1)}}function ln(){for(let n in W.requests)W.requests.hasOwnProperty(n)&&W.requests[n].abort()}const qi=function(){const n=un({xdomain:!1});return n&&n.responseType!==null}();class Vi extends Fi{constructor(e){super(e);const t=e&&e.forceBase64;this.supportsBinary=qi&&!t}request(e={}){return Object.assign(e,{xd:this.xd},this.opts),new W(un,this.uri(),e)}}function un(n){const e=n.xdomain;try{if(typeof XMLHttpRequest<"u"&&(!e||xi))return new XMLHttpRequest}catch{}if(!e)try{return new q[["Active"].concat("Object").join("X")]("Microsoft.XMLHTTP")}catch{}}const dn=typeof navigator<"u"&&typeof navigator.product=="string"&&navigator.product.toLowerCase()==="reactnative";class zi extends gt{get name(){return"websocket"}doOpen(){const e=this.uri(),t=this.opts.protocols,i=dn?{}:an(this.opts,"agent","perMessageDeflate","pfx","key","passphrase","cert","ca","ciphers","rejectUnauthorized","localAddress","protocolVersion","origin","maxPayload","family","checkServerIdentity");this.opts.extraHeaders&&(i.headers=this.opts.extraHeaders);try{this.ws=this.createSocket(e,t,i)}catch(r){return this.emitReserved("error",r)}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 i=e[t],r=t===e.length-1;ut(i,this.supportsBinary,s=>{try{this.doWrite(i,s)}catch{}r&&Ie(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){typeof this.ws<"u"&&(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]=cn()),this.supportsBinary||(t.b64=1),this.createUri(e,t)}}const mt=q.WebSocket||q.MozWebSocket;class Ki extends zi{createSocket(e,t,i){return dn?new mt(e,t,i):t?new mt(e,t):new mt(e)}doWrite(e,t){this.ws.send(t)}}class Hi extends gt{get name(){return"webtransport"}doOpen(){try{this._transport=new WebTransport(this.createUri("https"),this.opts.transportOptions[this.name])}catch(e){return this.emitReserved("error",e)}this._transport.closed.then(()=>{this.onClose()}).catch(e=>{this.onError("webtransport error",e)}),this._transport.ready.then(()=>{this._transport.createBidirectionalStream().then(e=>{const t=Ai(Number.MAX_SAFE_INTEGER,this.socket.binaryType),i=e.readable.pipeThrough(t).getReader(),r=ki();r.readable.pipeTo(e.writable),this._writer=r.writable.getWriter();const s=()=>{i.read().then(({done:a,value:c})=>{a||(this.onPacket(c),s())}).catch(a=>{})};s();const o={type:"open"};this.query.sid&&(o.data=`{"sid":"${this.query.sid}"}`),this._writer.write(o).then(()=>this.onOpen())})})}write(e){this.writable=!1;for(let t=0;t<e.length;t++){const i=e[t],r=t===e.length-1;this._writer.write(i).then(()=>{r&&Ie(()=>{this.writable=!0,this.emitReserved("drain")},this.setTimeoutFn)})}}doClose(){var e;(e=this._transport)===null||e===void 0||e.close()}}const Wi={websocket:Ki,webtransport:Hi,polling:Vi},Yi=/^(?:(?![^:@\/?#]+:[^:@\/]*@)(http|https|ws|wss):\/\/)?((?:(([^:@\/?#]*)(?::([^:@\/?#]*))?)?@)?((?:[a-f0-9]{0,4}:){2,7}[a-f0-9]{0,4}|[^:\/?#]*)(?::(\d*))?)(((\/(?:[^?#](?![^?#\/]*\.[^?#\/.]+(?:[?#]|$)))*\/?)?([^?#\/]*))(?:\?([^#]*))?(?:#(.*))?)/,Ji=["source","protocol","authority","userInfo","user","password","host","port","relative","path","directory","file","query","anchor"];function wt(n){if(n.length>8e3)throw"URI too long";const e=n,t=n.indexOf("["),i=n.indexOf("]");t!=-1&&i!=-1&&(n=n.substring(0,t)+n.substring(t,i).replace(/:/g,";")+n.substring(i,n.length));let r=Yi.exec(n||""),s={},o=14;for(;o--;)s[Ji[o]]=r[o]||"";return t!=-1&&i!=-1&&(s.source=e,s.host=s.host.substring(1,s.host.length-1).replace(/;/g,":"),s.authority=s.authority.replace("[","").replace("]","").replace(/;/g,":"),s.ipv6uri=!0),s.pathNames=ji(s,s.path),s.queryKey=Gi(s,s.query),s}function ji(n,e){const t=/\/{2,9}/g,i=e.replace(t,"/").split("/");return(e.slice(0,1)=="/"||e.length===0)&&i.splice(0,1),e.slice(-1)=="/"&&i.splice(i.length-1,1),i}function Gi(n,e){const t={};return e.replace(/(?:^|&)([^&=]*)=?([^&]*)/g,function(i,r,s){r&&(t[r]=s)}),t}const bt=typeof addEventListener=="function"&&typeof removeEventListener=="function",De=[];bt&&addEventListener("offline",()=>{De.forEach(n=>n())},!1);class Z extends M{constructor(e,t){if(super(),this.binaryType=Si,this.writeBuffer=[],this._prevBufferLen=0,this._pingInterval=-1,this._pingTimeout=-1,this._maxPayload=-1,this._pingTimeoutTime=1/0,e&&typeof e=="object"&&(t=e,e=null),e){const i=wt(e);t.hostname=i.host,t.secure=i.protocol==="https"||i.protocol==="wss",t.port=i.port,i.query&&(t.query=i.query)}else t.host&&(t.hostname=wt(t.host).host);Pe(this,t),this.secure=t.secure!=null?t.secure:typeof location<"u"&&location.protocol==="https:",t.hostname&&!t.port&&(t.port=this.secure?"443":"80"),this.hostname=t.hostname||(typeof location<"u"?location.hostname:"localhost"),this.port=t.port||(typeof location<"u"&&location.port?location.port:this.secure?"443":"80"),this.transports=[],this._transportsByName={},t.transports.forEach(i=>{const r=i.prototype.name;this.transports.push(r),this._transportsByName[r]=i}),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?"/":""),typeof this.opts.query=="string"&&(this.opts.query=Ii(this.opts.query)),bt&&(this.opts.closeOnBeforeunload&&(this._beforeunloadEventListener=()=>{this.transport&&(this.transport.removeAllListeners(),this.transport.close())},addEventListener("beforeunload",this._beforeunloadEventListener,!1)),this.hostname!=="localhost"&&(this._offlineEventListener=()=>{this._onClose("transport close",{description:"network connection lost"})},De.push(this._offlineEventListener))),this.opts.withCredentials&&(this._cookieJar=void 0),this._open()}createTransport(e){const t=Object.assign({},this.opts.query);t.EIO=on,t.transport=e,this.id&&(t.sid=this.id);const i=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](i)}_open(){if(this.transports.length===0){this.setTimeoutFn(()=>{this.emitReserved("error","No transports available")},0);return}const e=this.opts.rememberUpgrade&&Z.priorWebsocketSuccess&&this.transports.indexOf("websocket")!==-1?"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",t=>this._onClose("transport close",t))}onOpen(){this.readyState="open",Z.priorWebsocketSuccess=this.transport.name==="websocket",this.emitReserved("open"),this.flush()}_onPacket(e){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing")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);break}}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(),this.readyState!=="closed"&&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,this.writeBuffer.length===0?this.emitReserved("drain"):this.flush()}flush(){if(this.readyState!=="closed"&&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&&this.transport.name==="polling"&&this.writeBuffer.length>1))return this.writeBuffer;let t=1;for(let i=0;i<this.writeBuffer.length;i++){const r=this.writeBuffer[i].data;if(r&&(t+=Li(r)),i>0&&t>this._maxPayload)return this.writeBuffer.slice(0,i);t+=2}return this.writeBuffer}_hasPingExpired(){if(!this._pingTimeoutTime)return!0;const e=Date.now()>this._pingTimeoutTime;return e&&(this._pingTimeoutTime=0,Ie(()=>{this._onClose("ping timeout")},this.setTimeoutFn)),e}write(e,t,i){return this._sendPacket("message",e,t,i),this}send(e,t,i){return this._sendPacket("message",e,t,i),this}_sendPacket(e,t,i,r){if(typeof t=="function"&&(r=t,t=void 0),typeof i=="function"&&(r=i,i=null),this.readyState==="closing"||this.readyState==="closed")return;i=i||{},i.compress=i.compress!==!1;const s={type:e,data:t,options:i};this.emitReserved("packetCreate",s),this.writeBuffer.push(s),r&&this.once("flush",r),this.flush()}close(){const e=()=>{this._onClose("forced close"),this.transport.close()},t=()=>{this.off("upgrade",t),this.off("upgradeError",t),e()},i=()=>{this.once("upgrade",t),this.once("upgradeError",t)};return(this.readyState==="opening"||this.readyState==="open")&&(this.readyState="closing",this.writeBuffer.length?this.once("drain",()=>{this.upgrading?i():e()}):this.upgrading?i():e()),this}_onError(e){if(Z.priorWebsocketSuccess=!1,this.opts.tryAllTransports&&this.transports.length>1&&this.readyState==="opening")return this.transports.shift(),this._open();this.emitReserved("error",e),this._onClose("transport error",e)}_onClose(e,t){if(this.readyState==="opening"||this.readyState==="open"||this.readyState==="closing"){if(this.clearTimeoutFn(this._pingTimeoutTimer),this.transport.removeAllListeners("close"),this.transport.c