@paramms/chat-widget 1.9.1 → 1.9.2

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.
@@ -1,8 +1,11 @@
1
1
  var RelayEmbedLite=function(te){"use strict";var Dn=Object.defineProperty;var Nn=(te,X,ce)=>X in te?Dn(te,X,{enumerable:!0,configurable:!0,writable:!0,value:ce}):te[X]=ce;var c=(te,X,ce)=>Nn(te,typeof X!="symbol"?X+"":X,ce);const X="oc_uid";function ce(t){try{const e=document.cookie.match(new RegExp(`(?:^|; )${t}=([^;]*)`));return e?decodeURIComponent(e[1]):null}catch{return null}}function ft(t,e){try{const i=location.protocol==="https:"?"; Secure":"";document.cookie=`${t}=${encodeURIComponent(e)}; Max-Age=31536000; Path=/; SameSite=Lax${i}`}catch{}}function wt(){return`g_${Math.random().toString(36).slice(2)}${Date.now().toString(36)}`}function We(){let t=null;try{t=localStorage.getItem(X)}catch{}t||(t=ce(X));const e=t??wt();try{localStorage.setItem(X,e)}catch{}return ft(X,e),e}function gt(t){const e=t.length;let n=0,i=0;for(;i<e;){let o=t.charCodeAt(i++);if(o&4294967168)if(!(o&4294965248))n+=2;else{if(o>=55296&&o<=56319&&i<e){const s=t.charCodeAt(i);(s&64512)===56320&&(++i,o=((o&1023)<<10)+(s&1023)+65536)}o&4294901760?n+=4:n+=3}else{n++;continue}}return n}function xt(t,e,n){const i=t.length;let o=n,s=0;for(;s<i;){let r=t.charCodeAt(s++);if(r&4294967168)if(!(r&4294965248))e[o++]=r>>6&31|192;else{if(r>=55296&&r<=56319&&s<i){const p=t.charCodeAt(s);(p&64512)===56320&&(++s,r=((r&1023)<<10)+(p&1023)+65536)}r&4294901760?(e[o++]=r>>18&7|240,e[o++]=r>>12&63|128,e[o++]=r>>6&63|128):(e[o++]=r>>12&15|224,e[o++]=r>>6&63|128)}else{e[o++]=r;continue}e[o++]=r&63|128}}const yt=new TextEncoder,mt=50;function bt(t,e,n){yt.encodeInto(t,e.subarray(n))}function vt(t,e,n){t.length>mt?bt(t,e,n):xt(t,e,n)}const kt=4096;function Ke(t,e,n){let i=e;const o=i+n,s=[];let r="";for(;i<o;){const p=t[i++];if(!(p&128))s.push(p);else if((p&224)===192){const l=t[i++]&63;s.push((p&31)<<6|l)}else if((p&240)===224){const l=t[i++]&63,g=t[i++]&63;s.push((p&31)<<12|l<<6|g)}else if((p&248)===240){const l=t[i++]&63,g=t[i++]&63,w=t[i++]&63;let d=(p&7)<<18|l<<12|g<<6|w;d>65535&&(d-=65536,s.push(d>>>10&1023|55296),d=56320|d&1023),s.push(d)}else s.push(p);s.length>=kt&&(r+=String.fromCharCode(...s),s.length=0)}return s.length>0&&(r+=String.fromCharCode(...s)),r}const St=new TextDecoder,It=200;function Tt(t,e,n){const i=t.subarray(e,e+n);return St.decode(i)}function Ct(t,e,n){return n>It?Tt(t,e,n):Ke(t,e,n)}class me{constructor(e,n){c(this,"type");c(this,"data");this.type=e,this.data=n}}class V extends Error{constructor(e){super(e);const n=Object.create(V.prototype);Object.setPrototypeOf(this,n),Object.defineProperty(this,"name",{configurable:!0,enumerable:!1,value:V.name})}}const he=4294967295;function Et(t,e,n){const i=n/4294967296,o=n;t.setUint32(e,i),t.setUint32(e+4,o)}function Ve(t,e,n){const i=Math.floor(n/4294967296),o=n;t.setUint32(e,i),t.setUint32(e+4,o)}function Ye(t,e){const n=t.getInt32(e),i=t.getUint32(e+4);return n*4294967296+i}function Ut(t,e){const n=t.getUint32(e),i=t.getUint32(e+4);return n*4294967296+i}const Bt=-1,Lt=4294967296-1,At=17179869184-1;function zt({sec:t,nsec:e}){if(t>=0&&e>=0&&t<=At)if(e===0&&t<=Lt){const n=new Uint8Array(4);return new DataView(n.buffer).setUint32(0,t),n}else{const n=t/4294967296,i=t&4294967295,o=new Uint8Array(8),s=new DataView(o.buffer);return s.setUint32(0,e<<2|n&3),s.setUint32(4,i),o}else{const n=new Uint8Array(12),i=new DataView(n.buffer);return i.setUint32(0,e),Ve(i,4,t),n}}function Mt(t){const e=t.getTime(),n=Math.floor(e/1e3),i=(e-n*1e3)*1e6,o=Math.floor(i/1e9);return{sec:n+o,nsec:i-o*1e9}}function $t(t){if(t instanceof Date){const e=Mt(t);return zt(e)}else return null}function Rt(t){const e=new DataView(t.buffer,t.byteOffset,t.byteLength);switch(t.byteLength){case 4:return{sec:e.getUint32(0),nsec:0};case 8:{const n=e.getUint32(0),i=e.getUint32(4),o=(n&3)*4294967296+i,s=n>>>2;return{sec:o,nsec:s}}case 12:{const n=Ye(e,4),i=e.getUint32(0);return{sec:n,nsec:i}}default:throw new V(`Unrecognized data size for timestamp (expected 4, 8, or 12): ${t.length}`)}}function Pt(t){const e=Rt(t);return new Date(e.sec*1e3+e.nsec/1e6)}const _t={type:Bt,encode:$t,decode:Pt},Ie=class Ie{constructor(){c(this,"__brand");c(this,"builtInEncoders",[]);c(this,"builtInDecoders",[]);c(this,"encoders",[]);c(this,"decoders",[]);this.register(_t)}register({type:e,encode:n,decode:i}){if(e>=0)this.encoders[e]=n,this.decoders[e]=i;else{const o=-1-e;this.builtInEncoders[o]=n,this.builtInDecoders[o]=i}}tryToEncode(e,n){for(let i=0;i<this.builtInEncoders.length;i++){const o=this.builtInEncoders[i];if(o!=null){const s=o(e,n);if(s!=null){const r=-1-i;return new me(r,s)}}}for(let i=0;i<this.encoders.length;i++){const o=this.encoders[i];if(o!=null){const s=o(e,n);if(s!=null){const r=i;return new me(r,s)}}}return e instanceof me?e:null}decode(e,n,i){const o=n<0?this.builtInDecoders[-1-n]:this.decoders[n];return o?o(e,n,i):new me(n,e)}};c(Ie,"defaultCodec",new Ie);let be=Ie;function Dt(t){return t instanceof ArrayBuffer||typeof SharedArrayBuffer<"u"&&t instanceof SharedArrayBuffer}function Be(t){return t instanceof Uint8Array?t:ArrayBuffer.isView(t)?new Uint8Array(t.buffer,t.byteOffset,t.byteLength):Dt(t)?new Uint8Array(t):Uint8Array.from(t)}const Nt=100,qt=2048;class Le{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"maxDepth");c(this,"initialBufferSize");c(this,"sortKeys");c(this,"forceFloat32");c(this,"ignoreUndefined");c(this,"forceIntegerToFloat");c(this,"pos");c(this,"view");c(this,"bytes");c(this,"entered",!1);this.extensionCodec=(e==null?void 0:e.extensionCodec)??be.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.maxDepth=(e==null?void 0:e.maxDepth)??Nt,this.initialBufferSize=(e==null?void 0:e.initialBufferSize)??qt,this.sortKeys=(e==null?void 0:e.sortKeys)??!1,this.forceFloat32=(e==null?void 0:e.forceFloat32)??!1,this.ignoreUndefined=(e==null?void 0:e.ignoreUndefined)??!1,this.forceIntegerToFloat=(e==null?void 0:e.forceIntegerToFloat)??!1,this.pos=0,this.view=new DataView(new ArrayBuffer(this.initialBufferSize)),this.bytes=new Uint8Array(this.view.buffer)}clone(){return new Le({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,maxDepth:this.maxDepth,initialBufferSize:this.initialBufferSize,sortKeys:this.sortKeys,forceFloat32:this.forceFloat32,ignoreUndefined:this.ignoreUndefined,forceIntegerToFloat:this.forceIntegerToFloat})}reinitializeState(){this.pos=0}encodeSharedRef(e){if(this.entered)return this.clone().encodeSharedRef(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.subarray(0,this.pos)}finally{this.entered=!1}}encode(e){if(this.entered)return this.clone().encode(e);try{return this.entered=!0,this.reinitializeState(),this.doEncode(e,1),this.bytes.slice(0,this.pos)}finally{this.entered=!1}}doEncode(e,n){if(n>this.maxDepth)throw new Error(`Too deep objects in depth ${n}`);e==null?this.encodeNil():typeof e=="boolean"?this.encodeBoolean(e):typeof e=="number"?this.forceIntegerToFloat?this.encodeNumberAsFloat(e):this.encodeNumber(e):typeof e=="string"?this.encodeString(e):this.useBigInt64&&typeof e=="bigint"?this.encodeBigInt64(e):this.encodeObject(e,n)}ensureBufferSizeToWrite(e){const n=this.pos+e;this.view.byteLength<n&&this.resizeBuffer(n*2)}resizeBuffer(e){const n=new ArrayBuffer(e),i=new Uint8Array(n),o=new DataView(n);i.set(this.bytes),this.view=o,this.bytes=i}encodeNil(){this.writeU8(192)}encodeBoolean(e){e===!1?this.writeU8(194):this.writeU8(195)}encodeNumber(e){!this.forceIntegerToFloat&&Number.isSafeInteger(e)?e>=0?e<128?this.writeU8(e):e<256?(this.writeU8(204),this.writeU8(e)):e<65536?(this.writeU8(205),this.writeU16(e)):e<4294967296?(this.writeU8(206),this.writeU32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(207),this.writeU64(e)):e>=-32?this.writeU8(224|e+32):e>=-128?(this.writeU8(208),this.writeI8(e)):e>=-32768?(this.writeU8(209),this.writeI16(e)):e>=-2147483648?(this.writeU8(210),this.writeI32(e)):this.useBigInt64?this.encodeNumberAsFloat(e):(this.writeU8(211),this.writeI64(e)):this.encodeNumberAsFloat(e)}encodeNumberAsFloat(e){this.forceFloat32?(this.writeU8(202),this.writeF32(e)):(this.writeU8(203),this.writeF64(e))}encodeBigInt64(e){e>=BigInt(0)?(this.writeU8(207),this.writeBigUint64(e)):(this.writeU8(211),this.writeBigInt64(e))}writeStringHeader(e){if(e<32)this.writeU8(160+e);else if(e<256)this.writeU8(217),this.writeU8(e);else if(e<65536)this.writeU8(218),this.writeU16(e);else if(e<4294967296)this.writeU8(219),this.writeU32(e);else throw new Error(`Too long string: ${e} bytes in UTF-8`)}encodeString(e){const i=gt(e);this.ensureBufferSizeToWrite(5+i),this.writeStringHeader(i),vt(e,this.bytes,this.pos),this.pos+=i}encodeObject(e,n){const i=this.extensionCodec.tryToEncode(e,this.context);if(i!=null)this.encodeExtension(i);else if(Array.isArray(e))this.encodeArray(e,n);else if(ArrayBuffer.isView(e))this.encodeBinary(e);else if(typeof e=="object")this.encodeMap(e,n);else throw new Error(`Unrecognized object: ${Object.prototype.toString.apply(e)}`)}encodeBinary(e){const n=e.byteLength;if(n<256)this.writeU8(196),this.writeU8(n);else if(n<65536)this.writeU8(197),this.writeU16(n);else if(n<4294967296)this.writeU8(198),this.writeU32(n);else throw new Error(`Too large binary: ${n}`);const i=Be(e);this.writeU8a(i)}encodeArray(e,n){const i=e.length;if(i<16)this.writeU8(144+i);else if(i<65536)this.writeU8(220),this.writeU16(i);else if(i<4294967296)this.writeU8(221),this.writeU32(i);else throw new Error(`Too large array: ${i}`);for(const o of e)this.doEncode(o,n+1)}countWithoutUndefined(e,n){let i=0;for(const o of n)e[o]!==void 0&&i++;return i}encodeMap(e,n){const i=Object.keys(e);this.sortKeys&&i.sort();const o=this.ignoreUndefined?this.countWithoutUndefined(e,i):i.length;if(o<16)this.writeU8(128+o);else if(o<65536)this.writeU8(222),this.writeU16(o);else if(o<4294967296)this.writeU8(223),this.writeU32(o);else throw new Error(`Too large map object: ${o}`);for(const s of i){const r=e[s];this.ignoreUndefined&&r===void 0||(this.encodeString(s),this.doEncode(r,n+1))}}encodeExtension(e){if(typeof e.data=="function"){const i=e.data(this.pos+6),o=i.length;if(o>=4294967296)throw new Error(`Too large extension object: ${o}`);this.writeU8(201),this.writeU32(o),this.writeI8(e.type),this.writeU8a(i);return}const n=e.data.length;if(n===1)this.writeU8(212);else if(n===2)this.writeU8(213);else if(n===4)this.writeU8(214);else if(n===8)this.writeU8(215);else if(n===16)this.writeU8(216);else if(n<256)this.writeU8(199),this.writeU8(n);else if(n<65536)this.writeU8(200),this.writeU16(n);else if(n<4294967296)this.writeU8(201),this.writeU32(n);else throw new Error(`Too large extension object: ${n}`);this.writeI8(e.type),this.writeU8a(e.data)}writeU8(e){this.ensureBufferSizeToWrite(1),this.view.setUint8(this.pos,e),this.pos++}writeU8a(e){const n=e.length;this.ensureBufferSizeToWrite(n),this.bytes.set(e,this.pos),this.pos+=n}writeI8(e){this.ensureBufferSizeToWrite(1),this.view.setInt8(this.pos,e),this.pos++}writeU16(e){this.ensureBufferSizeToWrite(2),this.view.setUint16(this.pos,e),this.pos+=2}writeI16(e){this.ensureBufferSizeToWrite(2),this.view.setInt16(this.pos,e),this.pos+=2}writeU32(e){this.ensureBufferSizeToWrite(4),this.view.setUint32(this.pos,e),this.pos+=4}writeI32(e){this.ensureBufferSizeToWrite(4),this.view.setInt32(this.pos,e),this.pos+=4}writeF32(e){this.ensureBufferSizeToWrite(4),this.view.setFloat32(this.pos,e),this.pos+=4}writeF64(e){this.ensureBufferSizeToWrite(8),this.view.setFloat64(this.pos,e),this.pos+=8}writeU64(e){this.ensureBufferSizeToWrite(8),Et(this.view,this.pos,e),this.pos+=8}writeI64(e){this.ensureBufferSizeToWrite(8),Ve(this.view,this.pos,e),this.pos+=8}writeBigUint64(e){this.ensureBufferSizeToWrite(8),this.view.setBigUint64(this.pos,e),this.pos+=8}writeBigInt64(e){this.ensureBufferSizeToWrite(8),this.view.setBigInt64(this.pos,e),this.pos+=8}}function jt(t,e){return new Le(e).encodeSharedRef(t)}function Ae(t){return`${t<0?"-":""}0x${Math.abs(t).toString(16).padStart(2,"0")}`}const Ot=16,Ht=16;class Ft{constructor(e=Ot,n=Ht){c(this,"hit",0);c(this,"miss",0);c(this,"caches");c(this,"maxKeyLength");c(this,"maxLengthPerKey");this.maxKeyLength=e,this.maxLengthPerKey=n,this.caches=[];for(let i=0;i<this.maxKeyLength;i++)this.caches.push([])}canBeCached(e){return e>0&&e<=this.maxKeyLength}find(e,n,i){const o=this.caches[i-1];e:for(const s of o){const r=s.bytes;for(let p=0;p<i;p++)if(r[p]!==e[n+p])continue e;return s.str}return null}store(e,n){const i=this.caches[e.length-1],o={bytes:e,str:n};i.length>=this.maxLengthPerKey?i[Math.random()*i.length|0]=o:i.push(o)}decode(e,n,i){const o=this.find(e,n,i);if(o!=null)return this.hit++,o;this.miss++;const s=Ke(e,n,i),r=Uint8Array.prototype.slice.call(e,n,n+i);return this.store(r,s),s}}const ze="array",pe="map_key",Ge="map_value",Wt=t=>{if(typeof t=="string"||typeof t=="number")return t;throw new V("The type of key must be string or number but "+typeof t)};class Kt{constructor(){c(this,"stack",[]);c(this,"stackHeadPosition",-1)}get length(){return this.stackHeadPosition+1}top(){return this.stack[this.stackHeadPosition]}pushArrayState(e){const n=this.getUninitializedStateFromPool();n.type=ze,n.position=0,n.size=e,n.array=new Array(e)}pushMapState(e){const n=this.getUninitializedStateFromPool();n.type=pe,n.readCount=0,n.size=e,n.map={}}getUninitializedStateFromPool(){if(this.stackHeadPosition++,this.stackHeadPosition===this.stack.length){const e={type:void 0,size:0,array:void 0,position:0,readCount:0,map:void 0,key:null};this.stack.push(e)}return this.stack[this.stackHeadPosition]}release(e){if(this.stack[this.stackHeadPosition]!==e)throw new Error("Invalid stack state. Released state is not on top of the stack.");if(e.type===ze){const i=e;i.size=0,i.array=void 0,i.position=0,i.type=void 0}if(e.type===pe||e.type===Ge){const i=e;i.size=0,i.map=void 0,i.readCount=0,i.type=void 0}this.stackHeadPosition--}reset(){this.stack.length=0,this.stackHeadPosition=-1}}const ue=-1,Me=new DataView(new ArrayBuffer(0)),Vt=new Uint8Array(Me.buffer);try{Me.getInt8(0)}catch(t){if(!(t instanceof RangeError))throw new Error("This module is not supported in the current JavaScript engine because DataView does not throw RangeError on out-of-bounds access")}const Xe=new RangeError("Insufficient data"),Yt=new Ft;class $e{constructor(e){c(this,"extensionCodec");c(this,"context");c(this,"useBigInt64");c(this,"rawStrings");c(this,"maxStrLength");c(this,"maxBinLength");c(this,"maxArrayLength");c(this,"maxMapLength");c(this,"maxExtLength");c(this,"keyDecoder");c(this,"mapKeyConverter");c(this,"totalPos",0);c(this,"pos",0);c(this,"view",Me);c(this,"bytes",Vt);c(this,"headByte",ue);c(this,"stack",new Kt);c(this,"entered",!1);this.extensionCodec=(e==null?void 0:e.extensionCodec)??be.defaultCodec,this.context=e==null?void 0:e.context,this.useBigInt64=(e==null?void 0:e.useBigInt64)??!1,this.rawStrings=(e==null?void 0:e.rawStrings)??!1,this.maxStrLength=(e==null?void 0:e.maxStrLength)??he,this.maxBinLength=(e==null?void 0:e.maxBinLength)??he,this.maxArrayLength=(e==null?void 0:e.maxArrayLength)??he,this.maxMapLength=(e==null?void 0:e.maxMapLength)??he,this.maxExtLength=(e==null?void 0:e.maxExtLength)??he,this.keyDecoder=(e==null?void 0:e.keyDecoder)!==void 0?e.keyDecoder:Yt,this.mapKeyConverter=(e==null?void 0:e.mapKeyConverter)??Wt}clone(){return new $e({extensionCodec:this.extensionCodec,context:this.context,useBigInt64:this.useBigInt64,rawStrings:this.rawStrings,maxStrLength:this.maxStrLength,maxBinLength:this.maxBinLength,maxArrayLength:this.maxArrayLength,maxMapLength:this.maxMapLength,maxExtLength:this.maxExtLength,keyDecoder:this.keyDecoder})}reinitializeState(){this.totalPos=0,this.headByte=ue,this.stack.reset()}setBuffer(e){const n=Be(e);this.bytes=n,this.view=new DataView(n.buffer,n.byteOffset,n.byteLength),this.pos=0}appendBuffer(e){if(this.headByte===ue&&!this.hasRemaining(1))this.setBuffer(e);else{const n=this.bytes.subarray(this.pos),i=Be(e),o=new Uint8Array(n.length+i.length);o.set(n),o.set(i,n.length),this.setBuffer(o)}}hasRemaining(e){return this.view.byteLength-this.pos>=e}createExtraByteError(e){const{view:n,pos:i}=this;return new RangeError(`Extra ${n.byteLength-i} of ${n.byteLength} byte(s) found at buffer[${e}]`)}decode(e){if(this.entered)return this.clone().decode(e);try{this.entered=!0,this.reinitializeState(),this.setBuffer(e);const n=this.doDecodeSync();if(this.hasRemaining(1))throw this.createExtraByteError(this.pos);return n}finally{this.entered=!1}}*decodeMulti(e){if(this.entered){yield*this.clone().decodeMulti(e);return}try{for(this.entered=!0,this.reinitializeState(),this.setBuffer(e);this.hasRemaining(1);)yield this.doDecodeSync()}finally{this.entered=!1}}async decodeAsync(e){if(this.entered)return this.clone().decodeAsync(e);try{this.entered=!0;let n=!1,i;for await(const p of e){if(n)throw this.entered=!1,this.createExtraByteError(this.totalPos);this.appendBuffer(p);try{i=this.doDecodeSync(),n=!0}catch(l){if(!(l instanceof RangeError))throw l}this.totalPos+=this.pos}if(n){if(this.hasRemaining(1))throw this.createExtraByteError(this.totalPos);return i}const{headByte:o,pos:s,totalPos:r}=this;throw new RangeError(`Insufficient data in parsing ${Ae(o)} at ${r} (${s} in the current buffer)`)}finally{this.entered=!1}}decodeArrayStream(e){return this.decodeMultiAsync(e,!0)}decodeStream(e){return this.decodeMultiAsync(e,!1)}async*decodeMultiAsync(e,n){if(this.entered){yield*this.clone().decodeMultiAsync(e,n);return}try{this.entered=!0;let i=n,o=-1;for await(const s of e){if(n&&o===0)throw this.createExtraByteError(this.totalPos);this.appendBuffer(s),i&&(o=this.readArraySize(),i=!1,this.complete());try{for(;yield this.doDecodeSync(),--o!==0;);}catch(r){if(!(r instanceof RangeError))throw r}this.totalPos+=this.pos}}finally{this.entered=!1}}doDecodeSync(){e:for(;;){const e=this.readHeadByte();let n;if(e>=224)n=e-256;else if(e<192)if(e<128)n=e;else if(e<144){const o=e-128;if(o!==0){this.pushMapState(o),this.complete();continue e}else n={}}else if(e<160){const o=e-144;if(o!==0){this.pushArrayState(o),this.complete();continue e}else n=[]}else{const o=e-160;n=this.decodeString(o,0)}else if(e===192)n=null;else if(e===194)n=!1;else if(e===195)n=!0;else if(e===202)n=this.readF32();else if(e===203)n=this.readF64();else if(e===204)n=this.readU8();else if(e===205)n=this.readU16();else if(e===206)n=this.readU32();else if(e===207)this.useBigInt64?n=this.readU64AsBigInt():n=this.readU64();else if(e===208)n=this.readI8();else if(e===209)n=this.readI16();else if(e===210)n=this.readI32();else if(e===211)this.useBigInt64?n=this.readI64AsBigInt():n=this.readI64();else if(e===217){const o=this.lookU8();n=this.decodeString(o,1)}else if(e===218){const o=this.lookU16();n=this.decodeString(o,2)}else if(e===219){const o=this.lookU32();n=this.decodeString(o,4)}else if(e===220){const o=this.readU16();if(o!==0){this.pushArrayState(o),this.complete();continue e}else n=[]}else if(e===221){const o=this.readU32();if(o!==0){this.pushArrayState(o),this.complete();continue e}else n=[]}else if(e===222){const o=this.readU16();if(o!==0){this.pushMapState(o),this.complete();continue e}else n={}}else if(e===223){const o=this.readU32();if(o!==0){this.pushMapState(o),this.complete();continue e}else n={}}else if(e===196){const o=this.lookU8();n=this.decodeBinary(o,1)}else if(e===197){const o=this.lookU16();n=this.decodeBinary(o,2)}else if(e===198){const o=this.lookU32();n=this.decodeBinary(o,4)}else if(e===212)n=this.decodeExtension(1,0);else if(e===213)n=this.decodeExtension(2,0);else if(e===214)n=this.decodeExtension(4,0);else if(e===215)n=this.decodeExtension(8,0);else if(e===216)n=this.decodeExtension(16,0);else if(e===199){const o=this.lookU8();n=this.decodeExtension(o,1)}else if(e===200){const o=this.lookU16();n=this.decodeExtension(o,2)}else if(e===201){const o=this.lookU32();n=this.decodeExtension(o,4)}else throw new V(`Unrecognized type byte: ${Ae(e)}`);this.complete();const i=this.stack;for(;i.length>0;){const o=i.top();if(o.type===ze)if(o.array[o.position]=n,o.position++,o.position===o.size)n=o.array,i.release(o);else continue e;else if(o.type===pe){if(n==="__proto__")throw new V("The key __proto__ is not allowed");o.key=this.mapKeyConverter(n),o.type=Ge;continue e}else if(o.map[o.key]=n,o.readCount++,o.readCount===o.size)n=o.map,i.release(o);else{o.key=null,o.type=pe;continue e}}return n}}readHeadByte(){return this.headByte===ue&&(this.headByte=this.readU8()),this.headByte}complete(){this.headByte=ue}readArraySize(){const e=this.readHeadByte();switch(e){case 220:return this.readU16();case 221:return this.readU32();default:{if(e<160)return e-144;throw new V(`Unrecognized array type byte: ${Ae(e)}`)}}}pushMapState(e){if(e>this.maxMapLength)throw new V(`Max length exceeded: map length (${e}) > maxMapLengthLength (${this.maxMapLength})`);this.stack.pushMapState(e)}pushArrayState(e){if(e>this.maxArrayLength)throw new V(`Max length exceeded: array length (${e}) > maxArrayLength (${this.maxArrayLength})`);this.stack.pushArrayState(e)}decodeString(e,n){return!this.rawStrings||this.stateIsMapKey()?this.decodeUtf8String(e,n):this.decodeBinary(e,n)}decodeUtf8String(e,n){var s;if(e>this.maxStrLength)throw new V(`Max length exceeded: UTF-8 byte length (${e}) > maxStrLength (${this.maxStrLength})`);if(this.bytes.byteLength<this.pos+n+e)throw Xe;const i=this.pos+n;let o;return this.stateIsMapKey()&&((s=this.keyDecoder)!=null&&s.canBeCached(e))?o=this.keyDecoder.decode(this.bytes,i,e):o=Ct(this.bytes,i,e),this.pos+=n+e,o}stateIsMapKey(){return this.stack.length>0?this.stack.top().type===pe:!1}decodeBinary(e,n){if(e>this.maxBinLength)throw new V(`Max length exceeded: bin length (${e}) > maxBinLength (${this.maxBinLength})`);if(!this.hasRemaining(e+n))throw Xe;const i=this.pos+n,o=this.bytes.subarray(i,i+e);return this.pos+=n+e,o}decodeExtension(e,n){if(e>this.maxExtLength)throw new V(`Max length exceeded: ext length (${e}) > maxExtLength (${this.maxExtLength})`);const i=this.view.getInt8(this.pos+n),o=this.decodeBinary(e,n+1);return this.extensionCodec.decode(o,i,this.context)}lookU8(){return this.view.getUint8(this.pos)}lookU16(){return this.view.getUint16(this.pos)}lookU32(){return this.view.getUint32(this.pos)}readU8(){const e=this.view.getUint8(this.pos);return this.pos++,e}readI8(){const e=this.view.getInt8(this.pos);return this.pos++,e}readU16(){const e=this.view.getUint16(this.pos);return this.pos+=2,e}readI16(){const e=this.view.getInt16(this.pos);return this.pos+=2,e}readU32(){const e=this.view.getUint32(this.pos);return this.pos+=4,e}readI32(){const e=this.view.getInt32(this.pos);return this.pos+=4,e}readU64(){const e=Ut(this.view,this.pos);return this.pos+=8,e}readI64(){const e=Ye(this.view,this.pos);return this.pos+=8,e}readU64AsBigInt(){const e=this.view.getBigUint64(this.pos);return this.pos+=8,e}readI64AsBigInt(){const e=this.view.getBigInt64(this.pos);return this.pos+=8,e}readF32(){const e=this.view.getFloat32(this.pos);return this.pos+=4,e}readF64(){const e=this.view.getFloat64(this.pos);return this.pos+=8,e}}function Gt(t,e){return new $e(e).decode(t)}const Xt=new Set(["auth","open","send","sync","history","read","typing","react","edit","delete","invoke","pubkey","ping","uploadPrekeys","fetchPrekey","assign","tag","note","agent_status","subscribe_inbox","unsubscribe_inbox"]);function Jt(t){return Xt.has(t.type)}function Re(t){return jt(t)}function Je(t){let e;try{e=Gt(t)}catch{return null}return typeof e!="object"||e===null||typeof e.type!="string"?null:e}class Qt{constructor(e){c(this,"conversationId");c(this,"state","");c(this,"version",0);c(this,"hasMoreHistory",!1);c(this,"lastReadByOthers",0);c(this,"assignedAgentId");c(this,"accent");c(this,"subject");c(this,"name");c(this,"e2e",!1);c(this,"offline",!1);c(this,"offlineMessage","");c(this,"launcherMessage",null);c(this,"preChat",null);c(this,"whiteLabel",!1);c(this,"typing",new Set);c(this,"online",new Set);c(this,"sentiment");c(this,"sentimentScore");c(this,"actions",[]);c(this,"byId",new Map);c(this,"keyByClient",new Map);c(this,"_maxSeq",0);c(this,"_sorted",null);this.me=e}messages(){return this._sorted||(this._sorted=[...this.byId.values()].sort((e,n)=>{const i=e.status==="pending",o=n.status==="pending";return i!==o?i?1:-1:i&&o?e.ts-n.ts:e.seq-n.seq})),this._sorted}visibleActions(){return this.actions.filter(e=>!e.availableInStates||e.availableInStates.includes(this.state))}actionById(e){return this.actions.find(n=>n.id===e)}highestSeq(){return this._maxSeq}addOptimistic(e,n){const i={id:e,conversationId:this.conversationId,seq:0,senderId:this.me,senderRole:"guest",content:n,ts:Date.now(),clientMsgId:e,status:"pending"};return this.byId.set(e,i),this.keyByClient.set(e,e),this._sorted=null,i}apply(e){var n;switch(e.type){case"opened":this.conversationId=e.conversation.id,this.state=e.conversation.state,e.subject&&(this.subject=e.subject);return;case"manifest":this.actions=e.actions,this.version=e.version,e.name&&(this.name=e.name),(n=e.theme)!=null&&n.accent&&(this.accent=e.theme.accent),e.e2e&&(this.e2e=!0),this.offline=e.offline===!0,this.offlineMessage=e.offlineMessage??"",e.launcherMessage&&(this.launcherMessage=e.launcherMessage),e.whiteLabel&&(this.whiteLabel=!0),e.preChat&&(this.preChat=e.preChat);return;case"message":this.upsert({...e.message});return;case"ack":{const i=this.keyByClient.get(e.clientMsgId),o=i?this.byId.get(i):void 0;if(o&&i){this.byId.delete(i);const s={...o,id:e.messageId,seq:e.seq,ts:e.ts,status:"sent"};this.byId.set(e.messageId,s),this.keyByClient.set(e.clientMsgId,e.messageId),e.seq>this._maxSeq&&(this._maxSeq=e.seq)}this._sorted=null;return}case"delivered":this.markOwnStatus(e.seq,"delivered");return;case"read":e.by!==this.me&&(this.lastReadByOthers=Math.max(this.lastReadByOthers,e.seq),this.markOwnStatus(e.seq,"read"));return;case"sync":for(const i of e.messages)this.upsert({...i});return;case"history":for(const i of e.messages)this.upsert({...i});this.hasMoreHistory=e.hasMore;return;case"typing":e.userId!==this.me&&(e.isTyping?this.typing.add(e.userId):this.typing.delete(e.userId));return;case"reaction":{const i=this.byId.get(e.messageId);if(!i)return;const o={...i.reactions??{}},s=(o[e.emoji]??[]).filter(r=>r!==e.by);e.removed||s.push(e.by),s.length?o[e.emoji]=s:delete o[e.emoji],this.byId.set(e.messageId,{...i,reactions:o}),this._sorted=null;return}case"edited":{const i=this.byId.get(e.messageId);i&&(this.byId.set(e.messageId,{...i,content:e.content,editedAt:e.editedAt}),this._sorted=null);return}case"deleted":{const i=this.byId.get(e.messageId);i&&(this.byId.set(e.messageId,{...i,deletedAt:e.ts}),this._sorted=null);return}case"state":this.state=e.state;return;case"assigned":this.assignedAgentId=e.agentId??void 0;return;case"presence":e.status==="online"?this.online.add(e.userId):this.online.delete(e.userId);return;case"subjectState":case"invoked":case"authed":case"error":case"pong":return;case"sentiment":this.sentiment=e.label,this.sentimentScore=e.score;return;default:return}}upsert(e){const n=this.byId.get(e.id);this.byId.set(e.id,n?{...n,...e}:e),e.seq>this._maxSeq&&(this._maxSeq=e.seq),this._sorted=null}markOwnStatus(e,n){const i=Qe(n);let o=!1;for(const[s,r]of this.byId)r.senderId!==this.me||r.seq<=0||r.seq>e||Qe(r.status)>=i||(this.byId.set(s,{...r,status:n}),o=!0);o&&(this._sorted=null)}}function Qe(t){switch(t){case"read":return 3;case"delivered":return 2;case"sent":return 1;default:return 0}}class Zt{constructor(e){c(this,"socket",null);c(this,"state","idle");c(this,"authed",!1);c(this,"everAuthed",!1);c(this,"attempt",0);c(this,"outbox",[]);c(this,"stopped",!1);c(this,"timer",null);c(this,"refreshing",!1);this.opts=e}connect(){var i,o;if(this.state==="connecting"||this.state==="open")return;this.stopped=!1,this.state="connecting",this.authed=!1,(o=(i=this.opts).onStatusChange)==null||o.call(i,this.attempt>0?"reconnecting":"connecting");const n=(this.opts.socketFactory??nn)(this.opts.url);n.binaryType="arraybuffer",this.socket=n,n.onopen=()=>{this.raw({type:"auth",token:this.opts.token})},n.onmessage=s=>{const r=Je(new Uint8Array(s.data));!r||Jt(r)||this.handle(r)},n.onclose=()=>this.onClosed(),n.onerror=()=>{try{n.close()}catch{}}}send(e){if(this.state==="open"&&this.authed){this.raw(e);return}this.queue(e)}pendingCount(){return this.outbox.length}close(){var e;this.stopped=!0,this.timer&&clearTimeout(this.timer),this.state="closed";try{(e=this.socket)==null||e.close()}catch{}}handle(e){var n,i,o,s;if(e.type==="authed"&&(this.attempt=0,this.state="open",this.authed=!0,this.everAuthed=!0,(i=(n=this.opts).onStatusChange)==null||i.call(n,"open"),this.raw(this.opts.open),this.opts.open.type!=="open"&&this.flush()),e.type==="opened"&&(this.raw({type:"sync",conversationId:e.conversation.id,sinceSeq:this.opts.getCursor()}),this.flush(e.conversation.id)),e.type==="error"&&en.has(e.code)){if(e.code==="UNAUTHORIZED"&&this.opts.refreshToken&&!this.refreshing){this.refreshing=!0,(s=(o=this.opts).onStatusChange)==null||s.call(o,"reconnecting","Renewing session…"),this.opts.refreshToken().then(r=>{var p;if(this.refreshing=!1,!r){this.fatal(e);return}this.opts.token=r;try{(p=this.socket)==null||p.close()}catch{}}).catch(()=>{this.refreshing=!1,this.fatal(e)});return}this.fatal(e);return}this.opts.onFrame(e)}fatal(e){var n,i,o;this.stopped=!0;try{(n=this.socket)==null||n.close()}catch{}this.state="closed",(o=(i=this.opts).onStatusChange)==null||o.call(i,"error",tn(e.code)),this.opts.onFrame(e)}flush(e){const n=this.outbox;this.outbox=[];for(const i of n)this.raw(e&&i.type==="send"&&i.conversationId!==e?{...i,conversationId:e}:i)}queue(e){const n=this.opts.maxOutbox??1e3;this.outbox.length>=n&&(this.outbox=this.outbox.slice(this.outbox.length-(n>>1))),this.outbox.push(e)}raw(e){if(!this.socket){this.queue(e);return}try{this.socket.send(Re(e))}catch{this.queue(e)}}onClosed(){var o,s;if(this.authed=!1,this.socket=null,this.stopped){this.state="closed";return}this.state="idle";const e=this.opts.backoffBaseMs??500,n=this.opts.backoffMaxMs??15e3,i=Math.min(n,e*2**this.attempt)*(.5+Math.random()*.5);this.attempt++,this.attempt>=3&&!this.everAuthed&&((s=(o=this.opts).onStatusChange)==null||s.call(o,"reconnecting","Can't reach chat — retrying…")),this.timer=setTimeout(()=>this.connect(),i)}}const en=new Set(["UNAUTHORIZED"]);function tn(t){switch(t){case"UNAUTHORIZED":return"Chat unavailable — sign-in/token was rejected";default:return"Chat unavailable"}}function nn(t){return new WebSocket(t)}const Ze=200,on=7*864e5;class sn{constructor(e){c(this,"key");this.key=`ocw_outbox_${e}`}load(){try{const e=localStorage.getItem(this.key);if(!e)return[];const n=JSON.parse(e),i=Date.now()-on,o=n.filter(s=>s.ts>=i);return o.length!==n.length&&this.save(o),o}catch{return[]}}add(e){try{const n=this.load();n.push(e),this.save(n.length>Ze?n.slice(n.length-Ze):n)}catch{}}remove(e){try{const n=this.load().filter(i=>i.clientMsgId!==e);this.save(n)}catch{}}save(e){try{localStorage.setItem(this.key,JSON.stringify(e))}catch{}}}const rn={accent:"#6c5ce7",accent2:"#4c6fff",bg:"#f4f3fb",card:"#fff",tint:"#eeecfb",line:"#e6e2f5",ink:"#221d3a",mut:"#8f8aa8",onaccent:"#fff",rowhover:"#e7e3f8",shadow:"0 12px 32px rgba(108,92,231,.14)"},an={accent:"#a99cf2",accent2:"#6f8cff",bg:"#221d3a",card:"#2b2550",tint:"#2f2853",line:"#3a3363",ink:"#eceafc",mut:"#9b93c9",onaccent:"#221d3a",rowhover:"#39325e",shadow:"0 12px 32px rgba(0,0,0,.4)"},cn="'Nunito',-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif";function et(t,e){return Object.entries(e).map(([n,i])=>`--${t}-${n}:${i};`).join(" ")}function tt(t){return`${et(t,rn)} --${t}-fb:${cn}; --${t}-fh:'Baloo 2',var(--${t}-fb);`}function ve(t){return et(t,an)}const ln=`
2
2
  .ocw { ${tt("ocw")}
3
3
  position:relative;
4
- display:flex; flex-direction:column; height:100%; min-height:320px; background:var(--ocw-bg);
4
+ display:flex; flex-direction:column; height:100%; min-height:320px; max-width:100%; background:var(--ocw-bg);
5
5
  font-family:var(--ocw-fb); color:var(--ocw-ink); overflow:hidden; }
6
+ .ocw, .ocw *, .ocw *::before, .ocw *::after { box-sizing:border-box; }
7
+ .ocw input, .ocw textarea, .ocw select, .ocw button { font-family:inherit; }
8
+ .ocw a, .ocw .ocw-bubble { overflow-wrap:anywhere; word-break:break-word; }
6
9
  @media (prefers-color-scheme: dark) { .ocw[data-theme="auto"] { ${ve("ocw")} } }
7
10
  .ocw[data-theme="dark"] { ${ve("ocw")} }
8
11
  /* ── Responsive sizing ──────────────────────────────────────────────────────
@@ -50,7 +53,7 @@ var RelayEmbedLite=function(te){"use strict";var Dn=Object.defineProperty;var Nn
50
53
  .ocw-chiprow { display:flex; gap:8px; padding:10px 12px; background:var(--ocw-card); border-bottom:1px solid var(--ocw-line); overflow-x:auto; }
51
54
  .ocw-chip { flex:none; display:flex; align-items:center; gap:6px; border:none; background:var(--ocw-tint); color:var(--ocw-accent); border-radius:999px; padding:7px 13px; font-size:12px; font-weight:600; cursor:pointer; white-space:nowrap; }
52
55
  .ocw-chip:hover { border-color:var(--ocw-accent); color:var(--ocw-accent); }
53
- .ocw-scroll { flex:1; min-height:0; overflow-y:auto; padding:16px 14px; display:flex; flex-direction:column; gap:10px; }
56
+ .ocw-scroll { flex:1; min-height:0; overflow-y:auto; overflow-x:hidden; padding:16px 14px; display:flex; flex-direction:column; gap:10px; }
54
57
  .ocw-subject { background:var(--ocw-tint); border:none; border-radius:16px; padding:10px 12px; }
55
58
  .ocw-subject-title { font-family:var(--ocw-fh); font-weight:600; font-size:13px; margin-bottom:2px; }
56
59
  .ocw-subject-sub { color:var(--ocw-mut); font-size:10.5px; margin-bottom:6px; }
@@ -152,8 +155,9 @@ var RelayEmbedLite=function(te){"use strict";var Dn=Object.defineProperty;var Nn
152
155
  .ocw-form-title { font-weight:700; font-size:14px; margin-bottom:8px; }
153
156
  .ocw-form-row { display:flex; flex-direction:column; gap:3px; margin-bottom:8px; }
154
157
  .ocw-form-lbl { font-size:12px; color:var(--ocw-mut); }
155
- .ocw-form-input { border:1px solid var(--ocw-line); border-radius:9px; padding:9px 11px; font:inherit; font-size:14px; outline:none; }
158
+ .ocw-form-input { width:100%; box-sizing:border-box; border:1px solid var(--ocw-line); border-radius:9px; padding:9px 11px; font:inherit; font-size:14px; outline:none; background:var(--ocw-card); color:var(--ocw-ink); appearance:none; }
156
159
  .ocw-form-input:focus { border-color:var(--ocw-accent); }
160
+ .ocw-form-input::placeholder { color:var(--ocw-mut); }
157
161
  .ocw-form-actions { display:flex; justify-content:flex-end; gap:8px; margin-top:4px; }
158
162
  .ocw-form-cancel { background:none; border:none; color:var(--ocw-mut); font-size:13px; cursor:pointer; padding:8px 10px; }
159
163
  .ocw-form-submit { background:var(--ocw-accent); color:#fff; border:none; border-radius:999px; padding:8px 18px; font-size:13px; font-weight:600; cursor:pointer; }